voxolith

@voxolith/engine/worker

@voxolith/engine/worker: run generators off the main thread.

Generation is pure CPU with no DOM contact, so it belongs on a worker; doing it inline competes with the thread that has to draw. Split in two because the two halves run in different realms:

The consumer supplies the worker entry, because only their bundler can resolve one; see serveGenerators for the three-line worker file. With its cache option, generated models are kept in IndexedDB (openModelCache) so a second visit loads them.

Loading is the app's to steer, and the engine picks no policy: requests take a priority and an AbortSignal, the pool pauses, resumes and reprioritises its queue, and openModelCacheControls inspects, clears and trims the model cache from the main thread. Without those options everything behaves as a plain FIFO with an unbounded cache.

A second worker, the scene worker, encodes models for the GPU and bakes static instance placements (makeSceneWorker on the main thread, serveScene in the worker), for makeInstanceLayer(target, { worker }) and its commitAsync(). makePlacementWorker and servePlacement are its older, bake-only names. With its cache option it keeps the encodings and bakes in IndexedDB too (openSceneCache, openSceneCacheControls), so a warm visit skips both.

Ground chunks fill on workers too: makeChunkFillPool on the main thread is a makeChunkedWorld({ fill }) source, and serveChunks in the worker rebuilds the app's fill from a description sent once and answers boxes with bricks.

Interfaces

Type Aliases

Variables

Functions

On this page