I have downloaded a free model from turbosquid. It contains an obj and mtl, and textures (specular, bump map, etc...). For now I am just interested about the mtl and obj file. So I downloaded a free model from here (it's a car). Then I loaded the model using this code:
var loader= new THREE.OBJMTLLoader();
loader.load("./L200-Obj/L200-Obj.obj","./L200-Obj/L200-Obj.mtl",function(object) {
scene.add(object);
}
I already checked the paths and they're ok (I tried to log object
, it's an alive and valid object). Now the problem is that I see a black screen, and the reason is that the mtl file is somehow "not considered". If I try to add the material:
object.traverse(function(child) {
child.material= someMaterial;
});
Then I see the car with the material that I've set, and the shape of the car is fine. I also tried to load the textures:
var map= THREE.ImageUtils.loadTexture("./L200-Obj/truck_color-silver.jpg");
var bumpMap= THREE.ImageUtils.loadTexture("./L200-Obj/truck_bump.jpg");
var specularMap= THREE.ImageUtils.loadTexture("./L200-Obj/truck_spec.jpg");
var material= new THREE.MeshPhongMaterial({
map: map,
specularMap: specularMap,
bumpMap: bumpMap
});
// Set it as material with the above code
And they're fine, the car looks ok, but the question is: shouldn't the obj and mtl files be enough to display the car with it's colors? Shouldn't I see the car with it's colors even if I don't set the material? Am I doing something wrong?