@loaders.gl/tiles 4.3.0-alpha.7 → 4.3.0-alpha.8
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/dist.dev.js +488 -173
- package/dist/dist.min.js +1 -1
- package/package.json +8 -8
package/dist/dist.dev.js
CHANGED
|
@@ -76,17 +76,11 @@ var __exports__ = (() => {
|
|
|
76
76
|
printRowMajor: true,
|
|
77
77
|
_cartographicRadians: false
|
|
78
78
|
};
|
|
79
|
-
globalThis.mathgl = globalThis.mathgl || {
|
|
80
|
-
config: {
|
|
81
|
-
...DEFAULT_CONFIG
|
|
82
|
-
}
|
|
83
|
-
};
|
|
79
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
84
80
|
var config = globalThis.mathgl.config;
|
|
85
|
-
function formatValue(value, {
|
|
86
|
-
precision = config.precision
|
|
87
|
-
} = {}) {
|
|
81
|
+
function formatValue(value, { precision = config.precision } = {}) {
|
|
88
82
|
value = round(value);
|
|
89
|
-
return
|
|
83
|
+
return `${parseFloat(value.toPrecision(precision))}`;
|
|
90
84
|
}
|
|
91
85
|
function isArray(value) {
|
|
92
86
|
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
@@ -157,28 +151,12 @@ var __exports__ = (() => {
|
|
|
157
151
|
}
|
|
158
152
|
|
|
159
153
|
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
167
|
-
constructor: {
|
|
168
|
-
value: cls,
|
|
169
|
-
enumerable: false,
|
|
170
|
-
writable: true,
|
|
171
|
-
configurable: true
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
if (Object.setPrototypeOf) {
|
|
175
|
-
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
176
|
-
} else {
|
|
177
|
-
ExtendableBuiltin.__proto__ = cls;
|
|
178
|
-
}
|
|
179
|
-
return ExtendableBuiltin;
|
|
180
|
-
}
|
|
181
|
-
var MathArray = class extends _extendableBuiltin(Array) {
|
|
154
|
+
var MathArray = class extends Array {
|
|
155
|
+
// Common methods
|
|
156
|
+
/**
|
|
157
|
+
* Clone the current object
|
|
158
|
+
* @returns a new copy of this object
|
|
159
|
+
*/
|
|
182
160
|
clone() {
|
|
183
161
|
return new this.constructor().copy(this);
|
|
184
162
|
}
|
|
@@ -198,7 +176,10 @@ var __exports__ = (() => {
|
|
|
198
176
|
return targetObject;
|
|
199
177
|
}
|
|
200
178
|
from(arrayOrObject) {
|
|
201
|
-
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) :
|
|
179
|
+
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
this.fromObject(arrayOrObject)
|
|
182
|
+
);
|
|
202
183
|
}
|
|
203
184
|
to(arrayOrObject) {
|
|
204
185
|
if (arrayOrObject === this) {
|
|
@@ -209,18 +190,20 @@ var __exports__ = (() => {
|
|
|
209
190
|
toTarget(target) {
|
|
210
191
|
return target ? this.to(target) : this;
|
|
211
192
|
}
|
|
193
|
+
/** @deprecated */
|
|
212
194
|
toFloat32Array() {
|
|
213
195
|
return new Float32Array(this);
|
|
214
196
|
}
|
|
215
197
|
toString() {
|
|
216
198
|
return this.formatString(config);
|
|
217
199
|
}
|
|
200
|
+
/** Formats string according to options */
|
|
218
201
|
formatString(opts) {
|
|
219
202
|
let string = "";
|
|
220
203
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
221
204
|
string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
|
|
222
205
|
}
|
|
223
|
-
return
|
|
206
|
+
return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
|
|
224
207
|
}
|
|
225
208
|
equals(array) {
|
|
226
209
|
if (!array || this.length !== array.length) {
|
|
@@ -244,6 +227,8 @@ var __exports__ = (() => {
|
|
|
244
227
|
}
|
|
245
228
|
return true;
|
|
246
229
|
}
|
|
230
|
+
// Modifiers
|
|
231
|
+
/** Negates all values in this object */
|
|
247
232
|
negate() {
|
|
248
233
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
249
234
|
this[i] = -this[i];
|
|
@@ -261,12 +246,14 @@ var __exports__ = (() => {
|
|
|
261
246
|
}
|
|
262
247
|
return this.check();
|
|
263
248
|
}
|
|
249
|
+
/** Minimal */
|
|
264
250
|
min(vector) {
|
|
265
251
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
266
252
|
this[i] = Math.min(vector[i], this[i]);
|
|
267
253
|
}
|
|
268
254
|
return this.check();
|
|
269
255
|
}
|
|
256
|
+
/** Maximal */
|
|
270
257
|
max(vector) {
|
|
271
258
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
272
259
|
this[i] = Math.max(vector[i], this[i]);
|
|
@@ -307,18 +294,25 @@ var __exports__ = (() => {
|
|
|
307
294
|
}
|
|
308
295
|
return this.check();
|
|
309
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Multiplies all elements by `scale`
|
|
299
|
+
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
300
|
+
*/
|
|
310
301
|
multiplyByScalar(scalar) {
|
|
311
302
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
312
303
|
this[i] *= scalar;
|
|
313
304
|
}
|
|
314
305
|
return this.check();
|
|
315
306
|
}
|
|
307
|
+
// Debug checks
|
|
308
|
+
/** Throws an error if array length is incorrect or contains illegal values */
|
|
316
309
|
check() {
|
|
317
310
|
if (config.debug && !this.validate()) {
|
|
318
|
-
throw new Error(
|
|
311
|
+
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
|
|
319
312
|
}
|
|
320
313
|
return this;
|
|
321
314
|
}
|
|
315
|
+
/** Returns false if the array length is incorrect or contains illegal values */
|
|
322
316
|
validate() {
|
|
323
317
|
let valid = this.length === this.ELEMENTS;
|
|
324
318
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -326,39 +320,48 @@ var __exports__ = (() => {
|
|
|
326
320
|
}
|
|
327
321
|
return valid;
|
|
328
322
|
}
|
|
323
|
+
// three.js compatibility
|
|
324
|
+
/** @deprecated */
|
|
329
325
|
sub(a) {
|
|
330
326
|
return this.subtract(a);
|
|
331
327
|
}
|
|
328
|
+
/** @deprecated */
|
|
332
329
|
setScalar(a) {
|
|
333
330
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
334
331
|
this[i] = a;
|
|
335
332
|
}
|
|
336
333
|
return this.check();
|
|
337
334
|
}
|
|
335
|
+
/** @deprecated */
|
|
338
336
|
addScalar(a) {
|
|
339
337
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
340
338
|
this[i] += a;
|
|
341
339
|
}
|
|
342
340
|
return this.check();
|
|
343
341
|
}
|
|
342
|
+
/** @deprecated */
|
|
344
343
|
subScalar(a) {
|
|
345
344
|
return this.addScalar(-a);
|
|
346
345
|
}
|
|
346
|
+
/** @deprecated */
|
|
347
347
|
multiplyScalar(scalar) {
|
|
348
348
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
349
349
|
this[i] *= scalar;
|
|
350
350
|
}
|
|
351
351
|
return this.check();
|
|
352
352
|
}
|
|
353
|
+
/** @deprecated */
|
|
353
354
|
divideScalar(a) {
|
|
354
355
|
return this.multiplyByScalar(1 / a);
|
|
355
356
|
}
|
|
357
|
+
/** @deprecated */
|
|
356
358
|
clampScalar(min2, max2) {
|
|
357
359
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
358
360
|
this[i] = Math.min(Math.max(this[i], min2), max2);
|
|
359
361
|
}
|
|
360
362
|
return this.check();
|
|
361
363
|
}
|
|
364
|
+
/** @deprecated */
|
|
362
365
|
get elements() {
|
|
363
366
|
return this;
|
|
364
367
|
}
|
|
@@ -378,13 +381,13 @@ var __exports__ = (() => {
|
|
|
378
381
|
}
|
|
379
382
|
function checkNumber(value) {
|
|
380
383
|
if (!Number.isFinite(value)) {
|
|
381
|
-
throw new Error(
|
|
384
|
+
throw new Error(`Invalid number ${JSON.stringify(value)}`);
|
|
382
385
|
}
|
|
383
386
|
return value;
|
|
384
387
|
}
|
|
385
388
|
function checkVector(v, length4, callerName = "") {
|
|
386
389
|
if (config.debug && !validateVector(v, length4)) {
|
|
387
|
-
throw new Error(
|
|
390
|
+
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
|
|
388
391
|
}
|
|
389
392
|
return v;
|
|
390
393
|
}
|
|
@@ -392,12 +395,13 @@ var __exports__ = (() => {
|
|
|
392
395
|
// ../../node_modules/@math.gl/core/dist/lib/assert.js
|
|
393
396
|
function assert(condition, message) {
|
|
394
397
|
if (!condition) {
|
|
395
|
-
throw new Error(
|
|
398
|
+
throw new Error(`math.gl assertion ${message}`);
|
|
396
399
|
}
|
|
397
400
|
}
|
|
398
401
|
|
|
399
402
|
// ../../node_modules/@math.gl/core/dist/classes/base/vector.js
|
|
400
403
|
var Vector = class extends MathArray {
|
|
404
|
+
// ACCESSORS
|
|
401
405
|
get x() {
|
|
402
406
|
return this[0];
|
|
403
407
|
}
|
|
@@ -410,12 +414,24 @@ var __exports__ = (() => {
|
|
|
410
414
|
set y(value) {
|
|
411
415
|
this[1] = checkNumber(value);
|
|
412
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Returns the length of the vector from the origin to the point described by this vector
|
|
419
|
+
*
|
|
420
|
+
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
|
|
421
|
+
* Instead we provide `len` and `magnitude`
|
|
422
|
+
*/
|
|
413
423
|
len() {
|
|
414
424
|
return Math.sqrt(this.lengthSquared());
|
|
415
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Returns the length of the vector from the origin to the point described by this vector
|
|
428
|
+
*/
|
|
416
429
|
magnitude() {
|
|
417
430
|
return this.len();
|
|
418
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
434
|
+
*/
|
|
419
435
|
lengthSquared() {
|
|
420
436
|
let length4 = 0;
|
|
421
437
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -423,6 +439,9 @@ var __exports__ = (() => {
|
|
|
423
439
|
}
|
|
424
440
|
return length4;
|
|
425
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
444
|
+
*/
|
|
426
445
|
magnitudeSquared() {
|
|
427
446
|
return this.lengthSquared();
|
|
428
447
|
}
|
|
@@ -444,6 +463,7 @@ var __exports__ = (() => {
|
|
|
444
463
|
}
|
|
445
464
|
return checkNumber(product);
|
|
446
465
|
}
|
|
466
|
+
// MODIFIERS
|
|
447
467
|
normalize() {
|
|
448
468
|
const length4 = this.magnitude();
|
|
449
469
|
if (length4 !== 0) {
|
|
@@ -469,6 +489,7 @@ var __exports__ = (() => {
|
|
|
469
489
|
}
|
|
470
490
|
return this.check();
|
|
471
491
|
}
|
|
492
|
+
// THREE.js compatibility
|
|
472
493
|
lengthSq() {
|
|
473
494
|
return this.lengthSquared();
|
|
474
495
|
}
|
|
@@ -986,7 +1007,7 @@ var __exports__ = (() => {
|
|
|
986
1007
|
return out;
|
|
987
1008
|
}
|
|
988
1009
|
function str(a) {
|
|
989
|
-
return
|
|
1010
|
+
return `vec3(${a[0]}, ${a[1]}, ${a[2]})`;
|
|
990
1011
|
}
|
|
991
1012
|
function exactEquals(a, b) {
|
|
992
1013
|
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
@@ -1047,6 +1068,12 @@ var __exports__ = (() => {
|
|
|
1047
1068
|
}
|
|
1048
1069
|
return ZERO;
|
|
1049
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* @class
|
|
1073
|
+
* @param x
|
|
1074
|
+
* @param y
|
|
1075
|
+
* @param z
|
|
1076
|
+
*/
|
|
1050
1077
|
constructor(x = 0, y = 0, z = 0) {
|
|
1051
1078
|
super(-0, -0, -0);
|
|
1052
1079
|
if (arguments.length === 1 && isArray(x)) {
|
|
@@ -1091,6 +1118,7 @@ var __exports__ = (() => {
|
|
|
1091
1118
|
object.z = this[2];
|
|
1092
1119
|
return object;
|
|
1093
1120
|
}
|
|
1121
|
+
// Getters/setters
|
|
1094
1122
|
get ELEMENTS() {
|
|
1095
1123
|
return 3;
|
|
1096
1124
|
}
|
|
@@ -1100,41 +1128,38 @@ var __exports__ = (() => {
|
|
|
1100
1128
|
set z(value) {
|
|
1101
1129
|
this[2] = checkNumber(value);
|
|
1102
1130
|
}
|
|
1131
|
+
// ACCESSORS
|
|
1103
1132
|
angle(vector) {
|
|
1104
1133
|
return angle(this, vector);
|
|
1105
1134
|
}
|
|
1135
|
+
// MODIFIERS
|
|
1106
1136
|
cross(vector) {
|
|
1107
1137
|
cross(this, this, vector);
|
|
1108
1138
|
return this.check();
|
|
1109
1139
|
}
|
|
1110
|
-
rotateX({
|
|
1111
|
-
radians: radians2,
|
|
1112
|
-
origin = ORIGIN
|
|
1113
|
-
}) {
|
|
1140
|
+
rotateX({ radians: radians2, origin = ORIGIN }) {
|
|
1114
1141
|
rotateX(this, this, origin, radians2);
|
|
1115
1142
|
return this.check();
|
|
1116
1143
|
}
|
|
1117
|
-
rotateY({
|
|
1118
|
-
radians: radians2,
|
|
1119
|
-
origin = ORIGIN
|
|
1120
|
-
}) {
|
|
1144
|
+
rotateY({ radians: radians2, origin = ORIGIN }) {
|
|
1121
1145
|
rotateY(this, this, origin, radians2);
|
|
1122
1146
|
return this.check();
|
|
1123
1147
|
}
|
|
1124
|
-
rotateZ({
|
|
1125
|
-
radians: radians2,
|
|
1126
|
-
origin = ORIGIN
|
|
1127
|
-
}) {
|
|
1148
|
+
rotateZ({ radians: radians2, origin = ORIGIN }) {
|
|
1128
1149
|
rotateZ(this, this, origin, radians2);
|
|
1129
1150
|
return this.check();
|
|
1130
1151
|
}
|
|
1152
|
+
// Transforms
|
|
1153
|
+
// transforms as point (4th component is implicitly 1)
|
|
1131
1154
|
transform(matrix4) {
|
|
1132
1155
|
return this.transformAsPoint(matrix4);
|
|
1133
1156
|
}
|
|
1157
|
+
// transforms as point (4th component is implicitly 1)
|
|
1134
1158
|
transformAsPoint(matrix4) {
|
|
1135
1159
|
transformMat42(this, this, matrix4);
|
|
1136
1160
|
return this.check();
|
|
1137
1161
|
}
|
|
1162
|
+
// transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
|
|
1138
1163
|
transformAsVector(matrix4) {
|
|
1139
1164
|
vec3_transformMat4AsVector(this, this, matrix4);
|
|
1140
1165
|
return this.check();
|
|
@@ -1214,6 +1239,8 @@ var __exports__ = (() => {
|
|
|
1214
1239
|
object.w = this[3];
|
|
1215
1240
|
return object;
|
|
1216
1241
|
}
|
|
1242
|
+
// Getters/setters
|
|
1243
|
+
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
|
|
1217
1244
|
get ELEMENTS() {
|
|
1218
1245
|
return 4;
|
|
1219
1246
|
}
|
|
@@ -1245,6 +1272,7 @@ var __exports__ = (() => {
|
|
|
1245
1272
|
transformQuat(this, this, quaternion);
|
|
1246
1273
|
return this.check();
|
|
1247
1274
|
}
|
|
1275
|
+
// three.js compatibility
|
|
1248
1276
|
applyMatrix4(m) {
|
|
1249
1277
|
m.transform(this, this);
|
|
1250
1278
|
return this;
|
|
@@ -1253,19 +1281,29 @@ var __exports__ = (() => {
|
|
|
1253
1281
|
|
|
1254
1282
|
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
1255
1283
|
var Matrix = class extends MathArray {
|
|
1284
|
+
// fromObject(object) {
|
|
1285
|
+
// const array = object.elements;
|
|
1286
|
+
// return this.fromRowMajor(array);
|
|
1287
|
+
// }
|
|
1288
|
+
// toObject(object) {
|
|
1289
|
+
// const array = object.elements;
|
|
1290
|
+
// this.toRowMajor(array);
|
|
1291
|
+
// return object;
|
|
1292
|
+
// }
|
|
1293
|
+
// TODO better override formatString?
|
|
1256
1294
|
toString() {
|
|
1257
1295
|
let string = "[";
|
|
1258
1296
|
if (config.printRowMajor) {
|
|
1259
1297
|
string += "row-major:";
|
|
1260
1298
|
for (let row = 0; row < this.RANK; ++row) {
|
|
1261
1299
|
for (let col = 0; col < this.RANK; ++col) {
|
|
1262
|
-
string +=
|
|
1300
|
+
string += ` ${this[col * this.RANK + row]}`;
|
|
1263
1301
|
}
|
|
1264
1302
|
}
|
|
1265
1303
|
} else {
|
|
1266
1304
|
string += "column-major:";
|
|
1267
1305
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1268
|
-
string +=
|
|
1306
|
+
string += ` ${this[i]}`;
|
|
1269
1307
|
}
|
|
1270
1308
|
}
|
|
1271
1309
|
string += "]";
|
|
@@ -1274,9 +1312,11 @@ var __exports__ = (() => {
|
|
|
1274
1312
|
getElementIndex(row, col) {
|
|
1275
1313
|
return col * this.RANK + row;
|
|
1276
1314
|
}
|
|
1315
|
+
// By default assumes row major indices
|
|
1277
1316
|
getElement(row, col) {
|
|
1278
1317
|
return this[col * this.RANK + row];
|
|
1279
1318
|
}
|
|
1319
|
+
// By default assumes row major indices
|
|
1280
1320
|
setElement(row, col, value) {
|
|
1281
1321
|
this[col * this.RANK + row] = checkNumber(value);
|
|
1282
1322
|
return this;
|
|
@@ -1549,16 +1589,30 @@ var __exports__ = (() => {
|
|
|
1549
1589
|
this[8] = array[8];
|
|
1550
1590
|
return this.check();
|
|
1551
1591
|
}
|
|
1592
|
+
// Constructors
|
|
1552
1593
|
identity() {
|
|
1553
1594
|
return this.copy(IDENTITY_MATRIX);
|
|
1554
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
*
|
|
1598
|
+
* @param object
|
|
1599
|
+
* @returns self
|
|
1600
|
+
*/
|
|
1601
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1555
1602
|
fromObject(object) {
|
|
1556
1603
|
return this.check();
|
|
1557
1604
|
}
|
|
1605
|
+
/** Calculates a 3x3 matrix from the given quaternion
|
|
1606
|
+
* q quat Quaternion to create matrix from
|
|
1607
|
+
*/
|
|
1558
1608
|
fromQuaternion(q) {
|
|
1559
1609
|
fromQuat(this, q);
|
|
1560
1610
|
return this.check();
|
|
1561
1611
|
}
|
|
1612
|
+
/**
|
|
1613
|
+
* accepts column major order, stores in column major order
|
|
1614
|
+
*/
|
|
1615
|
+
// eslint-disable-next-line max-params
|
|
1562
1616
|
set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
|
|
1563
1617
|
this[0] = m00;
|
|
1564
1618
|
this[1] = m10;
|
|
@@ -1571,6 +1625,10 @@ var __exports__ = (() => {
|
|
|
1571
1625
|
this[8] = m22;
|
|
1572
1626
|
return this.check();
|
|
1573
1627
|
}
|
|
1628
|
+
/**
|
|
1629
|
+
* accepts row major order, stores as column major
|
|
1630
|
+
*/
|
|
1631
|
+
// eslint-disable-next-line max-params
|
|
1574
1632
|
setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
|
|
1575
1633
|
this[0] = m00;
|
|
1576
1634
|
this[1] = m10;
|
|
@@ -1583,17 +1641,21 @@ var __exports__ = (() => {
|
|
|
1583
1641
|
this[8] = m22;
|
|
1584
1642
|
return this.check();
|
|
1585
1643
|
}
|
|
1644
|
+
// Accessors
|
|
1586
1645
|
determinant() {
|
|
1587
1646
|
return determinant(this);
|
|
1588
1647
|
}
|
|
1648
|
+
// Modifiers
|
|
1589
1649
|
transpose() {
|
|
1590
1650
|
transpose(this, this);
|
|
1591
1651
|
return this.check();
|
|
1592
1652
|
}
|
|
1653
|
+
/** Invert a matrix. Note that this can fail if the matrix is not invertible */
|
|
1593
1654
|
invert() {
|
|
1594
1655
|
invert(this, this);
|
|
1595
1656
|
return this.check();
|
|
1596
1657
|
}
|
|
1658
|
+
// Operations
|
|
1597
1659
|
multiplyLeft(a) {
|
|
1598
1660
|
multiply2(this, a, this);
|
|
1599
1661
|
return this.check();
|
|
@@ -1618,6 +1680,7 @@ var __exports__ = (() => {
|
|
|
1618
1680
|
translate(this, this, vec);
|
|
1619
1681
|
return this.check();
|
|
1620
1682
|
}
|
|
1683
|
+
// Transforms
|
|
1621
1684
|
transform(vector, result) {
|
|
1622
1685
|
let out;
|
|
1623
1686
|
switch (vector.length) {
|
|
@@ -1636,12 +1699,15 @@ var __exports__ = (() => {
|
|
|
1636
1699
|
checkVector(out, vector.length);
|
|
1637
1700
|
return out;
|
|
1638
1701
|
}
|
|
1702
|
+
/** @deprecated */
|
|
1639
1703
|
transformVector(vector, result) {
|
|
1640
1704
|
return this.transform(vector, result);
|
|
1641
1705
|
}
|
|
1706
|
+
/** @deprecated */
|
|
1642
1707
|
transformVector2(vector, result) {
|
|
1643
1708
|
return this.transform(vector, result);
|
|
1644
1709
|
}
|
|
1710
|
+
/** @deprecated */
|
|
1645
1711
|
transformVector3(vector, result) {
|
|
1646
1712
|
return this.transform(vector, result);
|
|
1647
1713
|
}
|
|
@@ -3012,7 +3078,7 @@ var __exports__ = (() => {
|
|
|
3012
3078
|
return out;
|
|
3013
3079
|
}
|
|
3014
3080
|
function str2(a) {
|
|
3015
|
-
return
|
|
3081
|
+
return `mat4(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]}, ${a[4]}, ${a[5]}, ${a[6]}, ${a[7]}, ${a[8]}, ${a[9]}, ${a[10]}, ${a[11]}, ${a[12]}, ${a[13]}, ${a[14]}, ${a[15]})`;
|
|
3016
3082
|
}
|
|
3017
3083
|
function frob(a) {
|
|
3018
3084
|
return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8] + a[9] * a[9] + a[10] * a[10] + a[11] * a[11] + a[12] * a[12] + a[13] * a[13] + a[14] * a[14] + a[15] * a[15]);
|
|
@@ -3330,6 +3396,7 @@ var __exports__ = (() => {
|
|
|
3330
3396
|
this[15] = array[15];
|
|
3331
3397
|
return this.check();
|
|
3332
3398
|
}
|
|
3399
|
+
// eslint-disable-next-line max-params
|
|
3333
3400
|
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
3334
3401
|
this[0] = m00;
|
|
3335
3402
|
this[1] = m10;
|
|
@@ -3349,6 +3416,8 @@ var __exports__ = (() => {
|
|
|
3349
3416
|
this[15] = m33;
|
|
3350
3417
|
return this.check();
|
|
3351
3418
|
}
|
|
3419
|
+
// accepts row major order, stores as column major
|
|
3420
|
+
// eslint-disable-next-line max-params
|
|
3352
3421
|
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
3353
3422
|
this[0] = m00;
|
|
3354
3423
|
this[1] = m10;
|
|
@@ -3387,25 +3456,41 @@ var __exports__ = (() => {
|
|
|
3387
3456
|
result[15] = this[15];
|
|
3388
3457
|
return result;
|
|
3389
3458
|
}
|
|
3459
|
+
// Constructors
|
|
3460
|
+
/** Set to identity matrix */
|
|
3390
3461
|
identity() {
|
|
3391
3462
|
return this.copy(IDENTITY_MATRIX2);
|
|
3392
3463
|
}
|
|
3464
|
+
/**
|
|
3465
|
+
*
|
|
3466
|
+
* @param object
|
|
3467
|
+
* @returns self
|
|
3468
|
+
*/
|
|
3469
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3393
3470
|
fromObject(object) {
|
|
3394
3471
|
return this.check();
|
|
3395
3472
|
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Calculates a 4x4 matrix from the given quaternion
|
|
3475
|
+
* @param quaternion Quaternion to create matrix from
|
|
3476
|
+
* @returns self
|
|
3477
|
+
*/
|
|
3396
3478
|
fromQuaternion(quaternion) {
|
|
3397
3479
|
fromQuat3(this, quaternion);
|
|
3398
3480
|
return this.check();
|
|
3399
3481
|
}
|
|
3482
|
+
/**
|
|
3483
|
+
* Generates a frustum matrix with the given bounds
|
|
3484
|
+
* @param view.left - Left bound of the frustum
|
|
3485
|
+
* @param view.right - Right bound of the frustum
|
|
3486
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
3487
|
+
* @param view.top - Top bound of the frustum
|
|
3488
|
+
* @param view.near - Near bound of the frustum
|
|
3489
|
+
* @param view.far - Far bound of the frustum. Can be set to Infinity.
|
|
3490
|
+
* @returns self
|
|
3491
|
+
*/
|
|
3400
3492
|
frustum(view) {
|
|
3401
|
-
const {
|
|
3402
|
-
left,
|
|
3403
|
-
right,
|
|
3404
|
-
bottom,
|
|
3405
|
-
top,
|
|
3406
|
-
near = DEFAULT_NEAR,
|
|
3407
|
-
far = DEFAULT_FAR
|
|
3408
|
-
} = view;
|
|
3493
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
3409
3494
|
if (far === Infinity) {
|
|
3410
3495
|
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
3411
3496
|
} else {
|
|
@@ -3413,35 +3498,47 @@ var __exports__ = (() => {
|
|
|
3413
3498
|
}
|
|
3414
3499
|
return this.check();
|
|
3415
3500
|
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Generates a look-at matrix with the given eye position, focal point,
|
|
3503
|
+
* and up axis
|
|
3504
|
+
* @param view.eye - (vector) Position of the viewer
|
|
3505
|
+
* @param view.center - (vector) Point the viewer is looking at
|
|
3506
|
+
* @param view.up - (vector) Up axis
|
|
3507
|
+
* @returns self
|
|
3508
|
+
*/
|
|
3416
3509
|
lookAt(view) {
|
|
3417
|
-
const {
|
|
3418
|
-
eye,
|
|
3419
|
-
center = [0, 0, 0],
|
|
3420
|
-
up = [0, 1, 0]
|
|
3421
|
-
} = view;
|
|
3510
|
+
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
|
|
3422
3511
|
lookAt(this, eye, center, up);
|
|
3423
3512
|
return this.check();
|
|
3424
3513
|
}
|
|
3514
|
+
/**
|
|
3515
|
+
* Generates a orthogonal projection matrix with the given bounds
|
|
3516
|
+
* from "traditional" view space parameters
|
|
3517
|
+
* @param view.left - Left bound of the frustum
|
|
3518
|
+
* @param view.right number Right bound of the frustum
|
|
3519
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
3520
|
+
* @param view.top number Top bound of the frustum
|
|
3521
|
+
* @param view.near - Near bound of the frustum
|
|
3522
|
+
* @param view.far number Far bound of the frustum
|
|
3523
|
+
* @returns self
|
|
3524
|
+
*/
|
|
3425
3525
|
ortho(view) {
|
|
3426
|
-
const {
|
|
3427
|
-
left,
|
|
3428
|
-
right,
|
|
3429
|
-
bottom,
|
|
3430
|
-
top,
|
|
3431
|
-
near = DEFAULT_NEAR,
|
|
3432
|
-
far = DEFAULT_FAR
|
|
3433
|
-
} = view;
|
|
3526
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
3434
3527
|
ortho(this, left, right, bottom, top, near, far);
|
|
3435
3528
|
return this.check();
|
|
3436
3529
|
}
|
|
3530
|
+
/**
|
|
3531
|
+
* Generates an orthogonal projection matrix with the same parameters
|
|
3532
|
+
* as a perspective matrix (plus focalDistance)
|
|
3533
|
+
* @param view.fovy Vertical field of view in radians
|
|
3534
|
+
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
|
|
3535
|
+
* @param view.focalDistance Distance in the view frustum used for extent calculations
|
|
3536
|
+
* @param view.near Near bound of the frustum
|
|
3537
|
+
* @param view.far Far bound of the frustum
|
|
3538
|
+
* @returns self
|
|
3539
|
+
*/
|
|
3437
3540
|
orthographic(view) {
|
|
3438
|
-
const {
|
|
3439
|
-
fovy = DEFAULT_FOVY,
|
|
3440
|
-
aspect = DEFAULT_ASPECT,
|
|
3441
|
-
focalDistance = 1,
|
|
3442
|
-
near = DEFAULT_NEAR,
|
|
3443
|
-
far = DEFAULT_FAR
|
|
3444
|
-
} = view;
|
|
3541
|
+
const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
3445
3542
|
checkRadians(fovy);
|
|
3446
3543
|
const halfY = fovy / 2;
|
|
3447
3544
|
const top = focalDistance * Math.tan(halfY);
|
|
@@ -3455,32 +3552,53 @@ var __exports__ = (() => {
|
|
|
3455
3552
|
far
|
|
3456
3553
|
});
|
|
3457
3554
|
}
|
|
3555
|
+
/**
|
|
3556
|
+
* Generates a perspective projection matrix with the given bounds
|
|
3557
|
+
* @param view.fovy Vertical field of view in radians
|
|
3558
|
+
* @param view.aspect Aspect ratio. typically viewport width/height
|
|
3559
|
+
* @param view.near Near bound of the frustum
|
|
3560
|
+
* @param view.far Far bound of the frustum
|
|
3561
|
+
* @returns self
|
|
3562
|
+
*/
|
|
3458
3563
|
perspective(view) {
|
|
3459
|
-
const {
|
|
3460
|
-
fovy = 45 * Math.PI / 180,
|
|
3461
|
-
aspect = 1,
|
|
3462
|
-
near = 0.1,
|
|
3463
|
-
far = 500
|
|
3464
|
-
} = view;
|
|
3564
|
+
const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
|
|
3465
3565
|
checkRadians(fovy);
|
|
3466
3566
|
perspective(this, fovy, aspect, near, far);
|
|
3467
3567
|
return this.check();
|
|
3468
3568
|
}
|
|
3569
|
+
// Accessors
|
|
3469
3570
|
determinant() {
|
|
3470
3571
|
return determinant2(this);
|
|
3471
3572
|
}
|
|
3573
|
+
/**
|
|
3574
|
+
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
3575
|
+
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
3576
|
+
* @param result
|
|
3577
|
+
* @returns self
|
|
3578
|
+
*/
|
|
3472
3579
|
getScale(result = [-0, -0, -0]) {
|
|
3473
3580
|
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
3474
3581
|
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
3475
3582
|
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
3476
3583
|
return result;
|
|
3477
3584
|
}
|
|
3585
|
+
/**
|
|
3586
|
+
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
3587
|
+
* @param result
|
|
3588
|
+
* @returns self
|
|
3589
|
+
*/
|
|
3478
3590
|
getTranslation(result = [-0, -0, -0]) {
|
|
3479
3591
|
result[0] = this[12];
|
|
3480
3592
|
result[1] = this[13];
|
|
3481
3593
|
result[2] = this[14];
|
|
3482
3594
|
return result;
|
|
3483
3595
|
}
|
|
3596
|
+
/**
|
|
3597
|
+
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
3598
|
+
* @param result
|
|
3599
|
+
* @param scaleResult
|
|
3600
|
+
* @returns self
|
|
3601
|
+
*/
|
|
3484
3602
|
getRotation(result, scaleResult) {
|
|
3485
3603
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
3486
3604
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -3506,6 +3624,12 @@ var __exports__ = (() => {
|
|
|
3506
3624
|
result[15] = 1;
|
|
3507
3625
|
return result;
|
|
3508
3626
|
}
|
|
3627
|
+
/**
|
|
3628
|
+
*
|
|
3629
|
+
* @param result
|
|
3630
|
+
* @param scaleResult
|
|
3631
|
+
* @returns self
|
|
3632
|
+
*/
|
|
3509
3633
|
getRotationMatrix3(result, scaleResult) {
|
|
3510
3634
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
3511
3635
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -3524,6 +3648,7 @@ var __exports__ = (() => {
|
|
|
3524
3648
|
result[8] = this[10] * inverseScale2;
|
|
3525
3649
|
return result;
|
|
3526
3650
|
}
|
|
3651
|
+
// Modifiers
|
|
3527
3652
|
transpose() {
|
|
3528
3653
|
transpose2(this, this);
|
|
3529
3654
|
return this.check();
|
|
@@ -3532,6 +3657,7 @@ var __exports__ = (() => {
|
|
|
3532
3657
|
invert2(this, this);
|
|
3533
3658
|
return this.check();
|
|
3534
3659
|
}
|
|
3660
|
+
// Operations
|
|
3535
3661
|
multiplyLeft(a) {
|
|
3536
3662
|
multiply3(this, a, this);
|
|
3537
3663
|
return this.check();
|
|
@@ -3540,33 +3666,68 @@ var __exports__ = (() => {
|
|
|
3540
3666
|
multiply3(this, this, a);
|
|
3541
3667
|
return this.check();
|
|
3542
3668
|
}
|
|
3669
|
+
// Rotates a matrix by the given angle around the X axis
|
|
3543
3670
|
rotateX(radians2) {
|
|
3544
3671
|
rotateX2(this, this, radians2);
|
|
3545
3672
|
return this.check();
|
|
3546
3673
|
}
|
|
3674
|
+
// Rotates a matrix by the given angle around the Y axis.
|
|
3547
3675
|
rotateY(radians2) {
|
|
3548
3676
|
rotateY2(this, this, radians2);
|
|
3549
3677
|
return this.check();
|
|
3550
3678
|
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Rotates a matrix by the given angle around the Z axis.
|
|
3681
|
+
* @param radians
|
|
3682
|
+
* @returns self
|
|
3683
|
+
*/
|
|
3551
3684
|
rotateZ(radians2) {
|
|
3552
3685
|
rotateZ2(this, this, radians2);
|
|
3553
3686
|
return this.check();
|
|
3554
3687
|
}
|
|
3688
|
+
/**
|
|
3689
|
+
*
|
|
3690
|
+
* @param param0
|
|
3691
|
+
* @returns self
|
|
3692
|
+
*/
|
|
3555
3693
|
rotateXYZ(angleXYZ) {
|
|
3556
3694
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
3557
3695
|
}
|
|
3696
|
+
/**
|
|
3697
|
+
*
|
|
3698
|
+
* @param radians
|
|
3699
|
+
* @param axis
|
|
3700
|
+
* @returns self
|
|
3701
|
+
*/
|
|
3558
3702
|
rotateAxis(radians2, axis) {
|
|
3559
3703
|
rotate2(this, this, radians2, axis);
|
|
3560
3704
|
return this.check();
|
|
3561
3705
|
}
|
|
3706
|
+
/**
|
|
3707
|
+
*
|
|
3708
|
+
* @param factor
|
|
3709
|
+
* @returns self
|
|
3710
|
+
*/
|
|
3562
3711
|
scale(factor) {
|
|
3563
3712
|
scale3(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
3564
3713
|
return this.check();
|
|
3565
3714
|
}
|
|
3715
|
+
/**
|
|
3716
|
+
*
|
|
3717
|
+
* @param vec
|
|
3718
|
+
* @returns self
|
|
3719
|
+
*/
|
|
3566
3720
|
translate(vector) {
|
|
3567
3721
|
translate2(this, this, vector);
|
|
3568
3722
|
return this.check();
|
|
3569
3723
|
}
|
|
3724
|
+
// Transforms
|
|
3725
|
+
/**
|
|
3726
|
+
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
3727
|
+
* @param vector
|
|
3728
|
+
* @param result
|
|
3729
|
+
* @returns self
|
|
3730
|
+
*/
|
|
3570
3731
|
transform(vector, result) {
|
|
3571
3732
|
if (vector.length === 4) {
|
|
3572
3733
|
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
@@ -3575,10 +3736,14 @@ var __exports__ = (() => {
|
|
|
3575
3736
|
}
|
|
3576
3737
|
return this.transformAsPoint(vector, result);
|
|
3577
3738
|
}
|
|
3739
|
+
/**
|
|
3740
|
+
* Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
3741
|
+
* @param vector
|
|
3742
|
+
* @param result
|
|
3743
|
+
* @returns self
|
|
3744
|
+
*/
|
|
3578
3745
|
transformAsPoint(vector, result) {
|
|
3579
|
-
const {
|
|
3580
|
-
length: length4
|
|
3581
|
-
} = vector;
|
|
3746
|
+
const { length: length4 } = vector;
|
|
3582
3747
|
let out;
|
|
3583
3748
|
switch (length4) {
|
|
3584
3749
|
case 2:
|
|
@@ -3593,6 +3758,12 @@ var __exports__ = (() => {
|
|
|
3593
3758
|
checkVector(out, vector.length);
|
|
3594
3759
|
return out;
|
|
3595
3760
|
}
|
|
3761
|
+
/**
|
|
3762
|
+
* Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
3763
|
+
* @param vector
|
|
3764
|
+
* @param result
|
|
3765
|
+
* @returns self
|
|
3766
|
+
*/
|
|
3596
3767
|
transformAsVector(vector, result) {
|
|
3597
3768
|
let out;
|
|
3598
3769
|
switch (vector.length) {
|
|
@@ -3608,15 +3779,19 @@ var __exports__ = (() => {
|
|
|
3608
3779
|
checkVector(out, vector.length);
|
|
3609
3780
|
return out;
|
|
3610
3781
|
}
|
|
3782
|
+
/** @deprecated */
|
|
3611
3783
|
transformPoint(vector, result) {
|
|
3612
3784
|
return this.transformAsPoint(vector, result);
|
|
3613
3785
|
}
|
|
3786
|
+
/** @deprecated */
|
|
3614
3787
|
transformVector(vector, result) {
|
|
3615
3788
|
return this.transformAsPoint(vector, result);
|
|
3616
3789
|
}
|
|
3790
|
+
/** @deprecated */
|
|
3617
3791
|
transformDirection(vector, result) {
|
|
3618
3792
|
return this.transformAsVector(vector, result);
|
|
3619
3793
|
}
|
|
3794
|
+
// three.js math API compatibility
|
|
3620
3795
|
makeRotationX(radians2) {
|
|
3621
3796
|
return this.identity().rotateX(radians2);
|
|
3622
3797
|
}
|
|
@@ -3943,6 +4118,13 @@ var __exports__ = (() => {
|
|
|
3943
4118
|
this[3] = object.w;
|
|
3944
4119
|
return this.check();
|
|
3945
4120
|
}
|
|
4121
|
+
/**
|
|
4122
|
+
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
4123
|
+
* NOTE: The resultant quaternion is not normalized, so you should
|
|
4124
|
+
* be sure to renormalize the quaternion yourself where necessary.
|
|
4125
|
+
* @param m
|
|
4126
|
+
* @returns
|
|
4127
|
+
*/
|
|
3946
4128
|
fromMatrix3(m) {
|
|
3947
4129
|
fromMat3(this, m);
|
|
3948
4130
|
return this.check();
|
|
@@ -3951,13 +4133,21 @@ var __exports__ = (() => {
|
|
|
3951
4133
|
setAxisAngle(this, axis, rad);
|
|
3952
4134
|
return this.check();
|
|
3953
4135
|
}
|
|
4136
|
+
/** Set a quat to the identity quaternion */
|
|
3954
4137
|
identity() {
|
|
3955
4138
|
identity2(this);
|
|
3956
4139
|
return this.check();
|
|
3957
4140
|
}
|
|
4141
|
+
// Set the components of a quat to the given values
|
|
4142
|
+
// set(i, j, k, l) {
|
|
4143
|
+
// quat_set(this, i, j, k, l);
|
|
4144
|
+
// return this.check();
|
|
4145
|
+
// }
|
|
4146
|
+
// Sets a quat from the given angle and rotation axis, then returns it.
|
|
3958
4147
|
setAxisAngle(axis, rad) {
|
|
3959
4148
|
return this.fromAxisRotation(axis, rad);
|
|
3960
4149
|
}
|
|
4150
|
+
// Getters/setters
|
|
3961
4151
|
get ELEMENTS() {
|
|
3962
4152
|
return 4;
|
|
3963
4153
|
}
|
|
@@ -3985,35 +4175,72 @@ var __exports__ = (() => {
|
|
|
3985
4175
|
set w(value) {
|
|
3986
4176
|
this[3] = checkNumber(value);
|
|
3987
4177
|
}
|
|
4178
|
+
// Calculates the length of a quat
|
|
3988
4179
|
len() {
|
|
3989
4180
|
return length3(this);
|
|
3990
4181
|
}
|
|
4182
|
+
// Calculates the squared length of a quat
|
|
3991
4183
|
lengthSquared() {
|
|
3992
4184
|
return squaredLength3(this);
|
|
3993
4185
|
}
|
|
4186
|
+
// Calculates the dot product of two quat's
|
|
4187
|
+
// @return {Number}
|
|
3994
4188
|
dot(a) {
|
|
3995
4189
|
return dot3(this, a);
|
|
3996
4190
|
}
|
|
4191
|
+
// Gets the rotation axis and angle for a given quaternion.
|
|
4192
|
+
// If a quaternion is created with setAxisAngle, this method will
|
|
4193
|
+
// return the same values as providied in the original parameter
|
|
4194
|
+
// list OR functionally equivalent values.
|
|
4195
|
+
// Example: The quaternion formed by axis [0, 0, 1] and angle -90
|
|
4196
|
+
// is the same as the quaternion formed by [0, 0, 1] and 270.
|
|
4197
|
+
// This method favors the latter.
|
|
4198
|
+
// @return {{[x,y,z], Number}}
|
|
4199
|
+
// getAxisAngle() {
|
|
4200
|
+
// const axis = [];
|
|
4201
|
+
// // const angle = quat_getAxisAngle(axis, this);
|
|
4202
|
+
// return {axis, angle};
|
|
4203
|
+
// }
|
|
4204
|
+
// MODIFIERS
|
|
4205
|
+
// Sets a quaternion to represent the shortest rotation from one vector
|
|
4206
|
+
// to another. Both vectors are assumed to be unit length.
|
|
3997
4207
|
rotationTo(vectorA, vectorB) {
|
|
3998
4208
|
rotationTo(this, vectorA, vectorB);
|
|
3999
4209
|
return this.check();
|
|
4000
4210
|
}
|
|
4211
|
+
// Sets the specified quaternion with values corresponding to the given axes.
|
|
4212
|
+
// Each axis is a vec3 and is expected to be unit length and perpendicular
|
|
4213
|
+
// to all other specified axes.
|
|
4214
|
+
// setAxes() {
|
|
4215
|
+
// Number
|
|
4216
|
+
// }
|
|
4217
|
+
// Performs a spherical linear interpolation with two control points
|
|
4218
|
+
// sqlerp() {
|
|
4219
|
+
// Number;
|
|
4220
|
+
// }
|
|
4221
|
+
// Adds two quat's
|
|
4001
4222
|
add(a) {
|
|
4002
4223
|
add4(this, this, a);
|
|
4003
4224
|
return this.check();
|
|
4004
4225
|
}
|
|
4226
|
+
// Calculates the W component of a quat from the X, Y, and Z components.
|
|
4227
|
+
// Any existing W component will be ignored.
|
|
4005
4228
|
calculateW() {
|
|
4006
4229
|
calculateW(this, this);
|
|
4007
4230
|
return this.check();
|
|
4008
4231
|
}
|
|
4232
|
+
// Calculates the conjugate of a quat If the quaternion is normalized,
|
|
4233
|
+
// this function is faster than quat_invert and produces the same result.
|
|
4009
4234
|
conjugate() {
|
|
4010
4235
|
conjugate(this, this);
|
|
4011
4236
|
return this.check();
|
|
4012
4237
|
}
|
|
4238
|
+
// Calculates the inverse of a quat
|
|
4013
4239
|
invert() {
|
|
4014
4240
|
invert3(this, this);
|
|
4015
4241
|
return this.check();
|
|
4016
4242
|
}
|
|
4243
|
+
// Performs a linear interpolation between two quat's
|
|
4017
4244
|
lerp(a, b, t) {
|
|
4018
4245
|
if (t === void 0) {
|
|
4019
4246
|
return this.lerp(this, a, b);
|
|
@@ -4021,6 +4248,7 @@ var __exports__ = (() => {
|
|
|
4021
4248
|
lerp3(this, a, b, t);
|
|
4022
4249
|
return this.check();
|
|
4023
4250
|
}
|
|
4251
|
+
// Multiplies two quat's
|
|
4024
4252
|
multiplyRight(a) {
|
|
4025
4253
|
multiply4(this, this, a);
|
|
4026
4254
|
return this.check();
|
|
@@ -4029,6 +4257,7 @@ var __exports__ = (() => {
|
|
|
4029
4257
|
multiply4(this, a, this);
|
|
4030
4258
|
return this.check();
|
|
4031
4259
|
}
|
|
4260
|
+
// Normalize a quat
|
|
4032
4261
|
normalize() {
|
|
4033
4262
|
const length4 = this.len();
|
|
4034
4263
|
const l = length4 > 0 ? 1 / length4 : 0;
|
|
@@ -4041,22 +4270,27 @@ var __exports__ = (() => {
|
|
|
4041
4270
|
}
|
|
4042
4271
|
return this.check();
|
|
4043
4272
|
}
|
|
4273
|
+
// Rotates a quaternion by the given angle about the X axis
|
|
4044
4274
|
rotateX(rad) {
|
|
4045
4275
|
rotateX3(this, this, rad);
|
|
4046
4276
|
return this.check();
|
|
4047
4277
|
}
|
|
4278
|
+
// Rotates a quaternion by the given angle about the Y axis
|
|
4048
4279
|
rotateY(rad) {
|
|
4049
4280
|
rotateY3(this, this, rad);
|
|
4050
4281
|
return this.check();
|
|
4051
4282
|
}
|
|
4283
|
+
// Rotates a quaternion by the given angle about the Z axis
|
|
4052
4284
|
rotateZ(rad) {
|
|
4053
4285
|
rotateZ3(this, this, rad);
|
|
4054
4286
|
return this.check();
|
|
4055
4287
|
}
|
|
4288
|
+
// Scales a quat by a scalar number
|
|
4056
4289
|
scale(b) {
|
|
4057
4290
|
scale5(this, this, b);
|
|
4058
4291
|
return this.check();
|
|
4059
4292
|
}
|
|
4293
|
+
// Performs a spherical linear interpolation between two quat
|
|
4060
4294
|
slerp(arg0, arg1, arg2) {
|
|
4061
4295
|
let start;
|
|
4062
4296
|
let target;
|
|
@@ -4086,6 +4320,7 @@ var __exports__ = (() => {
|
|
|
4086
4320
|
transformQuat2(result, vector, this);
|
|
4087
4321
|
return checkVector(result, 4);
|
|
4088
4322
|
}
|
|
4323
|
+
// THREE.js Math API compatibility
|
|
4089
4324
|
lengthSq() {
|
|
4090
4325
|
return this.lengthSquared();
|
|
4091
4326
|
}
|
|
@@ -4100,52 +4335,6 @@ var __exports__ = (() => {
|
|
|
4100
4335
|
}
|
|
4101
4336
|
};
|
|
4102
4337
|
|
|
4103
|
-
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
4104
|
-
function _typeof(obj) {
|
|
4105
|
-
"@babel/helpers - typeof";
|
|
4106
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
4107
|
-
return typeof obj2;
|
|
4108
|
-
} : function(obj2) {
|
|
4109
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
4110
|
-
}, _typeof(obj);
|
|
4111
|
-
}
|
|
4112
|
-
|
|
4113
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
4114
|
-
function _toPrimitive(input, hint) {
|
|
4115
|
-
if (_typeof(input) !== "object" || input === null)
|
|
4116
|
-
return input;
|
|
4117
|
-
var prim = input[Symbol.toPrimitive];
|
|
4118
|
-
if (prim !== void 0) {
|
|
4119
|
-
var res = prim.call(input, hint || "default");
|
|
4120
|
-
if (_typeof(res) !== "object")
|
|
4121
|
-
return res;
|
|
4122
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4123
|
-
}
|
|
4124
|
-
return (hint === "string" ? String : Number)(input);
|
|
4125
|
-
}
|
|
4126
|
-
|
|
4127
|
-
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
4128
|
-
function _toPropertyKey(arg) {
|
|
4129
|
-
var key = _toPrimitive(arg, "string");
|
|
4130
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
4131
|
-
}
|
|
4132
|
-
|
|
4133
|
-
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
4134
|
-
function _defineProperty(obj, key, value) {
|
|
4135
|
-
key = _toPropertyKey(key);
|
|
4136
|
-
if (key in obj) {
|
|
4137
|
-
Object.defineProperty(obj, key, {
|
|
4138
|
-
value,
|
|
4139
|
-
enumerable: true,
|
|
4140
|
-
configurable: true,
|
|
4141
|
-
writable: true
|
|
4142
|
-
});
|
|
4143
|
-
} else {
|
|
4144
|
-
obj[key] = value;
|
|
4145
|
-
}
|
|
4146
|
-
return obj;
|
|
4147
|
-
}
|
|
4148
|
-
|
|
4149
4338
|
// ../../node_modules/@math.gl/core/dist/lib/math-utils.js
|
|
4150
4339
|
var math_utils_exports = {};
|
|
4151
4340
|
__export(math_utils_exports, {
|
|
@@ -4205,11 +4394,20 @@ var __exports__ = (() => {
|
|
|
4205
4394
|
var WGS84_RADIUS_Z = 6356752314245179e-9;
|
|
4206
4395
|
var WGS84_CONSTANTS = {
|
|
4207
4396
|
radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
|
|
4208
|
-
radiiSquared: [
|
|
4397
|
+
radiiSquared: [
|
|
4398
|
+
WGS84_RADIUS_X * WGS84_RADIUS_X,
|
|
4399
|
+
WGS84_RADIUS_Y * WGS84_RADIUS_Y,
|
|
4400
|
+
WGS84_RADIUS_Z * WGS84_RADIUS_Z
|
|
4401
|
+
],
|
|
4209
4402
|
oneOverRadii: [1 / WGS84_RADIUS_X, 1 / WGS84_RADIUS_Y, 1 / WGS84_RADIUS_Z],
|
|
4210
|
-
oneOverRadiiSquared: [
|
|
4403
|
+
oneOverRadiiSquared: [
|
|
4404
|
+
1 / (WGS84_RADIUS_X * WGS84_RADIUS_X),
|
|
4405
|
+
1 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),
|
|
4406
|
+
1 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)
|
|
4407
|
+
],
|
|
4211
4408
|
maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),
|
|
4212
4409
|
centerToleranceSquared: 0.1
|
|
4410
|
+
// EPSILON1;
|
|
4213
4411
|
};
|
|
4214
4412
|
|
|
4215
4413
|
// ../../node_modules/@math.gl/geospatial/dist/type-utils.js
|
|
@@ -4339,19 +4537,11 @@ var __exports__ = (() => {
|
|
|
4339
4537
|
thirdAxisVector.scale(sign);
|
|
4340
4538
|
}
|
|
4341
4539
|
} else {
|
|
4342
|
-
const {
|
|
4343
|
-
up,
|
|
4344
|
-
east,
|
|
4345
|
-
north
|
|
4346
|
-
} = scratchAxisVectors;
|
|
4540
|
+
const { up, east, north } = scratchAxisVectors;
|
|
4347
4541
|
east.set(-origin.y, origin.x, 0).normalize();
|
|
4348
4542
|
ellipsoid.geodeticSurfaceNormal(origin, up);
|
|
4349
4543
|
north.copy(up).cross(east);
|
|
4350
|
-
const {
|
|
4351
|
-
down,
|
|
4352
|
-
west,
|
|
4353
|
-
south
|
|
4354
|
-
} = scratchAxisVectors;
|
|
4544
|
+
const { down, west, south } = scratchAxisVectors;
|
|
4355
4545
|
down.copy(up).scale(-1);
|
|
4356
4546
|
west.copy(east).scale(-1);
|
|
4357
4547
|
south.copy(north).scale(-1);
|
|
@@ -4383,11 +4573,7 @@ var __exports__ = (() => {
|
|
|
4383
4573
|
var scaleToGeodeticSurfaceIntersection = new Vector3();
|
|
4384
4574
|
var scaleToGeodeticSurfaceGradient = new Vector3();
|
|
4385
4575
|
function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
4386
|
-
const {
|
|
4387
|
-
oneOverRadii,
|
|
4388
|
-
oneOverRadiiSquared,
|
|
4389
|
-
centerToleranceSquared
|
|
4390
|
-
} = ellipsoid;
|
|
4576
|
+
const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
|
|
4391
4577
|
scratchVector4.from(cartesian);
|
|
4392
4578
|
const positionX = scratchVector4.x;
|
|
4393
4579
|
const positionY = scratchVector4.y;
|
|
@@ -4447,15 +4633,7 @@ var __exports__ = (() => {
|
|
|
4447
4633
|
var scratchCartesian = new Vector3();
|
|
4448
4634
|
var Ellipsoid = class {
|
|
4449
4635
|
constructor(x = 0, y = 0, z = 0) {
|
|
4450
|
-
|
|
4451
|
-
_defineProperty(this, "radiiSquared", void 0);
|
|
4452
|
-
_defineProperty(this, "radiiToTheFourth", void 0);
|
|
4453
|
-
_defineProperty(this, "oneOverRadii", void 0);
|
|
4454
|
-
_defineProperty(this, "oneOverRadiiSquared", void 0);
|
|
4455
|
-
_defineProperty(this, "minimumRadius", void 0);
|
|
4456
|
-
_defineProperty(this, "maximumRadius", void 0);
|
|
4457
|
-
_defineProperty(this, "centerToleranceSquared", math_utils_exports.EPSILON1);
|
|
4458
|
-
_defineProperty(this, "squaredXOverSquaredZ", void 0);
|
|
4636
|
+
this.centerToleranceSquared = math_utils_exports.EPSILON1;
|
|
4459
4637
|
assert(x >= 0);
|
|
4460
4638
|
assert(y >= 0);
|
|
4461
4639
|
assert(z >= 0);
|
|
@@ -4471,9 +4649,11 @@ var __exports__ = (() => {
|
|
|
4471
4649
|
}
|
|
4472
4650
|
Object.freeze(this);
|
|
4473
4651
|
}
|
|
4652
|
+
/** Compares this Ellipsoid against the provided Ellipsoid componentwise */
|
|
4474
4653
|
equals(right) {
|
|
4475
4654
|
return this === right || Boolean(right && this.radii.equals(right.radii));
|
|
4476
4655
|
}
|
|
4656
|
+
/** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
|
|
4477
4657
|
toString() {
|
|
4478
4658
|
return this.radii.toString();
|
|
4479
4659
|
}
|
|
@@ -4506,6 +4686,8 @@ var __exports__ = (() => {
|
|
|
4506
4686
|
eastNorthUpToFixedFrame(origin, result = new Matrix4()) {
|
|
4507
4687
|
return localFrameToFixedFrame(this, "east", "north", "up", origin, result);
|
|
4508
4688
|
}
|
|
4689
|
+
// Computes a 4x4 transformation matrix from a reference frame centered at
|
|
4690
|
+
// the provided origin to the ellipsoid's fixed reference frame.
|
|
4509
4691
|
localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {
|
|
4510
4692
|
return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
4511
4693
|
}
|
|
@@ -4523,9 +4705,14 @@ var __exports__ = (() => {
|
|
|
4523
4705
|
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
4524
4706
|
return scratchVector5.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
4525
4707
|
}
|
|
4708
|
+
/** Scales the provided Cartesian position along the geodetic surface normal
|
|
4709
|
+
* so that it is on the surface of this ellipsoid. If the position is
|
|
4710
|
+
* at the center of the ellipsoid, this function returns undefined. */
|
|
4526
4711
|
scaleToGeodeticSurface(cartesian, result) {
|
|
4527
4712
|
return scaleToGeodeticSurface(cartesian, this, result);
|
|
4528
4713
|
}
|
|
4714
|
+
/** Scales the provided Cartesian position along the geocentric surface normal
|
|
4715
|
+
* so that it is on the surface of this ellipsoid. */
|
|
4529
4716
|
scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
|
|
4530
4717
|
scratchPosition.from(cartesian);
|
|
4531
4718
|
const positionX = scratchPosition.x;
|
|
@@ -4535,12 +4722,17 @@ var __exports__ = (() => {
|
|
|
4535
4722
|
const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
4536
4723
|
return scratchPosition.multiplyScalar(beta).to(result);
|
|
4537
4724
|
}
|
|
4725
|
+
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
4726
|
+
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
4538
4727
|
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
4539
4728
|
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
4540
4729
|
}
|
|
4730
|
+
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
4731
|
+
* its components by the result of `Ellipsoid#radii`. */
|
|
4541
4732
|
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
4542
4733
|
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
4543
4734
|
}
|
|
4735
|
+
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
4544
4736
|
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
4545
4737
|
assert(equals(this.radii.x, this.radii.y, math_utils_exports.EPSILON15));
|
|
4546
4738
|
assert(this.radii.z > 0);
|
|
@@ -4552,7 +4744,53 @@ var __exports__ = (() => {
|
|
|
4552
4744
|
return scratchPosition.set(0, 0, z).to(result);
|
|
4553
4745
|
}
|
|
4554
4746
|
};
|
|
4555
|
-
|
|
4747
|
+
Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|
|
4748
|
+
|
|
4749
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
4750
|
+
function _typeof(obj) {
|
|
4751
|
+
"@babel/helpers - typeof";
|
|
4752
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
4753
|
+
return typeof obj2;
|
|
4754
|
+
} : function(obj2) {
|
|
4755
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
4756
|
+
}, _typeof(obj);
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4759
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
4760
|
+
function _toPrimitive(input, hint) {
|
|
4761
|
+
if (_typeof(input) !== "object" || input === null)
|
|
4762
|
+
return input;
|
|
4763
|
+
var prim = input[Symbol.toPrimitive];
|
|
4764
|
+
if (prim !== void 0) {
|
|
4765
|
+
var res = prim.call(input, hint || "default");
|
|
4766
|
+
if (_typeof(res) !== "object")
|
|
4767
|
+
return res;
|
|
4768
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4769
|
+
}
|
|
4770
|
+
return (hint === "string" ? String : Number)(input);
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
4774
|
+
function _toPropertyKey(arg) {
|
|
4775
|
+
var key = _toPrimitive(arg, "string");
|
|
4776
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
4777
|
+
}
|
|
4778
|
+
|
|
4779
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
4780
|
+
function _defineProperty(obj, key, value) {
|
|
4781
|
+
key = _toPropertyKey(key);
|
|
4782
|
+
if (key in obj) {
|
|
4783
|
+
Object.defineProperty(obj, key, {
|
|
4784
|
+
value,
|
|
4785
|
+
enumerable: true,
|
|
4786
|
+
configurable: true,
|
|
4787
|
+
writable: true
|
|
4788
|
+
});
|
|
4789
|
+
} else {
|
|
4790
|
+
obj[key] = value;
|
|
4791
|
+
}
|
|
4792
|
+
return obj;
|
|
4793
|
+
}
|
|
4556
4794
|
|
|
4557
4795
|
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
4558
4796
|
function getHiResTimestamp() {
|
|
@@ -5221,8 +5459,11 @@ var __exports__ = (() => {
|
|
|
5221
5459
|
// ../../node_modules/@math.gl/culling/dist/constants.js
|
|
5222
5460
|
var INTERSECTION = {
|
|
5223
5461
|
OUTSIDE: -1,
|
|
5462
|
+
// Represents that an object is not contained within the frustum.
|
|
5224
5463
|
INTERSECTING: 0,
|
|
5464
|
+
// Represents that an object intersects one of the frustum's planes.
|
|
5225
5465
|
INSIDE: 1
|
|
5466
|
+
// Represents that an object is fully within the frustum.
|
|
5226
5467
|
};
|
|
5227
5468
|
|
|
5228
5469
|
// ../../node_modules/@math.gl/culling/dist/lib/bounding-volumes/axis-aligned-bounding-box.js
|
|
@@ -5233,30 +5474,37 @@ var __exports__ = (() => {
|
|
|
5233
5474
|
var scratchVector7 = new Vector3();
|
|
5234
5475
|
var scratchVector22 = new Vector3();
|
|
5235
5476
|
var BoundingSphere = class {
|
|
5477
|
+
/** Creates a bounding sphere */
|
|
5236
5478
|
constructor(center = [0, 0, 0], radius = 0) {
|
|
5237
|
-
_defineProperty(this, "center", void 0);
|
|
5238
|
-
_defineProperty(this, "radius", void 0);
|
|
5239
5479
|
this.radius = -0;
|
|
5240
5480
|
this.center = new Vector3();
|
|
5241
5481
|
this.fromCenterRadius(center, radius);
|
|
5242
5482
|
}
|
|
5483
|
+
/** Sets the bounding sphere from `center` and `radius`. */
|
|
5243
5484
|
fromCenterRadius(center, radius) {
|
|
5244
5485
|
this.center.from(center);
|
|
5245
5486
|
this.radius = radius;
|
|
5246
5487
|
return this;
|
|
5247
5488
|
}
|
|
5489
|
+
/**
|
|
5490
|
+
* Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere
|
|
5491
|
+
* tightly and fully encompasses the box.
|
|
5492
|
+
*/
|
|
5248
5493
|
fromCornerPoints(corner, oppositeCorner) {
|
|
5249
5494
|
oppositeCorner = scratchVector7.from(oppositeCorner);
|
|
5250
5495
|
this.center = new Vector3().from(corner).add(oppositeCorner).scale(0.5);
|
|
5251
5496
|
this.radius = this.center.distance(oppositeCorner);
|
|
5252
5497
|
return this;
|
|
5253
5498
|
}
|
|
5499
|
+
/** Compares the provided BoundingSphere component wise */
|
|
5254
5500
|
equals(right) {
|
|
5255
5501
|
return this === right || Boolean(right) && this.center.equals(right.center) && this.radius === right.radius;
|
|
5256
5502
|
}
|
|
5503
|
+
/** Duplicates a BoundingSphere instance. */
|
|
5257
5504
|
clone() {
|
|
5258
5505
|
return new BoundingSphere(this.center, this.radius);
|
|
5259
5506
|
}
|
|
5507
|
+
/** Computes a bounding sphere that contains both the left and right bounding spheres. */
|
|
5260
5508
|
union(boundingSphere) {
|
|
5261
5509
|
const leftCenter = this.center;
|
|
5262
5510
|
const leftRadius = this.radius;
|
|
@@ -5276,6 +5524,7 @@ var __exports__ = (() => {
|
|
|
5276
5524
|
this.radius = halfDistanceBetweenTangentPoints;
|
|
5277
5525
|
return this;
|
|
5278
5526
|
}
|
|
5527
|
+
/** Computes a bounding sphere by enlarging the provided sphere to contain the provided point. */
|
|
5279
5528
|
expand(point) {
|
|
5280
5529
|
const scratchPoint2 = scratchVector7.from(point);
|
|
5281
5530
|
const radius = scratchPoint2.subtract(this.center).magnitude();
|
|
@@ -5284,21 +5533,31 @@ var __exports__ = (() => {
|
|
|
5284
5533
|
}
|
|
5285
5534
|
return this;
|
|
5286
5535
|
}
|
|
5536
|
+
// BoundingVolume interface
|
|
5537
|
+
/**
|
|
5538
|
+
* Applies a 4x4 affine transformation matrix to a bounding sphere.
|
|
5539
|
+
* @param sphere The bounding sphere to apply the transformation to.
|
|
5540
|
+
* @param transform The transformation matrix to apply to the bounding sphere.
|
|
5541
|
+
* @returns self.
|
|
5542
|
+
*/
|
|
5287
5543
|
transform(transform) {
|
|
5288
5544
|
this.center.transform(transform);
|
|
5289
5545
|
const scale6 = mat4_exports.getScaling(scratchVector7, transform);
|
|
5290
5546
|
this.radius = Math.max(scale6[0], Math.max(scale6[1], scale6[2])) * this.radius;
|
|
5291
5547
|
return this;
|
|
5292
5548
|
}
|
|
5549
|
+
/** Computes the estimated distance squared from the closest point on a bounding sphere to a point. */
|
|
5293
5550
|
distanceSquaredTo(point) {
|
|
5294
5551
|
const d = this.distanceTo(point);
|
|
5295
5552
|
return d * d;
|
|
5296
5553
|
}
|
|
5554
|
+
/** Computes the estimated distance from the closest point on a bounding sphere to a point. */
|
|
5297
5555
|
distanceTo(point) {
|
|
5298
5556
|
const scratchPoint2 = scratchVector7.from(point);
|
|
5299
5557
|
const delta = scratchPoint2.subtract(this.center);
|
|
5300
5558
|
return Math.max(0, delta.len() - this.radius);
|
|
5301
5559
|
}
|
|
5560
|
+
/** Determines which side of a plane a sphere is located. */
|
|
5302
5561
|
intersectPlane(plane) {
|
|
5303
5562
|
const center = this.center;
|
|
5304
5563
|
const radius = this.radius;
|
|
@@ -5335,17 +5594,17 @@ var __exports__ = (() => {
|
|
|
5335
5594
|
};
|
|
5336
5595
|
var OrientedBoundingBox = class {
|
|
5337
5596
|
constructor(center = [0, 0, 0], halfAxes = [0, 0, 0, 0, 0, 0, 0, 0, 0]) {
|
|
5338
|
-
_defineProperty(this, "center", void 0);
|
|
5339
|
-
_defineProperty(this, "halfAxes", void 0);
|
|
5340
5597
|
this.center = new Vector3().from(center);
|
|
5341
5598
|
this.halfAxes = new Matrix3(halfAxes);
|
|
5342
5599
|
}
|
|
5600
|
+
/** Returns an array with three halfSizes for the bounding box */
|
|
5343
5601
|
get halfSize() {
|
|
5344
5602
|
const xAxis = this.halfAxes.getColumn(0);
|
|
5345
5603
|
const yAxis = this.halfAxes.getColumn(1);
|
|
5346
5604
|
const zAxis = this.halfAxes.getColumn(2);
|
|
5347
5605
|
return [new Vector3(xAxis).len(), new Vector3(yAxis).len(), new Vector3(zAxis).len()];
|
|
5348
5606
|
}
|
|
5607
|
+
/** Returns a quaternion describing the orientation of the bounding box */
|
|
5349
5608
|
get quaternion() {
|
|
5350
5609
|
const xAxis = this.halfAxes.getColumn(0);
|
|
5351
5610
|
const yAxis = this.halfAxes.getColumn(1);
|
|
@@ -5355,6 +5614,9 @@ var __exports__ = (() => {
|
|
|
5355
5614
|
const normZAxis = new Vector3(zAxis).normalize();
|
|
5356
5615
|
return new Quaternion().fromMatrix3(new Matrix3([...normXAxis, ...normYAxis, ...normZAxis]));
|
|
5357
5616
|
}
|
|
5617
|
+
/**
|
|
5618
|
+
* Create OrientedBoundingBox from quaternion based OBB,
|
|
5619
|
+
*/
|
|
5358
5620
|
fromCenterHalfSizeQuaternion(center, halfSize, quaternion) {
|
|
5359
5621
|
const quaternionObject = new Quaternion(quaternion);
|
|
5360
5622
|
const directionsMatrix = new Matrix3().fromQuaternion(quaternionObject);
|
|
@@ -5371,12 +5633,15 @@ var __exports__ = (() => {
|
|
|
5371
5633
|
this.halfAxes = directionsMatrix;
|
|
5372
5634
|
return this;
|
|
5373
5635
|
}
|
|
5636
|
+
/** Duplicates a OrientedBoundingBox instance. */
|
|
5374
5637
|
clone() {
|
|
5375
5638
|
return new OrientedBoundingBox(this.center, this.halfAxes);
|
|
5376
5639
|
}
|
|
5640
|
+
/** Compares the provided OrientedBoundingBox component wise and returns */
|
|
5377
5641
|
equals(right) {
|
|
5378
5642
|
return this === right || Boolean(right) && this.center.equals(right.center) && this.halfAxes.equals(right.halfAxes);
|
|
5379
5643
|
}
|
|
5644
|
+
/** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
|
|
5380
5645
|
getBoundingSphere(result = new BoundingSphere()) {
|
|
5381
5646
|
const halfAxes = this.halfAxes;
|
|
5382
5647
|
const u = halfAxes.getColumn(0, scratchVectorU);
|
|
@@ -5387,6 +5652,7 @@ var __exports__ = (() => {
|
|
|
5387
5652
|
result.radius = cornerVector.magnitude();
|
|
5388
5653
|
return result;
|
|
5389
5654
|
}
|
|
5655
|
+
/** Determines which side of a plane the oriented bounding box is located. */
|
|
5390
5656
|
intersectPlane(plane) {
|
|
5391
5657
|
const center = this.center;
|
|
5392
5658
|
const normal = plane.normal;
|
|
@@ -5403,9 +5669,15 @@ var __exports__ = (() => {
|
|
|
5403
5669
|
}
|
|
5404
5670
|
return INTERSECTION.INTERSECTING;
|
|
5405
5671
|
}
|
|
5672
|
+
/** Computes the estimated distance from the closest point on a bounding box to a point. */
|
|
5406
5673
|
distanceTo(point) {
|
|
5407
5674
|
return Math.sqrt(this.distanceSquaredTo(point));
|
|
5408
5675
|
}
|
|
5676
|
+
/**
|
|
5677
|
+
* Computes the estimated distance squared from the closest point
|
|
5678
|
+
* on a bounding box to a point.
|
|
5679
|
+
* See Geometric Tools for Computer Graphics 10.4.2
|
|
5680
|
+
*/
|
|
5409
5681
|
distanceSquaredTo(point) {
|
|
5410
5682
|
const offset = scratchOffset.from(point).subtract(this.center);
|
|
5411
5683
|
const halfAxes = this.halfAxes;
|
|
@@ -5434,6 +5706,21 @@ var __exports__ = (() => {
|
|
|
5434
5706
|
}
|
|
5435
5707
|
return distanceSquared;
|
|
5436
5708
|
}
|
|
5709
|
+
/**
|
|
5710
|
+
* The distances calculated by the vector from the center of the bounding box
|
|
5711
|
+
* to position projected onto direction.
|
|
5712
|
+
*
|
|
5713
|
+
* - If you imagine the infinite number of planes with normal direction,
|
|
5714
|
+
* this computes the smallest distance to the closest and farthest planes
|
|
5715
|
+
* from `position` that intersect the bounding box.
|
|
5716
|
+
*
|
|
5717
|
+
* @param position The position to calculate the distance from.
|
|
5718
|
+
* @param direction The direction from position.
|
|
5719
|
+
* @param result An Interval (array of length 2) to store the nearest and farthest distances.
|
|
5720
|
+
* @returns Interval (array of length 2) with nearest and farthest distances
|
|
5721
|
+
* on the bounding box from position in direction.
|
|
5722
|
+
*/
|
|
5723
|
+
// eslint-disable-next-line max-statements
|
|
5437
5724
|
computePlaneDistances(position, direction, result = [-0, -0]) {
|
|
5438
5725
|
let minDist = Number.POSITIVE_INFINITY;
|
|
5439
5726
|
let maxDist = Number.NEGATIVE_INFINITY;
|
|
@@ -5486,6 +5773,11 @@ var __exports__ = (() => {
|
|
|
5486
5773
|
result[1] = maxDist;
|
|
5487
5774
|
return result;
|
|
5488
5775
|
}
|
|
5776
|
+
/**
|
|
5777
|
+
* Applies a 4x4 affine transformation matrix to a bounding sphere.
|
|
5778
|
+
* @param transform The transformation matrix to apply to the bounding sphere.
|
|
5779
|
+
* @returns itself, i.e. the modified BoundingVolume.
|
|
5780
|
+
*/
|
|
5489
5781
|
transform(transformation) {
|
|
5490
5782
|
this.center.transformAsPoint(transformation);
|
|
5491
5783
|
const xAxis = this.halfAxes.getColumn(0, scratchVectorU);
|
|
@@ -5507,18 +5799,18 @@ var __exports__ = (() => {
|
|
|
5507
5799
|
var scratchNormal3 = new Vector3();
|
|
5508
5800
|
var Plane = class {
|
|
5509
5801
|
constructor(normal = [0, 0, 1], distance2 = 0) {
|
|
5510
|
-
_defineProperty(this, "normal", void 0);
|
|
5511
|
-
_defineProperty(this, "distance", void 0);
|
|
5512
5802
|
this.normal = new Vector3();
|
|
5513
5803
|
this.distance = -0;
|
|
5514
5804
|
this.fromNormalDistance(normal, distance2);
|
|
5515
5805
|
}
|
|
5806
|
+
/** Creates a plane from a normal and a distance from the origin. */
|
|
5516
5807
|
fromNormalDistance(normal, distance2) {
|
|
5517
5808
|
assert(Number.isFinite(distance2));
|
|
5518
5809
|
this.normal.from(normal).normalize();
|
|
5519
5810
|
this.distance = distance2;
|
|
5520
5811
|
return this;
|
|
5521
5812
|
}
|
|
5813
|
+
/** Creates a plane from a normal and a point on the plane. */
|
|
5522
5814
|
fromPointNormal(point, normal) {
|
|
5523
5815
|
point = scratchPosition2.from(point);
|
|
5524
5816
|
this.normal.from(normal).normalize();
|
|
@@ -5526,21 +5818,28 @@ var __exports__ = (() => {
|
|
|
5526
5818
|
this.distance = distance2;
|
|
5527
5819
|
return this;
|
|
5528
5820
|
}
|
|
5821
|
+
/** Creates a plane from the general equation */
|
|
5529
5822
|
fromCoefficients(a, b, c, d) {
|
|
5530
5823
|
this.normal.set(a, b, c);
|
|
5531
5824
|
assert(equals(this.normal.len(), 1));
|
|
5532
5825
|
this.distance = d;
|
|
5533
5826
|
return this;
|
|
5534
5827
|
}
|
|
5828
|
+
/** Duplicates a Plane instance. */
|
|
5535
5829
|
clone() {
|
|
5536
5830
|
return new Plane(this.normal, this.distance);
|
|
5537
5831
|
}
|
|
5832
|
+
/** Compares the provided Planes by normal and distance */
|
|
5538
5833
|
equals(right) {
|
|
5539
5834
|
return equals(this.distance, right.distance) && equals(this.normal, right.normal);
|
|
5540
5835
|
}
|
|
5836
|
+
/** Computes the signed shortest distance of a point to a plane.
|
|
5837
|
+
* The sign of the distance determines which side of the plane the point is on.
|
|
5838
|
+
*/
|
|
5541
5839
|
getPointDistance(point) {
|
|
5542
5840
|
return this.normal.dot(point) + this.distance;
|
|
5543
5841
|
}
|
|
5842
|
+
/** Transforms the plane by the given transformation matrix. */
|
|
5544
5843
|
transform(matrix4) {
|
|
5545
5844
|
const normal = scratchNormal3.copy(this.normal).transformAsVector(matrix4).normalize();
|
|
5546
5845
|
const point = this.normal.scale(-this.distance).transform(matrix4);
|
|
@@ -5559,10 +5858,17 @@ var __exports__ = (() => {
|
|
|
5559
5858
|
var scratchPlaneCenter = new Vector3();
|
|
5560
5859
|
var scratchPlaneNormal = new Vector3();
|
|
5561
5860
|
var CullingVolume = class {
|
|
5861
|
+
/**
|
|
5862
|
+
* Create a new `CullingVolume` bounded by an array of clipping planed
|
|
5863
|
+
* @param planes Array of clipping planes.
|
|
5864
|
+
* */
|
|
5562
5865
|
constructor(planes = []) {
|
|
5563
|
-
_defineProperty(this, "planes", void 0);
|
|
5564
5866
|
this.planes = planes;
|
|
5565
5867
|
}
|
|
5868
|
+
/**
|
|
5869
|
+
* Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
|
|
5870
|
+
* The planes are aligned to the x, y, and z axes in world coordinates.
|
|
5871
|
+
*/
|
|
5566
5872
|
fromBoundingSphere(boundingSphere) {
|
|
5567
5873
|
this.planes.length = 2 * faces.length;
|
|
5568
5874
|
const center = boundingSphere.center;
|
|
@@ -5586,6 +5892,7 @@ var __exports__ = (() => {
|
|
|
5586
5892
|
}
|
|
5587
5893
|
return this;
|
|
5588
5894
|
}
|
|
5895
|
+
/** Determines whether a bounding volume intersects the culling volume. */
|
|
5589
5896
|
computeVisibility(boundingVolume) {
|
|
5590
5897
|
let intersect = INTERSECTION.INSIDE;
|
|
5591
5898
|
for (const plane of this.planes) {
|
|
@@ -5601,6 +5908,14 @@ var __exports__ = (() => {
|
|
|
5601
5908
|
}
|
|
5602
5909
|
return intersect;
|
|
5603
5910
|
}
|
|
5911
|
+
/**
|
|
5912
|
+
* Determines whether a bounding volume intersects the culling volume.
|
|
5913
|
+
*
|
|
5914
|
+
* @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
|
|
5915
|
+
* volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
|
|
5916
|
+
* the parent (and therefore this) volume is completely inside plane[planeIndex]
|
|
5917
|
+
* and that plane check can be skipped.
|
|
5918
|
+
*/
|
|
5604
5919
|
computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
|
|
5605
5920
|
assert(Number.isFinite(parentPlaneMask), "parentPlaneMask is required.");
|
|
5606
5921
|
if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
|
|
@@ -5624,9 +5939,9 @@ var __exports__ = (() => {
|
|
|
5624
5939
|
return mask;
|
|
5625
5940
|
}
|
|
5626
5941
|
};
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5942
|
+
CullingVolume.MASK_OUTSIDE = 4294967295;
|
|
5943
|
+
CullingVolume.MASK_INSIDE = 0;
|
|
5944
|
+
CullingVolume.MASK_INDETERMINATE = 2147483647;
|
|
5630
5945
|
|
|
5631
5946
|
// ../../node_modules/@math.gl/culling/dist/lib/perspective-off-center-frustum.js
|
|
5632
5947
|
var scratchPlaneUpVector = new Vector3();
|