How to export and then import a scene with Three JS?

前提是你 提交于 2020-02-01 01:43:30

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/17516961/how-to-export-and-then-import-a-scene-with-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!