Skip to main content

Class: ScenePlugin<ResultT, SceneT>

@geenee/armature.ScenePlugin

Generic scene plugin

ScenePlugins can be attached to SceneRenderer instances. Usually they control a scene node and implement simple tasks that can be separated from main rendering context. For example, make a scene node follow (be attached to) person's head, or make node an occluder, or create face mesh node and set texture as a mask. On load() plugin prepares or modifies the attached node if required and reference to the scene object is cached to be used in update() and unload(); update() implements main logic and updates the scene node according to provided results.

Type parameters

NameTypeDescription
ResultTextends Object = Type of processing results
SceneTundefinedType of renderer's scene

Hierarchy

  • Plugin<ResultT>

    ScenePlugin

Constructors

constructor

new ScenePlugin<ResultT, SceneT>()

Constructor

Type parameters

NameType
ResultTextends Object =
SceneTundefined

Overrides

Plugin.constructor

Properties

loaded

loaded: boolean = false

Loaded state

Inherited from

Plugin.loaded


ordinal

ordinal: number = PluginOrdinal.Render

Ordinal number

Inherited from

Plugin.ordinal


renderer

Protected Optional renderer: Renderer<ResultT>

Renderer loaded the plugin

Inherited from

Plugin.renderer


scene

Protected Optional scene: SceneT

Reference to a scene instance

Methods

dispose

dispose(): void

Dispose video plugin

Returns

void

Inherited from

Plugin.dispose


load

load(renderer): Promise<void>

Initialize plugin

Prepares or modifies the attached node if required. Reference to the scene object is cached and used by plugin on update() and unload(). You need to reload plugin if you want to change scene it's attached to.

Parameters

NameTypeDescription
rendererRenderer<ResultT>Renderer this plugin is attached to

Returns

Promise<void>

Promise resolving when initialization is finished

Overrides

Plugin.load


setupCamera

setupCamera(ratio, angle): void

Set camera parameters

Could be overridden to adjust plugin's pipeline.

Parameters

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

Returns

void

Inherited from

Plugin.setupCamera


setupVideo

setupVideo(size): void

Set video size

Could be overridden to adjust plugin's pipeline.

Parameters

NameTypeDescription
sizeSizeResolution of input video

Returns

void

Inherited from

Plugin.setupVideo


unload

unload(): void

Reset plugin

Releases all resources allocated in load(). Deletes cached reference to the scene object.

Returns

void

Overrides

Plugin.unload


update

update(result, stream): Promise<void>

Update

Main method implementing the logic of the plugin. Overridden by derived classes for particular task.

Parameters

NameTypeDescription
resultResultTResults of video processing
streamHTMLCanvasElementCaptured video frame

Returns

Promise<void>

Promise resolving when update is finished

Inherited from

Plugin.update