-
Notifications
You must be signed in to change notification settings - Fork 103
Light
The Light class represents a light for use in a Scene or as a parameter to renderObject for direct rendering.
Parameters:
var myLight = new CubicVR.Light({
type: "point", // Light type, see setType() for options.
method: "dynamic", // Light management method, see setMethod() for options.
position: [0.0,0.0,0.0], // Light position in the world.
direction: [0.0,0.0,0.0], // Light direction (vector) for directional lights.
diffuse: [1.0,1.0,1.0], // Diffuse Light color.
specular: [0.1,0.1,0.1], // Specular Light color.
intensity: 1.0, // Light intensity.
distance: 10.0, // Maximum light distance for point lights.
cutoff: 60.0, // For spotlight types this is the cut-off angle of the cone.
mapRes: 512, // Shadow resolution when using a shadowed light type.
areaAxis: [1.0, 1.0], // With `"area"` light it sets the angle of the sun [North/South, East/West].
projector: null // Projector texture used for a light of type `"spot_shadow_projector"`.
});
Set the light type.
Parameters:
-
light_type
: An enum representing the light type, one of:-
"point"
: A point light, usesLight.distance
for maximum range. -
"directional"
: A directional light with infinite distance, usesLight.direction
vector for direction. -
"spot"
: Spotlight -
"spot_shadow"
: Shadowed Spotlight -
"spot_shadow_projector"
: Shadowed Spotlight /w projective texture -
"area"
: Area light
-
Returns:
none
Set the method of the light, either static or dynamic. Static lights have additional optimization when used in conjunction with an Octree.
Parameters:
-
method
: An enum representing the light method, one of:"dynamic"
"static"
Returns:
none
Sets the parent object of the light. The light's coordinates will become relative to the parent object. Set parent to null
to remove.
This currently only works with spot and point light types.
Parameters:
-
parent
: A parent object such as SceneObject containingobj.tMatrix
.
Returns:
none
Set the diffuse value of the light.
Parameters:
-
diffuse
: An R,G,B diffuse color value, format[1.0, 1.0, 1.0]
Returns:
none
Set the specular value of a light.
Parameters:
-
specular
: An R,G,B color value, format[1.0, 1.0, 1.0]
Returns:
none
Set the intensity of the light.
Parameters:
-
intensity
: The intensity of a light, default is1.0
Returns:
none
Set the maximum distance of a point light.
Parameters:
-
distance
: Maximum falloff distance for the light, measured fromLight.position
Returns:
none
Set the rotation of a directional light.
Parameters:
-
rotation
: An X,Y,Z rotation value, format[0.0, 0.0, 0.0]
Returns:
none
Set the direction of a directional light.
Parameters:
-
direction
: An X,Y,Z vector value, format[0.0, 0.0, 0.0]
Returns:
none
Set the direction of a spot or directional light type by using a 'look at' method.
Parameters:
-
x
: X position to look at. -
y
: Y position to look at. -
z
: Z position to look at. -
pos
: A position[x, y, z]
to look at.
Returns:
none
From samples/basic/materials.html:
// ...
var light = new CubicVR.Light({
type: "point",
method: "dynamic",
diffuse: [1,1,1],
specular: [1,1,1],
position: [0,5,-2],
distance: 20
});
scene.bindLight(light);