API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

I

interfaceWorkerSampledChunkSourceOptions

@codexo/exojs-tilemap / tilemap / stable

Options for createWorkerSampledChunkSource.

2
props
1
methods
0
events
Import
import { WorkerSampledChunkSourceOptions } from '@codexo/exojs-tilemap'

Options for createWorkerSampledChunkSource.

Methods1
Convert a sampled value (and its absolute tile coordinate) into a resolved tile, or null for an empty cell. Always runs on the main thread - a ResolvedTile references a TileSet/Texture, neither of which can cross a postMessage boundary. Must be pure and deterministic, same requirement as import('./SampledChunkSource').SampledChunkSourceOptions.mapValueToTile.
Properties2
initMessage?: unknown
Posted to the worker once, before any chunk request, when present. The transport for whatever the sampler needs to know that is not per-chunk - a seed, a feature size, a cost knob. Without it those values would have to be interpolated into WorkerSampledChunkSourceOptions.workerSource as literals, which turns every parameter change into a source rebuild and a new Worker. postMessage delivery is ordered, so the worker is guaranteed to see this before the first request. Distinguish it from a chunk request by its own shape; requests carry a requestId.
workerSource: string
Complete worker script source as a single self-contained string, Blob-URL'd into a real Worker at construction time - the same technique import('@codexo/exojs').WorkletEffect uses for AudioWorklet processors. No separate worker asset is fetched and no bundler-specific worker-import syntax is involved. Producing that string by hand-writing JavaScript into a template literal works but gives up type checking, linting and shared code. Prefer a build step that bundles a real module into a string: this repository's own examples are authored as *.worker.ts and imported through a ?worker query, which is why they can import the sampling functions the main thread uses instead of restating them. Must implement this request/response protocol: - Request (received via self.onmessage): { requestId: number; cx: number; cy: number; chunkWidth: number; chunkHeight: number }. - Response, success (send via self.postMessage, transferring the buffer for a zero-copy handoff - postMessage(response, [response.values.buffer])): { requestId: number; values: Float64Array }, values.length === chunkWidth * chunkHeight, row-major (localTy * chunkWidth + localTx), one sampled value per tile in the requested chunk. Compute each tile's absolute coordinate as cx * chunkWidth + localTx / cy * chunkHeight + localTy. - Response, error (one request failed without crashing the worker): { requestId: number; error: string }. Your worker must reply to every request with exactly one success or error message bearing the same requestId. A request left unanswered leaves that chunk permanently unfetched - there is no timeout - since ChunkStreamer tracks it as still in flight and never retries it.
Source