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 mask. ScenePlugin is very similar to Renderer and also should implement two basic methods load() and update(). It's a levels of abstraction allowing to single out ready-made helpers that can be reused as atomic building blocks in bigger application.
Type parameters
Name | Type | Description |
---|---|---|
ResultT | extends Object = {} | Type of processing results |
SceneT | undefined | Type of renderer's scene |
Constructors
constructor
• new ScenePlugin<ResultT
, SceneT
>()
Type parameters
Name | Type |
---|---|
ResultT | extends Object = {} |
SceneT | undefined |
Properties
loaded
• loaded: boolean
= false
Loaded state
scene
• Protected
Optional
scene: SceneT
Methods
dispose
▸ dispose(): void
Dispose render plugin
Returns
void
load
▸ load(scene?
): 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. Overridden by derived classes for particular task.
Parameters
Name | Type | Description |
---|---|---|
scene? | SceneT | Scene this plugin is attached to |
Returns
Promise
<void
>
Promise resolving when initialization is finished
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 the scene node
Main method implementing the logic of the plugin. Updates the node according to provided results. 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