-
Notifications
You must be signed in to change notification settings - Fork 27
Lights
Class diagram for lights
Ambient light is fixed-intensity and fixed-color light source that affects all objects in the scene equally. This type of light source is mainly used to provide the scene with a basic view of the different objects in it.
// Call constructor and set Ambient light color in HEX format
AmbientLight light = new AmbientLight( 0xff0000 );
getScene().add( light );
Hemisphere light, see figure: a point on the top of the sphere receives illumination only from the upper hemisphere (i.e., the sky color). A point on the bottom of the sphere receives illumination only from the lower hemisphere (i.e., the ground color). A point right on the equator would receive half of its illumination from the upper hemisphere and half from the lower hemisphere (e.g., 50% sky color and 50% ground color).
// Call constructor and set sky color and ground color
HemisphereLight light = new HemisphereLight( 0x0000ff, 0x111111 );
// Alternatively you can define color intensity by passing third parameter
HemisphereLight light = new HemisphereLight( 0x0000ff, 0x111111, 1.0 );
getScene().add( light );
Point light, like a star, radiates light equally in all directions from a given location in 3D space.
This light affects objects using MeshLambertMaterial
or MeshPhongMaterial
.
// Simple light creation by passing light color only in HEX
PointLight light = new PointLight( 0xff0000 );
// Or alternatively you can define color intensity and
// the lighted distance in the second and third parameter respectively
PointLight light = new PointLight( 0xff0000, 1, 100 );
light.getPosition().set( 50, 50, 50 );
getScene().add( light );
Directional light illuminates uniformly along a particular direction. Since it is infinitely far away, it has no location in 3D space.
This light affects objects using MeshLambertMaterial
or MeshPhongMaterial
.
Light is also used to cast shadow.
// White directional light at half intensity shining from the top.
// Also you can define the lighted distance in the third parameter
DirectionalLight light = new DirectionalLight( 0xffffff, 0.5 );
light.getPosition().set( 0, 1, 0 );
getScene().add( light );
Spot light illuminates from a point in space along a primary direction. Its illumination is a cone of light diverging from the light's position.
This light affects objects using MeshLambertMaterial
or MeshPhongMaterial
.
Light is also used to cast shadow.
// white spotlight shining from the side, casting shadow
SpotLight spotLight = new SpotLight( 0xffffff );
spotLight.getPosition().set( 100, 1000, 100 );
getScene().add( spotLight );