Class c3dl.Light
This is an 'abstract' class which should not be instantiaed. Doing so will result in a
light which will not work and have no effect on the scene. This class exists to serve as
a base class for c3dl.PositionalLight and c3dl.DirectionalLight. To place a light into a
scene use a class which derives from this one.
Defined in: light.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Method Attributes | Method Name and Description |
|---|---|
|
Get the ambient component of this light.
|
|
|
Get the difuse component of this light.
|
|
|
getName()
Get the name of this light.
|
|
|
Get the specular component of the light.
|
|
|
getType()
Get the type of light this is.
|
|
|
isOn()
If the light is on, it will affect the colors of the object it hits.
|
|
|
setAmbient(color)
Set the ambient color component of this light.
|
|
|
setDiffuse(color)
Set the diffuse color component of this light.
|
|
|
setName(name)
Set the name of the light.
|
|
|
setOn(isOn)
Turn the light on or off.
|
|
|
setSpecular(color)
Set the specular component of the light.
|
Method Detail
{Array}
getAmbient()
Get the ambient component of this light.
Ambient light does not have a direction or position, but seems to come from
everywhere. If only using ambient light, all objects in the scene would be lit
evenly. Assigning an ambient component to a light can seem strange since lights
typically tend to attenuate. The functionality is simply provided because OpenGL
supports it. Generally, you should use scene.setAmbientLight(array) to place
ambient light in the scene.
Regardless of the position of the light in the scene, the ambient component
will light the entire surface of all objects in the scene. Also, if only using
ambient light, object will tend to appear flat, therefore set the diffuse color
component to give 'shape' to objects.
- Returns:
- {Array} Array of three values in the order RGB.
{Array}
getDiffuse()
Get the difuse component of this light.
Diffuse light is what most people associate with what light is. Diffuse gives
shape to the object, making it appear 3D. Diffuse lighting is dependent on the
light’s position relative to the object. For example, if you were looking
at the object directly and the light was behind it, you would likely not see much of
the light's effect. If you were at the position of the light looking at the object,
you would see the object light and likely its contour would be less lit.
- Returns:
- {Array} Array of three values in the order RGB.
{string}
getName()
Get the name of this light.
The name can be assigned with SetName() and should be unique. When getting or
removing a light from the scene, the name must be used as an identifier.
- Returns:
- {string} the name of the light.
{Array}
getSpecular()
Get the specular component of the light.
Specular lighting is used to create shiny highlights. Highlights are typically
seen on objects such as glass, metal or plastic and are usually white.
Unlike ambient and diffuse light, specular light takes not only the object's
position into account, but also the viewer’s position. The highlights tend to
'follow' where the camera is looking.
- Returns:
- {Array} Array of three values in the order RGB.
{int}
getType()
Get the type of light this is.
- Returns:
- {int} the type of light this is.
{boolean}
isOn()
If the light is on, it will affect the colors of the object it hits.
When creating a light, its initial state will be off.
- Returns:
- {boolean} true if the light is on, otherwise false.
setAmbient(color)
Set the ambient color component of this light.
Ambient light does not have a direction or position, but seems to come from
everywhere. If only using ambient light, all objects in the scene would be lit
evenly. Assigning an ambient component to a light can seem strange since lights
typically tend to attenuate. The functionality is simply provided because OpenGL
supports it. Generally, you should use scene.setAmbientLight(array) to place
ambient light in the scene.
Regardless of the position of the light in the scene, the ambient component
will light the entire surface of all objects in the scene. Also, if only using
ambient light, object will tend to appear flat, therefore set the diffuse color
component to give 'shape' to objects.
- Parameters:
- {Array} color
- Array of three values in the order RGB.
setDiffuse(color)
Set the diffuse color component of this light.
Diffuse light is what most people associate with what light is. Diffuse gives
shape to the object, making it appear 3D. Diffuse lighting is dependent on the
light’s position relative to the object. For example, if you were looking
at the object directly and the light was behind it, you would likely not see much of
the light's effect. If you were at the position of the light looking at the object,
you would see the object light and likely its contour would be less lit.
- Parameters:
- {Array} color
- Array of three values in the order RGB.
setName(name)
Set the name of the light.
The scene can later be queried for the light by this name so the light can be
updated or removed. The default name is "unnamed".
- Parameters:
- {String} name
- The new name of the light.
setOn(isOn)
Turn the light on or off.
- Parameters:
- {boolean} isOn
- true to turn the light on, false to turn it off.
setSpecular(color)
Set the specular component of the light.
Specular lighting is used to create shiny highlights. Highlights are typically
seen on objects such as glass, metal or plastic and are usually white.
Unlike ambient and diffuse light, specular light takes not only the object's
position into account, but also the viewer’s position. The highlights tend to
'follow' where the camera is looking.
- Parameters:
- {Array} color
- Array of three values in the order RGB.