WebGL 在three.js 中使用OBJMTLoader 导入模型失败 [英] WebGL importing models using the OBJMTLoader in three.js fails

查看:68
本文介绍了WebGL 在three.js 中使用OBJMTLoader 导入模型失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 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.

感谢任何帮助

推荐答案

问题似乎是由于模型附带的 .TGA 文件造成的.显然,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.

这篇关于WebGL 在three.js 中使用OBJMTLoader 导入模型失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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