@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
76 lines (75 loc) • 2.54 kB
TypeScript
/**
* Append-only buffer for streaming voxelization results.
* Stores (linear blockIdx, voxel mask) pairs for non-empty 4x4x4 blocks.
*
* Block keys are linear block indices `bx + by*nbx + bz*nbx*nby` in the
* producer's grid coordinate system. Producers and consumers must agree
* on the grid dimensions; the buffer itself is dimension-agnostic.
*
* Backed by typed arrays that grow geometrically. Keys use Float64Array so
* the per-buffer capacity exceeds V8's regular-array backing-store limit
* (large grids exceed Smi range and would throw `RangeError: Invalid array
* length` with a regular array).
*/
declare class BlockMaskBuffer {
/** Linear block indices for solid blocks (mask is implicitly all 1s) */
private _solidIdx;
private _solidCount;
private _solidCap;
/** Linear block indices for mixed blocks */
private _mixedIdx;
private _mixedCount;
private _mixedCap;
/** Interleaved voxel masks for mixed blocks: [lo0, hi0, lo1, hi1, ...] */
private _mixedMasks;
/**
* Add a non-empty block to the buffer.
* Automatically classifies as solid or mixed based on mask values.
*
* @param blockIdx - Linear block index (`bx + by*nbx + bz*nbx*nby`)
* @param lo - Lower 32 bits of voxel mask
* @param hi - Upper 32 bits of voxel mask
*/
addBlock(blockIdx: number, lo: number, hi: number): void;
/**
* Get all mixed blocks as views into the underlying buffers.
* Index `i` of `blockIdx` corresponds to mask pair `(masks[i*2], masks[i*2+1])`.
*
* @returns Object with linear block indices and interleaved masks
*/
getMixedBlocks(): {
blockIdx: Float64Array;
masks: Uint32Array;
};
/**
* Get all solid blocks as a view into the underlying buffer.
*
* @returns Array of linear block indices
*/
getSolidBlocks(): Float64Array;
/**
* Get total number of blocks stored.
*
* @returns Count of mixed + solid blocks
*/
get count(): number;
/**
* Get number of mixed blocks.
*
* @returns Count of mixed blocks
*/
get mixedCount(): number;
/**
* Get number of solid blocks.
*
* @returns Count of solid blocks
*/
get solidCount(): number;
/**
* Clear all buffered blocks. Releases the underlying buffers so a cleared
* instance does not retain peak memory; the next `addBlock` re-allocates
* to `INITIAL_CAPACITY`.
*/
clear(): void;
}
export { BlockMaskBuffer };