forked from yudhik11/WebGL-TunnelRush
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.js
More file actions
75 lines (65 loc) · 2.29 KB
/
vector.js
File metadata and controls
75 lines (65 loc) · 2.29 KB
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
// Preventing Pressing of arrow keys from scrolling the page
window.addEventListener("keydown", function(e) {
// space and arrow keys
if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
function matrixMultiply(mat2, mat1)
{
return [
mat1[0]*mat2[0]+mat1[1]*mat2[4]+mat1[2]*mat2[8]+mat1[3]*mat2[12],
mat1[0]*mat2[1]+mat1[1]*mat2[5]+mat1[2]*mat2[9]+mat1[3]*mat2[13],
mat1[0]*mat2[2]+mat1[1]*mat2[6]+mat1[2]*mat2[10]+mat1[3]*mat2[14],
mat1[0]*mat2[3]+mat1[1]*mat2[7]+mat1[2]*mat2[11]+mat1[3]*mat2[15],
mat1[4]*mat2[0]+mat1[5]*mat2[4]+mat1[6]*mat2[8]+mat1[7]*mat2[12],
mat1[4]*mat2[1]+mat1[5]*mat2[5]+mat1[6]*mat2[9]+mat1[7]*mat2[13],
mat1[4]*mat2[2]+mat1[5]*mat2[6]+mat1[6]*mat2[10]+mat1[7]*mat2[14],
mat1[4]*mat2[3]+mat1[5]*mat2[7]+mat1[6]*mat2[11]+mat1[7]*mat2[15],
mat1[8]*mat2[0]+mat1[9]*mat2[4]+mat1[10]*mat2[8]+mat1[11]*mat2[12],
mat1[8]*mat2[1]+mat1[9]*mat2[5]+mat1[10]*mat2[9]+mat1[11]*mat2[13],
mat1[8]*mat2[2]+mat1[9]*mat2[6]+mat1[10]*mat2[10]+mat1[11]*mat2[14],
mat1[8]*mat2[3]+mat1[9]*mat2[7]+mat1[10]*mat2[11]+mat1[11]*mat2[15],
mat1[12]*mat2[0]+mat1[13]*mat2[4]+mat1[14]*mat2[8]+mat1[15]*mat2[12],
mat1[12]*mat2[1]+mat1[13]*mat2[5]+mat1[14]*mat2[9]+mat1[15]*mat2[13],
mat1[12]*mat2[2]+mat1[13]*mat2[6]+mat1[14]*mat2[10]+mat1[15]*mat2[14],
mat1[12]*mat2[3]+mat1[13]*mat2[7]+mat1[14]*mat2[11]+mat1[15]*mat2[15]
];
}
function randint(max_value){
return Math.floor(Math.random()*max_value);
}
mat4.toInverseMat3 = function(a, b) {
var c = a[0],
d = a[1],
e = a[2],
g = a[4],
f = a[5],
h = a[6],
i = a[8],
j = a[9],
k = a[10],
l = k * f - h * j,
o = -k * g + h * i,
m = j * g - f * i,
n = c * l + d * o + e * m;
if (!n) return null;
n = 1 / n;
b || (b = mat3.create());
b[0] = l * n;
b[1] = (-k * d + e * j) * n;
b[2] = (h * d - e * f) * n;
b[3] = o * n;
b[4] = (k * c - e * i) * n;
b[5] = (-h * c + e * g) * n;
b[6] = m * n;
b[7] = (-j * c + d * i) * n;
b[8] = (f * c - d * g) * n;
return b
};
function path(cord){
var new_cord = cord;
new_cord[1] += Math.sin(Math.PI*new_cord[2]/7);
// new_cord[0] += Math.sin(new_cord[2]/1000);
return new_cord;
}