Loading models problem (OBJ + MTL or FBX)

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 :wink:

Am I missing something obvious? Can anyone help me out with this?

Got a little further here. Seeing the MTL file, the “Kd” and “Ka” were a bunch of zeroes - changed that into “1.00” and now its showing.

Still - the character helmet should be translucid, and its showing as opaque. And why it doesn’t show all black in Maya…? Still investigating… :confused:

And accordingly with this page, the -mm in the MTL file is part of the spec - and its causing Three.JS to fail to load the file.

Hmmm. I think one of the problems is that it completely ignores the "ilum’ key, which determines the “illumination model” to be used?

Hi. My old test scene with 3dMax file. http://js.otrisovano.ru/tests/14exportobj/1.zip
If it help…
I always after export change the values in the MTL file in the direction of increase

Tried converting the same model into FBX and loading it… even with textures embedded, it can’t find them.

Making things even worse: I just made myself a very simple and basic model (I’m no modeller), exported it from 3d max in FBX format, and the loader seems to be stuck.

Edit: Apparently the FBX format I was using (on my own model - not the OBJ converted one…) was too old. Using the FBX converter from autodesk has helped a bit. Still, no textures at the file, its all white :frowning:
(Using the converter’s own viewer, I can see the FBX fine, textures and all)

This is the model:
ninja.fbx (150.5 KB)

Apparently THREE.JS trying to load the texture from disk, not from the file…?!
Edit: CONFIRMED. If I place the texture in the same path as the FBX, the model shows textured.
(The FBX has the texture embedded into itself, so why is it loading from outside the model?)

Are you using the latest version of the FBXLoader? This sounds like a bug that I fixed a while back.

Weird. I guess I somehow must have taken one of the old versions available online.

using this one: https://threejs.org/examples/js/loaders/FBXLoader.js
it loaded my model! Phew :slight_smile:

1 Like