如何导出并导入一个场景与三个JS? [英] How to export and then import a scene with Three JS?

查看:144
本文介绍了如何导出并导入一个场景与三个JS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复杂的3D场景,搭配三个JS和很多Javascript代码。我需要将这个场景作为一个文件导出,然后使用简单的ThreeJS场景播放器在我的网站上使用它。



我已经尝试过ObjectExporter和SceneExporter。但是仍然无法理解如何将这些数据加载到ThreeJS环境中。



正确的方法是什么?

解决方案

SceneExporter不导出通过JSON加载的场景对象
ObjectExporter无法导出纹理



链接脚本

  ObjectExporter.js 
GeometryExporter.js
BufferGeometryExporter.js
MaterialExporter。 js

函数exportScene(save,type){
exporter = new THREE.ObjectExporter;
var obj = exporter.parse(scene);
var json = JSON.stringify(obj);
log(json);
}

将json保存到文件ext .json
https://github.com/mrdoob/three.js/tree/master / examples / js / exporters
https: //github.com/mrdoob/three.js/tree/master/editor
默认导入编辑器菜单 - >文件 - >导入
我正在努力添加能力导出纹理


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?

解决方案

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

这篇关于如何导出并导入一个场景与三个JS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆