Skip to content

Commit 2a67e0b

Browse files
committed
added a spotLight to the example, added some text, and added describe()
1 parent 8a8fd3a commit 2a67e0b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/data/examples/en/20_3D/02_multiple_lights.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
function setup() {
77
createCanvas(710, 400, WEBGL);
8+
9+
describe(
10+
'a 3d example containing a spinning box and a sphere, each lit with a number of different lights, including ambient (gray), directional (red), spotlight (green), and point (blue).'
11+
);
812
}
913

1014
function draw() {
@@ -13,8 +17,13 @@ function draw() {
1317
let locX = mouseX - height / 2;
1418
let locY = mouseY - width / 2;
1519

20+
// ambient light is gray
1621
ambientLight(50);
22+
// directional light is red
1723
directionalLight(255, 0, 0, 0.25, 0.25, 0);
24+
// spotlight is green
25+
spotLight(0, 255, 0, 150, 0, 250, 0, 0, -1);
26+
// point light is blue
1827
pointLight(0, 0, 255, locX, locY, 250);
1928

2029
push();
@@ -27,5 +36,5 @@ function draw() {
2736

2837
translate(width / 4, 0, 0);
2938
ambientMaterial(250);
30-
sphere(120, 64);
39+
sphere(120, 24);
3140
}

0 commit comments

Comments
 (0)