Babylon glb file loader issue

In this PG,
I have created box with submeshes.
Number of mesh here is 1.
I have exported the scene to .glb format.
In the exported file, the submeshes are written as primitive.
But while loading the same .glb file, it loads 12 meshes.
Why the primitives are read as meshes in babylonjs loader?

Hi, when I run the scene, it only shows 1 mesh in scene object

But it does show 12 submeshes in that single mesh

12 triangles are what you have in place to make up the 6 sides of cube.

If you set the backFaceCulling to true it reveals things a bit better.

After exporting to glb, When I load the exported glb file in sandbox. I am getting 12 meshes.

Ping @Drigax and @bghgary :slight_smile:

This is a tricky one. For some context / history, see here: GLTF Parser Hooks.

Basically, the issue is that Babylon’s multi-material / submeshes is not a 1-to-1 mapping to glTF mesh primitives. This makes it difficult to get correct round-tripping behavior. The loader doesn’t attempt to load the glTF mesh primitives into Babylon.js submeshes as there are many edge cases.

One possible workaround is to manually merge the meshes using Mesh.MergeMeshes after the load if you know this will work for your scenario.