Skip to main content

Interface: LightManager

LightManager allows to create a light source in the scene, such as a sun or street lights.

At least one light must be added to a scene in order to see anything (unless the Material.Shading.UNLIT is used).

Extends

  • PointerHolder

Properties

isValid

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from

PointerHolder.isValid

Defined in

src/types/PointerHolder.ts:37

Methods

createLightEntity()

createLightEntity(type, colorKelvin, intensity, direction, position, castShadows, falloffRadius, spotLightCone): Entity

Parameters

type: "spot" | "point" | "focused_point" | "directional" | "sun"

colorKelvin: undefined | number

intensity: undefined | number

direction: undefined | Float3

position: undefined | Float3

castShadows: undefined | boolean

falloffRadius: undefined | number

spotLightCone: undefined | [number, number]

Returns

Entity

Defined in

src/types/LightManager.ts:13


destroy()

destroy(entityWrapper): void

Destroys this component from the given entity, should only be called when removed from the scene

Parameters

entityWrapper: Entity

Returns

void

Defined in

src/types/LightManager.ts:27


getColor()

getColor(entityWrapper): Float3[]

Returns the light's color in linear sRGB color-space.

Parameters

entityWrapper: Entity

Returns

Float3[]

Defined in

src/types/LightManager.ts:59


getDirection()

getDirection(entityWrapper): Float3[]

Returns the light's direction in world space.

Parameters

entityWrapper: Entity

Returns

Float3[]

Defined in

src/types/LightManager.ts:48


getFalloff()

getFalloff(entityWrapper): number

Parameters

entityWrapper: Entity

Returns

number

the falloff distance of this light.

Defined in

src/types/LightManager.ts:87


getIntensity()

getIntensity(entityWrapper): number

returns the light's luminous intensity in candela.

Parameters

entityWrapper: Entity

Returns

number

luminous intensity in candela.

Note

for Type.FOCUSED_SPOT lights, the returned value depends on the \p outer cone angle.

Defined in

src/types/LightManager.ts:77


getPosition()

getPosition(entityWrapper): Float3[]

Returns the light's position in world space.

Parameters

entityWrapper: Entity

Returns

Float3[]

Defined in

src/types/LightManager.ts:37


getSpotLightCone()

getSpotLightCone(entityWrapper): Float3[]

Parameters

entityWrapper: Entity

Returns

Float3[]

Defined in

src/types/LightManager.ts:95


release()

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns

void

Inherited from

PointerHolder.release

Defined in

src/types/PointerHolder.ts:30


setColor()

setColor(entityWrapper, linearSRGBColor): void

Dynamically updates the light's hue as linear sRGB

Parameters

entityWrapper: Entity

linearSRGBColor: Float3[]

Returns

void

Defined in

src/types/LightManager.ts:55


setDirection()

setDirection(entityWrapper, direction): void

Dynamically updates the light's direction

Parameters

entityWrapper: Entity

direction: Float3[]

Light's direction in world space. Should be a unit vector. The default is 0.

Returns

void

Defined in

src/types/LightManager.ts:44


setFalloff()

setFalloff(entityWrapper, falloffRadius): void

Set the falloff distance for point lights and spot lights.

Parameters

entityWrapper: Entity

falloffRadius: number

Returns

void

Defined in

src/types/LightManager.ts:83


setIntensity()

setIntensity(entityWrapper, intensity): void

Dynamically updates the light's intensity. The intensity can be negative.

Parameters

entityWrapper: Entity

intensity: number

This parameter depends on the Light.Type:

  • For directional lights, it specifies the illuminance in lux (or lumen/m^2).
  • For point lights and spot lights, it specifies the luminous power in lumen.

Returns

void

Defined in

src/types/LightManager.ts:69


setPosition()

setPosition(entityWrapper, position): void

Dynamically updates the light's position.

Parameters

entityWrapper: Entity

position: Float3[]

Light's position in world space. The default is at the origin.

Returns

void

Defined in

src/types/LightManager.ts:33


setSpotLightCone()

setSpotLightCone(entityWrapper, spotLightCone): void

Dynamically updates a spot light's cone as angles

Parameters

entityWrapper: Entity

spotLightCone: [number, number]

Returns

void

Defined in

src/types/LightManager.ts:94