-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
Pitch > 90 degrees #4851
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4851 +/- ##
==========================================
+ Coverage 89.94% 90.37% +0.42%
==========================================
Files 265 265
Lines 37977 38095 +118
Branches 2529 3191 +662
==========================================
+ Hits 34159 34427 +268
+ Misses 2951 2696 -255
- Partials 867 972 +105 ☔ 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
a5cf6fa
to
02d44fd
Compare
@kubapelc @ibesora would you like to go over this PR as well? |
No, those changes are independent. |
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.
Co-authored-by: Isaac Besora Vilardaga <[email protected]>
I don't think it should be fundamentally impossible. You can make it impossible by setting |
Maybe a good compromise between "going underground is impossible" and "no fundamental limits on going underground" is "mouse/touch navigation never puts the camera underground". Here's a proof of concept that ignores mouse/touch commands that result in the camera being underground. It works in the Changes to handleMapControlsRollPitchBearingZoom(deltas: MapControlsDeltas, tr: ITransform): void {
if (deltas.bearingDelta) tr.setBearing(tr.bearing + deltas.bearingDelta);
- if (deltas.pitchDelta) tr.setPitch(tr.pitch + deltas.pitchDelta);
+ if (deltas.pitchDelta) {
+ const originalPitch = tr.pitch;
+ tr.setPitch(tr.pitch + deltas.pitchDelta);
+ if (tr.getCameraAltitude() < 0) {
+ tr.setPitch(originalPitch);
+ }
+ }
if (deltas.rollDelta) tr.setRoll(tr.roll + deltas.rollDelta);
- if (deltas.zoomDelta) tr.setZoom(tr.zoom + deltas.zoomDelta);
+ if (deltas.zoomDelta) {
+ const originalZoom = tr.zoom;
+ tr.setZoom(tr.zoom + deltas.zoomDelta);
+ if (tr.getCameraAltitude() < 0) {
+ tr.setZoom(originalZoom);
+ }
+ }
} To fully work, this would need to support terrain, and would probably have some glitches due to the fact that terrain is constantly changing as the resolution of queried tiles changes. In the terrain case, it might be better to either accept/reject the entire |
For terrain the following method is being used to make sure the camera is not inside the terrain: maplibre-gl-js/src/ui/camera.ts Lines 1100 to 1113 in 491ac04
Which is being used by a global transform update for every movement of the camera: maplibre-gl-js/src/ui/camera.ts Line 1122 in 491ac04
I'm guessing this should be similar, or the |
We could easily update There are two things I don't like about applying the limit there.
|
For me it feels like solving the same issue in different places, so I prefer to have a single point that handles this, it doesn't have to be the current solution. |
I've moved the "underground" check in the no-terrain case to |
…fied by _elevateCameraIfInsideTerrain()
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 Center Altitude 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
.