Mesh setVerticesData sets values for all duplicate meshes

Hi,
In my application I need to change the skeleton that a loaded .babylon file uses. In addition, I need to change the indices of the bones.
To do this, I use:

const indices = myMesh.getVerticesData(VertexBuffer.MatricesIndicesKind);

To get the values, which are then updated and re-applied with:

myMesh.setVerticesData(VertexBuffer.MatricesIndicesKind, indices, false);

This all works well.

However, If I re-load another copy of the mesh, then it seems that the indices of the newly-loaded mesh have already been updated, indicating that in fact, I am being given a copy of the mesh in memory. I understand that this is an optimisation, but given I had edited the indices, I was expecting that re-loading the mesh would give me a clean copy.

In addition, if I clone the mesh and edit the clone’s indices, it seems that the original indices are also adjusted.

As I want to load a mesh multiple times and adjust each copy’s indices differently so that it can be applied to a different skeleton I will need to be able to have copies of the same mesh, each with different bone indices.

Has anyone got any ideas on how this can be achieved?
Thanks.

Hi @Charge

Before you start changing vertices, applying

Mesh.makeGeometryUnique();

Should fix both those issues

2 Likes