onNewMeshAdd executes repeatedly for the same mesh

When using LoadAssetContainer to load babylon scene data described in JSON format, the onNewMeshAdd for the same mesh will be executed repeatedly.

The scene data in playground only contains a cube mesh.

https://playground.babylonjs.com/#16O9D2

The two triggers occur here because Babylon.js meshes are added to the scene by default during initialization. The LoadAssetContainer behavior creates the mesh and then removes it from the scene.

Let me have a look

Working on a tentative fix: Try preventing events during babylon file parsing by sebavan · Pull Request #17623 · BabylonJS/Babylon.js · GitHub

1 Like