Colored lights

Our programs so far have shined white light on colored surfaces. In the following program, colored lights shine onto white surfaces. Each light revolving around the scene is co-located with a small sphere indicating its color. The speleothems tethering ceiling to floor are rotated parabolas generated with random parameters.

Colored lights

The program’s navigation uses a first-person fly control, different from the orbit control we’ve used in previous programs. Use the mouse or arrow keys to move forward, backward, left, and right, to wander around.

When color is represented as a combination of red, green, and blue values as it is in threejs, each lighting calculation is carried out separately in each of these color channels and then combined. The different amounts of red, green, and blue making up a surface’s diffuse color contribute to its apparent color. Similarly, the different relative intensities of red, green, and blue in a light’s emitted color affect the apparent color of the surfaces it illuminates. All this is accounted for in the standard lighting equation.