-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.js
118 lines (109 loc) · 1.99 KB
/
object.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class Cube
{
constructor(w,h,l)
{
this.w = w;
this.h = h;
this.l = l;
this.vertices = make_cube(w,h,l);
this.normals = [
// left column back
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, 0, -1,
// right
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
// top
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
// bottom
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, -1, 0,
// left
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
// right
1, 0, 0,
1, 0, 0,
1, 0, 0,
1, 0, 0,
1, 0, 0,
1, 0, 0,
];
this.tmatrix = make_tmatrix(0,0,0);
this.rmatrix = make_tmatrix(0,0,0);
this.smatrix = make_tmatrix(0,0,0);
}
}
class Square
{
constructor()
{
this.vertices =
[
1,1,0,
-1,1,0,
-1,-1,0,
1,1,0,
-1,-1,0,
1,-1,0
];
this.normals =
[
1,1,1,
1,1,1,
1,1,1,
1,1,1,
1,1,1,
1,1,1,
];
}
}
var base = new Cube(1,0.15,1);
var lower_arm = new Cube(0.2,1,0.2);
var upper_arm = new Cube(0.12,0.7,0.12);
var ball = new Square();
var background = new Cube(50,50,1);
var table = new Cube(20,3,15);
var rock = new Cube(0.175,0.175,0.175);
var camx = 0;
var camy = 4;
var camz = 6;
var camlx = 0;
var camly = 1.5;
var camlz = 0;
var lowr = 0;
var interval = 30;
var upr = 0;
var rockx,rocky,rockz = 0;
var rockrx,rockry,rockrz;
var key_frame = 0;
var rock_hold = false;
var rock_mat;
var rock_fall;
function next_key(inter)
{
interval = inter;
key_frame += 1;
time = 0;
}