Spotlights and Sunlight
So far, weâve seen two types of lights:
- Point, which acts like a light bulb
- Ambient, which provides a small amount of light everywhere
Two other lights are worth a quick look:
- Spotlight, which is great for focusing light at a single position
- Directional, which makes shadows like sunlight does
The difference between the lights is easier to see with objects in motion. So, down in the animate() function, add the following code to change the donutâs position.
â | donut.rotation.âsetâ(t, 2*t, 0); |
» | donut.position.z = 200 * Math.sin(t); |
This moves the donut back and forward, even as it continues to spin.
Letâs also dim the point light a bit, since weâll have more than one light shining on our donut.
» | âvarâ point ... |
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.