PlacementWorker
A worker that bakes static placements, from makeSceneWorker (or the older makePlacementWorker). Give it to makeInstanceLayer(target, { placement }), which registers models and bakes for you; the methods are there for hosts that drive Renderer.placementInput / applyPlacement themselves. One...
Defined in: engine/src/worker/scene.ts:480
A worker that bakes static placements, from makeSceneWorker (or the older
makePlacementWorker). Give it to makeInstanceLayer(target, { placement }), which
registers models and bakes for you; the methods are there for hosts that drive
Renderer.placementInput / applyPlacement themselves. One worker can serve several layers
and renderers: model keys are unique on the page.
Extended by
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
pending | readonly | number | Jobs (bakes, and on a scene worker encodes) asked for and not yet settled. | engine/src/worker/scene.ts:506 |
Methods
bake()
bake(input: PlacementInput, opts?: object): Promise<PlacementBake>;Defined in: engine/src/worker/scene.ts:502
Bake a static set on the worker. Every model the input names must have been registered.
Rejects when the bake fails, the worker dies, the worker is destroyed, or signal aborts
(with signal.reason, an AbortError unless given another). Aborting skips the bake if the
worker has not started it; one that has started runs to the end and its result is dropped.
onProgress hears the bake's progress from the worker while it runs: done of total opaque
work units (use done / total as a fraction), first (0, total), last (total, total), about
every 50 ms, never decreasing. It stops once the bake settles, is aborted or the worker is
destroyed.
A worker with a cache (serveScene({ cache })) answers from it when it holds this bake (by a
digest of the input and of the models' placement data): no progress then, and
PlacementWorker.fromCache is true for the result. cache: false skips it both ways.
Parameters
| Parameter | Type |
|---|---|
input | PlacementInput |
opts? | { cache?: boolean; onProgress?: (done: number, total: number) => void; signal?: AbortSignal; } |
opts.cache? | boolean |
opts.onProgress? | (done: number, total: number) => void |
opts.signal? | AbortSignal |
Returns
Promise<PlacementBake>
destroy()
destroy(): Promise<void>;Defined in: engine/src/worker/scene.ts:513
Stop the worker: pending jobs reject at once and the worker is unusable afterwards. A worker
still running a job is terminated at once; an idle one first finishes its cache writes (up
to closeTimeoutMs), so what it just made is there next visit. Resolves when the worker has
been terminated; callers need not wait (and should not make a first frame wait for it).
Returns
Promise<void>
drop()
drop(key: number): void;Defined in: engine/src/worker/scene.ts:486
Forget a model key on the worker, after its model was removed. Unknown keys are ignored.
Parameters
| Parameter | Type |
|---|---|
key | number |
Returns
void
fromCache()
fromCache(result: PlacementBake | EncodedModel): boolean;Defined in: engine/src/worker/scene.ts:504
Whether a bake (or an encoding, on a scene worker) this worker returned came from its cache.
Parameters
| Parameter | Type |
|---|---|
result | PlacementBake | EncodedModel |
Returns
boolean
has()
has(key: number): boolean;Defined in: engine/src/worker/scene.ts:484
Whether a model key has been sent (and not dropped).
Parameters
| Parameter | Type |
|---|---|
key | number |
Returns
boolean
register()
register(model: PlacementModel): void;Defined in: engine/src/worker/scene.ts:482
Send a model to the worker (Renderer.placementModel), once per key: a known key is not sent again.
Parameters
| Parameter | Type |
|---|---|
model | PlacementModel |
Returns
void