@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
36 lines (35 loc) • 1.57 kB
TypeScript
import { GraphicsDevice } from 'playcanvas';
/**
* GPU K-nearest-neighbours over a fixed point set using a flattened KD-tree.
*
* Algorithm: classic KD-tree DFS with bounded heap pruning, except the
* recursion is unrolled into an explicit per-thread stack and the top-K is
* maintained unsorted (with worst-index tracking) so the dominant
* candidate-rejection path is a single compare. Same O(N log N) total work
* as the CPU KD-tree the kernel mirrors, just parallelised across queries.
*
* Setup cost: O(N log N) for the CPU `KdTree` build + an O(N) DFS to
* flatten into typed arrays.
*
* Memory footprint: ~24 N bytes for the flattened tree (3 floats + 3
* u32 per node), plus query positions and the per-query output indices.
*/
declare class GpuKnn {
/**
* @param px - x coordinates of the N points (which double as queries).
* @param py - y coordinates.
* @param pz - z coordinates.
* @param outNeighbours - destination for per-query K neighbour indices,
* length `N * k`. `outNeighbours[i * k + j]` is one of the k nearest
* neighbours of point i (UNSORTED). Excludes i itself.
*/
execute: (px: Float32Array, py: Float32Array, pz: Float32Array, outNeighbours: Uint32Array) => Promise<void>;
destroy: () => void;
/**
* @param device - PlayCanvas GraphicsDevice (WebGPU).
* @param maxN - Maximum number of points the index will handle.
* @param k - Number of nearest neighbours per query.
*/
constructor(device: GraphicsDevice, maxN: number, k: number);
}
export { GpuKnn };