WebGLBackend
Defined in: webgl/webgl-backend.ts:20
A renderer for a Scene, implemented per target (WebGL / Canvas / SVG).
Implements
Section titled “Implements”Properties
Section titled “Properties”stylesNeedDrawables
Section titled “stylesNeedDrawables”
readonlystylesNeedDrawables: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.
Implementation of
Section titled “Implementation of”supportsPassThrough
Section titled “supportsPassThrough”
readonlysupportsPassThrough:true=true
Defined in: webgl/webgl-backend.ts:21
True if this backend supports pass-through (canvas/webgl yes, svg no).
Implementation of
Section titled “Implementation of”textLayerMode
Section titled “textLayerMode”
readonlytextLayerMode:"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).
Implementation of
Section titled “Implementation of”Accessors
Section titled “Accessors”gpuDevice
Section titled “gpuDevice”Get Signature
Section titled “Get Signature”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).
Returns
Section titled “Returns”Device
Methods
Section titled “Methods”appendToLayer()
Section titled “appendToLayer()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”destroy()
Section titled “destroy()”destroy():
void
Defined in: webgl/webgl-backend.ts:572
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”drawPassThrough()
Section titled “drawPassThrough()”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).
Parameters
Section titled “Parameters”string
"replace-first" | "replace-rest" | "append"
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”pickInstanced()
Section titled “pickInstanced()”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.
Parameters
Section titled “Parameters”number
number
boolean
Returns
Section titled “Returns”number | undefined
Implementation of
Section titled “Implementation of”readPixel()
Section titled “readPixel()”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.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”number[]
readScreenPixel()
Section titled “readScreenPixel()”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.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”number[]
removeInstancedLayer()
Section titled “removeInstancedLayer()”removeInstancedLayer(
name):void
Defined in: webgl/webgl-backend.ts:315
Remove an instanced primitive layer by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”removePassThroughLayer()
Section titled “removePassThroughLayer()”removePassThroughLayer(
name):void
Defined in: webgl/webgl-backend.ts:215
Remove a pass-through layer.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Backend.removePassThroughLayer
render()
Section titled “render()”render():
void
Defined in: webgl/webgl-backend.ts:401
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”resize()
Section titled “resize()”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.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setGlobeMode()
Section titled “setGlobeMode()”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.
Parameters
Section titled “Parameters”boolean
number = 2048
number = 1024
Returns
Section titled “Returns”void
setGlobeRotation()
Section titled “setGlobeRotation()”setGlobeRotation(
m):void
Defined in: webgl/webgl-backend.ts:399
Update the globe rotation (mat3, column-major) and repaint. No re-bake.
Parameters
Section titled “Parameters”Float32Array
Returns
Section titled “Returns”void
setInstancedLayer()
Section titled “setInstancedLayer()”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).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setLayers()
Section titled “setLayers()”setLayers(
newLayers):void
Defined in: webgl/webgl-backend.ts:85
Parameters
Section titled “Parameters”newLayers
Section titled “newLayers”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setPassThroughLayer()
Section titled “setPassThroughLayer()”setPassThroughLayer(
layer):void
Defined in: webgl/webgl-backend.ts:209
Register/replace a pass-through layer (no buffers). Backends opt in.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setTextLayer()
Section titled “setTextLayer()”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.
Parameters
Section titled “Parameters”readonly TextData[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setTransform()
Section titled “setTransform()”setTransform(
t):void
Defined in: webgl/webgl-backend.ts:338
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”snapshotPassThrough()
Section titled “snapshotPassThrough()”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.)
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”styleInstancedLayer()
Section titled “styleInstancedLayer()”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.
Parameters
Section titled “Parameters”string
highlight
Section titled “highlight”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”toPNG()
Section titled “toPNG()”toPNG():
string
Defined in: webgl/webgl-backend.ts:479
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”toSVG()
Section titled “toSVG()”toSVG():
string
Defined in: webgl/webgl-backend.ts:487
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”updateInstancedLayer()
Section titled “updateInstancedLayer()”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).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”updateLayer()
Section titled “updateLayer()”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).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”updateLayerFlags()
Section titled “updateLayerFlags()”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().
Parameters
Section titled “Parameters”string
Uint8Array
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”updateLayerStyles()
Section titled “updateLayerStyles()”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).
Parameters
Section titled “Parameters”string
tables
Section titled “tables”drawables?
Section titled “drawables?”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”create()
Section titled “create()”
staticcreate(canvas,opts):Promise<WebGLBackend>
Defined in: webgl/webgl-backend.ts:63
Parameters
Section titled “Parameters”canvas
Section titled “canvas”HTMLCanvasElement
WebGLBackendOptions
Returns
Section titled “Returns”Promise<WebGLBackend>