Texture not being rendered by OBJMTLLoader

五迷三道 提交于 2019-12-11 06:19:43

问题


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.

  • 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?

For ease of reading:

  • The OBJ file
  • The MTL file
  • The JPG file

回答1:


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)

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



来源:https://stackoverflow.com/questions/24311026/texture-not-being-rendered-by-objmtlloader

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