voxolith

ChunkedWorldOptions

Options for makeChunkedWorld.

Defined in: engine/src/chunks.ts:101

Properties

PropertyTypeDescriptionDefined in
chunknumberChunk footprint in voxels. Should be a multiple of the 8-voxel brick.engine/src/chunks.ts:113
fill?ChunkFillSourceFill chunks on workers instead of in generate (opt-in; usually makeChunkFillPool from @voxolith/engine/worker). focus queues chunks as before; the world keeps up to fill.capacity requests out, nearest first, and step applies the chunks that have come back, nearest first, within its budget: the main thread only copies bricks in. A chunk counts as built (resident, pendingWithin, whenReady, the ground phase) once it is applied. A chunk freed (beyond keep) while queued or out is dropped, and its result with it. The worker fills each brick from empty and the brick is replaced by the result, which is what generate writes whenever a chunk's bricks start empty, as they do (a chunk is new, or cleared when freed). So chunk must be a multiple of 8 here, or two chunks would share bricks. A request that fails leaves its chunk unbuilt: it is reported to onError, not retried until it has been freed, and whenReady over it rejects.engine/src/chunks.ts:136
load?LoadTrackerReport into a load tracker under the ground phase: focus adds the chunks it newly queues and step ticks each one it builds, so the total is what was actually asked for. Freed chunks are not counted back; revisiting one queues it again and adds it again. The phase ends when the queue is empty and starts again when the camera moves on.engine/src/chunks.ts:154
seednumberMixed with chunk coordinates into each chunk's rng.engine/src/chunks.ts:115
sizeobjectWorld extent in voxels; chunks are columns over the full height.engine/src/chunks.ts:111
size.xnumber-engine/src/chunks.ts:111
size.ynumber-engine/src/chunks.ts:111
size.znumber-engine/src/chunks.ts:111
targetBrickTarget & objectUsually the Renderer. With fill, chunks are applied through editMany when the target has it (one upload per chunk), else through edit per box.engine/src/chunks.ts:106

Methods

boxes()?

optional boxes(chunk: ChunkRef): Box[];

Defined in: engine/src/chunks.ts:142

With fill: the boxes to fill for a chunk, clamped to it (default the chunk's whole box). Tight boxes are what make it cheap, e.g. one per 8x8 brick column from the terrain's columnSpan. Runs on the main thread when the chunk is sent.

Parameters

ParameterType
chunkChunkRef

Returns

Box[]


generate()?

optional generate(ctx: ChunkContext): void;

Defined in: engine/src/chunks.ts:121

Fills one chunk. Must depend only on ctx, never on call order. Required without fill. With fill it is optional and runs on the main thread after the chunk's bricks are applied, for what cannot move to a worker (blitting entities, say).

Parameters

ParameterType
ctxChunkContext

Returns

void


onError()?

optional onError(error: unknown, chunk: ChunkRef): void;

Defined in: engine/src/chunks.ts:147

With fill: called when a chunk's request fails (the fill threw, the worker died), with the error. Default: console.error. Not called for requests the world cancelled itself.

Parameters

ParameterType
errorunknown
chunkChunkRef

Returns

void

On this page