Skip to content

Documentation / @ripl/webgpu / WebGPUContext3D

Class: WebGPUContext3D ​

Defined in: webgpu/src/context.ts:62

WebGPU-backed 3D rendering context with hardware depth testing and WGSL shaders.

Extends ​

Constructors ​

Constructor ​

new WebGPUContext3D(target, device, gpuContext, canvas, pipelineState, options?): WebGPUContext3D

Defined in: webgpu/src/context.ts:83

Parameters ​

ParameterType
targetstring | HTMLElement
deviceGPUDevice
gpuContextGPUCanvasContext
canvasHTMLCanvasElement
pipelineStatePipelineState
options?WebGPUContextOptions

Returns ​

WebGPUContext3D

Overrides ​

Context3D.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
cameraPositionpublicVector3undefinedThe camera's world-space position, as last set by setCamera.Context3D.cameraPosition3d/src/core/context.ts:185
currentStateprotectedBaseStateundefined-Context3D.currentStatecore/src/context/context.ts:104
elementreadonlyHTMLCanvasElementundefinedThe underlying DOM element the context renders into.Context3D.elementcore/src/context/context.ts:111
faceBufferpublicProjectedFace3D[][]Faces accumulated since the last flush, sorted back-to-front and drained when they are drawn (painter's algorithm). A backend that never draws them — the base class, or a GPU context — leaves this empty by clearing it at the start of each pass.Context3D.faceBuffer3d/src/core/context.ts:191
farprotectednumberundefined-Context3D.far3d/src/core/context.ts:195
fovprotectednumberundefined-Context3D.fov3d/src/core/context.ts:193
heightpublicnumberundefinedCurrent height of the rendering surface, in logical pixels — CSS pixels, unaffected by the device pixel ratio.Context3D.heightcore/src/context/context.ts:124
hitTestHonorsTransformpublicbooleanfalseWhether this context's hit testing natively accounts for element and ancestor group transforms (as SVG does, via the DOM). When false (e.g. canvas), callers map the hit point into the element's local space before testing. See Element.getWorldTransform.Context3D.hitTestHonorsTransformcore/src/context/context.ts:120
lightsreadonlyLightListundefinedThe lights illuminating the scene.Context3D.lights3d/src/core/context.ts:183
metareadonlyContext3DMetaundefinedArbitrary metadata attached to the context.Context3D.metacore/src/context/context.ts:113
nearprotectednumberundefined-Context3D.near3d/src/core/context.ts:194
parent?publicEventBus<ContextEventMap>undefinedThe parent event bus that emitted events bubble up to, if any.Context3D.parentcore/src/core/event-bus.ts:107
projectionMatrixpublicMatrix4undefinedThe projection matrix transforming view space into clip space.Context3D.projectionMatrix3d/src/core/context.ts:179
renderDepthprotectednumber0-Context3D.renderDepthcore/src/context/context.ts:105
renderedElementspublicRenderElement[]undefinedElements rendered during the current pass, used for hit testing.Context3D.renderedElementscore/src/context/context.ts:132
renderElement?publicRenderElementundefinedThe element currently being rendered, if any.Context3D.renderElementcore/src/context/context.ts:130
rootreadonlyHTMLElementundefinedThe host DOM element that the context's rendering surface is mounted into.Context3D.rootdom/src/context.ts:48
saveDepthprotectednumber0-Context3D.saveDepthcore/src/context/context.ts:106
scaleXpublicScale<number, number>undefinedScale mapping logical x coordinates onto this backend's surface x coordinates. Drives drawing, not a conversion seam for callers — use Context.toSurfacePoint.Context3D.scaleXcore/src/context/context.ts:126
scaleYpublicScale<number, number>undefinedScale mapping logical y coordinates onto this backend's surface y coordinates. Drives drawing, not a conversion seam for callers — use Context.toSurfacePoint.Context3D.scaleYcore/src/context/context.ts:128
statesprotectedBaseState[]undefined-Context3D.statescore/src/context/context.ts:103
typereadonlystringundefinedThe context type identifier (e.g. canvas, svg).Context3D.typecore/src/context/context.ts:109
viewMatrixpublicMatrix4undefinedThe view matrix transforming world space into camera (view) space.Context3D.viewMatrix3d/src/core/context.ts:177
viewProjectionMatrixpublicMatrix4undefinedThe combined view-projection matrix, transforming world space directly into clip space.Context3D.viewProjectionMatrix3d/src/core/context.ts:181
widthpublicnumberundefinedCurrent width of the rendering surface, in logical pixels — CSS pixels, unaffected by the device pixel ratio.Context3D.widthcore/src/context/context.ts:122
defaultKeyreadonlytypeof defaultKeyundefinedThe key under which resources are retained when no explicit key is provided.Context3D.defaultKeycore/src/core/disposer.ts:11

Accessors ​

$events ​

Get Signature ​

get $events(): keyof ContextEventMap[]

Defined in: core/src/context/context.ts:135

The event types a context can emit. See EventBus.$events.

Returns ​

keyof ContextEventMap[]

Inherited from ​

Context3D.$events


currentRenderElement ​

Get Signature ​

get currentRenderElement(): RenderElement | undefined

Defined in: core/src/context/context.ts:153

The element currently being rendered; setting a non-abstract element also records it in Context.renderedElements.

Returns ​

RenderElement | undefined

Set Signature ​

set currentRenderElement(element): void

Defined in: core/src/context/context.ts:157

Parameters ​
ParameterType
elementRenderElement | undefined
Returns ​

void

Inherited from ​

Context3D.currentRenderElement


direction ​

Get Signature ​

get direction(): Direction

Defined in: core/src/context/context.ts:184

Directionality used when rendering text.

Returns ​

Direction

Set Signature ​

set direction(value): void

Defined in: core/src/context/context.ts:188

Directionality used when rendering text.

Parameters ​
ParameterType
valueDirection
Returns ​

void

Directionality used when rendering text.

Inherited from ​

Context3D.direction


fill ​

Get Signature ​

get fill(): string

Defined in: core/src/context/context.ts:166

Fill style (CSS color, gradient, or pattern) used to paint filled regions.

Returns ​

string

Set Signature ​

set fill(value): void

Defined in: core/src/context/context.ts:170

Fill style (CSS color, gradient, or pattern) used to paint filled regions.

Parameters ​
ParameterType
valuestring
Returns ​

void

Fill style (CSS color, gradient, or pattern) used to paint filled regions.

Inherited from ​

Context3D.fill


filter ​

Get Signature ​

get filter(): string

Defined in: core/src/context/context.ts:175

CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).

Returns ​

string

Set Signature ​

set filter(value): void

Defined in: core/src/context/context.ts:179

CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).

Parameters ​
ParameterType
valuestring
Returns ​

void

CSS filter string applied to subsequent drawing operations (e.g. blur(4px)).

Inherited from ​

Context3D.filter


fog ​

Get Signature ​

get fog(): Fog | null

Defined in: 3d/src/core/context.ts:212

Atmospheric haze blending distant geometry towards a colour, or null for none.

Both backends resolve it identically. Assign a new object to change it — mutating the existing one in place will not repaint.

Returns ​

Fog | null

Set Signature ​

set fog(value): void

Defined in: 3d/src/core/context.ts:216

Parameters ​
ParameterType
valueFog | null
Returns ​

void

Inherited from ​

Context3D.fog


font ​

Get Signature ​

get font(): string

Defined in: core/src/context/context.ts:193

CSS font shorthand used when rendering text.

Returns ​

string

Set Signature ​

set font(value): void

Defined in: core/src/context/context.ts:197

CSS font shorthand used when rendering text.

Parameters ​
ParameterType
valuestring
Returns ​

void

CSS font shorthand used when rendering text.

Inherited from ​

Context3D.font


fontKerning ​

Get Signature ​

get fontKerning(): FontKerning

Defined in: core/src/context/context.ts:202

Whether font kerning is applied when rendering text.

Returns ​

FontKerning

Set Signature ​

set fontKerning(value): void

Defined in: core/src/context/context.ts:206

Whether font kerning is applied when rendering text.

Parameters ​
ParameterType
valueFontKerning
Returns ​

void

Whether font kerning is applied when rendering text.

Inherited from ​

Context3D.fontKerning


globalCompositeOperation ​

Get Signature ​

get globalCompositeOperation(): unknown

Defined in: core/src/context/context.ts:220

Compositing operation controlling how new drawing is blended with existing content.

Returns ​

unknown

Set Signature ​

set globalCompositeOperation(value): void

Defined in: core/src/context/context.ts:224

Compositing operation controlling how new drawing is blended with existing content.

Parameters ​
ParameterType
valueunknown
Returns ​

void

Compositing operation controlling how new drawing is blended with existing content.

Inherited from ​

Context3D.globalCompositeOperation


lightDirection ​

Get Signature ​

get lightDirection(): Vector3

Defined in: 3d/src/core/context.ts:244

The direction of the default rig's directional light.

A convenience over reaching into lights for the single-light case. Replacing the rig through Context3DOptions.lights, or removing that light, leaves this inert — set the light's own direction instead.

Returns ​

Vector3

Set Signature ​

set lightDirection(value): void

Defined in: 3d/src/core/context.ts:248

Parameters ​
ParameterType
valueVector3
Returns ​

void

Inherited from ​

Context3D.lightDirection


lightMode ​

Get Signature ​

get lightMode(): LightMode

Defined in: 3d/src/core/context.ts:261

Whether the default rig's directional light is fixed in world space or follows the camera.

Inert once the default rig is replaced, exactly as lightDirection is.

Returns ​

LightMode

Set Signature ​

set lightMode(value): void

Defined in: 3d/src/core/context.ts:265

Parameters ​
ParameterType
valueLightMode
Returns ​

void

Inherited from ​

Context3D.lightMode


lineCap ​

Get Signature ​

get lineCap(): LineCap

Defined in: core/src/context/context.ts:229

Cap style drawn at the endpoints of stroked lines.

Returns ​

LineCap

Set Signature ​

set lineCap(value): void

Defined in: core/src/context/context.ts:233

Cap style drawn at the endpoints of stroked lines.

Parameters ​
ParameterType
valueLineCap
Returns ​

void

Cap style drawn at the endpoints of stroked lines.

Inherited from ​

Context3D.lineCap


lineDash ​

Get Signature ​

get lineDash(): number[]

Defined in: core/src/context/context.ts:238

Dash pattern as alternating stroke and gap lengths; empty for a solid line.

Returns ​

number[]

Set Signature ​

set lineDash(value): void

Defined in: core/src/context/context.ts:242

Dash pattern as alternating stroke and gap lengths; empty for a solid line.

Parameters ​
ParameterType
valuenumber[]
Returns ​

void

Dash pattern as alternating stroke and gap lengths; empty for a solid line.

Inherited from ​

Context3D.lineDash


lineDashOffset ​

Get Signature ​

get lineDashOffset(): number

Defined in: core/src/context/context.ts:247

Distance into the line dash pattern at which dashing begins.

Returns ​

number

Set Signature ​

set lineDashOffset(value): void

Defined in: core/src/context/context.ts:251

Distance into the line dash pattern at which dashing begins.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Distance into the line dash pattern at which dashing begins.

Inherited from ​

Context3D.lineDashOffset


lineJoin ​

Get Signature ​

get lineJoin(): LineJoin

Defined in: core/src/context/context.ts:256

Join style drawn where two stroked segments meet.

Returns ​

LineJoin

Set Signature ​

set lineJoin(value): void

Defined in: core/src/context/context.ts:260

Join style drawn where two stroked segments meet.

Parameters ​
ParameterType
valueLineJoin
Returns ​

void

Join style drawn where two stroked segments meet.

Inherited from ​

Context3D.lineJoin


lineWidth ​

Get Signature ​

get lineWidth(): number

Defined in: core/src/context/context.ts:265

Width, in pixels, of stroked lines.

Returns ​

number

Set Signature ​

set lineWidth(value): void

Defined in: core/src/context/context.ts:269

Width, in pixels, of stroked lines.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Width, in pixels, of stroked lines.

Inherited from ​

Context3D.lineWidth


miterLimit ​

Get Signature ​

get miterLimit(): number

Defined in: core/src/context/context.ts:274

Miter length limit ratio applied to miter line joins.

Returns ​

number

Set Signature ​

set miterLimit(value): void

Defined in: core/src/context/context.ts:278

Miter length limit ratio applied to miter line joins.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Miter length limit ratio applied to miter line joins.

Inherited from ​

Context3D.miterLimit


opacity ​

Get Signature ​

get opacity(): number

Defined in: core/src/context/context.ts:211

Global alpha applied to everything drawn, from 0 to 1. Assignment replaces the current alpha; element and group opacity instead composite multiplicatively through CONTEXT_OPERATIONS.

Returns ​

number

Set Signature ​

set opacity(value): void

Defined in: core/src/context/context.ts:215

Global alpha applied to everything drawn, from 0 to 1.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Global alpha applied to everything drawn, from 0 to 1.

Inherited from ​

Context3D.opacity


projectionMode ​

Get Signature ​

get projectionMode(): "perspective" | "orthographic"

Defined in: 3d/src/core/context.ts:228

The projection currently in effect, which a resize preserves.

Returns ​

"perspective" | "orthographic"

Inherited from ​

Context3D.projectionMode


renderStrategy ​

Get Signature ​

get renderStrategy(): RenderStrategy

Defined in: 3d/src/core/context.ts:233

The active rendering strategy (cpu or gpu) for this context.

Returns ​

RenderStrategy

Inherited from ​

Context3D.renderStrategy


resolvedFog ​

Get Signature ​

get resolvedFog(): ResolvedFog | null

Defined in: 3d/src/core/context.ts:223

The resolved fog both backends shade against, or null when there is none.

Returns ​

ResolvedFog | null

Inherited from ​

Context3D.resolvedFog


rotation ​

Get Signature ​

get rotation(): Rotation

Defined in: core/src/context/context.ts:391

Rotation applied to the element's transform, as radians or a deg/rad string.

Returns ​

Rotation

Set Signature ​

set rotation(value): void

Defined in: core/src/context/context.ts:395

Rotation applied to the element's transform, as radians or a deg/rad string.

Parameters ​
ParameterType
valueRotation
Returns ​

void

Rotation applied to the element's transform, as radians or a deg/rad string.

Inherited from ​

Context3D.rotation


shadowBlur ​

Get Signature ​

get shadowBlur(): number

Defined in: core/src/context/context.ts:283

Gaussian blur radius applied to drawn shadows.

Returns ​

number

Set Signature ​

set shadowBlur(value): void

Defined in: core/src/context/context.ts:287

Gaussian blur radius applied to drawn shadows.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Gaussian blur radius applied to drawn shadows.

Inherited from ​

Context3D.shadowBlur


shadowColor ​

Get Signature ​

get shadowColor(): string

Defined in: core/src/context/context.ts:292

Color of drawn shadows.

Returns ​

string

Set Signature ​

set shadowColor(value): void

Defined in: core/src/context/context.ts:296

Color of drawn shadows.

Parameters ​
ParameterType
valuestring
Returns ​

void

Color of drawn shadows.

Inherited from ​

Context3D.shadowColor


shadowOffsetX ​

Get Signature ​

get shadowOffsetX(): number

Defined in: core/src/context/context.ts:301

Horizontal offset, in pixels, of drawn shadows.

Returns ​

number

Set Signature ​

set shadowOffsetX(value): void

Defined in: core/src/context/context.ts:305

Horizontal offset, in pixels, of drawn shadows.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Horizontal offset, in pixels, of drawn shadows.

Inherited from ​

Context3D.shadowOffsetX


shadowOffsetY ​

Get Signature ​

get shadowOffsetY(): number

Defined in: core/src/context/context.ts:310

Vertical offset, in pixels, of drawn shadows.

Returns ​

number

Set Signature ​

set shadowOffsetY(value): void

Defined in: core/src/context/context.ts:314

Vertical offset, in pixels, of drawn shadows.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Vertical offset, in pixels, of drawn shadows.

Inherited from ​

Context3D.shadowOffsetY


stroke ​

Get Signature ​

get stroke(): string

Defined in: core/src/context/context.ts:319

Stroke style (CSS color, gradient, or pattern) used to paint outlines.

Returns ​

string

Set Signature ​

set stroke(value): void

Defined in: core/src/context/context.ts:323

Stroke style (CSS color, gradient, or pattern) used to paint outlines.

Parameters ​
ParameterType
valuestring
Returns ​

void

Stroke style (CSS color, gradient, or pattern) used to paint outlines.

Inherited from ​

Context3D.stroke


supportsPathCaching ​

Get Signature ​

get supportsPathCaching(): boolean

Defined in: core/src/context/context.ts:733

Whether cached ContextPaths may be safely reused across render cycles. false by default; backends whose Context.createPath is free of per-frame side effects (e.g. canvas) override this to true. SVG, for example, returns false because createPath registers the path into a per-frame virtual DOM tree.

Returns ​

boolean

Inherited from ​

Context3D.supportsPathCaching


textAlign ​

Get Signature ​

get textAlign(): TextAlignment

Defined in: core/src/context/context.ts:328

Horizontal alignment of text relative to the drawing position.

Returns ​

TextAlignment

Set Signature ​

set textAlign(value): void

Defined in: core/src/context/context.ts:332

Horizontal alignment of text relative to the drawing position.

Parameters ​
ParameterType
valueTextAlignment
Returns ​

void

Horizontal alignment of text relative to the drawing position.

Inherited from ​

Context3D.textAlign


textBaseline ​

Get Signature ​

get textBaseline(): TextBaseline

Defined in: core/src/context/context.ts:337

Vertical baseline used when positioning text.

Returns ​

TextBaseline

Set Signature ​

set textBaseline(value): void

Defined in: core/src/context/context.ts:341

Vertical baseline used when positioning text.

Parameters ​
ParameterType
valueTextBaseline
Returns ​

void

Vertical baseline used when positioning text.

Inherited from ​

Context3D.textBaseline


transformOriginX ​

Get Signature ​

get transformOriginX(): TransformOrigin

Defined in: core/src/context/context.ts:400

Horizontal origin about which rotation and scaling are applied.

Returns ​

TransformOrigin

Set Signature ​

set transformOriginX(value): void

Defined in: core/src/context/context.ts:404

Horizontal origin about which rotation and scaling are applied.

Parameters ​
ParameterType
valueTransformOrigin
Returns ​

void

Horizontal origin about which rotation and scaling are applied.

Inherited from ​

Context3D.transformOriginX


transformOriginY ​

Get Signature ​

get transformOriginY(): TransformOrigin

Defined in: core/src/context/context.ts:409

Vertical origin about which rotation and scaling are applied.

Returns ​

TransformOrigin

Set Signature ​

set transformOriginY(value): void

Defined in: core/src/context/context.ts:413

Vertical origin about which rotation and scaling are applied.

Parameters ​
ParameterType
valueTransformOrigin
Returns ​

void

Vertical origin about which rotation and scaling are applied.

Inherited from ​

Context3D.transformOriginY


transformScaleX ​

Get Signature ​

get transformScaleX(): number

Defined in: core/src/context/context.ts:373

Horizontal scale factor applied to the element's transform.

Returns ​

number

Set Signature ​

set transformScaleX(value): void

Defined in: core/src/context/context.ts:377

Horizontal scale factor applied to the element's transform.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Horizontal scale factor applied to the element's transform.

Inherited from ​

Context3D.transformScaleX


transformScaleY ​

Get Signature ​

get transformScaleY(): number

Defined in: core/src/context/context.ts:382

Vertical scale factor applied to the element's transform.

Returns ​

number

Set Signature ​

set transformScaleY(value): void

Defined in: core/src/context/context.ts:386

Vertical scale factor applied to the element's transform.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Vertical scale factor applied to the element's transform.

Inherited from ​

Context3D.transformScaleY


translateX ​

Get Signature ​

get translateX(): number

Defined in: core/src/context/context.ts:355

Horizontal translation, in pixels, applied to the element's transform.

Returns ​

number

Set Signature ​

set translateX(value): void

Defined in: core/src/context/context.ts:359

Horizontal translation, in pixels, applied to the element's transform.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Horizontal translation, in pixels, applied to the element's transform.

Inherited from ​

Context3D.translateX


translateY ​

Get Signature ​

get translateY(): number

Defined in: core/src/context/context.ts:364

Vertical translation, in pixels, applied to the element's transform.

Returns ​

number

Set Signature ​

set translateY(value): void

Defined in: core/src/context/context.ts:368

Vertical translation, in pixels, applied to the element's transform.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Vertical translation, in pixels, applied to the element's transform.

Inherited from ​

Context3D.translateY


zIndex ​

Get Signature ​

get zIndex(): number

Defined in: core/src/context/context.ts:346

Stacking order used to sort elements during rendering; higher values draw on top.

Returns ​

number

Set Signature ​

set zIndex(value): void

Defined in: core/src/context/context.ts:350

Stacking order used to sort elements during rendering; higher values draw on top.

Parameters ​
ParameterType
valuenumber
Returns ​

void

Stacking order used to sort elements during rendering; higher values draw on top.

Inherited from ​

Context3D.zIndex

Methods ​

applyClip() ​

applyClip(): void

Defined in: webgpu/src/context.ts:283

No-op; the WebGPU pipeline rasterises submitted meshes only. Warns once.

Returns ​

void

Overrides ​

Context3D.applyClip


applyFill() ​

applyFill(): void

Defined in: webgpu/src/context.ts:273

No-op; the WebGPU pipeline rasterises submitted meshes only. Warns once.

Returns ​

void

Overrides ​

Context3D.applyFill


applyGroupPaint() ​

protected applyGroupPaint(group): void

Defined in: core/src/context/context.ts:603

Applies a group's own inherited paint (fill, stroke, opacity, font, line, shadow, text) to the context so descendants pick it up from the copied state. Transforms are applied separately, so they are skipped here.

Two boundary semantics are fixed here and every backend must honour them:

  • Opacity composites multiplicatively. CONTEXT_OPERATIONS multiplies rather than assigns, so nested groups compound and a leaf's own alpha stacks under its ancestors' instead of replacing it.
  • A group's gradient or pattern resolves against the group's own box. The group is the Context.currentRenderElement for the duration of the boundary, so a paint that bakes geometry at set time (canvas) and one that resolves it per leaf (SVG) agree on the same reference box: group.getBoundingBox(true), never a sibling's and never the surface.

Parameters ​

ParameterType
groupElement

Returns ​

void

Inherited from ​

Context3D.applyGroupPaint


applyStroke() ​

applyStroke(): void

Defined in: webgpu/src/context.ts:278

No-op; the WebGPU pipeline rasterises submitted meshes only. Warns once.

Returns ​

void

Overrides ​

Context3D.applyStroke


batch() ​

batch<TResult>(body): TResult

Defined in: core/src/context/context.ts:534

Clears the rendering surface and brackets the callback in markRenderStart/markRenderEnd, returning the callback's result. On exit the state stack is unwound to the depth captured on entry, giving the scene root the same guarantee Context.popGroup gives a group: a root-level clip: true shape deliberately skips its own restore() so the clip persists to later siblings, and with no enclosing group to absorb it that save would otherwise leak one state per frame, unbounded.

The surface is only cleared at render depth 0: a pass entered while an outer one is open continues it (matching Context.markRenderStart) rather than wiping what it drew.

Type Parameters ​

Type ParameterDefault type
TResultvoid

Parameters ​

ParameterType
body() => TResult

Returns ​

TResult

Inherited from ​

Context3D.batch


captureFaceState() ​

captureFaceState(transform): ProjectedFaceState3D

Defined in: 3d/src/core/context.ts:585

Snapshots the drawing state a face must be painted with.

The CPU painter buffers faces and flushes them at the end of the frame, by which point every element restore() and popGroup() has already unwound the state the face was projected under. Capturing it here is what lets CanvasContext3D re-apply it at draw time.

Parameters ​

ParameterTypeDescription
transformMatrix | nullThe element's composed 2D world transform, or null for the identity.

Returns ​

ProjectedFaceState3D

The resolved drawing state to store on each of the element's faces.

Inherited from ​

Context3D.captureFaceState


clear() ​

clear(): void

Defined in: webgpu/src/context.ts:245

No-op; the surface is cleared by the render pass via loadOp: 'clear'.

Returns ​

void

Overrides ​

Context3D.clear


createPath() ​

createPath(id?): CanvasPath

Defined in: webgpu/src/context.ts:268

Creates a CanvasPath used for CPU-side hit testing.

Parameters ​

ParameterType
id?string

Returns ​

CanvasPath

Overrides ​

Context3D.createPath


createText() ​

createText(options): ContextText

Defined in: webgpu/src/context.ts:293

Creates a text element that this backend cannot paint. Warns once.

Parameters ​

ParameterType
optionsTextOptions

Returns ​

ContextText

Overrides ​

Context3D.createText


destroy() ​

destroy(): void

Defined in: webgpu/src/context.ts:422

Destroys the WebGPU context, unconfigures the swap chain, and releases every GPU resource.

Returns ​

void

Overrides ​

Context3D.destroy


disableInteraction() ​

disableInteraction(): void

Defined in: dom/src/context.ts:388

Disables DOM interaction events, unwinding any hover with a final mouseleave per element.

Returns ​

void

Inherited from ​

Context3D.disableInteraction


dispose() ​

protected dispose(key?): void

Defined in: core/src/core/disposer.ts:25

Disposes all resources under the given key, or all resources if no key is provided.

Parameters ​

ParameterType
key?PropertyKey

Returns ​

void

Inherited from ​

Context3D.dispose


drawImage() ​

drawImage(): void

Defined in: webgpu/src/context.ts:288

No-op; the WebGPU pipeline rasterises submitted meshes only. Warns once.

Returns ​

void

Overrides ​

Context3D.drawImage


emit() ​

Call Signature ​

emit<TEvent>(event): TEvent

Defined in: core/src/core/event-bus.ts:185

Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.

Type Parameters ​
Type ParameterDefault type
TEvent extends Event<undefined>Event<undefined>
Parameters ​
ParameterType
eventTEvent
Returns ​

TEvent

Inherited from ​

Context3D.emit

Call Signature ​

emit<TEvent>(type, data): Event<ContextEventMap[TEvent]>

Defined in: core/src/core/event-bus.ts:186

Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.

Type Parameters ​
Type Parameter
TEvent extends keyof ContextEventMap
Parameters ​
ParameterType
typeTEvent
dataContextEventMap[TEvent]
Returns ​

Event<ContextEventMap[TEvent]>

Inherited from ​

Context3D.emit


enableInteraction() ​

enableInteraction(): void

Defined in: dom/src/context.ts:344

Enables DOM interaction events (mouse enter, leave, move, down, up, click, drag) with element hit testing.

Returns ​

void

Inherited from ​

Context3D.enableInteraction


export() ​

export(): ContextExport

Defined in: 3d/src/core/context.ts:627

Exports the rendered canvas. Shared by CPU and GPU 3D contexts; call after a frame has rendered (GPU present textures are transient, so createCanvasExport snapshots immediately).

Returns ​

ContextExport

Inherited from ​

Context3D.export


getDefaultState() ​

protected getDefaultState(): BaseState

Defined in: core/src/context/context.ts:446

Returns ​

BaseState

Inherited from ​

Context3D.getDefaultState


getLightDirectionForRender() ​

getLightDirectionForRender(): Vector3

Defined in: 3d/src/core/context.ts:414

Returns the effective light direction for the current render, accounting for the light mode.

Both consumers dot this against a world-space normal, so 'world' is the identity and 'camera' reads lightDirection as camera-relative and carries it into world space through the inverse of the view rotation.

Returns ​

Vector3

Inherited from ​

Context3D.getLightDirectionForRender


has() ​

has(type): boolean

Defined in: core/src/core/event-bus.ts:123

Returns whether there are any listeners registered for the given event type. Wildcard subscriptions (EVENT_WILDCARD) are not listeners for any concrete type, so a bus observed only through the wildcard still reports false here.

Parameters ​

ParameterType
typekeyof ContextEventMap

Returns ​

boolean

Inherited from ​

Context3D.has


hitTest() ​

protected hitTest(events, x, y): RenderElement[]

Defined in: 3d/src/core/context.ts:480

Tests which rendered elements the pointer is over, ranking 3D shapes by how near their geometry is rather than by paint order.

The base class ranks by paint order, which for 2D is exactly right — the last thing painted is the thing on top. A 3D scene does not paint in element order: CanvasContext3D.flushFaces buffers the faces of every shape and depth-sorts them globally, so what you see is ordered by depth while what the base class hits is ordered by the position an element happened to take in the render stream. For an assembly of interleaved parts those two orders routinely disagree.

2D elements keep their paint order and their positions in the list, so a 2D element painted over a 3D one still wins: it flushed the face buffer, and paint order genuinely does decide there.

Parameters ​

ParameterType
eventsstring[]
xnumber
ynumber

Returns ​

RenderElement[]

Inherited from ​

Context3D.hitTest


init() ​

protected init(): void

Defined in: dom/src/context.ts:85

Returns ​

void

Inherited from ​

Context3D.init


invalidateTrackedElements() ​

invalidateTrackedElements(event?): void

Defined in: core/src/context/context.ts:496

Clears the cached list of tracked elements for interaction, forcing a rebuild on the next hit test.

Parameters ​

ParameterType
event?string

Returns ​

void

Inherited from ​

Context3D.invalidateTrackedElements


isPointInPath() ​

isPointInPath(path, x, y, fillRule?): boolean

Defined in: webgpu/src/context.ts:300

Tests whether the logical-space point (x, y) lies inside the given path's fill, using an offscreen 2D canvas.

Parameters ​

ParameterType
pathContextPath
xnumber
ynumber
fillRule?FillRule

Returns ​

boolean

Overrides ​

Context3D.isPointInPath


isPointInStroke() ​

isPointInStroke(path, x, y): boolean

Defined in: webgpu/src/context.ts:312

Tests whether the logical-space point (x, y) lies on the given path's stroke, using an offscreen 2D canvas.

Parameters ​

ParameterType
pathContextPath
xnumber
ynumber

Returns ​

boolean

Overrides ​

Context3D.isPointInStroke


layer() ​

layer<TResult>(body): TResult

Defined in: core/src/context/context.ts:472

Executes a callback within a save/restore pair, returning the callback's result.

Type Parameters ​

Type ParameterDefault type
TResultvoid

Parameters ​

ParameterType
body() => TResult

Returns ​

TResult

Inherited from ​

Context3D.layer


markRenderEnd() ​

markRenderEnd(): void

Defined in: webgpu/src/context.ts:234

Ends the render pass and, at the outermost depth, executes the queued GPU draw commands.

Returns ​

void

Overrides ​

Context3D.markRenderEnd


markRenderStart() ​

markRenderStart(): void

Defined in: webgpu/src/context.ts:225

Begins a render pass, resetting per-frame geometry accumulation at the outermost depth.

Returns ​

void

Overrides ​

Context3D.markRenderStart


measureText() ​

measureText(text, font?): TextMetrics

Defined in: webgpu/src/context.ts:417

Measures text using the offscreen 2D canvas context.

Parameters ​

ParameterType
textstring
font?string

Returns ​

TextMetrics

Overrides ​

Context3D.measureText


off() ​

off<TEvent>(type, handler): void

Defined in: core/src/core/event-bus.ts:144

Removes a previously registered handler for the given event type.

Type Parameters ​

Type Parameter
TEvent extends keyof ContextEventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>

Returns ​

void

Inherited from ​

Context3D.off


on() ​

on<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:131

Subscribes a handler to the given event type and returns a disposable for cleanup. Pass EVENT_WILDCARD to receive every event emitted on the bus regardless of type.

Type Parameters ​

Type Parameter
TEvent extends keyof ContextEventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>
options?EventSubscriptionOptions

Returns ​

Disposable

Inherited from ​

Context3D.on


once() ​

once<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:159

Subscribes a handler that is automatically removed after it fires once.

Type Parameters ​

Type Parameter
TEvent extends keyof ContextEventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<ContextEventMap[TEvent]>
options?EventSubscriptionOptions

Returns ​

Disposable

Inherited from ​

Context3D.once


popGroup() ​

popGroup(): void

Defined in: core/src/context/context.ts:620

Closes the most recently opened group boundary, unwinding the state stack back to the depth captured at Context.pushGroup and restoring the render element that was current before it. This absorbs any dangling save() left by a group-scoped clip (which deliberately skips its own restore so the clip persists to later siblings), confining the clip to the group rather than leaking it to the scene.

Returns ​

void

Inherited from ​

Context3D.popGroup


project() ​

project(point): ProjectedPoint

Defined in: 3d/src/core/context.ts:571

Projects a 3D world-space point to 2D logical coordinates — CSS pixels relative to the context's top-left — plus a depth for z-ordering.

Parameters ​

ParameterType
pointVector3

Returns ​

ProjectedPoint

Inherited from ​

Context3D.project


pushGroup() ​

pushGroup(group): void

Defined in: core/src/context/context.ts:573

Opens a group boundary: saves the current drawing state and applies the group's own transform and inherited paint (see applyGroupPaint for the opacity and gradient-bounds semantics every backend must honour), so that descendant elements render within the group's coordinate system, inherit its paint through the copied state (the render-tree cascade), and composite under its opacity. Any group-scoped clip is confined to the group. Every Context.pushGroup must be balanced by a matching Context.popGroup. Backends that render hierarchy structurally (such as SVG) override this to nest descendants under a group node.

Parameters ​

ParameterTypeDescription
groupElementThe group element whose boundary is being entered.

Returns ​

void

Inherited from ​

Context3D.pushGroup


raycast() ​

raycast(x, y): Ray | null

Defined in: 3d/src/core/context.ts:429

Builds the world-space ray through a point on the surface.

Parameters ​

ParameterTypeDescription
xnumberScreen-space x, in logical CSS pixels relative to the context's top-left.
ynumberScreen-space y.

Returns ​

Ray | null

The ray, or null when the view-projection matrix is singular.

Inherited from ​

Context3D.raycast


raycastAll() ​

raycastAll(root, x, y, options?): Intersection3D[]

Defined in: 3d/src/core/context.ts:446

Casts a ray through a point on the surface and returns every 3D shape it meets.

Reports the full intersection — point, face, normal and texture coordinate — where hitTest answers only which elements the pointer is over. It also ignores pointerEvents and whether a shape has any handlers, so it sees the whole scene.

Parameters ​

ParameterTypeDescription
rootElementThe element to search, typically the scene.
xnumberScreen-space x, in logical CSS pixels relative to the context's top-left.
ynumberScreen-space y.
options?Raycast3DOptionsWhether to accept back-facing hits.

Returns ​

Intersection3D[]

The intersections, nearest first.

Inherited from ​

Context3D.raycastAll


requestRender() ​

requestRender(): void

Defined in: core/src/context/context.ts:505

Requests that the bound scene repaint on the next frame, for context-level changes (e.g. a 3D camera move) that mutate no element and so would otherwise be skipped by the renderer's dirty check.

Returns ​

void

Inherited from ​

Context3D.requestRender


rescale() ​

protected rescale(width, height): void

Defined in: webgpu/src/context.ts:136

Parameters ​

ParameterType
widthnumber
heightnumber

Returns ​

void

Overrides ​

Context3D.rescale


reset() ​

reset(): void

Defined in: core/src/context/context.ts:488

Resets the context to its initial state: drops the saved-state stack, restores the default drawing state, and closes any open group boundary.

Returns ​

void

Inherited from ​

Context3D.reset


resolveLights() ​

resolveLights(): ResolvedLight[]

Defined in: 3d/src/core/context.ts:518

Resolves the scene's lights into the flat numeric form both backends shade against.

Cached until a light changes or the camera moves, because the CPU painter asks for it once per shape and camera-space lights depend on the view matrix.

Returns ​

ResolvedLight[]

The enabled lights, capped at MAX_LIGHTS.

Inherited from ​

Context3D.resolveLights


restore() ​

restore(): void

Defined in: core/src/context/context.ts:462

Restores the most recently saved state from the stack.

Returns ​

void

Inherited from ​

Context3D.restore


retain() ​

protected retain(value, key?): void

Defined in: core/src/core/disposer.ts:14

Registers a disposable resource under an optional key for later cleanup.

Parameters ​

ParameterTypeDefault value
valueDisposableundefined
keyPropertyKeyDisposer.defaultKey

Returns ​

void

Inherited from ​

Context3D.retain


rotate() ​

rotate(angle): void

Defined in: core/src/context/context.ts:634

Applies a rotation transformation.

Parameters ​

ParameterType
anglenumber

Returns ​

void

Inherited from ​

Context3D.rotate


save() ​

save(): void

Defined in: core/src/context/context.ts:455

Pushes the current state onto the stack and continues with a copy of it, so nested scopes inherit the enclosing drawing state (matching native canvas). This is what lets a group's paint, applied once at its boundary via Context.pushGroup, cascade to descendants.

Returns ​

void

Inherited from ​

Context3D.save


scale() ​

scale(x, y): void

Defined in: core/src/context/context.ts:639

Applies a scale transformation.

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void

Inherited from ​

Context3D.scale


setCamera() ​

setCamera(eye, target, up): void

Defined in: 3d/src/core/context.ts:367

Sets the view matrix from an eye position, look-at target, and up direction.

Parameters ​

ParameterType
eyeVector3
targetVector3
upVector3

Returns ​

void

Inherited from ​

Context3D.setCamera


setOrthographic() ​

setOrthographic(left, right, bottom, top, near, far): void

Defined in: 3d/src/core/context.ts:393

Sets an orthographic projection with explicit frustum bounds.

The bounds are retained and replayed verbatim whenever the projection is rebuilt, so a resize keeps the projection orthographic. It does not re-fit the frustum to the new aspect ratio — the caller owns that, and Camera recomputes it on its next flush.

Parameters ​

ParameterType
leftnumber
rightnumber
bottomnumber
topnumber
nearnumber
farnumber

Returns ​

void

Inherited from ​

Context3D.setOrthographic


setPerspective() ​

setPerspective(fov, near, far): void

Defined in: 3d/src/core/context.ts:377

Updates the perspective projection with the given field of view, near, and far planes, replacing any orthographic projection.

Parameters ​

ParameterType
fovnumber
nearnumber
farnumber

Returns ​

void

Inherited from ​

Context3D.setPerspective


setTransform() ​

setTransform(a, b, c, d, e, f): void

Defined in: core/src/context/context.ts:663

Replaces the current transformation matrix with [a, b, c, d, e, f].

The matrix is in logical space, so the identity (1, 0, 0, 1, 0, 0) restores the context's own baseline rather than the backend's — on canvas that baseline is the device pixel ratio, which the backend composes back underneath. Translations are therefore in CSS pixels.

Parameters ​

ParameterTypeDescription
anumberHorizontal scaling.
bnumberVertical skewing.
cnumberHorizontal skewing.
dnumberVertical scaling.
enumberHorizontal translation, in logical pixels.
fnumberVertical translation, in logical pixels.

Returns ​

void

Inherited from ​

Context3D.setTransform


submitMesh() ​

submitMesh(submission): void

Defined in: webgpu/src/context.ts:216

Submits a mesh for GPU rendering this frame.

Parameters ​

ParameterType
submissionMeshSubmission

Returns ​

void

Overrides ​

Context3D.submitMesh


toLogicalPoint() ​

toLogicalPoint(x, y): [number, number]

Defined in: core/src/context/context.ts:697

Maps a point from surface space — this backend's own drawing coordinates, as produced by Context.scaleX and Context.scaleY — into the logical space elements are authored in and every public coordinate is expressed in.

Backends disagree on what surface space is: canvas maps logical coordinates onto device pixels while SVG leaves them identity, so a backend has to invert what this context actually does rather than assume the device pixel ratio.

This is a seam for backend implementors, not for consumers — nothing crossing the public API is in surface space, so a caller holding a pointer coordinate already has a logical one.

Parameters ​

ParameterTypeDescription
xnumberX coordinate in surface space.
ynumberY coordinate in surface space.

Returns ​

[number, number]

The [x, y] pair in logical space.

Inherited from ​

Context3D.toLogicalPoint


toSurfacePoint() ​

toSurfacePoint(x, y): [number, number]

Defined in: core/src/context/context.ts:710

Maps a point from the logical space elements are authored in into this backend's own drawing coordinates. The inverse of Context.toLogicalPoint, and likewise a seam for backend implementors rather than consumers.

Parameters ​

ParameterTypeDescription
xnumberX coordinate in logical space.
ynumberY coordinate in logical space.

Returns ​

[number, number]

The [x, y] pair in surface space.

Inherited from ​

Context3D.toSurfacePoint


transform() ​

transform(a, b, c, d, e, f): void

Defined in: core/src/context/context.ts:677

Multiplies the current transformation matrix by [a, b, c, d, e, f].

Parameters ​

ParameterTypeDescription
anumberHorizontal scaling.
bnumberVertical skewing.
cnumberHorizontal skewing.
dnumberVertical scaling.
enumberHorizontal translation.
fnumberVertical translation.

Returns ​

void

Inherited from ​

Context3D.transform


translate() ​

translate(x, y): void

Defined in: core/src/context/context.ts:644

Applies a translation transformation.

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void

Inherited from ​

Context3D.translate


updateProjectionMatrix() ​

protected updateProjectionMatrix(): void

Defined in: 3d/src/core/context.ts:346

Returns ​

void

Inherited from ​

Context3D.updateProjectionMatrix


updateViewProjectionMatrix() ​

protected updateViewProjectionMatrix(): void

Defined in: 3d/src/core/context.ts:342

Returns ​

void

Inherited from ​

Context3D.updateViewProjectionMatrix