Skip to content

feat(core): smooth noisy pinch frames before applying zoom#10328

Draft
charlieforward9 wants to merge 2 commits into
visgl:masterfrom
NEW-HEAT:codex/touch-pinch-smoothing
Draft

feat(core): smooth noisy pinch frames before applying zoom#10328
charlieforward9 wants to merge 2 commits into
visgl:masterfrom
NEW-HEAT:codex/touch-pinch-smoothing

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Clamps per-event pinch zoom deltas so a single noisy touch frame cannot jump the camera.

Why

Touch pinch streams can produce one bad scale value, especially near finger lift. Applying that raw value directly to zoom makes the map jump even though the user’s gesture was smooth.

Change

  • Track smoothed pinch scale in log2 space for the current gesture.
  • Reset the smoothing state on pinchstart and clear it on pinchend.
  • Clamp each event’s log2(scale) delta to 0.18, roughly a 1.13x zoom step, before applying it.

Validation

  • Added MapController clamps a noisy final pinch frame instead of jumping, covering a 100x scale spike and asserting the zoom delta stays under the per-event cap.
  • Focused local command used while developing: vitest run --project browser test/modules/core/controllers/controllers.spec.ts.

Merge Notes

Independent split from #10303. #10329 handles pinch-end inertia; this PR handles live pinch-frame noise.

Clamp the per-event change in log2(scale) so a single jittery pinch
frame (most commonly the last frame as fingers lift) can't propagate a
spike directly into the camera zoom. The smoothed log-scale is reset on
pinchstart and cleared on pinchend so each gesture stands alone.

The 0.18 cap allows up to ~1.13× zoom per event — comfortably above any
intentional pinch rate but tight enough to swallow sensor noise.
@coveralls

coveralls commented May 22, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 83.392% (+0.002%) from 83.39% — NEW-HEAT:codex/touch-pinch-smoothing into visgl:master

@charlieforward9 charlieforward9 marked this pull request as draft June 11, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants