cesiumgs/cesiumjs-skills/cesiumjs-interaction
Claude Code and agent skill by cesiumgs/cesiumjs-skills
- community
Checking that the SKILL.md file is still in the repository.
CesiumJS interaction and picking - ScreenSpaceEventHandler, multi-key KeyboardEventModifier input actions, Scene.pick, Scene.drillPick, Scene.pickPosition, Scene.snap edge snapping (1.144), mouse and touch events. Use when handling user clicks on the globe, selecting entities or 3D Tiles features, registering modifier-key shortcuts, implementing hover effects, snapping to model edges for measurement, or building drag-based interactions.
Install
npx vskill@latest install cesiumgs/cesiumjs-skills/cesiumjs-interactionSKILL.md
CesiumJS Interaction & Picking
Version baseline: CesiumJS v1.144 (ES module imports, Ion token required).
ScreenSpaceEventHandler
Central class for mouse, touch, and pointer events on the Cesium canvas. Always construct a new `ScreenSpaceEventHandler` bound to `viewer.scene.canvas` for interaction logic -- it isolates your listeners from Cesium's default camera/selection handlers and is the idiomatic pattern shown across all recipes below.
The Viewer also exposes a built-in handler at viewer.screenSpaceEventHandler which drives default behavior (entity selection, double-click tracking). You can attach to it, but for any non-trivial interaction prefer constructing your own new ScreenSpaceEventHandler(viewer.scene.canvas) so your handlers are independently disposable and do not collide with Cesium defaults.
ScreenSpaceEventType Reference
| Event | Callback shape | Notes | |
|---|---|---|---|
LEFT_DOWN / LEFT_UP / LEFT_CLICK | ({ position }) | Cartesian2 screen coords | |
LEFT_DOUBLE_CLICK | ({ position }) | Left only | |
RIGHT_DOWN / RIGHT_UP / RIGHT_CLICK | ({ position }) | ||
MIDDLE_DOWN / MIDDLE_UP / MIDDLE_CLICK | ({ position }) | ||
MOUSE_MOVE | ({ startPosition, endPosition }) | Fires on every pointer move | |
WHEEL | (delta) | Positive = scroll up | |
PINCH_START | ({ position1, position2 }) | Two-finger touch begins | |
PINCH_END | () | Two-finger touch ends | |
PINCH_MOVE | ({ distance, angleAndHeight }) | Two-finger move |
KeyboardEventModifier: SHIFT, CTRL, ALT -- optional third argument to setInputAction, getInputAction, and removeInputAction. In 1.142+, pass a single modifier or an array of modifiers. Modifier arrays are order-independent but exact: a handler registered for [CTRL, SHIFT] does not fire when ALT is also held.
Scene Picking Methods
pick / pickAsync / drillPick / pickPosition
Set scene.pickTranslucentDepth = true to include translucent primitives in pickPosition.
pickVoxel (experimental)
snap (experimental, 1.144+)
scene.snap searches a screen-space region around a window position and returns the best snap target, preferring model edges (from CAD-style EXT_mesh_primitive_edge_visibility data) over surfaces; among hits of the same kind, the one nearest the cursor wins. Use it for measurement and inspection tools that should latch onto edges instead of raw cursor hits.
Only primitives rendered through the Model pipeline (3D Tiles and glTF models) are snappable. Snapping requires WebGL2 with float color attachments (EXT_color_buffer_float); when that is unsupported, or the region contains no snappable geometry, snap returns undefined.
Picking Return Values
| Picked object | Return shape | Key properties | |
|---|---|---|---|
| Entity | { primitive, id } | id is the Entity instance | |
| Cesium3DTileFeature | Cesium3DTileFeature | .getProperty(name), .getPropertyIds(), .color | |
| Billboard/Label (collection) | { primitive, id } | id is the user-set id | |
| Primitive (geometry) | { primitive, id } | id is the GeometryInstance id | |
| Globe surface | undefined | Use camera.pickEllipsoid() or pickPosition() |
Camera Framing for Interaction Demos
Picking and hover demos must render the subject geography, not the starfield. Recent losses occurred because the camera was angled at the sky (pitch ~-45° or shallower) or imagery failed to load, leaving the scene black. Two non-negotiable rules:
- **Set the camera with
viewer.camera.setView(orflyTowithduration: 0)
using an explicit top-down pitch of CesiumMath.toRadians(-90)** (nadir) when the scenario calls for a regional map view. Do not rely on default pitch.
- Frame the scene at an altitude that contains all subject features.
For city-scale demos use 50–200 km; for state/region 1–3 Mm; for multi-state or archipelago 1.5–4 Mm. If pins or polygons land outside the frame, the judge will mark the candidate down even when programmatic checks pass.
- For regional pin demos, include the full latitude span with margin.
West-coast Seattle/San Francisco/Los Angeles views need a center near 40.8 N, -121 W and about 3.2-4.0 Mm altitude, or a fitted rectangle. At 2.5 Mm centered on 40 N, Seattle often lands at the top edge and fails as off-frame.
Coordinate Conversion (Required for Readouts)
Whenever you display longitude or latitude to the user (label text, console log, HTML overlay), convert from radians to degrees with CesiumMath.toDegrees. Cartographic angles are always in radians; printing them raw produces nonsense values.
Recipes
Polygon Setup For Picking Examples
When an interaction demo needs polygon entities to pick, build hierarchies with new PolygonHierarchy(Cartesian3.fromDegreesArray([...])). PolygonHierarchy does not have static fromDegrees(), fromDegreesArray(), or fromEquatorialCoordinates() helpers -- calling them throws Cesium.PolygonHierarchy.fromDegrees is not a function at runtime and the scene renders empty. The only correct construction is:
1. Entity Selection with Click
2. 3D Tiles Feature Picking and Property Inspection
3. Terrain Position Picking (Lon/Lat from Click)
For height on 3D content, use scene.pickPosition instead (see above).
4. Multi-Pick with drillPick
5. Hover Highlighting with MOUSE_MOVE
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cesiumjs-interaction/SKILL.md
Popularity
- Repository stars
- 98
- Repository forks
- 13
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 21 Jul 2026, 3 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cesiumgs/cesiumjs-skills/cesiumjs-interaction)