Adding Lights with Three.js (part 1)
Now it's time for one of the most important elements in 3D games and graphics: lights and lighting. The Three.js library offers us some of the latest and most realistic lighting and shading options available in today's web browsers. There are a lot of options for types of lights, types of surface materials on the subjects that are lit, and equations/algorithms that affect the final look of the lighted scene. This will be a multi-part post because we have to cover quite a bit of setup for lighting to work well in Three.js. First, we have to change the material (or skin) of our colored cube so that it will correctly respond to lights in the game world. If you recall, here is the old way of setting up the material/skin of our green-colored cube: var material = new THREE.MeshBasicMaterial({ color: 'rgb(0,255,0)' }); Unfortunately, this way of setting up a 'Basic' material will only shade the cube with the rgb color that you manually give to it...