feat(core): smooth noisy pinch frames before applying zoom#10328
Open
charlieforward9 wants to merge 1 commit into
Open
feat(core): smooth noisy pinch frames before applying zoom#10328charlieforward9 wants to merge 1 commit into
charlieforward9 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_smoothedPinchScaleLogon the existing module-levelpinchEventWorkaround, reset onpinchstartand cleared onpinchend._onPinch, each new event's log-scale delta is passed throughclampPinchZoomDelta(cap = 0.18 log2 units ≈ 1.13× zoom per event) before being applied tocontrollerState.zoom.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.