I've being trying to load some 3D models found on the web in my THREE.scene. I've followed basic tutorials, handled my light and cameras well and it works perfectly for some objects:
function loadObject(path, modelName)
{
var mtlLoader2 = new THREE.MTLLoader();
mtlLoader2.setPath( path );
mtlLoader2.load(modelName+'.mtl', function( material )
{
material.preload();
var objLoader2 = new THREE.OBJLoader();
objLoader2.setPath( path );
objLoader2.setMaterials( material );
material.side = THREE.BackSide;
objLoader2.load( modelName+'.obj', function ( mesh )
{
mesh.name=modelName;
var axisHelper = new THREE.AxisHelper(1);
axisHelper.visible=true;
mesh.add(axisHelper);
scene.add( mesh );
console.log('Loaded '+modelName);
});
});
}
I also call an animate function to render regularly:
function animate()
{
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
Unfortunately, some other objects disappear (without any error) as soon as I apply the material:
objLoader2.setMaterials( material );
By invisible, I mean that it doesn't appear but it exists, the axisHelper is displayed. As other online viewers seem to display perfectly the same objects, I've come to the conclusion that some .mtl files found online are not compatible with three.js. Or is it the way I use it?
Here is an example of a functioning file: https://www.models-resource.com/mobile/shaunthesheeppuzzleputt/model/19915/
And a non functioning one: https://www.models-resource.com/ds_dsi/shaunthesheep/model/12472/
I now try to figure out why and if I could fix it. Please share your ideas and (hopefully) solutions :)