@luma.gl/engine 9.0.5 → 9.0.6
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 +259 -104
- package/dist/dist.min.js +13 -13
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +2 -2
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +3 -3
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +6 -1
- package/dist.min.js +25 -0
- package/package.json +3 -3
- package/src/lib/pipeline-factory.ts +4 -3
- package/src/model/model.ts +6 -1
- package/src/.DS_Store +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -273,8 +273,6 @@ var __exports__ = (() => {
|
|
|
273
273
|
// ../../node_modules/@probe.gl/stats/dist/lib/stat.js
|
|
274
274
|
var Stat = class {
|
|
275
275
|
constructor(name, type) {
|
|
276
|
-
this.name = void 0;
|
|
277
|
-
this.type = void 0;
|
|
278
276
|
this.sampleSize = 1;
|
|
279
277
|
this.time = 0;
|
|
280
278
|
this.count = 0;
|
|
@@ -309,26 +307,31 @@ var __exports__ = (() => {
|
|
|
309
307
|
this.sampleSize = samples;
|
|
310
308
|
return this;
|
|
311
309
|
}
|
|
310
|
+
/** Call to increment count (+1) */
|
|
312
311
|
incrementCount() {
|
|
313
312
|
this.addCount(1);
|
|
314
313
|
return this;
|
|
315
314
|
}
|
|
315
|
+
/** Call to decrement count (-1) */
|
|
316
316
|
decrementCount() {
|
|
317
317
|
this.subtractCount(1);
|
|
318
318
|
return this;
|
|
319
319
|
}
|
|
320
|
+
/** Increase count */
|
|
320
321
|
addCount(value) {
|
|
321
322
|
this._count += value;
|
|
322
323
|
this._samples++;
|
|
323
324
|
this._checkSampling();
|
|
324
325
|
return this;
|
|
325
326
|
}
|
|
327
|
+
/** Decrease count */
|
|
326
328
|
subtractCount(value) {
|
|
327
329
|
this._count -= value;
|
|
328
330
|
this._samples++;
|
|
329
331
|
this._checkSampling();
|
|
330
332
|
return this;
|
|
331
333
|
}
|
|
334
|
+
/** Add an arbitrary timing and bump the count */
|
|
332
335
|
addTime(time) {
|
|
333
336
|
this._time += time;
|
|
334
337
|
this.lastTiming = time;
|
|
@@ -336,11 +339,13 @@ var __exports__ = (() => {
|
|
|
336
339
|
this._checkSampling();
|
|
337
340
|
return this;
|
|
338
341
|
}
|
|
342
|
+
/** Start a timer */
|
|
339
343
|
timeStart() {
|
|
340
344
|
this._startTime = getHiResTimestamp();
|
|
341
345
|
this._timerPending = true;
|
|
342
346
|
return this;
|
|
343
347
|
}
|
|
348
|
+
/** End a timer. Adds to time and bumps the timing count. */
|
|
344
349
|
timeEnd() {
|
|
345
350
|
if (!this._timerPending) {
|
|
346
351
|
return this;
|
|
@@ -353,18 +358,22 @@ var __exports__ = (() => {
|
|
|
353
358
|
getSampleAverageCount() {
|
|
354
359
|
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
|
|
355
360
|
}
|
|
361
|
+
/** Calculate average time / count for the previous window */
|
|
356
362
|
getSampleAverageTime() {
|
|
357
363
|
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
|
|
358
364
|
}
|
|
365
|
+
/** Calculate counts per second for the previous window */
|
|
359
366
|
getSampleHz() {
|
|
360
367
|
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
|
|
361
368
|
}
|
|
362
369
|
getAverageCount() {
|
|
363
370
|
return this.samples > 0 ? this.count / this.samples : 0;
|
|
364
371
|
}
|
|
372
|
+
/** Calculate average time / count */
|
|
365
373
|
getAverageTime() {
|
|
366
374
|
return this.samples > 0 ? this.time / this.samples : 0;
|
|
367
375
|
}
|
|
376
|
+
/** Calculate counts per second */
|
|
368
377
|
getHz() {
|
|
369
378
|
return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
|
|
370
379
|
}
|
|
@@ -385,23 +394,20 @@ var __exports__ = (() => {
|
|
|
385
394
|
// ../../node_modules/@probe.gl/stats/dist/lib/stats.js
|
|
386
395
|
var Stats = class {
|
|
387
396
|
constructor(options) {
|
|
388
|
-
this.id = void 0;
|
|
389
397
|
this.stats = {};
|
|
390
398
|
this.id = options.id;
|
|
391
399
|
this.stats = {};
|
|
392
400
|
this._initializeStats(options.stats);
|
|
393
401
|
Object.seal(this);
|
|
394
402
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return this._getOrCreate({
|
|
398
|
-
name,
|
|
399
|
-
type
|
|
400
|
-
});
|
|
403
|
+
/** Acquire a stat. Create if it doesn't exist. */
|
|
404
|
+
get(name, type = "count") {
|
|
405
|
+
return this._getOrCreate({ name, type });
|
|
401
406
|
}
|
|
402
407
|
get size() {
|
|
403
408
|
return Object.keys(this.stats).length;
|
|
404
409
|
}
|
|
410
|
+
/** Reset all stats */
|
|
405
411
|
reset() {
|
|
406
412
|
for (const stat of Object.values(this.stats)) {
|
|
407
413
|
stat.reset();
|
|
@@ -425,15 +431,11 @@ var __exports__ = (() => {
|
|
|
425
431
|
});
|
|
426
432
|
return table;
|
|
427
433
|
}
|
|
428
|
-
_initializeStats() {
|
|
429
|
-
let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
434
|
+
_initializeStats(stats = []) {
|
|
430
435
|
stats.forEach((stat) => this._getOrCreate(stat));
|
|
431
436
|
}
|
|
432
437
|
_getOrCreate(stat) {
|
|
433
|
-
const {
|
|
434
|
-
name,
|
|
435
|
-
type
|
|
436
|
-
} = stat;
|
|
438
|
+
const { name, type } = stat;
|
|
437
439
|
let result = this.stats[name];
|
|
438
440
|
if (!result) {
|
|
439
441
|
if (stat instanceof Stat) {
|
|
@@ -4721,17 +4723,11 @@ void main() {
|
|
|
4721
4723
|
printRowMajor: true,
|
|
4722
4724
|
_cartographicRadians: false
|
|
4723
4725
|
};
|
|
4724
|
-
globalThis.mathgl = globalThis.mathgl || {
|
|
4725
|
-
config: {
|
|
4726
|
-
...DEFAULT_CONFIG
|
|
4727
|
-
}
|
|
4728
|
-
};
|
|
4726
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
4729
4727
|
var config = globalThis.mathgl.config;
|
|
4730
|
-
function formatValue(value, {
|
|
4731
|
-
precision = config.precision
|
|
4732
|
-
} = {}) {
|
|
4728
|
+
function formatValue(value, { precision = config.precision } = {}) {
|
|
4733
4729
|
value = round(value);
|
|
4734
|
-
return
|
|
4730
|
+
return `${parseFloat(value.toPrecision(precision))}`;
|
|
4735
4731
|
}
|
|
4736
4732
|
function isArray(value) {
|
|
4737
4733
|
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
@@ -4775,28 +4771,12 @@ void main() {
|
|
|
4775
4771
|
}
|
|
4776
4772
|
|
|
4777
4773
|
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
4785
|
-
constructor: {
|
|
4786
|
-
value: cls,
|
|
4787
|
-
enumerable: false,
|
|
4788
|
-
writable: true,
|
|
4789
|
-
configurable: true
|
|
4790
|
-
}
|
|
4791
|
-
});
|
|
4792
|
-
if (Object.setPrototypeOf) {
|
|
4793
|
-
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
4794
|
-
} else {
|
|
4795
|
-
ExtendableBuiltin.__proto__ = cls;
|
|
4796
|
-
}
|
|
4797
|
-
return ExtendableBuiltin;
|
|
4798
|
-
}
|
|
4799
|
-
var MathArray = class extends _extendableBuiltin(Array) {
|
|
4774
|
+
var MathArray = class extends Array {
|
|
4775
|
+
// Common methods
|
|
4776
|
+
/**
|
|
4777
|
+
* Clone the current object
|
|
4778
|
+
* @returns a new copy of this object
|
|
4779
|
+
*/
|
|
4800
4780
|
clone() {
|
|
4801
4781
|
return new this.constructor().copy(this);
|
|
4802
4782
|
}
|
|
@@ -4816,7 +4796,10 @@ void main() {
|
|
|
4816
4796
|
return targetObject;
|
|
4817
4797
|
}
|
|
4818
4798
|
from(arrayOrObject) {
|
|
4819
|
-
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) :
|
|
4799
|
+
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
|
|
4800
|
+
// @ts-ignore
|
|
4801
|
+
this.fromObject(arrayOrObject)
|
|
4802
|
+
);
|
|
4820
4803
|
}
|
|
4821
4804
|
to(arrayOrObject) {
|
|
4822
4805
|
if (arrayOrObject === this) {
|
|
@@ -4827,18 +4810,20 @@ void main() {
|
|
|
4827
4810
|
toTarget(target) {
|
|
4828
4811
|
return target ? this.to(target) : this;
|
|
4829
4812
|
}
|
|
4813
|
+
/** @deprecated */
|
|
4830
4814
|
toFloat32Array() {
|
|
4831
4815
|
return new Float32Array(this);
|
|
4832
4816
|
}
|
|
4833
4817
|
toString() {
|
|
4834
4818
|
return this.formatString(config);
|
|
4835
4819
|
}
|
|
4820
|
+
/** Formats string according to options */
|
|
4836
4821
|
formatString(opts) {
|
|
4837
4822
|
let string = "";
|
|
4838
4823
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4839
4824
|
string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
|
|
4840
4825
|
}
|
|
4841
|
-
return
|
|
4826
|
+
return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
|
|
4842
4827
|
}
|
|
4843
4828
|
equals(array) {
|
|
4844
4829
|
if (!array || this.length !== array.length) {
|
|
@@ -4862,6 +4847,8 @@ void main() {
|
|
|
4862
4847
|
}
|
|
4863
4848
|
return true;
|
|
4864
4849
|
}
|
|
4850
|
+
// Modifiers
|
|
4851
|
+
/** Negates all values in this object */
|
|
4865
4852
|
negate() {
|
|
4866
4853
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4867
4854
|
this[i] = -this[i];
|
|
@@ -4879,12 +4866,14 @@ void main() {
|
|
|
4879
4866
|
}
|
|
4880
4867
|
return this.check();
|
|
4881
4868
|
}
|
|
4869
|
+
/** Minimal */
|
|
4882
4870
|
min(vector) {
|
|
4883
4871
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4884
4872
|
this[i] = Math.min(vector[i], this[i]);
|
|
4885
4873
|
}
|
|
4886
4874
|
return this.check();
|
|
4887
4875
|
}
|
|
4876
|
+
/** Maximal */
|
|
4888
4877
|
max(vector) {
|
|
4889
4878
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4890
4879
|
this[i] = Math.max(vector[i], this[i]);
|
|
@@ -4925,18 +4914,25 @@ void main() {
|
|
|
4925
4914
|
}
|
|
4926
4915
|
return this.check();
|
|
4927
4916
|
}
|
|
4917
|
+
/**
|
|
4918
|
+
* Multiplies all elements by `scale`
|
|
4919
|
+
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
4920
|
+
*/
|
|
4928
4921
|
multiplyByScalar(scalar) {
|
|
4929
4922
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4930
4923
|
this[i] *= scalar;
|
|
4931
4924
|
}
|
|
4932
4925
|
return this.check();
|
|
4933
4926
|
}
|
|
4927
|
+
// Debug checks
|
|
4928
|
+
/** Throws an error if array length is incorrect or contains illegal values */
|
|
4934
4929
|
check() {
|
|
4935
4930
|
if (config.debug && !this.validate()) {
|
|
4936
|
-
throw new Error(
|
|
4931
|
+
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
|
|
4937
4932
|
}
|
|
4938
4933
|
return this;
|
|
4939
4934
|
}
|
|
4935
|
+
/** Returns false if the array length is incorrect or contains illegal values */
|
|
4940
4936
|
validate() {
|
|
4941
4937
|
let valid = this.length === this.ELEMENTS;
|
|
4942
4938
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -4944,39 +4940,48 @@ void main() {
|
|
|
4944
4940
|
}
|
|
4945
4941
|
return valid;
|
|
4946
4942
|
}
|
|
4943
|
+
// three.js compatibility
|
|
4944
|
+
/** @deprecated */
|
|
4947
4945
|
sub(a) {
|
|
4948
4946
|
return this.subtract(a);
|
|
4949
4947
|
}
|
|
4948
|
+
/** @deprecated */
|
|
4950
4949
|
setScalar(a) {
|
|
4951
4950
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4952
4951
|
this[i] = a;
|
|
4953
4952
|
}
|
|
4954
4953
|
return this.check();
|
|
4955
4954
|
}
|
|
4955
|
+
/** @deprecated */
|
|
4956
4956
|
addScalar(a) {
|
|
4957
4957
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4958
4958
|
this[i] += a;
|
|
4959
4959
|
}
|
|
4960
4960
|
return this.check();
|
|
4961
4961
|
}
|
|
4962
|
+
/** @deprecated */
|
|
4962
4963
|
subScalar(a) {
|
|
4963
4964
|
return this.addScalar(-a);
|
|
4964
4965
|
}
|
|
4966
|
+
/** @deprecated */
|
|
4965
4967
|
multiplyScalar(scalar) {
|
|
4966
4968
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4967
4969
|
this[i] *= scalar;
|
|
4968
4970
|
}
|
|
4969
4971
|
return this.check();
|
|
4970
4972
|
}
|
|
4973
|
+
/** @deprecated */
|
|
4971
4974
|
divideScalar(a) {
|
|
4972
4975
|
return this.multiplyByScalar(1 / a);
|
|
4973
4976
|
}
|
|
4977
|
+
/** @deprecated */
|
|
4974
4978
|
clampScalar(min, max) {
|
|
4975
4979
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
4976
4980
|
this[i] = Math.min(Math.max(this[i], min), max);
|
|
4977
4981
|
}
|
|
4978
4982
|
return this.check();
|
|
4979
4983
|
}
|
|
4984
|
+
/** @deprecated */
|
|
4980
4985
|
get elements() {
|
|
4981
4986
|
return this;
|
|
4982
4987
|
}
|
|
@@ -4996,13 +5001,13 @@ void main() {
|
|
|
4996
5001
|
}
|
|
4997
5002
|
function checkNumber(value) {
|
|
4998
5003
|
if (!Number.isFinite(value)) {
|
|
4999
|
-
throw new Error(
|
|
5004
|
+
throw new Error(`Invalid number ${JSON.stringify(value)}`);
|
|
5000
5005
|
}
|
|
5001
5006
|
return value;
|
|
5002
5007
|
}
|
|
5003
5008
|
function checkVector(v, length, callerName = "") {
|
|
5004
5009
|
if (config.debug && !validateVector(v, length)) {
|
|
5005
|
-
throw new Error(
|
|
5010
|
+
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
|
|
5006
5011
|
}
|
|
5007
5012
|
return v;
|
|
5008
5013
|
}
|
|
@@ -5010,12 +5015,13 @@ void main() {
|
|
|
5010
5015
|
// ../../node_modules/@math.gl/core/dist/lib/assert.js
|
|
5011
5016
|
function assert2(condition, message) {
|
|
5012
5017
|
if (!condition) {
|
|
5013
|
-
throw new Error(
|
|
5018
|
+
throw new Error(`math.gl assertion ${message}`);
|
|
5014
5019
|
}
|
|
5015
5020
|
}
|
|
5016
5021
|
|
|
5017
5022
|
// ../../node_modules/@math.gl/core/dist/classes/base/vector.js
|
|
5018
5023
|
var Vector = class extends MathArray {
|
|
5024
|
+
// ACCESSORS
|
|
5019
5025
|
get x() {
|
|
5020
5026
|
return this[0];
|
|
5021
5027
|
}
|
|
@@ -5028,12 +5034,24 @@ void main() {
|
|
|
5028
5034
|
set y(value) {
|
|
5029
5035
|
this[1] = checkNumber(value);
|
|
5030
5036
|
}
|
|
5037
|
+
/**
|
|
5038
|
+
* Returns the length of the vector from the origin to the point described by this vector
|
|
5039
|
+
*
|
|
5040
|
+
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
|
|
5041
|
+
* Instead we provide `len` and `magnitude`
|
|
5042
|
+
*/
|
|
5031
5043
|
len() {
|
|
5032
5044
|
return Math.sqrt(this.lengthSquared());
|
|
5033
5045
|
}
|
|
5046
|
+
/**
|
|
5047
|
+
* Returns the length of the vector from the origin to the point described by this vector
|
|
5048
|
+
*/
|
|
5034
5049
|
magnitude() {
|
|
5035
5050
|
return this.len();
|
|
5036
5051
|
}
|
|
5052
|
+
/**
|
|
5053
|
+
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
5054
|
+
*/
|
|
5037
5055
|
lengthSquared() {
|
|
5038
5056
|
let length = 0;
|
|
5039
5057
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -5041,6 +5059,9 @@ void main() {
|
|
|
5041
5059
|
}
|
|
5042
5060
|
return length;
|
|
5043
5061
|
}
|
|
5062
|
+
/**
|
|
5063
|
+
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
5064
|
+
*/
|
|
5044
5065
|
magnitudeSquared() {
|
|
5045
5066
|
return this.lengthSquared();
|
|
5046
5067
|
}
|
|
@@ -5062,6 +5083,7 @@ void main() {
|
|
|
5062
5083
|
}
|
|
5063
5084
|
return checkNumber(product);
|
|
5064
5085
|
}
|
|
5086
|
+
// MODIFIERS
|
|
5065
5087
|
normalize() {
|
|
5066
5088
|
const length = this.magnitude();
|
|
5067
5089
|
if (length !== 0) {
|
|
@@ -5087,6 +5109,7 @@ void main() {
|
|
|
5087
5109
|
}
|
|
5088
5110
|
return this.check();
|
|
5089
5111
|
}
|
|
5112
|
+
// THREE.js compatibility
|
|
5090
5113
|
lengthSq() {
|
|
5091
5114
|
return this.lengthSquared();
|
|
5092
5115
|
}
|
|
@@ -5359,6 +5382,12 @@ void main() {
|
|
|
5359
5382
|
}
|
|
5360
5383
|
return ZERO;
|
|
5361
5384
|
}
|
|
5385
|
+
/**
|
|
5386
|
+
* @class
|
|
5387
|
+
* @param x
|
|
5388
|
+
* @param y
|
|
5389
|
+
* @param z
|
|
5390
|
+
*/
|
|
5362
5391
|
constructor(x = 0, y = 0, z = 0) {
|
|
5363
5392
|
super(-0, -0, -0);
|
|
5364
5393
|
if (arguments.length === 1 && isArray(x)) {
|
|
@@ -5403,6 +5432,7 @@ void main() {
|
|
|
5403
5432
|
object.z = this[2];
|
|
5404
5433
|
return object;
|
|
5405
5434
|
}
|
|
5435
|
+
// Getters/setters
|
|
5406
5436
|
get ELEMENTS() {
|
|
5407
5437
|
return 3;
|
|
5408
5438
|
}
|
|
@@ -5412,41 +5442,38 @@ void main() {
|
|
|
5412
5442
|
set z(value) {
|
|
5413
5443
|
this[2] = checkNumber(value);
|
|
5414
5444
|
}
|
|
5445
|
+
// ACCESSORS
|
|
5415
5446
|
angle(vector) {
|
|
5416
5447
|
return angle(this, vector);
|
|
5417
5448
|
}
|
|
5449
|
+
// MODIFIERS
|
|
5418
5450
|
cross(vector) {
|
|
5419
5451
|
cross(this, this, vector);
|
|
5420
5452
|
return this.check();
|
|
5421
5453
|
}
|
|
5422
|
-
rotateX({
|
|
5423
|
-
radians,
|
|
5424
|
-
origin = ORIGIN
|
|
5425
|
-
}) {
|
|
5454
|
+
rotateX({ radians, origin = ORIGIN }) {
|
|
5426
5455
|
rotateX(this, this, origin, radians);
|
|
5427
5456
|
return this.check();
|
|
5428
5457
|
}
|
|
5429
|
-
rotateY({
|
|
5430
|
-
radians,
|
|
5431
|
-
origin = ORIGIN
|
|
5432
|
-
}) {
|
|
5458
|
+
rotateY({ radians, origin = ORIGIN }) {
|
|
5433
5459
|
rotateY(this, this, origin, radians);
|
|
5434
5460
|
return this.check();
|
|
5435
5461
|
}
|
|
5436
|
-
rotateZ({
|
|
5437
|
-
radians,
|
|
5438
|
-
origin = ORIGIN
|
|
5439
|
-
}) {
|
|
5462
|
+
rotateZ({ radians, origin = ORIGIN }) {
|
|
5440
5463
|
rotateZ(this, this, origin, radians);
|
|
5441
5464
|
return this.check();
|
|
5442
5465
|
}
|
|
5466
|
+
// Transforms
|
|
5467
|
+
// transforms as point (4th component is implicitly 1)
|
|
5443
5468
|
transform(matrix4) {
|
|
5444
5469
|
return this.transformAsPoint(matrix4);
|
|
5445
5470
|
}
|
|
5471
|
+
// transforms as point (4th component is implicitly 1)
|
|
5446
5472
|
transformAsPoint(matrix4) {
|
|
5447
5473
|
transformMat42(this, this, matrix4);
|
|
5448
5474
|
return this.check();
|
|
5449
5475
|
}
|
|
5476
|
+
// transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
|
|
5450
5477
|
transformAsVector(matrix4) {
|
|
5451
5478
|
vec3_transformMat4AsVector(this, this, matrix4);
|
|
5452
5479
|
return this.check();
|
|
@@ -5467,19 +5494,29 @@ void main() {
|
|
|
5467
5494
|
|
|
5468
5495
|
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
5469
5496
|
var Matrix = class extends MathArray {
|
|
5497
|
+
// fromObject(object) {
|
|
5498
|
+
// const array = object.elements;
|
|
5499
|
+
// return this.fromRowMajor(array);
|
|
5500
|
+
// }
|
|
5501
|
+
// toObject(object) {
|
|
5502
|
+
// const array = object.elements;
|
|
5503
|
+
// this.toRowMajor(array);
|
|
5504
|
+
// return object;
|
|
5505
|
+
// }
|
|
5506
|
+
// TODO better override formatString?
|
|
5470
5507
|
toString() {
|
|
5471
5508
|
let string = "[";
|
|
5472
5509
|
if (config.printRowMajor) {
|
|
5473
5510
|
string += "row-major:";
|
|
5474
5511
|
for (let row = 0; row < this.RANK; ++row) {
|
|
5475
5512
|
for (let col = 0; col < this.RANK; ++col) {
|
|
5476
|
-
string +=
|
|
5513
|
+
string += ` ${this[col * this.RANK + row]}`;
|
|
5477
5514
|
}
|
|
5478
5515
|
}
|
|
5479
5516
|
} else {
|
|
5480
5517
|
string += "column-major:";
|
|
5481
5518
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
5482
|
-
string +=
|
|
5519
|
+
string += ` ${this[i]}`;
|
|
5483
5520
|
}
|
|
5484
5521
|
}
|
|
5485
5522
|
string += "]";
|
|
@@ -5488,9 +5525,11 @@ void main() {
|
|
|
5488
5525
|
getElementIndex(row, col) {
|
|
5489
5526
|
return col * this.RANK + row;
|
|
5490
5527
|
}
|
|
5528
|
+
// By default assumes row major indices
|
|
5491
5529
|
getElement(row, col) {
|
|
5492
5530
|
return this[col * this.RANK + row];
|
|
5493
5531
|
}
|
|
5532
|
+
// By default assumes row major indices
|
|
5494
5533
|
setElement(row, col, value) {
|
|
5495
5534
|
this[col * this.RANK + row] = checkNumber(value);
|
|
5496
5535
|
return this;
|
|
@@ -6256,6 +6295,7 @@ void main() {
|
|
|
6256
6295
|
this[15] = array[15];
|
|
6257
6296
|
return this.check();
|
|
6258
6297
|
}
|
|
6298
|
+
// eslint-disable-next-line max-params
|
|
6259
6299
|
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
6260
6300
|
this[0] = m00;
|
|
6261
6301
|
this[1] = m10;
|
|
@@ -6275,6 +6315,8 @@ void main() {
|
|
|
6275
6315
|
this[15] = m33;
|
|
6276
6316
|
return this.check();
|
|
6277
6317
|
}
|
|
6318
|
+
// accepts row major order, stores as column major
|
|
6319
|
+
// eslint-disable-next-line max-params
|
|
6278
6320
|
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
6279
6321
|
this[0] = m00;
|
|
6280
6322
|
this[1] = m10;
|
|
@@ -6313,25 +6355,41 @@ void main() {
|
|
|
6313
6355
|
result[15] = this[15];
|
|
6314
6356
|
return result;
|
|
6315
6357
|
}
|
|
6358
|
+
// Constructors
|
|
6359
|
+
/** Set to identity matrix */
|
|
6316
6360
|
identity() {
|
|
6317
6361
|
return this.copy(IDENTITY_MATRIX);
|
|
6318
6362
|
}
|
|
6363
|
+
/**
|
|
6364
|
+
*
|
|
6365
|
+
* @param object
|
|
6366
|
+
* @returns self
|
|
6367
|
+
*/
|
|
6368
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6319
6369
|
fromObject(object) {
|
|
6320
6370
|
return this.check();
|
|
6321
6371
|
}
|
|
6372
|
+
/**
|
|
6373
|
+
* Calculates a 4x4 matrix from the given quaternion
|
|
6374
|
+
* @param quaternion Quaternion to create matrix from
|
|
6375
|
+
* @returns self
|
|
6376
|
+
*/
|
|
6322
6377
|
fromQuaternion(quaternion) {
|
|
6323
6378
|
fromQuat(this, quaternion);
|
|
6324
6379
|
return this.check();
|
|
6325
6380
|
}
|
|
6381
|
+
/**
|
|
6382
|
+
* Generates a frustum matrix with the given bounds
|
|
6383
|
+
* @param view.left - Left bound of the frustum
|
|
6384
|
+
* @param view.right - Right bound of the frustum
|
|
6385
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
6386
|
+
* @param view.top - Top bound of the frustum
|
|
6387
|
+
* @param view.near - Near bound of the frustum
|
|
6388
|
+
* @param view.far - Far bound of the frustum. Can be set to Infinity.
|
|
6389
|
+
* @returns self
|
|
6390
|
+
*/
|
|
6326
6391
|
frustum(view) {
|
|
6327
|
-
const {
|
|
6328
|
-
left,
|
|
6329
|
-
right,
|
|
6330
|
-
bottom,
|
|
6331
|
-
top,
|
|
6332
|
-
near = DEFAULT_NEAR,
|
|
6333
|
-
far = DEFAULT_FAR
|
|
6334
|
-
} = view;
|
|
6392
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
6335
6393
|
if (far === Infinity) {
|
|
6336
6394
|
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
6337
6395
|
} else {
|
|
@@ -6339,35 +6397,47 @@ void main() {
|
|
|
6339
6397
|
}
|
|
6340
6398
|
return this.check();
|
|
6341
6399
|
}
|
|
6400
|
+
/**
|
|
6401
|
+
* Generates a look-at matrix with the given eye position, focal point,
|
|
6402
|
+
* and up axis
|
|
6403
|
+
* @param view.eye - (vector) Position of the viewer
|
|
6404
|
+
* @param view.center - (vector) Point the viewer is looking at
|
|
6405
|
+
* @param view.up - (vector) Up axis
|
|
6406
|
+
* @returns self
|
|
6407
|
+
*/
|
|
6342
6408
|
lookAt(view) {
|
|
6343
|
-
const {
|
|
6344
|
-
eye,
|
|
6345
|
-
center = [0, 0, 0],
|
|
6346
|
-
up = [0, 1, 0]
|
|
6347
|
-
} = view;
|
|
6409
|
+
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
|
|
6348
6410
|
lookAt(this, eye, center, up);
|
|
6349
6411
|
return this.check();
|
|
6350
6412
|
}
|
|
6413
|
+
/**
|
|
6414
|
+
* Generates a orthogonal projection matrix with the given bounds
|
|
6415
|
+
* from "traditional" view space parameters
|
|
6416
|
+
* @param view.left - Left bound of the frustum
|
|
6417
|
+
* @param view.right number Right bound of the frustum
|
|
6418
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
6419
|
+
* @param view.top number Top bound of the frustum
|
|
6420
|
+
* @param view.near - Near bound of the frustum
|
|
6421
|
+
* @param view.far number Far bound of the frustum
|
|
6422
|
+
* @returns self
|
|
6423
|
+
*/
|
|
6351
6424
|
ortho(view) {
|
|
6352
|
-
const {
|
|
6353
|
-
left,
|
|
6354
|
-
right,
|
|
6355
|
-
bottom,
|
|
6356
|
-
top,
|
|
6357
|
-
near = DEFAULT_NEAR,
|
|
6358
|
-
far = DEFAULT_FAR
|
|
6359
|
-
} = view;
|
|
6425
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
6360
6426
|
ortho(this, left, right, bottom, top, near, far);
|
|
6361
6427
|
return this.check();
|
|
6362
6428
|
}
|
|
6429
|
+
/**
|
|
6430
|
+
* Generates an orthogonal projection matrix with the same parameters
|
|
6431
|
+
* as a perspective matrix (plus focalDistance)
|
|
6432
|
+
* @param view.fovy Vertical field of view in radians
|
|
6433
|
+
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
|
|
6434
|
+
* @param view.focalDistance Distance in the view frustum used for extent calculations
|
|
6435
|
+
* @param view.near Near bound of the frustum
|
|
6436
|
+
* @param view.far Far bound of the frustum
|
|
6437
|
+
* @returns self
|
|
6438
|
+
*/
|
|
6363
6439
|
orthographic(view) {
|
|
6364
|
-
const {
|
|
6365
|
-
fovy = DEFAULT_FOVY,
|
|
6366
|
-
aspect = DEFAULT_ASPECT,
|
|
6367
|
-
focalDistance = 1,
|
|
6368
|
-
near = DEFAULT_NEAR,
|
|
6369
|
-
far = DEFAULT_FAR
|
|
6370
|
-
} = view;
|
|
6440
|
+
const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
6371
6441
|
checkRadians(fovy);
|
|
6372
6442
|
const halfY = fovy / 2;
|
|
6373
6443
|
const top = focalDistance * Math.tan(halfY);
|
|
@@ -6381,32 +6451,53 @@ void main() {
|
|
|
6381
6451
|
far
|
|
6382
6452
|
});
|
|
6383
6453
|
}
|
|
6454
|
+
/**
|
|
6455
|
+
* Generates a perspective projection matrix with the given bounds
|
|
6456
|
+
* @param view.fovy Vertical field of view in radians
|
|
6457
|
+
* @param view.aspect Aspect ratio. typically viewport width/height
|
|
6458
|
+
* @param view.near Near bound of the frustum
|
|
6459
|
+
* @param view.far Far bound of the frustum
|
|
6460
|
+
* @returns self
|
|
6461
|
+
*/
|
|
6384
6462
|
perspective(view) {
|
|
6385
|
-
const {
|
|
6386
|
-
fovy = 45 * Math.PI / 180,
|
|
6387
|
-
aspect = 1,
|
|
6388
|
-
near = 0.1,
|
|
6389
|
-
far = 500
|
|
6390
|
-
} = view;
|
|
6463
|
+
const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
|
|
6391
6464
|
checkRadians(fovy);
|
|
6392
6465
|
perspective(this, fovy, aspect, near, far);
|
|
6393
6466
|
return this.check();
|
|
6394
6467
|
}
|
|
6468
|
+
// Accessors
|
|
6395
6469
|
determinant() {
|
|
6396
6470
|
return determinant(this);
|
|
6397
6471
|
}
|
|
6472
|
+
/**
|
|
6473
|
+
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
6474
|
+
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
6475
|
+
* @param result
|
|
6476
|
+
* @returns self
|
|
6477
|
+
*/
|
|
6398
6478
|
getScale(result = [-0, -0, -0]) {
|
|
6399
6479
|
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
6400
6480
|
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
6401
6481
|
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
6402
6482
|
return result;
|
|
6403
6483
|
}
|
|
6484
|
+
/**
|
|
6485
|
+
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
6486
|
+
* @param result
|
|
6487
|
+
* @returns self
|
|
6488
|
+
*/
|
|
6404
6489
|
getTranslation(result = [-0, -0, -0]) {
|
|
6405
6490
|
result[0] = this[12];
|
|
6406
6491
|
result[1] = this[13];
|
|
6407
6492
|
result[2] = this[14];
|
|
6408
6493
|
return result;
|
|
6409
6494
|
}
|
|
6495
|
+
/**
|
|
6496
|
+
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
6497
|
+
* @param result
|
|
6498
|
+
* @param scaleResult
|
|
6499
|
+
* @returns self
|
|
6500
|
+
*/
|
|
6410
6501
|
getRotation(result, scaleResult) {
|
|
6411
6502
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
6412
6503
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -6432,6 +6523,12 @@ void main() {
|
|
|
6432
6523
|
result[15] = 1;
|
|
6433
6524
|
return result;
|
|
6434
6525
|
}
|
|
6526
|
+
/**
|
|
6527
|
+
*
|
|
6528
|
+
* @param result
|
|
6529
|
+
* @param scaleResult
|
|
6530
|
+
* @returns self
|
|
6531
|
+
*/
|
|
6435
6532
|
getRotationMatrix3(result, scaleResult) {
|
|
6436
6533
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
6437
6534
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -6450,6 +6547,7 @@ void main() {
|
|
|
6450
6547
|
result[8] = this[10] * inverseScale2;
|
|
6451
6548
|
return result;
|
|
6452
6549
|
}
|
|
6550
|
+
// Modifiers
|
|
6453
6551
|
transpose() {
|
|
6454
6552
|
transpose(this, this);
|
|
6455
6553
|
return this.check();
|
|
@@ -6458,6 +6556,7 @@ void main() {
|
|
|
6458
6556
|
invert(this, this);
|
|
6459
6557
|
return this.check();
|
|
6460
6558
|
}
|
|
6559
|
+
// Operations
|
|
6461
6560
|
multiplyLeft(a) {
|
|
6462
6561
|
multiply(this, a, this);
|
|
6463
6562
|
return this.check();
|
|
@@ -6466,33 +6565,68 @@ void main() {
|
|
|
6466
6565
|
multiply(this, this, a);
|
|
6467
6566
|
return this.check();
|
|
6468
6567
|
}
|
|
6568
|
+
// Rotates a matrix by the given angle around the X axis
|
|
6469
6569
|
rotateX(radians) {
|
|
6470
6570
|
rotateX2(this, this, radians);
|
|
6471
6571
|
return this.check();
|
|
6472
6572
|
}
|
|
6573
|
+
// Rotates a matrix by the given angle around the Y axis.
|
|
6473
6574
|
rotateY(radians) {
|
|
6474
6575
|
rotateY2(this, this, radians);
|
|
6475
6576
|
return this.check();
|
|
6476
6577
|
}
|
|
6578
|
+
/**
|
|
6579
|
+
* Rotates a matrix by the given angle around the Z axis.
|
|
6580
|
+
* @param radians
|
|
6581
|
+
* @returns self
|
|
6582
|
+
*/
|
|
6477
6583
|
rotateZ(radians) {
|
|
6478
6584
|
rotateZ2(this, this, radians);
|
|
6479
6585
|
return this.check();
|
|
6480
6586
|
}
|
|
6587
|
+
/**
|
|
6588
|
+
*
|
|
6589
|
+
* @param param0
|
|
6590
|
+
* @returns self
|
|
6591
|
+
*/
|
|
6481
6592
|
rotateXYZ(angleXYZ) {
|
|
6482
6593
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
6483
6594
|
}
|
|
6595
|
+
/**
|
|
6596
|
+
*
|
|
6597
|
+
* @param radians
|
|
6598
|
+
* @param axis
|
|
6599
|
+
* @returns self
|
|
6600
|
+
*/
|
|
6484
6601
|
rotateAxis(radians, axis) {
|
|
6485
6602
|
rotate(this, this, radians, axis);
|
|
6486
6603
|
return this.check();
|
|
6487
6604
|
}
|
|
6605
|
+
/**
|
|
6606
|
+
*
|
|
6607
|
+
* @param factor
|
|
6608
|
+
* @returns self
|
|
6609
|
+
*/
|
|
6488
6610
|
scale(factor) {
|
|
6489
6611
|
scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
6490
6612
|
return this.check();
|
|
6491
6613
|
}
|
|
6614
|
+
/**
|
|
6615
|
+
*
|
|
6616
|
+
* @param vec
|
|
6617
|
+
* @returns self
|
|
6618
|
+
*/
|
|
6492
6619
|
translate(vector) {
|
|
6493
6620
|
translate(this, this, vector);
|
|
6494
6621
|
return this.check();
|
|
6495
6622
|
}
|
|
6623
|
+
// Transforms
|
|
6624
|
+
/**
|
|
6625
|
+
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
6626
|
+
* @param vector
|
|
6627
|
+
* @param result
|
|
6628
|
+
* @returns self
|
|
6629
|
+
*/
|
|
6496
6630
|
transform(vector, result) {
|
|
6497
6631
|
if (vector.length === 4) {
|
|
6498
6632
|
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
@@ -6501,10 +6635,14 @@ void main() {
|
|
|
6501
6635
|
}
|
|
6502
6636
|
return this.transformAsPoint(vector, result);
|
|
6503
6637
|
}
|
|
6638
|
+
/**
|
|
6639
|
+
* Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
6640
|
+
* @param vector
|
|
6641
|
+
* @param result
|
|
6642
|
+
* @returns self
|
|
6643
|
+
*/
|
|
6504
6644
|
transformAsPoint(vector, result) {
|
|
6505
|
-
const {
|
|
6506
|
-
length
|
|
6507
|
-
} = vector;
|
|
6645
|
+
const { length } = vector;
|
|
6508
6646
|
let out;
|
|
6509
6647
|
switch (length) {
|
|
6510
6648
|
case 2:
|
|
@@ -6519,6 +6657,12 @@ void main() {
|
|
|
6519
6657
|
checkVector(out, vector.length);
|
|
6520
6658
|
return out;
|
|
6521
6659
|
}
|
|
6660
|
+
/**
|
|
6661
|
+
* Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
6662
|
+
* @param vector
|
|
6663
|
+
* @param result
|
|
6664
|
+
* @returns self
|
|
6665
|
+
*/
|
|
6522
6666
|
transformAsVector(vector, result) {
|
|
6523
6667
|
let out;
|
|
6524
6668
|
switch (vector.length) {
|
|
@@ -6534,15 +6678,19 @@ void main() {
|
|
|
6534
6678
|
checkVector(out, vector.length);
|
|
6535
6679
|
return out;
|
|
6536
6680
|
}
|
|
6681
|
+
/** @deprecated */
|
|
6537
6682
|
transformPoint(vector, result) {
|
|
6538
6683
|
return this.transformAsPoint(vector, result);
|
|
6539
6684
|
}
|
|
6685
|
+
/** @deprecated */
|
|
6540
6686
|
transformVector(vector, result) {
|
|
6541
6687
|
return this.transformAsPoint(vector, result);
|
|
6542
6688
|
}
|
|
6689
|
+
/** @deprecated */
|
|
6543
6690
|
transformDirection(vector, result) {
|
|
6544
6691
|
return this.transformAsVector(vector, result);
|
|
6545
6692
|
}
|
|
6693
|
+
// three.js math API compatibility
|
|
6546
6694
|
makeRotationX(radians) {
|
|
6547
6695
|
return this.identity().rotateX(radians);
|
|
6548
6696
|
}
|
|
@@ -6845,6 +6993,8 @@ void main() {
|
|
|
6845
6993
|
const varyingHash = "-";
|
|
6846
6994
|
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
6847
6995
|
switch (this.device.type) {
|
|
6996
|
+
case "webgl":
|
|
6997
|
+
return `${vsHash}/${fsHash}V${varyingHash}BL${bufferLayoutHash}`;
|
|
6848
6998
|
default:
|
|
6849
6999
|
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
6850
7000
|
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}`;
|
|
@@ -7155,7 +7305,12 @@ void main() {
|
|
|
7155
7305
|
vertexCount: this.vertexCount,
|
|
7156
7306
|
instanceCount: this.instanceCount,
|
|
7157
7307
|
indexCount,
|
|
7158
|
-
transformFeedback: this.transformFeedback
|
|
7308
|
+
transformFeedback: this.transformFeedback || void 0,
|
|
7309
|
+
// WebGL shares underlying cached pipelines even for models that have different parameters and topology,
|
|
7310
|
+
// so we must provide our unique parameters to each draw
|
|
7311
|
+
// (In WebGPU most parameters are encoded in the pipeline and cannot be changed per draw call)
|
|
7312
|
+
parameters: this.parameters,
|
|
7313
|
+
topology: this.topology
|
|
7159
7314
|
});
|
|
7160
7315
|
} finally {
|
|
7161
7316
|
this._logDrawCallEnd();
|