July 2018
Beginner to intermediate
374 pages
8h 54m
English
Drawing shadows is a lot of work for computers, so don’t go crazy with them. Since they are so much work, they’re disabled at first. We have to carefully work through each object that needs a shadow—and turn on shadows for the scene and light as well.
The first thing we need is some ground to see a shadow—we won’t see a shadow unless the shadow falls on something. Add the code for the ground below the code for the donut, and above the light code.
| | var shape = new THREE.PlaneGeometry(1000, 1000, 10, 10); |
| | var cover = new THREE.MeshPhongMaterial(); |
| | var ground = new THREE.Mesh(shape, cover); |
| | ground.rotation.x = -Math.PI/2; |
| | scene.add(ground); |
That creates a plane, rotates it flat, and adds it to the scene—without any shadows. ...
Read now
Unlock full access