Box3
Quick answer
Box3 is an axis-aligned bounding box defined by min and max corner vectors in world space. Build it with setFromObject(), then use intersectsBox(), containsPoint(), union(), or getBoundingSphere() for culling, framing cameras, and range queries. Call applyMatrix4() to transform it, or expandByPoint() to grow it incrementally as points arrive.
new THREE.Box3 ( min , max )
Key points
- new Box3() starts empty, with min above max; expandByPoint() or setFromObject() fills it correctly.
- setFromObject(object, true) walks vertices for an exact box, but is slow on large meshes.
- getCenter() and getSize() write into a target Vector3 rather than allocating a new one.
Example
const box = new THREE.Box3();
box.setFromObject(scene);
const size = box.getSize(new THREE.Vector3());
const center = box.getCenter(new THREE.Vector3());
console.log('范围', size, '中心', center);
const sphere = box.getBoundingSphere(new THREE.Sphere());
const distance = sphere.radius / Math.tan(Math.PI * camera.fov / 360);
camera.position.copy(sphere.center).add(new THREE.Vector3(0, distance * 0.6, distance));
camera.lookAt(sphere.center);
Notes
- intersect() with an empty box immediately yields an empty box; guard loops with isEmpty().
- setFromObject() defaults to geometry bounding boxes, so rotated meshes produce an inflated result.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Box3. https://www.jingweizhi.com/en/three/api/box3.html (accessed 2026-11-03).