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
| Parameter | Type |
|---|---|
opts | ServeChunksOptions |
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);
},
});packEntity()
An entity as a small header plus one byte buffer holding its arrays (PackedEntity): a sparse model's bricks become one key array and one brick array, in the map's order. Copies.
serveGenerators()
Serve generate requests on this worker until it is terminated. Call after registering the generators this worker should offer: the pool sends a generator id, and a function cannot cross the worker boundary, so the registry must be filled here. Posts a ready message listing the registered ids,...