MTL and OBJ and JPG problems with OBJLoader

Basically what was mentioned here:

All I did was to change the model loaded in this:

So the resulting code is:

var onLoadMtl = function ( materials ) {
  objLoader.setModelName( modelName );
  objLoader.setMaterials( materials );
  objLoader.setLogging( true, true );
  objLoader.load( 'models/obj/my_scans/Model.obj', callbackOnLoad, null, null, null, false );
  objLoader.loadMtl( 'models/obj/my_scans/Model.mtl', null, onLoadMtl );

But the model will not load. The model will not show up, and no errors come up…

Any ideas ?

PS: The model loads fine in MeshLab

Can you share the model? (570.1 KB)

There it is

You’ve ran into the following issue (it’s about the ambiguity of the tr statement):

You can solve the issue by creating your MTLLoader like so. This will invert the semantic of the transparency definition.

const materialLoader = new THREE.MTLLoader();
materialLoader.setMaterialOptions( { invertTrProperty: true } )

Result with OBJLoader:


BTW: One more reason to use glTF instead of OBJ. More information about this topic:

Thanks! It worked. I was also using an outdated version of the loader.

Hello, my 3d model is composed of obj file and texture (MTL + JPG), I don’t know how to load JPG.My model is shown in black.Can you share your code?Thank you very much!

I’ve already shared the code for loading MTL (with textures) here:

Have you actually tried this code? If so, please share your current work of progress as a git repository.

image image
Thank you very much for your careful answer. By changing the value in the MTL file, my model has texture, but the back of my model is still black. I think it may be the problem of setting the light source, but I don’t know how to adjust it.

You are just adding an instance of SpotLight right now. Try to add an ambient light next to your spot light like so:

var ambientLight = new THREE.AmbientLight( 0x404040 ); // soft white light
scene.add( ambientLight );

Thank you very much for your answer. It was very effective and helpful.And then I’m going to have to adjust the axes, hopefully to fit the model.