-
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
Match GlobeView projection parameters with Maplibre v5 #9201
base: x/globe-test-app
Are you sure you want to change the base?
Conversation
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.
Looks promising, but I get the page freezing after playing with the controls when viewing the full globe
@@ -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; |
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 wonder if math.gl shouldn't export this - it is used in a number of places
@@ -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; | |||
|
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'm seeing strange things when moving near the poles
Screen.Recording.2024-10-04.at.10.40.03.mov
|
||
constructor(opts: GlobeViewportOptions = {}) { | ||
const { | ||
latitude = 0, | ||
longitude = 0, | ||
zoom = 0, | ||
nearZMultiplier = 0.1, |
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.
Can you document somewhere how you updated these defaults? Is there some magic formula?
@@ -275,7 +275,7 @@ const TEST_CASES = [ | |||
viewState: { | |||
longitude: -6, | |||
latitude: 58, | |||
zoom: 1.5 | |||
zoom: 1.5 + 0.7353406094252244 // Math.log2(1 / Math.PI / Math.cos(58 / 180 * Math.PI)) |
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 feel it is better to update the image than having some weird constant here. There is a significant change in output anyway
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.
Does this constant help see us abnormalities in the images, or have some other benefit for testing?
fovy = altitudeToFovy(altitude); | ||
} | ||
// Used to match globe and web mercator projection at high zoom | ||
const scaleAdjust = 1 / Math.PI / Math.cos((latitude * Math.PI) / 180); |
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.
Worth guarding against division by 0? Despite this, the viewport could still be manually constructed with the pole value
zoom: 0, | ||
pitch: 0, | ||
bearing: 0 | ||
zoom: -1 |
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.
What's a negative zoom mean for globe?
@@ -50,6 +51,8 @@ export type GlobeViewportOptions = { | |||
zoom?: number; |
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.
Worth adding a comment about zoom's range in a globe view?
For #9199
Grid lines are rendered by Maplibre, points are rendered by deck.gl.
Change List
GlobeViewport
's scale, nearZ, farZ with maplibre'sGlobeTransform
GlobeView
switch toWebMercatorViewport
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.