Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match GlobeView projection parameters with Maplibre v5 #9201

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

Pessimistress
Copy link
Collaborator

For #9199

globe

Grid lines are rendered by Maplibre, points are rendered by deck.gl.

Change List

  • Match GlobeViewport's scale, nearZ, farZ with maplibre's GlobeTransform
  • GlobeView switch to WebMercatorViewport at zoom>=12. maplibre performs interpolation between the two projections at z [11, 12]. We may need to do the same, but the difference is honestly very subtle.
  • Some golden images are updated because the zoom -> scale mapping has changed. The new implementation uses an adaptive scale that depends on the latitude of the viewport center.

Copy link
Collaborator

@felixpalmer felixpalmer left a comment

Choose a reason for hiding this comment

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

Looks promising, but I get the page freezing after playing with the controls when viewing the full globe

modules/core/src/controllers/globe-controller.ts Outdated Show resolved Hide resolved
@@ -9,6 +9,9 @@ import {MapState, MapStateProps} from './map-controller';
import {mod} from '../utils/math-utils';
import LinearInterpolator from '../transitions/linear-interpolator';

// matches Web Mercator projection limit
const MAX_VALID_LATITUDE = 85.051129;

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 seeing strange things when moving near the poles

Screen.Recording.2024-10-04.at.10.40.03.mov

modules/core/src/viewports/globe-viewport.ts Show resolved Hide resolved
test/modules/geo-layers/tileset-2d/utils.spec.ts Outdated Show resolved Hide resolved
modules/core/src/viewports/globe-viewport.ts Show resolved Hide resolved
zoom: 0,
pitch: 0,
bearing: 0
zoom: -1
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's a negative zoom mean for globe?

@@ -50,6 +51,8 @@ export type GlobeViewportOptions = {
zoom?: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth adding a comment about zoom's range in a globe view?

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

This looks quite clean, I don't see any immediate reason why we wouldn't want to merge this as experimental in 9.1.

modules/core/src/controllers/globe-controller.ts Outdated Show resolved Hide resolved
@@ -20,7 +23,7 @@ class GlobeState extends MapState {
if (longitude < -180 || longitude > 180) {
props.longitude = mod(longitude + 180, 360) - 180;
}
props.latitude = clamp(latitude, -89, 89);
props.latitude = clamp(latitude, -MAX_VALID_LATITUDE, MAX_VALID_LATITUDE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we go all the way? or do we need some offset to avoid issues?

Copy link
Collaborator Author

@Pessimistress Pessimistress Dec 11, 2024

Choose a reason for hiding this comment

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

If we let latitude=90 then the controller goes into gimbal lock. It is a solvable problem, but irrelevant to this PR.

resolution = 10
} = opts;

let {height, altitude = 1.5} = opts;
let {height, altitude = 1.5, fovy} = opts;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: FWIW, I have consistently been adding a defaultOptions object to classes in luma.gl so that I can document all default options in one place rather than spreading out the default values in a bunch of descructuring calls like this.

static defaultOptions: Required<GlobeViewportOptions> = {
 ...
};
this.options ={...GlobeViewport.defaultOptions, ...options};

modules/core/src/viewports/globe-viewport.ts Show resolved Hide resolved
@@ -37,8 +38,8 @@ export default class GlobeView extends View<GlobeViewState, GlobeViewProps> {
super(props);
}

get ViewportType() {
return GlobeViewport;
getViewportType(viewState: GlobeViewState) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Nit: It just seems a bit weird that one of these takes an argument and the others do not. Should we allow it to be omitted?
  • Not sure if making the types less restrictive could be useful? - i.e. only ask for what we need to answer the question
Suggested change
getViewportType(viewState: GlobeViewState) {
getViewportType(viewState: {zoom: number}) {

test/modules/geo-layers/tileset-2d/utils.spec.ts Outdated Show resolved Hide resolved

height = height || 1;
altitude = Math.max(0.75, altitude);
if (fovy) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This aligns us more with other views, right?
We always support fovy and altitude is a backup for geospatial views?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is correct.
altitude is a parameter we inherited from the mapbox/maplibre. The name is a bit misleading. It refers to the camera's distance to the sea plane.

modules/core/src/viewports/globe-viewport.ts Show resolved Hide resolved
Copy link
Collaborator

@felixpalmer felixpalmer left a comment

Choose a reason for hiding this comment

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

@Pessimistress I believe the page freeze is unrelated to this PR #9265

@felixpalmer felixpalmer mentioned this pull request Dec 4, 2024
45 tasks
@Pessimistress Pessimistress changed the base branch from x/globe-test-app to master December 11, 2024 17:55
@coveralls
Copy link

Coverage Status

coverage: 91.702% (-0.003%) from 91.705%
when pulling 2f8996f on x/globe-view
into 0a4a25a on master.

@Pessimistress Pessimistress merged commit e9eada6 into master Dec 11, 2024
4 checks passed
@Pessimistress Pessimistress deleted the x/globe-view branch December 11, 2024 18:47
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.

5 participants