Using Three JS exporter and JSON loader correctly

99封情书 提交于 2019-12-25 08:59:43

问题


EDIT: Originally models didn't even load but I fixed that so now the question is how to export models into js file with textures included in the file.

The ThreeJSExporter.ms exporter is located in three.js-master\utils\exporters\max, designed to export 3d models from 3ds max to *.js files. It adds to 3ds max a window (see screenshot) which exports into *.js.

ThreeJSExporter.ms window:

As the window says it exports to three.js ASCII JSON format. For some reason these exported files don't have textures included. Diffuse color in them includes only color info, no textures in the files.

I load my *.js models this way:

var loader = new THREE.JSONLoader(), aMesh;
        loader.load("resources/models/model_flipYZ.js", function (geometry, materials) {
            aMesh = new THREE.Mesh(geometry, materials[0]);
            scene.add(aMesh);
        });

Question

1) The js model file does not contain the texture. So the model is displayed but no textures at all. How to include the texture in the js model?


回答1:


I found the answer myself. It is required to render all textures in 3DS Max including alpha, background, procedural textures and whatever you have there into a flat texture. So in material editor use Utilities - Render Map for your textures or for a composite texture if you have it, render it into a flat image and save. Then make a new material, assign this new flat texture to it, assign it to the model and then export this model to a *.js file.



来源:https://stackoverflow.com/questions/43112309/using-three-js-exporter-and-json-loader-correctly

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