suggestedDepthRange method

ClipDistances suggestedDepthRange()

Sensible near and far planes for the current framing.

A fixed 0.1..1000 range wastes most of the depth buffer on empty space and z-fights on small models; tying the range to the orbit distance keeps precision where the geometry actually is.

Implementation

ClipDistances suggestedDepthRange() {
  final near = math.max(distance * 0.01, 1e-4);
  // 10x the orbit distance covers the far side of anything frameBounds framed,
  // with room to zoom in. A larger multiplier only spends depth precision on
  // empty space, which is the very thing this method exists to avoid.
  final far = distance * 10.0 + 10.0;
  return ClipDistances(near: near, far: far);
}