UNPKG

@playcanvas/splat-transform

Version:

Library and CLI tool for 3D Gaussian splat format conversion and transformation

58 lines (57 loc) 2.88 kB
import { Vec3 } from 'playcanvas'; import { BlockMaskBuffer } from './block-mask-buffer'; import { SparseVoxelGrid } from './sparse-voxel-grid'; import { DataTable } from '../data-table'; import type { DeviceCreator } from '../types'; /** * Build an inverted SparseVoxelGrid from a BlockMaskBuffer for flood-filling * through occupied voxels. In the returned grid, originally-occupied voxels * are free (unblocked) and empty space is blocked. * * @param buffer - Block mask buffer with voxelization results. * @param nx - Grid dimension X in voxels. * @param ny - Grid dimension Y in voxels. * @param nz - Grid dimension Z in voxels. * @returns Inverted grid suitable for twoLevelBFS. */ declare const buildInvertedGrid: (buffer: BlockMaskBuffer, nx: number, ny: number, nz: number) => SparseVoxelGrid; /** * Find the connected component of occupied voxels reachable from a seed * position via 6-connected voxel-level flood fill. Returns the set of block * linear indices that contain at least one reachable voxel, the visited grid, * and the resolved seed position. * * If the seed voxel is not occupied, finds the nearest occupied voxel first. * * @param buffer - Block mask buffer with voxelization results. * @param nx - Grid dimension X in voxels. * @param ny - Grid dimension Y in voxels. * @param nz - Grid dimension Z in voxels. * @param seedIx - Seed voxel X coordinate. * @param seedIy - Seed voxel Y coordinate. * @param seedIz - Seed voxel Z coordinate. * @returns Object with ccSet, visited grid, and the resolved seed, or null if no occupied voxel found. */ declare const findClusterVoxelFlood: (buffer: BlockMaskBuffer, nx: number, ny: number, nz: number, seedIx: number, seedIy: number, seedIz: number) => { ccSet: Set<number>; visited: SparseVoxelGrid; resolvedSeed: { ix: number; iy: number; iz: number; }; } | null; /** * Filter a Gaussian splat DataTable to keep only Gaussians that contribute to * the connected component found by GPU voxelization from a seed position. * * @param dataTable - Input Gaussian splat data. * @param createDevice - Function to create a GPU device for voxelization. * @param voxelResolution - Voxel size in world units for coarse voxelization. Default: 1.0. * @param seed - Seed position in world space. Default: (0,0,0). * @param opacityCutoff - Opacity threshold for solid voxels. Default: 0.999. * @param minContribution - Minimum Gaussian contribution at a cluster voxel center to be kept. Default: 0.1. * @returns Filtered DataTable containing only Gaussians in the seed's cluster. */ declare const filterCluster: (dataTable: DataTable, createDevice: DeviceCreator, voxelResolution?: number, seed?: Vec3, opacityCutoff?: number, minContribution?: number) => Promise<DataTable>; export { buildInvertedGrid, findClusterVoxelFlood, filterCluster };