ObjFileLoader not loading all textures as it should

I’m loading some matterport scans to scene, obj files with mtl and textures, obj file loader does not seem to do good job applying those textures. In most cases it applies floor textures to ceiling . In other programs (eg MeshLab) obj is loaded correctly.
Any advice?

Plus, any of texture tweaking suggestions from docs does not seem to work.

We will need a repro in the Playground to be able to help here.

Thanks for a reply, here is repo https://www.babylonjs-playground.com/#28YUR5#743
Wilmette Wine Cellar (Pro2) - Matterport 3D Showcase this is obj file loaded in matterport viewer.

Brgds!!

Sry, camera isn’t best, I’ve chosen first PG with objloader, but you can see carpet on the floor.

@Marin_Pericic The PG doesn’t work so we don’t have any chance to see your textures.
image
If you need to use external assets, please refer to this page - Using External Assets In the Playground | Babylon.js Documentation
Also, in this case would be helpful to have the possibility to download your model with all textures.
Otherwise it is impossible to help…
By the way, did you try to load your model into Sandbox? Does it have incorrect results?

1 Like

I dont see any texture in your obj file:

May be cross check your model if the texture is visible in other online model loaders eg THREE.js, CLARAIO etc

I need to setup better hosting as browsers force same protocol policy, if you are in mood you can allow mixed content by clicking lock in address bar and then “disable protection for now”. I’ll try to setup it better tomorrow.

Hi, here is better version of PG

You don’t need to add your code on load.finish, the playground is already setting a render loop that is rendering the scene for you.

Also, Wilmette Wine Cellar (Pro2) - Matterport 3D Showcase is switching to a cubemap in the end, so we can’t really see if the ceiling is ok when using the 3D objects… You should try to display your scene (the .obj / .mtl files) with another obj viewer and see if it’s ok there.

I’ve tried meshlab and it loads texture as they should be

Could you try to load your model into Sandbox? If your model is OK with Sandbox it will be OK with the code too assuming the code has no errors.

It seems the obj loader does not handle all cases of usemtl location inside the .obj file (which is difficult to do as to my knowledge there is no official doc about the format).

Your best bet is to have the usemtl instruction following the g instruction instead of the reverse (as it is currently in the file) by switching the two lines:

https://www.babylonjs-playground.com/#28YUR5#747

2 Likes

Thanks man, great catch, it loads nice now!