# ChunkData

Interface

Source: https://github.com/playcanvas/splat-transform/blob/b6424a5b3b929695fbaafe738a995adb1240d675/src/lib/chunk/data.ts#L23

A CPU-resident buffer holding one layer's data for one chunk of gaussians.

A "chunk" is a row-range — a contiguous subset of gaussians; a `ChunkData`
holds one layer's data for one such chunk (it carries a `.layer`, and you
acquire and bind `position`/`geometric`/`color`/`other` separately). Buffers
are acquired from a [ChunkDataPool](https://api.playcanvas.com/splat-transform/interfaces/ChunkDataPool.md), filled by
[ChunkSource.read](https://api.playcanvas.com/splat-transform/interfaces/ChunkSource.md#read), used by consumers (writers, kernels that upload
`data` to the GPU themselves), and then released back to the pool. The
underlying `ArrayBuffer` is reused across subsequent acquisitions of the same
byte size.

`count` is the number of gaussians of valid data this buffer holds; it
matches the source's `chunkSize` except for the final (short) chunk. The
backing `data` buffer is allocated at full chunk capacity (`chunkSize *
stride`), so the valid region is always the leading `count * stride` bytes.
`stride` is the bytes per gaussian, dictated by the layer (and, for `color`
and `other`, by the SH band count or extras schema).

## Properties

### count

```ts
readonly count: number
```

Number of gaussians of valid data this buffer holds.

### data

```ts
readonly data: ArrayBuffer
```

CPU buffer holding this layer's interleaved per-gaussian records. Its
capacity may exceed `count * stride` (it is sized for a full chunk);
only the leading `count * stride` bytes are meaningful.

### fields

```ts
readonly fields: ChunkFieldMap
```

Field name -> byte offset / component descriptor within the stride.

### layer

```ts
readonly layer: ChunkLayer
```

Which layer this buffer holds.

### stride

```ts
readonly stride: number
```

Bytes per gaussian for this buffer's layer.

## Methods

### field

```ts
field(name: string): Float32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
```

Extract one named field as a tight (de-interleaved) typed-array over the
valid rows. The result is a copy — fields are generally a sub-span of the
stride, so a zero-copy view isn't possible.

**Parameters**

- `name` (`string`)

**Returns** `Float32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>`

### release

```ts
release(): void
```

Return this buffer to its [ChunkDataPool](https://api.playcanvas.com/splat-transform/interfaces/ChunkDataPool.md) for reuse.
After this call the buffer must not be referenced again.
