Point Light

To increase the realism, let’s add a “point light,” which is kind of like a light bulb. Add the code for our point light below the donut code.

​ ​var​ point = ​new​ THREE.PointLight(​'white'​, 0.8);
​ point.position.​set​(0, 300, -100);
​ scene.add(point);

We’re positioning the light above and behind the donut. The point light is bright, but not too bright at 0.8. The result should be a pretty cool-looking donut:

images/lights_and_materials/donut_pointlight.png

One weird thing about programming with 3D lights is that the light is not coming from an object in the scene. We positioned the source of the light at X-Y-Z coordinates of (0, 300, -100). The ...

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.