Skip to content

Documentation / @ripl/3d / CanvasContext3D

Class: CanvasContext3D

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

Canvas 2D–backed 3D rendering context with face buffer and painter's algorithm sorting.

Extends

Constructors

Constructor

new CanvasContext3D(target, options?): CanvasContext3D

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

Parameters

ParameterType
targetstring | HTMLElement
options?Context3DOptions

Returns

CanvasContext3D

Overrides

Context3D.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
bufferpublicbooleanfalseWhether drawing is buffered rather than committed to the surface immediately.Context3D.buffercore/src/context/context.ts:121
contextprotectedCanvasRenderingContext2Dundefined--3d/src/core/context.ts:244
currentStateprotectedBaseStateundefined-Context3D.currentStatecore/src/context/context.ts:144
elementreadonlyHTMLCanvasElementundefinedThe underlying DOM element the context renders into.Context3D.elementcore/src/context/context.ts:116
faceBufferpublicProjectedFace3D[][]Faces accumulated during the current frame, sorted back-to-front before drawing (painter's algorithm).Context3D.faceBuffer3d/src/core/context.ts:117
farprotectednumberundefined-Context3D.far3d/src/core/context.ts:121
fovprotectednumberundefined-Context3D.fov3d/src/core/context.ts:119
heightpublicnumberundefinedCurrent height, in pixels, of the rendering surface.Context3D.heightcore/src/context/context.ts:131
hitTestHonoursTransformpublicbooleanfalseWhether 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 getWorldTransform.Context3D.hitTestHonoursTransformcore/src/context/context.ts:127
lightDirectionpublicVector3undefinedThe directional light vector used for shading faces.Context3D.lightDirection3d/src/core/context.ts:113
lightModepublicLightModeundefinedWhether lightDirection is fixed in world space or follows the camera.Context3D.lightMode3d/src/core/context.ts:115
metareadonlyContext3DMetaundefinedArbitrary metadata attached to the context.Context3D.metacore/src/context/context.ts:118
nearprotectednumberundefined-Context3D.near3d/src/core/context.ts:120
parent?publicEventBus<ContextEventMap>undefinedThe parent event bus that emitted events bubble up to, if any.Context3D.parentcore/src/core/event-bus.ts:89
projectionMatrixpublicMatrix4undefinedThe projection matrix transforming view space into clip space.Context3D.projectionMatrix3d/src/core/context.ts:109
renderDepthprotectednumber0-Context3D.renderDepthcore/src/context/context.ts:145
renderedElementspublicRenderElement[]undefinedElements rendered during the current pass, used for hit testing.Context3D.renderedElementscore/src/context/context.ts:141
renderElement?publicRenderElementundefinedThe element currently being rendered, if any.Context3D.renderElementcore/src/context/context.ts:139
rootreadonlyHTMLElementundefinedThe host DOM element that the context's rendering surface is mounted into.Context3D.rootdom/src/context.ts:45
saveDepthprotectednumber0-Context3D.saveDepthcore/src/context/context.ts:146
scaleDPRpublicScale<number, number>undefinedScale mapping logical pixels to device pixels using the device pixel ratio.Context3D.scaleDPRcore/src/context/context.ts:137
scaleXpublicScale<number, number>undefinedScale mapping domain x coordinates to surface x coordinates.Context3D.scaleXcore/src/context/context.ts:133
scaleYpublicScale<number, number>undefinedScale mapping domain y coordinates to surface y coordinates.Context3D.scaleYcore/src/context/context.ts:135
statesprotectedBaseState[]undefined-Context3D.statescore/src/context/context.ts:143
typereadonlystringundefinedThe context type identifier (e.g. canvas, svg).Context3D.typecore/src/context/context.ts:114
viewMatrixpublicMatrix4undefinedThe view matrix transforming world space into camera (view) space.Context3D.viewMatrix3d/src/core/context.ts:107
viewProjectionMatrixpublicMatrix4undefinedThe combined view-projection matrix, transforming world space directly into clip space.Context3D.viewProjectionMatrix3d/src/core/context.ts:111
widthpublicnumberundefinedCurrent width, in pixels, of the rendering surface.Context3D.widthcore/src/context/context.ts:129
defaultKeyreadonlytypeof defaultKeyundefinedThe key under which resources are retained when no explicit key is provided.Context3D.defaultKeycore/src/core/disposer.ts:11

Accessors

currentRenderElement

Get Signature

get currentRenderElement(): RenderElement | undefined

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

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:154

Parameters
ParameterType
elementRenderElement | undefined
Returns

void

Inherited from

Context3D.currentRenderElement


direction

Get Signature

get direction(): Direction

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

Directionality used when rendering text.

Returns

Direction

Set Signature

set direction(value): void

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

Directionality used when rendering text.

Parameters
ParameterType
valueDirection
Returns

void

Directionality used when rendering text.

Overrides

Context3D.direction


fill

Get Signature

get fill(): string

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

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

Returns

string

Set Signature

set fill(value): void

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

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

Parameters
ParameterType
valuestring
Returns

void

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

Overrides

Context3D.fill


filter

Get Signature

get filter(): string

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

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

Returns

string

Set Signature

set filter(value): void

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

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

Overrides

Context3D.filter


font

Get Signature

get font(): string

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

CSS font shorthand used when rendering text.

Returns

string

Set Signature

set font(value): void

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

CSS font shorthand used when rendering text.

Parameters
ParameterType
valuestring
Returns

void

CSS font shorthand used when rendering text.

Overrides

Context3D.font


fontKerning

Get Signature

get fontKerning(): FontKerning

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

Whether font kerning is applied when rendering text.

Returns

FontKerning

Set Signature

set fontKerning(value): void

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

Whether font kerning is applied when rendering text.

Parameters
ParameterType
valueFontKerning
Returns

void

Whether font kerning is applied when rendering text.

Overrides

Context3D.fontKerning


globalCompositeOperation

Get Signature

get globalCompositeOperation(): unknown

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

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

Returns

unknown

Set Signature

set globalCompositeOperation(value): void

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

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.

Overrides

Context3D.globalCompositeOperation


lineCap

Get Signature

get lineCap(): LineCap

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

Cap style drawn at the endpoints of stroked lines.

Returns

LineCap

Set Signature

set lineCap(value): void

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

Cap style drawn at the endpoints of stroked lines.

Parameters
ParameterType
valueLineCap
Returns

void

Cap style drawn at the endpoints of stroked lines.

Overrides

Context3D.lineCap


lineDash

Get Signature

get lineDash(): number[]

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

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

Returns

number[]

Set Signature

set lineDash(value): void

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

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.

Overrides

Context3D.lineDash


lineDashOffset

Get Signature

get lineDashOffset(): number

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

Distance into the line dash pattern at which dashing begins.

Returns

number

Set Signature

set lineDashOffset(value): void

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

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.

Overrides

Context3D.lineDashOffset


lineJoin

Get Signature

get lineJoin(): LineJoin

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

Join style drawn where two stroked segments meet.

Returns

LineJoin

Set Signature

set lineJoin(value): void

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

Join style drawn where two stroked segments meet.

Parameters
ParameterType
valueLineJoin
Returns

void

Join style drawn where two stroked segments meet.

Overrides

Context3D.lineJoin


lineWidth

Get Signature

get lineWidth(): number

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

Width, in pixels, of stroked lines.

Returns

number

Set Signature

set lineWidth(value): void

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

Width, in pixels, of stroked lines.

Parameters
ParameterType
valuenumber
Returns

void

Width, in pixels, of stroked lines.

Overrides

Context3D.lineWidth


miterLimit

Get Signature

get miterLimit(): number

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

Miter length limit ratio applied to miter line joins.

Returns

number

Set Signature

set miterLimit(value): void

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

Miter length limit ratio applied to miter line joins.

Parameters
ParameterType
valuenumber
Returns

void

Miter length limit ratio applied to miter line joins.

Overrides

Context3D.miterLimit


opacity

Get Signature

get opacity(): number

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

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

Returns

number

Set Signature

set opacity(value): void

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

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.

Overrides

Context3D.opacity


renderStrategy

Get Signature

get renderStrategy(): RenderStrategy

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

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

Returns

RenderStrategy

Inherited from

Context3D.renderStrategy


rotation

Get Signature

get rotation(): Rotation

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

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:392

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: 3d/src/core/context.ts:360

Gaussian blur radius applied to drawn shadows.

Returns

number

Set Signature

set shadowBlur(value): void

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

Gaussian blur radius applied to drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Gaussian blur radius applied to drawn shadows.

Overrides

Context3D.shadowBlur


shadowColor

Get Signature

get shadowColor(): string

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

Colour of drawn shadows.

Returns

string

Set Signature

set shadowColor(value): void

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

Colour of drawn shadows.

Parameters
ParameterType
valuestring
Returns

void

Colour of drawn shadows.

Overrides

Context3D.shadowColor


shadowOffsetX

Get Signature

get shadowOffsetX(): number

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

Horizontal offset, in pixels, of drawn shadows.

Returns

number

Set Signature

set shadowOffsetX(value): void

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

Horizontal offset, in pixels, of drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Horizontal offset, in pixels, of drawn shadows.

Overrides

Context3D.shadowOffsetX


shadowOffsetY

Get Signature

get shadowOffsetY(): number

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

Vertical offset, in pixels, of drawn shadows.

Returns

number

Set Signature

set shadowOffsetY(value): void

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

Vertical offset, in pixels, of drawn shadows.

Parameters
ParameterType
valuenumber
Returns

void

Vertical offset, in pixels, of drawn shadows.

Overrides

Context3D.shadowOffsetY


stroke

Get Signature

get stroke(): string

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

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

Returns

string

Set Signature

set stroke(value): void

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

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

Parameters
ParameterType
valuestring
Returns

void

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

Overrides

Context3D.stroke


textAlign

Get Signature

get textAlign(): TextAlignment

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

Horizontal alignment of text relative to the drawing position.

Returns

TextAlignment

Set Signature

set textAlign(value): void

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

Horizontal alignment of text relative to the drawing position.

Parameters
ParameterType
valueTextAlignment
Returns

void

Horizontal alignment of text relative to the drawing position.

Overrides

Context3D.textAlign


textBaseline

Get Signature

get textBaseline(): TextBaseline

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

Vertical baseline used when positioning text.

Returns

TextBaseline

Set Signature

set textBaseline(value): void

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

Vertical baseline used when positioning text.

Parameters
ParameterType
valueTextBaseline
Returns

void

Vertical baseline used when positioning text.

Overrides

Context3D.textBaseline


transformOriginX

Get Signature

get transformOriginX(): TransformOrigin

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

Horizontal origin about which rotation and scaling are applied.

Returns

TransformOrigin

Set Signature

set transformOriginX(value): void

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

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:406

Vertical origin about which rotation and scaling are applied.

Returns

TransformOrigin

Set Signature

set transformOriginY(value): void

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

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:370

Horizontal scale factor applied to the element's transform.

Returns

number

Set Signature

set transformScaleX(value): void

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

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:379

Vertical scale factor applied to the element's transform.

Returns

number

Set Signature

set transformScaleY(value): void

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

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:352

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:356

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:361

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:365

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:343

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:347

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(path, fillRule?): void

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

Clips subsequent drawing operations to the given path.

Parameters

ParameterType
pathCanvasPath
fillRule?FillRule

Returns

void

Overrides

Context3D.applyClip


applyFill()

applyFill(element, fillRule?): void

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

Fills the given path or text element using the current fill style.

Parameters

ParameterType
elementContextText | CanvasPath
fillRule?FillRule

Returns

void

Overrides

Context3D.applyFill


applyGroupPaint()

protected applyGroupPaint(group): void

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

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

Parameters

ParameterType
groupElement

Returns

void

Inherited from

Context3D.applyGroupPaint


applyStroke()

applyStroke(element): void

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

Strokes the given path or text element using the current stroke style.

Parameters

ParameterType
elementContextText | CanvasPath

Returns

void

Overrides

Context3D.applyStroke


batch()

batch<TResult>(body): TResult

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

Clears the rendering surface and brackets the callback in markRenderStart/markRenderEnd, returning the callback's result.

Type Parameters

Type ParameterDefault type
TResultvoid

Parameters

ParameterType
body() => TResult

Returns

TResult

Inherited from

Context3D.batch


clear()

clear(): void

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

Clears the entire rendering surface.

Returns

void

Overrides

Context3D.clear


createPath()

createPath(id?): CanvasPath

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

Creates a new path element, optionally reusing an id for SVG diffing efficiency.

Parameters

ParameterType
id?string

Returns

CanvasPath

Overrides

Context3D.createPath


createText()

createText(options): ContextText

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

Creates a new text element from the given options.

Parameters

ParameterType
optionsTextOptions

Returns

ContextText

Inherited from

Context3D.createText


destroy()

destroy(): void

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

Destroys the context, removing the DOM element and disposing all resources.

Returns

void

Inherited from

Context3D.destroy


disableInteraction()

disableInteraction(): void

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

Disables DOM interaction events and clears the active element set.

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(image, x, y, width?, height?): void

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

Draws an image onto the rendering surface at the given position and optional size.

Parameters

ParameterType
imageCanvasImageSource
xnumber
ynumber
width?number
height?number

Returns

void

Overrides

Context3D.drawImage


emit()

Call Signature

emit<TEvent>(event): TEvent

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

Emits an event, invoking all matching handlers and bubbling to the parent if applicable.

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:138

Emits an event, invoking all matching handlers and bubbling to the parent if applicable.

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:264

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

Returns

void

Inherited from

Context3D.enableInteraction


export()

export(): ContextExport

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

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:444

Returns

BaseState

Inherited from

Context3D.getDefaultState


getLightDirectionForRender()

getLightDirectionForRender(): Vector3

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

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

Returns

Vector3

Inherited from

Context3D.getLightDirectionForRender


has()

has(type): boolean

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

Returns whether there are any listeners registered for the given event type.

Parameters

ParameterType
typekeyof ContextEventMap

Returns

boolean

Inherited from

Context3D.has


hitTest()

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

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

Tests which rendered elements intersect the given point for the given event types, returning them sorted by zIndex (highest first).

Parameters

ParameterType
eventsstring[]
xnumber
ynumber

Returns

RenderElement[]

Inherited from

Context3D.hitTest


init()

protected init(): void

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

Returns

void

Inherited from

Context3D.init


invalidateTrackedElements()

invalidateTrackedElements(event?): void

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

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: 3d/src/core/context.ts:518

Tests whether a point is inside the filled region of a path.

Parameters

ParameterType
pathContextPath
xnumber
ynumber
fillRule?FillRule

Returns

boolean

Overrides

Context3D.isPointInPath


isPointInStroke()

isPointInStroke(path, x, y): boolean

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

Tests whether a point is on the stroked outline of a path.

Parameters

ParameterType
pathContextPath
xnumber
ynumber

Returns

boolean

Overrides

Context3D.isPointInStroke


layer()

layer<TResult>(body): TResult

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

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: 3d/src/core/context.ts:542

Signals the end of a render pass.

Returns

void

Overrides

Context3D.markRenderEnd


markRenderStart()

markRenderStart(): void

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

Signals the start of a render pass; resets the rendered-elements list at depth 0.

Returns

void

Overrides

Context3D.markRenderStart


measureText()

measureText(text, font?): TextMetrics

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

Measures text dimensions using the context's current font or an optional override.

Parameters

ParameterType
textstring
font?string

Returns

TextMetrics

Overrides

Context3D.measureText


off()

off<TEvent>(type, handler): void

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

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:99

Subscribes a handler to the given event type and returns a disposable for cleanup.

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:127

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:578

Closes the most recently opened group boundary, unwinding the state stack back to the depth captured at Context.pushGroup. 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:215

Projects a 3D world-space point to 2D screen coordinates.

Parameters

ParameterType
pointVector3

Returns

ProjectedPoint

Inherited from

Context3D.project


pushGroup()

pushGroup(group): void

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

Opens a group boundary: saves the current drawing state and applies the group's own transform, inherited paint, and opacity, 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


rescale()

protected rescale(width, height): void

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

Parameters

ParameterType
widthnumber
heightnumber

Returns

void

Overrides

Context3D.rescale


reset()

reset(): void

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

Resets the context to its initial state.

Returns

void

Overrides

Context3D.reset


restore()

restore(): void

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

Restores the most recently saved state from the stack.

Returns

void

Overrides

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: 3d/src/core/context.ts:472

Applies a rotation transformation.

Parameters

ParameterType
anglenumber

Returns

void

Overrides

Context3D.rotate


save()

save(): void

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

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

Overrides

Context3D.save


scale()

scale(x, y): void

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

Applies a scale transformation.

Parameters

ParameterType
xnumber
ynumber

Returns

void

Overrides

Context3D.scale


setCamera()

setCamera(eye, target, up): void

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

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:193

Sets an orthographic projection with explicit frustum bounds.

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:185

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

Parameters

ParameterType
fovnumber
nearnumber
farnumber

Returns

void

Inherited from

Context3D.setPerspective


setTransform()

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

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

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

Parameters

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

Returns

void

Overrides

Context3D.setTransform


submitMesh()

submitMesh(submission): void

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

Submits a mesh for rendering this frame. Noop in the base class; overridden by GPU-backed contexts.

Parameters

ParameterType
submissionMeshSubmission

Returns

void

Inherited from

Context3D.submitMesh


transform()

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

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

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

Overrides

Context3D.transform


translate()

translate(x, y): void

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

Applies a translation transformation.

Parameters

ParameterType
xnumber
ynumber

Returns

void

Overrides

Context3D.translate


updateProjectionMatrix()

protected updateProjectionMatrix(): void

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

Returns

void

Inherited from

Context3D.updateProjectionMatrix


updateViewProjectionMatrix()

protected updateViewProjectionMatrix(): void

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

Returns

void

Inherited from

Context3D.updateViewProjectionMatrix