How to instantiate shape from raw shape data (new Shape(othershape.extractPoints())

Hi. I’m trying to cache shapes in storage as JSON so that my frontend doesn’t have to calculate everything from the base data each time.

To get the JSON for storage, I’m doing …


…and then saving it. But when I go to do…

var recreatedShape = new THREE.Shape(shapeDataFromStorage);

…I am getting errors like…

Uncaught TypeError: Cannot read property 'x' of undefined
    at Shape.setFromPoints (three.js:26535)

What is the correct way to do this save-to/recover-from JSON process?

I could have just asked “how do you serialize and deserialize a shape to/from JSON”?

But you get my point. Help appreciated.

Check in console what is into shapeDataFromStorage. Maybe there is no “x”.

Thanks. I figured it out. The object is

{ shape: (shape), holes:(holes) }

And I was reading the top level object only.