How clipping works with boxes, spheres, and planes
masterPotree Core uses a unified visibility rule for clipping. Clipping volumes can be defined as include (keep what is inside) or exclude (remove what is inside).
Clipping Modes
ClipMode.DISABLED: A global master switch that disables all clipping/highlighting.include: Clip-outside semantics (the volume's interior remains visible).exclude: Clip-inside semantics (the volume's interior is removed).- If a volume's mode is
undefined, it inherits the globalpco.material.clipMode. ClipMode.HIGHLIGHT_INSIDE: Highlights the interior without changing visibility.
Clipping Primitives
- Clip Boxes: Created via
createClipBox(size, position, mode?). Returns anIClipBox. - Clip Spheres: Created via
createClipSphere(center, radius, mode?). Returns anIClipSphere. - Clip Planes: These do not have individual modes; they always use the inherited global material mode. They are evaluated as
insideAllPlanes(point is on the positive side of all planes).
To apply clipping to a point cloud, use pco.material.setClipBoxes([...]) or pco.material.setClipSpheres([...]).
import { ClipMode, createClipBox, createClipSphere } from 'potree-core';
import { Vector3 } from 'three';
// Set global fallback
pco.material.clipMode = ClipMode.CLIP_OUTSIDE;
// Clip Boxes
const includeA = createClipBox(new Vector3(10, 10, 10), new Vector3(0, 0, 0), 'include');
const excludeB = createClipBox(new Vector3(4, 4, 4), new Vector3(0, 0, 0), 'exclude');
const inheritedD = createClipBox(new Vector3(3, 3, 3), new Vector3(-3, 0, 0)); // inherits CLIP_OUTSIDE
pco.material.setClipBoxes([includeA, excludeB, inheritedD]);
// Clip Spheres
pco.material.clipMode = ClipMode.HIGHLIGHT_INSIDE;
const sphereA = createClipSphere(new Vector3(0, 1, 0), 3, 'exclude');
const sphereB = createClipSphere(new Vector3(5, 1, 0), 2); // inherits HIGHLIGHT_INSIDE
pco.material.setClipSpheres([sphereA, sphereB]);