OBJMTLLoader 未渲染纹理 [英] Texture not being rendered by OBJMTLLoader

查看:29
本文介绍了OBJMTLLoader 未渲染纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 3d 模型,带有来自 Blender 的 OBJ/MTL/JPG 格式的纹理.但是我无法使用 Three,js 正确渲染.

I have a 3d model with texture that comes from Blender in OBJ/MTL/JPG format. But I cannot get this to render correctly with Three,js.

  • 查看器代码与three.js 网站上的示例相同.我只更改了 OBJ 和 MTL 文件的路径.
  • 我很确定所有文件都在正确的位置.加载了OBJ和MTL文件,MTL文件中JPG的路径是相对于MTL文件的正确路径(如果我改了会有404).
  • The viewer code is identical to the example on the three.js website. I have only changed the paths to the OBJ and MTL files.
  • I'm pretty sure all files are in the correct place. The OBJ and MTL files are loaded, and the path to the JPG in the MTL file is the correct path relative to the MTL file (there is a 404 if I change it).

结果是一个黑色模型.可以在此处找到我的示例.谁能让我摆脱痛苦并告诉我我做错了什么?

Yet the result is a black model. My example can be found here. Can anyone put me out of my misery and tell me what I've done wrong?

为了便于阅读:

推荐答案

您需要了解 MTL 文件中的参数代表什么.你的漫反射和环境反射是黑色的——不好.将它们更改为合理的值,如下所示:

You need to understand what the parameters in your MTL file represent. Your diffuse reflectance and ambient reflectance are black -- not good. Change them to something reasonable, like so:

Kd 1.000 1.000 1.000     # white
Ka 1.000 1.000 1.000     # white

或者像这样修改你的加载器回调函数:

Or modify your loader callback function like so:

node.material.color.setRGB( 1, 1, 1 );
node.material.ambient.setRGB( 1, 1, 1 ); // no longer required (see Note)

<小时>

注意:在three.js中去掉了material的ambient属性,现在只需要设置颜色即可.


Note: The ambient property of material has been removed from three.js, so you now only need to set the color.

three.js r.71

three.js r.71

这篇关于OBJMTLLoader 未渲染纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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