@luma.gl/engine 9.0.12 → 9.0.14

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,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
- /** Acquire a stat. Create if it doesn't exist. */
404
- get(name, type = "count") {
405
- return this._getOrCreate({ name, type });
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(stats = []) {
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 { name, type } = stat;
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) {
@@ -4725,11 +4723,17 @@ void main() {
4725
4723
  printRowMajor: true,
4726
4724
  _cartographicRadians: false
4727
4725
  };
4728
- globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4726
+ globalThis.mathgl = globalThis.mathgl || {
4727
+ config: {
4728
+ ...DEFAULT_CONFIG
4729
+ }
4730
+ };
4729
4731
  var config = globalThis.mathgl.config;
4730
- function formatValue(value, { precision = config.precision } = {}) {
4732
+ function formatValue(value, {
4733
+ precision = config.precision
4734
+ } = {}) {
4731
4735
  value = round(value);
4732
- return `${parseFloat(value.toPrecision(precision))}`;
4736
+ return "".concat(parseFloat(value.toPrecision(precision)));
4733
4737
  }
4734
4738
  function isArray(value) {
4735
4739
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -4773,12 +4777,28 @@ void main() {
4773
4777
  }
4774
4778
 
4775
4779
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4776
- var MathArray = class extends Array {
4777
- // Common methods
4778
- /**
4779
- * Clone the current object
4780
- * @returns a new copy of this object
4781
- */
4780
+ function _extendableBuiltin(cls) {
4781
+ function ExtendableBuiltin() {
4782
+ var instance = Reflect.construct(cls, Array.from(arguments));
4783
+ Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
4784
+ return instance;
4785
+ }
4786
+ ExtendableBuiltin.prototype = Object.create(cls.prototype, {
4787
+ constructor: {
4788
+ value: cls,
4789
+ enumerable: false,
4790
+ writable: true,
4791
+ configurable: true
4792
+ }
4793
+ });
4794
+ if (Object.setPrototypeOf) {
4795
+ Object.setPrototypeOf(ExtendableBuiltin, cls);
4796
+ } else {
4797
+ ExtendableBuiltin.__proto__ = cls;
4798
+ }
4799
+ return ExtendableBuiltin;
4800
+ }
4801
+ var MathArray = class extends _extendableBuiltin(Array) {
4782
4802
  clone() {
4783
4803
  return new this.constructor().copy(this);
4784
4804
  }
@@ -4798,10 +4818,7 @@ void main() {
4798
4818
  return targetObject;
4799
4819
  }
4800
4820
  from(arrayOrObject) {
4801
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4802
- // @ts-ignore
4803
- this.fromObject(arrayOrObject)
4804
- );
4821
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
4805
4822
  }
4806
4823
  to(arrayOrObject) {
4807
4824
  if (arrayOrObject === this) {
@@ -4812,20 +4829,18 @@ void main() {
4812
4829
  toTarget(target) {
4813
4830
  return target ? this.to(target) : this;
4814
4831
  }
4815
- /** @deprecated */
4816
4832
  toFloat32Array() {
4817
4833
  return new Float32Array(this);
4818
4834
  }
4819
4835
  toString() {
4820
4836
  return this.formatString(config);
4821
4837
  }
4822
- /** Formats string according to options */
4823
4838
  formatString(opts) {
4824
4839
  let string = "";
4825
4840
  for (let i = 0; i < this.ELEMENTS; ++i) {
4826
4841
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4827
4842
  }
4828
- return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4843
+ return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
4829
4844
  }
4830
4845
  equals(array) {
4831
4846
  if (!array || this.length !== array.length) {
@@ -4849,8 +4864,6 @@ void main() {
4849
4864
  }
4850
4865
  return true;
4851
4866
  }
4852
- // Modifiers
4853
- /** Negates all values in this object */
4854
4867
  negate() {
4855
4868
  for (let i = 0; i < this.ELEMENTS; ++i) {
4856
4869
  this[i] = -this[i];
@@ -4868,14 +4881,12 @@ void main() {
4868
4881
  }
4869
4882
  return this.check();
4870
4883
  }
4871
- /** Minimal */
4872
4884
  min(vector) {
4873
4885
  for (let i = 0; i < this.ELEMENTS; ++i) {
4874
4886
  this[i] = Math.min(vector[i], this[i]);
4875
4887
  }
4876
4888
  return this.check();
4877
4889
  }
4878
- /** Maximal */
4879
4890
  max(vector) {
4880
4891
  for (let i = 0; i < this.ELEMENTS; ++i) {
4881
4892
  this[i] = Math.max(vector[i], this[i]);
@@ -4916,25 +4927,18 @@ void main() {
4916
4927
  }
4917
4928
  return this.check();
4918
4929
  }
4919
- /**
4920
- * Multiplies all elements by `scale`
4921
- * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4922
- */
4923
4930
  multiplyByScalar(scalar) {
4924
4931
  for (let i = 0; i < this.ELEMENTS; ++i) {
4925
4932
  this[i] *= scalar;
4926
4933
  }
4927
4934
  return this.check();
4928
4935
  }
4929
- // Debug checks
4930
- /** Throws an error if array length is incorrect or contains illegal values */
4931
4936
  check() {
4932
4937
  if (config.debug && !this.validate()) {
4933
- throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
4938
+ throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
4934
4939
  }
4935
4940
  return this;
4936
4941
  }
4937
- /** Returns false if the array length is incorrect or contains illegal values */
4938
4942
  validate() {
4939
4943
  let valid = this.length === this.ELEMENTS;
4940
4944
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -4942,48 +4946,39 @@ void main() {
4942
4946
  }
4943
4947
  return valid;
4944
4948
  }
4945
- // three.js compatibility
4946
- /** @deprecated */
4947
4949
  sub(a) {
4948
4950
  return this.subtract(a);
4949
4951
  }
4950
- /** @deprecated */
4951
4952
  setScalar(a) {
4952
4953
  for (let i = 0; i < this.ELEMENTS; ++i) {
4953
4954
  this[i] = a;
4954
4955
  }
4955
4956
  return this.check();
4956
4957
  }
4957
- /** @deprecated */
4958
4958
  addScalar(a) {
4959
4959
  for (let i = 0; i < this.ELEMENTS; ++i) {
4960
4960
  this[i] += a;
4961
4961
  }
4962
4962
  return this.check();
4963
4963
  }
4964
- /** @deprecated */
4965
4964
  subScalar(a) {
4966
4965
  return this.addScalar(-a);
4967
4966
  }
4968
- /** @deprecated */
4969
4967
  multiplyScalar(scalar) {
4970
4968
  for (let i = 0; i < this.ELEMENTS; ++i) {
4971
4969
  this[i] *= scalar;
4972
4970
  }
4973
4971
  return this.check();
4974
4972
  }
4975
- /** @deprecated */
4976
4973
  divideScalar(a) {
4977
4974
  return this.multiplyByScalar(1 / a);
4978
4975
  }
4979
- /** @deprecated */
4980
4976
  clampScalar(min, max) {
4981
4977
  for (let i = 0; i < this.ELEMENTS; ++i) {
4982
4978
  this[i] = Math.min(Math.max(this[i], min), max);
4983
4979
  }
4984
4980
  return this.check();
4985
4981
  }
4986
- /** @deprecated */
4987
4982
  get elements() {
4988
4983
  return this;
4989
4984
  }
@@ -5003,13 +4998,13 @@ void main() {
5003
4998
  }
5004
4999
  function checkNumber(value) {
5005
5000
  if (!Number.isFinite(value)) {
5006
- throw new Error(`Invalid number ${JSON.stringify(value)}`);
5001
+ throw new Error("Invalid number ".concat(JSON.stringify(value)));
5007
5002
  }
5008
5003
  return value;
5009
5004
  }
5010
5005
  function checkVector(v, length, callerName = "") {
5011
5006
  if (config.debug && !validateVector(v, length)) {
5012
- throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
5007
+ throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
5013
5008
  }
5014
5009
  return v;
5015
5010
  }
@@ -5017,13 +5012,12 @@ void main() {
5017
5012
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
5018
5013
  function assert2(condition, message) {
5019
5014
  if (!condition) {
5020
- throw new Error(`math.gl assertion ${message}`);
5015
+ throw new Error("math.gl assertion ".concat(message));
5021
5016
  }
5022
5017
  }
5023
5018
 
5024
5019
  // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
5025
5020
  var Vector = class extends MathArray {
5026
- // ACCESSORS
5027
5021
  get x() {
5028
5022
  return this[0];
5029
5023
  }
@@ -5036,24 +5030,12 @@ void main() {
5036
5030
  set y(value) {
5037
5031
  this[1] = checkNumber(value);
5038
5032
  }
5039
- /**
5040
- * Returns the length of the vector from the origin to the point described by this vector
5041
- *
5042
- * @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
5043
- * Instead we provide `len` and `magnitude`
5044
- */
5045
5033
  len() {
5046
5034
  return Math.sqrt(this.lengthSquared());
5047
5035
  }
5048
- /**
5049
- * Returns the length of the vector from the origin to the point described by this vector
5050
- */
5051
5036
  magnitude() {
5052
5037
  return this.len();
5053
5038
  }
5054
- /**
5055
- * Returns the squared length of the vector from the origin to the point described by this vector
5056
- */
5057
5039
  lengthSquared() {
5058
5040
  let length = 0;
5059
5041
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -5061,9 +5043,6 @@ void main() {
5061
5043
  }
5062
5044
  return length;
5063
5045
  }
5064
- /**
5065
- * Returns the squared length of the vector from the origin to the point described by this vector
5066
- */
5067
5046
  magnitudeSquared() {
5068
5047
  return this.lengthSquared();
5069
5048
  }
@@ -5085,7 +5064,6 @@ void main() {
5085
5064
  }
5086
5065
  return checkNumber(product);
5087
5066
  }
5088
- // MODIFIERS
5089
5067
  normalize() {
5090
5068
  const length = this.magnitude();
5091
5069
  if (length !== 0) {
@@ -5111,7 +5089,6 @@ void main() {
5111
5089
  }
5112
5090
  return this.check();
5113
5091
  }
5114
- // THREE.js compatibility
5115
5092
  lengthSq() {
5116
5093
  return this.lengthSquared();
5117
5094
  }
@@ -5384,12 +5361,6 @@ void main() {
5384
5361
  }
5385
5362
  return ZERO;
5386
5363
  }
5387
- /**
5388
- * @class
5389
- * @param x
5390
- * @param y
5391
- * @param z
5392
- */
5393
5364
  constructor(x = 0, y = 0, z = 0) {
5394
5365
  super(-0, -0, -0);
5395
5366
  if (arguments.length === 1 && isArray(x)) {
@@ -5434,7 +5405,6 @@ void main() {
5434
5405
  object.z = this[2];
5435
5406
  return object;
5436
5407
  }
5437
- // Getters/setters
5438
5408
  get ELEMENTS() {
5439
5409
  return 3;
5440
5410
  }
@@ -5444,38 +5414,41 @@ void main() {
5444
5414
  set z(value) {
5445
5415
  this[2] = checkNumber(value);
5446
5416
  }
5447
- // ACCESSORS
5448
5417
  angle(vector) {
5449
5418
  return angle(this, vector);
5450
5419
  }
5451
- // MODIFIERS
5452
5420
  cross(vector) {
5453
5421
  cross(this, this, vector);
5454
5422
  return this.check();
5455
5423
  }
5456
- rotateX({ radians, origin = ORIGIN }) {
5424
+ rotateX({
5425
+ radians,
5426
+ origin = ORIGIN
5427
+ }) {
5457
5428
  rotateX(this, this, origin, radians);
5458
5429
  return this.check();
5459
5430
  }
5460
- rotateY({ radians, origin = ORIGIN }) {
5431
+ rotateY({
5432
+ radians,
5433
+ origin = ORIGIN
5434
+ }) {
5461
5435
  rotateY(this, this, origin, radians);
5462
5436
  return this.check();
5463
5437
  }
5464
- rotateZ({ radians, origin = ORIGIN }) {
5438
+ rotateZ({
5439
+ radians,
5440
+ origin = ORIGIN
5441
+ }) {
5465
5442
  rotateZ(this, this, origin, radians);
5466
5443
  return this.check();
5467
5444
  }
5468
- // Transforms
5469
- // transforms as point (4th component is implicitly 1)
5470
5445
  transform(matrix4) {
5471
5446
  return this.transformAsPoint(matrix4);
5472
5447
  }
5473
- // transforms as point (4th component is implicitly 1)
5474
5448
  transformAsPoint(matrix4) {
5475
5449
  transformMat42(this, this, matrix4);
5476
5450
  return this.check();
5477
5451
  }
5478
- // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
5479
5452
  transformAsVector(matrix4) {
5480
5453
  vec3_transformMat4AsVector(this, this, matrix4);
5481
5454
  return this.check();
@@ -5496,29 +5469,19 @@ void main() {
5496
5469
 
5497
5470
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
5498
5471
  var Matrix = class extends MathArray {
5499
- // fromObject(object) {
5500
- // const array = object.elements;
5501
- // return this.fromRowMajor(array);
5502
- // }
5503
- // toObject(object) {
5504
- // const array = object.elements;
5505
- // this.toRowMajor(array);
5506
- // return object;
5507
- // }
5508
- // TODO better override formatString?
5509
5472
  toString() {
5510
5473
  let string = "[";
5511
5474
  if (config.printRowMajor) {
5512
5475
  string += "row-major:";
5513
5476
  for (let row = 0; row < this.RANK; ++row) {
5514
5477
  for (let col = 0; col < this.RANK; ++col) {
5515
- string += ` ${this[col * this.RANK + row]}`;
5478
+ string += " ".concat(this[col * this.RANK + row]);
5516
5479
  }
5517
5480
  }
5518
5481
  } else {
5519
5482
  string += "column-major:";
5520
5483
  for (let i = 0; i < this.ELEMENTS; ++i) {
5521
- string += ` ${this[i]}`;
5484
+ string += " ".concat(this[i]);
5522
5485
  }
5523
5486
  }
5524
5487
  string += "]";
@@ -5527,11 +5490,9 @@ void main() {
5527
5490
  getElementIndex(row, col) {
5528
5491
  return col * this.RANK + row;
5529
5492
  }
5530
- // By default assumes row major indices
5531
5493
  getElement(row, col) {
5532
5494
  return this[col * this.RANK + row];
5533
5495
  }
5534
- // By default assumes row major indices
5535
5496
  setElement(row, col, value) {
5536
5497
  this[col * this.RANK + row] = checkNumber(value);
5537
5498
  return this;
@@ -6297,7 +6258,6 @@ void main() {
6297
6258
  this[15] = array[15];
6298
6259
  return this.check();
6299
6260
  }
6300
- // eslint-disable-next-line max-params
6301
6261
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
6302
6262
  this[0] = m00;
6303
6263
  this[1] = m10;
@@ -6317,8 +6277,6 @@ void main() {
6317
6277
  this[15] = m33;
6318
6278
  return this.check();
6319
6279
  }
6320
- // accepts row major order, stores as column major
6321
- // eslint-disable-next-line max-params
6322
6280
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
6323
6281
  this[0] = m00;
6324
6282
  this[1] = m10;
@@ -6357,41 +6315,25 @@ void main() {
6357
6315
  result[15] = this[15];
6358
6316
  return result;
6359
6317
  }
6360
- // Constructors
6361
- /** Set to identity matrix */
6362
6318
  identity() {
6363
6319
  return this.copy(IDENTITY_MATRIX);
6364
6320
  }
6365
- /**
6366
- *
6367
- * @param object
6368
- * @returns self
6369
- */
6370
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6371
6321
  fromObject(object) {
6372
6322
  return this.check();
6373
6323
  }
6374
- /**
6375
- * Calculates a 4x4 matrix from the given quaternion
6376
- * @param quaternion Quaternion to create matrix from
6377
- * @returns self
6378
- */
6379
6324
  fromQuaternion(quaternion) {
6380
6325
  fromQuat(this, quaternion);
6381
6326
  return this.check();
6382
6327
  }
6383
- /**
6384
- * Generates a frustum matrix with the given bounds
6385
- * @param view.left - Left bound of the frustum
6386
- * @param view.right - Right bound of the frustum
6387
- * @param view.bottom - Bottom bound of the frustum
6388
- * @param view.top - Top bound of the frustum
6389
- * @param view.near - Near bound of the frustum
6390
- * @param view.far - Far bound of the frustum. Can be set to Infinity.
6391
- * @returns self
6392
- */
6393
6328
  frustum(view) {
6394
- const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6329
+ const {
6330
+ left,
6331
+ right,
6332
+ bottom,
6333
+ top,
6334
+ near = DEFAULT_NEAR,
6335
+ far = DEFAULT_FAR
6336
+ } = view;
6395
6337
  if (far === Infinity) {
6396
6338
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
6397
6339
  } else {
@@ -6399,47 +6341,35 @@ void main() {
6399
6341
  }
6400
6342
  return this.check();
6401
6343
  }
6402
- /**
6403
- * Generates a look-at matrix with the given eye position, focal point,
6404
- * and up axis
6405
- * @param view.eye - (vector) Position of the viewer
6406
- * @param view.center - (vector) Point the viewer is looking at
6407
- * @param view.up - (vector) Up axis
6408
- * @returns self
6409
- */
6410
6344
  lookAt(view) {
6411
- const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
6345
+ const {
6346
+ eye,
6347
+ center = [0, 0, 0],
6348
+ up = [0, 1, 0]
6349
+ } = view;
6412
6350
  lookAt(this, eye, center, up);
6413
6351
  return this.check();
6414
6352
  }
6415
- /**
6416
- * Generates a orthogonal projection matrix with the given bounds
6417
- * from "traditional" view space parameters
6418
- * @param view.left - Left bound of the frustum
6419
- * @param view.right number Right bound of the frustum
6420
- * @param view.bottom - Bottom bound of the frustum
6421
- * @param view.top number Top bound of the frustum
6422
- * @param view.near - Near bound of the frustum
6423
- * @param view.far number Far bound of the frustum
6424
- * @returns self
6425
- */
6426
6353
  ortho(view) {
6427
- const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6354
+ const {
6355
+ left,
6356
+ right,
6357
+ bottom,
6358
+ top,
6359
+ near = DEFAULT_NEAR,
6360
+ far = DEFAULT_FAR
6361
+ } = view;
6428
6362
  ortho(this, left, right, bottom, top, near, far);
6429
6363
  return this.check();
6430
6364
  }
6431
- /**
6432
- * Generates an orthogonal projection matrix with the same parameters
6433
- * as a perspective matrix (plus focalDistance)
6434
- * @param view.fovy Vertical field of view in radians
6435
- * @param view.aspect Aspect ratio. Typically viewport width / viewport height
6436
- * @param view.focalDistance Distance in the view frustum used for extent calculations
6437
- * @param view.near Near bound of the frustum
6438
- * @param view.far Far bound of the frustum
6439
- * @returns self
6440
- */
6441
6365
  orthographic(view) {
6442
- const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6366
+ const {
6367
+ fovy = DEFAULT_FOVY,
6368
+ aspect = DEFAULT_ASPECT,
6369
+ focalDistance = 1,
6370
+ near = DEFAULT_NEAR,
6371
+ far = DEFAULT_FAR
6372
+ } = view;
6443
6373
  checkRadians(fovy);
6444
6374
  const halfY = fovy / 2;
6445
6375
  const top = focalDistance * Math.tan(halfY);
@@ -6453,53 +6383,32 @@ void main() {
6453
6383
  far
6454
6384
  });
6455
6385
  }
6456
- /**
6457
- * Generates a perspective projection matrix with the given bounds
6458
- * @param view.fovy Vertical field of view in radians
6459
- * @param view.aspect Aspect ratio. typically viewport width/height
6460
- * @param view.near Near bound of the frustum
6461
- * @param view.far Far bound of the frustum
6462
- * @returns self
6463
- */
6464
6386
  perspective(view) {
6465
- const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
6387
+ const {
6388
+ fovy = 45 * Math.PI / 180,
6389
+ aspect = 1,
6390
+ near = 0.1,
6391
+ far = 500
6392
+ } = view;
6466
6393
  checkRadians(fovy);
6467
6394
  perspective(this, fovy, aspect, near, far);
6468
6395
  return this.check();
6469
6396
  }
6470
- // Accessors
6471
6397
  determinant() {
6472
6398
  return determinant(this);
6473
6399
  }
6474
- /**
6475
- * Extracts the non-uniform scale assuming the matrix is an affine transformation.
6476
- * The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
6477
- * @param result
6478
- * @returns self
6479
- */
6480
6400
  getScale(result = [-0, -0, -0]) {
6481
6401
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
6482
6402
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
6483
6403
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
6484
6404
  return result;
6485
6405
  }
6486
- /**
6487
- * Gets the translation portion, assuming the matrix is a affine transformation matrix.
6488
- * @param result
6489
- * @returns self
6490
- */
6491
6406
  getTranslation(result = [-0, -0, -0]) {
6492
6407
  result[0] = this[12];
6493
6408
  result[1] = this[13];
6494
6409
  result[2] = this[14];
6495
6410
  return result;
6496
6411
  }
6497
- /**
6498
- * Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
6499
- * @param result
6500
- * @param scaleResult
6501
- * @returns self
6502
- */
6503
6412
  getRotation(result, scaleResult) {
6504
6413
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
6505
6414
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6525,12 +6434,6 @@ void main() {
6525
6434
  result[15] = 1;
6526
6435
  return result;
6527
6436
  }
6528
- /**
6529
- *
6530
- * @param result
6531
- * @param scaleResult
6532
- * @returns self
6533
- */
6534
6437
  getRotationMatrix3(result, scaleResult) {
6535
6438
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
6536
6439
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6549,7 +6452,6 @@ void main() {
6549
6452
  result[8] = this[10] * inverseScale2;
6550
6453
  return result;
6551
6454
  }
6552
- // Modifiers
6553
6455
  transpose() {
6554
6456
  transpose(this, this);
6555
6457
  return this.check();
@@ -6558,7 +6460,6 @@ void main() {
6558
6460
  invert(this, this);
6559
6461
  return this.check();
6560
6462
  }
6561
- // Operations
6562
6463
  multiplyLeft(a) {
6563
6464
  multiply(this, a, this);
6564
6465
  return this.check();
@@ -6567,68 +6468,33 @@ void main() {
6567
6468
  multiply(this, this, a);
6568
6469
  return this.check();
6569
6470
  }
6570
- // Rotates a matrix by the given angle around the X axis
6571
6471
  rotateX(radians) {
6572
6472
  rotateX2(this, this, radians);
6573
6473
  return this.check();
6574
6474
  }
6575
- // Rotates a matrix by the given angle around the Y axis.
6576
6475
  rotateY(radians) {
6577
6476
  rotateY2(this, this, radians);
6578
6477
  return this.check();
6579
6478
  }
6580
- /**
6581
- * Rotates a matrix by the given angle around the Z axis.
6582
- * @param radians
6583
- * @returns self
6584
- */
6585
6479
  rotateZ(radians) {
6586
6480
  rotateZ2(this, this, radians);
6587
6481
  return this.check();
6588
6482
  }
6589
- /**
6590
- *
6591
- * @param param0
6592
- * @returns self
6593
- */
6594
6483
  rotateXYZ(angleXYZ) {
6595
6484
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
6596
6485
  }
6597
- /**
6598
- *
6599
- * @param radians
6600
- * @param axis
6601
- * @returns self
6602
- */
6603
6486
  rotateAxis(radians, axis) {
6604
6487
  rotate(this, this, radians, axis);
6605
6488
  return this.check();
6606
6489
  }
6607
- /**
6608
- *
6609
- * @param factor
6610
- * @returns self
6611
- */
6612
6490
  scale(factor) {
6613
6491
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
6614
6492
  return this.check();
6615
6493
  }
6616
- /**
6617
- *
6618
- * @param vec
6619
- * @returns self
6620
- */
6621
6494
  translate(vector) {
6622
6495
  translate(this, this, vector);
6623
6496
  return this.check();
6624
6497
  }
6625
- // Transforms
6626
- /**
6627
- * Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
6628
- * @param vector
6629
- * @param result
6630
- * @returns self
6631
- */
6632
6498
  transform(vector, result) {
6633
6499
  if (vector.length === 4) {
6634
6500
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -6637,14 +6503,10 @@ void main() {
6637
6503
  }
6638
6504
  return this.transformAsPoint(vector, result);
6639
6505
  }
6640
- /**
6641
- * Transforms any 2 or 3 element array as point (w implicitly 1)
6642
- * @param vector
6643
- * @param result
6644
- * @returns self
6645
- */
6646
6506
  transformAsPoint(vector, result) {
6647
- const { length } = vector;
6507
+ const {
6508
+ length
6509
+ } = vector;
6648
6510
  let out;
6649
6511
  switch (length) {
6650
6512
  case 2:
@@ -6659,12 +6521,6 @@ void main() {
6659
6521
  checkVector(out, vector.length);
6660
6522
  return out;
6661
6523
  }
6662
- /**
6663
- * Transforms any 2 or 3 element array as vector (w implicitly 0)
6664
- * @param vector
6665
- * @param result
6666
- * @returns self
6667
- */
6668
6524
  transformAsVector(vector, result) {
6669
6525
  let out;
6670
6526
  switch (vector.length) {
@@ -6680,19 +6536,15 @@ void main() {
6680
6536
  checkVector(out, vector.length);
6681
6537
  return out;
6682
6538
  }
6683
- /** @deprecated */
6684
6539
  transformPoint(vector, result) {
6685
6540
  return this.transformAsPoint(vector, result);
6686
6541
  }
6687
- /** @deprecated */
6688
6542
  transformVector(vector, result) {
6689
6543
  return this.transformAsPoint(vector, result);
6690
6544
  }
6691
- /** @deprecated */
6692
6545
  transformDirection(vector, result) {
6693
6546
  return this.transformAsVector(vector, result);
6694
6547
  }
6695
- // three.js math API compatibility
6696
6548
  makeRotationX(radians) {
6697
6549
  return this.identity().rotateX(radians);
6698
6550
  }