Class: Plugin<ResultT>
@geenee/armature.Plugin
Generic renderer plugin
Plugin can be attached to an instances of Renderer. Usually they perform simple tasks that can be separated from bigger app context into atomic building blocks, for example control object on a scene to follow (be attached to) user's head, apply image effect (smoothing, beautification), recognize gestures or poses, notify about state changes or perform other kinds of transformations, pre/post-processing, or analyzes with a 3D scene, video stream or raw data from a Processor. Plugin is a abstraction level to single out ready-made helpers that can be reused as atomic building blocks of an application. Plugins are very similar to Renderer and also should implement two basic methods load() and update(). Renderer initializes a plugin calling load() and providing itself as argument, plugin in turn remembers renderer it's attached to and gets access to required resources of the renderer, for example 2d or webgl context of a canvas or reference to a 3d scene. In update() method plugins implement actual logic given processing results.
Type parameters
Name | Type | Description |
---|---|---|
ResultT | extends Object = {} | Type of processing results |
Hierarchy
Plugin
Constructors
constructor
• new Plugin<ResultT
>()
Type parameters
Name | Type |
---|---|
ResultT | extends Object = {} |
Properties
loaded
• loaded: boolean
= false
Loaded state
renderer
• Protected
Optional
renderer: Renderer
<ResultT
>
Renderer loaded the plugin
Methods
dispose
▸ dispose(): void
Dispose video plugin
Returns
void
load
▸ load(renderer
): Promise
<void
>
Initialize plugin
Initializes resources/instances needed by plugin. Overridden by derived classes for particular task.
Parameters
Name | Type | Description |
---|---|---|
renderer | Renderer <ResultT > | Renderer this plugin is attached to |
Returns
Promise
<void
>
Promise resolving when initialization is finished
setupVideo
▸ setupVideo(size
): void
Set video size
Could be overridden to adjust plugin's pipeline.
Parameters
Name | Type | Description |
---|---|---|
size | Size | Resolution of input video |
Returns
void
unload
▸ unload(): void
Reset plugin
Releases all resources/instances created in load(). Overridden by derived classes for particular task.
Returns
void
update
▸ update(result
, stream
): Promise
<void
>
Update
Main method implementing the logic of the plugin. Overridden by derived classes for particular task.
Parameters
Name | Type | Description |
---|---|---|
result | ResultT | Results of video processing |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished