Maths · function
sphereInFrustum
Whether a world-space sphere is anywhere inside the frustum.
Explained in Coordinates and units.
function sphereInFrustum(frustum: FrustumPlanes, x: number, y: number, z: number, radius: number): booleanimport { sphereInFrustum } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
frustum | FrustumPlanes | |
x | number | |
y | number | |
z | number | |
radius | number |
In depth
The question is "outside any one plane", not "inside every plane". A sphere is rejected only when it lies entirely on the far side of a single plane; anything else is kept. Asking whether the centre is inside all six is the version that looks equivalent and is not — it throws away everything larger than the view, so a room the camera is standing in vanishes.
Conservative at the corners: a sphere can be outside the frustum and still be within radius of all six planes, near an edge. That costs a draw that turns out to be invisible and never costs a draw that was visible, which is the only asymmetry a cull may have.