@luma.gl/engine 9.0.0 → 9.0.3

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) {
@@ -4721,17 +4723,11 @@ void main() {
4721
4723
  printRowMajor: true,
4722
4724
  _cartographicRadians: false
4723
4725
  };
4724
- globalThis.mathgl = globalThis.mathgl || {
4725
- config: {
4726
- ...DEFAULT_CONFIG
4727
- }
4728
- };
4726
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4729
4727
  var config = globalThis.mathgl.config;
4730
- function formatValue(value, {
4731
- precision = config.precision
4732
- } = {}) {
4728
+ function formatValue(value, { precision = config.precision } = {}) {
4733
4729
  value = round(value);
4734
- return "".concat(parseFloat(value.toPrecision(precision)));
4730
+ return `${parseFloat(value.toPrecision(precision))}`;
4735
4731
  }
4736
4732
  function isArray(value) {
4737
4733
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -4775,28 +4771,12 @@ void main() {
4775
4771
  }
4776
4772
 
4777
4773
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4778
- 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) {
4774
+ var MathArray = class extends Array {
4775
+ // Common methods
4776
+ /**
4777
+ * Clone the current object
4778
+ * @returns a new copy of this object
4779
+ */
4800
4780
  clone() {
4801
4781
  return new this.constructor().copy(this);
4802
4782
  }
@@ -4816,7 +4796,10 @@ void main() {
4816
4796
  return targetObject;
4817
4797
  }
4818
4798
  from(arrayOrObject) {
4819
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
4799
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4800
+ // @ts-ignore
4801
+ this.fromObject(arrayOrObject)
4802
+ );
4820
4803
  }
4821
4804
  to(arrayOrObject) {
4822
4805
  if (arrayOrObject === this) {
@@ -4827,18 +4810,20 @@ void main() {
4827
4810
  toTarget(target) {
4828
4811
  return target ? this.to(target) : this;
4829
4812
  }
4813
+ /** @deprecated */
4830
4814
  toFloat32Array() {
4831
4815
  return new Float32Array(this);
4832
4816
  }
4833
4817
  toString() {
4834
4818
  return this.formatString(config);
4835
4819
  }
4820
+ /** Formats string according to options */
4836
4821
  formatString(opts) {
4837
4822
  let string = "";
4838
4823
  for (let i = 0; i < this.ELEMENTS; ++i) {
4839
4824
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4840
4825
  }
4841
- return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
4826
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4842
4827
  }
4843
4828
  equals(array) {
4844
4829
  if (!array || this.length !== array.length) {
@@ -4862,6 +4847,8 @@ void main() {
4862
4847
  }
4863
4848
  return true;
4864
4849
  }
4850
+ // Modifiers
4851
+ /** Negates all values in this object */
4865
4852
  negate() {
4866
4853
  for (let i = 0; i < this.ELEMENTS; ++i) {
4867
4854
  this[i] = -this[i];
@@ -4879,12 +4866,14 @@ void main() {
4879
4866
  }
4880
4867
  return this.check();
4881
4868
  }
4869
+ /** Minimal */
4882
4870
  min(vector) {
4883
4871
  for (let i = 0; i < this.ELEMENTS; ++i) {
4884
4872
  this[i] = Math.min(vector[i], this[i]);
4885
4873
  }
4886
4874
  return this.check();
4887
4875
  }
4876
+ /** Maximal */
4888
4877
  max(vector) {
4889
4878
  for (let i = 0; i < this.ELEMENTS; ++i) {
4890
4879
  this[i] = Math.max(vector[i], this[i]);
@@ -4925,18 +4914,25 @@ void main() {
4925
4914
  }
4926
4915
  return this.check();
4927
4916
  }
4917
+ /**
4918
+ * Multiplies all elements by `scale`
4919
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4920
+ */
4928
4921
  multiplyByScalar(scalar) {
4929
4922
  for (let i = 0; i < this.ELEMENTS; ++i) {
4930
4923
  this[i] *= scalar;
4931
4924
  }
4932
4925
  return this.check();
4933
4926
  }
4927
+ // Debug checks
4928
+ /** Throws an error if array length is incorrect or contains illegal values */
4934
4929
  check() {
4935
4930
  if (config.debug && !this.validate()) {
4936
- throw new Error("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'`);
4937
4932
  }
4938
4933
  return this;
4939
4934
  }
4935
+ /** Returns false if the array length is incorrect or contains illegal values */
4940
4936
  validate() {
4941
4937
  let valid = this.length === this.ELEMENTS;
4942
4938
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -4944,39 +4940,48 @@ void main() {
4944
4940
  }
4945
4941
  return valid;
4946
4942
  }
4943
+ // three.js compatibility
4944
+ /** @deprecated */
4947
4945
  sub(a) {
4948
4946
  return this.subtract(a);
4949
4947
  }
4948
+ /** @deprecated */
4950
4949
  setScalar(a) {
4951
4950
  for (let i = 0; i < this.ELEMENTS; ++i) {
4952
4951
  this[i] = a;
4953
4952
  }
4954
4953
  return this.check();
4955
4954
  }
4955
+ /** @deprecated */
4956
4956
  addScalar(a) {
4957
4957
  for (let i = 0; i < this.ELEMENTS; ++i) {
4958
4958
  this[i] += a;
4959
4959
  }
4960
4960
  return this.check();
4961
4961
  }
4962
+ /** @deprecated */
4962
4963
  subScalar(a) {
4963
4964
  return this.addScalar(-a);
4964
4965
  }
4966
+ /** @deprecated */
4965
4967
  multiplyScalar(scalar) {
4966
4968
  for (let i = 0; i < this.ELEMENTS; ++i) {
4967
4969
  this[i] *= scalar;
4968
4970
  }
4969
4971
  return this.check();
4970
4972
  }
4973
+ /** @deprecated */
4971
4974
  divideScalar(a) {
4972
4975
  return this.multiplyByScalar(1 / a);
4973
4976
  }
4977
+ /** @deprecated */
4974
4978
  clampScalar(min, max) {
4975
4979
  for (let i = 0; i < this.ELEMENTS; ++i) {
4976
4980
  this[i] = Math.min(Math.max(this[i], min), max);
4977
4981
  }
4978
4982
  return this.check();
4979
4983
  }
4984
+ /** @deprecated */
4980
4985
  get elements() {
4981
4986
  return this;
4982
4987
  }
@@ -4996,13 +5001,13 @@ void main() {
4996
5001
  }
4997
5002
  function checkNumber(value) {
4998
5003
  if (!Number.isFinite(value)) {
4999
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
5004
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
5000
5005
  }
5001
5006
  return value;
5002
5007
  }
5003
5008
  function checkVector(v, length, callerName = "") {
5004
5009
  if (config.debug && !validateVector(v, length)) {
5005
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
5010
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
5006
5011
  }
5007
5012
  return v;
5008
5013
  }
@@ -5010,12 +5015,13 @@ void main() {
5010
5015
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
5011
5016
  function assert2(condition, message) {
5012
5017
  if (!condition) {
5013
- throw new Error("math.gl assertion ".concat(message));
5018
+ throw new Error(`math.gl assertion ${message}`);
5014
5019
  }
5015
5020
  }
5016
5021
 
5017
5022
  // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
5018
5023
  var Vector = class extends MathArray {
5024
+ // ACCESSORS
5019
5025
  get x() {
5020
5026
  return this[0];
5021
5027
  }
@@ -5028,12 +5034,24 @@ void main() {
5028
5034
  set y(value) {
5029
5035
  this[1] = checkNumber(value);
5030
5036
  }
5037
+ /**
5038
+ * Returns the length of the vector from the origin to the point described by this vector
5039
+ *
5040
+ * @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
5041
+ * Instead we provide `len` and `magnitude`
5042
+ */
5031
5043
  len() {
5032
5044
  return Math.sqrt(this.lengthSquared());
5033
5045
  }
5046
+ /**
5047
+ * Returns the length of the vector from the origin to the point described by this vector
5048
+ */
5034
5049
  magnitude() {
5035
5050
  return this.len();
5036
5051
  }
5052
+ /**
5053
+ * Returns the squared length of the vector from the origin to the point described by this vector
5054
+ */
5037
5055
  lengthSquared() {
5038
5056
  let length = 0;
5039
5057
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -5041,6 +5059,9 @@ void main() {
5041
5059
  }
5042
5060
  return length;
5043
5061
  }
5062
+ /**
5063
+ * Returns the squared length of the vector from the origin to the point described by this vector
5064
+ */
5044
5065
  magnitudeSquared() {
5045
5066
  return this.lengthSquared();
5046
5067
  }
@@ -5062,6 +5083,7 @@ void main() {
5062
5083
  }
5063
5084
  return checkNumber(product);
5064
5085
  }
5086
+ // MODIFIERS
5065
5087
  normalize() {
5066
5088
  const length = this.magnitude();
5067
5089
  if (length !== 0) {
@@ -5087,6 +5109,7 @@ void main() {
5087
5109
  }
5088
5110
  return this.check();
5089
5111
  }
5112
+ // THREE.js compatibility
5090
5113
  lengthSq() {
5091
5114
  return this.lengthSquared();
5092
5115
  }
@@ -5359,6 +5382,12 @@ void main() {
5359
5382
  }
5360
5383
  return ZERO;
5361
5384
  }
5385
+ /**
5386
+ * @class
5387
+ * @param x
5388
+ * @param y
5389
+ * @param z
5390
+ */
5362
5391
  constructor(x = 0, y = 0, z = 0) {
5363
5392
  super(-0, -0, -0);
5364
5393
  if (arguments.length === 1 && isArray(x)) {
@@ -5403,6 +5432,7 @@ void main() {
5403
5432
  object.z = this[2];
5404
5433
  return object;
5405
5434
  }
5435
+ // Getters/setters
5406
5436
  get ELEMENTS() {
5407
5437
  return 3;
5408
5438
  }
@@ -5412,41 +5442,38 @@ void main() {
5412
5442
  set z(value) {
5413
5443
  this[2] = checkNumber(value);
5414
5444
  }
5445
+ // ACCESSORS
5415
5446
  angle(vector) {
5416
5447
  return angle(this, vector);
5417
5448
  }
5449
+ // MODIFIERS
5418
5450
  cross(vector) {
5419
5451
  cross(this, this, vector);
5420
5452
  return this.check();
5421
5453
  }
5422
- rotateX({
5423
- radians,
5424
- origin = ORIGIN
5425
- }) {
5454
+ rotateX({ radians, origin = ORIGIN }) {
5426
5455
  rotateX(this, this, origin, radians);
5427
5456
  return this.check();
5428
5457
  }
5429
- rotateY({
5430
- radians,
5431
- origin = ORIGIN
5432
- }) {
5458
+ rotateY({ radians, origin = ORIGIN }) {
5433
5459
  rotateY(this, this, origin, radians);
5434
5460
  return this.check();
5435
5461
  }
5436
- rotateZ({
5437
- radians,
5438
- origin = ORIGIN
5439
- }) {
5462
+ rotateZ({ radians, origin = ORIGIN }) {
5440
5463
  rotateZ(this, this, origin, radians);
5441
5464
  return this.check();
5442
5465
  }
5466
+ // Transforms
5467
+ // transforms as point (4th component is implicitly 1)
5443
5468
  transform(matrix4) {
5444
5469
  return this.transformAsPoint(matrix4);
5445
5470
  }
5471
+ // transforms as point (4th component is implicitly 1)
5446
5472
  transformAsPoint(matrix4) {
5447
5473
  transformMat42(this, this, matrix4);
5448
5474
  return this.check();
5449
5475
  }
5476
+ // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
5450
5477
  transformAsVector(matrix4) {
5451
5478
  vec3_transformMat4AsVector(this, this, matrix4);
5452
5479
  return this.check();
@@ -5467,19 +5494,29 @@ void main() {
5467
5494
 
5468
5495
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
5469
5496
  var Matrix = class extends MathArray {
5497
+ // fromObject(object) {
5498
+ // const array = object.elements;
5499
+ // return this.fromRowMajor(array);
5500
+ // }
5501
+ // toObject(object) {
5502
+ // const array = object.elements;
5503
+ // this.toRowMajor(array);
5504
+ // return object;
5505
+ // }
5506
+ // TODO better override formatString?
5470
5507
  toString() {
5471
5508
  let string = "[";
5472
5509
  if (config.printRowMajor) {
5473
5510
  string += "row-major:";
5474
5511
  for (let row = 0; row < this.RANK; ++row) {
5475
5512
  for (let col = 0; col < this.RANK; ++col) {
5476
- string += " ".concat(this[col * this.RANK + row]);
5513
+ string += ` ${this[col * this.RANK + row]}`;
5477
5514
  }
5478
5515
  }
5479
5516
  } else {
5480
5517
  string += "column-major:";
5481
5518
  for (let i = 0; i < this.ELEMENTS; ++i) {
5482
- string += " ".concat(this[i]);
5519
+ string += ` ${this[i]}`;
5483
5520
  }
5484
5521
  }
5485
5522
  string += "]";
@@ -5488,9 +5525,11 @@ void main() {
5488
5525
  getElementIndex(row, col) {
5489
5526
  return col * this.RANK + row;
5490
5527
  }
5528
+ // By default assumes row major indices
5491
5529
  getElement(row, col) {
5492
5530
  return this[col * this.RANK + row];
5493
5531
  }
5532
+ // By default assumes row major indices
5494
5533
  setElement(row, col, value) {
5495
5534
  this[col * this.RANK + row] = checkNumber(value);
5496
5535
  return this;
@@ -6256,6 +6295,7 @@ void main() {
6256
6295
  this[15] = array[15];
6257
6296
  return this.check();
6258
6297
  }
6298
+ // eslint-disable-next-line max-params
6259
6299
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
6260
6300
  this[0] = m00;
6261
6301
  this[1] = m10;
@@ -6275,6 +6315,8 @@ void main() {
6275
6315
  this[15] = m33;
6276
6316
  return this.check();
6277
6317
  }
6318
+ // accepts row major order, stores as column major
6319
+ // eslint-disable-next-line max-params
6278
6320
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
6279
6321
  this[0] = m00;
6280
6322
  this[1] = m10;
@@ -6313,25 +6355,41 @@ void main() {
6313
6355
  result[15] = this[15];
6314
6356
  return result;
6315
6357
  }
6358
+ // Constructors
6359
+ /** Set to identity matrix */
6316
6360
  identity() {
6317
6361
  return this.copy(IDENTITY_MATRIX);
6318
6362
  }
6363
+ /**
6364
+ *
6365
+ * @param object
6366
+ * @returns self
6367
+ */
6368
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6319
6369
  fromObject(object) {
6320
6370
  return this.check();
6321
6371
  }
6372
+ /**
6373
+ * Calculates a 4x4 matrix from the given quaternion
6374
+ * @param quaternion Quaternion to create matrix from
6375
+ * @returns self
6376
+ */
6322
6377
  fromQuaternion(quaternion) {
6323
6378
  fromQuat(this, quaternion);
6324
6379
  return this.check();
6325
6380
  }
6381
+ /**
6382
+ * Generates a frustum matrix with the given bounds
6383
+ * @param view.left - Left bound of the frustum
6384
+ * @param view.right - Right bound of the frustum
6385
+ * @param view.bottom - Bottom bound of the frustum
6386
+ * @param view.top - Top bound of the frustum
6387
+ * @param view.near - Near bound of the frustum
6388
+ * @param view.far - Far bound of the frustum. Can be set to Infinity.
6389
+ * @returns self
6390
+ */
6326
6391
  frustum(view) {
6327
- const {
6328
- left,
6329
- right,
6330
- bottom,
6331
- top,
6332
- near = DEFAULT_NEAR,
6333
- far = DEFAULT_FAR
6334
- } = view;
6392
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6335
6393
  if (far === Infinity) {
6336
6394
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
6337
6395
  } else {
@@ -6339,35 +6397,47 @@ void main() {
6339
6397
  }
6340
6398
  return this.check();
6341
6399
  }
6400
+ /**
6401
+ * Generates a look-at matrix with the given eye position, focal point,
6402
+ * and up axis
6403
+ * @param view.eye - (vector) Position of the viewer
6404
+ * @param view.center - (vector) Point the viewer is looking at
6405
+ * @param view.up - (vector) Up axis
6406
+ * @returns self
6407
+ */
6342
6408
  lookAt(view) {
6343
- const {
6344
- eye,
6345
- center = [0, 0, 0],
6346
- up = [0, 1, 0]
6347
- } = view;
6409
+ const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
6348
6410
  lookAt(this, eye, center, up);
6349
6411
  return this.check();
6350
6412
  }
6413
+ /**
6414
+ * Generates a orthogonal projection matrix with the given bounds
6415
+ * from "traditional" view space parameters
6416
+ * @param view.left - Left bound of the frustum
6417
+ * @param view.right number Right bound of the frustum
6418
+ * @param view.bottom - Bottom bound of the frustum
6419
+ * @param view.top number Top bound of the frustum
6420
+ * @param view.near - Near bound of the frustum
6421
+ * @param view.far number Far bound of the frustum
6422
+ * @returns self
6423
+ */
6351
6424
  ortho(view) {
6352
- const {
6353
- left,
6354
- right,
6355
- bottom,
6356
- top,
6357
- near = DEFAULT_NEAR,
6358
- far = DEFAULT_FAR
6359
- } = view;
6425
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6360
6426
  ortho(this, left, right, bottom, top, near, far);
6361
6427
  return this.check();
6362
6428
  }
6429
+ /**
6430
+ * Generates an orthogonal projection matrix with the same parameters
6431
+ * as a perspective matrix (plus focalDistance)
6432
+ * @param view.fovy Vertical field of view in radians
6433
+ * @param view.aspect Aspect ratio. Typically viewport width / viewport height
6434
+ * @param view.focalDistance Distance in the view frustum used for extent calculations
6435
+ * @param view.near Near bound of the frustum
6436
+ * @param view.far Far bound of the frustum
6437
+ * @returns self
6438
+ */
6363
6439
  orthographic(view) {
6364
- const {
6365
- fovy = DEFAULT_FOVY,
6366
- aspect = DEFAULT_ASPECT,
6367
- focalDistance = 1,
6368
- near = DEFAULT_NEAR,
6369
- far = DEFAULT_FAR
6370
- } = view;
6440
+ const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
6371
6441
  checkRadians(fovy);
6372
6442
  const halfY = fovy / 2;
6373
6443
  const top = focalDistance * Math.tan(halfY);
@@ -6381,32 +6451,53 @@ void main() {
6381
6451
  far
6382
6452
  });
6383
6453
  }
6454
+ /**
6455
+ * Generates a perspective projection matrix with the given bounds
6456
+ * @param view.fovy Vertical field of view in radians
6457
+ * @param view.aspect Aspect ratio. typically viewport width/height
6458
+ * @param view.near Near bound of the frustum
6459
+ * @param view.far Far bound of the frustum
6460
+ * @returns self
6461
+ */
6384
6462
  perspective(view) {
6385
- const {
6386
- fovy = 45 * Math.PI / 180,
6387
- aspect = 1,
6388
- near = 0.1,
6389
- far = 500
6390
- } = view;
6463
+ const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
6391
6464
  checkRadians(fovy);
6392
6465
  perspective(this, fovy, aspect, near, far);
6393
6466
  return this.check();
6394
6467
  }
6468
+ // Accessors
6395
6469
  determinant() {
6396
6470
  return determinant(this);
6397
6471
  }
6472
+ /**
6473
+ * Extracts the non-uniform scale assuming the matrix is an affine transformation.
6474
+ * The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
6475
+ * @param result
6476
+ * @returns self
6477
+ */
6398
6478
  getScale(result = [-0, -0, -0]) {
6399
6479
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
6400
6480
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
6401
6481
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
6402
6482
  return result;
6403
6483
  }
6484
+ /**
6485
+ * Gets the translation portion, assuming the matrix is a affine transformation matrix.
6486
+ * @param result
6487
+ * @returns self
6488
+ */
6404
6489
  getTranslation(result = [-0, -0, -0]) {
6405
6490
  result[0] = this[12];
6406
6491
  result[1] = this[13];
6407
6492
  result[2] = this[14];
6408
6493
  return result;
6409
6494
  }
6495
+ /**
6496
+ * Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
6497
+ * @param result
6498
+ * @param scaleResult
6499
+ * @returns self
6500
+ */
6410
6501
  getRotation(result, scaleResult) {
6411
6502
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
6412
6503
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6432,6 +6523,12 @@ void main() {
6432
6523
  result[15] = 1;
6433
6524
  return result;
6434
6525
  }
6526
+ /**
6527
+ *
6528
+ * @param result
6529
+ * @param scaleResult
6530
+ * @returns self
6531
+ */
6435
6532
  getRotationMatrix3(result, scaleResult) {
6436
6533
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
6437
6534
  scaleResult = scaleResult || [-0, -0, -0];
@@ -6450,6 +6547,7 @@ void main() {
6450
6547
  result[8] = this[10] * inverseScale2;
6451
6548
  return result;
6452
6549
  }
6550
+ // Modifiers
6453
6551
  transpose() {
6454
6552
  transpose(this, this);
6455
6553
  return this.check();
@@ -6458,6 +6556,7 @@ void main() {
6458
6556
  invert(this, this);
6459
6557
  return this.check();
6460
6558
  }
6559
+ // Operations
6461
6560
  multiplyLeft(a) {
6462
6561
  multiply(this, a, this);
6463
6562
  return this.check();
@@ -6466,33 +6565,68 @@ void main() {
6466
6565
  multiply(this, this, a);
6467
6566
  return this.check();
6468
6567
  }
6568
+ // Rotates a matrix by the given angle around the X axis
6469
6569
  rotateX(radians) {
6470
6570
  rotateX2(this, this, radians);
6471
6571
  return this.check();
6472
6572
  }
6573
+ // Rotates a matrix by the given angle around the Y axis.
6473
6574
  rotateY(radians) {
6474
6575
  rotateY2(this, this, radians);
6475
6576
  return this.check();
6476
6577
  }
6578
+ /**
6579
+ * Rotates a matrix by the given angle around the Z axis.
6580
+ * @param radians
6581
+ * @returns self
6582
+ */
6477
6583
  rotateZ(radians) {
6478
6584
  rotateZ2(this, this, radians);
6479
6585
  return this.check();
6480
6586
  }
6587
+ /**
6588
+ *
6589
+ * @param param0
6590
+ * @returns self
6591
+ */
6481
6592
  rotateXYZ(angleXYZ) {
6482
6593
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
6483
6594
  }
6595
+ /**
6596
+ *
6597
+ * @param radians
6598
+ * @param axis
6599
+ * @returns self
6600
+ */
6484
6601
  rotateAxis(radians, axis) {
6485
6602
  rotate(this, this, radians, axis);
6486
6603
  return this.check();
6487
6604
  }
6605
+ /**
6606
+ *
6607
+ * @param factor
6608
+ * @returns self
6609
+ */
6488
6610
  scale(factor) {
6489
6611
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
6490
6612
  return this.check();
6491
6613
  }
6614
+ /**
6615
+ *
6616
+ * @param vec
6617
+ * @returns self
6618
+ */
6492
6619
  translate(vector) {
6493
6620
  translate(this, this, vector);
6494
6621
  return this.check();
6495
6622
  }
6623
+ // Transforms
6624
+ /**
6625
+ * Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
6626
+ * @param vector
6627
+ * @param result
6628
+ * @returns self
6629
+ */
6496
6630
  transform(vector, result) {
6497
6631
  if (vector.length === 4) {
6498
6632
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -6501,10 +6635,14 @@ void main() {
6501
6635
  }
6502
6636
  return this.transformAsPoint(vector, result);
6503
6637
  }
6638
+ /**
6639
+ * Transforms any 2 or 3 element array as point (w implicitly 1)
6640
+ * @param vector
6641
+ * @param result
6642
+ * @returns self
6643
+ */
6504
6644
  transformAsPoint(vector, result) {
6505
- const {
6506
- length
6507
- } = vector;
6645
+ const { length } = vector;
6508
6646
  let out;
6509
6647
  switch (length) {
6510
6648
  case 2:
@@ -6519,6 +6657,12 @@ void main() {
6519
6657
  checkVector(out, vector.length);
6520
6658
  return out;
6521
6659
  }
6660
+ /**
6661
+ * Transforms any 2 or 3 element array as vector (w implicitly 0)
6662
+ * @param vector
6663
+ * @param result
6664
+ * @returns self
6665
+ */
6522
6666
  transformAsVector(vector, result) {
6523
6667
  let out;
6524
6668
  switch (vector.length) {
@@ -6534,15 +6678,19 @@ void main() {
6534
6678
  checkVector(out, vector.length);
6535
6679
  return out;
6536
6680
  }
6681
+ /** @deprecated */
6537
6682
  transformPoint(vector, result) {
6538
6683
  return this.transformAsPoint(vector, result);
6539
6684
  }
6685
+ /** @deprecated */
6540
6686
  transformVector(vector, result) {
6541
6687
  return this.transformAsPoint(vector, result);
6542
6688
  }
6689
+ /** @deprecated */
6543
6690
  transformDirection(vector, result) {
6544
6691
  return this.transformAsVector(vector, result);
6545
6692
  }
6693
+ // three.js math API compatibility
6546
6694
  makeRotationX(radians) {
6547
6695
  return this.identity().rotateX(radians);
6548
6696
  }
@@ -7081,15 +7229,12 @@ void main() {
7081
7229
  if (props.instanceCount) {
7082
7230
  this.setInstanceCount(props.instanceCount);
7083
7231
  }
7084
- if (props.indices) {
7085
- throw new Error("Model.props.indices removed. Use props.indexBuffer");
7086
- }
7087
7232
  if (props.indexBuffer) {
7088
7233
  this.setIndexBuffer(props.indexBuffer);
7089
7234
  }
7090
7235
  if (props.attributes) {
7091
7236
  this.setAttributes(props.attributes, {
7092
- ignoreUnknownAttributes: props.ignoreUnknownAttributes
7237
+ disableWarnings: props.disableWarnings
7093
7238
  });
7094
7239
  }
7095
7240
  if (props.constantAttributes) {
@@ -7146,7 +7291,7 @@ void main() {
7146
7291
  try {
7147
7292
  this._logDrawCallStart();
7148
7293
  this.pipeline = this._updatePipeline();
7149
- this.pipeline.setBindings(this.bindings);
7294
+ this.pipeline.setBindings(this.bindings, { disableWarnings: this.props.disableWarnings });
7150
7295
  if (!(0, import_core11.isObjectEmpty)(this.uniforms)) {
7151
7296
  this.pipeline.setUniformsWebGL(this.uniforms);
7152
7297
  }
@@ -7305,7 +7450,7 @@ void main() {
7305
7450
  set = true;
7306
7451
  }
7307
7452
  }
7308
- if (!set && (options?.ignoreUnknownAttributes || this.props.ignoreUnknownAttributes)) {
7453
+ if (!set && !(options?.disableWarnings || this.props.disableWarnings)) {
7309
7454
  import_core11.log.warn(
7310
7455
  `Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`
7311
7456
  )();
@@ -7321,12 +7466,12 @@ void main() {
7321
7466
  * is read from the context's global constant value for that attribute location.
7322
7467
  * @param constantAttributes
7323
7468
  */
7324
- setConstantAttributes(attributes) {
7469
+ setConstantAttributes(attributes, options) {
7325
7470
  for (const [attributeName, value] of Object.entries(attributes)) {
7326
7471
  const attributeInfo = this._attributeInfos[attributeName];
7327
7472
  if (attributeInfo) {
7328
7473
  this.vertexArray.setConstantWebGL(attributeInfo.location, value);
7329
- } else {
7474
+ } else if (!(options?.disableWarnings || this.props.disableWarnings)) {
7330
7475
  import_core11.log.warn(
7331
7476
  `Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
7332
7477
  )();
@@ -7385,9 +7530,9 @@ void main() {
7385
7530
  }
7386
7531
  }
7387
7532
  this.vertexCount = gpuGeometry.vertexCount;
7388
- this.setIndexBuffer(gpuGeometry.indices);
7389
- this.setAttributes(gpuGeometry.attributes, { ignoreUnknownAttributes: true });
7390
- this.setAttributes(attributes, { ignoreUnknownAttributes: this.props.ignoreUnknownAttributes });
7533
+ this.setIndexBuffer(gpuGeometry.indices || null);
7534
+ this.setAttributes(gpuGeometry.attributes, { disableWarnings: true });
7535
+ this.setAttributes(attributes, { disableWarnings: this.props.disableWarnings });
7391
7536
  this.setNeedsRedraw("geometry attributes");
7392
7537
  }
7393
7538
  /** Mark pipeline as needing update */
@@ -7538,7 +7683,7 @@ void main() {
7538
7683
  transformFeedback: void 0,
7539
7684
  shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
7540
7685
  debugShaders: void 0,
7541
- ignoreUnknownAttributes: void 0
7686
+ disableWarnings: void 0
7542
7687
  });
7543
7688
  function mergeBufferLayouts(layouts1, layouts2) {
7544
7689
  const layouts = [...layouts1];