fix(camera): re-derive ortho near/far per frame so orbit never clips

The orthographic depth half-range was frozen at fit time and measured along
the fit-time eye direction. A 3-D drawing fitted straight-down (top view) got
a shallow depth span; orbiting only rotated the camera, never resized the
span, so the drawing's width loaded onto the eye axis and overran near/far —
clipping the model the moment it was tilted off top (#473).

Cache the model AABB on the camera and recompute the near/far depth from it
for the live eye direction every frame. This tracks orbit, viewcube snaps,
roll and restored views uniformly, and keeps the same tight, zoom-independent
depth precision (coincident solids / meshes / wires keep their draw order).
Falls back to the scalar half-range / distance-scaled span when no AABB is set.

Closes #473

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-24 14:57:16 +03:00
1 parent 8c36d3aca8
commit 2ff37b088b
2 files changed
+46 -11

No files matched your search

+4
View File
@@ -253,6 +253,10 @@ impl Scene {
// ~6× the view height deep. Orthographic depth precision is linear,
// so the wide range costs no z-fighting.
depth_half_range: (view_height as f32 * 64.0).max(1.0),
// A restored view has no model AABB yet; `fit_depth_to_saved_extents`
// fills it in from $EXTMIN/$EXTMAX right after, so the near/far tracks
// the eye direction once the view is orbited.
model_bounds: None,
})
}