-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(mapbox): support Maplibre globe projection #9296
Conversation
faa9aed
to
90eff32
Compare
@@ -58,6 +58,10 @@ export type GlobeViewportOptions = { | |||
nearZMultiplier?: number; | |||
/** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1` */ | |||
farZMultiplier?: number; | |||
/** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit nervous about having these overrides, especially as nearZ
and nearZMultiplier
do the same thing. Should we issue a warning if both are supplied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this can be confusing (and wasn't an easy thing to catch when I was first learning it). FWIW, web-mercator-viewport has had these same overrides for a long time.
A warning would be nice.. the multipliers have defaults assigned, so we'd just need to assign those after checking the user-supplied values (or else, they'd always print).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look confusing and somewhat intimidating. I think these props were originally intended as a semi-undocumented escape hatch but now I seem to see these being "touched" in every PR...
If not a coincidence, might be good to audit this API with an eye towards making it as fail proof as possible for new (and old) users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In deck.gl terms, *ZMultiplier
is a ViewProp - you set it to a constant and the effect will be (somewhat) consistent across all camera positions. *Z
is a ViewState - the proper value will be derived from zoom, pitch etc.
For example, MapView
by default places the far plane at sea level on the top(far) edge of the viewport. In the earth quake example we set farZMultiplier
to an arbitrary large number in order to display data points below the ocean surface.
Realistically, users almost never calculate the near/far planes manually. If they want to achieve a non-default effect, they will likely use *ZMultiplier
. If they want to match an external camera (from base map, three.js, etc.) they set *Z
values from an external source.
|
||
export function getDefaultView(map: Map): GlobeView | MapView { | ||
if (getProjection(map) === 'globe') { | ||
return new GlobeView({id: 'mapbox'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detect maplibre and instead call view 'maplibre'
? Or choose a common name like 'map-overlay'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a reliable way to detect mapbox vs maplibre, given that we also support a wide range of versions of each library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's not the best name. Unfortunately, this is used in some edge cases... @chrisgervang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a question of whether this would be a breaking change for the multi-view edge cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exciting support!
There's a lot of branching to support different API versions... at some point it'll be cleaner to maintain (and document) as two modules. But this is probably fine for 9.1
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
import {MapboxOverlay as DeckOverlay} from '@deck.gl/mapbox'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rename/alias things? If we are not happy with the name, rename it at export? If trying to make code clearer a longer name might be needed? Any name that mentions either just Deck or Mapbox is going to be confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For legacy reasons we are exporting all integration classes into the global deck
namespace. MapboxOverlay
and GoogleMapsOverlay
were named to differentiate from each other.
The proper naming convention should probably be something like deck.mapbox.DeckOverlay
, deck.maplibre.DeckOverlay
and deck.googlemaps.DeckOverlay
.
I don't like the current state either, but 9.1 is not a good time to make breaking changes like this.
@@ -58,6 +58,10 @@ export type GlobeViewportOptions = { | |||
nearZMultiplier?: number; | |||
/** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1` */ | |||
farZMultiplier?: number; | |||
/** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look confusing and somewhat intimidating. I think these props were originally intended as a semi-undocumented escape hatch but now I seem to see these being "touched" in every PR...
If not a coincidence, might be good to audit this API with an eye towards making it as fail proof as possible for new (and old) users.
6a24007
to
d55d144
Compare
For #9199
Note: requires #9295
Tested for overlaid and interleaved modes
Change List
MapboxOverlay
switches views based on map projection mode