javascript 3DS Max => ThreeJs。导出场景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20128767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
3DS Max => ThreeJs. Export scene
提问by AndrRem
I have a scene in 3ds Max that I want to export in threejs. The problem is that the textures don't seem to appear in threejs and objects are deformed.
我在 3ds Max 中有一个场景,我想在 Threejs 中导出。问题是在threejs中似乎没有出现纹理并且对象变形了。
That's my workflow (I'm new to threejs so there must be some wrong steps):
这是我的工作流程(我是 Threejs 的新手,所以一定有一些错误的步骤):
Export from 3ds Max into .obj + .mtl (the objects are simple meshes and the materials are standard ones)
Import into Blender 2.66 for using io_mesh_threejs to convert the scene into JavaScript(since I wasn't able to find a suitable converter for 3ds Max).
After exporting it I was unable to see my scene in threejs but if I export it without materials it's OK.
从 3ds Max 导出到 .obj + .mtl(对象是简单的网格,材质是标准的)
导入 Blender 2.66 以使用 io_mesh_threejs 将场景转换为 JavaScript(因为我找不到适合 3ds Max 的转换器)。
导出后,我无法在 Threejs 中看到我的场景,但是如果我在没有材质的情况下导出它,那就没问题了。
Also I have found out that the coordinate system is different which results in unpredictable scene placement and interactivity.
我还发现坐标系不同,这会导致不可预测的场景放置和交互性。
I'm wondering if you have any suggestions on how to export my scene into JavaScript directly from 3ds Max?
我想知道您是否对如何将我的场景直接从 3ds Max 导出到 JavaScript 有任何建议?
回答by Slider
You can use A3dsViewerto export 3ds models into the three.jsand directly preview the result in the browser.
可以使用A3dsViewer将3ds模型导出到three.js中,直接在浏览器中预览结果。
回答by Darius Miliauskas
Use "ThreeJSExporter" script, actually, just copy the script code and run the script inside 3dsMax (the code https://github.com/timoxley/threejs/blob/master/utils/exporters/max/ThreeJSExporter.ms) since there is possibility to run .ms files there without any installations or command lines. Then you will get .js file (json), check that file manually to be sure to avoid the character like "#" in the arrays (I spent a lot of hours while found this source of errors), these values are generated sometimes while the script recalculated the data, I changed these values by numbers (the occurrences of "#" are not necessary to change in the strings :-)), and then just use loaders of THREE.js.
使用“ThreeJSExporter”脚本,实际上,只需复制脚本代码并在 3dsMax 中运行脚本(代码https://github.com/timoxley/threejs/blob/master/utils/exporters/max/ThreeJSExporter.ms),因为那里可以在没有任何安装或命令行的情况下运行 .ms 文件。然后你会得到 .js 文件(json),手动检查该文件以确保避免在数组中出现像“#”这样的字符(我花了很多时间发现这个错误源),这些值有时会生成脚本重新计算了数据,我按数字更改了这些值(“#”的出现不需要在字符串中更改:-)),然后只使用 THREE.js 的加载程序。
Here is the code:
这是代码:
var loader = new THREE.JSONLoader();
loader.load( 'js/file.js', function ( geometry ) {
var mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial({color: 0x07624a}) );
mesh.position.x =0;
mesh.position.y =0;
mesh.position.z =0;
scene.add( mesh );
});
Here it is in the scene of WebGL Render. Between, I found that OBJLoader is recommended instead of JSONLoader but JSONLoader worked for me much better with THREE.js r71.
这是在WebGL Render的场景中。在这两者之间,我发现推荐使用 OBJLoader 而不是 JSONLoader,但 JSONLoader 使用 THREE.js r71 对我来说效果更好。
Source for similar approach: http://bkcore.com/blog/3d/webgl-three-js-workflow-tips.html
类似方法的来源:http: //bkcore.com/blog/3d/webgl-three-js-workflow-tips.html