-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Do not update camera zoom when DEM data isn't available yet #11461
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.
I'm still recreate the linked issue in this PR by zooming before terrain loads. This makes me think that the issue might be in the camera transformation algorithm itself.
Thanks for testing and the catch @SnailBones ! I'll close that tentative fix for now, until we find a more appropriate one as it's still possible to trigger that issue when zooming in before the terrain is loaded (resulting in the camera being below ground). |
aa57c06
to
885321c
Compare
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.
Great work @karimnaaji!
A few nits: thoughts on changing the variable names to make the code more clear?
For instance, cameraZoom
could perhaps be cameraHeight
since zoom suggests a relationship to map zoom.
And perhaps _updateCameraOnTerrain
could be called _resetCameraIfNoTerrain
.
The unit tests look great. Have you looked into render tests for this? Would it be possible to simulate the case that was causing this bug by placing the camera at high pitch and zoom and loading terrain after a wait
?
That's a good point,
Hmm 🤔 I've kept
Good call, although I think the unit test to be enough in that particular instance. The original issue is network-dependent and more difficult to recreate in a render test the way it is done in the unit test without introducing flakiness. Render tests are a better fit for visual testing or to be on-par with gl-native rather than a fine-grained data order/network testing. |
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 like the change to _seaLevelZoom
, LGTM!
Fixes issues when camera center would not change altitude if exaggeration changed and that camera could appear under terrain. Similar to #11461, the customer was affected (https://github.com/mapbox/mapbox-maps-android-internal/issues/850) by camera moved underground when animating exaggeration, increasing it from 0 in high altitude areas. In such an use case, we didn't adjust center and camera MSL altitude with exaggeration change. Extended usage of Transform._centerAltitudeValid to renamed _centerAltitudeValidForExaggeration: while data is not available, _centerAltitudeValidForExaggeration is 0. As soon as center elevation is available, new value for _centerAltitudeValidForExaggeration would trigger camera altitude adjustment in updateElevation.
* Fix camera under terrain when exaggeration changes Fixes issues when camera center would not change altitude if exaggeration changed and that camera could appear under terrain. Similar to #11461, the customer was affected (mapbox/mapbox-maps-android-internal#850) by camera moved underground when animating exaggeration, increasing it from 0 in high altitude areas. In such an use case, we didn't adjust center and camera MSL altitude with exaggeration change. Extended usage of Transform._centerAltitudeValid to renamed _centerAltitudeValidForExaggeration: while data is not available, _centerAltitudeValidForExaggeration is 0. As soon as center elevation is available, new value for _centerAltitudeValidForExaggeration would trigger camera altitude adjustment in updateElevation. * Fog demo: change exaggeration by pitch and zoom options Added exaggeration change on zoom (issue #11044 is still open) and pitch (bug #11589) to fog demo. Fixes: #11589 Co-authored-by: Aleksandar Stojiljković <aleksandar.stojijkovic@mapbox.com>
* Fix camera under terrain when exaggeration changes Fixes issues when camera center would not change altitude if exaggeration changed and that camera could appear under terrain. Similar to mapbox#11461, the customer was affected (https://github.com/mapbox/mapbox-maps-android-internal/issues/850) by camera moved underground when animating exaggeration, increasing it from 0 in high altitude areas. In such an use case, we didn't adjust center and camera MSL altitude with exaggeration change. Extended usage of Transform._centerAltitudeValid to renamed _centerAltitudeValidForExaggeration: while data is not available, _centerAltitudeValidForExaggeration is 0. As soon as center elevation is available, new value for _centerAltitudeValidForExaggeration would trigger camera altitude adjustment in updateElevation. * Fog demo: change exaggeration by pitch and zoom options Added exaggeration change on zoom (issue mapbox#11044 is still open) and pitch (bug mapbox#11589) to fog demo. Fixes: mapbox#11589 Co-authored-by: Aleksandar Stojiljković <aleksandar.stojijkovic@mapbox.com>
Make sure to not update camera zoom when the terrain DEM data isn't available at center point, which is the reference to calculate the camera zoom over terrain. This fixes the following issue that was reported by customer:
Edited-gljs.mov
More description of the issue and a reproducible case is available here https://github.com/mapbox/gl-js-team/issues/341
Launch Checklist
mapbox-gl-js
changelog:<changelog>Fix a potential issue with camera going under the terrain when the DEM data isn't available at center point.</changelog>