voxolith

makeSceneWorker()

Encode models and bake static placements on a worker, main-thread side (the worker runs serveScene). With it, makeInstanceLayer(renderer, { worker }) builds its static set off the main thread (layer.commitAsync()): the main thread only packs the models' bricks to send, claims their pool slots...

function makeSceneWorker(opts: SceneWorkerOptions): SceneWorker;

Defined in: engine/src/worker/scene.ts:615

Encode models and bake static placements on a worker, main-thread side (the worker runs serveScene). With it, makeInstanceLayer(renderer, { worker }) builds its static set off the main thread (layer.commitAsync()): the main thread only packs the models' bricks to send, claims their pool slots and applies the bake. Browser-only (needs Worker).

Parameters

ParameterType
optsSceneWorkerOptions

Returns

SceneWorker

Example

const worker = makeSceneWorker({
  spawn: () => new Worker(new URL("./scene.worker.ts", import.meta.url), { type: "module" }),
});
const layer = makeInstanceLayer(renderer, { load, worker });
layer.setStatic(scenery);
await layer.commitAsync(); // the page keeps drawing meanwhile

On this page