Project a world-space :type:BoundingBox through the camera and return the
fraction of the viewport AREA its screen-space AABB visibly covers — the
metric for selector: 'screen-area'.
Clipped to the viewport. The projected rect is intersected with the
viewport before the area is taken, so the metric reads the portion of the
screen ACTUALLY occupied: a node whose rect extends far off-screen but
clips only a corner reads that small visible fraction (and picks a coarse
level) instead of an arbitrarily large unclipped product — which matters
while panning across partition tiles. The metric therefore tops out at
exactly 1.0 (full coverage); the natural pick uses threshold <= metric, so the fills-screen partition threshold (1.0) is satisfied the
moment coverage is complete, and stays satisfied while zoomed past it. In
NDC each axis spans 2, so the covered fraction is the product of the
clipped half-extents — viewport-size independent by construction (the same
framing yields the same fraction on any monitor).
Degenerate (lower-dimensional) CONTENT ramps to its LINEAR span. For a
rect whose RAW (pre-clip) thin half-extent is below
DEGENERATE_RECT_HALF_EXTENT — sub-pixel thin content: an
axis-aligned straight polyline, an edge-on plane — the area product reads
~0 regardless of how much screen the content spans, which would pin it to
the coarsest level forever (the legacy diagonal metric never had this
failure mode — a diagonal reads the long extent). The metric is therefore
max(area, clippedSpan × (1 − rawThin/DEGENERATE_RECT_HALF_EXTENT)): at
zero thickness it reads the full CLIPPED linear span (a full-width line =
1.0, so the halving ladder keeps its meaning for 1D content), decays
CONTINUOUSLY to the plain area product as the thickness reaches the
sub-pixel floor — no cliff for the hysteresis to oscillate across when an
edge-on plane rotates through the boundary — and is exactly the area
product everywhere above it. A both-axes-degenerate rect (a point) still
reads ~0 → coarsest. The ramp is gated on the RAW thinness so it fires only
for intrinsically thin content — a wide 2D node whose CLIPPED sliver
happens to be thin (mostly panned off-screen) honestly reads its tiny
visible area rather than being inflated to a full linear span.
Fully off-screen rects read exactly 0. A clipped interval that is
INVERTED (no viewport overlap on that axis) zeroes the whole metric before
the degenerate ramp can see it — otherwise a zero-thickness clipped axis
would be indistinguishable from off-screen and the ramp would return the
other axis's span for geometry not on screen at all (the world-space
frustum gate catches most of these, but it is conservative near frustum
corners, so this function must not rely on it).
Same near-plane saturation contract as projectBoxDiagonalPx: under
a PERSPECTIVE camera, bounds reaching the near plane have no meaningful
projection (the homogeneous divide degenerates), so the metric saturates to
+Infinity → finest. An ORTHOGRAPHIC projection never degenerates
(w stays 1) so no saturation applies — the plain clipped metric is
already well-defined, and a camera inside a large node reads full coverage
naturally because its rect spans the viewport. Both selectors share this
contract by design (see the v3.4 spec's normative metric rules).
Project a world-space :type:
BoundingBoxthrough the camera and return the fraction of the viewport AREA its screen-space AABB visibly covers — the metric forselector: 'screen-area'.Clipped to the viewport. The projected rect is intersected with the viewport before the area is taken, so the metric reads the portion of the screen ACTUALLY occupied: a node whose rect extends far off-screen but clips only a corner reads that small visible fraction (and picks a coarse level) instead of an arbitrarily large unclipped product — which matters while panning across partition tiles. The metric therefore tops out at exactly
1.0(full coverage); the natural pick usesthreshold <= metric, so the fills-screen partition threshold (1.0) is satisfied the moment coverage is complete, and stays satisfied while zoomed past it. In NDC each axis spans 2, so the covered fraction is the product of the clipped half-extents — viewport-size independent by construction (the same framing yields the same fraction on any monitor).Degenerate (lower-dimensional) CONTENT ramps to its LINEAR span. For a rect whose RAW (pre-clip) thin half-extent is below DEGENERATE_RECT_HALF_EXTENT — sub-pixel thin content: an axis-aligned straight polyline, an edge-on plane — the area product reads ~0 regardless of how much screen the content spans, which would pin it to the coarsest level forever (the legacy diagonal metric never had this failure mode — a diagonal reads the long extent). The metric is therefore
max(area, clippedSpan × (1 − rawThin/DEGENERATE_RECT_HALF_EXTENT)): at zero thickness it reads the full CLIPPED linear span (a full-width line = 1.0, so the halving ladder keeps its meaning for 1D content), decays CONTINUOUSLY to the plain area product as the thickness reaches the sub-pixel floor — no cliff for the hysteresis to oscillate across when an edge-on plane rotates through the boundary — and is exactly the area product everywhere above it. A both-axes-degenerate rect (a point) still reads ~0 → coarsest. The ramp is gated on the RAW thinness so it fires only for intrinsically thin content — a wide 2D node whose CLIPPED sliver happens to be thin (mostly panned off-screen) honestly reads its tiny visible area rather than being inflated to a full linear span.Fully off-screen rects read exactly 0. A clipped interval that is INVERTED (no viewport overlap on that axis) zeroes the whole metric before the degenerate ramp can see it — otherwise a zero-thickness clipped axis would be indistinguishable from off-screen and the ramp would return the other axis's span for geometry not on screen at all (the world-space frustum gate catches most of these, but it is conservative near frustum corners, so this function must not rely on it).
Same near-plane saturation contract as projectBoxDiagonalPx: under a PERSPECTIVE camera, bounds reaching the near plane have no meaningful projection (the homogeneous divide degenerates), so the metric saturates to
+Infinity→ finest. An ORTHOGRAPHIC projection never degenerates (wstays 1) so no saturation applies — the plain clipped metric is already well-defined, and a camera inside a large node reads full coverage naturally because its rect spans the viewport. Both selectors share this contract by design (see the v3.4 spec's normative metric rules).Exported for unit testing.