forked from dionyziz/canvas-cube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cube.js
35 lines (31 loc) · 843 Bytes
/
cube.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
var points = [];
var STEP = 0.1;
var DELTA_THETA = 0.01 / 40,
DELTA_PHI = 0.027 / 40;
function init() {
for (var x = -0.5; x <= 0.5; x += STEP) {
for (var y = -0.5; y <= 0.5; y += STEP) {
for (var z = -0.5; z <= 0.5; z += STEP) {
if (Math.abs(x) == 0.5
|| Math.abs(y) == 0.5
|| Math.abs(z) == 0.5) {
points.push(
new Vector(
x, y, z
)
);
}
}
}
}
}
function integrate(t, dt) {
for (var i = 0; i < points.length; ++i) {
points[i] = points[i].rotateY(
DELTA_THETA * dt * Math.sin(t / 4000)
).rotateX(
DELTA_PHI * dt * Math.cos(t / 9000)
);
}
}
init();