Skip to main content

RenderingSurface

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:33

A rendering surface backed by an HTML canvas.

The context can be specified as either 2D, WebGL or WebGL2 along with its attributes.

The canvas is automatically resized to match the size of the HTML element it is attached to.

Extends

Constructors

new RenderingSurface()

new RenderingSurface(params: {
canvas_element: string | HTMLCanvasElement;
} &
| {
context_type: "2d";
context_attributes: CanvasRenderingContext2DSettings;
}
| {
context_type: "webgl" | "webgl2";
context_attributes: WebGLContextAttributes & {
xrCompatible: boolean;
};
}): RenderingSurface

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:85

Creates a new rendering surface.

Parameters

ParameterTypeDescription
params{ canvas_element: string | HTMLCanvasElement; } & | { context_type: "2d"; context_attributes: CanvasRenderingContext2DSettings; } | { context_type: "webgl" | "webgl2"; context_attributes: WebGLContextAttributes & { xrCompatible: boolean; }; }

Returns

RenderingSurface

Overrides

RenderingSurfaceBase.constructor;

Accessors

width

Get Signature

get width(): number

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:52

Width of the surface.

Returns

number

Overrides

RenderingSurfaceBase.width


height

Get Signature

get height(): number

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:59

Height of the surface.

Returns

number

Overrides

RenderingSurfaceBase.height


dimensions

Get Signature

get dimensions(): Vec2

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:66

Dimensions of the surface.

Returns

Vec2


canvas

Get Signature

get canvas(): HTMLCanvasElement

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:73

HTML canvas on which the final frame is displayed.

Returns

HTMLCanvasElement

Methods

release()

release(): void

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:130

Releases the resources associated with the surface.

Returns

void

Overrides

RenderingSurfaceBase.release


getContext()

getContext<ContextType>(): ContextType

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:140

Returns the context of the surface.

Type Parameters

Type Parameter
ContextType extends ContextProvider

Returns

ContextType


getBoundingRect()

getBoundingRect(): Rect

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:147

Returns the bounding rectangle of the surface.

Returns

Rect

Overrides

RenderingSurfaceBase.getBoundingRect


_drawFrame()

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

Defined in: livelink.js/sources/rendering/surfaces/RenderingSurface.ts:169

Draws a frame to the surface.

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

Overrides

RenderingSurfaceBase._drawFrame;