Camera clipping-plane policy extracted from SceneManager.
Three independent behaviours live here as pure helpers that take
a narrow ClippingCtx rather than reading SceneManager fields:
applyClippingPlanes — apply explicit near/far with
validation and Z-precision warnings.
autoAdjustFromBounds — derive near/far from scene bounds
(metadata first, geometry fallback), feed scene scale into
controls, and apply.
updateDynamicFromCache — per-frame near/far from a cached
bounding sphere; zero allocations, and zero scene-graph
traversal once the bounds are cached (a metadata-less scene
re-walks each frame). Skips updates < 0.1% change for stability.
Both bounds-derived paths clamp near to the SHARED
nearPlaneFloor(R, far), which bounds the near/far ratio to
MAX_NEAR_FAR_RATIO and thereby the depth-buffer quantization. The
two paths compute the same math twice on purpose (the per-frame one
must not allocate); clipping-policy.test.ts pins them to identical
values so the duplication cannot drift.
The host owns ClippingState (enabled flag) and threads it
through alongside camera / controls / scene refs. Event dispatch
remains at SceneManager call sites — these helpers never call
dispatchEvent.
Camera clipping-plane policy extracted from SceneManager.
Three independent behaviours live here as pure helpers that take a narrow
ClippingCtxrather than reading SceneManager fields:applyClippingPlanes— apply explicit near/far with validation and Z-precision warnings.autoAdjustFromBounds— derive near/far from scene bounds (metadata first, geometry fallback), feed scene scale into controls, and apply.updateDynamicFromCache— per-frame near/far from a cached bounding sphere; zero allocations, and zero scene-graph traversal once the bounds are cached (a metadata-less scene re-walks each frame). Skips updates < 0.1% change for stability.Both bounds-derived paths clamp
nearto the SHAREDnearPlaneFloor(R, far), which bounds the near/far ratio toMAX_NEAR_FAR_RATIOand thereby the depth-buffer quantization. The two paths compute the same math twice on purpose (the per-frame one must not allocate);clipping-policy.test.tspins them to identical values so the duplication cannot drift.The host owns
ClippingState(enabled flag) and threads it through alongside camera / controls / scene refs. Event dispatch remains at SceneManager call sites — these helpers never calldispatchEvent.