@luma.gl/engine 9.0.0-beta.8 → 9.0.0-beta.9

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 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
- get(name) {
396
- let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
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) {
@@ -1285,62 +1287,6 @@ ${moduleSource}
1285
1287
  `;
1286
1288
  }
1287
1289
  }
1288
- function getVersionDefines(platformInfo) {
1289
- let versionDefines = "";
1290
- if (platformInfo.features.has("webgl2")) {
1291
- versionDefines += glsl`\
1292
- # define FEATURE_GLSL_DERIVATIVES
1293
- # define FEATURE_GLSL_DRAW_BUFFERS
1294
- # define FEATURE_GLSL_FRAG_DEPTH
1295
- # define FEATURE_GLSL_TEXTURE_LOD
1296
- `;
1297
- }
1298
- if (!platformInfo.features.has("webgl2")) {
1299
- if (platformInfo.features.has("glsl-frag-depth")) {
1300
- versionDefines += glsl`\
1301
-
1302
- // FEATURE_GLSL_FRAG_DEPTH => gl_FragDepth is available
1303
- #ifdef GL_EXT_frag_depth
1304
- # extension GL_EXT_frag_depth : enable
1305
- # define FEATURE_GLSL_FRAG_DEPTH
1306
- # define FRAG_DEPTH
1307
- # define gl_FragDepth gl_FragDepthEXT
1308
- #endif
1309
- `;
1310
- }
1311
- if (platformInfo?.features.has("glsl-derivatives")) {
1312
- versionDefines += glsl`\
1313
-
1314
- // FEATURE_GLSL_DERIVATIVES => dxdF, dxdY and fwidth are available
1315
- #if defined(GL_OES_standard_derivatives) || defined(FEATURE_GLSL_DERIVATIVES)
1316
- # extension GL_OES_standard_derivatives : enable
1317
- # define FEATURE_GLSL_DERIVATIVES
1318
- #endif
1319
- `;
1320
- }
1321
- if (platformInfo?.features.has("glsl-frag-data")) {
1322
- versionDefines += glsl`\
1323
-
1324
- // FEATURE_GLSL_DRAW_BUFFERS => gl_FragData[] is available
1325
- #ifdef GL_EXT_draw_buffers
1326
- # extension GL_EXT_draw_buffers : require
1327
- # define FEATURE_GLSL_DRAW_BUFFERS
1328
- #endif
1329
- `;
1330
- }
1331
- if (platformInfo?.features.has("glsl-texture-lod")) {
1332
- versionDefines += glsl`\
1333
- // TEXTURE_LOD => texture2DLod etc are available
1334
- #ifdef GL_EXT_shader_texture_lod
1335
- # extension GL_EXT_shader_texture_lod : enable
1336
- # define FEATURE_GLSL_TEXTURE_LOD
1337
- # define TEXTURE_LOD
1338
- #endif
1339
- `;
1340
- }
1341
- }
1342
- return versionDefines;
1343
- }
1344
1290
 
1345
1291
  // ../shadertools/src/lib/shader-transpiler/transpile-glsl-shader.ts
1346
1292
  function transpileGLSLShader(source, stage) {
@@ -1628,7 +1574,6 @@ precision highp float;
1628
1574
  ${getShaderNameDefine({ id, source, stage })}
1629
1575
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
1630
1576
  ${getPlatformShaderDefines(platformInfo)}
1631
- ${getVersionDefines(platformInfo)}
1632
1577
  ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
1633
1578
 
1634
1579
  // ----- APPLICATION DEFINES -------------------------
@@ -4778,17 +4723,11 @@ void main() {
4778
4723
  printRowMajor: true,
4779
4724
  _cartographicRadians: false
4780
4725
  };
4781
- globalThis.mathgl = globalThis.mathgl || {
4782
- config: {
4783
- ...DEFAULT_CONFIG
4784
- }
4785
- };
4726
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4786
4727
  var config = globalThis.mathgl.config;
4787
- function formatValue(value, {
4788
- precision = config.precision
4789
- } = {}) {
4728
+ function formatValue(value, { precision = config.precision } = {}) {
4790
4729
  value = round(value);
4791
- return "".concat(parseFloat(value.toPrecision(precision)));
4730
+ return `${parseFloat(value.toPrecision(precision))}`;
4792
4731
  }
4793
4732
  function isArray(value) {
4794
4733
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -4832,28 +4771,12 @@ void main() {
4832
4771
  }
4833
4772
 
4834
4773
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4835
- function _extendableBuiltin(cls) {
4836
- function ExtendableBuiltin() {
4837
- var instance = Reflect.construct(cls, Array.from(arguments));
4838
- Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
4839
- return instance;
4840
- }
4841
- ExtendableBuiltin.prototype = Object.create(cls.prototype, {
4842
- constructor: {
4843
- value: cls,
4844
- enumerable: false,
4845
- writable: true,
4846
- configurable: true
4847
- }
4848
- });
4849
- if (Object.setPrototypeOf) {
4850
- Object.setPrototypeOf(ExtendableBuiltin, cls);
4851
- } else {
4852
- ExtendableBuiltin.__proto__ = cls;
4853
- }
4854
- return ExtendableBuiltin;
4855
- }
4856
- 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
+ */
4857
4780
  clone() {
4858
4781
  return new this.constructor().copy(this);
4859
4782
  }
@@ -4873,7 +4796,10 @@ void main() {
4873
4796
  return targetObject;
4874
4797
  }
4875
4798
  from(arrayOrObject) {
4876
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
4799
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4800
+ // @ts-ignore
4801
+ this.fromObject(arrayOrObject)
4802
+ );
4877
4803
  }
4878
4804
  to(arrayOrObject) {
4879
4805
  if (arrayOrObject === this) {
@@ -4884,18 +4810,20 @@ void main() {
4884
4810
  toTarget(target) {
4885
4811
  return target ? this.to(target) : this;
4886
4812
  }
4813
+ /** @deprecated */
4887
4814
  toFloat32Array() {
4888
4815
  return new Float32Array(this);
4889
4816
  }
4890
4817
  toString() {
4891
4818
  return this.formatString(config);
4892
4819
  }
4820
+ /** Formats string according to options */
4893
4821
  formatString(opts) {
4894
4822
  let string = "";
4895
4823
  for (let i = 0; i < this.ELEMENTS; ++i) {
4896
4824
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4897
4825
  }
4898
- return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
4826
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4899
4827
  }
4900
4828
  equals(array) {
4901
4829
  if (!array || this.length !== array.length) {
@@ -4919,6 +4847,8 @@ void main() {
4919
4847
  }
4920
4848
  return true;
4921
4849
  }
4850
+ // Modifiers
4851
+ /** Negates all values in this object */
4922
4852
  negate() {
4923
4853
  for (let i = 0; i < this.ELEMENTS; ++i) {
4924
4854
  this[i] = -this[i];
@@ -4936,12 +4866,14 @@ void main() {
4936
4866
  }
4937
4867
  return this.check();
4938
4868
  }
4869
+ /** Minimal */
4939
4870
  min(vector) {
4940
4871
  for (let i = 0; i < this.ELEMENTS; ++i) {
4941
4872
  this[i] = Math.min(vector[i], this[i]);
4942
4873
  }
4943
4874
  return this.check();
4944
4875
  }
4876
+ /** Maximal */
4945
4877
  max(vector) {
4946
4878
  for (let i = 0; i < this.ELEMENTS; ++i) {
4947
4879
  this[i] = Math.max(vector[i], this[i]);
@@ -4982,18 +4914,25 @@ void main() {
4982
4914
  }
4983
4915
  return this.check();
4984
4916
  }
4917
+ /**
4918
+ * Multiplies all elements by `scale`
4919
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4920
+ */
4985
4921
  multiplyByScalar(scalar) {
4986
4922
  for (let i = 0; i < this.ELEMENTS; ++i) {
4987
4923
  this[i] *= scalar;
4988
4924
  }
4989
4925
  return this.check();
4990
4926
  }
4927
+ // Debug checks
4928
+ /** Throws an error if array length is incorrect or contains illegal values */
4991
4929
  check() {
4992
4930
  if (config.debug && !this.validate()) {
4993
- throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
4931
+ throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
4994
4932
  }
4995
4933
  return this;
4996
4934
  }
4935
+ /** Returns false if the array length is incorrect or contains illegal values */
4997
4936
  validate() {
4998
4937
  let valid = this.length === this.ELEMENTS;
4999
4938
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -5001,39 +4940,48 @@ void main() {
5001
4940
  }
5002
4941
  return valid;
5003
4942
  }
4943
+ // three.js compatibility
4944
+ /** @deprecated */
5004
4945
  sub(a) {
5005
4946
  return this.subtract(a);
5006
4947
  }
4948
+ /** @deprecated */
5007
4949
  setScalar(a) {
5008
4950
  for (let i = 0; i < this.ELEMENTS; ++i) {
5009
4951
  this[i] = a;
5010
4952
  }
5011
4953
  return this.check();
5012
4954
  }
4955
+ /** @deprecated */
5013
4956
  addScalar(a) {
5014
4957
  for (let i = 0; i < this.ELEMENTS; ++i) {
5015
4958
  this[i] += a;
5016
4959
  }
5017
4960
  return this.check();
5018
4961
  }
4962
+ /** @deprecated */
5019
4963
  subScalar(a) {
5020
4964
  return this.addScalar(-a);
5021
4965
  }
4966
+ /** @deprecated */
5022
4967
  multiplyScalar(scalar) {
5023
4968
  for (let i = 0; i < this.ELEMENTS; ++i) {
5024
4969
  this[i] *= scalar;
5025
4970
  }
5026
4971
  return this.check();
5027
4972
  }
4973
+ /** @deprecated */
5028
4974
  divideScalar(a) {
5029
4975
  return this.multiplyByScalar(1 / a);
5030
4976
  }
4977
+ /** @deprecated */
5031
4978
  clampScalar(min, max) {
5032
4979
  for (let i = 0; i < this.ELEMENTS; ++i) {
5033
4980
  this[i] = Math.min(Math.max(this[i], min), max);
5034
4981
  }
5035
4982
  return this.check();
5036
4983
  }
4984
+ /** @deprecated */
5037
4985
  get elements() {
5038
4986
  return this;
5039
4987
  }
@@ -5053,13 +5001,13 @@ void main() {
5053
5001
  }
5054
5002
  function checkNumber(value) {
5055
5003
  if (!Number.isFinite(value)) {
5056
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
5004
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
5057
5005
  }
5058
5006
  return value;
5059
5007
  }
5060
5008
  function checkVector(v, length, callerName = "") {
5061
5009
  if (config.debug && !validateVector(v, length)) {
5062
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
5010
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
5063
5011
  }
5064
5012
  return v;
5065
5013
  }
@@ -5067,12 +5015,13 @@ void main() {
5067
5015
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
5068
5016
  function assert2(condition, message) {
5069
5017
  if (!condition) {
5070
- throw new Error("math.gl assertion ".concat(message));
5018
+ throw new Error(`math.gl assertion ${message}`);
5071
5019
  }
5072
5020
  }
5073
5021
 
5074
5022
  // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
5075
5023
  var Vector = class extends MathArray {
5024
+ // ACCESSORS
5076
5025
  get x() {
5077
5026
  return this[0];
5078
5027
  }
@@ -5085,12 +5034,24 @@ void main() {
5085
5034
  set y(value) {
5086
5035
  this[1] = checkNumber(value);
5087
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
+ */
5088
5043
  len() {
5089
5044
  return Math.sqrt(this.lengthSquared());
5090
5045
  }
5046
+ /**
5047
+ * Returns the length of the vector from the origin to the point described by this vector
5048
+ */
5091
5049
  magnitude() {
5092
5050
  return this.len();
5093
5051
  }
5052
+ /**
5053
+ * Returns the squared length of the vector from the origin to the point described by this vector
5054
+ */
5094
5055
  lengthSquared() {
5095
5056
  let length = 0;
5096
5057
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -5098,6 +5059,9 @@ void main() {
5098
5059
  }
5099
5060
  return length;
5100
5061
  }
5062
+ /**
5063
+ * Returns the squared length of the vector from the origin to the point described by this vector
5064
+ */
5101
5065
  magnitudeSquared() {
5102
5066
  return this.lengthSquared();
5103
5067
  }
@@ -5119,6 +5083,7 @@ void main() {
5119
5083
  }
5120
5084
  return checkNumber(product);
5121
5085
  }
5086
+ // MODIFIERS
5122
5087
  normalize() {
5123
5088
  const length = this.magnitude();
5124
5089
  if (length !== 0) {
@@ -5144,6 +5109,7 @@ void main() {
5144
5109
  }
5145
5110
  return this.check();
5146
5111
  }
5112
+ // THREE.js compatibility
5147
5113
  lengthSq() {
5148
5114
  return this.lengthSquared();
5149
5115
  }
@@ -5416,6 +5382,12 @@ void main() {
5416
5382
  }
5417
5383
  return ZERO;
5418
5384
  }
5385
+ /**
5386
+ * @class
5387
+ * @param x
5388
+ * @param y
5389
+ * @param z
5390
+ */
5419
5391
  constructor(x = 0, y = 0, z = 0) {
5420
5392
  super(-0, -0, -0);
5421
5393
  if (arguments.length === 1 && isArray(x)) {
@@ -5460,6 +5432,7 @@ void main() {
5460
5432
  object.z = this[2];
5461
5433
  return object;
5462
5434
  }
5435
+ // Getters/setters
5463
5436
  get ELEMENTS() {
5464
5437
  return 3;
5465
5438
  }
@@ -5469,41 +5442,38 @@ void main() {
5469
5442
  set z(value) {
5470
5443
  this[2] = checkNumber(value);
5471
5444
  }
5445
+ // ACCESSORS
5472
5446
  angle(vector) {
5473
5447
  return angle(this, vector);
5474
5448
  }
5449
+ // MODIFIERS
5475
5450
  cross(vector) {
5476
5451
  cross(this, this, vector);
5477
5452
  return this.check();
5478
5453
  }
5479
- rotateX({
5480
- radians,
5481
- origin = ORIGIN
5482
- }) {
5454
+ rotateX({ radians, origin = ORIGIN }) {
5483
5455
  rotateX(this, this, origin, radians);
5484
5456
  return this.check();
5485
5457
  }
5486
- rotateY({
5487
- radians,
5488
- origin = ORIGIN
5489
- }) {
5458
+ rotateY({ radians, origin = ORIGIN }) {
5490
5459
  rotateY(this, this, origin, radians);
5491
5460
  return this.check();
5492
5461
  }
5493
- rotateZ({
5494
- radians,
5495
- origin = ORIGIN
5496
- }) {
5462
+ rotateZ({ radians, origin = ORIGIN }) {
5497
5463
  rotateZ(this, this, origin, radians);
5498
5464
  return this.check();
5499
5465
  }
5466
+ // Transforms
5467
+ // transforms as point (4th component is implicitly 1)
5500
5468
  transform(matrix4) {
5501
5469
  return this.transformAsPoint(matrix4);
5502
5470
  }
5471
+ // transforms as point (4th component is implicitly 1)
5503
5472
  transformAsPoint(matrix4) {
5504
5473
  transformMat42(this, this, matrix4);
5505
5474
  return this.check();
5506
5475
  }
5476
+ // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
5507
5477
  transformAsVector(matrix4) {
5508
5478
  vec3_transformMat4AsVector(this, this, matrix4);
5509
5479
  return this.check();
@@ -5524,19 +5494,29 @@ void main() {
5524
5494
 
5525
5495
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
5526
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?
5527
5507
  toString() {
5528
5508
  let string = "[";
5529
5509
  if (config.printRowMajor) {
5530
5510
  string += "row-major:";
5531
5511
  for (let row = 0; row < this.RANK; ++row) {
5532
5512
  for (let col = 0; col < this.RANK; ++col) {
5533
- string += " ".concat(this[col * this.RANK + row]);
5513
+ string += ` ${this[col * this.RANK + row]}`;
5534
5514
  }
5535
5515
  }
5536
5516
  } else {
5537
5517
  string += "column-major:";
5538
5518
  for (let i = 0; i < this.ELEMENTS; ++i) {
5539
- string += " ".concat(this[i]);
5519
+ string += ` ${this[i]}`;
5540
5520
  }
5541
5521
  }
5542
5522
  string += "]";
@@ -5545,9 +5525,11 @@ void main() {
5545
5525
  getElementIndex(row, col) {
5546
5526
  return col * this.RANK + row;
5547
5527
  }
5528
+ // By default assumes row major indices
5548
5529
  getElement(row, col) {
5549
5530
  return this[col * this.RANK + row];
5550
5531
  }
5532
+ // By default assumes row major indices
5551
5533
  setElement(row, col, value) {
5552
5534
  this[col * this.RANK + row] = checkNumber(value);
5553
5535
  return this;
@@ -6313,6 +6295,7 @@ void main() {
6313
6295
  this[15] = array[15];
6314
6296
  return this.check();
6315
6297
  }
6298
+ // eslint-disable-next-line max-params
6316
6299
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
6317
6300
  this[0] = m00;
6318
6301
  this[1] = m10;
@@ -6332,6 +6315,8 @@ void main() {
6332
6315
  this[15] = m33;
6333
6316
  return this.check();
6334
6317
  }
6318
+ // accepts row major order, stores as column major
6319
+ // eslint-disable-next-line max-params
6335
6320
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
6336
6321
  this[0] = m00;
6337
6322
  this[1] = m10;
@@ -6370,25 +6355,41 @@ void main() {
6370
6355
  result[15] = this[15];
6371
6356
  return result;
6372
6357
  }
6358
+ // Constructors
6359
+ /** Set to identity matrix */
6373
6360
  identity() {
6374
6361
  return this.copy(IDENTITY_MATRIX);
6375
6362
  }
6363
+ /**
6364
+ *
6365
+ * @param object
6366
+ * @returns self
6367
+ */
6368
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6376
6369
  fromObject(object) {
6377
6370
  return this.check();
6378
6371
  }
6372
+ /**
6373
+ * Calculates a 4x4 matrix from the given quaternion
6374
+ * @param quaternion Quaternion to create matrix from
6375
+ * @returns self
6376
+ */
6379
6377
  fromQuaternion(quaternion) {
6380
6378
  fromQuat(this, quaternion);
6381
6379
  return this.check();
6382
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
+ */
6383
6391
  frustum(view) {
6384
- const {
6385
- left,
6386
- right,
6387
- bottom,
6388
- top,
6389
- near = DEFAULT_NEAR,
6390
- far = DEFAULT_FAR
6391
- } = view;
6392
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6392
6393
  if (far === Infinity) {
6393
6394
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
6394
6395
  } else {
@@ -6396,35 +6397,47 @@ void main() {
6396
6397
  }
6397
6398
  return this.check();
6398
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
+ */
6399
6408
  lookAt(view) {
6400
- const {
6401
- eye,
6402
- center = [0, 0, 0],
6403
- up = [0, 1, 0]
6404
- } = view;
6409
+ const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
6405
6410
  lookAt(this, eye, center, up);
6406
6411
  return this.check();
6407
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
+ */
6408
6424
  ortho(view) {
6409
- const {
6410
- left,
6411
- right,
6412
- bottom,
6413
- top,
6414
- near = DEFAULT_NEAR,
6415
- far = DEFAULT_FAR
6416
- } = view;
6425
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6417
6426
  ortho(this, left, right, bottom, top, near, far);
6418
6427
  return this.check();
6419
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
+ */
6420
6439
  orthographic(view) {
6421
- const {
6422
- fovy = DEFAULT_FOVY,
6423
- aspect = DEFAULT_ASPECT,
6424
- focalDistance = 1,
6425
- near = DEFAULT_NEAR,
6426
- far = DEFAULT_FAR
6427
- } = view;
6440
+ const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6428
6441
  checkRadians(fovy);
6429
6442
  const halfY = fovy / 2;
6430
6443
  const top = focalDistance * Math.tan(halfY);
@@ -6438,32 +6451,53 @@ void main() {
6438
6451
  far
6439
6452
  });
6440
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
+ */
6441
6462
  perspective(view) {
6442
- const {
6443
- fovy = 45 * Math.PI / 180,
6444
- aspect = 1,
6445
- near = 0.1,
6446
- far = 500
6447
- } = view;
6463
+ const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
6448
6464
  checkRadians(fovy);
6449
6465
  perspective(this, fovy, aspect, near, far);
6450
6466
  return this.check();
6451
6467
  }
6468
+ // Accessors
6452
6469
  determinant() {
6453
6470
  return determinant(this);
6454
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
+ */
6455
6478
  getScale(result = [-0, -0, -0]) {
6456
6479
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
6457
6480
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
6458
6481
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
6459
6482
  return result;
6460
6483
  }
6484
+ /**
6485
+ * Gets the translation portion, assuming the matrix is a affine transformation matrix.
6486
+ * @param result
6487
+ * @returns self
6488
+ */
6461
6489
  getTranslation(result = [-0, -0, -0]) {
6462
6490
  result[0] = this[12];
6463
6491
  result[1] = this[13];
6464
6492
  result[2] = this[14];
6465
6493
  return result;
6466
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
+ */
6467
6501
  getRotation(result, scaleResult) {
6468
6502
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
6469
6503
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6489,6 +6523,12 @@ void main() {
6489
6523
  result[15] = 1;
6490
6524
  return result;
6491
6525
  }
6526
+ /**
6527
+ *
6528
+ * @param result
6529
+ * @param scaleResult
6530
+ * @returns self
6531
+ */
6492
6532
  getRotationMatrix3(result, scaleResult) {
6493
6533
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
6494
6534
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6507,6 +6547,7 @@ void main() {
6507
6547
  result[8] = this[10] * inverseScale2;
6508
6548
  return result;
6509
6549
  }
6550
+ // Modifiers
6510
6551
  transpose() {
6511
6552
  transpose(this, this);
6512
6553
  return this.check();
@@ -6515,6 +6556,7 @@ void main() {
6515
6556
  invert(this, this);
6516
6557
  return this.check();
6517
6558
  }
6559
+ // Operations
6518
6560
  multiplyLeft(a) {
6519
6561
  multiply(this, a, this);
6520
6562
  return this.check();
@@ -6523,33 +6565,68 @@ void main() {
6523
6565
  multiply(this, this, a);
6524
6566
  return this.check();
6525
6567
  }
6568
+ // Rotates a matrix by the given angle around the X axis
6526
6569
  rotateX(radians) {
6527
6570
  rotateX2(this, this, radians);
6528
6571
  return this.check();
6529
6572
  }
6573
+ // Rotates a matrix by the given angle around the Y axis.
6530
6574
  rotateY(radians) {
6531
6575
  rotateY2(this, this, radians);
6532
6576
  return this.check();
6533
6577
  }
6578
+ /**
6579
+ * Rotates a matrix by the given angle around the Z axis.
6580
+ * @param radians
6581
+ * @returns self
6582
+ */
6534
6583
  rotateZ(radians) {
6535
6584
  rotateZ2(this, this, radians);
6536
6585
  return this.check();
6537
6586
  }
6587
+ /**
6588
+ *
6589
+ * @param param0
6590
+ * @returns self
6591
+ */
6538
6592
  rotateXYZ(angleXYZ) {
6539
6593
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
6540
6594
  }
6595
+ /**
6596
+ *
6597
+ * @param radians
6598
+ * @param axis
6599
+ * @returns self
6600
+ */
6541
6601
  rotateAxis(radians, axis) {
6542
6602
  rotate(this, this, radians, axis);
6543
6603
  return this.check();
6544
6604
  }
6605
+ /**
6606
+ *
6607
+ * @param factor
6608
+ * @returns self
6609
+ */
6545
6610
  scale(factor) {
6546
6611
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
6547
6612
  return this.check();
6548
6613
  }
6614
+ /**
6615
+ *
6616
+ * @param vec
6617
+ * @returns self
6618
+ */
6549
6619
  translate(vector) {
6550
6620
  translate(this, this, vector);
6551
6621
  return this.check();
6552
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
+ */
6553
6630
  transform(vector, result) {
6554
6631
  if (vector.length === 4) {
6555
6632
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -6558,10 +6635,14 @@ void main() {
6558
6635
  }
6559
6636
  return this.transformAsPoint(vector, result);
6560
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
+ */
6561
6644
  transformAsPoint(vector, result) {
6562
- const {
6563
- length
6564
- } = vector;
6645
+ const { length } = vector;
6565
6646
  let out;
6566
6647
  switch (length) {
6567
6648
  case 2:
@@ -6576,6 +6657,12 @@ void main() {
6576
6657
  checkVector(out, vector.length);
6577
6658
  return out;
6578
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
+ */
6579
6666
  transformAsVector(vector, result) {
6580
6667
  let out;
6581
6668
  switch (vector.length) {
@@ -6591,15 +6678,19 @@ void main() {
6591
6678
  checkVector(out, vector.length);
6592
6679
  return out;
6593
6680
  }
6681
+ /** @deprecated */
6594
6682
  transformPoint(vector, result) {
6595
6683
  return this.transformAsPoint(vector, result);
6596
6684
  }
6685
+ /** @deprecated */
6597
6686
  transformVector(vector, result) {
6598
6687
  return this.transformAsPoint(vector, result);
6599
6688
  }
6689
+ /** @deprecated */
6600
6690
  transformDirection(vector, result) {
6601
6691
  return this.transformAsVector(vector, result);
6602
6692
  }
6693
+ // three.js math API compatibility
6603
6694
  makeRotationX(radians) {
6604
6695
  return this.identity().rotateX(radians);
6605
6696
  }