Hi everyone!
I’m new over here, but I’ve been working with Three.js for the last couple of months. Now I finally found something that I couldn’t solve myself, which is loading an OBJ model and its MTL material. I hope you guys can help me with it!
What I have is a model + mtl + textures exported from Maya (I didn’t make it).
The first problem I encountered was that Three.js was giving me errors on loading the MTL file. This one I could find the problem: one of the materials had the following line:
newmtl phong2SG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd -mm 0 0.52349 Textura sem grid.png
Ni 0.01
Ks 0.00 0.00 0.00
Ns 0.00
Notice the “-mm (number) (number)” before the actual texture name on map_Kd. That was preventing the file from loading (I have no clue what it does… but removing it, it loads)
I used the mtl + obj loader example code to try to load the mesh and textures - but all I get is a black model on screen.
Using my own code to be able to debug stuff, it doesn’t return any error on loading either the material or the model.
Dumping the material var into the console, I get:
“materials sucessfully loaded!” Object { baseUrl: “./assets/models/”, options: undefined, materialsInfo: Object, materials: Object, materialsArray: Array[0], nameLookup: Object, side: 0, wrap: 1000, crossOrigin: “anonymous”, manager: Object }
The materialsArray with 0 length strikes me as odd - but the materials appears to be loading correctly. Below what the console shows me about the loaded materials:
The OBJ model also seems to load correctly, the mesh is displayed on screen - but all gray (if I don’t load any material) or all black (if I do load the mtl). Texture coords are okay: if I manually apply a texture, it shows correctly.
The material seems to be correctly assigned to the OBJ: its children all have a material (with a name) applied.
Textures, OBJ and MTL are all in the same path as the “male02” in the sample.
This is the model, mtl and textures - it is copyrighted by the company I work for, so please don’t use it anywhere
Am I missing something obvious? Can anyone help me out with this?