INNER CODE UNIT · JavaScript
worldBox
MageStudio/Mage · src/physics/index.js:444
const worldBox = new Box3(); // for the center (axis-aligned, world)
const sizeBox = new Box3(); // for the size (rotation removed)
let found = false;
const visit = obj => {
if (obj !== body && excluded.has(obj)) return; // skip a child element's subtree
if (obj.geometry) {
if (!obj.geometry.boundingBox) obj.geometry.computeBoundingBox();
// World AABB (its center is the true world center of the box).
worldBox.union(obj.geometry.boundingBox.clone().applyMatrix4(obj.matrixWorld));
// Un-rotate and measure in ONE transform: applying matrixWorld
// first would already collapse the rotated box to an inflated
// axis-aligned bound. `unrotate * matrixWorld` has no net rotation,
// so the resulting AABB is the box's true (scaled) extent.
const combined = unrotate.clone().multiply(obj.matrixWorld);
sizeBox.union(obj.geometry.boundingBox.clone().applyMatrix4(combined));
found = true;
}