1
votes

I noticed the .mtl file that gets exported along with my .obj exports isn't something I'm required to directly load when using Three.js, but I was wondering if the library loads it silently if it can find it in the same directory that it pulls the .obj from. I noticed in a directory where I didnt include the .mtls, the textures didn't map to my models, and I'm trying to understand what importance they have to Three.js if any. Does three.js load the .mtl file silently? Are they necessary at all for mapping textures?

1

1 Answers

2
votes

Does three.js load the .mtl file silently?

No. If you just use OBJLoader, any related MTL files are ignored and default materials are applied. You have to use MTLLoader like demonstrated in the following example to load any material definitions. As you can see in the source code, you essentially perform two request. You first load the MTL and then the OBJ file.

https://threejs.org/examples/webgl_loader_obj_mtl.html

Are they necessary at all for mapping textures?

No, texture coordinates are defined in the OBJ file. So you can load the OBJ and apply a texture manually after loading like shown here:

https://threejs.org/examples/webgl_loader_obj.html