Extract selected faces / vertices as an additional submesh

So, I have a mesh containing 4 subMeshes. I know the indices that I wish to extract and create as a 5th submesh with a new material but can’t quite work out how best to go about this. Any suggestions would be very welcome!

You can simply call the SubMesh constructor and pass the required parameters:


You will have to update the index buffer first. You can do something like this (not tested!):

const ib = mesh.getIndices();
const idxStart = ib.length;
// add the new faces
new BABYLON.SubMesh(0, 0, mesh.getTotalVertices(), idxStart, ib.length - idxStart, mesh);