Point Lights
Three colored PointLights orbiting a TorusKnot at different radii and speeds.
Controls
Light Intensity
0
3
Orbit Speed
0.1
3
import * as EASEL from "easel";
const scene = new EASEL.Scene();
const camera = new EASEL.PerspectiveCamera({
fov: 45,
aspect: width / height,
near: 0.1,
far: 100,
});
camera.position.set(0, 3, 10);
camera.lookAt(new EASEL.Vector3(0, 0, 0));
scene.add(new EASEL.AmbientLight(0xffffff, 0.1));
const knot = new EASEL.Mesh(
new EASEL.TorusKnotGeometry(2, 0.6, 128, 16),
new EASEL.LambertMaterial({ color: 0xdddddd }),
);
scene.add(knot);
// PointLight(color, intensity, distance, decay)
const red = new EASEL.PointLight(0xff0000, 1.5, 20, 2);
const green = new EASEL.PointLight(0x00ff00, 1.5, 20, 2);
const blue = new EASEL.PointLight(0x0000ff, 1.5, 20, 2);
let t = 0;
function animate() {
t += clock.delta;
red.position.set(Math.cos(t) * 4, 2, Math.sin(t) * 4);
green.position.set(Math.cos(t * 0.7 + 2) * 5, 1, Math.sin(t * 0.7 + 2) * 5);
blue.position.set(Math.cos(t * 1.3 + 4) * 3, 3, Math.sin(t * 1.3 + 4) * 3);
renderer.render(scene, camera);
}