INNER CODE UNIT · JavaScript

sizeBox

MageStudio/Mage · src/physics/index.js:445

        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;
            }
            for (const child of obj.children) visit(child);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…