Skip to content

feat(core): TerrainController#10134

Merged
felixpalmer merged 8 commits intomasterfrom
felix/terrain-controller
Mar 27, 2026
Merged

feat(core): TerrainController#10134
felixpalmer merged 8 commits intomasterfrom
felix/terrain-controller

Conversation

@felixpalmer
Copy link
Copy Markdown
Collaborator

Background

Currently the MapController has no concept of tracking the terrain. The rotationPivot makes it possible to rotate the view around a fixed point in the scene. This PR introduces a new controller, TerrainController, which automatically tracks the terrain, smoothly updating the position z-component so that it is the same height as the terrain at the center of the viewport

Screen.Recording.2026-03-25.at.20.26.02.mov

Change List

  • Improve Tile3DLayer.filterSubLayer to perform culling to speed up picking performance (conservative approach, could likely do even better)
  • TerrainController._pickTerrainCenterAltitude obtains altitude at viewport center on interaction
  • TerrainController viewport.position[2] updated smoothly on every frame
  • TerrainController._rebaseViewport avoids jump on initial interaction

@felixpalmer felixpalmer requested review from Pessimistress, chrisgervang and ibgreen and removed request for chrisgervang March 25, 2026 19:32
setProps(
props: ControllerProps &
MapStateProps & {
rotationPivot?: 'center' | '2d' | '3d';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be default to 3d for this class?

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 27, 2026

Coverage Status

coverage: 90.907% (-0.2%) from 91.066%
when pulling aae6174 on felix/terrain-controller
into 135d329 on master.

@felixpalmer felixpalmer merged commit d3444a8 into master Mar 27, 2026
3 checks passed
@felixpalmer felixpalmer deleted the felix/terrain-controller branch March 27, 2026 10:02
style={{backgroundColor: '#061714'}}
initialViewState={INITIAL_VIEW_STATE}
controller={{touchRotate: true, inertia: 250}}
controller={{type: TerrainController, touchRotate: true, inertia: 500}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting feature! This seems like one of the first times where a user will pick between controller classes - do our docs cover this interface in the Views guide?

I think it'd be useful to have an API reference for this too. We could make it very intuitive to understand with a few GIFs demoing each mode

@chrisgervang chrisgervang added this to the v9.3 milestone Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants