-
Notifications
You must be signed in to change notification settings - Fork 46
/
mat4.ts
76 lines (75 loc) · 3.26 KB
/
mat4.ts
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
import { mat4 } from "gl-matrix"
export class Mat4 {
static getTranslation(mat: Float32Array, out = new Float32Array(3)) {
return <Float32Array>mat4.getTranslation(out, mat)
}
static create() {
return <Float32Array>mat4.create()
}
static translate(mat: Float32Array, v: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.translate(out, mat, v)
}
static getScaling(mat: Float32Array, out = new Float32Array(3)) {
return <Float32Array>mat4.getScaling(out, mat)
}
static getRotation(mat: Float32Array, out = new Float32Array(4)) {
return <Float32Array>mat4.getRotation(out, mat)
}
static copy(a: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.copy(out, a)
}
static fromQuat(q: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.fromQuat(out, q)
}
static fromRotationTranslationScale(q: Float32Array, v: Float32Array, s: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.fromRotationTranslationScale(out, q, v, s)
}
static fromRotation(rad: number, axis: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.fromRotation(out, rad, axis)
}
static fromScaling(v: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.fromScaling(out, v)
}
static fromTranslation(v: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.fromTranslation(out, v)
}
static multiply(a: Float32Array, b: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.multiply(out, a, b)
}
static lookAt(eye: Float32Array, center: Float32Array, up: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.lookAt(out, eye, center, up)
}
static identity(out = new Float32Array(16)) {
return <Float32Array>mat4.identity(out)
}
static perspective(fovy: number, aspect: number, near: number, far: number, out = new Float32Array(16)) {
return <Float32Array>mat4.perspective(out, fovy, aspect, near, far)
}
static ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, out = new Float32Array(16)) {
return <Float32Array>mat4.ortho(out, left, right, bottom, top, near, far)
}
static invert(a: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.invert(out, a)
}
static transpose(a: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.transpose(out, a)
}
static targetTo(eye: Float32Array, target: Float32Array, up: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.targetTo(out, eye, target, up)
}
static rotateX(a: Float32Array, rad: number, out = new Float32Array(16)) {
return <Float32Array>mat4.rotateX(out, a, rad)
}
static rotateY(a: Float32Array, rad: number, out = new Float32Array(16)) {
return <Float32Array>mat4.rotateY(out, a, rad)
}
static rotateZ(a: Float32Array, rad: number, out = new Float32Array(16)) {
return <Float32Array>mat4.rotateZ(out, a, rad)
}
static rotate(a: Float32Array, rad: number, axis: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.rotate(out, a, rad, axis)
}
static scale(a: Float32Array, v: Float32Array, out = new Float32Array(16)) {
return <Float32Array>mat4.scale(out, a, v)
}
}