Creating shadows with THREE.DirectionalLight

With THREE.DirectionalLight, you can simulate a light source from far away whose rays run parallel to each other. A good example of this is light received from the sun. In this recipe, we'll show you how to create THREE.DirectionalLight and use it to create shadows.

Getting ready

For this recipe, we've created an example that shows you what the shadows cast by a THREE.DirectionalLight object look like. Open up the 05.02-using-shadows-with-a-directionalLight.html example in your browser, and you'll see something like what is shown in the following screenshot:

Getting ready

In this screenshot, a single THREE.DirectionalLight ...

Get Three.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.