How to exclude all empty nodes from export?

Hi there!
I am building an app that can import or export meshes. Sometimes I import different meshes with empty nodes in it, so I would like to be able to export excluding all these empty nodes. What is the best way to do this?

Here is what I have tried, but it is not working:

                      let excludedNodes = [];        
                      scene.getNodes().forEach(node => {
                        if(node.getChildMeshes().length == 0){
                      let options = {
                        shouldExportNode: function (node) {
                          return excludedNodes.indexOf(node) === -1;
                      BABYLON.GLTF2Export.GLBAsync(scene, "fileName",options).then((glb) => {

Hello! Can you provide us with a Babylon.js Playground ( example so we can look better into this? :slight_smile:

1 Like

Here is the playground:

You’re calling the GLTF export function outside of the SceneLoader callback, which means it is being called before the mesh actually loads :slight_smile:

Also, the SceneLoader isn’t loading anything for now, since the provided link isn’t in a compatible format with the playground. Take a look at this Using External Assets In the Playground | Babylon.js Documentation (

I followed the instructions, but it seems to be blocked by the CORS policy Babylon.js Playground .

You can take a look of this file at plataformaonline/fileName.glb at master · mathus1/plataformaonline · GitHub
In the sandbox there will be an empty node

I think you could read them again, they explain how to properly use github assets on the Playground. :slight_smile:

Sorry. I missed some steps Now I got it working: Babylon.js Playground

Instead of just checking for nodes without children, you could check if it’s also a TransformNode.