Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 39 ยท Lights and Shadows

Light Types in Three.js

Learn every Three.js light: AmbientLight, HemisphereLight, DirectionalLight, PointLight, SpotLight and RectAreaLight, with intensity, decay, cone settings and helpers.

Lit materials (Lambert, Phong, Standard, Physical, Toon) are black without light. Three.js provides several light types, and each simulates a different real-world source: the sun, a light bulb, a spotlight, a window. Choosing and combining them is what gives a scene its mood. This lesson introduces each light, its parameters, and the helper that visualizes it.

The six lights

Lights that fill the scene

AmbientLight Same light on everything, no direction
HemisphereLight Sky color above, ground color below

Cheap, no shadows, no shape. Good fill light.

1 / 2
Light Position matters? Direction matters? Casts shadows? Typical use
AmbientLight No No No Base fill so shadows are not pure black
HemisphereLight No Up vs down No Outdoor sky and ground bounce
DirectionalLight Defines direction Yes (toward target) Yes Sun, moon
PointLight Yes No Yes Bulb, candle, fireball
SpotLight Yes Yes Yes Flashlight, stage light
RectAreaLight Yes Yes No Softbox, window, screen

All lights take a color and an intensity. Since version r155 Three.js uses physically correct units by default: a PointLight or SpotLight intensity is in candela, and the light falls off with distance (decay = 2). Practical consequence: a point light at 5 units away needs an intensity in the tens or hundreds, not 1. Directional lights have no falloff, so their values stay small (1 to 5).

Ambient and hemisphere

JavaScript
scene.add(new THREE.AmbientLight("#ffffff", 0.3));
scene.add(new THREE.HemisphereLight("#bfdcff", "#4a3b2a", 0.8)); // sky, ground, intensity

Ambient light brightens all surfaces equally, so it flattens form: use a little. Hemisphere light is better outdoors because surfaces facing up get the sky color and surfaces facing down get the ground color, which suggests volume for free.

Directional light

Parallel rays from far away. Only its position relative to its target matters, which sets the direction. The target is an invisible object at the origin by default; add it to the scene if you move it.

JavaScript
const sun = new THREE.DirectionalLight("#fff1d6", 3);
sun.position.set(5, 8, 4);          // direction = from here toward the target
sun.target.position.set(0, 0, 0);
scene.add(sun, sun.target);

Point light

JavaScript
const bulb = new THREE.PointLight("#ffb347", 80, 0, 2); // color, intensity, distance, decay
bulb.position.set(0, 2, 0);

distance of 0 means infinite range with natural falloff; a positive distance makes light fade to zero at that distance, useful to limit cost and spill. decay of 2 is the physical value.

Spot light

JavaScript
const spot = new THREE.SpotLight("#ffffff", 200);
spot.position.set(0, 5, 0);
spot.angle = Math.PI / 6;     // cone half-angle
spot.penumbra = 0.4;          // 0 = hard edge, 1 = fully soft
spot.decay = 2;
spot.target.position.set(0, 0, 0);
scene.add(spot, spot.target);

RectAreaLight

A rectangular light panel with soft, realistic reflections on glossy surfaces. It works only with MeshStandardMaterial and MeshPhysicalMaterial, does not cast shadows, and needs a one-time shader library initialization:

JavaScript
import { RectAreaLightUniformsLib } from "three/addons/lights/RectAreaLightUniformsLib.js";
RectAreaLightUniformsLib.init();

const panel = new THREE.RectAreaLight("#ffffff", 8, 4, 2); // color, intensity, width, height
panel.position.set(0, 3, 2);
panel.lookAt(0, 0, 0);

See and tune them

Each light has a helper: DirectionalLightHelper, PointLightHelper, SpotLightHelper, HemisphereLightHelper, RectAreaLightHelper (add-on). The playground below places a small stage with one of each. Use the checkboxes to switch lights on and off and see what each contributes.

Light playground

Turn everything off except the point light: it lights shapes by how close they are, with a visible falloff. Then only the spot: a clear cone with a soft edge (set by penumbra). Directional gives even parallel light with the same direction everywhere, while hemisphere tints upward and downward faces differently.

Number of lights and cost

Each light is evaluated for every lit pixel, so more lights cost more. A few (two to four) are fine, dozens are heavy. Adding, removing or hiding a light at runtime changes the light count, which makes every lit material recompile its shader and can cause a hitch. For smooth results during play, keep the lights in the scene and set intensity = 0 instead.

Falloff: distance and decay

With decay = 0 the light does not fall off at all, which is physically wrong but sometimes handy. With decay = 2 the pool of light shrinks quickly; raise the intensity to compensate. A nonzero distance hard-limits the reach.

If your lit object is nearly black, first check: is there a light at all, is its intensity big enough for its distance (point and spot lights need much larger numbers than you expect), and is the material one that reacts to light?

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which light is the best choice for sunlight?

    A directional light sends parallel rays, like a distant sun, and can cast shadows.
  2. 2. Why does a PointLight with intensity 1 often look dark?

    Physically correct units mean point and spot lights usually need values in the tens or hundreds.
  3. 3. Which of these lights cannot cast shadows?

    RectAreaLight has soft reflections but no shadow support.
  4. 4. What does SpotLight.penumbra control?

    0 gives a hard edge, 1 a fully soft falloff.

Summary

  • Lit materials need lights: ambient/hemisphere for fill, directional for sun, point for bulbs, spot for cones, rect area for panels.
  • Point and spot lights use physical units: intensity in candela, decay 2, optional distance cutoff.
  • Directional and spot lights aim at their target; add the target to the scene if you move it.
  • Use light helpers while tuning; keep the number of lights small, since each costs per pixel.

Next: Shadows