Linked meshes issue when exported with blender babylon exporter

Hi Everyone,

There seems to be an issue with linked meshes exported with blender babylonjs exporter. When I dispose of one of the linked meshes in the scene, the entire linked objects are removed from the scene. I have created a playground for a better explanation.

Uncomment the setInterval function to dispose of one mesh at a time or just simply specify a mesh id using the second function to dispose of individual ones.

The first mesh (coin1) will reveal the issue but also try other id names like coin2, coin3 e.t.c to investigate, thanks.

Welcome aboard!

It’s the expected behaviour because coin2, coin3, etc are instances of coin1: if the master mesh is removed from the scene, its instances are removed too because they depend on this mesh for proper rendering. You should disable coin1 (mesh.setEnabled(false)) instead of removing it if you want to make it disappear but not its instances.

Thanks for the quick reply. In that case, how do I identify the master mesh with blender->export workflow?

I have no idea, I don’t know Blender. I think you must also have the same notion of master / child instances in Blender, meaning the master mesh is the mesh from which you create new clones (instances)?

I am afraid that you do not. The first one encountered during export ends up the mesh. In Blender, these are all just meshes which share geometry. There is no hierarchy.

You can just put one on the file & create the instances yourself, then you would know.

1 Like

How does the exporter determine the first mesh? Based on your previous statement (The first one encountered during export ends up the mesh). My meshes are named with a number prefix. So if the exporter picks up or sort the meshes by name then I can always assume the first mesh(coin1) will always be the master, would that work?

If you want to determine on Babylon.js side which one is the master mesh, you can simply scan all your meshes and call mesh.getClassName(): the instances will return InstancedMesh whereas the master mesh will return Mesh.

1 Like

Thanks, that will solve the issue.