Skip to content

Match GlobeView projection parameters with Maplibre v5#9201

Merged
Pessimistress merged 5 commits intomasterfrom
x/globe-view
Dec 11, 2024
Merged

Match GlobeView projection parameters with Maplibre v5#9201
Pessimistress merged 5 commits intomasterfrom
x/globe-view

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


// 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

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.

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.

} = 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};


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}) {


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.

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.

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