hello,I want to accurately determine if there is a collision between two irregular and stationary meshes in three.js. My current approach is to first construct AABB (Axis-Aligned Bounding Boxes) for initial collision detection. After that initial screening, I plan to check for intersecting faces by examining the positions from the geometry of each mesh and the indices that form triangles. However, I’ve found that when there are too many meshes in the view, the speed of this process becomes very slow. Are there any other better methods for this? I look forward to your suggestions.
That’s gonna be REAL slow. Luckily @gkjohnson has developed the excellent mesh-bvh library, which has a “shapeCast” facility which is what you need I think:
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/shapecast.html
I cannot express my gratitude to you in words.
Hello, is there any method in the three-mesh-bvh library to ignore the situation where two mesh surfaces just come into contact? I tried to scale based on the centroid, but some meshes are too complex and scattered in different locations in space. I also found the method “distanceToGeometry”, but whether they are just in contact or embedded in each other, I found that its minimum value is always 0, so I still can’t distinguish these two situations. Is there any other way to achieve this point?
Maybe you want to try a physics engine.
Cannon is very lightweight
but lacks some of the features of the heavier Rapier physics engine,