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

Adding a moving all-directional light


In a lot of cases, you don't need a light source that casts shadows but just a light source that illuminates your scene. In the Creating shadows with THREE.SpotLight and Creating shadows with THREE.DirectionalLight recipes, we already showed you how you can use THREE.SpotLight and THREE.DirectionalLight. In this recipe, we'll show you a third kind of light, which is THREE.PointLight; this kind of light emits light to all directions and in this recipe, we will show you how to create one and move it through the scene.

Getting ready

As the Three.js standard comes with the THREE.PointLight object, there is no need to include any additional JavaScript. The same is the case with all the recipes where we've included an example where you can see the result of this recipe in action. For this recipe, open the 05.05-use-a-point-light.html example in your browser, and you'll see the following result:

In this example, there are four THREE.PointLight objects that move...