Keep the tilt clearance through a zoom in

A zoom in during a pivoting tilt stops at the range that keeps the camera 150 m above the pivot at its current pitch. A zoom that moves the range by less than half a metre (at the clearance, the 80 m floor or the 5,000 km cap) now answers not zoomed instead of ok, and a tilt reports tiltRangeAdjusted rather than orbitRadiusAdjusted.
This commit is contained in:
Manjunath committed 2026-11-03 22:23:38 +05:30
1 parent 9d8db97a33
commit fdecc8c581
4 files changed
+78 -15

No files matched your search

+16 -8
View File
@@ -1932,19 +1932,27 @@ export function moveCamera(args = {}, runNavigation = null) {
* fight the per-frame lookAt (field test: "zoom out did literally nothing").
* A tilt swinging about its pivot holds a range the same way.
* @param {number} factor >1 zooms out (radius grows), <1 zooms in.
* @returns {boolean} true when an orbit or pivoting tilt consumed the zoom.
* @returns {{kind: string, changed: boolean}|null} the motion that consumed
* the zoom, and whether its range moved; null when none did.
*/
export function adjustOrbitRange(factor) {
if (!_active || !['orbit', 'tilt'].includes(_active.kind) || !_active.hpr)
return false;
// The limits never move a view the wrong way: a zoom in leaves a closer
// view in place, and a zoom out leaves a farther one.
const range = _active.hpr.range;
_active.hpr.range = Math.max(
Math.min(80, range),
return null;
// A tilt's zoom in stops at the range that keeps its clearance. The limits
// never move a view the wrong way: a zoom in leaves a closer view in place,
// and a zoom out leaves a farther one.
const { kind, hpr } = _active;
const floor =
kind === 'tilt'
? Math.max(80, TILT_MIN_CLEARANCE_M / Math.abs(Math.sin(hpr.pitch)))
: 80;
const range = hpr.range;
hpr.range = Math.max(
Math.min(floor, range),
Math.min(Math.max(5_000_000, range), range * factor),
);
return true;
// Under half a metre counts as not moved, as for a plain zoom.
return { kind, changed: Math.abs(hpr.range - range) >= 0.5 };
}
/**