[resolved]How to detect if two objects overlap?

If you want to do simple intersection detection without use of a physics engine, you can use the mesh’s bounding boxes to detect intersection with each other:

In order to accurately collide, you will need to apply the mesh’s matrix transform to the bounding box.

box1.updateMatrixWorld();
box2.updateMatrixWorld();
var bounding1 = box1.geometry.boundingBox.clone();
bounding1.applyMatrix4(box1.matrixWorld);
var bounding2 = box2.geometry.boundingBox.clone();
bounding2.applyMatrix4(box2.matrixWorld);

if(bounding1.intersectsBox(bounding2)){
//collision, reject placement
}

I have just written this from memory, I have a working example that I can post later if you like?

1 Like