Multiple Lights
All types of lights could be used in one sketch.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function setup() {
createCanvas(710, 400, WEBGL);
}
function draw() {
background(0);
let locX = mouseX - height / 2;
let locY = mouseY - width / 2;
ambientLight(50);
directionalLight(255, 0, 0, 0.25, 0.25, 0);
pointLight(0, 0, 255, locX, locY, 250);
push();
translate(-width / 4, 0, 0);
rotateZ(frameCount * 0.02);
rotateX(frameCount * 0.02);
specularMaterial(250);
box(100, 100, 100);
pop();
translate(width / 4, 0, 0);
ambientMaterial(250);
sphere(120, 64);
}