Search code examples
gltfbabylonjs

How to optimize babylon's glb reader by welding primitives


I tessellated a step file and exported it to glb . I then opened the glb file with blender . The file works really fine . I then uploaded the file to babylon's sandbox and found out that since i exported just after tessellation , all the primitives are meshes and babylon draws every primitive everytime i move the camera resulting to a really big number of draw calls . I found out that blender welds the node's primitives to one mesh by itself after uploading the glb file . I exported the blender render to glb and uploaded it to babylon's platform and found out that all the primitives are merged . Is there a way to merge all the primitives to one mesh when reading the glb file with babylon like blender does ?


Solution

  • It's generally best to do this once, offline, in a tool like Blender. That's much more efficient than doing it each time the page is loaded, and the page will load faster. But if you need to do it in BabylonJS, these are the docs you'd want: https://doc.babylonjs.com/how_to/how_to_merge_meshes