Skip to content

WebGLBackend

Defined in: webgl/webgl-backend.ts:20

A renderer for a Scene, implemented per target (WebGL / Canvas / SVG).

readonly stylesNeedDrawables: false = false

Defined in: webgl/webgl-backend.ts:136

WebGL renders from the GPU flag/color textures, not the vector view — the drawables arg to updateLayerStyles is only stashed for toSVG export. So the engine may omit it on hot paths (per-frame declutter) to skip an O(n) rebuild.

Backend.stylesNeedDrawables


readonly supportsPassThrough: true = true

Defined in: webgl/webgl-backend.ts:21

True if this backend supports pass-through (canvas/webgl yes, svg no).

Backend.supportsPassThrough


readonly textLayerMode: "export-only" = "export-only"

Defined in: webgl/webgl-backend.ts:330

Labels are an export-only stash here (#219): the engine keeps the HTML overlay live on WebGL and pushes the placed set only when exporting — never per transform (zero per-frame cost).

Backend.textLayerMode

get gpuDevice(): Device

Defined in: webgl/webgl-backend.ts:61

The luma.gl Device powering this backend — exposed for GPU-side consumers (e.g. GPU layout).

Device

appendToLayer(delta): void

Defined in: webgl/webgl-backend.ts:181

O(new) incremental append: grow the existing GroupRenderer’s geometry buffers (capacity-doubling) and color/flag textures with only the appended tail, instead of rebuilding from full buffers. The engine calls this (not updateLayer) for appends.

The layer is always registered (via setLayers) before any append, so the renderer exists; if it somehow doesn’t, we no-op (nothing to grow from a delta alone). If a new geometry-type pass appears that can’t be grown incrementally (renderer.append returns false), fall back to a full rebuild via updateLayer so the result stays correct.

RenderDelta

void

Backend.appendToLayer


destroy(): void

Defined in: webgl/webgl-backend.ts:572

void

Backend.destroy


drawPassThrough(name, batch, mode): void

Defined in: webgl/webgl-backend.ts:223

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).

string

DrawBatch

"replace-first" | "replace-rest" | "append"

void

Backend.drawPassThrough


pickInstanced(x, y, exact): number | undefined

Defined in: webgl/webgl-backend.ts:507

GPU-readback pick (#141): resolve a screen point (CSS px) to the topmost pickable instanced link instance. Returns the decoded gl_InstanceID, -1 for background, or undefined when there are no pickable layers (the engine then falls through to other pick paths). exact: true (click) reads synchronously; exact: false (hover) uses the double-buffered PBO and may return the previous pointer position’s result with no stall. See PickReadback.

number

number

boolean

number | undefined

Backend.pickInstanced


readPixel(x, y): number[]

Defined in: webgl/webgl-backend.ts:561

Read a pixel from the offscreen framebuffer (renders first). Flips y for WebGL origin.

number

number

number[]


readScreenPixel(x, y): number[]

Defined in: webgl/webgl-backend.ts:550

Read a pixel from the ONSCREEN canvas default framebuffer after render(). Test aid. Coords are in CSS px; the onscreen buffer is device px, so scale by the buffer ratio.

number

number

number[]


removeInstancedLayer(name): void

Defined in: webgl/webgl-backend.ts:315

Remove an instanced primitive layer by name.

string

void

Backend.removeInstancedLayer


removePassThroughLayer(name): void

Defined in: webgl/webgl-backend.ts:215

Remove a pass-through layer.

string

void

Backend.removePassThroughLayer


render(): void

Defined in: webgl/webgl-backend.ts:401

void

Backend.render


resize(width, height): void

Defined in: webgl/webgl-backend.ts:350

Resize the onscreen canvas drawing buffer (luma owns it via useDevicePixels), recompute the clip matrix at the new size, push the new viewport to every renderer (screen-mode point sizing) and recreate the offscreen export framebuffer. The engine re-pushes layers + renders after. Globe mode reads this.width/height per draw, so it follows automatically.

number

number

void

Backend.resize


setGlobeMode(on, texW?, texH?): void

Defined in: webgl/webgl-backend.ts:385

Enter/leave globe mode. texW/texH = equirect bake size. Idempotent re-entry resizes.

boolean

number = 2048

number = 1024

void


setGlobeRotation(m): void

Defined in: webgl/webgl-backend.ts:399

Update the globe rotation (mat3, column-major) and repaint. No re-bake.

Float32Array

void


setInstancedLayer(layer): void

Defined in: webgl/webgl-backend.ts:242

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).

InstancedLayer

void

Backend.setInstancedLayer


setLayers(newLayers): void

Defined in: webgl/webgl-backend.ts:85

RenderLayer[]

void

Backend.setLayers


setPassThroughLayer(layer): void

Defined in: webgl/webgl-backend.ts:209

Register/replace a pass-through layer (no buffers). Backends opt in.

PassThroughLayer

void

Backend.setPassThroughLayer


setTextLayer(texts): void

Defined in: webgl/webgl-backend.ts:334

Retain the screen-space labels for toPNG()/toSVG() (#219). No render — the set is not drawn to screen (the HTML overlay is); an O(1) reference swap, safe to call at any frequency.

readonly TextData[]

void

Backend.setTextLayer


setTransform(t): void

Defined in: webgl/webgl-backend.ts:338

ViewTransform

void

Backend.setTransform


snapshotPassThrough(): void

Defined in: webgl/webgl-backend.ts:240

No-op for WebGL: the accumulation FBO persists across gestures and PassThroughGL.fboTransform already records the reference transform (set on the last clear), so the composite blit can offset it during a pan with no extra snapshot. (The canvas backend, by contrast, must copy the canvas here because it has no retained FBO.)

void

Backend.snapshotPassThrough


styleInstancedLayer(name, highlight): void

Defined in: webgl/webgl-backend.ts:324

Shader-driven highlight (#162): set the layer’s highlight uniforms (+ optionally rewrite its per-instance selected flags) with no geometry rebuild — a hover is a uniform change.

string

InstancedHighlight

void

Backend.styleInstancedLayer


toPNG(): string

Defined in: webgl/webgl-backend.ts:479

string

Backend.toPNG


toSVG(): string

Defined in: webgl/webgl-backend.ts:487

string

Backend.toSVG


updateInstancedLayer(layer): void

Defined in: webgl/webgl-backend.ts:276

Update-in-place for instanced layers: if the layer already exists as the matching primitive type, call update() (GPU sub-upload, no teardown). Lines/arrows/half-arrows return false from update() when a structural property changed (samples, half-flag) — fall back to setInstancedLayer (destroy+recreate) in that case. Also recreates when the primitive type changes (e.g. lines → arrows) OR when the layer’s pickable state no longer matches the existing renderer’s pick-model presence (toggling pickLinks builds/drops the id-encoded pick model, which update() can’t do in place — see #141/#179).

InstancedLayer

void

Backend.updateInstancedLayer


updateLayer(name, layer): void

Defined in: webgl/webgl-backend.ts:115

Replace a layer’s geometry + tables. When the layer’s renderer already exists and needs no pass it was built without, it is updated IN PLACE (GroupRenderer.replace): geometry buffers and tables are rewritten through the retained Grow* objects (which grow + rebind on overflow) and the Models/pipelines are REUSED. The hover overlay re-targets a different drawable on every pointer move, so this path must not churn GPU objects per event (#218). It is still a full GEOMETRY replace, never a same-count recolor shortcut: equal drawable counts do NOT imply unchanged geometry, so the buffers are always rewritten. Styles-only changes go through updateLayerStyles; appends through appendToLayer (O(new)). Destroy + rebuild remains only for a structural change (a geometry-type pass appearing that the renderer lacks — e.g. an overlay created points-only later highlighting a path).

string

RenderLayer

void

Backend.updateLayer


updateLayerFlags(name, flags): void

Defined in: webgl/webgl-backend.ts:163

Flags-only update (#208): rewrite ONLY the flags texture — colour tables, geometry and the stashed vector view untouched, zero CPU-side copies. A zoom frame with declutter uploads drawableCount bytes instead of updateColors’ 9×. The vector view (toSVG reads it) is NOT patched here — that would be an O(drawables) per-frame loop for an export-only consumer; the live view is retained and folded in at toSVG().

string

Uint8Array

void

Backend.updateLayerFlags


updateLayerStyles(name, tables, drawables?): void

Defined in: webgl/webgl-backend.ts:141

Styles-only update: rewrite the palette/flags textures, refresh the stored vector view (toSVG reads it), leave geometry buffers untouched. drawables omitted ⇒ keep the previously-stored vector view (export may lag the textures until the next update with it).

string

StyleTables

DrawableVector[]

void

Backend.updateLayerStyles


static create(canvas, opts): Promise<WebGLBackend>

Defined in: webgl/webgl-backend.ts:63

HTMLCanvasElement

WebGLBackendOptions

Promise<WebGLBackend>