Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By : Jos Dirksen
Book Image

Learning Three.js - the JavaScript 3D Library for WebGL

By: Jos Dirksen

Overview of this book

Table of Contents (20 chapters)
Learning Three.js – the JavaScript 3D Library for WebGL Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
8
Creating and Loading Advanced Meshes and Geometries
Index

Basic lights


We'll start with the most basic of the lights: THREE.AmbientLight.

THREE.AmbientLight

When you create THREE.AmbientLight, the color is applied globally. There isn't a specific direction this light comes from, and THREE.AmbientLight doesn't contribute to any shadows. You would normally not use THREE.AmbientLight as the single source of light in a scene since it colors all the objects in the same color, regardless of shape. You use it together with other lighting sources, such as THREE.SpotLight or THREE.DirectionalLight to soften the shadows or add some additional color to the scene. The easiest way to understand this is by looking at the 01-ambient-light.html example in the chapter-03 folder. With this example, you get a simple user interface that can be used to modify THREE.AmbientLight that is available in this scene. Note that in this scene, we also have THREE.SpotLight, which adds additional lighting and provides shadows.

In the following screenshot, you can see that we used...