Add ScreenSpaceCameraController.collisionHeightReference #12975
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.
Description
When a 3D tileset is added to the map, height clamping of the camera to the scene takes about 25% of total frame time, mostly due to Model.pick. This PR proposes a new flag on the
ScreenSpaceCameraController
, that will allows users to continue clamping entities to the 3D tileset without also sampling the camera height off the 3D tileset every frame.This is useful when 3D tiles are used in conjuction and closely map to a regular
TerrainProvider
, so entities can useHeightReference.CLAMP_TO_GROUND
and clamp to both terrain and 3D tiles, while the camera can choose to clamp only to the terrain usingHeightReference.CLAMP_TO_TERRAIN
.This is important, as unlike entities which in the future we can improve their clamping performance, every frame that the camera moves it must sample the 3D tiles as well. The current API is insufficient in providing users with a solution to this problem, as they are either forced to disable collision entirely (including against terrain) on the camera, or disable clamping to 3D tilesets entirely (including for entities).
Example
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change