Jpg texture of obj model can be loaded in Windows, but not in Mac OS X

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

Can you please share the OBJ/MTL files with textures in this topic?

I’m using macOS and can verify the asset on my system.

Thanks, @Mugen87

However, the OBJ+MTL+JPEG files (140MB) belongs to one of our clients, and I need to check if they can be shared. Will message you directly on this forum if they are accessible.

Nevertheless, what could be the cause of this problem by your preliminary estimation?

Try resizing the textures to be at most 2048px or 4096px on the longest side, and see if that helps? The texture may be too large for the device.

1 Like

Hi @Mugen87 and @donmccurdy , I found the solution of this issue: in the .mtl file, add empty lines to separate the information of the JPG texture files used by the OBJ model, as shown below.

Anyway, thanks for your kind help.

Screenshot 2021-01-17 at 13.22.34