A light object is a light template referenced by one or more LightInstances. The LightInstances provides the transformation for the Lights from the SceneNode they are attached to. Direction lights are not effected by the the transformation.
Lights are often created by loading a Scene, see the Scene pipeline documentation.
Required scripts
The Light object requires:
/*{{ javascript("jslib/light.js") }}*/
It also requires that a MathDevice has been created before calling the Light constructor.
Summary
Creates and returns a Light object with passed in parameters.
Syntax
var pointLight = Light.create({name : lightName,
color : mathDevice.v3Build(1, 1, 1),
point : true,
shadows : true,
halfExtents : mathDevice.v3Build(40, 40, 40),
origin : mathDevice.v3Build(0, 10, 0),
material : lightMatrial});
var spotLight = Light.create({name : "spot_light_1",
spot : true,
color : mathDevice.v3Build(0.89, 1, 0.99),
material : coneLightMaterial,
right : mathDevice.v3Build(0, 6, 26),
up : mathDevice.v3Build(21, 0, 0),
target : mathDevice.v3Build(0, -36, 9),
shadows : true});
var directionalLight = Light.create({name : "directional_light1",
directional : true,
color : mathDevice.v3Build(0.2, 0.2, 0.8),
direction : mathDevice.v3Build(0, -1, 0),
material : directionalLightMaterial});
var ambient = Light.create({name : "ambient1",
ambient : true,
color : mathDevice.v3Build(0.1, 0.1, 0.1)} );
If a light does not have halfExtents, radius or target parameters defined then it is assumed to be a global light.
Returns a light object.
Summary
Creates a light by cloning an existing light.
Syntax
var newLight = light.clone();
The properties of lights depends on the type of the light created.
Booleans representing the type of the light. Only one of these values should be true.
Syntax
if (light.point)
{
// ...
}
Summary
Boolean. If set to true then all objects in the Scene are effected by the light. Ambient and directional lights are often global.
Syntax
if (light.global)
{
// ...
}
Summary
A Vector3 representing color. Defaults to white.
Syntax
var red = light.color[0];
Summary
Boolean, set to true if the light casts shadows.
Syntax
var shadows = light.shadows;
Summary
A Vector3 representing the direction of a direction light.
Syntax
var direction = light.direction;
Summary
A Vector3 representing the position of the light source. This property does not need to have the same value as center.
Syntax
var origin = light.origin;
Summary
A Vector3 representing the center of the light’s bounding box. If the property is missing or undefined it is implied to be [0, 0, 0].
Syntax
var center = light.center;
Summary
A Vector3 representing the half extents of the light’s bounding box.
Syntax
var minX = light.center[0] - light.halfExtents[0];
Summary
For point lights the radius of effect. The half extents of the light should be set to this value.
Syntax
light.halfExtents[0] = light.radius;
Summary
Boolean value. If its set then the light is ignored.
Syntax
if (light.disabled)
{
// ...
}
Summary
The Material to use. This supplies the TechniqueParameters to use.
Syntax
if (light.material)
{
// ...
}
Summary
The TechniqueParameters to use.
Syntax
var techniqueParameters = light.techniqueParameters;