Skip to content

refactor: enable useDepthPicking on Scene - #123

Merged
airslice merged 1 commit into
alphafrom
refactor/enable-scene-use-depth-picking
Mar 13, 2026
Merged

refactor: enable useDepthPicking on Scene#123
airslice merged 1 commit into
alphafrom
refactor/enable-scene-use-depth-picking

Conversation

@airslice

@airslice airslice commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

When drag the map, Cesium needs to determine what 3D point on the globe you're interacting with. This pick
point becomes the rotation center. There are two methods:

  1. Ray-based picking (useDepthPicking={false})
  • Casts a ray from the camera through the screen pixel to find where it intersects the globe
  • Problem when close to ground:
    • Ray intersection can fail due to floating-point precision issues
    • May miss the ground entirely at steep angles or very close distances
    • When the pick fails, Cesium has no rotation center, so it falls back to rotating the camera itself (camera
      rotates in place instead of orbiting around the ground)
  1. Depth-based picking (useDepthPicking={true})
  • Reads the depth buffer directly from the GPU to get the exact 3D position at that pixel
  • Why it works better:
    • The depth buffer already contains precise position data from rendering
    • Works reliably even when extremely close to surfaces
    • No ray-casting calculations needed, just direct GPU readback

When zoomed in close to the ground:

  • Without depth picking: Ray intersection occasionally fails → no valid pick point → camera rotates in place
    (wrong behavior)
  • With depth picking: Depth buffer always provides accurate ground position → rotation always happens around the
    ground point → earth rotates correctly (expected behavior)

Enable this option could fix the bug we meet on Visualizer that left drag sometimes trigger camera rotation.

BTW its default value is true, i don't know why we set it to false https://cesium.com/learn/cesiumjs/ref-doc/Scene.html#useDepthPicking

@bnimit bnimit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@airslice
airslice merged commit f28129b into alpha Mar 13, 2026
3 of 4 checks passed
@airslice
airslice deleted the refactor/enable-scene-use-depth-picking branch March 13, 2026 08:02
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.

2 participants