For each mesh (THREE.Object3D
) Three.js provide a very handy properties - boundingSphere
and boundingSphere
that have intersectsSphere
and isIntersectionBox
methods.
With all this I thought I can use it for simple collision detection but when I try it appears that collision happens all the time because (I tried boundingSphere
) boundingSphere.center is always in (0, 0, 0);
So If I want to check collisions between 2 meshes I should for each object - clone boundingSphere
object and then get it world coordinates and only then to use intersectsSphere
.
something like this:
var bs = component.object.geometry.boundingSphere.clone();
bs.center.setFromMatrixPosition(component.object.matrixWorld);
...
if (_bs.intersectsSphere(bs)){
is this how it suppose to be used or am I missing something and there are more convenient way of doing collisions detection based on boundingBox/boundingSphere?