feat(core): GlobeView pointer-anchored zoom (wheel + transitions)#10307
Open
charlieforward9 wants to merge 3 commits into
Open
feat(core): GlobeView pointer-anchored zoom (wheel + transitions)#10307charlieforward9 wants to merge 3 commits into
charlieforward9 wants to merge 3 commits into
Conversation
Replace the `log.warn('around not supported in GlobeView')` no-op
with real spherical anchoring, mirroring the existing planar branch:
- `initializeProps`: when the start viewport is a GlobeViewport and the
screen anchor falls on the globe (`isPointOnGlobe`), unproject it to
lng/lat and stash it as `aroundLngLat`.
- `interpolateProps`: each frame, call `panByGlobeAnchor(aroundLngLat,
lerp(start.around, end.around, t))` so the geographic point stays
pinned under the anchor screen point during the transition.
This makes the `_onDoubleClick` zoom transition (`_getTransitionProps
({around: pos})`) actually anchor on GlobeView. Previously the warn
fired and the LERP ran without anchor maintenance, which read as a
center-anchored zoom-in regardless of where the user tapped.
Tests cover the on-globe anchored path and the off-globe fall-through.
Collaborator
Author
|
Added a follow-up commit ( BackgroundThe existing Change
Tests
Happy to split this into a separate PR stacked on top of #10307 if you'd rather review it independently — let me know. |
- Consolidate stray imports at the top of the file. - Document the two GLOBE_ZOOM_ANCHOR_* constants so the empirical damping behavior (start damping at 0.75 of the limb, never below 35% strength) is self-explanatory. - Add a JSDoc to _getRayToGlobe explaining it as the shared ray/sphere math helper for unproject + isPointOnGlobe + panByGlobeAnchor.
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.
Summary
Adds an opt-in
zoomAround: 'pointer'controller option that keeps the geographic point under the cursor/touch fixed during zoom — for wheel/pinch and for the dblclick zoom transition.controller.ts: newzoomAround?: 'center' | 'pointer'option onControllerOptions.globe-controller.ts:GlobeStategainszoomStart/zoomEndand a refactoredzoomthat usesGlobeViewport.panByGlobeAnchorwhenzoomAround === 'pointer'. Off-globe taps fall through to a plain zoom.globe-viewport.ts:_getRayToGlobehelper builds the ray/sphere math used byunproject,isPointOnGlobe, andpanByGlobeAnchor. JSDoc on the helper explains the contract.isPointOnGlobe(xy, { maxDistanceRatio }).panByGlobeAnchor(anchorLngLat, pixel)with documented edge-damping (anchor starts loosening at0.75 × limb radiusand never goes below0.35 × strength) so near-edge anchors don't snap the camera.linear-interpolator.ts: replaces the priorlog.warn('around not supported in GlobeView')no-op with real spherical anchoring —initializePropsstashesaroundLngLat,interpolatePropsrunspanByGlobeAnchoreach frame. Off-globe anchors fall through to a plain LERP. This is what makes the dblclick zoom transition land on the tap point instead of the camera center.Why
Pointer-anchored zoom matches Google Earth-style interaction. Keeping the option opt-in (default remains
'center') avoids changing existing GlobeView behavior.Tests
GlobeController supports pointer anchored zoom option— wheel on a globe with{zoomAround: 'pointer'}shifts longitude; default does not.GlobeViewport#isPointOnGlobe— center hits the globe, corner misses.LinearInterpolator anchors transitions on GlobeViewport—initializePropsrecordsaroundLngLat, mid-transition longitude shifts.LinearInterpolator falls back to a plain LERP when the GlobeView anchor is off-globe— corner anchor leavesaroundLngLatundefined.CI:
vitest run --project browser test/modules/core/controllers/controllers.spec.ts test/modules/core/viewports/globe-viewport.spec.ts test/modules/core/transitions/linear-interpolator.spec.ts.