Emitting Light

The dull light in the scene is coming from a light at the very top of the code. Comment out that light.

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

With no light, everything is black. We have a red donut spinning in a dark room and can’t see it.

The first kind of light we can play with is “emissive” light. It’s the light with which an object itself glows. This is like a white LED bulb that can shine different colors—even though the bulb itself is white, it can glow red, green, yellow…

So let’s go back to our donut code to make our red donut… glow yellow.

​ ​var​ shape = ​new​ THREE.TorusGeometry(50, 20, 8, 20);
​ ​var​ cover = ​new​ THREE.MeshPhongMaterial({color: ...

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.