Skip to main content

Class: PoseRenderer

@geenee/bodyrenderers-babylon.PoseRenderer

Abstract renderer for @geenee/bodyprocessors!PoseProcessor

Specializes BabylonUniRenderer generic for @geenee/bodyprocessors!PoseResult.This is abstract renderer that doesn't implement any logic.

Hierarchy

Constructors

constructor

new PoseRenderer(container, mode?, mirror?)

Constructor

Parameters

NameTypeDescription
containerHTMLElementContainer of @geenee/armature!ResponsiveCanvas
mode?CanvasModeFitting mode
mirror?booleanMirror the output

Inherited from

BabylonUniRenderer.constructor

Properties

camera

Protected camera: UniversalCamera

Camera instance

Inherited from

BabylonUniRenderer.camera


cameraAngle

Protected cameraAngle: number

Camera vertical angle in radians

Inherited from

BabylonUniRenderer.cameraAngle


cameraRatio

Protected cameraRatio: number

Camera aspect ratio

Inherited from

BabylonUniRenderer.cameraRatio


canvas

canvas: ResponsiveCanvas

Responsive canvas

Inherited from

BabylonUniRenderer.canvas


current

current: null | WebGLTexture

Current image texture

Inherited from

BabylonUniRenderer.current


input

Optional input: ImageTexture

Input image texture

Inherited from

BabylonUniRenderer.input


layer

Protected layer: Layer

Video layer

Inherited from

BabylonUniRenderer.layer


loaded

Protected loaded: boolean

Loaded state

Inherited from

BabylonUniRenderer.loaded


padCtx

Protected padCtx: [null | CanvasRenderingContext2D, null | CanvasRenderingContext2D]

Drawing context of padding canvases

Inherited from

BabylonUniRenderer.padCtx


plugins

Protected plugins: Plugin<PoseResult>[]

Attached plugins

Inherited from

BabylonUniRenderer.plugins


renderer

Protected renderer: Engine

Rendering engine

Inherited from

BabylonUniRenderer.renderer


scene

Optional scene: Scene

Renderer scene

Inherited from

BabylonUniRenderer.scene


setupPadding

Protected setupPadding: () => void

Type declaration

▸ (): void

Setup padding canvases

Callback sets up size of padding canvases.

Returns

void

Inherited from

BabylonUniRenderer.setupPadding


shader

Protected Optional shader: ShaderProgram

Rendering shader

Inherited from

BabylonUniRenderer.shader


shaderCtx

shaderCtx: null | WebGL2RenderingContext

Context of the video canvas layer

Inherited from

BabylonUniRenderer.shaderCtx


videoRatio

Protected videoRatio: number

Aspect ratio of input video

Inherited from

BabylonUniRenderer.videoRatio


videoSize

Protected videoSize: Size

Resolution of input video

Inherited from

BabylonUniRenderer.videoSize

Methods

addListener

addListener<E>(event, listener): PoseRenderer

Adds the listener function to the end of the listeners array

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.addListener


addPlugin

addPlugin(plugin): Promise<void>

Add render plugin

Initializes the plugin if it's not loaded yet but renderer is ready. Renderer takes ownership of the plugin instance meaning it will release it when plugin is detached or renderer is disposed itself.

Parameters

NameType
pluginPlugin<PoseResult>

Returns

Promise<void>

Inherited from

BabylonUniRenderer.addPlugin


dispose

dispose(): void

Dispose renderer object

Extended to dispose scene and engine.

Returns

void

Inherited from

BabylonUniRenderer.dispose


emit

emit<E>(event, ...args): boolean

Synchronously calls each of the listeners registered for the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
...argsArgs<RendererEvents[E]>Arguments passed to the listeners

Returns

boolean

True if the event had listeners, False otherwise

Inherited from

BabylonUniRenderer.emit


eventNames

eventNames(): (string | symbol)[]

List of emitter's events

Returns

(string | symbol)[]

List of emitter's events

Inherited from

BabylonUniRenderer.eventNames


getMaxListeners

getMaxListeners(): number

Maximum number of listeners per event

Returns

number

Maximum number of listeners per event

Inherited from

BabylonUniRenderer.getMaxListeners


listenerCount

listenerCount<E>(event): number

The number of listeners listening to the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

number

Number of listeners

Inherited from

BabylonUniRenderer.listenerCount


listeners

listeners<E>(event): Function[]

Copy of the array of listeners for the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

BabylonUniRenderer.listeners


load

load(): Promise<void>

Initialize renderer

Initializes rendering context, shader program and buffers.

Returns

Promise<void>

Promise resolving when initialization is finished

Inherited from

BabylonUniRenderer.load


off

off<E>(event, listener): PoseRenderer

Removes the listener from the listener array for the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.off


on

on<E>(event, listener): PoseRenderer

Adds the listener function to the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.on


once

once<E>(event, listener): PoseRenderer

Adds a one-time listener function for the event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.once


prependListener

prependListener<E>(event, listener): PoseRenderer

Adds the listener function to the beginning of the listeners array

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.prependListener


prependOnceListener

prependOnceListener<E>(event, listener): PoseRenderer

Adds a one-time listener function to the beginning of the listeners array

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

Inherited from

BabylonUniRenderer.prependOnceListener


rawListeners

rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

BabylonUniRenderer.rawListeners


removeAllListeners

removeAllListeners<E>(event?): PoseRenderer

Removes all listeners, or those of the specified event

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
event?EThe name of the event

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.removeAllListeners


removeAllPlugins

removeAllPlugins(): void

Remove all render plugins

Renderer will dispose all plugins before detaching them.

Returns

void

Inherited from

BabylonUniRenderer.removeAllPlugins


removeListener

removeListener<E>(event, listener): PoseRenderer

Removes the specified listener from the listener array

Type parameters

NameType
Eextends keyof RendererEvents

Parameters

NameTypeDescription
eventEThe name of the event
listenerRendererEvents[E]The callback function

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.removeListener


removePlugin

removePlugin(plugin): void

Remove render plugin

Renderer will dispose the plugin before detaching it.

Parameters

NameType
pluginPlugin<PoseResult>

Returns

void

Inherited from

BabylonUniRenderer.removePlugin


setMaxListeners

setMaxListeners(n): PoseRenderer

Sets maximum number of listeners per event

Parameters

NameTypeDescription
nnumberMaximum number of listeners

Returns

PoseRenderer

This EventEmitter

Inherited from

BabylonUniRenderer.setMaxListeners


setMirror

setMirror(mirror): void

Set mirror mode

CanvasRenderer sets mirror mode of ResponsiveCanvas.

Parameters

NameTypeDescription
mirrorbooleanMirror the output

Returns

void

Inherited from

BabylonUniRenderer.setMirror


setMode

setMode(mode): void

Set fitting mode

CanvasRenderer sets fitting mode of ResponsiveCanvas.

Parameters

NameTypeDescription
modeCanvasModeFitting mode

Returns

void

Inherited from

BabylonUniRenderer.setMode


setupCamera

setupCamera(ratio, angle): void

Set camera parameters

Setups BabylonRenderer#camera instance according to parameters provided by @geenee/armature!Processor.

Parameters

NameTypeDescription
rationumberAspect ration of input video
anglenumberVertical field of view in radians

Returns

void

Inherited from

BabylonUniRenderer.setupCamera


setupVideo

setupVideo(size, ratio?): void

Set video parameters

Resizes video texture and rendering shader.

Parameters

NameTypeDescription
sizeSizeResolution of input video
ratio?numberAspect ration of input video

Returns

void

Inherited from

BabylonUniRenderer.setupVideo


unload

unload(): void

Reset renderer

Releases all resources and instances created in load(). Releases rendering context, shader program and buffers.

Returns

void

Inherited from

BabylonUniRenderer.unload


update

update(result, stream): Promise<void>

Update the scene

Renderers input video frame on corresponding canvas layer.

Parameters

NameTypeDescription
resultPoseResultResults of video processing
streamHTMLCanvasElementCaptured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

BabylonUniRenderer.update


updatePads

Protected updatePads(stream): void

Update padding canvases

Updates padding canvases using portions of video frame.

Parameters

NameTypeDescription
streamHTMLCanvasElementCaptured video frame

Returns

void

Inherited from

BabylonUniRenderer.updatePads


updatePlugins

Protected updatePlugins(result, stream): Promise<void>

Update attached plugins

Calls update() of all attached plugins.

Parameters

NameTypeDescription
resultPoseResultResults of video processing
streamHTMLCanvasElementCaptured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

BabylonUniRenderer.updatePlugins


updateScene

Protected updateScene(): void

Update and render the scene

Virtual method updating and rendering 3D scene. For babylon.js engine calls this.scene.render().

Returns

void

Inherited from

BabylonUniRenderer.updateScene


updateVideo

Protected updateVideo(stream): void

Update the video layer

Renders processed frame to texture of video layer.

Parameters

NameTypeDescription
streamHTMLCanvasElementCaptured video frame

Returns

void

Inherited from

BabylonUniRenderer.updateVideo