After downloading a free model from Turbosquid, I found that it included an obj and mtl file along with textures like specular and bump maps. Focusing only on the mtl and obj files, I decided to use a car model from this link (http://www.turbosquid.com/FullPreview/Index.cfm/ID/394290). Loading the model using the following code:
var loader= new THREE.OBJMTLLoader();
loader.load("./L200-Obj/L200-Obj.obj","./L200-Obj/L200-Obj.mtl",function(object) {
scene.add(object);
}
Upon verifying the paths and ensuring they were correct (object appeared as an alive and valid object upon logging), I encountered a black screen issue due to the mtl file not being recognized. Attempting to add the material manually:
object.traverse(function(child) {
child.material= someMaterial;
});
Resulted in the car appearing with the specified material and correct shape. Further attempts to load 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
});
// Applying the above material to the car
Showcased the vehicle correctly, leading me to question whether the obj and mtl files alone should have been sufficient to display the car with its colors. Shouldn't the car appear colored without setting the material manually? Could there be something amiss in my approach?