Book Image

Three.js Cookbook

By : Jos Dirksen
Book Image

Three.js Cookbook

By: Jos Dirksen

Overview of this book

Table of Contents (15 chapters)
Three.js Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using THREE.HemisphereLight for natural lighting


If you look at the lighting outside, you'll see that the lights don't really come from a single direction. Part of the sunlight is reflected by Earth, and other parts are scattered by the atmosphere. The result is a very soft light coming from lots of directions. In Three.js, we can create something similar using THREE.HemisphereLight.

Getting ready

Just like the other lights provided by Three.js, there is no need to include any additional JavaScript file to work with THREE.HemisphereLight. All you need is a scene with some objects, and you can add this light. To see the effect THREE.HemisphereLight object has, we've provided a simple example. Open up 05.04-create-a-sun-like-light.html in your browser. You will see something similar to the following screenshot:

With the controls in the top-right section, you can enable and disable THREE.HemisphereLight and THREE.DirectionalLight, which are used in this scene.

How to do it...

Creating THREE.HemisphereLight...