How can I save and load workspace in threejs?

Hi everyone, I am building my own 3d model editor with threejs.
I can create a new 3d object or import existing models in the type of gltf, obj, ifc, etc.
And I am going to save workspace in a json format or something else.
I tried with toJSON, gltf exporter but none of them was helpful.
How can I solve this problem?

What do you mean with ā€œnot helpfulā€? In general, the JSON format of three.js is ideal for such a use case. It is also used by the three.js editor.

1 Like

Thanks for quick reply.
Here is what I did with toJSON and ObjectLoader.

//exporting
var sceneData = this.scene.toJSON();

//importing
var loader = new THREE.ObjectLoader();
loader.load(
ā€œscene.jsonā€,
function (scene) {
self.scene = scene;
},
function (xhr) {
console.log((xhr.loaded / xhr.total * 100) + ā€˜% loadedā€™);
},
function (err) {
console.error(ā€˜An error happenedā€™);
}
);

And I could get this result with unexpected error.

Origin object:
image

Loaded object:
image

Error:
image

Hi Zap, I am new to threejs myself and I am not a programerā€¦ But I do have 20+ years of modeling experience in Maya, 3DSmax, ZBrush, and Blenderā€¦ If you ever need a beta tester let me know! Good luck with Save and Loadā€¦

Sure things. :slight_smile: