Class: RenderingSurface
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:36
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
Constructor
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.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:81
Creates a new rendering surface.
Parameters
| Parameter | Type | Description |
|---|---|---|
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
Properties
| Property | Modifier | Type | Default value | Description | Inherited from |
|---|---|---|---|---|---|
viewports | readonly | Viewport[] | [] | List of viewports bound to the current surface. | RenderingSurfaceBase.viewports |
relative_rect | public | RelativeRect | undefined | Normalized dimensions and offset of the surface relative to the remote rendering surface. | RenderingSurfaceBase.relative_rect |
_scale | protected | number | 1.0 | Scale of the surface. | RenderingSurfaceBase._scale |
Accessors
width
Get Signature
get width(): number;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:55
Width of the surface.
Returns
number
Overrides
height
Get Signature
get height(): number;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:62
Height of the surface.
Returns
number
Overrides
canvas
Get Signature
get canvas(): HTMLCanvasElement;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:69
HTML canvas on which the final frame is displayed.
Returns
HTMLCanvasElement
scale
Get Signature
get scale(): number;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:49
Scale of the surface.
Returns
number
Set Signature
set scale(scale: number): void;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:56
Set scale of the surface.
Parameters
| Parameter | Type |
|---|---|
scale | number |
Returns
void
Inherited from
dimensions
Get Signature
get dimensions(): Vec2;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:71
Dimensions of the surface.
Returns
Inherited from
RenderingSurfaceBase.dimensions
Methods
release()
release(): void;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:129
Releases the resources associated with the surface.
Returns
void
Overrides
getContext()
getContext<ContextType>(): ContextType;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:139
Returns the context of the surface.
Type Parameters
| Type Parameter |
|---|
ContextType extends ContextProvider |
Returns
ContextType
getBoundingRect()
getBoundingRect(): Rect;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurface.ts:146
Returns the bounding rectangle of the surface.
Returns
Overrides
RenderingSurfaceBase.getBoundingRect
isValid()
isValid(): boolean;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:104
Returns whether the current surface is valid.
Returns
boolean
Inherited from
drawFrame()
drawFrame(params: {
decoded_frame: DecodedFrame;
}): void;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:115
Draws the portions of the frame associated with the viewports to the backing element. Keeps a reference to the last frame drawn.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { decoded_frame: DecodedFrame; } | - |
params.decoded_frame | DecodedFrame | The frame to draw. |
Returns
void
Inherited from
RenderingSurfaceBase.drawFrame
redrawLastFrame()
redrawLastFrame(): void;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:123
Redraws the last frame.
Returns
void
Inherited from
RenderingSurfaceBase.redrawLastFrame
reset()
reset(): void;
Defined in: livelink.clients/livelink.js/sources/rendering/surfaces/RenderingSurfaceBase.ts:132
Resets the surface states.
Returns
void
Inherited from
addEventListener()
addEventListener<_EventName>(
event_name: _EventName,
listener: (event: RenderingSurfaceEvents[_EventName]) => void,
options?: boolean | AddEventListenerOptions): void;
Defined in: livelink.clients/livelink.base/sources/TypedEventTarget.ts:10
Type Parameters
| Type Parameter |
|---|
_EventName extends "on-rendering-surface-resized" |
Parameters
| Parameter | Type |
|---|---|
event_name | _EventName |
listener | (event: RenderingSurfaceEvents[_EventName]) => void |
options? | boolean | AddEventListenerOptions |
Returns
void
Inherited from
RenderingSurfaceBase.addEventListener
removeEventListener()
removeEventListener<_EventName>(
event_name: _EventName,
listener: (event: RenderingSurfaceEvents[_EventName]) => void,
options?: boolean | EventListenerOptions): void;
Defined in: livelink.clients/livelink.base/sources/TypedEventTarget.ts:21
Type Parameters
| Type Parameter |
|---|
_EventName extends "on-rendering-surface-resized" |
Parameters
| Parameter | Type |
|---|---|
event_name | _EventName |
listener | (event: RenderingSurfaceEvents[_EventName]) => void |
options? | boolean | EventListenerOptions |
Returns
void