-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
43 lines (37 loc) · 860 Bytes
/
sketch.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
let boxes = [];
let z, cam;
const boxsize = 20;
function setup() {
cam = new Cam(0, 0, 0, 5);
z = (500 / 2.0) / tan(PI / 6);
createCanvas(windowWidth, windowHeight, WEBGL)
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
for (let z = 0; z < 10; z++) {
let b = new Box(x * boxsize, y * boxsize, z * boxsize);
boxes.push(b);
}
}
}
}
function draw() {
let accs = [
createVector(random(-.1, .1), 0, 0),
createVector(0, random(-.1, .1), 0),
createVector(0, 0, random(-.1, .1)),
createVector(0, 0, 0)
];
cam.update();
cam.show();
randomBox = random(boxes);
if (randomBox.acc) {
randomBox.vel = createVector(0, 0, 0);
randomBox.acc = null;
} else {
randomBox.acc = accs[floor(random(3))];
}
for (let box of boxes) {
box.update();
box.draw();
}
}