Applying VertexData to Mesh used as InstancedMesh source

Here is a playground where a sphere is created. Then VertexData for a box is created and applied to the source mesh. After this the index data for the submeshes are incorrect and clicking the box gives an error in the console.

Looking into the issue the submesh has the wrong indexStart and indexCount.

It works fine to do the same thing when instances are not involved.

Further investigation shows that while the source mesh has the subMeshes rebuild (with the new index count) the instances also have subMeshes (not sure why) and they are not updated.

This seems to be a bug in Geometry.setIndices.

I don’t quite get the subMesh situation but it seems that if a mesh understands that is has broken subMeshes so it needs to rebuild them… and it also has instances… then it should loop over the instances and do something :slight_smile: That should be more or less free if there are no instances…

Definitely adding @Evgeni_Popov for this one :slight_smile:

Just wanted to point out that this is not a bug that is important to us right now, it is just something I stumbled upon.

Summary: Geometry.setIndices fails to update subMesh information in InstancedMeshes causing corrupt index ranges there. Influences picking at least. Rendering is not affected since subMesh information is not used.

Yup and thanks for the report :slight_smile: We hate bugs so we ll take care of it ASAP

Created an issue for that, need some feebacks about it from the team.

Fixed by: