-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
Pitch > 90 degrees #4851
base: main
Are you sure you want to change the base?
Pitch > 90 degrees #4851
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4851 +/- ##
==========================================
+ Coverage 87.77% 87.95% +0.18%
==========================================
Files 265 265
Lines 37970 38084 +114
Branches 2446 2415 -31
==========================================
+ Hits 33328 33498 +170
+ Misses 3568 3513 -55
+ Partials 1074 1073 -1 ☔ View full report in Codecov by Sentry. |
Is it possible to move some parts of this to a plugin? Or maybe place that in an example instead? |
Certainly the I think the other changes (change in |
How does elevation and zoom correlate? Can one set an elevation value that will change the zoom value? |
Together, To allow pitch > 90, I want to move the "center point" off of the ground. This will allow the camera to stay above the ground when it pitches above 90.
Where/how should I present the design? |
I've reduced the scope of this PR to only changes that allow |
The design can be presented either as an initial comment of an issue, and initial comment in a PR or a discussion. In any case, the diagram above makes things a lot more clearer. |
Is it possible to clean the git history as well? Sorry for not picking on that, but it makes review harder because I need to expand every time I look at this PR as git thinks there's a lot of commits... |
Can you elaborate a bit of the center change that is added. |
ecb12b8
to
a53c094
Compare
f4a6497
to
338c78b
Compare
const preZoomAroundLoc = tr.screenPointToLocation(panDelta ? around.sub(panDelta) : around); | ||
// If we are rotating about the center point, avoid numerical issues near the horizon by using the transform's | ||
// center directly, instead of computing it from the screen point | ||
const preZoomAroundLoc = around.distSqr(tr.centerPoint) < 1.0e-2 ? |
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 needs to be covered by a test I believe. Same goes for the other place that has a similar logic.
// elevation to Mercator Z using the scale factor at the center point (not the camera point). Since the center point is | ||
// initially unknown, we compute it using the scale factor at the camera point. This gives us a better estimate of the | ||
// center point scale factor, which we use to recompute the center point. We repeat until the error is very small. | ||
// This typically takes about 5 iterations. |
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 there a way to calculate this without an iterative approach? This seems like a heavy calculation that is being made often...
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.
If I'm not missing something, there's 1 cos
, 1 atan
, 1 exp
, and ~20 arithmetic operations per loop. That doesn't seem too heavy to me? I can't think of a way to do it without iteration, but if it's too heavy we could reduce the accuracy threshold, which is currently set at 10^-12 m. This would result in fewer iterations being performed.
…tionsFromCameraLngLatAltRotation()
Allow pitch angle > 90 degrees. #4717
Fixes #3683
Changes:
centerClampedToGround
configuration variable. The default is true, which maintains previous behavior. To use pitch angles higher than 90 degrees, this must be set to true, and the elevation must be provided. The elevation must be floating in space above the ground to keep the camera from going below ground.elevation
toJumpToOptions
. This is needed to set camera pitch > 90 degrees, as the center point must be above the camera, which must be above the terrain.maxPitch
to 180.recalculateZoom()
to keep the camera position constant. This means that it now adjusts the center point, in addition tozoom
andelevation
. This is important to keep the camera from jumping when terrain is updated behind the scenes. This is also the biggest change and the one with the most potential for unwanted ripples.demo: https://nathanmolson.github.io/camera-centric
TODO
Figure out whether
elevation
needs to be added to style spec. Design Proposal: Add Elevation maplibre-style-spec#851Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
Briefly describe the changes in this PR.
Link to related issues.
Include before/after visuals or gifs if this PR includes visual changes.
Write tests for all new functionality.
Document any changes to public APIs.
Add an entry to
CHANGELOG.md
under the## main
section.Additional details about the center point elevation:
The
Transform
variablescenter
,elevation
,zoom
,pitch
,bearing
, andfov
control the location of the camera indirectly.elevation
sets the height of the "center point" above sea level. In the typical use case (centerClampedToGround = true
), the library modifieselevation
in an attempt to keep the center point always on the terrain (or 0 MSL if no terrain is enabled).zoom
sets the distance from the center point to the camera (in conjunction withfovInRadians
, which is currently hardcoded).Together,
zoom
,elevation
, andpitch
set the altitude of the camera.To allow pitch > 90, the "center point" must be placed off of the ground. This will allow the camera to stay above the ground when it pitches above 90. This requires setting
centerClampedToGround = false
The same math applies whether the center point is on terrain or not, and whether the camera is above or below the ground:
In most cases, having the camera underground is undesirable.
To help users position the camera, a new function
calculateCameraOptionsFromCameraLngLatAltRotation()
has been added toCamera
.