-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.js
More file actions
45 lines (40 loc) · 901 Bytes
/
cube.js
File metadata and controls
45 lines (40 loc) · 901 Bytes
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
44
45
function vec3d(x = 0, y = 0, z = 0, w = 1) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
function triangle(
a = 0,
b = 0,
c = 0,
d = 0,
e = 0,
f = 0,
g = 0,
h = 0,
i = 0
) {
this.p = [new vec3d(a, b, c), new vec3d(d, e, f), new vec3d(g, h, i)];
this.c = 'white';
}
var cube = [
// SOUTH
new triangle(0, 0, 0, 0, 1, 0, 1, 1, 0),
new triangle(0, 0, 0, 1, 1, 0, 1, 0, 0),
// EAST
new triangle(1, 0, 0, 1, 1, 0, 1, 1, 1),
new triangle(1, 0, 0, 1, 1, 1, 1, 0, 1),
// NORTH
new triangle(1, 0, 1, 1, 1, 1, 0, 1, 1),
new triangle(1, 0, 1, 0, 1, 1, 0, 0, 1),
// WEST
new triangle(0, 0, 1, 0, 1, 1, 0, 1, 0),
new triangle(0, 0, 1, 0, 1, 0, 0, 0, 0),
// TOP
new triangle(0, 1, 0, 0, 1, 1, 1, 1, 1),
new triangle(0, 1, 0, 1, 1, 1, 1, 1, 0),
// BOTTOM
new triangle(1, 0, 1, 0, 0, 1, 0, 0, 0),
new triangle(1, 0, 1, 0, 0, 0, 1, 0, 0),
];