Error after cloning mesh with instanced buffer

Hi everyone,
I encountered an error when I tried to register an instanced buffer for a cloned mesh.

Example: https://playground.babylonjs.com/#MHXX89#2

Reproduce:
It reproduces on 6.25.0. It works correctly on 5.71.1.

  1. Create a mesh and register an instanced buffer.
  2. Clone the first mesh.
  3. Register an instanced buffer for the cloned mesh.

It looks like clone copies instancedBuffers from source mesh. So, registerInstancedBuffer does not initialize _userInstancedBuffersStorage and instancedBuffers for instances.
So I found a temporary fix (line 18 in the example): cloneSphere.instancedBuffers = null
After ‘fix’ registerInstancedBuffer works correctly.

What side effects can I encounter using my ‘fix’?
Have any ideas about how to fix this better than I did?

Welcome to the community!
Thanks for reporting this, I’ve opened a fix in: Fix instanced buffers of cloned meshes by carolhmj · Pull Request #14456 · BabylonJS/Babylon.js (github.com)

2 Likes