Merging a BABYLON.InstancedMesh and BABYLON.Mesh

Hi Babylon Devs, I am grateful for all the help I received from this awesome community. I Love all the people here and In this topic I will share an experience that I am having when Merging Instanced Mesh and a Mesh

In this demo I am trying to merge an imported 3d model from blender and after inspecting it the reason why I can’t merge it properly is because of missing vertex data. To merge them properly every mesh should have the same VertexKind[uv, uv2, kind, position] I achieved it in this demo unfortunately there is more to it. some mesh is not an instanceOf BABYLON.Mesh instead an instance of BABYLON.InstancedMesh. After cloning the instance and merging it some meshes are missing even tho I did not dispose anything. Hopefully someone already encountered this kind of things and asking for your help. Here is a demo in the playground: Babylon.js Playground

As you set the position/rotation/scaling from the world matrix, you should set the parent to null for the new meshes, so that they don’t inherit a second time of all their parent transformations.

However, it’s easier to simply copy the position/rotation/scaling of the mesh you are currently cloning to the cloned mesh, and set the parent of the new mesh to the parent of the mesh:

2 Likes

Amazing it works ! I can’t express my gratitude enough ! You are a life and time saver