ConvexPolyhedron with imported geometry can't collide against each other ? #135
-
Hi there ! I'm importing basic meshes from Blender and throwing them on a plane. But it crashes as soon as they collide against each other. I don't get why. It might not be related, but it was pointed to me that in cannon.js ConvexPolyhedron class doesn't accept coplanar triangles : It seems really strange, since three.js geometries only work with triangular faces (quads are cut in half). This is also how GLTF export works. In Blender I had a plain cube, with 6 faces, but the exported model has 12 faces. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So… THE FIX : The CodeSandBox here shows the issue and the fix. |
Beta Was this translation helpful? Give feedback.
So…
THE CAUSE :
In the process of cuting quads into triangles, Blender GLTF export multiplies the vertices. This doesn’t bother the rendering of the meshes in Three.js, but causes crashing deep into cannon-es script when two of them collide with each other.
THE FIX :
The geometry can be cleaned up with geometry.mergeVertices(). This caused the duplicated vertices to disappear, and the geometry.faces to be remapped onto the new geometry.vertices.
The CodeSandBox here shows the issue and the fix.