Scene exporter is not working correctly (19.0 KB)

I’m trying to export the scene using the command

BABYLON.GLTF2Export.GLBAsync(scene, "fileName").then((glb) => {

but it seems to have some errors when I import in blender. Even the other formats like gltf or .babylon is not working.

What would be the problem?

Find attached the glb file

Could you share a repro in the playground ? so that we can have a look into it easily.

cc @bghgary

Because in my project has some backend in it, I tried to compile the parts that might have a problem in the playground.

Here it is: Babylon.js Playground

Another strange thing happened. In that playground, the export does not work but when I remove lines from 43 to 50, the exporter works, but the file is still corrupted

No Export is expected as you create an empty texture here

impact.material.diffuseTexture = new BABYLON.Texture("", scene);
                          impact.material.diffuseTexture.hasAlpha = true;

so it will never load.

But what is not is that a material with a texture is losing it on export: @bghgary could you have a quick look ?

I realized that the materials of merged meshes is not transferred to glb:

I am not sure if we support multi material in the exporter but @bghgary will be able to confirm when he ll look into the texture issue :slight_smile:

I have the texture issue fixed. It looks like we support MultiMaterial, but it doesn’t appear to work correctly with your PG. Will investigate.

1 Like

PR: Export glTF material fixes by bghgary · Pull Request #12239 · BabylonJS/Babylon.js (

This will fix both issues.

1 Like

And also I am having problems with some nodes when exported like this one: Babylon.js Playground

It is importing well, but when I export, some nodes disappear

I don’t know what you mean by this.

I dont know the right term for it but if you see the exported file, some faces of the mesh disappearsed.
But now it seems that the PG is working fine. The issue is fixed. Thank you

1 Like

Hey everyone, sorry to revive an old thread, but I think there is a small bug with the PR that was merged due to this issue.

We import/export models frequently in our application, and what appears to be happening is that when you import a gltf/glb model, it will get the __root__ node applied (as shown here). Now in Babylon 5, due to root being a mesh node, it will assign a “default material” to the root node and export the gltf with that material (as shown here). When you open the gltf file, it will now have a “default material” material that is unused. We updated to Babylon 5 recently and started encountering this, which was working previously in Babylon 4.

cc @Guillaume_Pelletier and @bghgary

The __root__ being a mesh is not new, but maybe my changes cause the default material to be exported. Let me investigate.

1 Like

I’m not able to repro this. Do you have a PG with this issue?

@bghgary Hey! Sorry about that. It appears to be an edge case. One imported mesh needs to be parented underneath another imported mesh for the behavior to appear.

PG: Babylon.js Playground

1 Like

Fixed here: Only export material from mesh with geometry by bghgary · Pull Request #12694 · BabylonJS/Babylon.js · GitHub

Thanks for the bug report!