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.

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

LightsPlugin

Overrides

BrightnessPlugin.constructor

Properties

callback()?

protected optional callback: (brightness) => void

Method when brightness has changed

Parameters

brightness: number

Returns

void

Inherited from

BrightnessPlugin.callback


filterParams

protected filterParams: FilterParams

Parameters of reactive low-pass filter

Inherited from

BrightnessPlugin.filterParams


loaded

loaded: boolean

Loaded state

Inherited from

BrightnessPlugin.loaded


ordinal

ordinal: number

Ordinal number

Inherited from

BrightnessPlugin.ordinal


rangeMax

protected rangeMax: number = 0.85

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

Inherited from

BrightnessPlugin.rangeMax


rangeMin

protected rangeMin: number = 0.03

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

Inherited from

BrightnessPlugin.rangeMin


renderer?

protected optional renderer: Renderer<any>

Renderer loaded the plugin

Inherited from

BrightnessPlugin.renderer


scene?

protected optional scene: Scene

Scene controlled by the plugin

Methods

dispose()

dispose(): void

Dispose video plugin

Returns

void

Inherited from

BrightnessPlugin.dispose


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

BrightnessPlugin.load


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

BrightnessPlugin.setCallback


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

BrightnessPlugin.setupCamera


setupVideo()

setupVideo(size): boolean

Set video size

Resize multilevel texture

Parameters

size: Size

Resolution of input video

Returns

boolean

Inherited from

BrightnessPlugin.setupVideo


unload()

unload(): void

Reset plugin

Restores intensities of all controlled lights.

Returns

void

Overrides

BrightnessPlugin.unload


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

Inherited from

BrightnessPlugin.update