fix(viewer): ease wheel zoom in every view, bound bursts, read deltaMode, add a zoom-speed setting (#9507)

Merged
LO
21d ago
+1365-294

Closes #9507

User feedback said the viewer is hard to navigate because zoom is too aggressive. The size of one notch was fine: about 10%, like MapLibre and Potree. The trouble was how each step landed: in a single frame, and with nothing stopping bursts from compounding. This PR brings wheel zoom in line with what the open-source viewers and map libraries we compared do (comparison in #9507).

What changes

  • Eased wheel zoom in every view (3D viewport, Drawing panel, plan). A notch's first slice lands in the event itself, so the response starts in the same frame. The rest drains over about 180 ms (time constant 60 ms), at most one notch per frame.
  • Bursts are bounded. At most three notches can be pending. Twenty notches arriving inside one frame now zoom about 3.2 notches instead of compounding 20 × 10%.
  • Continuous input is not eased. Trackpad scroll, pinch and smooth-wheel deltas apply directly, as MapLibre does, because easing them only adds lag.
  • Cancel rules: reversing the wheel drops the queue; any other move of the view (orbit, pan, preset view, fly, Fit, +/−) cancels it. prefers-reduced-motion applies every step at once.
  • One deltaMode reading (lib/navigation/wheel-input.ts) for 3D, drawing, plan, fly speed and the appearance preview. Before, 3D and plan ignored deltaMode, the drawing used ×16 and fly used ×33; a Firefox line-mode notch now zooms as far as a Chromium pixel notch.
  • New setting: Settings → Display → Navigation → Wheel zoom speed: Slow, Normal or Fast (about 5%, 10% or 20% per notch). Saved per browser, used by all three views. Translated into de, fr, it and ru.
  • Behaviour change: a plan-view notch is now 10% instead of 14%, matching the other views.

Design

  • lib/navigation/wheel-zoom-smoother.ts: a pure smoother (backlog, ease, caps, cancel), with an injected clock and frames.
  • createWheelZoomController in wheelZoom.ts combines the fine-step modifier, input reading and the smoother. createViewportWheelZoom adds a camera step: cursor anchor plus surface standoff (#5393). createTransformWheelZoom adds a 2D transform step.
  • A notch's travel is clamped to one camera notch before smoothing, which keeps today's 10% maximum for the 120 px and 150 px (HiDPI) notches Chromium sends; the camera used to clip those itself.
  • No renderer API change: the smoother feeds camera.zoom steps of at most one notch.
  • useMouseControls.ts shrinks; its allowlist budget is lowered from 893 to 880.

Review follow-ups (independent review, fixed in 3b1d4a5ce)

  • 3D: a zoom step clears the gesture-end timer an earlier settled zoom armed, so isInteracting and the camera-interacted signal never fire mid-zoom.
  • 2D: the drawing and plan transforms have one writer that resolves functional updates against the live ref. A drag pan queued in the same frame as a zoom step is kept and cancels the rest of the zoom.
  • The pose key includes the orthographic size, so a centred ortho zoom by another control cancels a pending wheel zoom.
  • Continuous input (pinch, trackpad) is capped at one camera notch per event, as on main.
  • New regression tests cover the 3D timer, the drawing pan and the large pinch. The 3D-timer and drawing-pan tests were each confirmed to fail with their fix reverted.

Evidence

Real Chromium, measured per frame on AC20-FZK-Haus.ifc by the new tests/e2e/wheel-zoom-easing.e2e.spec.ts (3/3 runs with --repeat-each=3). The ratios are camera-to-target distance during zoom-out; half of each step moves the orbit target (the existing anti-Zeno dolly), so one notch reads as about 5%.

Measured
Slice landing in the wheel event×1.012 (24% of the notch)
Following frames1.019 → 1.037 → 1.045 → 1.048 → … → 1.051 (settled within ~10 frames)
One notch, settled×1.051
20 notches in one task×1.174, about 3.2 notches (old per-event cap: 1.05²⁰ ≈ 2.65)
Firefox line-mode notch (deltaY 3, deltaMode 1)×1.051, same as pixel mode

Tests

  • New unit tests:
    • wheel-zoom-smoother.test.ts: fake clock and frames; ease timing, per-step cap, burst cap, continuous input, reversal, foreign move, reduced motion, frozen clock, dispose.
    • wheel-input.test.ts: units, compounding, sensitivity.
  • Hook tests drive frames by hand through a new test/manual-frames.ts helper instead of waiting on real time. They cover the 3D viewport (ease, orbit cancels, sensitivity, reduced motion, pinch speed), the drawing (ease, a pan cancels, burst, sensitivity, units) and the plan.
  • Local runs:
    • pnpm typecheck and pnpm lint pass.
    • node scripts/pre-handoff.mjs: all 14 gates pass.
    • Full viewer suite in 16 shards: every shard green. Five failures in the first run came from a stale local fixture copy (SHA mismatch with the manifest); all five passed after pnpm fixtures.
    • The 367 wheel, plan, drawing, measure, fly and settings tests pass again on the rebased head.
    • e2e: wheel-zoom-easing, navigation-presets and entity-context-menu pass.