Skip to content
bg2 engine

Light

Defines the properties of a light. The final result of the rendering and the concrete meaning of each parameter may vary depending on the rendering method. At the bg2e-base library level, the Light class is only used as a data container and to handle data serialization and deserialization.

import Light, { LightType } from 'bg2e-js/ts/base/Light.ts';
import Color from 'bg2e-js/ts/base/Color.ts';
const light = new Light();
light.ambient = new Color({ rgb: 0.1 });
light.diffuse = new Color({ rgb: 0.77 });
light.type = LightType.POINT;

Defines the available kinds of lights:

const LightType = {
DIRECTIONAL: 4,
SPOT: 1,
POINT: 5,
DISABLED: 10
}

l.clone(): returns a copy of l.

l.assign(l2): copy the attributes of l2 into l.

l.enabled: (read/write) boolean

l.type: (read/write) LightType

l.direction: (read/write) bg2e-math.Vec with three components.

l.ambient: (read/write) Color

l.diffuse: (read/write) Color

l.specular: (read/write) Color

l.intensity: (read/write) number

l.spotCutoff: (read/write) number

l.spotExponent: (read/write) number

l.shadowStrength: (read/write) number

l.castShadows: (read/write) boolean

l.shadowBias: (read/write) number

l.projection: (read/write) bg2e-math.Mat4 (projection matrix)

See the serialization protocol.