在Three.js中使用OBJMTLoader导入WebGL模型失败 [英] WebGL importing models using the OBJMTLoader in three.js fails
问题描述
尝试使用three.js将以下模型导入WebGL时遇到一些问题:
I am having some problems trying to import the following model into WebGL using three.js:
http://tf3dm.com/3d-model/vanille-99084.html
我已经使用three.js附带的转换器将obj文件转换为JSON,并且在使用JSON Loader时模型可以正常工作.但是,当尝试使用.mtl文件中的纹理加载模型时,OBJMTLOader失败.
I've converted the obj file to JSON using the converter that comes with three.js and the model works fine when using the JSON Loader. However, when trying to load the model with the textures from the .mtl file the OBJMTLOader fails.
我使用以下示例,只是将路径替换为文件路径:
I am using the following example and just replaced the paths with the paths to my files:
https://github.com/mrdoob/three. js/blob/master/examples/webgl_loader_obj_mtl.html
更新:
我取得了一些进步.由于某种原因,我认为我需要导入JSON转换的OBJ而不是obj文件本身.因此,既然我已经引用了正确的.obj文件,就可以正确导入模型.但是,纹理仍未加载.目前,整个模型/网格都是黑色的.
I've made a bit of progress. For some reason I thought that I need to import the JSON converted OBJ rather than the obj file itself. So now that I've referenced the correct .obj file the model is imported correctly. However, the textures are still not loaded. Currently the whole model/mesh is just black.
任何帮助表示赞赏
推荐答案
看来,问题出在模型中.显然,Threejs无法解析TGA文件.因此,解决方案是使用Photoshop将TGA文件转换为纯PNG,然后更新.mtl文件以引用PNG而不是TGA文件.
It appears that the problem was due to the .TGA files comming with the models. Apparently, threejs can't parse TGA files. So the solution was to convert the TGA files to plain PNGs using Photoshop and then update the .mtl file to reference the PNGs rather than the TGA files.
这篇关于在Three.js中使用OBJMTLoader导入WebGL模型失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!