I have a complex 3D scene builded with Three JS and a lot of Javascript code. I need to export this scene as one file and then use it on my site with a simple ThreeJS scene player.
I have tried ObjectExporter and SceneExporter. But still can not understand how to load this data back into ThreeJS environment.
What is the right way to do this?
On this page, you'll see a single Three. js scene. If you hit the p key, the current state will be saved as a new image, which you can then download normally.
Implementation of Export in JavaScript Using the keyword “export” we can export anything like a variable, function, or class to any other file. What we have to do is, simply write the “export” keyword prior to that variable, function, class, or anything we want to export.
With the help of ES6, we can create modules in JavaScript. In a module, there can be classes, functions, variables, and objects as well. To make all these available in another file, we can use export and import. The export and import are the keywords used for exporting and importing one or more members in a module.
SceneExporter does not export the scene objects that are loaded through JSON ObjectExporter can't exports texture
link scripts
ObjectExporter.js
GeometryExporter.js
BufferGeometryExporter.js
MaterialExporter.js
function exportScene(save, type) {
exporter = new THREE.ObjectExporter;
var obj = exporter.parse(scene);
var json = JSON.stringify(obj);
log(json);
}
save json to file ext .json Library taken from https://github.com/mrdoob/three.js/tree/master/examples/js/exporters Loader taken from https://github.com/mrdoob/three.js/tree/master/editor default import in editor menu->file->import I'm working on that to add the ability to export texture
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With