-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not getting desired boundaries with simple cube like shapes #158
Comments
It looks like you might be fitting a bounding box to your mesh. For a closer fit, use the convex hull or mesh types: https://github.com/donmccurdy/three-to-cannon?tab=readme-ov-file#api |
@elkizana That's what convex hulls are — think of it like stretching shrink-wrap around an object. If you need a tight fit around concave objects in Cannon.js, then the "mesh" type is your only option, and there are a bunch of performance and support caveats with that, unfortunately. Ideally your meshes above could be fit with a collection of 'compound' box-shaped bodies, one box fitted to each box-shaped segment of the mesh... But that's not something this library can automate for you. Or if you don't need a full physics engine like cannon.js, then using a navmesh or BVH hierarchy could be alternatives: https://github.com/gkjohnson/three-mesh-bvh. |
@donmccurdy thank you ! |
Very cool! I hadn't seen this yet. It supports higher-end WASM-based physics engines like Havok and Rapier, and might have better options for you indeed. |
how can it have more detailed collision ? |
Cannon.js has some significant limitations on collisions with trimesh bodies — discussed in more detail at pmndrs/cannon-es#21. I believe Rapier and Havok have better options for that, but it's always going to be more expensive than colliding with primitive shapes. In general though, meshes are just a pile of triangles as far as the runtime can see, so it's difficult for an engine to guess how you want to simulate it for performance vs. detail. Usually a good idea to make that decision for the engine if you can. |
How to get rid of these extra boundaries
The text was updated successfully, but these errors were encountered: