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