@math.gl/core 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/base/math-array.d.ts +1 -2
- package/dist/classes/base/math-array.js +220 -266
- package/dist/classes/base/matrix.d.ts +1 -2
- package/dist/classes/base/matrix.js +52 -53
- package/dist/classes/base/vector.d.ts +1 -2
- package/dist/classes/base/vector.js +121 -135
- package/dist/classes/euler.d.ts +2 -3
- package/dist/classes/euler.js +462 -533
- package/dist/classes/matrix3.d.ts +2 -3
- package/dist/classes/matrix3.js +185 -190
- package/dist/classes/matrix4.d.ts +1 -2
- package/dist/classes/matrix4.js +516 -452
- package/dist/classes/pose.d.ts +4 -5
- package/dist/classes/pose.js +104 -119
- package/dist/classes/quaternion.d.ts +1 -2
- package/dist/classes/quaternion.js +257 -233
- package/dist/classes/spherical-coordinates.d.ts +3 -4
- package/dist/classes/spherical-coordinates.js +138 -147
- package/dist/classes/vector2.d.ts +1 -2
- package/dist/classes/vector2.js +101 -85
- package/dist/classes/vector3.d.ts +1 -2
- package/dist/classes/vector3.js +125 -136
- package/dist/classes/vector4.d.ts +2 -3
- package/dist/classes/vector4.js +106 -114
- package/dist/gl-matrix/common.d.ts +0 -1
- package/dist/gl-matrix/common.js +38 -6
- package/dist/gl-matrix/mat3.d.ts +0 -1
- package/dist/gl-matrix/mat3.js +699 -425
- package/dist/gl-matrix/mat4.d.ts +0 -1
- package/dist/gl-matrix/mat4.js +1879 -1339
- package/dist/gl-matrix/quat.d.ts +0 -1
- package/dist/gl-matrix/quat.js +655 -257
- package/dist/gl-matrix/vec2.d.ts +0 -1
- package/dist/gl-matrix/vec2.js +529 -212
- package/dist/gl-matrix/vec3.d.ts +0 -1
- package/dist/gl-matrix/vec3.js +703 -335
- package/dist/gl-matrix/vec4.d.ts +0 -1
- package/dist/gl-matrix/vec4.js +579 -293
- package/dist/gl-matrix/wip/index.d.ts +3 -4
- package/dist/gl-matrix/wip/index.js +2 -1
- package/dist/gl-matrix/wip/mat2.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2.js +333 -157
- package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2d.js +377 -202
- package/dist/gl-matrix/wip/quat2.d.ts +0 -1
- package/dist/gl-matrix/wip/quat2.js +647 -409
- package/dist/index.cjs +60 -100
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +21 -22
- package/dist/index.js +23 -16
- package/dist/lib/assert.d.ts +0 -1
- package/dist/lib/assert.js +3 -4
- package/dist/lib/common.d.ts +2 -3
- package/dist/lib/common.js +163 -134
- package/dist/lib/gl-matrix-extras.d.ts +0 -1
- package/dist/lib/gl-matrix-extras.js +39 -36
- package/dist/lib/math-utils.d.ts +0 -1
- package/dist/lib/math-utils.js +2 -1
- package/dist/lib/validators.d.ts +0 -1
- package/dist/lib/validators.js +22 -25
- package/package.json +5 -6
- package/src/classes/matrix3.ts +1 -1
- package/dist/classes/base/math-array.d.ts.map +0 -1
- package/dist/classes/base/math-array.js.map +0 -1
- package/dist/classes/base/matrix.d.ts.map +0 -1
- package/dist/classes/base/matrix.js.map +0 -1
- package/dist/classes/base/vector.d.ts.map +0 -1
- package/dist/classes/base/vector.js.map +0 -1
- package/dist/classes/euler.d.ts.map +0 -1
- package/dist/classes/euler.js.map +0 -1
- package/dist/classes/matrix3.d.ts.map +0 -1
- package/dist/classes/matrix3.js.map +0 -1
- package/dist/classes/matrix4.d.ts.map +0 -1
- package/dist/classes/matrix4.js.map +0 -1
- package/dist/classes/pose.d.ts.map +0 -1
- package/dist/classes/pose.js.map +0 -1
- package/dist/classes/quaternion.d.ts.map +0 -1
- package/dist/classes/quaternion.js.map +0 -1
- package/dist/classes/spherical-coordinates.d.ts.map +0 -1
- package/dist/classes/spherical-coordinates.js.map +0 -1
- package/dist/classes/vector2.d.ts.map +0 -1
- package/dist/classes/vector2.js.map +0 -1
- package/dist/classes/vector3.d.ts.map +0 -1
- package/dist/classes/vector3.js.map +0 -1
- package/dist/classes/vector4.d.ts.map +0 -1
- package/dist/classes/vector4.js.map +0 -1
- package/dist/gl-matrix/common.d.ts.map +0 -1
- package/dist/gl-matrix/common.js.map +0 -1
- package/dist/gl-matrix/mat3.d.ts.map +0 -1
- package/dist/gl-matrix/mat3.js.map +0 -1
- package/dist/gl-matrix/mat4.d.ts.map +0 -1
- package/dist/gl-matrix/mat4.js.map +0 -1
- package/dist/gl-matrix/quat.d.ts.map +0 -1
- package/dist/gl-matrix/quat.js.map +0 -1
- package/dist/gl-matrix/vec2.d.ts.map +0 -1
- package/dist/gl-matrix/vec2.js.map +0 -1
- package/dist/gl-matrix/vec3.d.ts.map +0 -1
- package/dist/gl-matrix/vec3.js.map +0 -1
- package/dist/gl-matrix/vec4.d.ts.map +0 -1
- package/dist/gl-matrix/vec4.js.map +0 -1
- package/dist/gl-matrix/wip/index.d.ts.map +0 -1
- package/dist/gl-matrix/wip/index.js.map +0 -1
- package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2.js.map +0 -1
- package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2d.js.map +0 -1
- package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/quat2.js.map +0 -1
- package/dist/gl-matrix/wip/types.d.js +0 -2
- package/dist/gl-matrix/wip/types.d.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/assert.d.ts.map +0 -1
- package/dist/lib/assert.js.map +0 -1
- package/dist/lib/common.d.ts.map +0 -1
- package/dist/lib/common.js.map +0 -1
- package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
- package/dist/lib/gl-matrix-extras.js.map +0 -1
- package/dist/lib/gl-matrix.d.js +0 -2
- package/dist/lib/gl-matrix.d.js.map +0 -1
- package/dist/lib/math-utils.d.ts.map +0 -1
- package/dist/lib/math-utils.js.map +0 -1
- package/dist/lib/validators.d.ts.map +0 -1
- package/dist/lib/validators.js.map +0 -1
package/dist/classes/vector3.js
CHANGED
|
@@ -1,145 +1,134 @@
|
|
|
1
1
|
import { Vector } from "./base/vector.js";
|
|
2
2
|
import { config, isArray } from "../lib/common.js";
|
|
3
3
|
import { checkNumber } from "../lib/validators.js";
|
|
4
|
+
// @ts-ignore gl-matrix types
|
|
4
5
|
import { angle as vec3_angle, cross as vec3_cross, rotateX as vec3_rotateX, rotateY as vec3_rotateY, rotateZ as vec3_rotateZ, transformMat4 as vec3_transformMat4, transformMat3 as vec3_transformMat3, transformQuat as vec3_transformQuat } from "../gl-matrix/vec3.js";
|
|
6
|
+
/* eslint-disable camelcase */
|
|
5
7
|
import { vec3_transformMat2, vec3_transformMat4AsVector } from "../lib/gl-matrix-extras.js";
|
|
6
8
|
const ORIGIN = [0, 0, 0];
|
|
7
9
|
let ZERO;
|
|
10
|
+
/**
|
|
11
|
+
* Three-element vector class.
|
|
12
|
+
* Subclass of Array<number>
|
|
13
|
+
*/
|
|
8
14
|
export class Vector3 extends Vector {
|
|
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
|
-
object
|
|
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
|
-
origin = ORIGIN
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
transformByMatrix3(matrix3) {
|
|
130
|
-
vec3_transformMat3(this, this, matrix3);
|
|
131
|
-
return this.check();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
transformByMatrix2(matrix2) {
|
|
135
|
-
vec3_transformMat2(this, this, matrix2);
|
|
136
|
-
return this.check();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
transformByQuaternion(quaternion) {
|
|
140
|
-
vec3_transformQuat(this, this, quaternion);
|
|
141
|
-
return this.check();
|
|
142
|
-
}
|
|
143
|
-
|
|
15
|
+
static get ZERO() {
|
|
16
|
+
if (!ZERO) {
|
|
17
|
+
ZERO = new Vector3(0, 0, 0);
|
|
18
|
+
Object.freeze(ZERO);
|
|
19
|
+
}
|
|
20
|
+
return ZERO;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @class
|
|
24
|
+
* @param x
|
|
25
|
+
* @param y
|
|
26
|
+
* @param z
|
|
27
|
+
*/
|
|
28
|
+
constructor(x = 0, y = 0, z = 0) {
|
|
29
|
+
// PERF NOTE: initialize elements as double precision numbers
|
|
30
|
+
super(-0, -0, -0);
|
|
31
|
+
if (arguments.length === 1 && isArray(x)) {
|
|
32
|
+
this.copy(x);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// this.set(x, y, z);
|
|
36
|
+
if (config.debug) {
|
|
37
|
+
checkNumber(x);
|
|
38
|
+
checkNumber(y);
|
|
39
|
+
checkNumber(z);
|
|
40
|
+
}
|
|
41
|
+
// @ts-expect-error TS2412: Property '0' of type 'number | [number, number, number]' is not assignable to numeric index type 'number'
|
|
42
|
+
this[0] = x;
|
|
43
|
+
this[1] = y;
|
|
44
|
+
this[2] = z;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
set(x, y, z) {
|
|
48
|
+
this[0] = x;
|
|
49
|
+
this[1] = y;
|
|
50
|
+
this[2] = z;
|
|
51
|
+
return this.check();
|
|
52
|
+
}
|
|
53
|
+
copy(array) {
|
|
54
|
+
this[0] = array[0];
|
|
55
|
+
this[1] = array[1];
|
|
56
|
+
this[2] = array[2];
|
|
57
|
+
return this.check();
|
|
58
|
+
}
|
|
59
|
+
fromObject(object) {
|
|
60
|
+
if (config.debug) {
|
|
61
|
+
checkNumber(object.x);
|
|
62
|
+
checkNumber(object.y);
|
|
63
|
+
checkNumber(object.z);
|
|
64
|
+
}
|
|
65
|
+
this[0] = object.x;
|
|
66
|
+
this[1] = object.y;
|
|
67
|
+
this[2] = object.z;
|
|
68
|
+
return this.check();
|
|
69
|
+
}
|
|
70
|
+
toObject(object) {
|
|
71
|
+
object.x = this[0];
|
|
72
|
+
object.y = this[1];
|
|
73
|
+
object.z = this[2];
|
|
74
|
+
return object;
|
|
75
|
+
}
|
|
76
|
+
// Getters/setters
|
|
77
|
+
get ELEMENTS() {
|
|
78
|
+
return 3;
|
|
79
|
+
}
|
|
80
|
+
get z() {
|
|
81
|
+
return this[2];
|
|
82
|
+
}
|
|
83
|
+
set z(value) {
|
|
84
|
+
this[2] = checkNumber(value);
|
|
85
|
+
}
|
|
86
|
+
// ACCESSORS
|
|
87
|
+
angle(vector) {
|
|
88
|
+
return vec3_angle(this, vector);
|
|
89
|
+
}
|
|
90
|
+
// MODIFIERS
|
|
91
|
+
cross(vector) {
|
|
92
|
+
vec3_cross(this, this, vector);
|
|
93
|
+
return this.check();
|
|
94
|
+
}
|
|
95
|
+
rotateX({ radians, origin = ORIGIN }) {
|
|
96
|
+
vec3_rotateX(this, this, origin, radians);
|
|
97
|
+
return this.check();
|
|
98
|
+
}
|
|
99
|
+
rotateY({ radians, origin = ORIGIN }) {
|
|
100
|
+
vec3_rotateY(this, this, origin, radians);
|
|
101
|
+
return this.check();
|
|
102
|
+
}
|
|
103
|
+
rotateZ({ radians, origin = ORIGIN }) {
|
|
104
|
+
vec3_rotateZ(this, this, origin, radians);
|
|
105
|
+
return this.check();
|
|
106
|
+
}
|
|
107
|
+
// Transforms
|
|
108
|
+
// transforms as point (4th component is implicitly 1)
|
|
109
|
+
transform(matrix4) {
|
|
110
|
+
return this.transformAsPoint(matrix4);
|
|
111
|
+
}
|
|
112
|
+
// transforms as point (4th component is implicitly 1)
|
|
113
|
+
transformAsPoint(matrix4) {
|
|
114
|
+
vec3_transformMat4(this, this, matrix4);
|
|
115
|
+
return this.check();
|
|
116
|
+
}
|
|
117
|
+
// transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
|
|
118
|
+
transformAsVector(matrix4) {
|
|
119
|
+
vec3_transformMat4AsVector(this, this, matrix4);
|
|
120
|
+
return this.check();
|
|
121
|
+
}
|
|
122
|
+
transformByMatrix3(matrix3) {
|
|
123
|
+
vec3_transformMat3(this, this, matrix3);
|
|
124
|
+
return this.check();
|
|
125
|
+
}
|
|
126
|
+
transformByMatrix2(matrix2) {
|
|
127
|
+
vec3_transformMat2(this, this, matrix2);
|
|
128
|
+
return this.check();
|
|
129
|
+
}
|
|
130
|
+
transformByQuaternion(quaternion) {
|
|
131
|
+
vec3_transformQuat(this, this, quaternion);
|
|
132
|
+
return this.check();
|
|
133
|
+
}
|
|
144
134
|
}
|
|
145
|
-
//# sourceMappingURL=vector3.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NumericArray } from '@math.gl/types';
|
|
2
|
-
import { Vector } from
|
|
3
|
-
import type { Matrix4 } from
|
|
2
|
+
import { Vector } from "./base/vector.js";
|
|
3
|
+
import type { Matrix4 } from "./matrix4.js";
|
|
4
4
|
/**
|
|
5
5
|
* Four-element vector class.
|
|
6
6
|
* Subclass of Array<number>
|
|
@@ -38,4 +38,3 @@ export declare class Vector4 extends Vector {
|
|
|
38
38
|
transformByQuaternion(quaternion: Readonly<NumericArray>): this;
|
|
39
39
|
applyMatrix4(m: Matrix4): this;
|
|
40
40
|
}
|
|
41
|
-
//# sourceMappingURL=vector4.d.ts.map
|
package/dist/classes/vector4.js
CHANGED
|
@@ -1,122 +1,114 @@
|
|
|
1
|
+
// Copyright (c) 2017 Uber Technologies, Inc.
|
|
2
|
+
// MIT License
|
|
3
|
+
/* eslint-disable camelcase */
|
|
1
4
|
import { transformMat4 as vec4_transformMat4, transformQuat as vec4_transformQuat } from "../gl-matrix/vec3.js";
|
|
2
5
|
import { vec4_transformMat2, vec4_transformMat3 } from "../lib/gl-matrix-extras.js";
|
|
3
6
|
import { Vector } from "./base/vector.js";
|
|
4
7
|
import { config, isArray } from "../lib/common.js";
|
|
5
8
|
import { checkNumber } from "../lib/validators.js";
|
|
6
9
|
let ZERO;
|
|
10
|
+
/**
|
|
11
|
+
* Four-element vector class.
|
|
12
|
+
* Subclass of Array<number>
|
|
13
|
+
*/
|
|
7
14
|
export class Vector4 extends Vector {
|
|
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
|
-
vec4_transformMat2(this, this, matrix2);
|
|
108
|
-
return this.check();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
transformByQuaternion(quaternion) {
|
|
112
|
-
vec4_transformQuat(this, this, quaternion);
|
|
113
|
-
return this.check();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
applyMatrix4(m) {
|
|
117
|
-
m.transform(this, this);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
|
|
15
|
+
static get ZERO() {
|
|
16
|
+
if (!ZERO) {
|
|
17
|
+
ZERO = new Vector4(0, 0, 0, 0);
|
|
18
|
+
Object.freeze(ZERO);
|
|
19
|
+
}
|
|
20
|
+
return ZERO;
|
|
21
|
+
}
|
|
22
|
+
constructor(x = 0, y = 0, z = 0, w = 0) {
|
|
23
|
+
// PERF NOTE: initialize elements as double precision numbers
|
|
24
|
+
super(-0, -0, -0, -0);
|
|
25
|
+
if (isArray(x) && arguments.length === 1) {
|
|
26
|
+
this.copy(x);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// this.set(x, y, z, w);
|
|
30
|
+
if (config.debug) {
|
|
31
|
+
checkNumber(x);
|
|
32
|
+
checkNumber(y);
|
|
33
|
+
checkNumber(z);
|
|
34
|
+
checkNumber(w);
|
|
35
|
+
}
|
|
36
|
+
this[0] = x;
|
|
37
|
+
this[1] = y;
|
|
38
|
+
this[2] = z;
|
|
39
|
+
this[3] = w;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
set(x, y, z, w) {
|
|
43
|
+
this[0] = x;
|
|
44
|
+
this[1] = y;
|
|
45
|
+
this[2] = z;
|
|
46
|
+
this[3] = w;
|
|
47
|
+
return this.check();
|
|
48
|
+
}
|
|
49
|
+
copy(array) {
|
|
50
|
+
this[0] = array[0];
|
|
51
|
+
this[1] = array[1];
|
|
52
|
+
this[2] = array[2];
|
|
53
|
+
this[3] = array[3];
|
|
54
|
+
return this.check();
|
|
55
|
+
}
|
|
56
|
+
fromObject(object) {
|
|
57
|
+
if (config.debug) {
|
|
58
|
+
checkNumber(object.x);
|
|
59
|
+
checkNumber(object.y);
|
|
60
|
+
checkNumber(object.z);
|
|
61
|
+
checkNumber(object.w);
|
|
62
|
+
}
|
|
63
|
+
this[0] = object.x;
|
|
64
|
+
this[1] = object.y;
|
|
65
|
+
this[2] = object.z;
|
|
66
|
+
this[3] = object.w;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
toObject(object) {
|
|
70
|
+
object.x = this[0];
|
|
71
|
+
object.y = this[1];
|
|
72
|
+
object.z = this[2];
|
|
73
|
+
object.w = this[3];
|
|
74
|
+
return object;
|
|
75
|
+
}
|
|
76
|
+
// Getters/setters
|
|
77
|
+
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
|
|
78
|
+
get ELEMENTS() {
|
|
79
|
+
return 4;
|
|
80
|
+
}
|
|
81
|
+
get z() {
|
|
82
|
+
return this[2];
|
|
83
|
+
}
|
|
84
|
+
set z(value) {
|
|
85
|
+
this[2] = checkNumber(value);
|
|
86
|
+
}
|
|
87
|
+
get w() {
|
|
88
|
+
return this[3];
|
|
89
|
+
}
|
|
90
|
+
set w(value) {
|
|
91
|
+
this[3] = checkNumber(value);
|
|
92
|
+
}
|
|
93
|
+
transform(matrix4) {
|
|
94
|
+
vec4_transformMat4(this, this, matrix4);
|
|
95
|
+
return this.check();
|
|
96
|
+
}
|
|
97
|
+
transformByMatrix3(matrix3) {
|
|
98
|
+
vec4_transformMat3(this, this, matrix3);
|
|
99
|
+
return this.check();
|
|
100
|
+
}
|
|
101
|
+
transformByMatrix2(matrix2) {
|
|
102
|
+
vec4_transformMat2(this, this, matrix2);
|
|
103
|
+
return this.check();
|
|
104
|
+
}
|
|
105
|
+
transformByQuaternion(quaternion) {
|
|
106
|
+
vec4_transformQuat(this, this, quaternion);
|
|
107
|
+
return this.check();
|
|
108
|
+
}
|
|
109
|
+
// three.js compatibility
|
|
110
|
+
applyMatrix4(m) {
|
|
111
|
+
m.transform(this, this);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
121
114
|
}
|
|
122
|
-
//# sourceMappingURL=vector4.js.map
|
package/dist/gl-matrix/common.js
CHANGED
|
@@ -1,19 +1,51 @@
|
|
|
1
|
+
// @eslint-disable
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* Common utilities
|
|
5
|
+
* @module glMatrix
|
|
6
|
+
*/
|
|
7
|
+
// Configuration Constants
|
|
1
8
|
export const EPSILON = 0.000001;
|
|
2
9
|
export let ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
3
10
|
export const RANDOM = Math.random;
|
|
4
11
|
export const ANGLE_ORDER = 'zyx';
|
|
12
|
+
/**
|
|
13
|
+
* Symmetric round
|
|
14
|
+
* see https://www.npmjs.com/package/round-half-up-symmetric#user-content-detailed-background
|
|
15
|
+
*
|
|
16
|
+
* @param {Number} a value to round
|
|
17
|
+
*/
|
|
5
18
|
export function round(a) {
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
if (a >= 0)
|
|
20
|
+
return Math.round(a);
|
|
21
|
+
return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
|
|
8
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Sets the type of array used when creating new vectors and matrices
|
|
25
|
+
*
|
|
26
|
+
* @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array
|
|
27
|
+
*/
|
|
9
28
|
export function setMatrixArrayType(type) {
|
|
10
|
-
|
|
29
|
+
ARRAY_TYPE = type;
|
|
11
30
|
}
|
|
12
31
|
const degree = Math.PI / 180;
|
|
32
|
+
/**
|
|
33
|
+
* Convert Degree To Radian
|
|
34
|
+
*
|
|
35
|
+
* @param {Number} a Angle in Degrees
|
|
36
|
+
*/
|
|
13
37
|
export function toRadian(a) {
|
|
14
|
-
|
|
38
|
+
return a * degree;
|
|
15
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Tests whether or not the arguments have approximately the same value, within an absolute
|
|
42
|
+
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
|
|
43
|
+
* than or equal to 1.0, and a relative tolerance is used for larger values)
|
|
44
|
+
*
|
|
45
|
+
* @param {Number} a The first number to test.
|
|
46
|
+
* @param {Number} b The second number to test.
|
|
47
|
+
* @returns {Boolean} True if the numbers are approximately equal, false otherwise.
|
|
48
|
+
*/
|
|
16
49
|
export function equals(a, b) {
|
|
17
|
-
|
|
50
|
+
return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
|
|
18
51
|
}
|
|
19
|
-
//# sourceMappingURL=common.js.map
|
package/dist/gl-matrix/mat3.d.ts
CHANGED