Skip to content

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

Open
charlieforward9 wants to merge 1 commit into
visgl:masterfrom
NEW-HEAT:codex/touch-pinch-smoothing
Open

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

Conversation

@charlieforward9
Copy link
Copy Markdown
Collaborator

Clamps 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.

Change

  • Track a _smoothedPinchScaleLog on the existing module-level pinchEventWorkaround, reset on pinchstart and cleared on pinchend.
  • In _onPinch, each new event's log-scale delta is passed through clampPinchZoomDelta (cap = 0.18 log2 units ≈ 1.13× zoom per event) before being applied to controllerState.zoom.
  • Per-event cap is comfortably above any realistic pinch rate and tight enough to swallow sensor noise.

Notes

Tests

  • MapController clamps a noisy final pinch frame instead of jumping — sequence with a 100× scale spike on the final frame asserts the zoom delta stays under the per-event cap.

CI: vitest run --project browser test/modules/core/controllers/controllers.spec.ts.

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
Copy link
Copy Markdown

Coverage Status

coverage: 83.372% (+0.006%) from 83.366% — NEW-HEAT:codex/touch-pinch-smoothing into visgl:master

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