Meshes not merging

I’m trying to merge some meshes from a .babylon file exported from Blender, no matter what I try it’s not merging successfully. I read somewhere the meshes had to have the same material so I set each mesh to the same material, and it still doesn’t work. It should console.log the merged mesh

https://playground.babylonjs.com/#049EUN

If you enclose your code in a try block you would be able to capture the error:
Cannot merge vertex data that do not have the same set of attributes
https://playground.babylonjs.com/#049EUN#1
I assume you need to animate this model so merging will not work with different vertex data (as per my finding), just use single material in blender for all model and UV map to your texture atlas in same material.

2 Likes

Thanks for the help!

I don’t follow, I guess I need to look more into UV mapping and texture atlases.

But I don’t know if that solves my original problem. My goal is to merge all of these meshes into a single mesh. Are you saying it’s not possible because it’s animated? If I join it in blender and export it after, the animations will work still, but the meshes will still be sub meshes, and require the same # of draw calls.

because it has different vertex data

You have to do this in blender, join all meshes so there will be only one mesh in blender, I have attached a zip file which contains a simple example blender file, it has one mesh with single material and parts of mesh are uv mapped to two different colours of image, It also include animations with vertex groups, you can drop the .glb file from attached zip file on https://sandbox.babylonjs.com and see the result in inspector.
Archive 2.zip (156.0 KB)

Gotcha. The reason I’m wanting to export the meshes separately in Blender and then merge them in Babylon is so that I can cache the vertices of each mesh before they are merged. I could then change the color of each mesh (via it’s vertices) afterwards. The player model has a ton of items attached that need to be removed and materials changed at run-time. So I was going to do something similar to:
https://playground.babylonjs.com/#CURCZC#83

Where I could draw the entire player model in 1 draw call.

Doing this with a texture atlas sounds more intuitive, but I don’t see a way for any of this to be possible without first having the mesh joined into a single mesh while maintaining some form of access to the individual sub meshes.