# decimateSource

Function

Source: https://github.com/playcanvas/splat-transform/blob/b6424a5b3b929695fbaafe738a995adb1240d675/src/lib/decimate-uniform/decimate-source.ts#L122

```ts
decimateSource(source: ChunkSource, pool: ChunkDataPool, opts: DecimateOptions): Promise<ChunkSource>
```

Chunk-native, memory-bounded decimation to an exact target count.

Design: positions resident; KD blocks as an IO pattern only; per-block exact global 16-NN +
edge costs (GPU when a device is supplied) reduced to K resident
candidates; global bucketed greedy matching with chain closure; a second
heavy pass moment-matches groups and streams the output.

The returned source supports a single sequential pass (it computes the
merge stream on demand) — the PLY-terminal consumption model. Its `close`
releases the input source and any intermediate spill files. Deep targets
run multiple generations; intermediates land in RAM when small enough,
else in temp PLY spills under `opts.spill.scratchDir`.

**Parameters**

- `source` ([`ChunkSource`](https://api.playcanvas.com/splat-transform/interfaces/ChunkSource.md)): Input (consumed: the returned source owns it). Single LOD, gaussian layers required.
- `pool` ([`ChunkDataPool`](https://api.playcanvas.com/splat-transform/interfaces/ChunkDataPool.md)): Chunk-data pool; its chunk size must match the source's.
- `opts` (`DecimateOptions`): Options.

**Returns** `Promise<`[`ChunkSource`](https://api.playcanvas.com/splat-transform/interfaces/ChunkSource.md)`>`: The decimated stream-once source with exact metadata.
