Skip to content

Conversation

@felixpalmer
Copy link
Collaborator

@felixpalmer felixpalmer commented Dec 12, 2025

Closes #9676

Background

The GlobeController has always been flaky, but since the changes made in order to integrate with Maplibre Globe, the controls in deck.gl are hopelessly broken: https://deck.gl/examples/globe-view

One of the causes for the breakage is the introduction of a scaleAdjust parameter which:

 "Exagerates distance by latitude to match the Web Mercator distortion. The goal is that globe and web mercator projection results converge at high zoom"

New handling

This PR changes the way the controls work, to bring them closer to what Maplibre is doing:

  • Dragging in the mouse X/Y plane translates linearly to a lon/lat rotation of the globe
  • Dragging is scaled by zoom, so that the geographic location dragged stays roughly under the cursor
  • Zooming is just a straighforward interaction for now, the mouse/touch position is ignore (Maplibre is better here)

Zoom adjustment

The new requirement that "globe and web mercator projection results converge" means we have to treat zoom differently in globe view, and it is arguably a bit counterintuitive as it no longer is related to size of the globe on-screen.

This PR replaces the scaleAdjust parameter with a zoomAdjust parameter that is mathematically equivalent, but easier to use in the code, in particular when it comes to clipping the zoom to minZoom and maxZoom.

Testing

Here is how the new behavior looks:

Panning

globe-controller

Zooming

globe-controller2

Transition

globe-controller3

Note that it is not trivial to add these changes to the Controller and ViewState classes without breaking the controls either in the Maplibre Globe view or the standard Web Mercator controls

Change List

  • Replace scaleAdjust with zoomAdjust
  • Rewrite panByPosition handler for GlobeViewport
  • Pass additional context startPixel to panByPosition handlers

@coveralls
Copy link

Coverage Status

coverage: 91.067% (+0.01%) from 91.055%
when pulling fb25012 on felix/improved-globe-controls
into 528bb50 on master.

Copy link
Collaborator

@chrisgervang chrisgervang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much appreciated. There aren't any "before" comparisons, which is fine, but would you say there is anything significantly different?

It'd be great to have some tests added for the maths, and a pass taken on the docs

/**
* End panning
* Must call if `panStart()` was called
* Must call if `panStart()` was not called
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused - when are you supposed to call this? Could we rewrite this as the positive form rather than the negative?

@felixpalmer
Copy link
Collaborator Author

This is much appreciated. There aren't any "before" comparisons, which is fine, but would you say there is anything significantly different?

The current behavior is on the website https://deck.gl/examples/globe-view, I would go as far as to say it’s basically unusable

* @return {Object} props of the new viewport
*/
panByPosition(coords: number[], pixel: number[]): any {
panByPosition(coords: number[], pixel: number[], startPixel?: number[]): any {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assumption (at least with the other viewports) is that startPixel is this.project(coords). Is it not the case with globe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as you can start the interaction outside the globe - try it on the website example, it’s impossible to rotate the globe, and contrast to how MapLibre behaves

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.

[Bug] Panning GlobeView is jittery

5 participants