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.
Controlling the intersection threshold
Since v3.1.0 setting threshold doesn't have any effect because of new GPU-based picking method. Will be fully removed in v4.0.0.
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);