@luma.gl/gltf 9.1.0-alpha.2 → 9.1.0-alpha.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
@@ -264,7 +264,7 @@ var __exports__ = (() => {
264
264
  }
265
265
 
266
266
  // ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
267
- var VERSION = true ? "4.2.0-beta.2" : "latest";
267
+ var VERSION = true ? "4.2.1" : "latest";
268
268
 
269
269
  // ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
270
270
  var parseImageNode = globalThis.loaders?.parseImageNode;
@@ -837,17 +837,11 @@ var __exports__ = (() => {
837
837
  printRowMajor: true,
838
838
  _cartographicRadians: false
839
839
  };
840
- globalThis.mathgl = globalThis.mathgl || {
841
- config: {
842
- ...DEFAULT_CONFIG
843
- }
844
- };
840
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
845
841
  var config = globalThis.mathgl.config;
846
- function formatValue(value, {
847
- precision = config.precision
848
- } = {}) {
842
+ function formatValue(value, { precision = config.precision } = {}) {
849
843
  value = round(value);
850
- return "".concat(parseFloat(value.toPrecision(precision)));
844
+ return `${parseFloat(value.toPrecision(precision))}`;
851
845
  }
852
846
  function isArray(value) {
853
847
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -891,28 +885,12 @@ var __exports__ = (() => {
891
885
  }
892
886
 
893
887
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
894
- function _extendableBuiltin(cls) {
895
- function ExtendableBuiltin() {
896
- var instance = Reflect.construct(cls, Array.from(arguments));
897
- Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
898
- return instance;
899
- }
900
- ExtendableBuiltin.prototype = Object.create(cls.prototype, {
901
- constructor: {
902
- value: cls,
903
- enumerable: false,
904
- writable: true,
905
- configurable: true
906
- }
907
- });
908
- if (Object.setPrototypeOf) {
909
- Object.setPrototypeOf(ExtendableBuiltin, cls);
910
- } else {
911
- ExtendableBuiltin.__proto__ = cls;
912
- }
913
- return ExtendableBuiltin;
914
- }
915
- var MathArray = class extends _extendableBuiltin(Array) {
888
+ var MathArray = class extends Array {
889
+ // Common methods
890
+ /**
891
+ * Clone the current object
892
+ * @returns a new copy of this object
893
+ */
916
894
  clone() {
917
895
  return new this.constructor().copy(this);
918
896
  }
@@ -932,7 +910,10 @@ var __exports__ = (() => {
932
910
  return targetObject;
933
911
  }
934
912
  from(arrayOrObject) {
935
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
913
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
914
+ // @ts-ignore
915
+ this.fromObject(arrayOrObject)
916
+ );
936
917
  }
937
918
  to(arrayOrObject) {
938
919
  if (arrayOrObject === this) {
@@ -943,18 +924,20 @@ var __exports__ = (() => {
943
924
  toTarget(target) {
944
925
  return target ? this.to(target) : this;
945
926
  }
927
+ /** @deprecated */
946
928
  toFloat32Array() {
947
929
  return new Float32Array(this);
948
930
  }
949
931
  toString() {
950
932
  return this.formatString(config);
951
933
  }
934
+ /** Formats string according to options */
952
935
  formatString(opts) {
953
936
  let string = "";
954
937
  for (let i = 0; i < this.ELEMENTS; ++i) {
955
938
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
956
939
  }
957
- return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
940
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
958
941
  }
959
942
  equals(array) {
960
943
  if (!array || this.length !== array.length) {
@@ -978,6 +961,8 @@ var __exports__ = (() => {
978
961
  }
979
962
  return true;
980
963
  }
964
+ // Modifiers
965
+ /** Negates all values in this object */
981
966
  negate() {
982
967
  for (let i = 0; i < this.ELEMENTS; ++i) {
983
968
  this[i] = -this[i];
@@ -995,12 +980,14 @@ var __exports__ = (() => {
995
980
  }
996
981
  return this.check();
997
982
  }
983
+ /** Minimal */
998
984
  min(vector) {
999
985
  for (let i = 0; i < this.ELEMENTS; ++i) {
1000
986
  this[i] = Math.min(vector[i], this[i]);
1001
987
  }
1002
988
  return this.check();
1003
989
  }
990
+ /** Maximal */
1004
991
  max(vector) {
1005
992
  for (let i = 0; i < this.ELEMENTS; ++i) {
1006
993
  this[i] = Math.max(vector[i], this[i]);
@@ -1041,18 +1028,25 @@ var __exports__ = (() => {
1041
1028
  }
1042
1029
  return this.check();
1043
1030
  }
1031
+ /**
1032
+ * Multiplies all elements by `scale`
1033
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
1034
+ */
1044
1035
  multiplyByScalar(scalar) {
1045
1036
  for (let i = 0; i < this.ELEMENTS; ++i) {
1046
1037
  this[i] *= scalar;
1047
1038
  }
1048
1039
  return this.check();
1049
1040
  }
1041
+ // Debug checks
1042
+ /** Throws an error if array length is incorrect or contains illegal values */
1050
1043
  check() {
1051
1044
  if (config.debug && !this.validate()) {
1052
- throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
1045
+ throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
1053
1046
  }
1054
1047
  return this;
1055
1048
  }
1049
+ /** Returns false if the array length is incorrect or contains illegal values */
1056
1050
  validate() {
1057
1051
  let valid = this.length === this.ELEMENTS;
1058
1052
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -1060,39 +1054,48 @@ var __exports__ = (() => {
1060
1054
  }
1061
1055
  return valid;
1062
1056
  }
1057
+ // three.js compatibility
1058
+ /** @deprecated */
1063
1059
  sub(a) {
1064
1060
  return this.subtract(a);
1065
1061
  }
1062
+ /** @deprecated */
1066
1063
  setScalar(a) {
1067
1064
  for (let i = 0; i < this.ELEMENTS; ++i) {
1068
1065
  this[i] = a;
1069
1066
  }
1070
1067
  return this.check();
1071
1068
  }
1069
+ /** @deprecated */
1072
1070
  addScalar(a) {
1073
1071
  for (let i = 0; i < this.ELEMENTS; ++i) {
1074
1072
  this[i] += a;
1075
1073
  }
1076
1074
  return this.check();
1077
1075
  }
1076
+ /** @deprecated */
1078
1077
  subScalar(a) {
1079
1078
  return this.addScalar(-a);
1080
1079
  }
1080
+ /** @deprecated */
1081
1081
  multiplyScalar(scalar) {
1082
1082
  for (let i = 0; i < this.ELEMENTS; ++i) {
1083
1083
  this[i] *= scalar;
1084
1084
  }
1085
1085
  return this.check();
1086
1086
  }
1087
+ /** @deprecated */
1087
1088
  divideScalar(a) {
1088
1089
  return this.multiplyByScalar(1 / a);
1089
1090
  }
1091
+ /** @deprecated */
1090
1092
  clampScalar(min, max) {
1091
1093
  for (let i = 0; i < this.ELEMENTS; ++i) {
1092
1094
  this[i] = Math.min(Math.max(this[i], min), max);
1093
1095
  }
1094
1096
  return this.check();
1095
1097
  }
1098
+ /** @deprecated */
1096
1099
  get elements() {
1097
1100
  return this;
1098
1101
  }
@@ -1112,13 +1115,13 @@ var __exports__ = (() => {
1112
1115
  }
1113
1116
  function checkNumber(value) {
1114
1117
  if (!Number.isFinite(value)) {
1115
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
1118
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
1116
1119
  }
1117
1120
  return value;
1118
1121
  }
1119
1122
  function checkVector(v, length4, callerName = "") {
1120
1123
  if (config.debug && !validateVector(v, length4)) {
1121
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
1124
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
1122
1125
  }
1123
1126
  return v;
1124
1127
  }
@@ -1126,12 +1129,13 @@ var __exports__ = (() => {
1126
1129
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
1127
1130
  function assert2(condition, message) {
1128
1131
  if (!condition) {
1129
- throw new Error("math.gl assertion ".concat(message));
1132
+ throw new Error(`math.gl assertion ${message}`);
1130
1133
  }
1131
1134
  }
1132
1135
 
1133
1136
  // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
1134
1137
  var Vector = class extends MathArray {
1138
+ // ACCESSORS
1135
1139
  get x() {
1136
1140
  return this[0];
1137
1141
  }
@@ -1144,12 +1148,24 @@ var __exports__ = (() => {
1144
1148
  set y(value) {
1145
1149
  this[1] = checkNumber(value);
1146
1150
  }
1151
+ /**
1152
+ * Returns the length of the vector from the origin to the point described by this vector
1153
+ *
1154
+ * @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
1155
+ * Instead we provide `len` and `magnitude`
1156
+ */
1147
1157
  len() {
1148
1158
  return Math.sqrt(this.lengthSquared());
1149
1159
  }
1160
+ /**
1161
+ * Returns the length of the vector from the origin to the point described by this vector
1162
+ */
1150
1163
  magnitude() {
1151
1164
  return this.len();
1152
1165
  }
1166
+ /**
1167
+ * Returns the squared length of the vector from the origin to the point described by this vector
1168
+ */
1153
1169
  lengthSquared() {
1154
1170
  let length4 = 0;
1155
1171
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -1157,6 +1173,9 @@ var __exports__ = (() => {
1157
1173
  }
1158
1174
  return length4;
1159
1175
  }
1176
+ /**
1177
+ * Returns the squared length of the vector from the origin to the point described by this vector
1178
+ */
1160
1179
  magnitudeSquared() {
1161
1180
  return this.lengthSquared();
1162
1181
  }
@@ -1178,6 +1197,7 @@ var __exports__ = (() => {
1178
1197
  }
1179
1198
  return checkNumber(product);
1180
1199
  }
1200
+ // MODIFIERS
1181
1201
  normalize() {
1182
1202
  const length4 = this.magnitude();
1183
1203
  if (length4 !== 0) {
@@ -1203,6 +1223,7 @@ var __exports__ = (() => {
1203
1223
  }
1204
1224
  return this.check();
1205
1225
  }
1226
+ // THREE.js compatibility
1206
1227
  lengthSq() {
1207
1228
  return this.lengthSquared();
1208
1229
  }
@@ -1501,6 +1522,8 @@ var __exports__ = (() => {
1501
1522
  object.w = this[3];
1502
1523
  return object;
1503
1524
  }
1525
+ // Getters/setters
1526
+ /* eslint-disable no-multi-spaces, brace-style, no-return-assign */
1504
1527
  get ELEMENTS() {
1505
1528
  return 4;
1506
1529
  }
@@ -1532,6 +1555,7 @@ var __exports__ = (() => {
1532
1555
  transformQuat(this, this, quaternion2);
1533
1556
  return this.check();
1534
1557
  }
1558
+ // three.js compatibility
1535
1559
  applyMatrix4(m) {
1536
1560
  m.transform(this, this);
1537
1561
  return this;
@@ -1540,19 +1564,29 @@ var __exports__ = (() => {
1540
1564
 
1541
1565
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
1542
1566
  var Matrix = class extends MathArray {
1567
+ // fromObject(object) {
1568
+ // const array = object.elements;
1569
+ // return this.fromRowMajor(array);
1570
+ // }
1571
+ // toObject(object) {
1572
+ // const array = object.elements;
1573
+ // this.toRowMajor(array);
1574
+ // return object;
1575
+ // }
1576
+ // TODO better override formatString?
1543
1577
  toString() {
1544
1578
  let string = "[";
1545
1579
  if (config.printRowMajor) {
1546
1580
  string += "row-major:";
1547
1581
  for (let row = 0; row < this.RANK; ++row) {
1548
1582
  for (let col = 0; col < this.RANK; ++col) {
1549
- string += " ".concat(this[col * this.RANK + row]);
1583
+ string += ` ${this[col * this.RANK + row]}`;
1550
1584
  }
1551
1585
  }
1552
1586
  } else {
1553
1587
  string += "column-major:";
1554
1588
  for (let i = 0; i < this.ELEMENTS; ++i) {
1555
- string += " ".concat(this[i]);
1589
+ string += ` ${this[i]}`;
1556
1590
  }
1557
1591
  }
1558
1592
  string += "]";
@@ -1561,9 +1595,11 @@ var __exports__ = (() => {
1561
1595
  getElementIndex(row, col) {
1562
1596
  return col * this.RANK + row;
1563
1597
  }
1598
+ // By default assumes row major indices
1564
1599
  getElement(row, col) {
1565
1600
  return this[col * this.RANK + row];
1566
1601
  }
1602
+ // By default assumes row major indices
1567
1603
  setElement(row, col, value) {
1568
1604
  this[col * this.RANK + row] = checkNumber(value);
1569
1605
  return this;
@@ -2421,6 +2457,7 @@ var __exports__ = (() => {
2421
2457
  this[15] = array[15];
2422
2458
  return this.check();
2423
2459
  }
2460
+ // eslint-disable-next-line max-params
2424
2461
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
2425
2462
  this[0] = m00;
2426
2463
  this[1] = m10;
@@ -2440,6 +2477,8 @@ var __exports__ = (() => {
2440
2477
  this[15] = m33;
2441
2478
  return this.check();
2442
2479
  }
2480
+ // accepts row major order, stores as column major
2481
+ // eslint-disable-next-line max-params
2443
2482
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
2444
2483
  this[0] = m00;
2445
2484
  this[1] = m10;
@@ -2478,25 +2517,41 @@ var __exports__ = (() => {
2478
2517
  result[15] = this[15];
2479
2518
  return result;
2480
2519
  }
2520
+ // Constructors
2521
+ /** Set to identity matrix */
2481
2522
  identity() {
2482
2523
  return this.copy(IDENTITY_MATRIX);
2483
2524
  }
2525
+ /**
2526
+ *
2527
+ * @param object
2528
+ * @returns self
2529
+ */
2530
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2484
2531
  fromObject(object) {
2485
2532
  return this.check();
2486
2533
  }
2534
+ /**
2535
+ * Calculates a 4x4 matrix from the given quaternion
2536
+ * @param quaternion Quaternion to create matrix from
2537
+ * @returns self
2538
+ */
2487
2539
  fromQuaternion(quaternion2) {
2488
2540
  fromQuat(this, quaternion2);
2489
2541
  return this.check();
2490
2542
  }
2543
+ /**
2544
+ * Generates a frustum matrix with the given bounds
2545
+ * @param view.left - Left bound of the frustum
2546
+ * @param view.right - Right bound of the frustum
2547
+ * @param view.bottom - Bottom bound of the frustum
2548
+ * @param view.top - Top bound of the frustum
2549
+ * @param view.near - Near bound of the frustum
2550
+ * @param view.far - Far bound of the frustum. Can be set to Infinity.
2551
+ * @returns self
2552
+ */
2491
2553
  frustum(view) {
2492
- const {
2493
- left,
2494
- right,
2495
- bottom,
2496
- top,
2497
- near = DEFAULT_NEAR,
2498
- far = DEFAULT_FAR
2499
- } = view;
2554
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
2500
2555
  if (far === Infinity) {
2501
2556
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
2502
2557
  } else {
@@ -2504,35 +2559,47 @@ var __exports__ = (() => {
2504
2559
  }
2505
2560
  return this.check();
2506
2561
  }
2562
+ /**
2563
+ * Generates a look-at matrix with the given eye position, focal point,
2564
+ * and up axis
2565
+ * @param view.eye - (vector) Position of the viewer
2566
+ * @param view.center - (vector) Point the viewer is looking at
2567
+ * @param view.up - (vector) Up axis
2568
+ * @returns self
2569
+ */
2507
2570
  lookAt(view) {
2508
- const {
2509
- eye,
2510
- center = [0, 0, 0],
2511
- up = [0, 1, 0]
2512
- } = view;
2571
+ const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
2513
2572
  lookAt(this, eye, center, up);
2514
2573
  return this.check();
2515
2574
  }
2575
+ /**
2576
+ * Generates a orthogonal projection matrix with the given bounds
2577
+ * from "traditional" view space parameters
2578
+ * @param view.left - Left bound of the frustum
2579
+ * @param view.right number Right bound of the frustum
2580
+ * @param view.bottom - Bottom bound of the frustum
2581
+ * @param view.top number Top bound of the frustum
2582
+ * @param view.near - Near bound of the frustum
2583
+ * @param view.far number Far bound of the frustum
2584
+ * @returns self
2585
+ */
2516
2586
  ortho(view) {
2517
- const {
2518
- left,
2519
- right,
2520
- bottom,
2521
- top,
2522
- near = DEFAULT_NEAR,
2523
- far = DEFAULT_FAR
2524
- } = view;
2587
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
2525
2588
  ortho(this, left, right, bottom, top, near, far);
2526
2589
  return this.check();
2527
2590
  }
2591
+ /**
2592
+ * Generates an orthogonal projection matrix with the same parameters
2593
+ * as a perspective matrix (plus focalDistance)
2594
+ * @param view.fovy Vertical field of view in radians
2595
+ * @param view.aspect Aspect ratio. Typically viewport width / viewport height
2596
+ * @param view.focalDistance Distance in the view frustum used for extent calculations
2597
+ * @param view.near Near bound of the frustum
2598
+ * @param view.far Far bound of the frustum
2599
+ * @returns self
2600
+ */
2528
2601
  orthographic(view) {
2529
- const {
2530
- fovy = DEFAULT_FOVY,
2531
- aspect = DEFAULT_ASPECT,
2532
- focalDistance = 1,
2533
- near = DEFAULT_NEAR,
2534
- far = DEFAULT_FAR
2535
- } = view;
2602
+ const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
2536
2603
  checkRadians(fovy);
2537
2604
  const halfY = fovy / 2;
2538
2605
  const top = focalDistance * Math.tan(halfY);
@@ -2546,32 +2613,53 @@ var __exports__ = (() => {
2546
2613
  far
2547
2614
  });
2548
2615
  }
2616
+ /**
2617
+ * Generates a perspective projection matrix with the given bounds
2618
+ * @param view.fovy Vertical field of view in radians
2619
+ * @param view.aspect Aspect ratio. typically viewport width/height
2620
+ * @param view.near Near bound of the frustum
2621
+ * @param view.far Far bound of the frustum
2622
+ * @returns self
2623
+ */
2549
2624
  perspective(view) {
2550
- const {
2551
- fovy = 45 * Math.PI / 180,
2552
- aspect = 1,
2553
- near = 0.1,
2554
- far = 500
2555
- } = view;
2625
+ const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
2556
2626
  checkRadians(fovy);
2557
2627
  perspective(this, fovy, aspect, near, far);
2558
2628
  return this.check();
2559
2629
  }
2630
+ // Accessors
2560
2631
  determinant() {
2561
2632
  return determinant(this);
2562
2633
  }
2634
+ /**
2635
+ * Extracts the non-uniform scale assuming the matrix is an affine transformation.
2636
+ * The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
2637
+ * @param result
2638
+ * @returns self
2639
+ */
2563
2640
  getScale(result = [-0, -0, -0]) {
2564
2641
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
2565
2642
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
2566
2643
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
2567
2644
  return result;
2568
2645
  }
2646
+ /**
2647
+ * Gets the translation portion, assuming the matrix is a affine transformation matrix.
2648
+ * @param result
2649
+ * @returns self
2650
+ */
2569
2651
  getTranslation(result = [-0, -0, -0]) {
2570
2652
  result[0] = this[12];
2571
2653
  result[1] = this[13];
2572
2654
  result[2] = this[14];
2573
2655
  return result;
2574
2656
  }
2657
+ /**
2658
+ * Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
2659
+ * @param result
2660
+ * @param scaleResult
2661
+ * @returns self
2662
+ */
2575
2663
  getRotation(result, scaleResult) {
2576
2664
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
2577
2665
  scaleResult = scaleResult || [-0, -0, -0];
@@ -2597,6 +2685,12 @@ var __exports__ = (() => {
2597
2685
  result[15] = 1;
2598
2686
  return result;
2599
2687
  }
2688
+ /**
2689
+ *
2690
+ * @param result
2691
+ * @param scaleResult
2692
+ * @returns self
2693
+ */
2600
2694
  getRotationMatrix3(result, scaleResult) {
2601
2695
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
2602
2696
  scaleResult = scaleResult || [-0, -0, -0];
@@ -2615,6 +2709,7 @@ var __exports__ = (() => {
2615
2709
  result[8] = this[10] * inverseScale2;
2616
2710
  return result;
2617
2711
  }
2712
+ // Modifiers
2618
2713
  transpose() {
2619
2714
  transpose(this, this);
2620
2715
  return this.check();
@@ -2623,6 +2718,7 @@ var __exports__ = (() => {
2623
2718
  invert(this, this);
2624
2719
  return this.check();
2625
2720
  }
2721
+ // Operations
2626
2722
  multiplyLeft(a) {
2627
2723
  multiply(this, a, this);
2628
2724
  return this.check();
@@ -2631,33 +2727,68 @@ var __exports__ = (() => {
2631
2727
  multiply(this, this, a);
2632
2728
  return this.check();
2633
2729
  }
2730
+ // Rotates a matrix by the given angle around the X axis
2634
2731
  rotateX(radians) {
2635
2732
  rotateX(this, this, radians);
2636
2733
  return this.check();
2637
2734
  }
2735
+ // Rotates a matrix by the given angle around the Y axis.
2638
2736
  rotateY(radians) {
2639
2737
  rotateY(this, this, radians);
2640
2738
  return this.check();
2641
2739
  }
2740
+ /**
2741
+ * Rotates a matrix by the given angle around the Z axis.
2742
+ * @param radians
2743
+ * @returns self
2744
+ */
2642
2745
  rotateZ(radians) {
2643
2746
  rotateZ(this, this, radians);
2644
2747
  return this.check();
2645
2748
  }
2749
+ /**
2750
+ *
2751
+ * @param param0
2752
+ * @returns self
2753
+ */
2646
2754
  rotateXYZ(angleXYZ) {
2647
2755
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
2648
2756
  }
2757
+ /**
2758
+ *
2759
+ * @param radians
2760
+ * @param axis
2761
+ * @returns self
2762
+ */
2649
2763
  rotateAxis(radians, axis) {
2650
2764
  rotate(this, this, radians, axis);
2651
2765
  return this.check();
2652
2766
  }
2767
+ /**
2768
+ *
2769
+ * @param factor
2770
+ * @returns self
2771
+ */
2653
2772
  scale(factor) {
2654
2773
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
2655
2774
  return this.check();
2656
2775
  }
2776
+ /**
2777
+ *
2778
+ * @param vec
2779
+ * @returns self
2780
+ */
2657
2781
  translate(vector) {
2658
2782
  translate(this, this, vector);
2659
2783
  return this.check();
2660
2784
  }
2785
+ // Transforms
2786
+ /**
2787
+ * Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
2788
+ * @param vector
2789
+ * @param result
2790
+ * @returns self
2791
+ */
2661
2792
  transform(vector, result) {
2662
2793
  if (vector.length === 4) {
2663
2794
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -2666,10 +2797,14 @@ var __exports__ = (() => {
2666
2797
  }
2667
2798
  return this.transformAsPoint(vector, result);
2668
2799
  }
2800
+ /**
2801
+ * Transforms any 2 or 3 element array as point (w implicitly 1)
2802
+ * @param vector
2803
+ * @param result
2804
+ * @returns self
2805
+ */
2669
2806
  transformAsPoint(vector, result) {
2670
- const {
2671
- length: length4
2672
- } = vector;
2807
+ const { length: length4 } = vector;
2673
2808
  let out;
2674
2809
  switch (length4) {
2675
2810
  case 2:
@@ -2684,6 +2819,12 @@ var __exports__ = (() => {
2684
2819
  checkVector(out, vector.length);
2685
2820
  return out;
2686
2821
  }
2822
+ /**
2823
+ * Transforms any 2 or 3 element array as vector (w implicitly 0)
2824
+ * @param vector
2825
+ * @param result
2826
+ * @returns self
2827
+ */
2687
2828
  transformAsVector(vector, result) {
2688
2829
  let out;
2689
2830
  switch (vector.length) {
@@ -2699,15 +2840,19 @@ var __exports__ = (() => {
2699
2840
  checkVector(out, vector.length);
2700
2841
  return out;
2701
2842
  }
2843
+ /** @deprecated */
2702
2844
  transformPoint(vector, result) {
2703
2845
  return this.transformAsPoint(vector, result);
2704
2846
  }
2847
+ /** @deprecated */
2705
2848
  transformVector(vector, result) {
2706
2849
  return this.transformAsPoint(vector, result);
2707
2850
  }
2851
+ /** @deprecated */
2708
2852
  transformDirection(vector, result) {
2709
2853
  return this.transformAsVector(vector, result);
2710
2854
  }
2855
+ // three.js math API compatibility
2711
2856
  makeRotationX(radians) {
2712
2857
  return this.identity().rotateX(radians);
2713
2858
  }
@@ -3034,6 +3179,13 @@ var __exports__ = (() => {
3034
3179
  this[3] = object.w;
3035
3180
  return this.check();
3036
3181
  }
3182
+ /**
3183
+ * Creates a quaternion from the given 3x3 rotation matrix.
3184
+ * NOTE: The resultant quaternion is not normalized, so you should
3185
+ * be sure to renormalize the quaternion yourself where necessary.
3186
+ * @param m
3187
+ * @returns
3188
+ */
3037
3189
  fromMatrix3(m) {
3038
3190
  fromMat3(this, m);
3039
3191
  return this.check();
@@ -3042,13 +3194,21 @@ var __exports__ = (() => {
3042
3194
  setAxisAngle(this, axis, rad);
3043
3195
  return this.check();
3044
3196
  }
3197
+ /** Set a quat to the identity quaternion */
3045
3198
  identity() {
3046
3199
  identity2(this);
3047
3200
  return this.check();
3048
3201
  }
3202
+ // Set the components of a quat to the given values
3203
+ // set(i, j, k, l) {
3204
+ // quat_set(this, i, j, k, l);
3205
+ // return this.check();
3206
+ // }
3207
+ // Sets a quat from the given angle and rotation axis, then returns it.
3049
3208
  setAxisAngle(axis, rad) {
3050
3209
  return this.fromAxisRotation(axis, rad);
3051
3210
  }
3211
+ // Getters/setters
3052
3212
  get ELEMENTS() {
3053
3213
  return 4;
3054
3214
  }
@@ -3076,35 +3236,72 @@ var __exports__ = (() => {
3076
3236
  set w(value) {
3077
3237
  this[3] = checkNumber(value);
3078
3238
  }
3239
+ // Calculates the length of a quat
3079
3240
  len() {
3080
3241
  return length3(this);
3081
3242
  }
3243
+ // Calculates the squared length of a quat
3082
3244
  lengthSquared() {
3083
3245
  return squaredLength2(this);
3084
3246
  }
3247
+ // Calculates the dot product of two quat's
3248
+ // @return {Number}
3085
3249
  dot(a) {
3086
3250
  return dot3(this, a);
3087
3251
  }
3252
+ // Gets the rotation axis and angle for a given quaternion.
3253
+ // If a quaternion is created with setAxisAngle, this method will
3254
+ // return the same values as providied in the original parameter
3255
+ // list OR functionally equivalent values.
3256
+ // Example: The quaternion formed by axis [0, 0, 1] and angle -90
3257
+ // is the same as the quaternion formed by [0, 0, 1] and 270.
3258
+ // This method favors the latter.
3259
+ // @return {{[x,y,z], Number}}
3260
+ // getAxisAngle() {
3261
+ // const axis = [];
3262
+ // // const angle = quat_getAxisAngle(axis, this);
3263
+ // return {axis, angle};
3264
+ // }
3265
+ // MODIFIERS
3266
+ // Sets a quaternion to represent the shortest rotation from one vector
3267
+ // to another. Both vectors are assumed to be unit length.
3088
3268
  rotationTo(vectorA, vectorB) {
3089
3269
  rotationTo(this, vectorA, vectorB);
3090
3270
  return this.check();
3091
3271
  }
3272
+ // Sets the specified quaternion with values corresponding to the given axes.
3273
+ // Each axis is a vec3 and is expected to be unit length and perpendicular
3274
+ // to all other specified axes.
3275
+ // setAxes() {
3276
+ // Number
3277
+ // }
3278
+ // Performs a spherical linear interpolation with two control points
3279
+ // sqlerp() {
3280
+ // Number;
3281
+ // }
3282
+ // Adds two quat's
3092
3283
  add(a) {
3093
3284
  add2(this, this, a);
3094
3285
  return this.check();
3095
3286
  }
3287
+ // Calculates the W component of a quat from the X, Y, and Z components.
3288
+ // Any existing W component will be ignored.
3096
3289
  calculateW() {
3097
3290
  calculateW(this, this);
3098
3291
  return this.check();
3099
3292
  }
3293
+ // Calculates the conjugate of a quat If the quaternion is normalized,
3294
+ // this function is faster than quat_invert and produces the same result.
3100
3295
  conjugate() {
3101
3296
  conjugate(this, this);
3102
3297
  return this.check();
3103
3298
  }
3299
+ // Calculates the inverse of a quat
3104
3300
  invert() {
3105
3301
  invert2(this, this);
3106
3302
  return this.check();
3107
3303
  }
3304
+ // Performs a linear interpolation between two quat's
3108
3305
  lerp(a, b, t) {
3109
3306
  if (t === void 0) {
3110
3307
  return this.lerp(this, a, b);
@@ -3112,6 +3309,7 @@ var __exports__ = (() => {
3112
3309
  lerp2(this, a, b, t);
3113
3310
  return this.check();
3114
3311
  }
3312
+ // Multiplies two quat's
3115
3313
  multiplyRight(a) {
3116
3314
  multiply2(this, this, a);
3117
3315
  return this.check();
@@ -3120,6 +3318,7 @@ var __exports__ = (() => {
3120
3318
  multiply2(this, a, this);
3121
3319
  return this.check();
3122
3320
  }
3321
+ // Normalize a quat
3123
3322
  normalize() {
3124
3323
  const length4 = this.len();
3125
3324
  const l = length4 > 0 ? 1 / length4 : 0;
@@ -3132,22 +3331,27 @@ var __exports__ = (() => {
3132
3331
  }
3133
3332
  return this.check();
3134
3333
  }
3334
+ // Rotates a quaternion by the given angle about the X axis
3135
3335
  rotateX(rad) {
3136
3336
  rotateX2(this, this, rad);
3137
3337
  return this.check();
3138
3338
  }
3339
+ // Rotates a quaternion by the given angle about the Y axis
3139
3340
  rotateY(rad) {
3140
3341
  rotateY2(this, this, rad);
3141
3342
  return this.check();
3142
3343
  }
3344
+ // Rotates a quaternion by the given angle about the Z axis
3143
3345
  rotateZ(rad) {
3144
3346
  rotateZ2(this, this, rad);
3145
3347
  return this.check();
3146
3348
  }
3349
+ // Scales a quat by a scalar number
3147
3350
  scale(b) {
3148
3351
  scale3(this, this, b);
3149
3352
  return this.check();
3150
3353
  }
3354
+ // Performs a spherical linear interpolation between two quat
3151
3355
  slerp(arg0, arg1, arg2) {
3152
3356
  let start;
3153
3357
  let target;
@@ -3177,6 +3381,7 @@ var __exports__ = (() => {
3177
3381
  transformQuat2(result, vector, this);
3178
3382
  return checkVector(result, 4);
3179
3383
  }
3384
+ // THREE.js Math API compatibility
3180
3385
  lengthSq() {
3181
3386
  return this.lengthSquared();
3182
3387
  }
@@ -3370,12 +3575,10 @@ var __exports__ = (() => {
3370
3575
  // src/gltf/create-gltf-model.ts
3371
3576
  var import_core4 = __toESM(require_core(), 1);
3372
3577
 
3373
- // ../shadertools/src/lib/glsl-utils/highlight.ts
3374
- var glsl = (x) => `${x}`;
3375
-
3376
3578
  // ../shadertools/src/modules-webgl1/lighting/lights/lights-glsl.ts
3377
- var lightingShader = glsl`\
3378
- #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3579
+ var lightingShader = (
3580
+ /* glsl */
3581
+ `#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
3379
3582
 
3380
3583
  struct AmbientLight {
3381
3584
  vec3 color;
@@ -3409,7 +3612,8 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
3409
3612
  }
3410
3613
 
3411
3614
  #endif
3412
- `;
3615
+ `
3616
+ );
3413
3617
 
3414
3618
  // ../shadertools/src/modules-webgl1/lighting/lights/lights.ts
3415
3619
  var INITIAL_MODULE_OPTIONS = {
@@ -3493,8 +3697,9 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
3493
3697
  };
3494
3698
 
3495
3699
  // ../shadertools/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts
3496
- var vs = glsl`\
3497
- uniform mat4 u_MVPMatrix;
3700
+ var vs = (
3701
+ /* glsl */
3702
+ `uniform mat4 u_MVPMatrix;
3498
3703
  uniform mat4 u_ModelMatrix;
3499
3704
  uniform mat4 u_NormalMatrix;
3500
3705
 
@@ -3531,11 +3736,13 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
3531
3736
  pbr_vUV = vec2(0.,0.);
3532
3737
  #endif
3533
3738
  }
3534
- `;
3739
+ `
3740
+ );
3535
3741
 
3536
3742
  // ../shadertools/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
3537
- var fs = glsl`\
3538
- precision highp float;
3743
+ var fs = (
3744
+ /* glsl */
3745
+ `precision highp float;
3539
3746
 
3540
3747
  uniform bool pbr_uUnlit;
3541
3748
 
@@ -3916,7 +4123,8 @@ vec4 pbr_filterColor(vec4 colorUnused)
3916
4123
 
3917
4124
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
3918
4125
  }
3919
- `;
4126
+ `
4127
+ );
3920
4128
 
3921
4129
  // ../shadertools/src/modules-webgl1/lighting/pbr/pbr.ts
3922
4130
  var pbr = {
@@ -3981,8 +4189,9 @@ layout(0) positions: vec4; // in vec4 POSITION;
3981
4189
  }
3982
4190
  `
3983
4191
  );
3984
- var vs2 = import_core4.glsl`\
3985
- #version 300 es
4192
+ var vs2 = (
4193
+ /* glsl */
4194
+ `#version 300 es
3986
4195
 
3987
4196
  // in vec4 POSITION;
3988
4197
  in vec4 positions;
@@ -4021,16 +4230,19 @@ layout(0) positions: vec4; // in vec4 POSITION;
4021
4230
  pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
4022
4231
  gl_Position = u_MVPMatrix * positions;
4023
4232
  }
4024
- `;
4025
- var fs2 = import_core4.glsl`\
4026
- #version 300 es
4233
+ `
4234
+ );
4235
+ var fs2 = (
4236
+ /* glsl */
4237
+ `#version 300 es
4027
4238
  out vec4 fragmentColor;
4028
4239
 
4029
4240
  void main(void) {
4030
4241
  vec3 pos = pbr_vPosition;
4031
4242
  fragmentColor = pbr_filterColor(vec4(1.0));
4032
4243
  }
4033
- `;
4244
+ `
4245
+ );
4034
4246
  function createGLTFModel(device, options) {
4035
4247
  const { id, geometry, material, vertexCount, materialOptions, modelOptions } = options;
4036
4248
  const parsedMaterial = parsePBRMaterial(device, material, geometry.attributes, materialOptions);