Class: LightsPlugin
@geenee/bodyrenderers-babylon.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.
Hierarchy
-
↳
LightsPlugin
Constructors
constructor
• new LightsPlugin(scene?
, rangeMax?
, rangeMin?
, filterParams?
)
Constructor
Parameters
Name | Type | Default value | Description |
---|---|---|---|
scene? | Scene | undefined | Scene controlled by the plugin |
rangeMax | number | 0.85 | - |
rangeMin | number | 0.03 | - |
filterParams | FilterParams | undefined | - |
Overrides
Properties
callback
• Protected
Optional
callback: (brightness
: number
) => void
Type declaration
▸ (brightness
): void
Parameters
Name | Type |
---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
callback | undefined | (brightness : number ) => 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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
result | any | Results of video processing |
stream | HTMLCanvasElement | Captured video frame |
Returns
Promise
<void
>
Promise resolving when update is finished