Skip to content

FaceRenderer

Abstract renderer for @geenee/bodyprocessors!FaceProcessor

Specializes the ThreeRenderer generic for @geenee/bodyprocessors!FaceResult. This is abstract renderer that doesn’t implement any logic.

Extends

Constructors

new FaceRenderer()

new FaceRenderer(container, mode?, mirror?): FaceRenderer

Constructor

Parameters

container: HTMLElement

Container of @geenee/armature!ResponsiveCanvas

mode?: CanvasMode

Fitting mode

mirror?: boolean

Mirror the output

Returns

FaceRenderer

Inherited from

ThreeRenderer.constructor

Properties

camera

protected camera: Camera

Camera instance

Inherited from

ThreeRenderer.camera


cameraAngle

protected cameraAngle: number

Camera vertical angle in radians

Inherited from

ThreeRenderer.cameraAngle


cameraRatio

protected cameraRatio: number

Camera aspect ratio

Inherited from

ThreeRenderer.cameraRatio


canvas

canvas: ResponsiveCanvas

Responsive canvas

Inherited from

ThreeRenderer.canvas


current

current: null | WebGLTexture

Current image texture

Inherited from

ThreeRenderer.current


input?

optional input: ImageTexture

Input image texture

Inherited from

ThreeRenderer.input


loaded

protected loaded: boolean

Loaded state

Inherited from

ThreeRenderer.loaded


padCtx

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

Drawing context of padding canvases

Inherited from

ThreeRenderer.padCtx


plugins

protected plugins: Plugin<FaceResult>[]

Attached plugins

Inherited from

ThreeRenderer.plugins


renderer

protected renderer: WebGLRenderer

Rendering engine

Inherited from

ThreeRenderer.renderer


scene?

optional scene: Scene

Renderer scene

Inherited from

ThreeRenderer.scene


setupPadding()

protected setupPadding: () => void

Setup padding canvases

Callback sets up size of padding canvases.

Returns

void

Inherited from

ThreeRenderer.setupPadding


shader?

protected optional shader: ShaderProgram

Rendering shader

Inherited from

ThreeRenderer.shader


shaderCtx

shaderCtx: null | WebGL2RenderingContext

Context of the video canvas layer

Inherited from

ThreeRenderer.shaderCtx


videoRatio

protected videoRatio: number

Aspect ratio of input video

Inherited from

ThreeRenderer.videoRatio


videoSize

protected videoSize: Size

Resolution of input video

Inherited from

ThreeRenderer.videoSize

Methods

addListener()

addListener<E>(event, listener): this

Adds the listener function to the end of the listeners array

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.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

plugin: Plugin<FaceResult>

Returns

Promise<void>

Inherited from

ThreeRenderer.addPlugin


dispose()

dispose(): void

Dispose renderer object

Extended to dispose scene object.

Returns

void

Inherited from

ThreeRenderer.dispose


disposeObject()

protected disposeObject(object): void

Dispose object

Helper method to remove object from the scene and recursively dispose it with all its children and allocated resources like materials and textures.

Parameters

object: Object3D<Object3DEventMap>

Object to dispose

Returns

void

Inherited from

ThreeRenderer.disposeObject


emit()

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

Synchronously calls each of the listeners registered for the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

• …args: Args<RendererEvents[E]>

Arguments passed to the listeners

Returns

boolean

True if the event had listeners, False otherwise

Inherited from

ThreeRenderer.emit


eventNames()

eventNames(): (string | symbol)[]

List of emitter’s events

Returns

(string | symbol)[]

List of emitter’s events

Inherited from

ThreeRenderer.eventNames


getMaxListeners()

getMaxListeners(): number

Maximum number of listeners per event

Returns

number

Maximum number of listeners per event

Inherited from

ThreeRenderer.getMaxListeners


listenerCount()

listenerCount<E>(event): number

The number of listeners listening to the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

Returns

number

Number of listeners

Inherited from

ThreeRenderer.listenerCount


listeners()

listeners<E>(event): Function[]

Copy of the array of listeners for the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

ThreeRenderer.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

ThreeRenderer.load


off()

off<E>(event, listener): this

Removes the listener from the listener array for the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.off


on()

on<E>(event, listener): this

Adds the listener function to the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.on


once()

once<E>(event, listener): this

Adds a one-time listener function for the event

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.once


prependListener()

prependListener<E>(event, listener): this

Adds the listener function to the beginning of the listeners array

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.prependListener


prependOnceListener()

prependOnceListener<E>(event, listener): this

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

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

Inherited from

ThreeRenderer.prependOnceListener


rawListeners()

rawListeners<E>(event): Function[]

Copy of the array of listeners for the event including wrappers

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

Returns

Function[]

Copy of the listeners array

Inherited from

ThreeRenderer.rawListeners


removeAllListeners()

removeAllListeners<E>(event?): this

Removes all listeners, or those of the specified event

Type Parameters

E extends keyof RendererEvents

Parameters

event?: E

The name of the event

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.removeAllListeners


removeAllPlugins()

removeAllPlugins(): void

Remove all render plugins

Renderer will dispose all plugins before detaching them.

Returns

void

Inherited from

ThreeRenderer.removeAllPlugins


removeListener()

removeListener<E>(event, listener): this

Removes the specified listener from the listener array

Type Parameters

E extends keyof RendererEvents

Parameters

event: E

The name of the event

listener: RendererEvents[E]

The callback function

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.removeListener


removePlugin()

removePlugin(plugin): void

Remove render plugin

Renderer will dispose the plugin before detaching it.

Parameters

plugin: Plugin<FaceResult>

Returns

void

Inherited from

ThreeRenderer.removePlugin


setMaxListeners()

setMaxListeners(n): this

Sets maximum number of listeners per event

Parameters

n: number

Maximum number of listeners

Returns

this

This EventEmitter

Inherited from

ThreeRenderer.setMaxListeners


setMirror()

setMirror(mirror): void

Set mirror mode

CanvasRenderer sets mirror mode of ResponsiveCanvas.

Parameters

mirror: boolean

Mirror the output

Returns

void

Inherited from

ThreeRenderer.setMirror


setMode()

setMode(mode): void

Set fitting mode

CanvasRenderer sets fitting mode of ResponsiveCanvas.

Parameters

mode: CanvasMode

Fitting mode

Returns

void

Inherited from

ThreeRenderer.setMode


setupCamera()

setupCamera(ratio, angle): void

Set camera parameters

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

Parameters

ratio: number

Aspect ration of input video

angle: number

Vertical field of view in radians

Returns

void

Inherited from

ThreeRenderer.setupCamera


setupVideo()

setupVideo(size, ratio?): void

Set camera parameters

If ThreeRenderer#camera is OrthographicCamera sets orthographic projection according to resolution of video.

Parameters

size: Size

Resolution of input video

ratio?: number

Aspect ration of input video

Returns

void

Inherited from

ThreeRenderer.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

ThreeRenderer.unload


update()

update(result, stream): Promise<void>

Update the scene

Renderers input video frame on corresponding canvas layer.

Parameters

result: FaceResult

Results of video processing

stream: HTMLCanvasElement

Captured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

ThreeRenderer.update


updatePads()

protected updatePads(stream): void

Update padding canvases

Updates padding canvases using portions of video frame.

Parameters

stream: HTMLCanvasElement

Captured video frame

Returns

void

Inherited from

ThreeRenderer.updatePads


updatePlugins()

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

Update attached plugins

Calls update() of all attached plugins.

Parameters

result: FaceResult

Results of video processing

stream: HTMLCanvasElement

Captured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

ThreeRenderer.updatePlugins


updateScene()

protected updateScene(): void

Update and render the scene

Virtual method updating and rendering 3D scene. Basic implementation for three.js engine calls this.renderer.render(this.scene, this.camera).

Returns

void

Inherited from

ThreeRenderer.updateScene


updateVideo()

protected updateVideo(stream): void

Update the video layer

Calls rendering shaders with current input texture.

Parameters

stream: HTMLCanvasElement

Captured video frame

Returns

void

Inherited from

ThreeRenderer.updateVideo