Reputation: 1253
I have seen loaders for objects and other things but nothing for an entire scene. Is it possible to save and load three.js scenes?
Upvotes: 3
Views: 10192
Reputation: 217
looks like scene exporter is deprecated. There is now a GLTFExporter
Upvotes: 3
Reputation: 1903
Yes you can use the THREE.SceneLoader for this:
To export use this:
var exporter = new THREE.SceneExporter();
var sceneJson = JSON.stringify(exporter.parse(scene));
To import use this:
var sceneLoader = new THREE.SceneLoader();
sceneLoader.parse(JSON.parse(json), function (e) {scene = e.scene;}, '.');
For an example see: https://github.com/josdirksen/learning-threejs/blob/master/chapter-08/04-load-save-json-scene.html
Source files for loader and exporters are here:
Upvotes: 7