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: