@math.gl/core 4.0.0-beta.1 → 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumericArray } from '@math.gl/types';
|
|
2
|
-
import { ConfigurationOptions } from
|
|
2
|
+
import { ConfigurationOptions } from "../../lib/common.js";
|
|
3
3
|
/** Base class for vectors and matrices */
|
|
4
4
|
export declare abstract class MathArray extends Array<number> {
|
|
5
5
|
/** Number of elements (values) in this array */
|
|
@@ -64,4 +64,3 @@ export declare abstract class MathArray extends Array<number> {
|
|
|
64
64
|
/** @deprecated */
|
|
65
65
|
get elements(): NumericArray;
|
|
66
66
|
}
|
|
67
|
-
//# sourceMappingURL=math-array.d.ts.map
|
|
@@ -1,269 +1,223 @@
|
|
|
1
|
-
function _extendableBuiltin(cls) {
|
|
2
|
-
function ExtendableBuiltin() {
|
|
3
|
-
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
4
|
-
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
|
|
5
|
-
return instance;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
9
|
-
constructor: {
|
|
10
|
-
value: cls,
|
|
11
|
-
enumerable: false,
|
|
12
|
-
writable: true,
|
|
13
|
-
configurable: true
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (Object.setPrototypeOf) {
|
|
18
|
-
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
19
|
-
} else {
|
|
20
|
-
ExtendableBuiltin.__proto__ = cls;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return ExtendableBuiltin;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
1
|
import { config, formatValue, equals, isArray } from "../../lib/common.js";
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return this.check();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
divideScalar(a) {
|
|
253
|
-
return this.multiplyByScalar(1 / a);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
clampScalar(min, max) {
|
|
257
|
-
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
258
|
-
this[i] = Math.min(Math.max(this[i], min), max);
|
|
2
|
+
/** Base class for vectors and matrices */
|
|
3
|
+
export class MathArray extends Array {
|
|
4
|
+
// Common methods
|
|
5
|
+
/**
|
|
6
|
+
* Clone the current object
|
|
7
|
+
* @returns a new copy of this object
|
|
8
|
+
*/
|
|
9
|
+
clone() {
|
|
10
|
+
// @ts-expect-error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
|
11
|
+
return new this.constructor().copy(this); // eslint-disable-line
|
|
12
|
+
}
|
|
13
|
+
fromArray(array, offset = 0) {
|
|
14
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
15
|
+
this[i] = array[i + offset];
|
|
16
|
+
}
|
|
17
|
+
return this.check();
|
|
18
|
+
}
|
|
19
|
+
toArray(targetArray = [], offset = 0) {
|
|
20
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
21
|
+
targetArray[offset + i] = this[i];
|
|
22
|
+
}
|
|
23
|
+
return targetArray;
|
|
24
|
+
}
|
|
25
|
+
toObject(targetObject) {
|
|
26
|
+
return targetObject;
|
|
27
|
+
}
|
|
28
|
+
from(arrayOrObject) {
|
|
29
|
+
return Array.isArray(arrayOrObject)
|
|
30
|
+
? this.copy(arrayOrObject)
|
|
31
|
+
: // @ts-ignore
|
|
32
|
+
this.fromObject(arrayOrObject);
|
|
33
|
+
}
|
|
34
|
+
to(arrayOrObject) {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
if (arrayOrObject === this) {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
// @ts-expect-error TS2339: Property 'toObject' does not exist on type 'MathArray'.
|
|
40
|
+
return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
|
|
41
|
+
}
|
|
42
|
+
toTarget(target) {
|
|
43
|
+
return target ? this.to(target) : this;
|
|
44
|
+
}
|
|
45
|
+
/** @deprecated */
|
|
46
|
+
toFloat32Array() {
|
|
47
|
+
return new Float32Array(this);
|
|
48
|
+
}
|
|
49
|
+
toString() {
|
|
50
|
+
return this.formatString(config);
|
|
51
|
+
}
|
|
52
|
+
/** Formats string according to options */
|
|
53
|
+
formatString(opts) {
|
|
54
|
+
let string = '';
|
|
55
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
56
|
+
string += (i > 0 ? ', ' : '') + formatValue(this[i], opts);
|
|
57
|
+
}
|
|
58
|
+
return `${opts.printTypes ? this.constructor.name : ''}[${string}]`;
|
|
59
|
+
}
|
|
60
|
+
equals(array) {
|
|
61
|
+
if (!array || this.length !== array.length) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
65
|
+
if (!equals(this[i], array[i])) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
exactEquals(array) {
|
|
72
|
+
if (!array || this.length !== array.length) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
76
|
+
if (this[i] !== array[i]) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
// Modifiers
|
|
83
|
+
/** Negates all values in this object */
|
|
84
|
+
negate() {
|
|
85
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
86
|
+
this[i] = -this[i];
|
|
87
|
+
}
|
|
88
|
+
return this.check();
|
|
89
|
+
}
|
|
90
|
+
lerp(a, b, t) {
|
|
91
|
+
if (t === undefined) {
|
|
92
|
+
return this.lerp(this, a, b);
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
95
|
+
const ai = a[i];
|
|
96
|
+
const endValue = typeof b === 'number' ? b : b[i];
|
|
97
|
+
this[i] = ai + t * (endValue - ai);
|
|
98
|
+
}
|
|
99
|
+
return this.check();
|
|
100
|
+
}
|
|
101
|
+
/** Minimal */
|
|
102
|
+
min(vector) {
|
|
103
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
104
|
+
this[i] = Math.min(vector[i], this[i]);
|
|
105
|
+
}
|
|
106
|
+
return this.check();
|
|
107
|
+
}
|
|
108
|
+
/** Maximal */
|
|
109
|
+
max(vector) {
|
|
110
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
111
|
+
this[i] = Math.max(vector[i], this[i]);
|
|
112
|
+
}
|
|
113
|
+
return this.check();
|
|
114
|
+
}
|
|
115
|
+
clamp(minVector, maxVector) {
|
|
116
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
117
|
+
this[i] = Math.min(Math.max(this[i], minVector[i]), maxVector[i]);
|
|
118
|
+
}
|
|
119
|
+
return this.check();
|
|
120
|
+
}
|
|
121
|
+
add(...vectors) {
|
|
122
|
+
for (const vector of vectors) {
|
|
123
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
124
|
+
this[i] += vector[i];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return this.check();
|
|
128
|
+
}
|
|
129
|
+
subtract(...vectors) {
|
|
130
|
+
for (const vector of vectors) {
|
|
131
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
132
|
+
this[i] -= vector[i];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return this.check();
|
|
136
|
+
}
|
|
137
|
+
scale(scale) {
|
|
138
|
+
if (typeof scale === 'number') {
|
|
139
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
140
|
+
this[i] *= scale;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
for (let i = 0; i < this.ELEMENTS && i < scale.length; ++i) {
|
|
145
|
+
this[i] *= scale[i];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return this.check();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Multiplies all elements by `scale`
|
|
152
|
+
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
153
|
+
*/
|
|
154
|
+
multiplyByScalar(scalar) {
|
|
155
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
156
|
+
this[i] *= scalar;
|
|
157
|
+
}
|
|
158
|
+
return this.check();
|
|
159
|
+
}
|
|
160
|
+
// Debug checks
|
|
161
|
+
/** Throws an error if array length is incorrect or contains illegal values */
|
|
162
|
+
check() {
|
|
163
|
+
if (config.debug && !this.validate()) {
|
|
164
|
+
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
|
|
165
|
+
}
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
/** Returns false if the array length is incorrect or contains illegal values */
|
|
169
|
+
validate() {
|
|
170
|
+
let valid = this.length === this.ELEMENTS;
|
|
171
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
172
|
+
valid = valid && Number.isFinite(this[i]);
|
|
173
|
+
}
|
|
174
|
+
return valid;
|
|
175
|
+
}
|
|
176
|
+
// three.js compatibility
|
|
177
|
+
/** @deprecated */
|
|
178
|
+
sub(a) {
|
|
179
|
+
return this.subtract(a);
|
|
180
|
+
}
|
|
181
|
+
/** @deprecated */
|
|
182
|
+
setScalar(a) {
|
|
183
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
184
|
+
this[i] = a;
|
|
185
|
+
}
|
|
186
|
+
return this.check();
|
|
187
|
+
}
|
|
188
|
+
/** @deprecated */
|
|
189
|
+
addScalar(a) {
|
|
190
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
191
|
+
this[i] += a;
|
|
192
|
+
}
|
|
193
|
+
return this.check();
|
|
194
|
+
}
|
|
195
|
+
/** @deprecated */
|
|
196
|
+
subScalar(a) {
|
|
197
|
+
return this.addScalar(-a);
|
|
198
|
+
}
|
|
199
|
+
/** @deprecated */
|
|
200
|
+
multiplyScalar(scalar) {
|
|
201
|
+
// Multiplies all elements
|
|
202
|
+
// `Matrix4.scale` only scales its 3x3 "minor"
|
|
203
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
204
|
+
this[i] *= scalar;
|
|
205
|
+
}
|
|
206
|
+
return this.check();
|
|
207
|
+
}
|
|
208
|
+
/** @deprecated */
|
|
209
|
+
divideScalar(a) {
|
|
210
|
+
return this.multiplyByScalar(1 / a);
|
|
211
|
+
}
|
|
212
|
+
/** @deprecated */
|
|
213
|
+
clampScalar(min, max) {
|
|
214
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
215
|
+
this[i] = Math.min(Math.max(this[i], min), max);
|
|
216
|
+
}
|
|
217
|
+
return this.check();
|
|
218
|
+
}
|
|
219
|
+
/** @deprecated */
|
|
220
|
+
get elements() {
|
|
221
|
+
return this;
|
|
259
222
|
}
|
|
260
|
-
|
|
261
|
-
return this.check();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
get elements() {
|
|
265
|
-
return this;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
223
|
}
|
|
269
|
-
//# sourceMappingURL=math-array.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumericArray } from '@math.gl/types';
|
|
2
|
-
import { MathArray } from
|
|
2
|
+
import { MathArray } from "./math-array.js";
|
|
3
3
|
/** Base class for matrices */
|
|
4
4
|
export declare abstract class Matrix extends MathArray {
|
|
5
5
|
abstract get RANK(): number;
|
|
@@ -11,4 +11,3 @@ export declare abstract class Matrix extends MathArray {
|
|
|
11
11
|
getColumn(columnIndex: number): number[];
|
|
12
12
|
setColumn(columnIndex: number, columnVector: Readonly<NumericArray>): this;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=matrix.d.ts.map
|
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
import { MathArray } from "./math-array.js";
|
|
2
2
|
import { checkNumber } from "../../lib/validators.js";
|
|
3
3
|
import { config } from "../../lib/common.js";
|
|
4
|
+
/** Base class for matrices */
|
|
4
5
|
export class Matrix extends MathArray {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// fromObject(object) {
|
|
7
|
+
// const array = object.elements;
|
|
8
|
+
// return this.fromRowMajor(array);
|
|
9
|
+
// }
|
|
10
|
+
// toObject(object) {
|
|
11
|
+
// const array = object.elements;
|
|
12
|
+
// this.toRowMajor(array);
|
|
13
|
+
// return object;
|
|
14
|
+
// }
|
|
15
|
+
// TODO better override formatString?
|
|
16
|
+
toString() {
|
|
17
|
+
let string = '[';
|
|
18
|
+
if (config.printRowMajor) {
|
|
19
|
+
string += 'row-major:';
|
|
20
|
+
for (let row = 0; row < this.RANK; ++row) {
|
|
21
|
+
for (let col = 0; col < this.RANK; ++col) {
|
|
22
|
+
string += ` ${this[col * this.RANK + row]}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
else {
|
|
27
|
+
string += 'column-major:';
|
|
28
|
+
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
29
|
+
string += ` ${this[i]}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
string += ']';
|
|
33
|
+
return string;
|
|
34
|
+
}
|
|
35
|
+
getElementIndex(row, col) {
|
|
36
|
+
return col * this.RANK + row;
|
|
37
|
+
}
|
|
38
|
+
// By default assumes row major indices
|
|
39
|
+
getElement(row, col) {
|
|
40
|
+
return this[col * this.RANK + row];
|
|
22
41
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getElementIndex(row, col) {
|
|
29
|
-
return col * this.RANK + row;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getElement(row, col) {
|
|
33
|
-
return this[col * this.RANK + row];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setElement(row, col, value) {
|
|
37
|
-
this[col * this.RANK + row] = checkNumber(value);
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
|
|
42
|
-
const firstIndex = columnIndex * this.RANK;
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < this.RANK; ++i) {
|
|
45
|
-
result[i] = this[firstIndex + i];
|
|
42
|
+
// By default assumes row major indices
|
|
43
|
+
setElement(row, col, value) {
|
|
44
|
+
this[col * this.RANK + row] = checkNumber(value);
|
|
45
|
+
return this;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
|
|
48
|
+
const firstIndex = columnIndex * this.RANK;
|
|
49
|
+
for (let i = 0; i < this.RANK; ++i) {
|
|
50
|
+
result[i] = this[firstIndex + i];
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
setColumn(columnIndex, columnVector) {
|
|
55
|
+
const firstIndex = columnIndex * this.RANK;
|
|
56
|
+
for (let i = 0; i < this.RANK; ++i) {
|
|
57
|
+
this[firstIndex + i] = columnVector[i];
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
56
60
|
}
|
|
57
|
-
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
61
|
}
|
|
62
|
-
//# sourceMappingURL=matrix.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumericArray } from '@math.gl/types';
|
|
2
|
-
import { MathArray } from
|
|
2
|
+
import { MathArray } from "./math-array.js";
|
|
3
3
|
/** Base class for vectors with at least 2 elements */
|
|
4
4
|
export declare abstract class Vector extends MathArray {
|
|
5
5
|
get x(): number;
|
|
@@ -41,4 +41,3 @@ export declare abstract class Vector extends MathArray {
|
|
|
41
41
|
multiplyVectors(a: Readonly<NumericArray>, b: Readonly<NumericArray>): this;
|
|
42
42
|
addScaledVector(a: Readonly<NumericArray>, b: number): this;
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=vector.d.ts.map
|