After introducing a new model in .obj and .mtl formats into my three.js code, I encountered an issue where the color of the model would turn white, regardless of its original color or texture. Below is a snippet of the code related to 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 depicted scenario includes a pigsty setting with compost boxes. However, as observed in the code, the pig appears white instead of pink as intended. Similarly, the fence lacks its wooden texture and also appears white.pig model image
This discrepancy leads us to suspect that there might be an issue with the mtl file causing these elements to appear white. The complete code and mtl files can be accessed through this link.