Mesh Merging error

Hi all, I got an error “cannot merge vertex data that do not have the same set of attributes”, when I was trying to merge a mesh created by SPS and a mesh from MeshBuilder. I reproduced a PG: I have been haunted by this error for few days, any clue or hint to get rid of this will be appreciated very much.

This error is because the two meshes have different Vertex data:

Check line 67 and 68;

  console.log([ground, mesh].map((t)=>t.getVerticesDataKinds()))

67 console logs the vertices data and we can see the mesh has one more attribute which is the color;

68 removes the color attribute of the mesh;

Another alternative to my solution above is replacing line 68 with code that adds ColorKind vertex data to the ground rather than remove it from the mesh.

  console.log([ground, mesh].map((t)=>t.getVerticesDataKinds()))
//   mesh.removeVerticesData(BABYLON.VertexBuffer.ColorKind)
  ground.setVerticesData(BABYLON.VertexBuffer.ColorKind,new Float32Array(mesh.getVerticesData(BABYLON.VertexBuffer.ColorKind).byteLength))
// same size
  console.log([ground, mesh].map((t)=>t.getVerticesDataKinds()))

Each of the above will affect how the ground/mesh looks since you’re playing with color data; So watch out how you use it


Thanks for your swift reply which really saved me. really appreciate.
As I have no idea about how to debug the vertex data with method getVerticesDataKinds(), I even rebuilt the ground with VertexData and applied all the positions, indices, normals, uvs except colors to the VertexData…
Thanks again.

1 Like