Backend
Defined in: core/backend.ts:275
A renderer for a Scene, implemented per target (WebGL / Canvas / SVG).
Properties
Section titled “Properties”stylesNeedDrawables?
Section titled “stylesNeedDrawables?”
readonlyoptionalstylesNeedDrawables?:boolean
Defined in: core/backend.ts:298
Whether updateLayerStyles actually renders from its drawables argument (Canvas
and SVG repaint from the vector view) vs. only stashing it for export (WebGL draws from the
GPU flag/color tables). When false, the engine may omit drawables on hot paths. Absent
⇒ treated as true (safe default: always pass the vector view).
supportsPassThrough?
Section titled “supportsPassThrough?”
readonlyoptionalsupportsPassThrough?:boolean
Defined in: core/backend.ts:331
True if this backend supports pass-through (canvas/webgl yes, svg no).
textLayerMode?
Section titled “textLayerMode?”
readonlyoptionaltextLayerMode?:"live"|"export-only"
Defined in: core/backend.ts:382
How setTextLayer text is rendered (#219). "live" (default when absent): the backend
draws the set on screen (SVG <text> / Canvas fillText), so the engine routes labels away from
the HTML overlay and re-pushes them each setTransform. "export-only" (WebGL): the backend only
retains the set for toPNG()/toSVG() — the engine must keep its own live label rendering (the
HTML overlay) and needs to push the set only when exporting, NOT per transform (zero per-frame cost).
Methods
Section titled “Methods”appendToLayer()?
Section titled “appendToLayer()?”
optionalappendToLayer(delta):void
Defined in: core/backend.ts:316
Append-only fast path (optional). Same observable result as a full re-upload,
but the backend uploads/draws only the appended tail (delta) — O(new) instead
of O(total). Backends that don’t implement it are driven via updateLayer
(full re-upload); the engine still calls updateLayer for non-append changes.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy():
void
Defined in: core/backend.ts:393
Returns
Section titled “Returns”void
drawPassThrough()?
Section titled “drawPassThrough()?”
optionaldrawPassThrough(name,batch,mode):void
Defined in: core/backend.ts:327
Draw a batch into the layer’s accumulation buffer.
mode: "replace-first" clears the layer’s buffer first (start of a full repaint),
"replace-rest" continues a chunked full repaint without clearing,
"append" draws on top (incremental).
Parameters
Section titled “Parameters”string
"replace-first" | "replace-rest" | "append"
Returns
Section titled “Returns”void
pickInstanced()?
Section titled “pickInstanced()?”
optionalpickInstanced(x,y,exact):number|undefined
Defined in: core/backend.ts:365
GPU-readback pick (#141): resolve a screen point (CSS px) to the topmost pickable instanced
link instance by reading its id-encoded colour from an offscreen pick FBO. Returns the decoded
instance index (gl_InstanceID within the pickable link layers, which the network emits in edge
order), -1 for background (no link), or undefined when unsupported or no pickable layer is
registered. exact: false (hover) uses double-buffered async PBO readback — returns the previous
pointer position’s result with no GPU pipeline stall; exact: true (click) reads synchronously at
(x, y). WebGL-only; other backends omit it (network instanced rendering is WebGL-only).
Parameters
Section titled “Parameters”number
number
boolean
Returns
Section titled “Returns”number | undefined
removeInstancedLayer()?
Section titled “removeInstancedLayer()?”
optionalremoveInstancedLayer(name):void
Defined in: core/backend.ts:348
Remove an instanced primitive layer by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
removePassThroughLayer()?
Section titled “removePassThroughLayer()?”
optionalremovePassThroughLayer(name):void
Defined in: core/backend.ts:320
Remove a pass-through layer.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
render()
Section titled “render()”render():
void
Defined in: core/backend.ts:390
Returns
Section titled “Returns”void
resize()
Section titled “resize()”resize(
width,height):void
Defined in: core/backend.ts:389
Resize the rendering surface to a new CSS size (px). Re-reads the device pixel ratio and reconciles the backing buffer / framebuffers; the engine re-pushes layers and re-renders afterwards. A no-op when the size is unchanged.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
setInstancedLayer()?
Section titled “setInstancedLayer()?”
optionalsetInstancedLayer(layer):void
Defined in: core/backend.ts:337
Register/replace a GPU-instanced primitive layer (the network rendering lane). Optional — only the WebGL backend implements it; other backends omit it, so network instanced rendering is WebGL-only (small-N / export go through the PathContext emitter).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setLayers()
Section titled “setLayers()”setLayers(
layers):void
Defined in: core/backend.ts:276
Parameters
Section titled “Parameters”layers
Section titled “layers”Returns
Section titled “Returns”void
setPassThroughLayer()?
Section titled “setPassThroughLayer()?”
optionalsetPassThroughLayer(layer):void
Defined in: core/backend.ts:318
Register/replace a pass-through layer (no buffers). Backends opt in.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setTextLayer()?
Section titled “setTextLayer()?”
optionalsetTextLayer(texts):void
Defined in: core/backend.ts:374
Set the screen-space text labels to draw on top of the scene (#105 N7b-2). Optional — the SVG
(<text>) and Canvas (fillText) backends implement it and render the set live, so the engine
routes labels here (instead of the HTML overlay) and they appear in toSVG()/toPNG(). The WebGL
backend implements it as an export-only stash (see textLayerMode): the set is retained
for toPNG()/toSVG() but never drawn to screen — the engine keeps the HTML overlay live and
pushes the placed set only at export time (#219). Replaces the whole set; pass [] to clear.
Parameters
Section titled “Parameters”readonly TextData[]
Returns
Section titled “Returns”void
setTransform()
Section titled “setTransform()”setTransform(
t):void
Defined in: core/backend.ts:383
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
snapshotPassThrough()?
Section titled “snapshotPassThrough()?”
optionalsnapshotPassThrough():void
Defined in: core/backend.ts:329
Snapshot current accumulation for snapshot-pan (called on interaction start).
Returns
Section titled “Returns”void
styleInstancedLayer()?
Section titled “styleInstancedLayer()?”
optionalstyleInstancedLayer(name,highlight):void
Defined in: core/backend.ts:355
Shader-driven selection/hover styling for an instanced layer (#162) — applies the highlight WITHOUT
rebuilding geometry, so a hover is just a uniform change (no CPU rebuild, no GPU re-upload) even on a
full-graph (LOD-off) draw. Sets the given uniforms; when selected is present, updates only that
per-instance flag buffer. No-op when the layer/backend doesn’t support it. WebGL-only.
Parameters
Section titled “Parameters”string
highlight
Section titled “highlight”Returns
Section titled “Returns”void
toPNG()
Section titled “toPNG()”toPNG():
string
Defined in: core/backend.ts:391
Returns
Section titled “Returns”string
toSVG()
Section titled “toSVG()”toSVG():
string
Defined in: core/backend.ts:392
Returns
Section titled “Returns”string
updateInstancedLayer()?
Section titled “updateInstancedLayer()?”
optionalupdateInstancedLayer(layer):void
Defined in: core/backend.ts:346
Update an instanced layer in place when the primitive supports it, or fall back to
destroy+recreate otherwise. Optional — only the WebGL backend implements it; when absent,
emitInstancedLane falls back to setInstancedLayer. All four primitive types
(circles/lines/arrows/half-arrows) now support in-place update() — falling back to
recreate only when a structural property changes (e.g. samples or half flag on
arrows/lines) or the primitive type itself changes.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
updateLayer()
Section titled “updateLayer()”updateLayer(
name,layer):void
Defined in: core/backend.ts:277
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
updateLayerFlags()?
Section titled “updateLayerFlags()?”
optionalupdateLayerFlags(name,flags):void
Defined in: core/backend.ts:309
Flags-only fast path (optional): ONLY the per-drawable visibility flags changed —
colours and geometry did not (the per-frame declutter show/hide, #208). flags is a
LIVE view of the Scene’s persistent flags table (one byte per drawable, drawableId-
indexed, bit 0 = visible), passed by REFERENCE: the caller allocates and copies
nothing per frame, and the view’s contents stay current until the layer’s drawable
set changes — which always reaches the backend as a setLayers/updateLayer/
appendToLayer call first. Backends must not mutate it. Backends without this
method are driven through the updateLayerStyles path (full tables).
Parameters
Section titled “Parameters”string
Uint8Array
Returns
Section titled “Returns”void
updateLayerStyles()?
Section titled “updateLayerStyles()?”
optionalupdateLayerStyles(name,tables,drawables?):void
Defined in: core/backend.ts:291
Styles-only fast path (optional): the per-drawable color/flag tables changed but
geometry did not (recolor / dim / show-hide). drawables is the refreshed vector
view (same drawables, same order) so vector-reading consumers (Canvas redraw, SVG
serialize, toSVG export) stay in sync with the raster output. Backends without it
are driven through updateLayer (full re-upload).
drawables may be omitted (undefined): the caller does this on a backend that doesn’t
render from the vector view (see stylesNeedDrawables) to skip an O(n) rebuild on a
hot path (e.g. per-frame declutter). Such a backend must keep its previously-stored vector
view; consumers that read it (e.g. toSVG) may then lag the tables until the next update
that does pass drawables.
Parameters
Section titled “Parameters”string
tables
Section titled “tables”drawables?
Section titled “drawables?”Returns
Section titled “Returns”void