0
votes

I want to run .obj file and .mtl file, but when I run only .obj loader it doesnt show any problem. Running objloader together with mtlloader it gives me an error:

MTLLoader error

Code that I use to load .obj and .mtl files is:

carLoad = new THREE.MTLLoader();
                carLoad.load('assets/obj/audi/Audi_R8.mtl',function(materials){
                materials.preload();
                
                objLoader = new THREE.OBJLoader();
                objLoader.setMaterials(materials)
                objLoader.load( 'assets/obj/audi/Audi_R8.obj', function ( object ) {
                object.position.set(-50, 0, -60);
                scene.add( object );
});
}); 

Any idea how to fix this?

1

1 Answers

0
votes

This runtime error indicates a version mismatch of your library files. You always have to ensure that the core file ( three.js) as well as all example files (like OBJLoader or MTLLoader) are from the same release. Please try it with the latest version which is r115 right now.