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
| Parameter | Type |
|---|---|
opts | ChunkFillPoolOptions |
Returns
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();@voxolith/engine/worker
@voxolith/engine/worker: run generators off the main thread.
makeGeneratorPool()
Run entity generators on a pool of workers, main-thread side. Generation is pure CPU work, so doing it here keeps the render thread free and spreads it across cores. Each worker runs serveGenerators with its own registry; the pool queues requests and hands each to the next free worker....