Ambient Light

First, let’s add some “ambient” light to the scene. A scene is rarely completely black. There’s usually a little bit of illumination.

The light that we commented out at the very top of our code is that kind of light. So, let’s uncomment it and change its brightness from a fairly high 0.8 (1.0 is maximum brightness) to a dim 0.1 (0.0 is no light).

»​var​ light = ​new​ THREE.AmbientLight(​'white'​, 0.1);
»scene.add(light);

If you hide the code, you can see that this amount of ambient light is just barely enough to see the donut. That probably seems too dark, but it’s perfect when working with other lights. That is just what we’ll do in the next section!

Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.