-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
35 lines (34 loc) · 950 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
const e = Math.exp(1);
let cam;
let cubes = [];
let spacing = 100;
let nums;
function setup() {
nums = createVector(10, 10);
colorMode(HSB, nums.x * nums.y, 1, 1);
createCanvas(500, 400, WEBGL);
cam = createEasyCam();
cam.state.distance = 2000;
cam.state.center = [width / 1.5, height / 2, 0];
cam.state_reset.distance = 2000;
cam.state_reset.center = [width / 1.5, height / 2, 0];
for (var j = 0; j < nums.x; j++) {
cubes.push([]);
for (var i = 0; i < nums.y; i++) {
cubes[j].push(new Cube(i * spacing, width / 2, (j - 4) * spacing, spacing, map(i + j, 0, 6, 0, PI)));
}
}
}
function draw() {
background(0);
rotateX(-atan(cos(QUARTER_PI)));
rotateY(-QUARTER_PI);
directionalLight(255, 255, 255, -1, 1, -1);
for (var j = 0; j < nums.x; j++) {
for (var i = 0; i < nums.y; i++) {
fill(i + j * nums.x, 1, 1);
cubes[i][j].update(z => cos(z) * sin(z));
cubes[i][j].render();
}
}
}