Graphics Reference
In-Depth Information
requestAnimationFrame(render);
}
One thing to notice in the last step is that we set the target property of
spotLight to the THREE.Mesh object and not to the position property of
THREE.Mesh .
There's more…
To point THREE.SpotLight at a certain position, we set its target property.
As you've seen in the recipe steps, we target THREE.Object3D , from which
THREE.Mesh extends, instead of a position. If we want to point THREE.SpotLight
to an arbitrary position, we need to first create an empty THREE.Object3D object:
var target = new THREE.Object3D();
target.position = new
THREE.Vector3(20,10,-10);
scene.add(target);
spotLight.target = target;
This way, you can point THREE.SpotLight not just to an existing object in the
scene but to any position you want.
See also
• In this recipe, we pointed a light at a specific target, and we can also make a
camera follow an object around the scene, as we showed in the Making the
camera follow an object recipe from Chapter 3 , working with the Camera and
point one object to another, as shown in the Pointing an object to another ob-
ject recipe in Chapter 2 , Geometries and Meshes .
Search WWH ::




Custom Search