Atlaslog
Atlaslog / Cesium / Tutorial / Picking and scene interaction
Cesium · Tutorial

Picking and scene interaction

Quick answer

This tutorial distinguishes the four CesiumJS picking entry points and what each returns: scene.pick, scene.drillPick, scene.pickPosition and camera.pickEllipsoid. It shows how picked.id exposes an Entity while Cesium3DTileFeature exposes getProperty, and how drillPick cycles stacked features. It also covers throttling MOUSE_MOVE, falling back from pickPosition to pickEllipsoid, and picking caveats such as allowPicking and pickTranslucentDepth. Readers can implement reliable click and hover interactions.

Last verified 2026-11-03 · CesiumJS 1.121 · Cite this page
Key points
Example
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);

handler.setInputAction(function (movement) {
  var picked = viewer.scene.pick(movement.position);

  if (!Cesium.defined(picked)) {
    console.log('点到了空白处');
    return;
  }

  if (picked.id instanceof Cesium.Entity) {
    console.log('实体', picked.id.name, picked.id.properties);
  } else if (picked instanceof Cesium.Cesium3DTileFeature) {
    console.log('瓦片要素', picked.getProperty('name'));
  } else {
    console.log('图元', picked.primitive);
  }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
var cycle = 0;
var lastPixel = null;

handler.setInputAction(function (movement) {
  var pos = movement.position;

  if (!lastPixel || lastPixel.x !== pos.x || lastPixel.y !== pos.y) {
    cycle = 0;
    lastPixel = pos;
  }

  var stack = viewer.scene.drillPick(pos, 6);
  if (stack.length === 0) return;

  cycle = (cycle + 1) % stack.length;
  var target = stack[cycle];
  console.log('第', cycle + 1, '层', target.id && target.id.name);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Picking and scene interaction. https://www.jingweizhi.com/en/cesium/tutorials/picking.html (accessed 2026-11-03).