voxolith

serveChunks()

Serve chunk fills on this worker until it is terminated: the worker side of makeChunkFillPool. The pool sends init once; make turns it into a ChunkFill; then each request's boxes are filled brick by brick, each brick from empty, and the bricks written come back in one transferred buffer....

function serveChunks(opts: ServeChunksOptions): void;

Defined in: engine/src/worker/chunks.ts:81

Serve chunk fills on this worker until it is terminated: the worker side of makeChunkFillPool. The pool sends init once; make turns it into a ChunkFill; then each request's boxes are filled brick by brick, each brick from empty, and the bricks written come back in one transferred buffer. Requests run in the order they arrive, one at a time.

Parameters

ParameterType
optsServeChunksOptions

Returns

void

Example

// ground.worker.ts: rebuild the app's terrain from its description, fill its bricks
import { serveChunks } from "@voxolith/engine/worker";
import { fineTerrainFrom, type FineTerrainInit } from "@voxolith/gen-terrain";
serveChunks({
  make(init) {
    const { fine, base } = init as { fine: FineTerrainInit; base: number };
    const ground = fineTerrainFrom(fine);
    return (cells, ox, oy, oz) => ground.fillBrick(cells, ox, oy, oz, base);
  },
});

On this page