Lights and materials are two sides of the same coin in Away3D. The effect of a light can only be seen on a material, and materials that can be illuminated will generally show up completely black without a light source.
Away3D includes three classes, all from the away3d.lights
package, with each one representing a different type of light:
PointLight3D
class, emit light in all directions from a point in space. The intensity of the point light is calculated using the inverse square law of attenuation (light intensity = 1 / distance2).DirectionalLight3D
class, emit light along a vector, like a flash light. Unlike the point light, the intensity of the directional light does not diminish with distance. The intensity does decrease as the angle between the vector along which the directional light is shining and the surface it is shining on increases.AmbientLight3D
class, shine on all surfaces equally. Ambient lights can be used to add a minimum amount of light to those materials that implement them.Only a subset of the materials available in Away3D can be illuminated, and those materials may only support a subset of the different types of lights. The following table lists those materials that can be lit, which types of lights they support, and whether the material can be illuminated by multiple light sources. The material classes themselves will be covered in more detail later on in this chapter.
Material |
Ambient |
Directional |
Point |
Multiple Lights |
---|---|---|---|---|
* |
* |
* | ||
* | ||||
* |
* |
* | ||
* |
* | |||
* |
* |
* | ||
* | ||||
* |
* |
* | ||
* |
* |
* | ||
* |
* |
* |
There does not appear to be any overall design when determining which types of lights are supported by which materials. The phong shading materials are a good example. PhongMultipassMaterial
supports both point and directional lights, while PhongPBMaterial
only supports point lights. Neither supports the ambient light type, unlike the PhongBitmapMaterial
, PhongColorMaterial
, and PhongMovieMaterial
classes.
The choice of what type of light source to use in your Away3D applications will usually be determined by your choice of material, and not the other way around.