Skip to main content

RenderingSurfaceBase

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:25

Abstract class for rendering surfaces.

A rendering surface represents the final destination of the rendered frame.

It is usually backed by an HTML Canvas or an OffscreenCanvas.

It can be split into multiple viewports, each with its own camera and render target. The rendering surface if responsible for holding the viewports and their configurations.

It is finally responsible for drawing the portions of the final frame to its backing element.

Extends

Extended by

Properties

PropertyModifierTypeDefault valueDescription
viewportsreadonlyViewport[][]List of viewports bound to the current surface.
offsetpublicVec2undefinedOffset of the surface relative to the remote rendering surface.

Accessors

width

Get Signature

get abstract width(): number

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:44

Width of the surface.

Returns

number


height

Get Signature

get abstract height(): number

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:49

Height of the surface.

Returns

number

Methods

getBoundingRect()

abstract getBoundingRect(): Rect

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:54

Returns the bounding rectangle of the surface.

Returns

Rect


drawFrame()

drawFrame(params: {
frame: OffscreenCanvas | VideoFrame;
meta_data: FrameMetaData;
}): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:64

Draws the portions of the frame associated with the viewports to the backing element. Keeps a reference to the last frame drawn.

Parameters

ParameterTypeDescription
params{ frame: OffscreenCanvas | VideoFrame; meta_data: FrameMetaData; }
params.frameOffscreenCanvas | VideoFrameThe frame to draw.
params.meta_dataFrameMetaDataThe metadata associated with the frame.

Returns

void


redrawLastFrame()

redrawLastFrame(): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:72

Redraws the last frame.

Returns

void


addViewport()

addViewport(params: {
viewport: Viewport;
}): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:98

Adds a viewport to the current surface.

Note that the viewport knows which section of the surface it should draw to using its Viewport.relative_rect property.

Parameters

ParameterTypeDescription
params{ viewport: Viewport; }
params.viewportViewportThe viewport to add.

Returns

void


removeViewport()

removeViewport(params: {
viewport: Viewport;
}): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:108

Removes a viewport from the current surface.

Parameters

ParameterTypeDescription
params{ viewport: Viewport; }
params.viewportViewportThe viewport to remove.

Returns

void


release()

release(): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:118

Releases the resources associated with the current surface.

Returns

void


isValid()

isValid(): boolean

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:128

Returns whether the current surface is valid.

Returns

boolean