voxolith

makeChunkFillPool()

Fill ground chunks on a pool of workers, main-thread side: pass it as makeChunkedWorld's fill. Each worker runs serveChunks, gets init once, and fills the boxes it is sent. Requests go to the least busy worker, up to depth each, and queue in order beyond that; the chunked world keeps its own...

function makeChunkFillPool(opts: ChunkFillPoolOptions): ChunkFillPool;

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

Fill ground chunks on a pool of workers, main-thread side: pass it as makeChunkedWorld's fill. Each worker runs serveChunks, gets init once, and fills the boxes it is sent. Requests go to the least busy worker, up to depth each, and queue in order beyond that; the chunked world keeps its own nearest-first queue and hands out only capacity at a time. A worker that dies fails the request it was running (the others it held go to another worker) and is replaced (with init sent again), unless it died before it was ready, which fails the pool as make throwing does. Browser-only (needs Worker).

Parameters

ParameterType
optsChunkFillPoolOptions

Returns

ChunkFillPool

Example

const fill = makeChunkFillPool({
  spawn: () => new Worker(new URL("./ground.worker.ts", import.meta.url), { type: "module" }),
  init: { fine: fineTerrainInit(ground), base: terrainBase },
});
const world = makeChunkedWorld({
  target: renderer, size: SIZE, chunk: 256, seed, load, fill,
  boxes: ({ box }) => columnBoxes(box, (ox, oz) => ground.columnSpan(ox, oz)),
});
// per frame, as without it:
world.focus(x, z, 2000);
if (world.step(4) > 0) loop.invalidate();

On this page