Meshes are duplicated + rescaled + repositioned when exported to glb

Hello Forum <3

When i export my scene with the following lines of code, I experience a strange phenomenon :smiley:
All my meshes seem to be duplicated, rescaled and repositioned to 0/0/0 or something… Sadly, I can not share a Playground because this is integrated in a larger application where the scene can be created in 2D and is then transformed into 3D (I suspect this also causes the problem).

    let options = {
      includeCoordinateSystemConversionNodes:false,
      exportUnusedUVs:false,
    };

    GLTF2Export.GLBAsync(this.getScene(), "test", options).then((glb) => {
      glb.downloadFiles();
    });

This is the Code I use to export the Scene


This is the Scene in my application (as it should be)


This is the Scene when exporting it and viewing it in the Babylon Sandbox viewer

I know that for example the green vision cone of the human model could manually be removed, but It’s not just that :smiley: As it seems there are replicas of every single model in this messy mesh salad in the middle.

I tried to upload the exported file, but it is too large (even when zipped :frowning: )

Thank you for any advice! :slight_smile:

I think that in my app all the models are instantiated and added to the scene when needed. The instantiation could be visible in the export somehow…

Oh yeah, if they are instantiated and then exported, the instances will go along. You can use the shouldExportNode function to filter them out.

1 Like

Thank you very much! I tried using this but i think I managed to exclude the whole scene :smiley:
In the original version the Scene Tree looks like this:
image

Here I only want to keep the “apartment” node. The rest is instances that I’d like to exclude…
I tried using the following code which resulted in a completely empty apartment node :smiley:
image

      shouldExportNode: function (node: { name: string; }) {
        return node.name === 'apartment';
      },

Am I missing something obvious? (sry in advance)

Thank you for your time :slight_smile:

Hmmm by the looks of the inspector, the “apartment” is an TransformNode, which indeed doesn’t have geometry.

Just a tip, but since you’re already destructuring node in shouldExportNode, you don’t need to do node.name, just name works :slight_smile:

When I export the scene without any filtering, the “apartment” note (TransformNode) holds all the geometry I want.
image

  • Floor-PVC
  • Floor-Tile
  • The Walls

This is the models I’d like to export (but they are automatically generated, so I don’t want to pick them separately). So I wanted to only export their parent, which seems to be the “apartment” node.

Thank you for your time :slight_smile:

Oooh, now I see! The thing here is that your shouldExportNode needs to return true for both the “apartment” node AND its children, so you can’t check only for the name of the node, you also have to check if any parent of the node has that name with a recursive function. Something like:

function nameInHierarchy(node, nameToCheck) {
 if (node.name === nameToCheck) return true; //check if node has that name
 if (node.parent) return nameInHierarchy(node.parent, nameToCheck); //if not, check if node's parent has that name
 return false; //if there aren't any parents anymore, we checked all the hierarchy
}
2 Likes

Thank you, I’ll try it out! I am working with TypeScript so I think I’ll have to edit this a little before it runs in my application :smiley:

EDIT: I did it! Thank you very much :slight_smile:

2 Likes