@luma.gl/engine 9.0.14 → 9.0.15

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