-
Notifications
You must be signed in to change notification settings - Fork 46
/
quat.ts
37 lines (36 loc) · 1.41 KB
/
quat.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
import { quat } from "gl-matrix"
export class Quat {
static set(x: number, y: number, z: number, w: number, out = new Float32Array(4)) {
return <Float32Array>quat.set(out, x, y, z, w)
}
static fromValues(x: number, y: number, z: number, w: number) {
return <Float32Array>quat.fromValues(x, y, z, w)
}
static create() {
return <Float32Array>quat.create()
}
static normalize(a: Float32Array, out = new Float32Array(4)) {
return <Float32Array>quat.normalize(out, a)
}
static slerp(a: Float32Array, b: Float32Array, t: number, out = new Float32Array(4)) {
return <Float32Array>quat.slerp(out, a, b, t)
}
static fromEuler(x: number, y: number, z: number, out = new Float32Array(4)) {
return <Float32Array>quat.fromEuler(out, x, y, z)
}
static conjugate(a: Float32Array, out = new Float32Array(4)) {
return <Float32Array>quat.conjugate(out, a)
}
static rotateX(a: Float32Array, rad: number, out = new Float32Array(4)) {
return <Float32Array>quat.rotateX(out, a, rad)
}
static rotateY(a: Float32Array, rad: number, out = new Float32Array(4)) {
return <Float32Array>quat.rotateY(out, a, rad)
}
static rotateZ(a: Float32Array, rad: number, out = new Float32Array(4)) {
return <Float32Array>quat.rotateZ(out, a, rad)
}
static rotationTo(from: Float32Array, to: Float32Array, out = new Float32Array(4)) {
return <Float32Array>quat.rotationTo(out, from, to);
}
}