i'm new at three js and i'm trying to clone some object using obj + mtl format. The problem is when i'm loading my object i have an TypeError: url is undefined in three.js files.
var models = {
fence : {
obj: "http://localhost:8000/SIA/src/medias/models/gltf/fence/Fence.obj",
mlt: "http://localhost:8000/SIA/src/medias/models/gltf/fence/Fence.mlt",
mesh: null
},
grass : {
obj : "http://localhost:8000/SIA/src/medias/models/gltf/grass/Grass.obj",
mlt: "http://localhost:8000/SIA/src/medias/models/gltf/grass/Grass.mlt",
mesh: null
}
};
//Meshes index
var meshes = {};
And this is how i get my url :
for( var _key in models ){
(function(key){
mtlLoader.load(models[key].mtl, function(materials){
materials.preload();
objLoader.setMaterials(materials);
objLoader.load(models[key].obj, function(mesh){
mesh.traverse(function(node){
if( node instanceof THREE.Mesh ){
node.castShadow = true;
node.receiveShadow = true;
}
});
models[key].mesh = mesh;
});
});
})(_key);
}
I guess it's mtlLoader the problem, but i'm not sure. I just use console.log(""); to find where the code stop. I checked my models url 10 times and they are correct. If anyone can help me to find where is the mistake.