Skip to content

Scene

Defined in: core/scene.ts:351

new Scene(tolerance?): Scene

Defined in: core/scene.ts:354

number = 0.25

Scene

appendedBuffers(name, fromDrawable): GroupBufferDelta

Defined in: core/scene.ts:714

GPU-ready buffers for ONLY the drawables appended at/after fromDrawable — the tail slices as O(1) views (pointCenters assembled in O(new circles)). A backend whose buffers mirror the group 1:1 (append-only, same order) can apply this by appending: the index values are group-ABSOLUTE (no rebasing), because the new vertices sit at the same positions the group placed them. fromDrawable >= drawableCount yields an empty delta.

string

number

GroupBufferDelta


appendToGroup(name, build): void

Defined in: core/scene.ts:374

Append more drawables to an existing group (vs group(), which replaces it). New drawables’ integer drawableIds continue after the existing ones; a duplicate domain id (the caller’s string/number id) throws. NOTE: not atomic across a multi-drawable build — if a later drawable in the batch throws, earlier ones are already committed. Callers needing all-or-nothing (the engine append path) validate ids before calling.

string

(g) => void

void


buffers(name): GroupBuffers

Defined in: core/scene.ts:687

Assemble GPU-ready typed arrays for a group. O(1) views of the typed storage for everything except pointCenters (assembled fresh, O(pointCount) — it interleaves the drawableId per circle). See GroupBuffers for the sharing contract.

string

GroupBuffers


declutterIndex(name): DeclutterIndex

Defined in: core/scene.ts:578

The DeclutterIndex for a group — the transform-independent anchor grouping used by screen-space declutter. Built once and cached on the group; the per-frame caller projects ax/ay to screen and bins them, so the (string-keyed) grouping never re-runs on a zoom. Invalidated automatically when the group is rebuilt (group) or appended to (appendToGroup).

string

DeclutterIndex


drawableCount(name): number

Defined in: core/scene.ts:381

Number of drawables currently registered in a group.

string

number


drawableOf(name, id): DrawableVector | null

Defined in: core/scene.ts:661

The vector view of ONE drawable by domain id, or null when the id has no drawable (unknown, or culled at build time). O(1) lookup.

string

string | number

DrawableVector | null


drawables(name, from?): DrawableVector[]

Defined in: core/scene.ts:652

Return the vector view of a group’s drawables, optionally only those at/after from (so an incremental append can read just the new ones in O(new)).

string

number = 0

DrawableVector[]


flagsView(name): Uint8Array

Defined in: core/scene.ts:628

A LIVE typed view of a group’s per-drawable flag bytes (bit 0 = visible): the SAME Uint8Array instance across calls — zero per-call allocation — aliasing the Scene’s typed flags storage directly (#207 made #208’s mirror the primary storage), so the flag writers (setFlag, writeDeclutterFlags) are visible through it with no double-write. Replaced only when the drawable set changes (append grows it; a group rebuild replaces it). This is what the flags-only per-frame path (#208) passes by reference to Backend.updateLayerFlags, instead of the O(9·drawableCount)-bytes styleTables snapshot. Callers must treat it as read-only and must not retain it across drawable-set changes.

string

Uint8Array


group(name, build): void

Defined in: core/scene.ts:357

Build (or rebuild) a named group. The callback registers drawables.

string

(g) => void

void


range(name, id): DrawableRange

Defined in: core/scene.ts:537

The contiguous buffer slice a drawable occupies.

string

string | number

DrawableRange


remove(name): void

Defined in: core/scene.ts:364

Drop a group entirely (vs an empty re-group, which keeps a zero-drawable entry).

string

void


setFill(name, id, color): void

Defined in: core/scene.ts:553

Set a drawable’s fill color (any CSS color string). Hot-swappable.

string

string | number

string

void


setFlag(name, id, flags): void

Defined in: core/scene.ts:566

Set a drawable’s flag byte (e.g. bit 0 = visible). Hot-swappable. Writes the typed storage directly, so any flagsView/styleTables view sees it.

string

string | number

number

void


setStroke(name, id, color): void

Defined in: core/scene.ts:559

Set a drawable’s stroke color (any CSS color string). Hot-swappable.

string

string | number

string

void


styleTables(name): StyleTables

Defined in: core/scene.ts:675

The per-drawable color/flag tables (see StyleTables) as LIVE views of the group’s typed storage — O(1), zero copies (#207; previously an O(drawableCount) snapshot per call). Later setFill/setStroke/setFlag writes are visible through the views; an append makes them stale (backends always receive the drawable-set change as a setLayers/updateLayer/appendToLayer first). Consumers must not mutate or retain them across drawable-set changes.

string

StyleTables


writeDeclutterFlags(name, visibleByGroup): void

Defined in: core/scene.ts:606

Apply a per-anchor-group visibility verdict (1 = keep, 0 = hide) to the flag bytes, in place — one linear pass over the cached DeclutterIndex, with no per-id Map lookups. Drawables with no anchor (groupOf = -1) always stay visible. visibleByGroup is indexed by the same group index as ax/ay. Writes the typed flags storage directly — the flagsView the per-frame path hands to backends aliases it (#208).

string

Uint8Array

void