Material SideOrientation/Normal flipped during glb export


I am importing an obj file into my scene. Then I am exporting it using GLTF2Export.GLBAsync.
I am using a right-handed coordinate system. When I re-import the glb file I have the wrong sideOrientation on materials. Is it possibly an issue of converting between standard material and PBR material not taking into account the right handed coordinate system? When I switch to left handed it works fine.

Best Regards,


var theMesh = scene.getMeshByID(“theMeshName”);
theMesh.overrideMaterialSideOrientation = 1;

That would fix the issue but it seems like a band-aid?

This should work as we are taking the useRightHandedSystem in account in the exporter.
Can you repro on the playground?
Pinging @bghgary

Yeah, this sounds like a bug. A PG would be helpful.

I’m working on a playground. I got it to this point:

Unable to import exported glb at the moment.

Okay I can reproduce it now.
Here you go:

When right handed the material orientation is wrong.

@BrianW Thanks for the PG. Do you mind filing a GitHub issue?

Not at all. Here you go:


1 Like

I’m having the same issue with another block. I believe it has something to do with multi-material.

Also the difference in lighting between the direct import vs glb import is strange if anyone could explain it to me I would be very happy.

pinging @bghgary

The root of the problem is that the babylon file is referencing a texture that isn’t an image. The handling of this is wrong somewhere in the rendering/export for this edge case, but fixing the asset will probably make it work.

Replaced texture with base64 string. The issue seems to still be there…

I was not adding in the multi-material + sub materials to the scene. This fixed the side-orientation issue.
Texture doesn’t seem to import though.

@bghgary should be able to answer soon (We have a busy week, sorry for the inconvenience )

No problem. Thanks for the help.

Looks like there is an issue with the exporting code. @BrianW Can you file an issue on GitHub? @Drigax Can you look at this? Something is wrong with the way the materials are being exported. I can show you offline.

Sure, I have about 2 weeks worth of backlog to get through before I can give this my full attention, but I’d greatly appreciate any analysis :slight_smile:

1 Like

Heres the issue:

Thanks for creating the issue, I’ll try to take a look at this today.

Created a possible PR to fix this here:

1 Like