Documentation
    Preparing search index...

    Function computeWorldBoundingSphere

    • 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:

      1. §53's cached local box gives a centre c and half-extents e;
      2. the world centre is worldMatrix · c — an ordinary point transform;
      3. 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;
      4. 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.

      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.

      Parameters

      • geometry: BufferGeometry

        the item's vertex data (§53). Read, never written.

      • worldMatrix: Matrix4

        the item's resolved world transform (§7), or its §43 interpolated render pose — whichever the render item carries.

      • out: BoundingSphere

        rewritten in place; supply one per call site and reuse it.

      Returns boolean