Skip to content

fix(examples): keep the terrain example's camera above ground across changes - #731

Merged
kylebarron merged 1 commit into
mainfrom
kyle/cog-terrain-camera-fixes
Oct 16, 2026
Merged

kylebarron merged 1 commit into
mainfrom
kyle/cog-terrain-camera-fixes

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

Follow-ups to #720's terrain example, from a final review of its camera changes:

  • Scene changes reset the exaggeration to the default 1.5x. Every start view is set for it. At 3x, NAIP's start put the camera inside the terrain in short windows, and jumped back about 1.6 zoom levels in 750 px ones.
  • Lowering the exaggeration leaves the camera where it is. Lowered with the terrain, the camera ended up nearer the ground, and the new TerrainController's first pick could zoom past maxZoom and jump back. Raising it still raises the camera with the terrain.
  • The camera math uses the window's size. The view states the controller emits keep a stale size after a resize, until you next move the map.
  • Wording:

Not fixed: the first pick after an exaggeration change

The review found that the new TerrainController's first pick can land on the wrong ground, and suggested a new TerrainLayer per exaggeration. I tried that, and also waiting for the terrain to load before handing the camera to a TerrainController. Neither changed the result.

  • Raising NAIP from 1.5x to 2x put the target at 6,005 m on terrain beyond the summit. The slope in view is at 8,360 m.
  • This happened even with every terrain tile loaded.
  • The pick reports the correct terrain tile, but a point farther along the view ray than the visible surface.
  • Picks from a view whose target is on the ground come back correct, so this looks like a deck.gl picking issue.

The README now describes it: the target eases to the ground as you move, so zooming straight in after raising the exaggeration can take the camera into the slope.

Checked in headed Chrome at 1200x750:

  • 1.5x to 3x one step at a time, and back down to 1x. The zoom never passed 12.2, and the terrain stayed in view.
  • Scene switches reset the slider, and NAIP's start view lands where it does on first load (zoom 13.58).
  • No console errors.

🤖 Written by Claude Code

…changes

Follow-ups from the last review of #720:

- Reset the exaggeration to the default on a scene change. Every start view
  is set for it, and at 3x NAIP's start put the camera inside the terrain in
  short windows.
- Leave the camera where it is when the exaggeration goes down. Lowered with
  the terrain, it ended up nearer the ground, and the new TerrainController's
  first pick could zoom past maxZoom and jump back.
- Size the camera math from the window: the controller's view states keep a
  stale size after a resize until you next move the map.
- Correct the start view's thresholds (630 px, and 1760x1100 at the default
  exaggeration), the pitch limit's framing and the naip.ts comment.
- Document that TerrainController's first pick after an exaggeration change
  can miss the visible ground.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Oct 16, 2026
@kylebarron
kylebarron merged commit 1ec45cd into main Oct 16, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/cog-terrain-camera-fixes branch October 16, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant