Large worlds · interface

CellStream

Explained in Coordinates and units.

interface CellStream
import type { CellStream } from '@driftengine/core';

Properties

NameTypeDescription
storereadonlyCellStore
sizereadonlynumber
radiusreadonlynumber
hysteresisreadonlynumber
originreadonlyFloat64ArrayWhere the predicted views' origin is, in absolute world coordinates.
More

A view matrix is Float32Array, and that is why this exists. runPrediction writes views into single precision — which is right, because a view matrix is what a renderer takes — and single precision stops resolving whole metres past 2²⁴. A world larger than that cannot put an absolute position through one: at 2²⁵ the spacing is four metres, so the camera position recovered from the matrix is wrong by up to two. Streaming survives it, because cellsInRadius is conservative and four metres against a five-hundred-metre cell only ever adds a cell — but it is wrong, and it is wrong in exactly the place this mechanism exists for.

So the views are render-space, relative to this, and the stream adds it back. Zero by default, which is what every consumer that fits inside single precision already had.

lastWantedreadonlyMap<number, number>Cell identifier to the frame it was last wanted. What the hysteresis counts against.
framenumberPumps so far. Monotonic, and the only clock this has.
gridreadonlyCellGrid
projectionreadonlyArrayLike<number> | nullThe caller's own array, read on every predicted frame — so a lens that zooms or pulls its far plane in is followed without telling the stream.