@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:
- makeGeneratorPool: main thread, owns the workers and the queue
- serveGenerators: inside the worker, answers requests from its registry
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
- CacheRecord
- CacheStore
- ChunkFillPool
- ChunkFillPoolOptions
- CloseRequest
- EncodeSource
- GenerateManyOptions
- GenerateOptions
- GenerateRequest
- GenerateSpec
- GeneratorPool
- GeneratorPoolOptions
- ModelCache
- ModelCacheControls
- ModelCacheEntry
- ModelCacheFilter
- ModelCacheOptions
- PackedEntity
- PlacementWorker
- PlacementWorkerOptions
- SceneCache
- SceneCacheControls
- SceneCacheEntry
- SceneCacheFilter
- SceneCacheOptions
- SceneEncodeOptions
- SceneWorker
- SceneWorkerOptions
- ServeCacheOptions
- ServeChunksOptions
- ServeOptions
- ServeSceneCacheOptions
- ServeSceneOptions
Type Aliases
- ChunkFill
- ChunkRequest
- ChunkResponse
- PlacementRequest
- PlacementResponse
- SceneCacheKind
- SceneRequest
- SceneResponse
- ServePlacementOptions
- WorkerRequest
- WorkerResponse
Variables
Functions
- makeChunkFillPool
- makeGeneratorPool
- makeModelCache
- makeModelCacheControls
makePlacementWorker- makeSceneCache
- makeSceneCacheControls
- makeSceneWorker
- memoryCacheStore
- openModelCache
- openModelCacheControls
- openModelCacheOn
- openSceneCache
- openSceneCacheControls
- openSceneCacheOn
- packEntity
- serveChunks
- serveGenerators
servePlacement- serveScene
- unpackEntity
@voxolith/engine/vox
Previous Page
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...