For some reason when I add a new model in .obj and .mtl into my three.js code, the color will become white, despite whatever the original color or texture is. The following is a snippet of the code responsible for the pig model:
// pigmodel
var objLoader = new OBJLoader();
var mtlLoader = new MTLLoader();
function loadpigmodel( x, y, z, ang, scale ) {
mtlLoader.setPath( './images/' );
mtlLoader.load( 'Pig1.mtl', function ( loadedMesh ) {
objLoader.setMaterials( loadedMesh );
objLoader.load( './images/Pig1.obj', function ( object ) {
switch ( scale ) {
case 'big':
object.scale.set( 100, 100, 100 );
break;
case 'small':
object.scale.set( 90, 90, 90 );
break;
default:
}
The code above simulates a pigsty with some compost boxes. As you can see, the pig displayed in the code is white, even though it should be pink. The fence should also have wooden texture, but instead, it is also white.pig model image
We suspect that there is something wrong with the mtl file of the things that became white. The full code and the mtl files are included in this hyperlink.