Loading MTL having multiple mtl entries

I have a MeshOBJ having one Obj file, Mtl File and Jpg texture file. This Mtl file has multiple Mtl entries. My current code is working fine if the Mtl file has a single entry but in case of multiple entries, it’s failing.

Agra UPRSAC.mtl (185 Bytes)

I am using MTLLoader and OBJLoader of threejs.

Please help me with some code snippet to resolve this issue or share any article reference that I could refer to get an idea.

While someone with experience with MTL provides a solution, you may try the following: load the model (and its materials) in Blender, export the model in another format (GLTF/GLB, for example). Does the problem occur when you use this GLTF/GLB file?

Hi Pavel, Well our platform only expects MTL/OBJ/JPG for 3D model rendering. We are not using any other format to do the same. So please help me to know how to load multiple mtl entries to solve my problem. Does ThreeJs provide any other MTL Loader which supports this?

When I try the Three.js models from the examples/models/obj/female02 and examples/models/obj/male02, they load fine. Both are OBJ models with MTL materials. The female material has 6 entries, the male material has 5 entries.

Could you try your current code with these models? If it works, then the problem is with your OBJ/MTL files. If it does not work, the problem is with your code.

Here is a snapshot of these two models, each with a material with multiple entries:

Hi Pavel, I have checked the male02 MTL file and it has multiple materials inside. This is exactly the problem where my code is not working you can say. For single-material, my code is working fine but if the MTL file has multiple material entries then it is not working. I am new to ThreeJS so if you could share a code snippet or any article reference which I could refer to solve my issue? This will be a great help to me.

My references are the Three.js online documentation and examples. The code that I used is:

new THREE.MTLLoader( ).load( 'male02.mtl', function( materials ) {
	var loader = new THREE.OBJLoader( );
		loader.setMaterials( materials );
		loader.load( 'male02.obj', function( object ) {
			scene.add( object );
} );

Similar code can be found in the official Three.js example for using OBJLoader and MTLLoader:

OBJLoader + MTLLoader

Good luck with your project.