for (let i = 0; i < scene.meshes.length; i++) {
let mesh = scene.meshes[i];
if (mesh.name.endsWith("_merged")) {
scene.meshes.splice(i, 1);
// mesh.dispose()
}
}
First: It is not a good idea to remove an item within a loop over the items. You should go from the last item backwards to index 0: for (let i=scene.meshes.length-1; i>=0; i–) …
Second: mesh.dispose() returns this error. I suppose you have to remove the Hawok body first before removing the mesh because they are connected together.
LoL, good one. I won’t mention that I tried for 20min disposing of the body before disposing of the mesh , thinking the same as @CodingCrusader…though it’s hard to dispose of something that no longer exists, isn’t it ?