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
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LightsPlugin(
scene?
,rangeMax?
,rangeMin?
,filterParams?
):LightsPlugin
Constructor
Parameters
Section titled “Parameters”scene?
Section titled “scene?”Scene
Scene controlled by the plugin
rangeMax?
Section titled “rangeMax?”number
= 0.85
rangeMin?
Section titled “rangeMin?”number
= 0.03
filterParams?
Section titled “filterParams?”FilterParams
= ...
Returns
Section titled “Returns”LightsPlugin
Overrides
Section titled “Overrides”Properties
Section titled “Properties”callback()?
Section titled “callback()?”
protected
optional
callback: (brightness
) =>void
Method when brightness has changed
Parameters
Section titled “Parameters”brightness
Section titled “brightness”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”filterParams
Section titled “filterParams”
protected
filterParams:FilterParams
Parameters of reactive low-pass filter
Inherited from
Section titled “Inherited from”loaded
Section titled “loaded”loaded:
boolean
Loaded state
Inherited from
Section titled “Inherited from”ordinal
Section titled “ordinal”ordinal:
number
Ordinal number
Inherited from
Section titled “Inherited from”rangeMax
Section titled “rangeMax”
protected
rangeMax:number
=0.85
Maximum brightness, range scales to [min..1.0]
Inherited from
Section titled “Inherited from”rangeMin
Section titled “rangeMin”
protected
rangeMin:number
=0.03
Minimum brightness, range scales to [min..1.0]
Inherited from
Section titled “Inherited from”renderer?
Section titled “renderer?”
protected
optional
renderer:Renderer
<any
>
Renderer loaded the plugin
Inherited from
Section titled “Inherited from”scene?
Section titled “scene?”
protected
optional
scene:Scene
Scene controlled by the plugin
Methods
Section titled “Methods”dispose()
Section titled “dispose()”dispose():
void
Dispose video plugin
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”load()
Section titled “load()”load(
renderer
):Promise
<void
>
Initialize plugin
Remembers intensities of all light sources in the current scene as reference maximums.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”Renderer
<any
>
Renderer this plugin is attached to
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when initialization is finished
Overrides
Section titled “Overrides”resetScene()
Section titled “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
Section titled “Returns”void
setCallback()
Section titled “setCallback()”setCallback(
callback
):void
Set brightness change callback
Parameters
Section titled “Parameters”callback
Section titled “callback”Method when brightness has changed
undefined
| (brightness
) => void
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setScene()
Section titled “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
Section titled “Parameters”scene?
Section titled “scene?”Scene
Scene controlled by the plugin
Returns
Section titled “Returns”void
setupCamera()
Section titled “setupCamera()”setupCamera(
ratio
,angle
):void
Set camera parameters
Could be overridden to adjust plugin’s pipeline.
Parameters
Section titled “Parameters”number
Aspect ration of input video
number
Vertical field of view in radians
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setupVideo()
Section titled “setupVideo()”setupVideo(
size
):boolean
Set video size
Resize multilevel texture
Parameters
Section titled “Parameters”Resolution of input video
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”unload()
Section titled “unload()”unload():
void
Reset plugin
Restores intensities of all controlled lights.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”update()
Section titled “update()”update(
result
,stream
):Promise
<void
>
Update
Plugin estimates current brightness and calls provided callback.
Parameters
Section titled “Parameters”result
Section titled “result”any
Results of video processing
stream
Section titled “stream”HTMLCanvasElement
Captured video frame
Returns
Section titled “Returns”Promise
<void
>
Promise resolving when update is finished