Project a :type:BoundingBox through its box-to-clip matrix and
return the diagonal of the screen-space AABB in pixels.
The box and matrix must use the same coordinate frame: the registry passes
group-local bounds with projection × view × group-world, while callers that
omit the matrix pass world bounds and use projection × matrixWorldInverse.
Treats the bbox's 8 corners independently (works for both
perspective and orthographic projection without a closed-form
radius). NDC → pixels assumes the viewport size matches the
renderer canvas.
Near-plane saturation. Projects with an explicit homogeneous w (the
supplied box-to-clip matrix (or projection × matrixWorldInverse), not THREE's
Vector3.project which divides by w unguarded). If any corner has
w <= W_EPSILON the eye plane cuts the box. With the camera INSIDE the box
the group fills the screen, so we return +Infinity to saturate the
selector to its finest level (pickChildWithHysteresis then picks the top
index; the value is never fed to finite arithmetic, so no NaN). With the eye
outside it (a box running past the camera) the rect is that of the part in
front of the near plane (clippedNdcRect) — unclipped by the viewport,
so usually large, but finite (#2944 review B). Saturating was the inverse of
the old behaviour, where a corner crossing behind the near plane collapsed
the diagonal and wrongly dropped to a coarse level on close approach.
Orthographic cameras keep w == 1 and so never saturate.
Project a :type:
BoundingBoxthrough its box-to-clip matrix and return the diagonal of the screen-space AABB in pixels. The box and matrix must use the same coordinate frame: the registry passes group-local bounds with projection × view × group-world, while callers that omit the matrix pass world bounds and use projection × matrixWorldInverse.Treats the bbox's 8 corners independently (works for both perspective and orthographic projection without a closed-form radius). NDC → pixels assumes the viewport size matches the renderer canvas.
Near-plane saturation. Projects with an explicit homogeneous
w(the supplied box-to-clip matrix (or projection × matrixWorldInverse), not THREE'sVector3.projectwhich divides bywunguarded). If any corner hasw <= W_EPSILONthe eye plane cuts the box. With the camera INSIDE the box the group fills the screen, so we return+Infinityto saturate the selector to its finest level (pickChildWithHysteresisthen picks the top index; the value is never fed to finite arithmetic, so no NaN). With the eye outside it (a box running past the camera) the rect is that of the part in front of the near plane (clippedNdcRect) — unclipped by the viewport, so usually large, but finite (#2944 review B). Saturating was the inverse of the old behaviour, where a corner crossing behind the near plane collapsed the diagonal and wrongly dropped to a coarse level on close approach. Orthographic cameras keepw == 1and so never saturate.Exported for unit testing.