Skip to content

Class: RenderRoot ​

Experimental

Implements ​

Constructors ​

Constructor ​

ts
new RenderRoot(container, options?): RenderRoot;

Experimental

Parameters ​

ParameterType
containerHTMLElement
optionsRenderRootOptions

Returns ​

RenderRoot

Properties ​

PropertyModifierTypeDescription
canvasreadonlyHTMLCanvasElementExperimental The figure's canvas in the page. Under a shared renderer this is not renderer.domElement.
containerreadonlyHTMLElementExperimental
contextreadonlyPrimitiveContextExperimental Context handed to primitives.
loopreadonlyRenderLoopExperimental
overlayreadonlyViewport | nullExperimental Figure-level overlay (paper-space components), drawn after every other viewport.
rendererreadonlyWebGLRendererExperimental
resourcesreadonlyResourceManagerExperimental
sharedreadonlybooleanExperimental Whether the renderer (and its WebGL context) is shared with other roots.

Accessors ​

canvasHeight ​

Get Signature ​

ts
get canvasHeight(): number;

Experimental

Returns ​

number

Experimental

Implementation of ​

ViewportHost.canvasHeight


canvasWidth ​

Get Signature ​

ts
get canvasWidth(): number;

Experimental

Returns ​

number

Experimental

Implementation of ​

ViewportHost.canvasWidth


capabilities ​

Get Signature ​

ts
get capabilities(): GpuCapabilities;

Experimental

The device's GPU limits: read when the root is created, updated after a context restore.

Returns ​

GpuCapabilities


contextLost ​

Get Signature ​

ts
get contextLost(): boolean;

Experimental

Returns ​

boolean


destroyed ​

Get Signature ​

ts
get destroyed(): boolean;

Experimental

Returns ​

boolean


pixelRatio ​

Get Signature ​

ts
get pixelRatio(): number;

Experimental

Returns ​

number

Experimental

Implementation of ​

ViewportHost.pixelRatio


size ​

Get Signature ​

ts
get size(): Readonly<ViewportSize>;

Experimental

Canvas CSS size and pixel ratio (read-only, updated in place).

Returns ​

Readonly<ViewportSize>


viewports ​

Get Signature ​

ts
get viewports(): readonly Viewport[];

Experimental

Returns ​

readonly Viewport[]

Methods ​

activate() ​

ts
activate(): void;

Experimental

Point a shared renderer at this root (its pixel ratio) before drawing outside the frame, e.g. into a render target. Does nothing on a root with its own context.

Returns ​

void


addViewport() ​

ts
addViewport(options?): Viewport;

Experimental

Parameters ​

ParameterType
optionsViewportOptions

Returns ​

Viewport


destroy() ​

ts
destroy(): void;

Experimental

Dispose every viewport, primitive, GPU resource, listener, and the context itself.

Returns ​

void


flush() ​

ts
flush(): void;

Experimental

Render synchronously if a frame is pending.

Returns ​

void


invalidate() ​

ts
invalidate(): void;

Experimental

Schedule a frame (coalesced).

Returns ​

void

Implementation of ​

ViewportHost.invalidate


on() ​

ts
on<K>(type, listener): () => void;

Experimental

Type Parameters ​

Type Parameter
K extends keyof RenderRootEvents

Parameters ​

ParameterType
typeK
listener(payload) => void

Returns ​

() => void


removeViewport() ​

ts
removeViewport(viewport, options?): void;

Experimental

Remove a viewport. By default its primitives and scene contents are disposed.

Parameters ​

ParameterType
viewportViewport
options{ dispose?: boolean; }
options.dispose?boolean

Returns ​

void


renderNow() ​

ts
renderNow(): void;

Experimental

Render synchronously now, regardless of the dirty flag (e.g. for image export).

Returns ​

void


requestAnimation() ​

ts
requestAnimation(): () => void;

Experimental

Enter continuous rendering until the returned function is called (ref-counted).

Returns ​

() => void


resize() ​

ts
resize(width, height): void;

Experimental

Resize the canvas (CSS px). Called automatically when responsive.

Parameters ​

ParameterType
widthnumber
heightnumber

Returns ​

void


setBackground() ​

ts
setBackground(background): void;

Experimental

Parameters ​

ParameterType
backgroundRGBA | null

Returns ​

void


setPixelRatio() ​

ts
setPixelRatio(pixelRatio): void;

Experimental

Override the pixel ratio (disables automatic DPR tracking only if passed at construction).

Parameters ​

ParameterType
pixelRationumber

Returns ​

void


viewportAt() ​

ts
viewportAt(px, py): Viewport | null;

Experimental

Topmost visible viewport under a container-space point (for hover routing).

Parameters ​

ParameterType
pxnumber
pynumber

Returns ​

Viewport | null

Released under the MIT License.