import * as THREE from 'three/webgpu'; import type { SplatData } from '../core/splat-data'; /** * Volume selection over splat centers (CPU). * * A {@link SelectionVolume} answers one question - is this point inside the * volume? - so hosts can select a region of a loaded splat cloud with a placed * box, sphere or cylinder ({@link createSelectionVolume}), or with any custom * shape by implementing the interface directly. * * Selection runs over a `SplatData`'s positions ({@link selectInData}); the * split itself lives in `splat-partition.ts`. Everything here is pure array * math - no GPU, no mesh - so it is cheap to test and works the same for any * host. A one-shot selection gesture over a few million centers is a * brute-force scan by design: it costs milliseconds, needs no index to build * or invalidate, and supports arbitrarily transformed (including non-uniformly * scaled) volumes that a radius-based spatial grid cannot. */ export interface SelectionVolume { /** * Whether the point `(x, y, z)` lies inside the volume, in **the frame the * volume was built for** - for {@link createSelectionVolume} that is the * frame of the positions passed to {@link selectInData} (splat-local for a * `SplatData`, source-local for a collision mesh), fixed by the * `worldMatrix` argument. * * A splat is selected iff its *center* passes this test; a splat whose * center is outside but whose ellipsoid extent overlaps the volume is not * selected. */ containsPoint(x: number, y: number, z: number): boolean; } /** The built-in selection shapes. Custom shapes implement {@link SelectionVolume}. */ export type SelectionVolumeKind = 'box' | 'sphere' | 'cylinder'; /** Describes a built-in selection shape for {@link createSelectionVolume}. */ export interface SelectionVolumeOptions { kind: SelectionVolumeKind; /** * Places the shape: volume-local → world. Encodes the shape's center, * orientation and any (possibly non-uniform) scale. Default identity. * Must be invertible - a zero scale axis throws. */ transform?: THREE.Matrix4; /** * Box half-extents (volume-local units). Required for `kind: 'box'`; every * component must be positive. */ halfExtents?: readonly [number, number, number]; /** * Sphere or cylinder radius (volume-local units). Required for * `kind: 'sphere'` and `kind: 'cylinder'`; must be positive. */ radius?: number; /** * Cylinder full height along the volume-local Y axis. Required for * `kind: 'cylinder'`; must be positive. */ height?: number; } /** * Builds a {@link SelectionVolume} for one of the built-in shapes. * * `worldMatrix` is the local → world matrix of the geometry being selected * (`mesh.matrixWorld`; omit for data not attached to a mesh). It fixes the * frame {@link SelectionVolume.containsPoint} expects: each point is mapped * through `transform⁻¹ · worldMatrix` into the shape's own frame, so a rotated * or non-uniformly scaled volume placement costs the same as an axis-aligned * one. * * @throws {Error} if the shape's dimensions are missing/non-positive, or if * the combined `transform⁻¹ · worldMatrix` is singular or non-finite (a * collapsed axis on either matrix would otherwise select silent garbage). */ export declare function createSelectionVolume(options: SelectionVolumeOptions, worldMatrix?: THREE.Matrix4): SelectionVolume; /** * The indices of every splat in `data` whose center is inside `volume`, * ascending. Pure read - `data` is untouched; feed the result (or the volume * directly) to `partitionSplatData` to split. */ export declare function selectInData(data: SplatData, volume: SelectionVolume): Uint32Array; /** * How many splats in `data` fall inside `volume`, without materializing the * index list - for a live "n selected" readout while a host drags a volume * around, where {@link selectInData}'s `Uint32Array(count)` would allocate tens * of megabytes per pointer event on a large scene. */ export declare function countInData(data: SplatData, volume: SelectionVolume): number;