Skip to main content
Version: 2.x

Reacting to clicks in point cloud models

While point clouds doesn't have a concept of nodes, applications can detect clicked points. Just like with CAD models, Cognite3DViewer.getIntersectionFromPixel is used to determine world position and point from a mouse click.

Detecting clicked positions

The following example detects intersections at clicked positions and marks the intersected positions using a red sphere.

Live Editor

Controlling the intersection threshold

By default, points within 5 cm of an intersection ray is considered to be intersecting. For point clouds of large physical assets this is usually a good value, but for point clouds with large extends (e.g. geographical point clouds) this threshold might be too small.

The intersection threshold can be changed using the pointIntersectionThreshold option of getIntersectionFromPixel:

const options = { pointIntersectionThreshold: 1.0 /* 1 m */ };
const intersection = await viewer.getIntersectionFromPixel(event.offsetX, event.offsetY, options);