Hello,
I have a problem and I would like you to help me solve it. Currently, I am working on a project that requires an update regarding box collisions. Initially, I used the intersect
function of Box3
. Now, they want the boxes to undergo rotations, and collisions should occur on the actual box, not the bounding box of Box3
. I thought about transforming my Box3
into an OBB (Oriented Bounding Box) and trying to use the intersect
function, but it doesn’t seem to work.
export function isCollided(component: Component, components: Component){
return components.some((otherComponent: any) => {
const otherComponent3DObject = get3DComponentById(otherComponent.id);
const movedComponent3DObject = get3DComponentById(component.id);
if (otherComponent3DObject) {
const otherBoundingBox = new Box3().setFromObject(otherComponent3DObject)
const boundingBox = new Box3().setFromObject(movedComponent3DObject)
const OBBother = new OBB().fromBox3(otherBoundingBox)
const OBBFromMovedComponent = new OBB().fromBox3(boundingBox)
return OBBother.intersectsOBB(OBBFromMovedComponent)
}
return false;
});
}