Class: Renderer<ResultT>
@geenee/armature.Renderer
Core generic renderer
Renderer is the core visualization part of any application. It's attached to Engine. Results of processing and captured frame are provided to renderer that updates scene, visualization and application logic according to this data. Basically, renders define two methods load() and update(). The first one is used to initialize all assets and prepare the scene e.g. set up lightning, environment map. Engine will call load() method during pipeline initialization. The second one is used to update the scene using results of video processing. This's where all the logic happens. By overriding/extending () and () you can add any custom logic, interactions, animations, post-processing effects, gesture recognition, physics, etc. to an app. Renderer is a generic abstract class defining common core interfaces.
Type parameters
Name | Description |
---|---|
ResultT | Type of processing results |
Hierarchy
-
EventEmitterT
<RendererEvents
>↳
Renderer
Constructors
constructor
• new Renderer<ResultT
>()
Constructor
Type parameters
Name |
---|
ResultT |
Overrides
Properties
cameraAngle
• Protected
cameraAngle: number
Camera vertical angle in radians
cameraRatio
• Protected
cameraRatio: number
Camera aspect ratio
loaded
• Protected
loaded: boolean
= false
Loaded state
videoRatio
• Protected
videoRatio: number
Aspect ratio of input video
videoSize
• Protected
videoSize: Size
Resolution of input video
Methods
addListener
▸ addListener<E
>(event
, listener
): Renderer
<ResultT
>
Adds the listener function to the end of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
dispose
▸ dispose(): void
Dispose renderer object
Returns
void
emit
▸ emit<E
>(event
, ...args
): boolean
Synchronously calls each of the listeners registered for the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
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
eventNames
▸ eventNames(): (string
| symbol
)[]
List of emitter's events
Returns
(string
| symbol
)[]
List of emitter's events
Inherited from
getMaxListeners
▸ getMaxListeners(): number
Maximum number of listeners per event
Returns
number
Maximum number of listeners per event
Inherited from
listenerCount
▸ listenerCount<E
>(event
): number
The number of listeners listening to the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
number
Number of listeners
Inherited from
listeners
▸ listeners<E
>(event
): Function
[]
Copy of the array of listeners for the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
load
▸ load(): Promise
<void
>
Initialize renderer
Initializes renderer, all required assets, and the scene. Overridden by derived classes for particular application.
Returns
Promise
<void
>
Promise resolving when initialization is finished
off
▸ off<E
>(event
, listener
): Renderer
<ResultT
>
Removes the listener from the listener array for the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
on
▸ on<E
>(event
, listener
): Renderer
<ResultT
>
Adds the listener function to the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
once
▸ once<E
>(event
, listener
): Renderer
<ResultT
>
Adds a one-time listener function for the event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
prependListener
▸ prependListener<E
>(event
, listener
): Renderer
<ResultT
>
Adds the listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
prependOnceListener
▸ prependOnceListener<E
>(event
, listener
): Renderer
<ResultT
>
Adds a one-time listener function to the beginning of the listeners array
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
Inherited from
EventEmitterT.prependOnceListener
rawListeners
▸ rawListeners<E
>(event
): Function
[]
Copy of the array of listeners for the event including wrappers
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
Returns
Function
[]
Copy of the listeners array
Inherited from
removeAllListeners
▸ removeAllListeners<E
>(event?
): Renderer
<ResultT
>
Removes all listeners, or those of the specified event
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event? | E | The name of the event |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
EventEmitterT.removeAllListeners
removeListener
▸ removeListener<E
>(event
, listener
): Renderer
<ResultT
>
Removes the specified listener from the listener array
Type parameters
Name | Type |
---|---|
E | extends keyof RendererEvents |
Parameters
Name | Type | Description |
---|---|---|
event | E | The name of the event |
listener | RendererEvents [E ] | The callback function |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
setMaxListeners
▸ setMaxListeners(n
): Renderer
<ResultT
>
Sets maximum number of listeners per event
Parameters
Name | Type | Description |
---|---|---|
n | number | Maximum number of listeners |
Returns
Renderer
<ResultT
>
This EventEmitter
Inherited from
setupCamera
▸ setupCamera(ratio
, angle
): void
Set camera parameters
Some video processors statically define camera parameters from just a video resolution. In this cases setupCamera() is used to pass these static camera parameters to renderer.
Parameters
Name | Type | Description |
---|---|---|
ratio | number | Camera aspect ratio |
angle | number | Camera vertical angle in radians |
Returns
void
setupVideo
▸ setupVideo(size
, ratio?
): void
Set video parameters
Could be overridden to adjust rendering pipeline.
Parameters
Name | Type | Description |
---|---|---|
size | Size | Resolution of input video |
ratio? | number | Aspect ration of input video |
Returns
void
unload
▸ unload(): void
Reset renderer
Releases all resources and instances created in load(). Overridden by derived classes for particular application.
Returns
void
update
▸ update(result
, stream
): Promise
<void
>
Update the scene
Main method defining the logic of the renderer. Updates the scene according to provided results. Overridden by derived classes for the application.
Parameters
Name | Type | Description |
---|---|---|
result | ResultT | Results of video processing |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished
updateScene
▸ Protected
updateScene(): void
Update and render the scene
Virtual method updating and rendering the scene. Overridden by implementation of derived renderer.
Returns
void
updateVideo
▸ Protected
updateVideo(stream
): void
Update the video layer
Virtual method drawing input video frame. Derived renderer provides implementation.
Parameters
Name | Type | Description |
---|---|---|
stream | HTMLCanvasElement | Captured video frame |
Returns
void