In Three.js, each mesh (THREE.Object3D
) comes with useful properties like boundingSphere
and boundingBox
, along with methods such as intersectsSphere
and isIntersectionBox
.
I initially thought I could use these for simple collision detection. However, I noticed that collisions were always detected because the boundingSphere
's center was consistently at (0, 0, 0)
. To properly check collisions between two meshes, I realized that I needed to clone the boundingSphere
object for each mesh, get its world coordinates, and then utilize intersectsSphere
.
This approach might look something like this:
var bs = component.object.geometry.boundingSphere.clone();
bs.center.setFromMatrixPosition(component.object.matrixWorld);
...
if (_bs.intersectsSphere(bs)){
Is this the correct way to handle collision detection using boundingBox/boundingSphere, or is there a more straightforward method available?