LightsPlugin
Plugin automatically adjusting lighting environment
Plugin controls intensities of all light sources in the rendered scene according to estimated level of brightness. Extends @geenee/bodyrenderers-common!BrightnessPlugin providing callback that automatically adjusts parameters of lights. On initialization or scene update it remembers props of all light sources as references corresponding to maximum brightness level. When brightness changes the plugin adjusts controlled props using the new brightness value as the factor. On upload() intensities of all controlled lights are restored.
Extends
Constructors
new LightsPlugin()
new LightsPlugin(
scene
?,rangeMax
?,rangeMin
?,filterParams
?):LightsPlugin
Constructor
Parameters
• scene?: Scene
Scene controlled by the plugin
• rangeMax?: number
= 0.85
• rangeMin?: number
= 0.03
• filterParams?: FilterParams
= ...
Returns
Overrides
Properties
callback()?
protected
optional
callback: (brightness
) =>void
Method when brightness has changed
Parameters
• brightness: number
Returns
void
Inherited from
filterParams
protected
filterParams:FilterParams
Parameters of reactive low-pass filter
Inherited from
loaded
loaded:
boolean
Loaded state
Inherited from
ordinal
ordinal:
number
Ordinal number
Inherited from
rangeMax
protected
rangeMax:number
=0.85
Maximum brightness, range scales to [min..1.0]
Inherited from
rangeMin
protected
rangeMin:number
=0.03
Minimum brightness, range scales to [min..1.0]
Inherited from
renderer?
protected
optional
renderer:Renderer
<any
>
Renderer loaded the plugin
Inherited from
scene?
protected
optional
scene:Scene
Scene controlled by the plugin
Methods
dispose()
dispose():
void
Dispose video plugin
Returns
void
Inherited from
load()
load(
renderer
):Promise
<void
>
Initialize plugin
Remembers intensities of all light sources in the current scene as reference maximums.
Parameters
• renderer: Renderer
<any
>
Renderer this plugin is attached to
Returns
Promise
<void
>
Promise resolving when initialization is finished
Overrides
resetScene()
resetScene():
void
Reset lighting in the current scene
Updates reference/default intensities of all light sources in the current scene. This method can be used after a light is added to or removed from a scene to update the list of controlled sources.
Returns
void
setCallback()
setCallback(
callback
):void
Set brightness change callback
Parameters
• callback: undefined
| (brightness
) => void
Method when brightness has changed
Returns
void
Inherited from
setScene()
setScene(
scene
?):void
Set/attach a scene to control its lighting
When a new scene is attached plugin remembers intensities of all light sources in it as reference maximums and use them as values corresponding to maximum brightness (1.0). In previously attached scene all intensities are restored.
Parameters
• scene?: Scene
Scene controlled by the plugin
Returns
void
setupCamera()
setupCamera(
ratio
,angle
):void
Set camera parameters
Could be overridden to adjust plugin’s pipeline.
Parameters
• ratio: number
Aspect ration of input video
• angle: number
Vertical field of view in radians
Returns
void
Inherited from
setupVideo()
setupVideo(
size
):boolean
Set video size
Resize multilevel texture
Parameters
• size: Size
Resolution of input video
Returns
boolean
Inherited from
unload()
unload():
void
Reset plugin
Restores intensities of all controlled lights.
Returns
void
Overrides
update()
update(
result
,stream
):Promise
<void
>
Update
Plugin estimates current brightness and calls provided callback.
Parameters
• result: any
Results of video processing
• stream: HTMLCanvasElement
Captured video frame
Returns
Promise
<void
>
Promise resolving when update is finished