@playcanvas/splat-transform
Version:
Library and CLI tool for 3D Gaussian splat format conversion and transformation
64 lines (63 loc) • 2.23 kB
TypeScript
/**
* Open-addressing hash map for voxel block masks backed by typed arrays.
* Replaces Map<number, [number, number]> to eliminate V8 Map overhead and
* per-entry tuple allocations that cause GC pressure.
*
* Keys are non-negative block indices. Values are lo/hi uint32 mask pairs.
* Uses Fibonacci hashing with linear probing and backward-shift deletion.
*/
declare class BlockMaskMap {
keys: Int32Array;
lo: Uint32Array;
hi: Uint32Array;
private _size;
private _capacity;
private _mask;
constructor(initialCapacity?: number);
get size(): number;
/**
* Find the slot for a key. If the key exists, keys[slot] === key.
* If the key doesn't exist, keys[slot] === -1 (empty slot for insertion).
*
* @param key - Block index to look up.
* @returns Slot index into keys/lo/hi arrays.
*/
slot(key: number): number;
has(key: number): boolean;
/**
* Insert at a slot known to be empty (keys[slot] === -1).
* Caller must have obtained slot via slot() and verified it is empty.
*
* @param slot - Empty slot index.
* @param key - Block index to insert.
* @param loVal - Lower 32 bits of voxel mask.
* @param hiVal - Upper 32 bits of voxel mask.
*/
insertAt(slot: number, key: number, loVal: number, hiVal: number): void;
/**
* Set key to lo/hi values. Inserts if key doesn't exist, updates if it does.
*
* @param key - Block index.
* @param loVal - Lower 32 bits of voxel mask.
* @param hiVal - Upper 32 bits of voxel mask.
*/
set(key: number, loVal: number, hiVal: number): void;
/**
* Remove entry at slot using backward-shift deletion.
* Maintains probe chain integrity without tombstones.
*
* @param slot - Slot index of the entry to remove.
*/
removeAt(slot: number): void;
delete(key: number): void;
clear(): void;
/**
* Release all backing storage. The map should not be used again except by
* replacing it with a new instance.
*/
releaseStorage(): void;
forEach(fn: (key: number, lo: number, hi: number) => void): void;
clone(): BlockMaskMap;
private _grow;
}
export { BlockMaskMap };