Sphere
Quick answer
Sphere is a bounding volume defined by a center Vector3 and a radius, used by frustum culling and coarse ray tests. Compute it with setFromPoints(), test overlap via intersectsBox() or intersectsSphere(), and guard against the empty state where radius is negative.
new THREE.Sphere ( center , radius )
Key points
- new Sphere() has radius -1, so isEmpty() returns true until set() or setFromPoints() is called.
- distanceToPoint() is negative inside the sphere and positive outside.
- applyMatrix4() enlarges the radius under non-uniform scaling.
Example
geometry.computeBoundingSphere();
const bound = geometry.boundingSphere.clone().applyMatrix4(mesh.matrixWorld);
const frustum = new THREE.Frustum();
frustum.setFromProjectionMatrix(
new THREE.Matrix4().multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
)
);
console.log('是否可见', frustum.intersectsSphere(bound));
const sphere = new THREE.Sphere();
const hit = raycaster.ray.intersectsSphere(sphere.set(mesh.position, 3.2));
if (hit) {
raycaster.intersectObject(mesh);
}
Notes
- An empty sphere fails every intersection test, making objects disappear from culling checks.
- Reusing a sphere for new geometry without recomputing leaves stale bounds.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Sphere. https://www.jingweizhi.com/en/three/api/sphere.html (accessed 2026-11-03).