Writes the world-space bounding sphere of geometry under worldMatrix into
out, and returns whether the result is usable.
if (computeWorldBoundingSphere(item.geometry, item.worldMatrix, sphere)) { if (!frustum.intersectsSphere(sphere.center, sphere.radius)) continue; }
The derivation, in one line each:
§53's cached local box gives a centre c and half-extents e;
the world centre is worldMatrix · c — an ordinary point transform;
the world AABB's half-extents are |M| · e, the matrix with every element
replaced by its absolute value applied to the half-extent vector. This is
the standard conservative box transform: every corner of the local box
lands inside that world box, whatever the rotation, shear, or non-uniform
scale;
the radius is the length of those half-extents — the circumradius of the
world box, hence a sphere containing it, hence a sphere containing the
geometry.
Every step is conservative in the same direction, so the result is never too
small. It can be loose: a long thin rotated box gets the sphere around its
axis-aligned envelope rather than around itself. That costs draws, never
pixels — see Frustum's note on which direction of error is a bug.
When it returns false
Three cases, and all three mean the same thing to a caller: draw the item.
The geometry cannot state its bounds.computeBounds is probed rather
than called, because RenderItem.geometry is reached by a backend that may
have been handed a structurally-typed geometry — a host's own minimal
object, a test double written before §87 existed. That is the same defence
render-list.ts makes for layers, transparent, and the shadow flags,
with a sharper failure mode if it were omitted: a missing method is a
TypeError inside a frame, which §61 forbids.
The geometry is empty. §53 returns min = +Infinity, max = -Infinity
for a geometry with no vertices — the identity element of bounds union —
and the centre of that box is NaN. An empty geometry draws nothing
anyway, so refusing to bound it costs a test and not a draw.
The matrix or the bounds carry non-finite numbers. A NaN in a world
matrix is an authoring bug somewhere upstream; hiding the object it belongs
to would hide the bug behind a symptom that looks like a culling defect.
out is left in an unspecified state when this returns false — the caller
has been told not to read it.
Writes the world-space bounding sphere of
geometryunderworldMatrixintoout, and returns whether the result is usable.The derivation, in one line each:
cand half-extentse;worldMatrix · c— an ordinary point transform;|M| · e, the matrix with every element replaced by its absolute value applied to the half-extent vector. This is the standard conservative box transform: every corner of the local box lands inside that world box, whatever the rotation, shear, or non-uniform scale;Every step is conservative in the same direction, so the result is never too small. It can be loose: a long thin rotated box gets the sphere around its axis-aligned envelope rather than around itself. That costs draws, never pixels — see
Frustum's note on which direction of error is a bug.When it returns
falseThree cases, and all three mean the same thing to a caller: draw the item.
computeBoundsis probed rather than called, becauseRenderItem.geometryis reached by a backend that may have been handed a structurally-typed geometry — a host's own minimal object, a test double written before §87 existed. That is the same defencerender-list.tsmakes forlayers,transparent, and the shadow flags, with a sharper failure mode if it were omitted: a missing method is aTypeErrorinside a frame, which §61 forbids.min = +Infinity,max = -Infinityfor a geometry with no vertices — the identity element of bounds union — and the centre of that box isNaN. An empty geometry draws nothing anyway, so refusing to bound it costs a test and not a draw.NaNin a world matrix is an authoring bug somewhere upstream; hiding the object it belongs to would hide the bug behind a symptom that looks like a culling defect.outis left in an unspecified state when this returnsfalse— the caller has been told not to read it.