I’m new to three.js, and I’m using the following boilerplate code to import an obj file via OBJLoader2.
The obj file and its jpg texture files associated (put in the same directory) can be correctly imported in Windows, but not in Mac OS X in which the texture is missing and I get error message in the console of Chrome as shown below.
Can anybody kindly advise the source of this problem and how to solve it? Thank you.
const objName = ‘model’;
const objLoader2 = new OBJLoader2();
const callbackOnLoad = function ( object3d ) {
object3d.rotateX(-0.5*Math.PI);
scene.add( object3d ); };
const onLoadMtl = function ( mtlParseResult ) {
objLoader2.setModelName( objName );
objLoader2.setLogging( true, true );
objLoader2.addMaterials( MtlObjBridge.addMaterialsFromMtlLoader( mtlParseResult ), true );
objLoader2.load( './models/texture.obj', callbackOnLoad, null, null, null );
};
const mtlLoader = new MTLLoader();
mtlLoader.load( './models/texture.mtl', onLoadMtl );
Error message as shown in Chrome’s Console in Mac OS X:
OBJLoader.Parser configuration:
materialNames:
- defaultMaterial
- defaultVertexColorMaterial
- defaultLineMaterial
- defaultPointMaterial
materialPerSmoothingGroup: false
useOAsMesh: false
useIndices: false
disregardNormals: false
callbacks.onProgress: onProgress
callbacks.onAssetAvailable: defaultOnAssetAvailable
callbacks.onError: onError
Global output object count: 1
object_group "_" was defined with unresolvable material "0"! Assigning "defaultMaterial".
object_group "_" was defined with unresolvable material "1"! Assigning "defaultMaterial".
object_group "_" was defined with unresolvable material "2"! Assigning "defaultMaterial".
The correct message as shown in Chrome’s Console in Windows:
OBJLoader.Parser configuration:
materialNames:
- 0
- 1
- 2
- defaultMaterial
- defaultVertexColorMaterial
- defaultLineMaterial
- defaultPointMaterial
materialPerSmoothingGroup: false
useOAsMesh: false
useIndices: false
disregardNormals: false
callbacks.onProgress: onProgress
callbacks.onAssetAvailable: defaultOnAssetAvailable
callbacks.onError: onError
Global output object count: 1