Graphics Reference
In-Depth Information
new THREE.Vector3(-40, 20, 20),
new THREE.Vector3(0, 20, -100),
new THREE.Vector3(20, 20, -100),
new THREE.Vector3(40, 20, 100),
new THREE.Vector3(70, 20, 10),
new THREE.Vector3(100, 20, 30),
new THREE.Vector3(-100, 20, 100)]);
This will result in a curved path that moves through the points added in the
constructor of the THREE.SplineCurve3 object.
2. Before we position our light on the path of this THREE.SplineCurve3 ob-
ject, let's create the light:
var pointLight = new THREE.PointLight();
pointLight.color = new
THREE.Color(0xff0000);
pointLight.intensity = 3;
pointLight.distance = 60;
pointlight.name = 'pointLight';
3. Now, we can use this SplineCurve3 object to determine the position of our
light. For this, we create a helper function called positionLight :
var pos = 0;
function positionLight() {
light =
scene.getObjectByName('pointLight');
if (pos <= 1) {
light.position =
spline.getPointAt(pos);
pos += 0.001
} else {
pos = 0;
}
}
Search WWH ::




Custom Search