Skip to content

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.

new LightsPlugin(scene?, rangeMax?, rangeMin?, filterParams?): LightsPlugin

Constructor

Scene

Scene controlled by the plugin

number = 0.85

number = 0.03

FilterParams = ...

LightsPlugin

BrightnessPlugin.constructor

protected optional callback: (brightness) => void

Method when brightness has changed

number

void

BrightnessPlugin.callback


protected filterParams: FilterParams

Parameters of reactive low-pass filter

BrightnessPlugin.filterParams


loaded: boolean

Loaded state

BrightnessPlugin.loaded


ordinal: number

Ordinal number

BrightnessPlugin.ordinal


protected rangeMax: number = 0.85

Maximum brightness, range scales to [min..1.0]

BrightnessPlugin.rangeMax


protected rangeMin: number = 0.03

Minimum brightness, range scales to [min..1.0]

BrightnessPlugin.rangeMin


protected optional renderer: Renderer<any>

Renderer loaded the plugin

BrightnessPlugin.renderer


protected optional scene: Scene

Scene controlled by the plugin

dispose(): void

Dispose video plugin

void

BrightnessPlugin.dispose


load(renderer): Promise<void>

Initialize plugin

Remembers intensities of all light sources in the current scene as reference maximums.

Renderer<any>

Renderer this plugin is attached to

Promise<void>

Promise resolving when initialization is finished

BrightnessPlugin.load


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.

void


setCallback(callback): void

Set brightness change callback

Method when brightness has changed

undefined | (brightness) => void

void

BrightnessPlugin.setCallback


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.

Scene

Scene controlled by the plugin

void


setupCamera(ratio, angle): void

Set camera parameters

Could be overridden to adjust plugin’s pipeline.

number

Aspect ration of input video

number

Vertical field of view in radians

void

BrightnessPlugin.setupCamera


setupVideo(size): boolean

Set video size

Resize multilevel texture

Size

Resolution of input video

boolean

BrightnessPlugin.setupVideo


unload(): void

Reset plugin

Restores intensities of all controlled lights.

void

BrightnessPlugin.unload


update(result, stream): Promise<void>

Update

Plugin estimates current brightness and calls provided callback.

any

Results of video processing

HTMLCanvasElement

Captured video frame

Promise<void>

Promise resolving when update is finished

BrightnessPlugin.update