Skip to main content

RenderingSurface

@3dverse/livelink v0.8.10


@3dverse/livelink / RenderingSurface

Class: RenderingSurface

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

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): RenderingSurface

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

Creates a new rendering surface.

Parameters

params

object & { context_type: "2d"; context_attributes: CanvasRenderingContext2DSettings; } | { context_type: "webgl" | "webgl2"; context_attributes: WebGLContextAttributes & object; }

Returns

RenderingSurface

Overrides

RenderingSurfaceBase.constructor

Properties

viewports

readonly viewports: Viewport[] = []

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

List of viewports bound to the current surface.

Inherited from

RenderingSurfaceBase.viewports


offset

offset: Vec2

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

Offset of the surface relative to the remote rendering surface.

Inherited from

RenderingSurfaceBase.offset

Accessors

width

Get Signature

get width(): number

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

Width of the surface.

Returns

number

Overrides

RenderingSurfaceBase.width


height

Get Signature

get height(): number

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

Height of the surface.

Returns

number

Overrides

RenderingSurfaceBase.height


dimensions

Get Signature

get dimensions(): Vec2

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

Dimensions of the surface.

Returns

Vec2


canvas

Get Signature

get canvas(): HTMLCanvasElement

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

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

Returns the context of the surface.

Type Parameters

ContextType extends ContextProvider

Returns

ContextType


getBoundingRect()

getBoundingRect(): Rect

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

Returns the bounding rectangle of the surface.

Returns

Rect

Overrides

RenderingSurfaceBase.getBoundingRect


drawFrame()

drawFrame(params): void

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

Draws a frame to the surface.

Parameters

params
frame

OffscreenCanvas | VideoFrame

The frame to draw.

meta_data

FrameMetaData

The metadata associated with the frame.

Returns

void

Overrides

RenderingSurfaceBase.drawFrame


addViewport()

addViewport(params): void

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

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

params
viewport

Viewport

The viewport to add.

Returns

void

Inherited from

RenderingSurfaceBase.addViewport


removeViewport()

removeViewport(params): void

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

Removes a viewport from the current surface.

Parameters

params
viewport

Viewport

The viewport to remove.

Returns

void

Inherited from

RenderingSurfaceBase.removeViewport


isValid()

isValid(): boolean

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

Returns whether the current surface is valid.

Returns

boolean

Inherited from

RenderingSurfaceBase.isValid


addEventListener()

addEventListener(type, callback, options?): void

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8303

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

MDN Reference

Parameters

type

string

callback

null | EventListenerOrEventListenerObject

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

RenderingSurfaceBase.addEventListener


dispatchEvent()

dispatchEvent(event): boolean

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8309

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

MDN Reference

Parameters

event

Event

Returns

boolean

Inherited from

RenderingSurfaceBase.dispatchEvent


removeEventListener()

removeEventListener(type, callback, options?): void

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8315

Removes the event listener in target's event listener list with the same type, callback, and options.

MDN Reference

Parameters

type

string

callback

null | EventListenerOrEventListenerObject

options?

boolean | EventListenerOptions

Returns

void

Inherited from

RenderingSurfaceBase.removeEventListener