-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Prevent pitching when zooming into terrain #12280
Closed
Closed
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1159341
remove code that pitches camera above terrain WIP
avpeery 5364b04
WIP
avpeery 47504b8
remove changing z position and updating camera orientation
avpeery b01337e
re-add change to minHeight
avpeery 5e01266
remove extra spacing
avpeery da3d155
update integration tests - since pitch is not being adjusted
avpeery b5cb3ac
fix failing unit tests, remove unused code
avpeery e590e8e
add new render test to show camera stops and doesn't pitch when colli…
avpeery 7ad12dc
fix clipping terrain with drag gestures
avpeery f434e74
formatting fix
avpeery 9556be9
revert to original comment
avpeery 5c70f09
decreased clipping
avpeery 59c4b2a
removing orientation change - does not help lessen clipping
avpeery 2636f8f
update render tests
avpeery 30e461f
run constrainCamera when camera is moving and when potential style or…
avpeery 619f578
typo
avpeery 2e7e89e
update averageElevation unit test
avpeery 4001079
reset pitch and bearing for unit test
avpeery f159782
skip constraining when zooming as it is already contrained
avpeery 62e080f
change comment
avpeery 6fb34fe
add comment to explain hard-coding 85 value
avpeery 7454aef
Wording
avpeery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+5.72 KB
...ntegration/render-tests/debug/terrain/camera-collides-with-terrain/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
test/integration/render-tests/debug/terrain/camera-collides-with-terrain/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"version": 8, | ||
"metadata": { | ||
"test": { | ||
"height": 256, | ||
"width": 256 | ||
} | ||
}, | ||
"center": [ | ||
-104.93611234965806, | ||
38.85724324489064 | ||
], | ||
"zoom": 22, | ||
"pitch": 85, | ||
"bearing": -79, | ||
"terrain": { | ||
"source": "rgbterrain", | ||
"exaggeration": 1 | ||
}, | ||
"sources": { | ||
"rgbterrain": { | ||
"type": "raster-dem", | ||
"tiles": [ | ||
"local://tiles/12-759-1609.terrain.png" | ||
], | ||
"maxzoom": 11, | ||
"tileSize": 256 | ||
} | ||
}, | ||
"glyphs": "local://glyphs/{fontstack}/{range}.pbf", | ||
"layers": [ | ||
{ | ||
"id": "background", | ||
"type": "background", | ||
"paint": { | ||
"background-color": "gray" | ||
} | ||
}, | ||
{ | ||
"id": "hillshade-translucent", | ||
"type": "hillshade", | ||
"source": "rgbterrain", | ||
"paint": { | ||
"hillshade-exaggeration": 1 | ||
} | ||
} | ||
] | ||
} |
Binary file modified
BIN
-17.1 KB
(42%)
test/integration/render-tests/debug/terrain/camera-under-terrain/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+774 Bytes
(110%)
test/integration/render-tests/terrain/buildings-on-raster/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the reason for hard-coding this value? Maybe add context in a comment?
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.
Added a comment. In maps with maxPitch set to less than 85, fast-zooming past terrain is exasperated since it would adjust the camera position too early. Hard-coding this value to 85 instead of maxPitch reduces this experience in these 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.
Since
Math.cos(degToRad(85))
<Math.cos(degToRad(0))
, should we use the upper bound of the possible values in order to keep a constantminHeigh
safe bound? That would mean directly using:Since
Math.cos(degToRad(0))
is 1. Would that work or lead to issues in practice?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.
The initial experience of using
minHeight = this._minimumHeightOverTerrain()
is a bit more jarring. if you bounce into the terrain it pushes the camera farther up and away. It also allowed for the camera to go under the terrain. I'll look into whyThere 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.
Nit: If this is the correct value, should we consider hard coding the result in order to avoid an
unnecessary cos()
operation?Though, have you experimented with other values to see if you the behavior can be smoother?