bg2e-js 2.2.2 → 2.2.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/bg2e-js.js CHANGED
@@ -1,4 +1,4 @@
1
- var lt = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.Y = 2] = "Y", t[t.Z = 3] = "Z", t[t.W = 4] = "W", t))(lt || {});
1
+ var ct = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.Y = 2] = "Y", t[t.Z = 3] = "Z", t[t.W = 4] = "W", t))(ct || {});
2
2
  ((t) => {
3
3
  function e(r) {
4
4
  switch (r) {
@@ -17,11 +17,11 @@ var lt = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.
17
17
  }
18
18
  }
19
19
  t.name = e;
20
- })(lt || (lt = {}));
20
+ })(ct || (ct = {}));
21
21
  const $r = 3.141592653589793, ei = 0.01745329251994, ti = 57.29577951308233, qn = 1.5707963267948966, _n = 0.785398163397448, $n = 0.392699081698724, es = 6.283185307179586, gt = 1e-7, Le = Float32Array, ts = Float64Array, rs = 3402823e32, Ge = (t, e) => t.length >= e;
22
22
  let Ft = Date.now();
23
- const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, fe = (t) => t > -gt && t < gt ? 0 : t, b = (t) => fe(t) === 0, E = (t, e) => Math.abs(t - e) < gt, We = (t) => Math.fround(fe(t * ei)), ri = (t) => Math.fround(fe(t * ti)), ns = (t) => Math.fround(fe(Math.sin(t))), ss = (t) => Math.fround(fe(Math.cos(t))), ii = (t) => Math.fround(fe(Math.tan(t))), os = (t) => Math.fround(fe(1 / ii(t))), as = (t) => Math.fround(fe(Math.atan(t))), hs = (t, e) => Math.fround(fe(Math.atan2(t, e))), As = () => Math.random(), fs = () => (Ft = (Ft * 9301 + 49297) % 233280, 0 + Ft / 233280 * 1), cs = (t, e) => Math.fround(Math.max(t, e)), ls = (t, e) => Math.fround(Math.min(t, e)), gs = (t) => Math.fround(Math.abs(t)), us = (t) => Math.fround(Math.sqrt(t)), J = (t, e, r) => (r = r > 1 ? 1 : r, Math.fround((1 - r) * t + r * e)), ws = (t) => Math.fround(t * t), Z = (t, e, r) => Math.fround(Math.max(e, Math.min(t, r))), ds = {
24
- Axis: lt,
23
+ const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, fe = (t) => t > -gt && t < gt ? 0 : t, b = (t) => fe(t) === 0, E = (t, e) => Math.abs(t - e) < gt, We = (t) => Math.fround(fe(t * ei)), ri = (t) => Math.fround(fe(t * ti)), ns = (t) => Math.fround(fe(Math.sin(t))), ss = (t) => Math.fround(fe(Math.cos(t))), ii = (t) => Math.fround(fe(Math.tan(t))), os = (t) => Math.fround(fe(1 / ii(t))), as = (t) => Math.fround(fe(Math.atan(t))), hs = (t, e) => Math.fround(fe(Math.atan2(t, e))), As = () => Math.random(), fs = () => (Ft = (Ft * 9301 + 49297) % 233280, 0 + Ft / 233280 * 1), ls = (t, e) => Math.fround(Math.max(t, e)), cs = (t, e) => Math.fround(Math.min(t, e)), gs = (t) => Math.fround(Math.abs(t)), us = (t) => Math.fround(Math.sqrt(t)), J = (t, e, r) => (r = r > 1 ? 1 : r, Math.fround((1 - r) * t + r * e)), ds = (t) => Math.fround(t * t), Z = (t, e, r) => Math.fround(Math.max(e, Math.min(t, r))), ws = {
24
+ Axis: ct,
25
25
  PI: $r,
26
26
  DEG_TO_RAD: ei,
27
27
  RAD_TO_DEG: ti,
@@ -47,13 +47,13 @@ const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, fe =
47
47
  atan2: hs,
48
48
  random: As,
49
49
  seededRandom: fs,
50
- max: cs,
51
- min: ls,
50
+ max: ls,
51
+ min: cs,
52
52
  abs: gs,
53
53
  sqrt: us,
54
54
  lerp: J,
55
- square: ws
56
- }, le = (t, e) => {
55
+ square: ds
56
+ }, ce = (t, e) => {
57
57
  if (t.length != e.length) throw new Error("Invalid vector length in operation");
58
58
  };
59
59
  class h extends Le {
@@ -94,7 +94,7 @@ class h extends Le {
94
94
  return this;
95
95
  }
96
96
  assign(e) {
97
- switch (le(this, e), this.length) {
97
+ switch (ce(this, e), this.length) {
98
98
  case 4:
99
99
  this[3] = e[3];
100
100
  case 3:
@@ -350,10 +350,10 @@ class h extends Le {
350
350
  return Array.from(this);
351
351
  }
352
352
  static CheckEqualLength(e, r) {
353
- le(e, r);
353
+ ce(e, r);
354
354
  }
355
355
  static Max(e, r) {
356
- switch (le(e, r), e.length) {
356
+ switch (ce(e, r), e.length) {
357
357
  case 2:
358
358
  return new h([
359
359
  e[0] > r[0] ? e[0] : r[0],
@@ -377,7 +377,7 @@ class h extends Le {
377
377
  }
378
378
  }
379
379
  static Min(e, r) {
380
- switch (le(e, r), e.length) {
380
+ switch (ce(e, r), e.length) {
381
381
  case 2:
382
382
  return new h([
383
383
  e[0] < r[0] ? e[0] : r[0],
@@ -401,7 +401,7 @@ class h extends Le {
401
401
  }
402
402
  }
403
403
  static Add(e, r) {
404
- switch (le(e, r), e.length) {
404
+ switch (ce(e, r), e.length) {
405
405
  case 2:
406
406
  return new h([
407
407
  e[0] + r[0],
@@ -425,7 +425,7 @@ class h extends Le {
425
425
  }
426
426
  }
427
427
  static Sub(e, r) {
428
- switch (le(e, r), e.length) {
428
+ switch (ce(e, r), e.length) {
429
429
  case 2:
430
430
  return new h([
431
431
  e[0] - r[0],
@@ -461,10 +461,10 @@ class h extends Le {
461
461
  }
462
462
  }
463
463
  static Distance(e, r) {
464
- return le(e, r), h.Magnitude(h.Sub(e, r));
464
+ return ce(e, r), h.Magnitude(h.Sub(e, r));
465
465
  }
466
466
  static Dot(e, r) {
467
- switch (le(e, r), e.length) {
467
+ switch (ce(e, r), e.length) {
468
468
  case 2:
469
469
  return e[0] * r[0] + e[1] * r[1];
470
470
  case 3:
@@ -476,7 +476,7 @@ class h extends Le {
476
476
  }
477
477
  }
478
478
  static Cross(e, r) {
479
- switch (le(e, r), e.length) {
479
+ switch (ce(e, r), e.length) {
480
480
  case 2:
481
481
  return e[0] * r[1] - e[1] * r[0];
482
482
  case 3:
@@ -758,7 +758,7 @@ class te extends Le {
758
758
  return new te(r).mult(e);
759
759
  }
760
760
  }
761
- class d extends Le {
761
+ class w extends Le {
762
762
  constructor(...e) {
763
763
  const r = [
764
764
  0,
@@ -802,12 +802,12 @@ class d extends Le {
802
802
  return this.frustum(-o, o, -s, s, i, n), this;
803
803
  }
804
804
  frustum(e, r, i, n, s, o) {
805
- let a = r - e, f = n - i, l = o - s;
806
- return this.setRow(0, new h(s * 2 / a, 0, 0, 0)), this.setRow(1, new h(0, s * 2 / f, 0, 0)), this.setRow(2, new h((r + e) / a, (n + i) / f, -(o + s) / l, -1)), this.setRow(3, new h(0, 0, -(o * s * 2) / l, 0)), this;
805
+ let a = r - e, f = n - i, c = o - s;
806
+ return this.setRow(0, new h(s * 2 / a, 0, 0, 0)), this.setRow(1, new h(0, s * 2 / f, 0, 0)), this.setRow(2, new h((r + e) / a, (n + i) / f, -(o + s) / c, -1)), this.setRow(3, new h(0, 0, -(o * s * 2) / c, 0)), this;
807
807
  }
808
808
  ortho(e, r, i, n, s, o) {
809
- let a = r - e, f = n - i, l = o - s;
810
- return this[0] = 2 / a, this[1] = 0, this[2] = 0, this[3] = 0, this[4] = 0, this[5] = 2 / f, this[6] = 0, this[7] = 0, this[8] = 0, this[9] = 0, this[10] = -2 / l, this[11] = 0, this[12] = -(e + r) / a, this[13] = -(n + i) / f, this[14] = -(o + s) / l, this[15] = 1, this;
809
+ let a = r - e, f = n - i, c = o - s;
810
+ return this[0] = 2 / a, this[1] = 0, this[2] = 0, this[3] = 0, this[4] = 0, this[5] = 2 / f, this[6] = 0, this[7] = 0, this[8] = 0, this[9] = 0, this[10] = -2 / c, this[11] = 0, this[12] = -(e + r) / a, this[13] = -(n + i) / f, this[14] = -(o + s) / c, this[15] = 1, this;
811
811
  }
812
812
  lookAt(e, r, i) {
813
813
  this.identity();
@@ -927,22 +927,22 @@ class d extends Le {
927
927
  );
928
928
  }
929
929
  get forwardVector() {
930
- return d.TransformDirection(this, new h(0, 0, 1));
930
+ return w.TransformDirection(this, new h(0, 0, 1));
931
931
  }
932
932
  get rightVector() {
933
- return d.TransformDirection(this, new h(1, 0, 0));
933
+ return w.TransformDirection(this, new h(1, 0, 0));
934
934
  }
935
935
  get upVector() {
936
- return d.TransformDirection(this, new h(0, 1, 0));
936
+ return w.TransformDirection(this, new h(0, 1, 0));
937
937
  }
938
938
  get backwardVector() {
939
- return d.TransformDirection(this, new h(0, 0, -1));
939
+ return w.TransformDirection(this, new h(0, 0, -1));
940
940
  }
941
941
  get leftVector() {
942
- return d.TransformDirection(this, new h(-1, 0, 0));
942
+ return w.TransformDirection(this, new h(-1, 0, 0));
943
943
  }
944
944
  get downVector() {
945
- return d.TransformDirection(this, new h(0, -1, 0));
945
+ return w.TransformDirection(this, new h(0, -1, 0));
946
946
  }
947
947
  row(e) {
948
948
  return new h(
@@ -984,13 +984,13 @@ class d extends Le {
984
984
  return e.length == 9 ? (this[0] = e[0], this[1] = e[1], this[2] = e[2], this[3] = 0, this[4] = e[3], this[5] = e[4], this[6] = e[5], this[7] = 0, this[8] = e[6], this[9] = e[7], this[10] = e[8], this[11] = 0, this[12] = 0, this[13] = 0, this[14] = 0, this[15] = 1) : e.length == 16 && (this[0] = e[0], this[1] = e[1], this[2] = e[2], this[3] = e[3], this[4] = e[4], this[5] = e[5], this[6] = e[6], this[7] = e[7], this[8] = e[8], this[9] = e[9], this[10] = e[10], this[11] = e[11], this[12] = e[12], this[13] = e[13], this[14] = e[14], this[15] = e[15]), this;
985
985
  }
986
986
  translate(e, r, i) {
987
- return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), this.mult(d.MakeTranslation(e, r, i)), this;
987
+ return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), this.mult(w.MakeTranslation(e, r, i)), this;
988
988
  }
989
989
  rotate(e, r, i, n) {
990
- return Ge(r, 3) && (i = r[1], n = r[2], r = r[0]), this.mult(d.MakeRotation(e, r, i ?? 0, n ?? 0)), this;
990
+ return Ge(r, 3) && (i = r[1], n = r[2], r = r[0]), this.mult(w.MakeRotation(e, r, i ?? 0, n ?? 0)), this;
991
991
  }
992
992
  scale(e, r, i) {
993
- return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), this.mult(d.MakeScale(e, r, i)), this;
993
+ return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), this.mult(w.MakeScale(e, r, i)), this;
994
994
  }
995
995
  toString() {
996
996
  return `[ ${this[0]}, ${this[1]}, ${this[2]}, ${this[3]}
@@ -1017,8 +1017,8 @@ class d extends Le {
1017
1017
  mult(e) {
1018
1018
  if (typeof e == "number")
1019
1019
  return this[0] *= e, this[1] *= e, this[2] *= e, this[3] *= e, this[4] *= e, this[5] *= e, this[6] *= e, this[7] *= e, this[8] *= e, this[9] *= e, this[10] *= e, this[11] *= e, this[12] *= e, this[13] *= e, this[14] *= e, this[15] *= e, this;
1020
- const r = this.row(0), i = this.row(1), n = this.row(2), s = this.row(3), o = e.col(0), a = e.col(1), f = e.col(2), l = e.col(3);
1021
- return this[0] = h.Dot(r, o), this[1] = h.Dot(r, a), this[2] = h.Dot(r, f), this[3] = h.Dot(r, l), this[4] = h.Dot(i, o), this[5] = h.Dot(i, a), this[6] = h.Dot(i, f), this[7] = h.Dot(i, l), this[8] = h.Dot(n, o), this[9] = h.Dot(n, a), this[10] = h.Dot(n, f), this[11] = h.Dot(n, l), this[12] = h.Dot(s, o), this[13] = h.Dot(s, a), this[14] = h.Dot(s, f), this[15] = h.Dot(s, l), this;
1020
+ const r = this.row(0), i = this.row(1), n = this.row(2), s = this.row(3), o = e.col(0), a = e.col(1), f = e.col(2), c = e.col(3);
1021
+ return this[0] = h.Dot(r, o), this[1] = h.Dot(r, a), this[2] = h.Dot(r, f), this[3] = h.Dot(r, c), this[4] = h.Dot(i, o), this[5] = h.Dot(i, a), this[6] = h.Dot(i, f), this[7] = h.Dot(i, c), this[8] = h.Dot(n, o), this[9] = h.Dot(n, a), this[10] = h.Dot(n, f), this[11] = h.Dot(n, c), this[12] = h.Dot(s, o), this[13] = h.Dot(s, a), this[14] = h.Dot(s, f), this[15] = h.Dot(s, c), this;
1022
1022
  }
1023
1023
  multVector(e) {
1024
1024
  if (e.length < 3)
@@ -1032,9 +1032,9 @@ class d extends Le {
1032
1032
  );
1033
1033
  }
1034
1034
  invert() {
1035
- const e = this[0], r = this[1], i = this[2], n = this[3], s = this[4], o = this[5], a = this[6], f = this[7], l = this[8], w = this[9], P = this[10], C = this[11], v = this[12], D = this[13], B = this[14], N = this[15], K = e * o - r * s, G = e * a - i * s, H = e * f - n * s, L = r * a - i * o, c = r * f - n * o, g = i * f - n * a, u = l * D - w * v, A = l * B - P * v, m = l * N - C * v, z = w * B - P * D, I = w * N - C * D, W = P * N - C * B;
1036
- let O = K * W - G * I + H * z + L * m - c * A + g * u;
1037
- return O ? (O = 1 / O, this[0] = (o * W - a * I + f * z) * O, this[1] = (i * I - r * W - n * z) * O, this[2] = (D * g - B * c + N * L) * O, this[3] = (P * c - w * g - C * L) * O, this[4] = (a * m - s * W - f * A) * O, this[5] = (e * W - i * m + n * A) * O, this[6] = (B * H - v * g - N * G) * O, this[7] = (l * g - P * H + C * G) * O, this[8] = (s * I - o * m + f * u) * O, this[9] = (r * m - e * I - n * u) * O, this[10] = (v * c - D * H + N * K) * O, this[11] = (w * H - l * c - C * K) * O, this[12] = (o * A - s * z - a * u) * O, this[13] = (e * z - r * A + i * u) * O, this[14] = (D * G - v * L - B * K) * O, this[15] = (l * L - w * G + P * K) * O) : this.zero(), this;
1035
+ const e = this[0], r = this[1], i = this[2], n = this[3], s = this[4], o = this[5], a = this[6], f = this[7], c = this[8], d = this[9], P = this[10], C = this[11], v = this[12], D = this[13], B = this[14], N = this[15], K = e * o - r * s, G = e * a - i * s, H = e * f - n * s, L = r * a - i * o, l = r * f - n * o, g = i * f - n * a, u = c * D - d * v, A = c * B - P * v, m = c * N - C * v, z = d * B - P * D, I = d * N - C * D, W = P * N - C * B;
1036
+ let O = K * W - G * I + H * z + L * m - l * A + g * u;
1037
+ return O ? (O = 1 / O, this[0] = (o * W - a * I + f * z) * O, this[1] = (i * I - r * W - n * z) * O, this[2] = (D * g - B * l + N * L) * O, this[3] = (P * l - d * g - C * L) * O, this[4] = (a * m - s * W - f * A) * O, this[5] = (e * W - i * m + n * A) * O, this[6] = (B * H - v * g - N * G) * O, this[7] = (c * g - P * H + C * G) * O, this[8] = (s * I - o * m + f * u) * O, this[9] = (r * m - e * I - n * u) * O, this[10] = (v * l - D * H + N * K) * O, this[11] = (d * H - c * l - C * K) * O, this[12] = (o * A - s * z - a * u) * O, this[13] = (e * z - r * A + i * u) * O, this[14] = (D * G - v * L - B * K) * O, this[15] = (c * L - d * G + P * K) * O) : this.zero(), this;
1038
1038
  }
1039
1039
  traspose() {
1040
1040
  const e = new h(this[0], this[4], this[8], this[12]), r = new h(this[1], this[5], this[9], this[13]), i = new h(this[2], this[6], this[10], this[14]), n = new h(this[3], this[7], this[11], this[15]);
@@ -1042,17 +1042,17 @@ class d extends Le {
1042
1042
  }
1043
1043
  ///////// Factory methods
1044
1044
  static MakeIdentity() {
1045
- return new d().identity();
1045
+ return new w().identity();
1046
1046
  }
1047
1047
  static MakeZero() {
1048
- return new d().zero();
1048
+ return new w().zero();
1049
1049
  }
1050
1050
  static MakeWithQuaternion(e) {
1051
- const r = d.MakeIdentity();
1051
+ const r = w.MakeIdentity();
1052
1052
  return r.setRotation(te.MakeWithQuaternion(e)), r;
1053
1053
  }
1054
1054
  static MakeTranslation(e, r, i) {
1055
- return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), new d(
1055
+ return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), new w(
1056
1056
  1,
1057
1057
  0,
1058
1058
  0,
@@ -1075,7 +1075,7 @@ class d extends Le {
1075
1075
  const s = new h(r, i, n);
1076
1076
  s.normalize();
1077
1077
  var o = Math.cos(e), a = 1 - o, f = Math.sin(e);
1078
- return new d(
1078
+ return new w(
1079
1079
  s.x * s.x * a + o,
1080
1080
  s.x * s.y * a + s.z * f,
1081
1081
  s.x * s.z * a - s.y * f,
@@ -1095,11 +1095,11 @@ class d extends Le {
1095
1095
  );
1096
1096
  }
1097
1097
  static MakeRotationWithDirection(e, r) {
1098
- const i = d.MakeIdentity();
1098
+ const i = w.MakeIdentity();
1099
1099
  return i.setRotation(te.MakeRotationWithDirection(e, r)), i;
1100
1100
  }
1101
1101
  static MakeScale(e, r, i) {
1102
- return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), new d(
1102
+ return Ge(e, 3) && (r = e[1], i = e[2], e = e[0]), new w(
1103
1103
  e,
1104
1104
  0,
1105
1105
  0,
@@ -1119,37 +1119,37 @@ class d extends Le {
1119
1119
  );
1120
1120
  }
1121
1121
  static MakePerspective(e, r, i, n) {
1122
- return new d().perspective(e, r, i, n);
1122
+ return new w().perspective(e, r, i, n);
1123
1123
  }
1124
1124
  static MakeFrustum(e, r, i, n, s, o) {
1125
- return new d().frustum(e, r, i, n, s, o);
1125
+ return new w().frustum(e, r, i, n, s, o);
1126
1126
  }
1127
1127
  static MakeOrtho(e, r, i, n, s, o) {
1128
- return new d().ortho(e, r, i, n, s, o);
1128
+ return new w().ortho(e, r, i, n, s, o);
1129
1129
  }
1130
1130
  static MakeLookAt(e, r, i) {
1131
- return new d().lookAt(e, r, i);
1131
+ return new w().lookAt(e, r, i);
1132
1132
  }
1133
1133
  // Other static methods. This function multyplies two B x A matrices. It works opposite than the non-static mult() function:
1134
1134
  // A.mult(B) is the same as Mat4.Mult(B,A)
1135
1135
  static Mult(e, r) {
1136
- return new d(r).mult(e);
1136
+ return new w(r).mult(e);
1137
1137
  }
1138
1138
  static Unproject(e, r, i, n, s, o) {
1139
- let a = new d(s);
1139
+ let a = new w(s);
1140
1140
  a.mult(n), a.invert();
1141
1141
  const f = new h(
1142
1142
  (e - o.y) / o.width * 2 - 1,
1143
1143
  (r - o.x) / o.height * 2 - 1,
1144
1144
  i * 2 - 1,
1145
1145
  1
1146
- ), l = a.multVector(f);
1147
- return l.z == 0 ? l.setValue(0, 0, 0, 0) : l.setValue(
1148
- l.x / l.w,
1149
- l.y / l.w,
1150
- l.z / l.w,
1151
- l.w / l.w
1152
- ), l;
1146
+ ), c = a.multVector(f);
1147
+ return c.z == 0 ? c.setValue(0, 0, 0, 0) : c.setValue(
1148
+ c.x / c.w,
1149
+ c.y / c.w,
1150
+ c.z / c.w,
1151
+ c.w / c.w
1152
+ ), c;
1153
1153
  }
1154
1154
  static GetScale(e) {
1155
1155
  return new h(
@@ -1159,8 +1159,8 @@ class d extends Le {
1159
1159
  );
1160
1160
  }
1161
1161
  static GetRotation(e) {
1162
- const r = d.GetScale(e);
1163
- return new d(
1162
+ const r = w.GetScale(e);
1163
+ return new w(
1164
1164
  e[0] / r.x,
1165
1165
  e[1] / r.y,
1166
1166
  e[2] / r.z,
@@ -1183,17 +1183,17 @@ class d extends Le {
1183
1183
  return new h(e[12], e[13], e[14]);
1184
1184
  }
1185
1185
  static GetInverted(e) {
1186
- const r = new d(e);
1186
+ const r = new w(e);
1187
1187
  return r.invert(), r;
1188
1188
  }
1189
1189
  static GetNormalMatrix(e) {
1190
- return new d(e).invert().traspose().mat3;
1190
+ return new w(e).invert().traspose().mat3;
1191
1191
  }
1192
1192
  static Equals(e, r) {
1193
1193
  return e[0] == r[0] && e[1] == r[1] && e[2] == r[2] && e[3] == r[3] && e[4] == r[4] && e[5] == r[5] && e[6] == r[6] && e[7] == r[7] && e[8] == r[8] && e[9] == r[9] && e[10] == r[10] && e[11] == r[11] && e[12] == r[12] && e[13] == r[13] && e[14] == r[14] && e[15] == r[15];
1194
1194
  }
1195
1195
  static TransformDirection(e, r) {
1196
- const i = new h(r), n = new d(e);
1196
+ const i = new h(r), n = new w(e);
1197
1197
  return n.setRow(3, new h(0, 0, 0, 1)), i.assign(n.multVector(i).xyz), i.normalize(), i;
1198
1198
  }
1199
1199
  static IsNan(e) {
@@ -1238,7 +1238,7 @@ class vs extends h {
1238
1238
  }
1239
1239
  class ni {
1240
1240
  constructor(e = null) {
1241
- if (e !== null && !(e instanceof d))
1241
+ if (e !== null && !(e instanceof w))
1242
1242
  throw Error("MatrixStrategy: invalid target object. Target object must be of type bg.math.Mat4");
1243
1243
  this._target = e;
1244
1244
  }
@@ -1253,51 +1253,51 @@ class ni {
1253
1253
  }
1254
1254
  }
1255
1255
  (function(t) {
1256
- function e(c) {
1257
- for (var g = "", u = "", A = 0, m = 0, z = 0, I = c.length; I > z; z++) {
1258
- var W = c.charCodeAt(z);
1259
- 128 > W ? m++ : (u = 2048 > W ? String.fromCharCode(W >> 6 | 192, 63 & W | 128) : String.fromCharCode(W >> 12 | 224, W >> 6 & 63 | 128, 63 & W | 128), m > A && (g += c.slice(A, m)), g += u, A = m = z + 1);
1256
+ function e(l) {
1257
+ for (var g = "", u = "", A = 0, m = 0, z = 0, I = l.length; I > z; z++) {
1258
+ var W = l.charCodeAt(z);
1259
+ 128 > W ? m++ : (u = 2048 > W ? String.fromCharCode(W >> 6 | 192, 63 & W | 128) : String.fromCharCode(W >> 12 | 224, W >> 6 & 63 | 128, 63 & W | 128), m > A && (g += l.slice(A, m)), g += u, A = m = z + 1);
1260
1260
  }
1261
- return m > A && (g += c.slice(A, I)), g;
1261
+ return m > A && (g += l.slice(A, I)), g;
1262
1262
  }
1263
- function r(c) {
1263
+ function r(l) {
1264
1264
  var g, u;
1265
- if (c += "", N = !1, K = G = c.length, G > 63) {
1266
- for (i(c.substring(0, 64)), o(P), N = !0, g = 128; G >= g; g += 64) i(c.substring(g - 64, g)), a(P);
1267
- c = c.substring(g - 64), G = c.length;
1265
+ if (l += "", N = !1, K = G = l.length, G > 63) {
1266
+ for (i(l.substring(0, 64)), o(P), N = !0, g = 128; G >= g; g += 64) i(l.substring(g - 64, g)), a(P);
1267
+ l = l.substring(g - 64), G = l.length;
1268
1268
  }
1269
- for (w[0] = w[1] = w[2] = w[3] = w[4] = w[5] = w[6] = w[7] = w[8] = w[9] = w[10] = w[11] = w[12] = w[13] = w[14] = w[15] = 0, g = 0; G > g; g++) u = 3 & g, u === 0 ? w[g >> 2] = c.charCodeAt(g) : w[g >> 2] |= c.charCodeAt(g) << D[u];
1270
- return w[g >> 2] |= C[3 & g], g > 55 ? (N ? a(w) : (o(w), N = !0), a([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, K << 3, 0])) : (w[14] = K << 3, void (N ? a(w) : o(w)));
1269
+ for (d[0] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = 0, g = 0; G > g; g++) u = 3 & g, u === 0 ? d[g >> 2] = l.charCodeAt(g) : d[g >> 2] |= l.charCodeAt(g) << D[u];
1270
+ return d[g >> 2] |= C[3 & g], g > 55 ? (N ? a(d) : (o(d), N = !0), a([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, K << 3, 0])) : (d[14] = K << 3, void (N ? a(d) : o(d)));
1271
1271
  }
1272
- function i(c) {
1272
+ function i(l) {
1273
1273
  for (var g = 16; g--; ) {
1274
1274
  var u = g << 2;
1275
- P[g] = c.charCodeAt(u) + (c.charCodeAt(u + 1) << 8) + (c.charCodeAt(u + 2) << 16) + (c.charCodeAt(u + 3) << 24);
1275
+ P[g] = l.charCodeAt(u) + (l.charCodeAt(u + 1) << 8) + (l.charCodeAt(u + 2) << 16) + (l.charCodeAt(u + 3) << 24);
1276
1276
  }
1277
1277
  }
1278
- function n(c, g, u) {
1279
- r(g ? c : e(c));
1278
+ function n(l, g, u) {
1279
+ r(g ? l : e(l));
1280
1280
  var A = B[0];
1281
- return l[1] = v[15 & A], l[0] = v[15 & (A >>= 4)], l[3] = v[15 & (A >>= 4)], l[2] = v[15 & (A >>= 4)], l[5] = v[15 & (A >>= 4)], l[4] = v[15 & (A >>= 4)], l[7] = v[15 & (A >>= 4)], l[6] = v[15 & (A >>= 4)], A = B[1], l[9] = v[15 & A], l[8] = v[15 & (A >>= 4)], l[11] = v[15 & (A >>= 4)], l[10] = v[15 & (A >>= 4)], l[13] = v[15 & (A >>= 4)], l[12] = v[15 & (A >>= 4)], l[15] = v[15 & (A >>= 4)], l[14] = v[15 & (A >>= 4)], A = B[2], l[17] = v[15 & A], l[16] = v[15 & (A >>= 4)], l[19] = v[15 & (A >>= 4)], l[18] = v[15 & (A >>= 4)], l[21] = v[15 & (A >>= 4)], l[20] = v[15 & (A >>= 4)], l[23] = v[15 & (A >>= 4)], l[22] = v[15 & (A >>= 4)], A = B[3], l[25] = v[15 & A], l[24] = v[15 & (A >>= 4)], l[27] = v[15 & (A >>= 4)], l[26] = v[15 & (A >>= 4)], l[29] = v[15 & (A >>= 4)], l[28] = v[15 & (A >>= 4)], l[31] = v[15 & (A >>= 4)], l[30] = v[15 & (A >>= 4)], u ? l : l.join("");
1281
+ return c[1] = v[15 & A], c[0] = v[15 & (A >>= 4)], c[3] = v[15 & (A >>= 4)], c[2] = v[15 & (A >>= 4)], c[5] = v[15 & (A >>= 4)], c[4] = v[15 & (A >>= 4)], c[7] = v[15 & (A >>= 4)], c[6] = v[15 & (A >>= 4)], A = B[1], c[9] = v[15 & A], c[8] = v[15 & (A >>= 4)], c[11] = v[15 & (A >>= 4)], c[10] = v[15 & (A >>= 4)], c[13] = v[15 & (A >>= 4)], c[12] = v[15 & (A >>= 4)], c[15] = v[15 & (A >>= 4)], c[14] = v[15 & (A >>= 4)], A = B[2], c[17] = v[15 & A], c[16] = v[15 & (A >>= 4)], c[19] = v[15 & (A >>= 4)], c[18] = v[15 & (A >>= 4)], c[21] = v[15 & (A >>= 4)], c[20] = v[15 & (A >>= 4)], c[23] = v[15 & (A >>= 4)], c[22] = v[15 & (A >>= 4)], A = B[3], c[25] = v[15 & A], c[24] = v[15 & (A >>= 4)], c[27] = v[15 & (A >>= 4)], c[26] = v[15 & (A >>= 4)], c[29] = v[15 & (A >>= 4)], c[28] = v[15 & (A >>= 4)], c[31] = v[15 & (A >>= 4)], c[30] = v[15 & (A >>= 4)], u ? c : c.join("");
1282
1282
  }
1283
- function s(c, g, u, A, m, z, I) {
1284
- return g += c + A + I, (g << m | g >>> z) + u << 0;
1283
+ function s(l, g, u, A, m, z, I) {
1284
+ return g += l + A + I, (g << m | g >>> z) + u << 0;
1285
1285
  }
1286
- function o(c) {
1287
- f(0, 0, 0, 0, c), B[0] = H[0] + 1732584193 << 0, B[1] = H[1] - 271733879 << 0, B[2] = H[2] - 1732584194 << 0, B[3] = H[3] + 271733878 << 0;
1286
+ function o(l) {
1287
+ f(0, 0, 0, 0, l), B[0] = H[0] + 1732584193 << 0, B[1] = H[1] - 271733879 << 0, B[2] = H[2] - 1732584194 << 0, B[3] = H[3] + 271733878 << 0;
1288
1288
  }
1289
- function a(c) {
1290
- f(B[0], B[1], B[2], B[3], c), B[0] = H[0] + B[0] << 0, B[1] = H[1] + B[1] << 0, B[2] = H[2] + B[2] << 0, B[3] = H[3] + B[3] << 0;
1289
+ function a(l) {
1290
+ f(B[0], B[1], B[2], B[3], l), B[0] = H[0] + B[0] << 0, B[1] = H[1] + B[1] << 0, B[2] = H[2] + B[2] << 0, B[3] = H[3] + B[3] << 0;
1291
1291
  }
1292
- function f(c, g, u, A, m) {
1292
+ function f(l, g, u, A, m) {
1293
1293
  var z, I;
1294
- N ? (c = s((u ^ A) & g ^ A, c, g, m[0], 7, 25, -680876936), A = s((g ^ u) & c ^ u, A, c, m[1], 12, 20, -389564586), u = s((c ^ g) & A ^ g, u, A, m[2], 17, 15, 606105819), g = s((A ^ c) & u ^ c, g, u, m[3], 22, 10, -1044525330)) : (c = m[0] - 680876937, c = (c << 7 | c >>> 25) - 271733879 << 0, A = m[1] - 117830708 + (2004318071 & c ^ -1732584194), A = (A << 12 | A >>> 20) + c << 0, u = m[2] - 1126478375 + ((-271733879 ^ c) & A ^ -271733879), u = (u << 17 | u >>> 15) + A << 0, g = m[3] - 1316259209 + ((A ^ c) & u ^ c), g = (g << 22 | g >>> 10) + u << 0), c = s((u ^ A) & g ^ A, c, g, m[4], 7, 25, -176418897), A = s((g ^ u) & c ^ u, A, c, m[5], 12, 20, 1200080426), u = s((c ^ g) & A ^ g, u, A, m[6], 17, 15, -1473231341), g = s((A ^ c) & u ^ c, g, u, m[7], 22, 10, -45705983), c = s((u ^ A) & g ^ A, c, g, m[8], 7, 25, 1770035416), A = s((g ^ u) & c ^ u, A, c, m[9], 12, 20, -1958414417), u = s((c ^ g) & A ^ g, u, A, m[10], 17, 15, -42063), g = s((A ^ c) & u ^ c, g, u, m[11], 22, 10, -1990404162), c = s((u ^ A) & g ^ A, c, g, m[12], 7, 25, 1804603682), A = s((g ^ u) & c ^ u, A, c, m[13], 12, 20, -40341101), u = s((c ^ g) & A ^ g, u, A, m[14], 17, 15, -1502002290), g = s((A ^ c) & u ^ c, g, u, m[15], 22, 10, 1236535329), c = s((g ^ u) & A ^ u, c, g, m[1], 5, 27, -165796510), A = s((c ^ g) & u ^ g, A, c, m[6], 9, 23, -1069501632), u = s((A ^ c) & g ^ c, u, A, m[11], 14, 18, 643717713), g = s((u ^ A) & c ^ A, g, u, m[0], 20, 12, -373897302), c = s((g ^ u) & A ^ u, c, g, m[5], 5, 27, -701558691), A = s((c ^ g) & u ^ g, A, c, m[10], 9, 23, 38016083), u = s((A ^ c) & g ^ c, u, A, m[15], 14, 18, -660478335), g = s((u ^ A) & c ^ A, g, u, m[4], 20, 12, -405537848), c = s((g ^ u) & A ^ u, c, g, m[9], 5, 27, 568446438), A = s((c ^ g) & u ^ g, A, c, m[14], 9, 23, -1019803690), u = s((A ^ c) & g ^ c, u, A, m[3], 14, 18, -187363961), g = s((u ^ A) & c ^ A, g, u, m[8], 20, 12, 1163531501), c = s((g ^ u) & A ^ u, c, g, m[13], 5, 27, -1444681467), A = s((c ^ g) & u ^ g, A, c, m[2], 9, 23, -51403784), u = s((A ^ c) & g ^ c, u, A, m[7], 14, 18, 1735328473), g = s((u ^ A) & c ^ A, g, u, m[12], 20, 12, -1926607734), z = g ^ u, c = s(z ^ A, c, g, m[5], 4, 28, -378558), A = s(z ^ c, A, c, m[8], 11, 21, -2022574463), I = A ^ c, u = s(I ^ g, u, A, m[11], 16, 16, 1839030562), g = s(I ^ u, g, u, m[14], 23, 9, -35309556), z = g ^ u, c = s(z ^ A, c, g, m[1], 4, 28, -1530992060), A = s(z ^ c, A, c, m[4], 11, 21, 1272893353), I = A ^ c, u = s(I ^ g, u, A, m[7], 16, 16, -155497632), g = s(I ^ u, g, u, m[10], 23, 9, -1094730640), z = g ^ u, c = s(z ^ A, c, g, m[13], 4, 28, 681279174), A = s(z ^ c, A, c, m[0], 11, 21, -358537222), I = A ^ c, u = s(I ^ g, u, A, m[3], 16, 16, -722521979), g = s(I ^ u, g, u, m[6], 23, 9, 76029189), z = g ^ u, c = s(z ^ A, c, g, m[9], 4, 28, -640364487), A = s(z ^ c, A, c, m[12], 11, 21, -421815835), I = A ^ c, u = s(I ^ g, u, A, m[15], 16, 16, 530742520), g = s(I ^ u, g, u, m[2], 23, 9, -995338651), c = s(u ^ (g | ~A), c, g, m[0], 6, 26, -198630844), A = s(g ^ (c | ~u), A, c, m[7], 10, 22, 1126891415), u = s(c ^ (A | ~g), u, A, m[14], 15, 17, -1416354905), g = s(A ^ (u | ~c), g, u, m[5], 21, 11, -57434055), c = s(u ^ (g | ~A), c, g, m[12], 6, 26, 1700485571), A = s(g ^ (c | ~u), A, c, m[3], 10, 22, -1894986606), u = s(c ^ (A | ~g), u, A, m[10], 15, 17, -1051523), g = s(A ^ (u | ~c), g, u, m[1], 21, 11, -2054922799), c = s(u ^ (g | ~A), c, g, m[8], 6, 26, 1873313359), A = s(g ^ (c | ~u), A, c, m[15], 10, 22, -30611744), u = s(c ^ (A | ~g), u, A, m[6], 15, 17, -1560198380), g = s(A ^ (u | ~c), g, u, m[13], 21, 11, 1309151649), c = s(u ^ (g | ~A), c, g, m[4], 6, 26, -145523070), A = s(g ^ (c | ~u), A, c, m[11], 10, 22, -1120210379), u = s(c ^ (A | ~g), u, A, m[2], 15, 17, 718787259), g = s(A ^ (u | ~c), g, u, m[9], 21, 11, -343485551), H[0] = c, H[1] = g, H[2] = u, H[3] = A;
1294
+ N ? (l = s((u ^ A) & g ^ A, l, g, m[0], 7, 25, -680876936), A = s((g ^ u) & l ^ u, A, l, m[1], 12, 20, -389564586), u = s((l ^ g) & A ^ g, u, A, m[2], 17, 15, 606105819), g = s((A ^ l) & u ^ l, g, u, m[3], 22, 10, -1044525330)) : (l = m[0] - 680876937, l = (l << 7 | l >>> 25) - 271733879 << 0, A = m[1] - 117830708 + (2004318071 & l ^ -1732584194), A = (A << 12 | A >>> 20) + l << 0, u = m[2] - 1126478375 + ((-271733879 ^ l) & A ^ -271733879), u = (u << 17 | u >>> 15) + A << 0, g = m[3] - 1316259209 + ((A ^ l) & u ^ l), g = (g << 22 | g >>> 10) + u << 0), l = s((u ^ A) & g ^ A, l, g, m[4], 7, 25, -176418897), A = s((g ^ u) & l ^ u, A, l, m[5], 12, 20, 1200080426), u = s((l ^ g) & A ^ g, u, A, m[6], 17, 15, -1473231341), g = s((A ^ l) & u ^ l, g, u, m[7], 22, 10, -45705983), l = s((u ^ A) & g ^ A, l, g, m[8], 7, 25, 1770035416), A = s((g ^ u) & l ^ u, A, l, m[9], 12, 20, -1958414417), u = s((l ^ g) & A ^ g, u, A, m[10], 17, 15, -42063), g = s((A ^ l) & u ^ l, g, u, m[11], 22, 10, -1990404162), l = s((u ^ A) & g ^ A, l, g, m[12], 7, 25, 1804603682), A = s((g ^ u) & l ^ u, A, l, m[13], 12, 20, -40341101), u = s((l ^ g) & A ^ g, u, A, m[14], 17, 15, -1502002290), g = s((A ^ l) & u ^ l, g, u, m[15], 22, 10, 1236535329), l = s((g ^ u) & A ^ u, l, g, m[1], 5, 27, -165796510), A = s((l ^ g) & u ^ g, A, l, m[6], 9, 23, -1069501632), u = s((A ^ l) & g ^ l, u, A, m[11], 14, 18, 643717713), g = s((u ^ A) & l ^ A, g, u, m[0], 20, 12, -373897302), l = s((g ^ u) & A ^ u, l, g, m[5], 5, 27, -701558691), A = s((l ^ g) & u ^ g, A, l, m[10], 9, 23, 38016083), u = s((A ^ l) & g ^ l, u, A, m[15], 14, 18, -660478335), g = s((u ^ A) & l ^ A, g, u, m[4], 20, 12, -405537848), l = s((g ^ u) & A ^ u, l, g, m[9], 5, 27, 568446438), A = s((l ^ g) & u ^ g, A, l, m[14], 9, 23, -1019803690), u = s((A ^ l) & g ^ l, u, A, m[3], 14, 18, -187363961), g = s((u ^ A) & l ^ A, g, u, m[8], 20, 12, 1163531501), l = s((g ^ u) & A ^ u, l, g, m[13], 5, 27, -1444681467), A = s((l ^ g) & u ^ g, A, l, m[2], 9, 23, -51403784), u = s((A ^ l) & g ^ l, u, A, m[7], 14, 18, 1735328473), g = s((u ^ A) & l ^ A, g, u, m[12], 20, 12, -1926607734), z = g ^ u, l = s(z ^ A, l, g, m[5], 4, 28, -378558), A = s(z ^ l, A, l, m[8], 11, 21, -2022574463), I = A ^ l, u = s(I ^ g, u, A, m[11], 16, 16, 1839030562), g = s(I ^ u, g, u, m[14], 23, 9, -35309556), z = g ^ u, l = s(z ^ A, l, g, m[1], 4, 28, -1530992060), A = s(z ^ l, A, l, m[4], 11, 21, 1272893353), I = A ^ l, u = s(I ^ g, u, A, m[7], 16, 16, -155497632), g = s(I ^ u, g, u, m[10], 23, 9, -1094730640), z = g ^ u, l = s(z ^ A, l, g, m[13], 4, 28, 681279174), A = s(z ^ l, A, l, m[0], 11, 21, -358537222), I = A ^ l, u = s(I ^ g, u, A, m[3], 16, 16, -722521979), g = s(I ^ u, g, u, m[6], 23, 9, 76029189), z = g ^ u, l = s(z ^ A, l, g, m[9], 4, 28, -640364487), A = s(z ^ l, A, l, m[12], 11, 21, -421815835), I = A ^ l, u = s(I ^ g, u, A, m[15], 16, 16, 530742520), g = s(I ^ u, g, u, m[2], 23, 9, -995338651), l = s(u ^ (g | ~A), l, g, m[0], 6, 26, -198630844), A = s(g ^ (l | ~u), A, l, m[7], 10, 22, 1126891415), u = s(l ^ (A | ~g), u, A, m[14], 15, 17, -1416354905), g = s(A ^ (u | ~l), g, u, m[5], 21, 11, -57434055), l = s(u ^ (g | ~A), l, g, m[12], 6, 26, 1700485571), A = s(g ^ (l | ~u), A, l, m[3], 10, 22, -1894986606), u = s(l ^ (A | ~g), u, A, m[10], 15, 17, -1051523), g = s(A ^ (u | ~l), g, u, m[1], 21, 11, -2054922799), l = s(u ^ (g | ~A), l, g, m[8], 6, 26, 1873313359), A = s(g ^ (l | ~u), A, l, m[15], 10, 22, -30611744), u = s(l ^ (A | ~g), u, A, m[6], 15, 17, -1560198380), g = s(A ^ (u | ~l), g, u, m[13], 21, 11, 1309151649), l = s(u ^ (g | ~A), l, g, m[4], 6, 26, -145523070), A = s(g ^ (l | ~u), A, l, m[11], 10, 22, -1120210379), u = s(l ^ (A | ~g), u, A, m[2], 15, 17, 718787259), g = s(A ^ (u | ~l), g, u, m[9], 21, 11, -343485551), H[0] = l, H[1] = g, H[2] = u, H[3] = A;
1295
1295
  }
1296
- var l = [], w = [], P = [], C = [], v = "0123456789abcdef".split(""), D = [], B = [], N = !1, K = 0, G = 0, H = [];
1297
- if (t.Int32Array) w = new Int32Array(16), P = new Int32Array(16), C = new Int32Array(4), D = new Int32Array(4), B = new Int32Array(4), H = new Int32Array(4);
1296
+ var c = [], d = [], P = [], C = [], v = "0123456789abcdef".split(""), D = [], B = [], N = !1, K = 0, G = 0, H = [];
1297
+ if (t.Int32Array) d = new Int32Array(16), P = new Int32Array(16), C = new Int32Array(4), D = new Int32Array(4), B = new Int32Array(4), H = new Int32Array(4);
1298
1298
  else {
1299
1299
  var L;
1300
- for (L = 0; 16 > L; L++) w[L] = P[L] = 0;
1300
+ for (L = 0; 16 > L; L++) d[L] = P[L] = 0;
1301
1301
  for (L = 0; 4 > L; L++) C[L] = D[L] = B[L] = H[L] = 0;
1302
1302
  }
1303
1303
  C[0] = 128, C[1] = 32768, C[2] = 8388608, C[3] = -2147483648, D[0] = 0, D[1] = 8, D[2] = 16, D[3] = 24, t.md5 = t.md5 || n;
@@ -1524,7 +1524,7 @@ class fi extends Ze {
1524
1524
  throw new Error("VideoResourceProvider.write(): not supported");
1525
1525
  }
1526
1526
  }
1527
- class ci extends Ze {
1527
+ class li extends Ze {
1528
1528
  async load(e) {
1529
1529
  const r = await fetch(e);
1530
1530
  if (r.ok)
@@ -1532,7 +1532,7 @@ class ci extends Ze {
1532
1532
  throw new Error(`Resource not found at '${e}'`);
1533
1533
  }
1534
1534
  }
1535
- class li extends Ze {
1535
+ class ci extends Ze {
1536
1536
  async load(e) {
1537
1537
  const r = await fetch(e);
1538
1538
  if (r.ok) {
@@ -1566,19 +1566,19 @@ const Es = (t) => {
1566
1566
  Array.isArray(t) || (t = [t]), t.forEach((r) => {
1567
1567
  e.indexOf(r) === -1 && e.push(r);
1568
1568
  });
1569
- }, cr = [
1569
+ }, lr = [
1570
1570
  "jpg",
1571
1571
  "jpeg",
1572
1572
  "gif",
1573
1573
  "png"
1574
- ], wi = (t) => Bt(t, cr), Qs = (t) => {
1575
- Ct(t, cr);
1576
- }, Ts = () => cr, lr = [
1574
+ ], di = (t) => Bt(t, lr), Qs = (t) => {
1575
+ Ct(t, lr);
1576
+ }, Ts = () => lr, cr = [
1577
1577
  "mp4",
1578
1578
  "m4v"
1579
- ], di = (t) => Bt(t, lr), ys = (t) => {
1580
- Ct(t, lr);
1581
- }, Ms = () => lr, gr = [
1579
+ ], wi = (t) => Bt(t, cr), ys = (t) => {
1580
+ Ct(t, cr);
1581
+ }, Ms = () => cr, gr = [
1582
1582
  "vwglb",
1583
1583
  "bg2"
1584
1584
  ], vi = (t) => Bt(t, gr), Ns = (t) => {
@@ -1592,7 +1592,7 @@ class qe {
1592
1592
  textProvider: n = null,
1593
1593
  writeStrategy: s = void 0
1594
1594
  } = {}) {
1595
- this._imageProvider = e || new Ai(), this._videoProvider = r || new fi(), this._binaryProvider = i || new ci(), this._textProvider = n || new li(), s && (this.writeStrategy = s);
1595
+ this._imageProvider = e || new Ai(), this._videoProvider = r || new fi(), this._binaryProvider = i || new li(), this._textProvider = n || new ci(), s && (this.writeStrategy = s);
1596
1596
  }
1597
1597
  set writeStrategy(e) {
1598
1598
  this._writeStrategy = e, e && (this._imageProvider.writeStrategy = e, this._videoProvider.writeStrategy = e, this._binaryProvider.writeStrategy = e, this._textProvider.writeStrategy = e);
@@ -1602,9 +1602,9 @@ class qe {
1602
1602
  }
1603
1603
  getProvider(e) {
1604
1604
  switch (!0) {
1605
- case wi(e):
1606
- return this._imageProvider;
1607
1605
  case di(e):
1606
+ return this._imageProvider;
1607
+ case wi(e):
1608
1608
  return this._videoProvider;
1609
1609
  case vi(e):
1610
1610
  return this._binaryProvider;
@@ -1628,10 +1628,10 @@ const zs = {
1628
1628
  Resource: qe,
1629
1629
  isFormat: Bt,
1630
1630
  addFormats: Ct,
1631
- isValidImage: wi,
1631
+ isValidImage: di,
1632
1632
  addImageFormats: Qs,
1633
1633
  getValidImageFormats: Ts,
1634
- isValidVideo: di,
1634
+ isValidVideo: wi,
1635
1635
  addVideoFormats: ys,
1636
1636
  getValidVideoFormats: Ms,
1637
1637
  isValidBinary: vi,
@@ -1640,8 +1640,8 @@ const zs = {
1640
1640
  ResourceProvider: Ze,
1641
1641
  ImageResourceProvider: Ai,
1642
1642
  VideoResourceProvider: fi,
1643
- BinaryResourceProvider: ci,
1644
- TextResourceProvider: li,
1643
+ BinaryResourceProvider: li,
1644
+ TextResourceProvider: ci,
1645
1645
  ProcessType: oi,
1646
1646
  ProcessTypeName: ai,
1647
1647
  getProcessType: ar,
@@ -1815,12 +1815,12 @@ function Mr(t) {
1815
1815
  }), i = (s, o) => h.Sub(s.uv, o.uv), n = (s, o) => 1 / (s.x * o.y - s.y * o.x);
1816
1816
  if (t.index.length % 3 === 0)
1817
1817
  for (let s = 0; s < t.index.length - 2; s += 3) {
1818
- let o = r(t.index[s]), a = r(t.index[s + 1]), f = r(t.index[s + 2]), l = h.Sub(a.pos, o.pos), w = h.Sub(f.pos, a.pos), P = i(a, o), C = i(f, o), v = n(P, C);
1818
+ let o = r(t.index[s]), a = r(t.index[s + 1]), f = r(t.index[s + 2]), c = h.Sub(a.pos, o.pos), d = h.Sub(f.pos, a.pos), P = i(a, o), C = i(f, o), v = n(P, C);
1819
1819
  isFinite(v) || (o.uv.x = o.uv.x * 1.1, o.uv.y = o.uv.y * 0.94, P = i(a, o), C = i(f, o), v = n(P, C)), isFinite(v) || (f.uv.x = f.uv.x * 1.3, f.uv.y = f.uv.y * 1.82, P = i(a, o), C = i(f, o), v = n(P, C));
1820
1820
  const D = new h(
1821
- (l.x * C.y - w.x * P.y) * v,
1822
- (l.y * C.y - w.y * P.y) * v,
1823
- (l.z * C.y - w.z * P.y) * v
1821
+ (c.x * C.y - d.x * P.y) * v,
1822
+ (c.y * C.y - d.y * P.y) * v,
1823
+ (c.z * C.y - d.z * P.y) * v
1824
1824
  );
1825
1825
  D.normalize(), e.push(D.x), e.push(D.y), e.push(D.z), e.push(D.x), e.push(D.y), e.push(D.z), e.push(D.x), e.push(D.y), e.push(D.z);
1826
1826
  }
@@ -1831,12 +1831,12 @@ function Mr(t) {
1831
1831
  }
1832
1832
  t._tangent = e;
1833
1833
  }
1834
- class we {
1834
+ class de {
1835
1835
  constructor() {
1836
1836
  this._renderLayers = 0, this._drawMode = 1, this._lineWidth = 1, this._name = "", this._groupName = "", this._visible = !0, this._visibleToShadows = !0, this._cullFace = 1, this._frontFace = 1, this._enableCullFace = !0, this._vertex = [], this._normal = [], this._texCoord0 = [], this._texCoord1 = [], this._texCoord2 = [], this._color = [], this._index = [], this._colorCode = p.Black(), this._selected = !1, this._selectable = !0;
1837
1837
  }
1838
1838
  clone() {
1839
- const e = new we();
1839
+ const e = new de();
1840
1840
  return e.assign(this), e.name = this.name + " clone", e;
1841
1841
  }
1842
1842
  assign(e) {
@@ -1987,7 +1987,7 @@ class we {
1987
1987
  this.renderer && this.renderer.destroy();
1988
1988
  }
1989
1989
  static ApplyTransform(e, r) {
1990
- const i = new d(r), n = new d(r.mat3);
1990
+ const i = new w(r), n = new w(r.mat3);
1991
1991
  if (e.normal.length > 0 && e.normal.length != e.vertex.length)
1992
1992
  throw new Error(`Unexpected number of normal coordinates found in polyList '${e.name}'`);
1993
1993
  for (let s = 0; s < e.vertex.length - 2; s += 3) {
@@ -2370,9 +2370,9 @@ class x {
2370
2370
  }
2371
2371
  }
2372
2372
  const ye = {};
2373
- class wt {
2373
+ class dt {
2374
2374
  static Get(e = null) {
2375
- return e = e || _e.FirstCanvas(), !e && !ye.__no_canvas__ && console.warn("TextureCache.Get() No canvas available. If your application uses a canvas, ensure that it has been created before using TexturCache. If your application does not use a canvas, you may disregard this message."), e && !ye[e.id] ? ye[e.id] = new wt(e) : !e && !ye.__no_canvas__ && (ye.__no_canvas__ = new wt(null)), ye[e ? e.id : "__no_canvas__"];
2375
+ return e = e || _e.FirstCanvas(), !e && !ye.__no_canvas__ && console.warn("TextureCache.Get() No canvas available. If your application uses a canvas, ensure that it has been created before using TexturCache. If your application does not use a canvas, you may disregard this message."), e && !ye[e.id] ? ye[e.id] = new dt(e) : !e && !ye.__no_canvas__ && (ye.__no_canvas__ = new dt(null)), ye[e ? e.id : "__no_canvas__"];
2376
2376
  }
2377
2377
  constructor(e) {
2378
2378
  this._canvas = e, this._cache = {};
@@ -2408,7 +2408,7 @@ const Ce = {
2408
2408
  if (t === "ambientOcclussion" && typeof e == "number")
2409
2409
  return null;
2410
2410
  if (typeof e == "string") {
2411
- const n = r + e, s = wt.Get(i);
2411
+ const n = r + e, s = dt.Get(i);
2412
2412
  if (s.findTexture(n))
2413
2413
  return console.debug(`Texture '${n}' already loaded. Reusing texture.`), s.getTexture(n);
2414
2414
  {
@@ -2451,6 +2451,8 @@ const Ce = {
2451
2451
  if (e) {
2452
2452
  if (e.length >= 2 && e.length <= 4)
2453
2453
  return new h(e);
2454
+ if (e._v && e._v.length >= 2 && e._v.length <= 4)
2455
+ return new h(e._v);
2454
2456
  throw new Error("Invalid parameter found in material deserialization. The required parameter type is array with 2, 3 or 4 elements");
2455
2457
  } else return null;
2456
2458
  }
@@ -2801,7 +2803,7 @@ class V {
2801
2803
  }
2802
2804
  async load() {
2803
2805
  }
2804
- setup(e, r, i = d.MakeIdentity(), n = d.MakeIdentity(), s = d.MakeIdentity()) {
2806
+ setup(e, r, i = w.MakeIdentity(), n = w.MakeIdentity(), s = w.MakeIdentity()) {
2805
2807
  throw new Error("Error: using an abstract implementation of render.Shader.");
2806
2808
  }
2807
2809
  destroy() {
@@ -3001,7 +3003,7 @@ ${e.getProgramInfoLog(this._program)}`);
3001
3003
  this.positionAttribPointer(e.positionAttribParams(r)), i && this.normalAttribPointer(e.normalAttribParams(i)), n && this.texCoordAttribPointer(e.texCoord0AttribParams(n)), s && this.texCoordAttribPointer(e.texCoord1AttribParams(s)), o && this.texCoordAttribPointer(e.texCoord2AttribParams(o)), f && this.tangentAttribPointer(e.tangentAttribParams(f)), a && this.colorAttribPointer(e.colorAttribParams(a));
3002
3004
  }
3003
3005
  bindMatrix(e, r) {
3004
- r instanceof d ? this.uniformMatrix4fv(e, !1, r) : r instanceof te && this.uniformMatrix3fv(e, !1, r);
3006
+ r instanceof w ? this.uniformMatrix4fv(e, !1, r) : r instanceof te && this.uniformMatrix3fv(e, !1, r);
3005
3007
  }
3006
3008
  bindVector(e, r) {
3007
3009
  switch (r.length) {
@@ -3101,10 +3103,10 @@ class Ni extends V {
3101
3103
  throw new Error("IrradianceMapCubeShader: shader program is not loaded");
3102
3104
  const o = this.renderer, { gl: a } = o;
3103
3105
  o.state.shaderProgram = this._program;
3104
- const f = d.Mult(s, n);
3106
+ const f = w.Mult(s, n);
3105
3107
  this._program.uniformMatrix4fv("uMVP", !1, f), a.activeTexture(a.TEXTURE0), this._program.uniform1i("uCubemap", 0);
3106
- const l = r.getTextureRenderer("albedoTexture").getApiObject();
3107
- a.bindTexture(a.TEXTURE_CUBE_MAP, l), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
3108
+ const c = r.getTextureRenderer("albedoTexture").getApiObject();
3109
+ a.bindTexture(a.TEXTURE_CUBE_MAP, c), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
3108
3110
  }
3109
3111
  destroy() {
3110
3112
  this._program && (T.Delete(this._program), this._program = null);
@@ -3219,10 +3221,10 @@ class Hi extends V {
3219
3221
  throw new Error("SpecularMapCubeShader: Shader program is not loaded.");
3220
3222
  const { material: o } = r, a = this.renderer, { gl: f } = a;
3221
3223
  a.state.shaderProgram = this._program;
3222
- const l = d.Mult(s, n);
3223
- this._program.uniformMatrix4fv("uMVP", !1, l), f.activeTexture(f.TEXTURE0), this._program.uniform1i("uCubemap", 0);
3224
- const w = r.getTextureRenderer("albedoTexture")?.getApiObject();
3225
- f.bindTexture(f.TEXTURE_CUBE_MAP, w), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
3224
+ const c = w.Mult(s, n);
3225
+ this._program.uniformMatrix4fv("uMVP", !1, c), f.activeTexture(f.TEXTURE0), this._program.uniform1i("uCubemap", 0);
3226
+ const d = r.getTextureRenderer("albedoTexture")?.getApiObject();
3227
+ f.bindTexture(f.TEXTURE_CUBE_MAP, d), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
3226
3228
  }
3227
3229
  destroy() {
3228
3230
  this._program && (T.Delete(this._program), this._program = null);
@@ -3268,11 +3270,11 @@ function Ws(t) {
3268
3270
  for (; e = i.exec(r); ) {
3269
3271
  let s = Number(e[1]), o = e[3] ? Number(e[3]) : null, a = e[2] ? Number(e[2]) : null;
3270
3272
  s = s < 0 ? this._vertexArray.length + s : s - 1;
3271
- let f = this._vertexArray[s], l = null, w = null;
3272
- o !== null && (o = o < 0 ? this._normalArray.length + o : o === null ? null : o - 1, l = o !== null ? this._normalArray[o] : null), a !== null && (a = a < 0 ? this._texCoordArray.length + a : a === null ? null : a - 1, w = a !== null ? this._texCoordArray[a] : null), n.push({
3273
+ let f = this._vertexArray[s], c = null, d = null;
3274
+ o !== null && (o = o < 0 ? this._normalArray.length + o : o === null ? null : o - 1, c = o !== null ? this._normalArray[o] : null), a !== null && (a = a < 0 ? this._texCoordArray.length + a : a === null ? null : a - 1, d = a !== null ? this._texCoordArray[a] : null), n.push({
3273
3275
  vertex: f,
3274
- normal: l,
3275
- tex: w
3276
+ normal: c,
3277
+ tex: d
3276
3278
  });
3277
3279
  }
3278
3280
  Ks.apply(this, [n]);
@@ -3283,7 +3285,7 @@ function Js(t) {
3283
3285
  e && this._currentPlist?.name == "" && (this._currentPlist.name = e[1]);
3284
3286
  }
3285
3287
  function ot() {
3286
- this._addPlist && (this._currentPlist && this._plistArray.push(this._currentPlist), this._currentPlist = new we(), this._addPlist = !1);
3288
+ this._addPlist && (this._currentPlist && this._plistArray.push(this._currentPlist), this._currentPlist = new de(), this._addPlist = !1);
3287
3289
  }
3288
3290
  function Zs() {
3289
3291
  let t = this._textData.split(`
@@ -4529,7 +4531,7 @@ function no(t, e) {
4529
4531
  return new Re(r).polyListArray[0];
4530
4532
  }
4531
4533
  function so(t, e) {
4532
- const r = new we(), i = t / 2, n = e / 2;
4534
+ const r = new de(), i = t / 2, n = e / 2;
4533
4535
  return r.vertex = [
4534
4536
  -i,
4535
4537
  0,
@@ -4575,9 +4577,9 @@ function so(t, e) {
4575
4577
  ], r.drawMode = ae.TRIANGLES, r;
4576
4578
  }
4577
4579
  function oo(t, e = 0.3, r = new h(0, 0, 1), i = new h(0, 1, 0)) {
4578
- const n = new we();
4580
+ const n = new de();
4579
4581
  r.normalize(), n.drawMode = ae.LINES;
4580
- const s = d.MakeRotationWithDirection(r, i), o = s.multVector(new h(0, 0, -1)), a = s.multVector(new h(e, 0, -1 + e)), f = s.multVector(new h(-e, 0, -1 + e));
4582
+ const s = w.MakeRotationWithDirection(r, i), o = s.multVector(new h(0, 0, -1)), a = s.multVector(new h(e, 0, -1 + e)), f = s.multVector(new h(-e, 0, -1 + e));
4581
4583
  return n.vertex = [
4582
4584
  0,
4583
4585
  0,
@@ -4691,8 +4693,8 @@ class Ii extends V {
4691
4693
  throw new Error("SkySphereShader: material does not have an albedo texture");
4692
4694
  const a = this.renderer, { gl: f } = a;
4693
4695
  a.state.shaderProgram = this._program, this._program.uniformMatrix4fv("mView", !1, n), this._program.uniformMatrix4fv("mProj", !1, s), f.activeTexture(f.TEXTURE0), this._program.uniform1i("uTexture", 0);
4694
- const l = r.getTextureRenderer("albedoTexture")?.getApiObject(), w = Be[o.albedoTexture.target];
4695
- f.bindTexture(f[w], l), this._program.positionAttribPointer(e.positionAttribParams("vertPosition")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("t0Position"));
4696
+ const c = r.getTextureRenderer("albedoTexture")?.getApiObject(), d = Be[o.albedoTexture.target];
4697
+ f.bindTexture(f[d], c), this._program.positionAttribPointer(e.positionAttribParams("vertPosition")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("t0Position"));
4696
4698
  }
4697
4699
  destroy() {
4698
4700
  this._program && (T.Delete(this._program), this._program = null);
@@ -4703,9 +4705,9 @@ class Dt {
4703
4705
  shader: e = null,
4704
4706
  polyListRenderer: r = null,
4705
4707
  materialRenderer: i = null,
4706
- modelMatrix: n = d.MakeIdentity(),
4707
- viewMatrix: s = d.MakeIdentity(),
4708
- projectionMatrix: o = d.MakeIdentity(),
4708
+ modelMatrix: n = w.MakeIdentity(),
4709
+ viewMatrix: s = w.MakeIdentity(),
4710
+ projectionMatrix: o = w.MakeIdentity(),
4709
4711
  pipeline: a = null
4710
4712
  } = {}) {
4711
4713
  this._shader = e, this._polyListRenderer = r, this._materialRenderer = i, this._modelMatrix = n, this._viewMatrix = s, this._projectionMatrix = o, this._pipeline = a;
@@ -4777,7 +4779,7 @@ class Dt {
4777
4779
  ), this.polyListRenderer.draw(), this.renderer?.debugMode && console.log(`======= End render polyList "${this.polyListRenderer.polyList.name}" ==============`);
4778
4780
  }
4779
4781
  }
4780
- class wr {
4782
+ class dr {
4781
4783
  constructor(e) {
4782
4784
  this._renderer = e, this._texture = null, this._material = null, this._shader = null, this._plistRenderer = null, this._renderState = null;
4783
4785
  }
@@ -4795,13 +4797,13 @@ class wr {
4795
4797
  updateRenderState({ viewMatrix: e, projectionMatrix: r = null }) {
4796
4798
  if (!this._material)
4797
4799
  throw new Error("SkySphere: internal error, material is null when updating render state.");
4798
- const i = d.GetRotation(e);
4800
+ const i = w.GetRotation(e);
4799
4801
  return this._renderState ? (this._renderState.viewMatrix = i, r && (this._renderState.projectionMatrix = r)) : this._renderState = new Dt({
4800
4802
  shader: this._shader,
4801
4803
  polyListRenderer: this.polyListRenderer,
4802
4804
  materialRenderer: this.renderer.factory.material(this._material),
4803
4805
  viewMatrix: i,
4804
- projectionMatrix: r || d.MakeIdentity()
4806
+ projectionMatrix: r || w.MakeIdentity()
4805
4807
  }), this._renderState;
4806
4808
  }
4807
4809
  draw() {
@@ -4829,7 +4831,7 @@ const Kt = async (t, e) => {
4829
4831
  const { renderBuffer: e, skyShape: r } = t;
4830
4832
  e.update((i, n, s) => {
4831
4833
  t.renderer.clearBuffer(), r?.updateRenderState({
4832
- viewMatrix: n || d.MakeIdentity(),
4834
+ viewMatrix: n || w.MakeIdentity(),
4833
4835
  projectionMatrix: s
4834
4836
  }), r?.draw();
4835
4837
  });
@@ -4874,7 +4876,7 @@ let Si = class {
4874
4876
  this._environmentMapResources && Jt(this._environmentMapResources), this._specularMapResources && Jt(this._specularMapResources), this._irradianceMapResources && Jt(this._irradianceMapResources), this._updated = !0;
4875
4877
  }
4876
4878
  async reloadImage(e) {
4877
- this._environmentMapResources && (this._environmentMapResources.skyShape instanceof wr && await this._environmentMapResources.skyShape.setTexture(e), this._updated = !1);
4879
+ this._environmentMapResources && (this._environmentMapResources.skyShape instanceof dr && await this._environmentMapResources.skyShape.setTexture(e), this._updated = !1);
4878
4880
  }
4879
4881
  };
4880
4882
  const Sr = {
@@ -4966,8 +4968,8 @@ class bt extends V {
4966
4968
  throw new Error("TextureMergerShader: B texture is not set");
4967
4969
  if (!this._textures[y.A])
4968
4970
  throw new Error("TextureMergerShader: A texture is not set");
4969
- const a = this.renderer.factory.texture(this._textures[y.R]), f = this.renderer.factory.texture(this._textures[y.G]), l = this.renderer.factory.texture(this._textures[y.B]), w = this.renderer.factory.texture(this._textures[y.A]);
4970
- this._program.bindTexture("uTextureR", a, 0), this._program.bindTexture("uTextureG", f, 1), this._program.bindTexture("uTextureB", l, 2), this._program.bindTexture("uTextureA", w, 3), this._program.uniform1i("uRChannel", this._textureChannels[y.R] || 0), this._program.uniform1i("uGChannel", this._textureChannels[y.G] || 1), this._program.uniform1i("uBChannel", this._textureChannels[y.B] || 2), this._program.uniform1i("uAChannel", this._textureChannels[y.A] || 3), this._program.positionAttribPointer(e.positionAttribParams("position")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("texCoord"));
4971
+ const a = this.renderer.factory.texture(this._textures[y.R]), f = this.renderer.factory.texture(this._textures[y.G]), c = this.renderer.factory.texture(this._textures[y.B]), d = this.renderer.factory.texture(this._textures[y.A]);
4972
+ this._program.bindTexture("uTextureR", a, 0), this._program.bindTexture("uTextureG", f, 1), this._program.bindTexture("uTextureB", c, 2), this._program.bindTexture("uTextureA", d, 3), this._program.uniform1i("uRChannel", this._textureChannels[y.R] || 0), this._program.uniform1i("uGChannel", this._textureChannels[y.G] || 1), this._program.uniform1i("uBChannel", this._textureChannels[y.B] || 2), this._program.uniform1i("uAChannel", this._textureChannels[y.A] || 3), this._program.positionAttribPointer(e.positionAttribParams("position")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("texCoord"));
4971
4973
  }
4972
4974
  }
4973
4975
  class Ri {
@@ -5039,10 +5041,10 @@ class Oi extends V {
5039
5041
  throw new Error("PresentTextureShader: shader program is not loaded");
5040
5042
  const o = this.renderer, { gl: a } = o;
5041
5043
  o.state.shaderProgram = this._program, a.activeTexture(a.TEXTURE0), this._program.uniform1i("uTexture", 0);
5042
- const f = r.material, l = r.getTextureRenderer("albedoTexture")?.getApiObject();
5043
- if (l && f.albedoTexture) {
5044
- const w = Be[f.albedoTexture.target];
5045
- a.bindTexture(a[w], l);
5044
+ const f = r.material, c = r.getTextureRenderer("albedoTexture")?.getApiObject();
5045
+ if (c && f.albedoTexture) {
5046
+ const d = Be[f.albedoTexture.target];
5047
+ a.bindTexture(a[d], c);
5046
5048
  } else
5047
5049
  throw new Error("PresentTextureShader: invalid material setup. The albedoTexture material attribute must to be a texture");
5048
5050
  this._program.positionAttribPointer(e.positionAttribParams("position")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("texCoord"));
@@ -5079,7 +5081,7 @@ class Et {
5079
5081
  }
5080
5082
  get presentTextureSurfaceRenderer() {
5081
5083
  if (!this._presentTextureSurface) {
5082
- const e = new we();
5084
+ const e = new de();
5083
5085
  e.vertex = [
5084
5086
  -1,
5085
5087
  -1,
@@ -5222,7 +5224,7 @@ class Et {
5222
5224
  }
5223
5225
  const Fi = {}, ee = (t, e) => {
5224
5226
  Fi[t] = e;
5225
- }, co = (t) => {
5227
+ }, lo = (t) => {
5226
5228
  const e = Fi[t];
5227
5229
  if (e)
5228
5230
  try {
@@ -5235,7 +5237,7 @@ const Fi = {}, ee = (t, e) => {
5235
5237
  return console.debug(`Ignoring component with type id='${t}'. If this is not expected, check if the component is registered in the component factory.`), null;
5236
5238
  return null;
5237
5239
  }, Gi = async (t, e) => {
5238
- const r = co(t.type);
5240
+ const r = lo(t.type);
5239
5241
  return r ? (await r.deserialize(t, e), r) : null;
5240
5242
  };
5241
5243
  class se {
@@ -5338,7 +5340,7 @@ class se {
5338
5340
  touchEnd(e) {
5339
5341
  }
5340
5342
  }
5341
- class dr {
5343
+ class wr {
5342
5344
  syncArray() {
5343
5345
  this._array = [];
5344
5346
  for (const e in this._obj) {
@@ -5386,7 +5388,7 @@ class dr {
5386
5388
  return this._array.filter(e);
5387
5389
  }
5388
5390
  clone(e) {
5389
- const r = new dr(e);
5391
+ const r = new wr(e);
5390
5392
  return r.assign(this), r;
5391
5393
  }
5392
5394
  // Note: this function clones the components from 'other'
@@ -5406,7 +5408,7 @@ function Ui(t, e) {
5406
5408
  r.bindRenderer(e);
5407
5409
  });
5408
5410
  }
5409
- async function lo(t) {
5411
+ async function co(t) {
5410
5412
  for (const e in t.components.array) {
5411
5413
  const r = t.components.array[e];
5412
5414
  r._initialized || (await r.init(), r._initialized = !0);
@@ -5415,7 +5417,7 @@ async function lo(t) {
5415
5417
  }
5416
5418
  class Ae {
5417
5419
  constructor(e = "") {
5418
- this._sceneChanged = !1, this._name = e, this._enabled = !0, this._steady = !1, this._components = new dr(this), this._parent = null, this._children = [];
5420
+ this._sceneChanged = !1, this._name = e, this._enabled = !0, this._steady = !1, this._components = new wr(this), this._parent = null, this._children = [];
5419
5421
  }
5420
5422
  get name() {
5421
5423
  return this._name;
@@ -5619,8 +5621,12 @@ class ki extends pt {
5619
5621
  static PreferredDrawableFormat() {
5620
5622
  return Or;
5621
5623
  }
5622
- constructor({ bg2ioPath: e, preferedDrawableFormat: r = vr.BG2 } = { bg2ioPath: null }) {
5623
- super(), this._bg2ioPath = e, Or = r;
5624
+ constructor({
5625
+ bg2ioPath: e,
5626
+ preferedDrawableFormat: r = vr.BG2,
5627
+ materialImportCallback: i
5628
+ } = { bg2ioPath: null }) {
5629
+ super(), this._bg2ioPath = e, Or = r, this._materialImportCallback = i;
5624
5630
  }
5625
5631
  get supportedExtensions() {
5626
5632
  return ["vitscnj"];
@@ -5637,13 +5643,16 @@ class ki extends pt {
5637
5643
  i.currentPath = gi(e);
5638
5644
  const s = new qe(), o = new Ae("Scene Root"), { scene: a } = await s.load(e);
5639
5645
  for (const f of a) {
5640
- const l = await Xi(f, i);
5641
- o.addChild(l);
5646
+ const c = await Xi(f, i);
5647
+ o.addChild(c);
5642
5648
  }
5643
5649
  return i.currentPath = n, o;
5644
5650
  }
5645
5651
  get dependencies() {
5646
- return [new Vi({ bg2ioPath: this._bg2ioPath })];
5652
+ return [new Vi({
5653
+ bg2ioPath: this._bg2ioPath,
5654
+ materialImportCallback: this._materialImportCallback
5655
+ })];
5647
5656
  }
5648
5657
  }
5649
5658
  class Oe extends se {
@@ -5668,16 +5677,16 @@ class Oe extends se {
5668
5677
  }
5669
5678
  assign(e) {
5670
5679
  this.destroy(), this._name = e._name, this._items = [], e._items.forEach((r) => {
5671
- const i = r.polyList.clone(), n = r.material.clone(), s = new d(r.transform);
5680
+ const i = r.polyList.clone(), n = r.material.clone(), s = new w(r.transform);
5672
5681
  this.addPolyList(i, n, s);
5673
5682
  });
5674
5683
  }
5675
- addPolyList(e, r, i = d.MakeIdentity()) {
5676
- if (!(e instanceof we))
5684
+ addPolyList(e, r, i = w.MakeIdentity()) {
5685
+ if (!(e instanceof de))
5677
5686
  throw new Error("Error adding polyList to drawable object: polyList is not an instance of PolyList");
5678
5687
  if (!(r instanceof ne))
5679
5688
  throw new Error("Error adding polyList to drawable object: material is not an instance of Material");
5680
- if (!(i instanceof d))
5689
+ if (!(i instanceof w))
5681
5690
  throw new Error("Error adding polyList to drawable object: transform is not an instance of Mat4");
5682
5691
  this._items.push({ polyList: e, material: r, transform: i });
5683
5692
  }
@@ -5720,7 +5729,7 @@ class Oe extends se {
5720
5729
  e.addPolyList(
5721
5730
  n,
5722
5731
  s,
5723
- d.Mult(i, r)
5732
+ w.Mult(i, r)
5724
5733
  );
5725
5734
  });
5726
5735
  }
@@ -5762,14 +5771,14 @@ class go {
5762
5771
  r.version.revision,
5763
5772
  r.numberOfPlist,
5764
5773
  this._debug ? 1 : 0
5765
- ), this.instance.ccall("setMaterialData", null, ["number", "string", "number"], [a, JSON.stringify(i), this._debug ? 1 : 0]), this.instance.ccall("setComponentData", null, ["number", "string", "number"], [a, JSON.stringify(o), this._debug ? 1 : 0]), this.instance.ccall("setJointData", null, ["number", "string", "number"], [a, JSON.stringify(n), this._debug ? 1 : 0]), this.instance.ccall("createPolyListArray", null, ["number", "number", "number"], [a, s.length, this._debug ? 1 : 0]), s.forEach((w, P) => {
5766
- const C = this.instance.ccall("createPolyList", "number", ["string", "string", "number"], [w.name, w.matName, this._debug ? 1 : 0]);
5767
- this.instance._addPolyList(a, C, P, this._debug ? 1 : 0), this.addFloatBuffer(C, w.vertex, He.VERTEX), this.addFloatBuffer(C, w.normal, He.NORMAL), this.addFloatBuffer(C, w.texCoord0, He.TEXCOORD0), this.addFloatBuffer(C, w.texCoord1, He.TEXCOORD1), this.addFloatBuffer(C, w.texCoord2, He.TEXCOORD2), this.addIndexBuffer(C, w.index, He.INDEX);
5774
+ ), this.instance.ccall("setMaterialData", null, ["number", "string", "number"], [a, JSON.stringify(i), this._debug ? 1 : 0]), this.instance.ccall("setComponentData", null, ["number", "string", "number"], [a, JSON.stringify(o), this._debug ? 1 : 0]), this.instance.ccall("setJointData", null, ["number", "string", "number"], [a, JSON.stringify(n), this._debug ? 1 : 0]), this.instance.ccall("createPolyListArray", null, ["number", "number", "number"], [a, s.length, this._debug ? 1 : 0]), s.forEach((d, P) => {
5775
+ const C = this.instance.ccall("createPolyList", "number", ["string", "string", "number"], [d.name, d.matName, this._debug ? 1 : 0]);
5776
+ this.instance._addPolyList(a, C, P, this._debug ? 1 : 0), this.addFloatBuffer(C, d.vertex, He.VERTEX), this.addFloatBuffer(C, d.normal, He.NORMAL), this.addFloatBuffer(C, d.texCoord0, He.TEXCOORD0), this.addFloatBuffer(C, d.texCoord1, He.TEXCOORD1), this.addFloatBuffer(C, d.texCoord2, He.TEXCOORD2), this.addIndexBuffer(C, d.index, He.INDEX);
5768
5777
  });
5769
- const l = this.instance._createBufferWithBg2File(a, this._debug ? 1 : 0);
5770
- if (l) {
5771
- const w = new Int32Array(this.instance.HEAPU8.buffer, l, 1)[0], P = new Uint32Array(this.instance.HEAPU8.buffer, l + 4, 1)[0];
5772
- f = new Uint8Array(this.instance.HEAPU8.buffer, P, w).slice(), this.instance._freeBufferWrapper(l, this._debug ? 1 : 0);
5778
+ const c = this.instance._createBufferWithBg2File(a, this._debug ? 1 : 0);
5779
+ if (c) {
5780
+ const d = new Int32Array(this.instance.HEAPU8.buffer, c, 1)[0], P = new Uint32Array(this.instance.HEAPU8.buffer, c + 4, 1)[0];
5781
+ f = new Uint8Array(this.instance.HEAPU8.buffer, P, d).slice(), this.instance._freeBufferWrapper(c, this._debug ? 1 : 0);
5773
5782
  }
5774
5783
  this.instance._freeBg2File(a, this._debug ? 1 : 0);
5775
5784
  }
@@ -5814,13 +5823,13 @@ class go {
5814
5823
  getPolyList(e, r) {
5815
5824
  const i = this._instance._getPolyList(e, r, this._debug ? 1 : 0);
5816
5825
  if (i) {
5817
- const n = new Int32Array(this.instance.HEAPU8.buffer, i, 16), s = n[0], o = n[1], a = n[2], f = n[3], l = n[4], w = n[5], P = n[6], C = n[7], v = n[8], D = n[9], B = n[10], N = n[11], K = n[12], G = n[13], H = n[14], L = n[15];
5826
+ const n = new Int32Array(this.instance.HEAPU8.buffer, i, 16), s = n[0], o = n[1], a = n[2], f = n[3], c = n[4], d = n[5], P = n[6], C = n[7], v = n[8], D = n[9], B = n[10], N = n[11], K = n[12], G = n[13], H = n[14], L = n[15];
5818
5827
  return {
5819
5828
  name: this.getStringFromCStr(s),
5820
5829
  matName: this.getStringFromCStr(o),
5821
5830
  groupName: this.getStringFromCStr(a),
5822
5831
  visible: f === 1,
5823
- vertex: this.getFloatArray(w, l),
5832
+ vertex: this.getFloatArray(d, c),
5824
5833
  normal: this.getFloatArray(C, P),
5825
5834
  texCoord0: this.getFloatArray(D, v),
5826
5835
  texCoord1: this.getFloatArray(N, B),
@@ -5895,7 +5904,7 @@ const vo = async (t) => {
5895
5904
  throw new Error("Bg2LoaderPlugin: unable to initialize bg2io library");
5896
5905
  return ht;
5897
5906
  }, Yi = (t, e) => t.polyLists.map((i) => {
5898
- const n = new we(), s = t.materials.find((o) => o.name === i.matName);
5907
+ const n = new de(), s = t.materials.find((o) => o.name === i.matName);
5899
5908
  return n.name = i.name, n.visible = i.visible, s && (n.groupName = s.groupName || "", n.enableCullFace = s.cullFace), n.vertex = i.vertex, n.normal = i.normal, n.texCoord0 = i.texCoord0, n.texCoord1 = i.texCoord1, n.texCoord2 = i.texCoord2, n.index = i.index, { plist: n, materialData: s };
5900
5909
  }), ji = async (t, e, r) => {
5901
5910
  const i = fr(Ar(e)), n = gi(e), s = new Oe(i);
@@ -5917,8 +5926,11 @@ const vo = async (t) => {
5917
5926
  return console.log(t), s;
5918
5927
  };
5919
5928
  class Vi extends pt {
5920
- constructor({ bg2ioPath: e = null } = {}) {
5921
- super(), this._bg2ioPath = e, this._resource = new qe();
5929
+ constructor({
5930
+ bg2ioPath: e = null,
5931
+ materialImportCallback: r
5932
+ } = {}) {
5933
+ super(), this._bg2ioPath = e, this._materialImportCallback = r, this._resource = new qe();
5922
5934
  }
5923
5935
  get supportedExtensions() {
5924
5936
  return ["bg2", "vwglb"];
@@ -5934,7 +5946,7 @@ class Vi extends pt {
5934
5946
  const n = await vo(this._bg2ioPath), s = await this._resource.load(e), o = n.loadBg2FileAsJson(s);
5935
5947
  switch (o.materials.forEach((a) => {
5936
5948
  a.type || (a.type = a.class, delete a.class);
5937
- }), r) {
5949
+ }), this._materialImportCallback && (o.materials = o.materials.map((a) => this._materialImportCallback(a))), r) {
5938
5950
  case M.PolyList:
5939
5951
  return Yi(o).map((a) => a.plist);
5940
5952
  case M.Drawable:
@@ -5952,7 +5964,7 @@ const mr = {
5952
5964
  }, Pr = (t) => ({
5953
5965
  operationType: t,
5954
5966
  plugins: {}
5955
- }), dt = (t, e) => {
5967
+ }), wt = (t, e) => {
5956
5968
  t.resourceTypes.forEach((r) => {
5957
5969
  e.plugins[r] = e.plugins[r] || [], e.plugins[r].push(t);
5958
5970
  });
@@ -5966,7 +5978,7 @@ const mr = {
5966
5978
  } else
5967
5979
  throw new Error(s);
5968
5980
  }, ir = Pr(mr.Read), Po = (t) => {
5969
- t.dependencies.forEach((e) => dt(e, ir)), dt(t, ir);
5981
+ t.dependencies.forEach((e) => wt(e, ir)), wt(t, ir);
5970
5982
  }, nr = (t, e) => Br(t, e, ir), Fr = () => ({
5971
5983
  [M.PolyList]: {},
5972
5984
  [M.Drawable]: {},
@@ -6085,7 +6097,7 @@ class bo extends Ki {
6085
6097
  }
6086
6098
  }
6087
6099
  const Wi = Pr(mr.Write), Eo = (t) => {
6088
- dt(t, Wi);
6100
+ wt(t, Wi);
6089
6101
  }, Ji = (t, e) => Br(t, e, Wi);
6090
6102
  class xo {
6091
6103
  constructor() {
@@ -6113,7 +6125,7 @@ const Qo = {
6113
6125
  Bg2LoaderPlugin: Vi,
6114
6126
  PluginOperationType: mr,
6115
6127
  createPluginDatabase: Pr,
6116
- registerPluginInDatabase: dt,
6128
+ registerPluginInDatabase: wt,
6117
6129
  getPluginFromDatabase: Br,
6118
6130
  Loader: Bo,
6119
6131
  registerLoaderPlugin: Po,
@@ -6233,7 +6245,7 @@ class Cr {
6233
6245
  var be = /* @__PURE__ */ ((t) => (t[t.DIRECTIONAL = 4] = "DIRECTIONAL", t[t.SPOT = 1] = "SPOT", t[t.POINT = 5] = "POINT", t[t.DISABLED = 10] = "DISABLED", t))(be || {});
6234
6246
  class xt {
6235
6247
  constructor() {
6236
- this._enabled = !0, this._type = 4, this._direction = new h(0, 0, -1), this._position = new h(0, 0, 0), this._color = new p({ rgb: 0.9 }), this._intensity = 20, this._spotCutoff = 20, this._spotExponent = 30, this._shadowStrength = 0.7, this._castShadows = !0, this._shadowBias = 2e-5, this._projection = d.MakeOrtho(-10, 10, -10, 10, 0.1, 500), this._depthTexture = null;
6248
+ this._enabled = !0, this._type = 4, this._direction = new h(0, 0, -1), this._position = new h(0, 0, 0), this._color = new p({ rgb: 0.9 }), this._intensity = 20, this._spotCutoff = 20, this._spotExponent = 30, this._shadowStrength = 0.7, this._castShadows = !0, this._shadowBias = 2e-5, this._projection = w.MakeOrtho(-10, 10, -10, 10, 0.1, 500), this._depthTexture = null;
6237
6249
  }
6238
6250
  clone() {
6239
6251
  const e = new xt();
@@ -6349,7 +6361,7 @@ class xt {
6349
6361
  this._type = 4;
6350
6362
  }
6351
6363
  const r = () => this._type === 4 ? 1 : 20;
6352
- this._position = e.position || new h(0, 0, 0), this._direction = e.direction || new h(0, 0, -1), e.diffuse ? (this._color = new p(e.diffuse), this._intensity = (e.intensity || 1) * r()) : e.color && (this._color = new p(e.color), this._intensity = e.intensity || r()), this._spotCutoff = e.spotCutoff || 20, this._spotExponent = e.spotExponent || 30, this._shadowStrength = e.shadowStrength || 1, e.projection && (this._projection = new d(e.projection)), this._castShadows = e.castShadows !== void 0 ? e.castShadows : !0;
6364
+ this._position = e.position || new h(0, 0, 0), this._direction = e.direction || new h(0, 0, -1), e.diffuse ? (this._color = new p(e.diffuse), this._intensity = (e.intensity || 1) * r()) : e.color && (this._color = new p(e.color), this._intensity = e.intensity || r()), this._spotCutoff = e.spotCutoff || 20, this._spotExponent = e.spotExponent || 30, this._shadowStrength = e.shadowStrength || 1, e.projection && (this._projection = new w(e.projection)), this._castShadows = e.castShadows !== void 0 ? e.castShadows : !0;
6353
6365
  }
6354
6366
  async serialize(e) {
6355
6367
  const r = [];
@@ -6371,7 +6383,7 @@ const To = {
6371
6383
  Light: xt,
6372
6384
  LightType: be,
6373
6385
  Material: ne,
6374
- PolyList: we,
6386
+ PolyList: de,
6375
6387
  BufferType: mi,
6376
6388
  DrawMode: ae,
6377
6389
  RenderLayer: k,
@@ -6404,7 +6416,7 @@ const To = {
6404
6416
  textureComponentFormatString: Gs,
6405
6417
  textureChannelString: Us
6406
6418
  };
6407
- class ce {
6419
+ class le {
6408
6420
  constructor() {
6409
6421
  this._ignoreDisabled = !0;
6410
6422
  }
@@ -6419,15 +6431,15 @@ class ce {
6419
6431
  didVisit(e) {
6420
6432
  }
6421
6433
  }
6422
- class yo extends ce {
6434
+ class yo extends le {
6423
6435
  constructor() {
6424
- super(), this._matrix = d.MakeIdentity();
6436
+ super(), this._matrix = w.MakeIdentity();
6425
6437
  }
6426
6438
  get matrix() {
6427
6439
  return this._matrix;
6428
6440
  }
6429
6441
  visit(e) {
6430
- e.transform && (this._matrix = d.Mult(this._matrix, e.transform.matrix));
6442
+ e.transform && (this._matrix = w.Mult(this._matrix, e.transform.matrix));
6431
6443
  }
6432
6444
  }
6433
6445
  class oe extends se {
@@ -6436,7 +6448,7 @@ class oe extends se {
6436
6448
  const r = new yo();
6437
6449
  return e.acceptReverse(r), r.matrix;
6438
6450
  }
6439
- constructor(e = d.MakeIdentity()) {
6451
+ constructor(e = w.MakeIdentity()) {
6440
6452
  super("Transform"), this._matrix = e;
6441
6453
  }
6442
6454
  get matrix() {
@@ -6450,7 +6462,7 @@ class oe extends se {
6450
6462
  return e.assign(this), e;
6451
6463
  }
6452
6464
  assign(e) {
6453
- this._matrix = new d(e.matrix);
6465
+ this._matrix = new w(e.matrix);
6454
6466
  }
6455
6467
  async deserialize(e, r) {
6456
6468
  Array.isArray(e.transformMatrix) && e.transformMatrix.length === 16 ? this._matrix.assign(e.transformMatrix) : console.warn("Transform.deserialize(): invalid transformMatrix attribute found in scene data");
@@ -6459,7 +6471,7 @@ class oe extends se {
6459
6471
  throw await super.serialize(e, r), new Error("Transform.serialice() not implemented");
6460
6472
  }
6461
6473
  update(e, r) {
6462
- r.assign(d.Mult(r, this._matrix));
6474
+ r.assign(w.Mult(r, this._matrix));
6463
6475
  }
6464
6476
  }
6465
6477
  class Qt extends se {
@@ -6468,7 +6480,7 @@ class Qt extends se {
6468
6480
  }
6469
6481
  willUpdate(e, r) {
6470
6482
  if (this.node) {
6471
- const i = d.MakeIdentity();
6483
+ const i = w.MakeIdentity();
6472
6484
  this.node.children.forEach((n, s) => {
6473
6485
  const o = n.transform, a = n.component("InputChainJoint"), f = n.component("OutputChainJoint");
6474
6486
  s > 0 && a ? a.joint.applyTransform(i) : i.identity(), o && o.matrix.assign(i), f && f.joint.applyTransform(i);
@@ -6494,7 +6506,7 @@ class Zi {
6494
6506
  return e.type === "LinkJoint" && (r = new Je(), r.deserialize(e)), r;
6495
6507
  }
6496
6508
  constructor() {
6497
- this._transform = d.MakeIdentity();
6509
+ this._transform = w.MakeIdentity();
6498
6510
  }
6499
6511
  get transform() {
6500
6512
  return this._transform;
@@ -6630,7 +6642,7 @@ class yt extends qi {
6630
6642
  return e.assign(this), e;
6631
6643
  }
6632
6644
  }
6633
- class pr extends ce {
6645
+ class pr extends le {
6634
6646
  constructor() {
6635
6647
  super(), this._name = void 0, this._result = [], this._hasComponents = [];
6636
6648
  }
@@ -6707,13 +6719,13 @@ class ge extends se {
6707
6719
  color: o,
6708
6720
  spotCutoff: a,
6709
6721
  spotExponent: f,
6710
- shadowStrength: l,
6711
- castShadows: w,
6722
+ shadowStrength: c,
6723
+ castShadows: d,
6712
6724
  shadowBias: P,
6713
6725
  intensity: C,
6714
6726
  projection: v
6715
6727
  }) {
6716
- e !== void 0 && (this.light.enabled = e), r !== void 0 && (this.light.type = r), i !== void 0 && (this.light.type = i), n !== void 0 && (this.light.direction = n), s !== void 0 && (this.light.position = s), o !== void 0 && (this.light.color = o), a !== void 0 && (this.light.spotCutoff = a), f !== void 0 && (this.light.spotExponent = f), l !== void 0 && (this.light.shadowStrength = l), w !== void 0 && (this.light.castShadows = w), P !== void 0 && (this.light.shadowBias = P), C !== void 0 && (this.light.intensity = C), v !== void 0 && (this.light.projection = v);
6728
+ e !== void 0 && (this.light.enabled = e), r !== void 0 && (this.light.type = r), i !== void 0 && (this.light.type = i), n !== void 0 && (this.light.direction = n), s !== void 0 && (this.light.position = s), o !== void 0 && (this.light.color = o), a !== void 0 && (this.light.spotCutoff = a), f !== void 0 && (this.light.spotExponent = f), c !== void 0 && (this.light.shadowStrength = c), d !== void 0 && (this.light.castShadows = d), P !== void 0 && (this.light.shadowBias = P), C !== void 0 && (this.light.intensity = C), v !== void 0 && (this.light.projection = v);
6717
6729
  }
6718
6730
  async deserialize(e, r) {
6719
6731
  await this._light.deserialize(e);
@@ -6873,7 +6885,7 @@ class Ie extends $e {
6873
6885
  this.viewWidth = e.viewWidth ?? this.viewWidth, super.deserialize(e);
6874
6886
  }
6875
6887
  }
6876
- class Mo extends ce {
6888
+ class Mo extends le {
6877
6889
  constructor(e) {
6878
6890
  if (super(), !e)
6879
6891
  throw Error("Set main camera: invalid parameter. The camera paremeter is null.");
@@ -6886,7 +6898,7 @@ class Mo extends ce {
6886
6898
  r instanceof j && (r._isMain = r === this._mainCamera);
6887
6899
  }
6888
6900
  }
6889
- class No extends ce {
6901
+ class No extends le {
6890
6902
  constructor() {
6891
6903
  super(), this._mainCamera = null, this._firstCameraFound = null;
6892
6904
  }
@@ -6925,14 +6937,14 @@ class j extends se {
6925
6937
  j.SetMain(e, this);
6926
6938
  }
6927
6939
  constructor() {
6928
- super("Camera"), this._projectionStrategy = null, this._isMain = !1, this._projectionMatrix = d.MakePerspective(45, 1, 0.1, 100), this._viewport = new h(0, 0, 512, 512), this._focusDistance = 5;
6940
+ super("Camera"), this._projectionStrategy = null, this._isMain = !1, this._projectionMatrix = w.MakePerspective(45, 1, 0.1, 100), this._viewport = new h(0, 0, 512, 512), this._focusDistance = 5;
6929
6941
  }
6930
6942
  clone() {
6931
6943
  const e = new j();
6932
6944
  return e.assign(this), e;
6933
6945
  }
6934
6946
  assign(e) {
6935
- e._projectionStrategy = this._projectionStrategy?.clone() || null, e._isMain = !1, e._projectionMatrix = new d(this._projectionMatrix), e._viewport = new h(this._viewport), e._focusDistance = this._focusDistance;
6947
+ e._projectionStrategy = this._projectionStrategy?.clone() || null, e._isMain = !1, e._projectionMatrix = new w(this._projectionMatrix), e._viewport = new h(this._viewport), e._focusDistance = this._focusDistance;
6936
6948
  }
6937
6949
  get isMain() {
6938
6950
  return this._isMain;
@@ -7259,8 +7271,8 @@ class tt extends se {
7259
7271
  e.touches.forEach((P) => {
7260
7272
  P.identifier === r.identifier ? n = P : P.identifier === i.identifier && (s = P);
7261
7273
  });
7262
- const o = h.Magnitude(h.Sub(new h(r.x, r.y), new h(i.x, i.y))), a = h.Magnitude(h.Sub(new h(n.x, n.y), new h(s.x, s.y))), f = new h(r.y - n.y, i.x - s.x), l = this.transform.matrix.upVector, w = this.transform.matrix.leftVector;
7263
- l.scale(f.x * -1e-3 * this._distance), w.scale(f.y * -1e-3 * this._distance), this._center = h.Add(this._center, h.Add(l, w)), this._distance += (o - a) * 5e-3 * this._distance;
7274
+ const o = h.Magnitude(h.Sub(new h(r.x, r.y), new h(i.x, i.y))), a = h.Magnitude(h.Sub(new h(n.x, n.y), new h(s.x, s.y))), f = new h(r.y - n.y, i.x - s.x), c = this.transform.matrix.upVector, d = this.transform.matrix.leftVector;
7275
+ c.scale(f.x * -1e-3 * this._distance), d.scale(f.y * -1e-3 * this._distance), this._center = h.Add(this._center, h.Add(c, d)), this._distance += (o - a) * 5e-3 * this._distance;
7264
7276
  }
7265
7277
  e.stopPropagation();
7266
7278
  }
@@ -7291,7 +7303,7 @@ class Lt extends tt {
7291
7303
  let s = new h([0, 0, 0]);
7292
7304
  this._keys[re.UP_ARROW] && (s = h.Add(s, this.transform.matrix.backwardVector)), this._keys[re.DOWN_ARROW] && (s = h.Add(s, this.transform.matrix.forwardVector)), this._keys[re.LEFT_ARROW] && (s = h.Add(s, this.transform.matrix.leftVector)), this._keys[re.RIGHT_ARROW] && (s = h.Add(s, this.transform.matrix.rightVector)), s.scale(this._displacementSpeed), this._center = h.Add(this._center, s);
7293
7305
  }
7294
- this._center0 = this._center0 ?? d.GetPosition(this.transform.matrix), this._distance0 = this._distance0 ?? h.Distance(this._center0, this._center), this._center0 = h.Lerp(this._center0, this._center, e * this._smoothFactor), this._distance0 = J(this._distance0, this._distance, e * this._smoothFactor * 2), this._pitch0 = this._pitch0 ?? this._rotation.x, this._yaw0 = this._yaw0 ?? this._rotation.y, this._pitch0 = J(this._pitch0, this._rotation.x, e * this._smoothFactor), this._yaw0 = J(this._yaw0, this._rotation.y, e * this._smoothFactor), this._distance = Z(this._distance, this.minDistance, this.maxDistance), this._distance0 = Z(this._distance0, this.minDistance, this.maxDistance), this._pitch0 = Z(this._pitch0, this.minPitch, this.maxPitch), this._rotation.x = Z(this._rotation.x, this.minPitch, this.maxPitch);
7306
+ this._center0 = this._center0 ?? w.GetPosition(this.transform.matrix), this._distance0 = this._distance0 ?? h.Distance(this._center0, this._center), this._center0 = h.Lerp(this._center0, this._center, e * this._smoothFactor), this._distance0 = J(this._distance0, this._distance, e * this._smoothFactor * 2), this._pitch0 = this._pitch0 ?? this._rotation.x, this._yaw0 = this._yaw0 ?? this._rotation.y, this._pitch0 = J(this._pitch0, this._rotation.x, e * this._smoothFactor), this._yaw0 = J(this._yaw0, this._rotation.y, e * this._smoothFactor), this._distance = Z(this._distance, this.minDistance, this.maxDistance), this._distance0 = Z(this._distance0, this.minDistance, this.maxDistance), this._pitch0 = Z(this._pitch0, this.minPitch, this.maxPitch), this._rotation.x = Z(this._rotation.x, this.minPitch, this.maxPitch);
7295
7307
  const i = new h(this.minX, this.minY, this.minZ), n = new h(this.maxX, this.maxY, this.maxZ);
7296
7308
  this._center0 = h.Clamp(this._center0, i, n), this._center = h.Clamp(this._center, i, n), this.transform.matrix.identity(), r ? r.viewWidth = this._viewWidth : (this.transform.matrix.translate(0, 0, this._distance0), this.camera && (this.camera.focusDistance = this._distance0)), this.transform.matrix.rotate(We(-this._pitch0), 1, 0, 0).rotate(We(this._yaw0), 0, 1, 0).translate(this._center0);
7297
7309
  }
@@ -7391,7 +7403,7 @@ const tn = () => {
7391
7403
  registerComponents: tn,
7392
7404
  registerComponent: ee,
7393
7405
  Node: Ae,
7394
- NodeVisitor: ce,
7406
+ NodeVisitor: le,
7395
7407
  FindNodeVisitor: pr
7396
7408
  };
7397
7409
  class rn {
@@ -7681,7 +7693,7 @@ class fn {
7681
7693
  throw new Error("Pipeline.activate(): calling base class method.");
7682
7694
  }
7683
7695
  }
7684
- class cn {
7696
+ class ln {
7685
7697
  constructor(e, r) {
7686
7698
  if (r.renderer)
7687
7699
  throw new Error("Invalid initialization of polyList renderer: the polyList is already controlled by another polyList renderer.");
@@ -7708,7 +7720,7 @@ class cn {
7708
7720
  }
7709
7721
  }
7710
7722
  var ve = /* @__PURE__ */ ((t) => (t[t.UNINITIALIZED = 0] = "UNINITIALIZED", t[t.TEXTURE = 1] = "TEXTURE", t[t.CUBE_MAP = 2] = "CUBE_MAP", t))(ve || {});
7711
- const ln = {
7723
+ const cn = {
7712
7724
  0: "UNINITIALIZED",
7713
7725
  1: "TEXTURE",
7714
7726
  2: "CUBE_MAP"
@@ -7721,7 +7733,7 @@ function Gr(t) {
7721
7733
  return 2;
7722
7734
  }
7723
7735
  function Ur(t) {
7724
- return ln[t];
7736
+ return cn[t];
7725
7737
  }
7726
7738
  class gn {
7727
7739
  constructor(e, r = new h([512, 512])) {
@@ -7807,7 +7819,7 @@ class gn {
7807
7819
  if (this.saveVertexBufferState(), this.type === 1)
7808
7820
  this.beginUpdate(), e(), this.endUpdate();
7809
7821
  else if (this.type === 2) {
7810
- const r = d.MakeIdentity(), i = d.MakePerspective(90, 1, 0.1, 1e5);
7822
+ const r = w.MakeIdentity(), i = w.MakePerspective(90, 1, 0.1, 1e5);
7811
7823
  for (let n = 0; n < 6; ++n) {
7812
7824
  const s = 1 + n;
7813
7825
  switch (s) {
@@ -7835,12 +7847,12 @@ class gn {
7835
7847
  }
7836
7848
  this.restoreVertexBufferState();
7837
7849
  }
7838
- readPixels(e, r, i, n, s, o) {
7850
+ readPixels(e, r, i, n) {
7839
7851
  }
7840
7852
  }
7841
7853
  class St {
7842
7854
  constructor(e) {
7843
- this._renderer = e, this._queues = [], this._viewMatrix = d.MakeIdentity(), this._projectionMatrix = d.MakeIdentity(), this._lights = [];
7855
+ this._renderer = e, this._queues = [], this._viewMatrix = w.MakeIdentity(), this._projectionMatrix = w.MakeIdentity(), this._lights = [];
7844
7856
  }
7845
7857
  get renderer() {
7846
7858
  return this._renderer;
@@ -7869,14 +7881,14 @@ class St {
7869
7881
  enableQueue(e, r, { beginOperation: i = null, endOperation: n = null, enabled: s = !0 } = {}) {
7870
7882
  const o = this.renderer.factory.pipeline(), a = this.renderer.factory.pipeline();
7871
7883
  if (e === k.TRANSPARENT_DEFAULT) {
7872
- const l = {
7884
+ const c = {
7873
7885
  enabled: !0,
7874
7886
  blendFuncSrc: R.SRC_ALPHA,
7875
7887
  blendFuncDst: R.ONE_MINUS_SRC_ALPHA,
7876
7888
  blendFuncSrcAlpha: R.ONE,
7877
7889
  blendFuncDstAlpha: R.ONE_MINUS_SRC_ALPHA
7878
7890
  };
7879
- o.setBlendState(l), a.setBlendState(l);
7891
+ o.setBlendState(c), a.setBlendState(c);
7880
7892
  }
7881
7893
  o.create(), a.cullFace = !1, a.create();
7882
7894
  const f = this.getQueue(e);
@@ -7907,16 +7919,16 @@ class St {
7907
7919
  const n = Pi(e.polyList, r.material);
7908
7920
  this._queues.forEach(({ layer: s, shader: o, queue: a, pipelines: f }) => {
7909
7921
  if (n & s) {
7910
- const { polyList: l } = e;
7911
- let w = null;
7912
- l.enableCullFace ? w = f.cullBackFace : w = f.cullFaceDisabled, a.push(new Dt({
7922
+ const { polyList: c } = e;
7923
+ let d = null;
7924
+ c.enableCullFace ? d = f.cullBackFace : d = f.cullFaceDisabled, a.push(new Dt({
7913
7925
  shader: o,
7914
7926
  polyListRenderer: e,
7915
7927
  materialRenderer: r,
7916
7928
  modelMatrix: i,
7917
7929
  viewMatrix: this.viewMatrix,
7918
7930
  projectionMatrix: this.projectionMatrix,
7919
- pipeline: w
7931
+ pipeline: d
7920
7932
  }));
7921
7933
  }
7922
7934
  });
@@ -7931,9 +7943,9 @@ class St {
7931
7943
  }), typeof r.endOperation == "function" && r.endOperation(e)) : console.warn(`No render queue found for layer ${e}`);
7932
7944
  }
7933
7945
  }
7934
- class Rt extends ce {
7946
+ class Rt extends le {
7935
7947
  constructor(e) {
7936
- super(), this._renderQueue = e, this._delta = 0, this._modelMatrix = d.MakeIdentity(), this._matrixStack = [];
7948
+ super(), this._renderQueue = e, this._delta = 0, this._modelMatrix = w.MakeIdentity(), this._matrixStack = [];
7937
7949
  }
7938
7950
  get delta() {
7939
7951
  return this._delta;
@@ -7945,13 +7957,13 @@ class Rt extends ce {
7945
7957
  return this._modelMatrix;
7946
7958
  }
7947
7959
  visit(e) {
7948
- this._matrixStack.push(new d(this._modelMatrix)), e.frame(this._delta, this._modelMatrix, this._renderQueue);
7960
+ this._matrixStack.push(new w(this._modelMatrix)), e.frame(this._delta, this._modelMatrix, this._renderQueue);
7949
7961
  }
7950
7962
  didVisit(e) {
7951
- this._modelMatrix = this._matrixStack[this._matrixStack.length - 1] || d.MakeIdentity(), this._matrixStack.pop();
7963
+ this._modelMatrix = this._matrixStack[this._matrixStack.length - 1] || w.MakeIdentity(), this._matrixStack.pop();
7952
7964
  }
7953
7965
  }
7954
- class un extends ce {
7966
+ class un extends le {
7955
7967
  constructor(e) {
7956
7968
  super(), this._renderer = e;
7957
7969
  }
@@ -7959,15 +7971,15 @@ class un extends ce {
7959
7971
  Ui(e, this._renderer);
7960
7972
  }
7961
7973
  }
7962
- class wn extends ce {
7974
+ class dn extends le {
7963
7975
  constructor() {
7964
7976
  super();
7965
7977
  }
7966
7978
  async asyncVisit(e) {
7967
- await lo(e);
7979
+ await co(e);
7968
7980
  }
7969
7981
  }
7970
- class _ extends ce {
7982
+ class _ extends le {
7971
7983
  constructor(e) {
7972
7984
  super(), this._callbackName = e, this._event = null;
7973
7985
  }
@@ -7981,9 +7993,9 @@ class _ extends ce {
7981
7993
  e[this._callbackName](this._event);
7982
7994
  }
7983
7995
  }
7984
- class dn {
7996
+ class wn {
7985
7997
  constructor(e) {
7986
- this._shadowMapSize = null, this._mainDirectionalLight = null, this._opaquePipeline = null, this._transparentPipeline = null, this._renderQueue = null, this._initVisitor = null, this._frameVisitor = null, this._skyCube = null, this._shadowRenderer = null, this._environment = null, this._defaultViewMatrix = d.MakeIdentity(), this._defaultProjectionMatrix = d.MakeIdentity(), this._sceneRoot = null, this._renderer = e, this._keyDownVisitor = new _("keyDown"), this._keyUpVisitor = new _("keyUp"), this._mouseUpVisitor = new _("mouseUp"), this._mouseDownVisitor = new _("mouseDown"), this._mouseMoveVisitor = new _("mouseMove"), this._mouseOutVisitor = new _("mouseOut"), this._mouseDragVisitor = new _("mouseDrag"), this._mouseWheelVisitor = new _("mouseWheel"), this._touchStartVisitor = new _("touchStart"), this._touchMoveVisitor = new _("touchMove"), this._touchEndVisitor = new _("touchEnd"), this._sceneEnvironment = null;
7998
+ this._shadowMapSize = null, this._mainDirectionalLight = null, this._opaquePipeline = null, this._transparentPipeline = null, this._renderQueue = null, this._initVisitor = null, this._frameVisitor = null, this._skyCube = null, this._shadowRenderer = null, this._environment = null, this._defaultViewMatrix = w.MakeIdentity(), this._defaultProjectionMatrix = w.MakeIdentity(), this._sceneRoot = null, this._renderer = e, this._keyDownVisitor = new _("keyDown"), this._keyUpVisitor = new _("keyUp"), this._mouseUpVisitor = new _("mouseUp"), this._mouseDownVisitor = new _("mouseDown"), this._mouseMoveVisitor = new _("mouseMove"), this._mouseOutVisitor = new _("mouseOut"), this._mouseDragVisitor = new _("mouseDrag"), this._mouseWheelVisitor = new _("mouseWheel"), this._touchStartVisitor = new _("touchStart"), this._touchMoveVisitor = new _("touchMove"), this._touchEndVisitor = new _("touchEnd"), this._sceneEnvironment = null;
7987
7999
  }
7988
8000
  // Implement in subclasses
7989
8001
  get brightness() {
@@ -8009,7 +8021,7 @@ class dn {
8009
8021
  blendFuncDst: R.ONE_MINUS_SRC_ALPHA,
8010
8022
  blendFuncSrcAlpha: R.ONE,
8011
8023
  blendFuncDstAlpha: R.ONE_MINUS_SRC_ALPHA
8012
- }), this._transparentPipeline?.create(), this._renderQueue = new St(this.renderer), this._initVisitor = new wn(), this._frameVisitor = new Rt(this._renderQueue), this._skyCube = this.renderer.factory.skyCube(), this._shadowRenderer = this.renderer.factory.shadowRenderer(), await this._shadowRenderer?.create(this._shadowMapSize);
8024
+ }), this._transparentPipeline?.create(), this._renderQueue = new St(this.renderer), this._initVisitor = new dn(), this._frameVisitor = new Rt(this._renderQueue), this._skyCube = this.renderer.factory.skyCube(), this._shadowRenderer = this.renderer.factory.shadowRenderer(), await this._shadowRenderer?.create(this._shadowMapSize);
8013
8025
  }
8014
8026
  async setEnvironment(e) {
8015
8027
  this._environment = e, this._environment?.environmentMap && this._skyCube?.load(this._environment?.environmentMap);
@@ -8018,13 +8030,13 @@ class dn {
8018
8030
  return this._environment;
8019
8031
  }
8020
8032
  get defaultViewMatrix() {
8021
- return this._defaultViewMatrix || d.MakeIdentity();
8033
+ return this._defaultViewMatrix || w.MakeIdentity();
8022
8034
  }
8023
8035
  set defaultViewMatrix(e) {
8024
8036
  this._defaultViewMatrix = e;
8025
8037
  }
8026
8038
  get defaultProjectionMatrix() {
8027
- return this._defaultProjectionMatrix || d.MakePerspective(55, this.renderer.viewport.aspectRatio, 0.2, 100);
8039
+ return this._defaultProjectionMatrix || w.MakePerspective(55, this.renderer.viewport.aspectRatio, 0.2, 100);
8028
8040
  }
8029
8041
  set defaultProjectionMatrix(e) {
8030
8042
  this._defaultProjectionMatrix = e;
@@ -8049,7 +8061,7 @@ class dn {
8049
8061
  e.sceneChanged && await e.asyncAccept(this._initVisitor), this._sceneRoot = e, this._renderQueue?.newFrame(), this._frameVisitor.delta = r, this._frameVisitor.modelMatrix.identity();
8050
8062
  const i = j.GetMain(e);
8051
8063
  let n = this.defaultViewMatrix, s = this.defaultProjectionMatrix;
8052
- i && (s = i.projectionMatrix, n = d.GetInverted(oe.GetWorldMatrix(i.node))), this._renderQueue.viewMatrix = n, this._renderQueue.projectionMatrix = s, e.accept(this._frameVisitor), this._skyCube?.updateRenderState({
8064
+ i && (s = i.projectionMatrix, n = w.GetInverted(oe.GetWorldMatrix(i.node))), this._renderQueue.viewMatrix = n, this._renderQueue.projectionMatrix = s, e.accept(this._frameVisitor), this._skyCube?.updateRenderState({
8053
8065
  viewMatrix: n,
8054
8066
  projectionMatrix: s
8055
8067
  });
@@ -8059,7 +8071,7 @@ class dn {
8059
8071
  throw new Error("SceneRenderer.draw(): SceneRenderer not initialized. Call SceneRenderer.init() first.");
8060
8072
  const i = ge.GetMainDirectionalLight(this._sceneRoot), n = j.GetMain(this._sceneRoot);
8061
8073
  if (i && n) {
8062
- const s = n.focusDistance, o = d.MakeOrtho(-s, s, -s, s, 0.1, 500);
8074
+ const s = n.focusDistance, o = w.MakeOrtho(-s, s, -s, s, 0.1, 500);
8063
8075
  i.light.projection = o;
8064
8076
  }
8065
8077
  i && n && this._shadowRenderer.update(n, i, this._renderQueue), e && this.renderer.frameBuffer.clear(), this.environment && !this.environment.updated && this.environment.updateMaps(), r && (!this._sceneEnvironment || this._sceneEnvironment.showSkybox) && this._skyCube?.draw(), this._renderQueue.draw(k.OPAQUE_DEFAULT), this._renderQueue.draw(k.TRANSPARENT_DEFAULT);
@@ -8295,9 +8307,9 @@ function s0(t) {
8295
8307
  const i = e.substring(0, r).trim(), n = e.substring(r + 1, e.lastIndexOf("}")).trim(), s = i.indexOf("("), o = i.lastIndexOf(")");
8296
8308
  if (s === -1 || o === -1)
8297
8309
  throw new Error("Invalid function signature: missing parentheses");
8298
- const a = i.substring(s + 1, o).trim(), l = i.substring(0, s).trim().split(/\s+/);
8299
- let w, P;
8300
- return l.length >= 2 ? (w = l.slice(0, -1).join(" "), P = l[l.length - 1]) : (w = "void", P = l[0]), new Q(w, P, a, ` {
8310
+ const a = i.substring(s + 1, o).trim(), c = i.substring(0, s).trim().split(/\s+/);
8311
+ let d, P;
8312
+ return c.length >= 2 ? (d = c.slice(0, -1).join(" "), P = c[c.length - 1]) : (d = "void", P = c[0]), new Q(d, P, a, ` {
8301
8313
  ${n}
8302
8314
  }`);
8303
8315
  }
@@ -8510,7 +8522,7 @@ const Er = new Q("vec3", "fresnelSchlick", "float cosTheta, vec3 F0", `{
8510
8522
  0, 0, contrast, 0,
8511
8523
  t, t, t, 1);
8512
8524
  return contrastMat * brightnessMat * color;
8513
- }`, []), c0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8525
+ }`, []), l0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8514
8526
  __proto__: null,
8515
8527
  SRGB2Lineal: A0,
8516
8528
  applyConvolution: pn,
@@ -8587,10 +8599,10 @@ class Dn extends V {
8587
8599
  throw new Error("SelectionHighlightShader: shader program is not loaded");
8588
8600
  const o = this.renderer, { gl: a, viewport: f } = o;
8589
8601
  o.state.shaderProgram = this._program, a.activeTexture(a.TEXTURE0), this._program.uniform1i("uTexture", 0), this._program.uniform2f("uTexSize", f[2], f[3]), this._program.uniform1f("uBorderWidth", this._borderWidth), this._program.uniform4fv("uBorderColor", this._borderColor), this._program.uniform1fv("uConvMatrix", this._convMatrix);
8590
- const l = r.material, w = r.getTextureRenderer("albedoTexture")?.getApiObject();
8591
- if (w && l.albedoTexture) {
8592
- const P = Be[l.albedoTexture.target];
8593
- a.bindTexture(a[P], w);
8602
+ const c = r.material, d = r.getTextureRenderer("albedoTexture")?.getApiObject();
8603
+ if (d && c.albedoTexture) {
8604
+ const P = Be[c.albedoTexture.target];
8605
+ a.bindTexture(a[P], d);
8594
8606
  } else
8595
8607
  throw new Error("SelectionHighlightShader: invalid material setup. The albedoTexture material attribute must to be a texture");
8596
8608
  this._program.positionAttribPointer(e.positionAttribParams("position")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("texCoord"));
@@ -8599,9 +8611,9 @@ class Dn extends V {
8599
8611
  this._program && (T.Delete(this._program), this._program = null);
8600
8612
  }
8601
8613
  }
8602
- class l0 {
8614
+ class c0 {
8603
8615
  constructor(e) {
8604
- this._renderer = e;
8616
+ this._targetTexture = null, this._renderBuffer = null, this._shader = null, this._renderQueue = null, this._frameVisitor = null, this._selectionDrawShader = null, this._renderer = e;
8605
8617
  }
8606
8618
  async init() {
8607
8619
  const e = this._renderer;
@@ -8611,45 +8623,49 @@ class l0 {
8611
8623
  this._renderBuffer.size = new h(e, r);
8612
8624
  }
8613
8625
  draw(e, r) {
8614
- const i = d.GetInverted(oe.GetWorldMatrix(r.node));
8626
+ if (!this._renderQueue || !this._frameVisitor || !this._renderBuffer || !this._targetTexture)
8627
+ return;
8628
+ const i = w.GetInverted(oe.GetWorldMatrix(r.node));
8615
8629
  this._renderQueue.viewMatrix = i, this._renderQueue.projectionMatrix = r.projectionMatrix, this._renderQueue.newFrame(), this._frameVisitor.delta = 0, this._frameVisitor.modelMatrix.identity(), e.accept(this._frameVisitor), this._renderBuffer.update(() => {
8616
- this._renderBuffer.frameBuffer.clear(), this._renderQueue.draw(k.SELECTION_DEFAULT);
8630
+ this._renderBuffer?.frameBuffer.clear(), this._renderQueue?.draw(k.SELECTION_DEFAULT);
8617
8631
  });
8618
8632
  const n = this._selectionDrawShader;
8619
8633
  this._renderer.presentTexture(this._targetTexture, { clearBuffers: !1, shader: n });
8620
8634
  }
8621
8635
  destroy() {
8622
- this._renderBuffer.destroy(), this._targetTexture.destroy(), this._renderBuffer = null, this._targetTexture = null;
8636
+ this._renderBuffer?.destroy(), this._targetTexture?.destroy(), this._renderBuffer = null, this._targetTexture = null;
8623
8637
  }
8624
8638
  }
8625
8639
  class g0 {
8626
8640
  constructor(e) {
8627
- this._renderer = e;
8641
+ this._targetTexture = null, this._renderBuffer = null, this._shader = null, this._renderQueue = null, this._frameVisitor = null, this._renderer = e;
8628
8642
  }
8629
8643
  async init() {
8630
8644
  const e = this._renderer;
8631
8645
  this._targetTexture = new x(), this._targetTexture.renderTargetAttachment = Y.COLOR_ATTACHMENT_0, this._targetTexture.componentFormat = ie.UNSIGNED_BYTE, this._targetTexture.wrapModeXY = U.CLAMP, this._renderBuffer = e.factory.renderBuffer(), await this._renderBuffer.attachTexture(this._targetTexture), this._shader = new br(e), await this._shader.load(), this._renderQueue = new St(e), this._renderQueue.enableQueue(k.SELECTION_DEFAULT, this._shader), this._frameVisitor = new Rt(this._renderQueue);
8632
8646
  }
8633
8647
  reshape(e, r) {
8634
- this._renderBuffer.size = new h(e, r);
8648
+ this._renderBuffer && (this._renderBuffer.size = new h(e, r));
8635
8649
  }
8636
8650
  draw(e, r, i, n, s = 1, o = 1) {
8637
- const a = d.GetInverted(oe.GetWorldMatrix(r.node));
8651
+ if (!this._renderQueue || !this._frameVisitor || !this._renderBuffer)
8652
+ return;
8653
+ const a = w.GetInverted(oe.GetWorldMatrix(r.node));
8638
8654
  this._renderQueue.viewMatrix = a, this._renderQueue.projectionMatrix = r.projectionMatrix, this._renderQueue.newFrame(), this._frameVisitor.delta = 0, this._frameVisitor.modelMatrix.identity(), e.accept(this._frameVisitor);
8639
8655
  let f = null;
8640
8656
  return this._renderBuffer.update(() => {
8641
- this._renderBuffer.frameBuffer.clear(), this._renderQueue.draw(k.SELECTION_DEFAULT), f = this._renderBuffer.readPixels(i, n, s, o);
8657
+ this._renderBuffer?.frameBuffer.clear(), this._renderQueue?.draw(k.SELECTION_DEFAULT), f = this._renderBuffer?.readPixels(i, n, s, o);
8642
8658
  }), f;
8643
8659
  }
8644
8660
  destroy() {
8645
- this._renderBuffer.destroy(), this._targetTexture.destroy(), this._renderBuffer = null, this._targetTexture = null;
8661
+ this._renderBuffer?.destroy(), this._targetTexture?.destroy(), this._renderBuffer = null, this._targetTexture = null;
8646
8662
  }
8647
8663
  }
8648
8664
  var mt = /* @__PURE__ */ ((t) => (t[t.OBJECT = 0] = "OBJECT", t[t.POLY_LIST = 1] = "POLY_LIST", t))(mt || {});
8649
8665
  const At = (t) => "" + t[0] + t[1] + t[2];
8650
- class u0 extends ce {
8666
+ class u0 extends le {
8651
8667
  constructor() {
8652
- super(), this._selectionMode = mt.POLY_LIST, this._elements = {};
8668
+ super(), this._r = 0, this._g = 0, this._b = 0, this._selectionMode = mt.POLY_LIST, this._elements = {};
8653
8669
  }
8654
8670
  set selectionMode(e) {
8655
8671
  this._selectionMode = e, this.clear();
@@ -8672,6 +8688,8 @@ class u0 extends ce {
8672
8688
  return this._r = r[0], this._g = r[1], this._b = r[2], new p([r[0] / 255, r[1] / 255, r[2] / 255, 1]);
8673
8689
  }
8674
8690
  findElement(e) {
8691
+ if (!e)
8692
+ return null;
8675
8693
  const r = [
8676
8694
  e[0],
8677
8695
  e[1],
@@ -8698,9 +8716,9 @@ class u0 extends ce {
8698
8716
  }
8699
8717
  }
8700
8718
  }
8701
- class w0 {
8719
+ class d0 {
8702
8720
  constructor(e) {
8703
- this._renderer = e, this._sceneRoot = null, this._camera = null, this._selectionMode = mt.POLY_LIST, this._multiSelect = !1, this._selection = [], this._selectionChangedCallbacks = {};
8721
+ this._selectionBuffer = null, this._selectionIdVisitor = null, this._downPosition = new h(), this._viewportSize = [1, 1], this._renderer = e, this._sceneRoot = null, this._camera = null, this._selectionMode = mt.POLY_LIST, this._multiSelect = !1, this._selection = [], this._selectionChangedCallbacks = {};
8704
8722
  }
8705
8723
  async init() {
8706
8724
  this._selectionBuffer = new g0(this._renderer), await this._selectionBuffer.init(), this._selectionIdVisitor = new u0();
@@ -8724,7 +8742,7 @@ class w0 {
8724
8742
  this._camera = e, this.clearSelection();
8725
8743
  }
8726
8744
  get camera() {
8727
- return this._camera ? this._camera : (this._camera = j.GetMain(this.sceneRoot), this._camera);
8745
+ return this._camera ? this._camera : this.sceneRoot ? (this._camera = j.GetMain(this.sceneRoot), this._camera) : null;
8728
8746
  }
8729
8747
  set selectionMode(e) {
8730
8748
  this._selectionMode = e, this.clearSelection();
@@ -8746,11 +8764,13 @@ class w0 {
8746
8764
  this._selectionChangedCallbacks[e](this._selection);
8747
8765
  }
8748
8766
  mouseUp(e) {
8767
+ if (!this._selectionBuffer || !this._selectionIdVisitor || !this.camera || !this.sceneRoot)
8768
+ return;
8749
8769
  const r = new h([e.x, e.y]);
8750
8770
  if (h.Distance(this._downPosition, r) < 2) {
8751
- this._selectionIdVisitor.selectionMode = this.selectionMode, this.sceneRoot.accept(this._selectionIdVisitor);
8771
+ this._selectionIdVisitor && this.sceneRoot && (this._selectionIdVisitor.selectionMode = this.selectionMode, this.sceneRoot.accept(this._selectionIdVisitor));
8752
8772
  const i = window.devicePixelRatio || 1;
8753
- this._selectionBuffer.reshape(this._viewportSize[0], this._viewportSize[1]);
8773
+ this._selectionBuffer?.reshape(this._viewportSize[0], this._viewportSize[1]);
8754
8774
  const n = this._selectionBuffer.draw(this.sceneRoot, this.camera, e.x * i, e.y * i), s = this._selectionIdVisitor.findElement(n), o = () => this._selection.find((a) => a.polyList === s.polyList && a.drawable === s.drawable);
8755
8775
  s && this._multiSelect && !o() ? (this._selection.push(s), this.triggerSelectionChanged()) : s && !o() ? (this._selection = [s], this.triggerSelectionChanged()) : !s && !this._multiSelect && this._selection.length > 0 && (this._selection = [], this.triggerSelectionChanged()), this._selection.forEach((a) => a.polyList.selected = !0);
8756
8776
  }
@@ -8763,7 +8783,7 @@ class w0 {
8763
8783
  touchEnd(e) {
8764
8784
  }
8765
8785
  destroy() {
8766
- this._selectionBuffer.destroy();
8786
+ this._selectionBuffer?.destroy();
8767
8787
  }
8768
8788
  }
8769
8789
  const Yr = {
@@ -8875,10 +8895,10 @@ class En extends V {
8875
8895
  throw new Error("PresentDebugFramebufferShader: shader program is not loaded");
8876
8896
  const o = this.renderer, { gl: a } = o;
8877
8897
  o.state.shaderProgram = this._program, a.activeTexture(a.TEXTURE0), this._program.uniform1i("uTexture", 0);
8878
- const f = r.material, l = r.getTextureRenderer("albedoTexture")?.getApiObject();
8879
- if (l && f.albedoTexture) {
8880
- const w = Be[f.albedoTexture.target];
8881
- a.bindTexture(a[w], l);
8898
+ const f = r.material, c = r.getTextureRenderer("albedoTexture")?.getApiObject();
8899
+ if (c && f.albedoTexture) {
8900
+ const d = Be[f.albedoTexture.target];
8901
+ a.bindTexture(a[d], c);
8882
8902
  } else
8883
8903
  throw new Error("PresentDebugFramebufferShader: invalid material setup. The albedoTexture material attribute must to be a texture");
8884
8904
  this._program.positionAttribPointer(e.positionAttribParams("position")), this._program.texCoordAttribPointer(e.texCoord0AttribParams("texCoord"));
@@ -8887,7 +8907,7 @@ class En extends V {
8887
8907
  this._program && (T.Delete(this._program), this._program = null);
8888
8908
  }
8889
8909
  }
8890
- const qt = {}, Vr = (t, e) => (!t && e ? t = d.MakeTranslation(e) : t || (t = d.MakeIdentity()), t);
8910
+ const qt = {}, Vr = (t, e) => (!t && e ? t = w.MakeTranslation(e) : t || (t = w.MakeIdentity()), t);
8891
8911
  class xe {
8892
8912
  static Get(e) {
8893
8913
  return qt[e.uniqueId] || (qt[e.uniqueId] = new xe(e)), qt[e.uniqueId];
@@ -8925,10 +8945,10 @@ class xe {
8925
8945
  this._renderBuffer.size = new h(e, r);
8926
8946
  }
8927
8947
  draw(e) {
8928
- const i = d.GetInverted(oe.GetWorldMatrix(e.node)), n = e.projectionMatrix;
8948
+ const i = w.GetInverted(oe.GetWorldMatrix(e.node)), n = e.projectionMatrix;
8929
8949
  this._renderBuffer.update(() => {
8930
8950
  this._renderBuffer.frameBuffer.clear(), this._objects.forEach((o) => {
8931
- const f = d.MakeScale(o.scale, o.scale, o.scale).mult(o.transformMatrix);
8951
+ const f = w.MakeScale(o.scale, o.scale, o.scale).mult(o.transformMatrix);
8932
8952
  this._materialRenderer.material.albedo = o.color, o.renderer.bindBuffers(), this._shader.setup(
8933
8953
  o.renderer,
8934
8954
  this._materialRenderer,
@@ -8945,7 +8965,7 @@ class xe {
8945
8965
  this._renderBuffer.destroy(), this._targetTexture.destroy(), this._renderBuffer = null, this._targetTexture = null;
8946
8966
  }
8947
8967
  }
8948
- class d0 extends rn {
8968
+ class w0 extends rn {
8949
8969
  constructor() {
8950
8970
  super(...arguments), this._sceneRoot = null, this._sceneRenderer = null, this._environment = null, this._selectionManager = null, this._selectionHighlight = null, this._debugRenderer = null;
8951
8971
  }
@@ -8989,7 +9009,7 @@ class d0 extends rn {
8989
9009
  async init() {
8990
9010
  if (tn(), await this.registerLoaders(), this._sceneRoot = await this.loadScene(), !this._sceneRoot)
8991
9011
  throw new Error("SceneAppController.init: Failed to load scene.");
8992
- this._environment = await this.loadEnvironment(), this._environment || (this._environment = this.renderer.factory.environment(), await this._environment?.load()), this._sceneRenderer = this.renderer.factory.scene(), await this.sceneRenderer?.init({ shadowMapSize: new h(4096, 4096) }), this.environment && await this.sceneRenderer?.setEnvironment(this.environment), await this.sceneRenderer?.bindRenderer(this.sceneRoot), this.selectionManagerEnabled && (this._selectionManager = new w0(this.renderer), await this._selectionManager.init(), this._selectionManager.sceneRoot = this.sceneRoot), this.selectionHighlightEnabled && (this._selectionHighlight = new l0(this.renderer), await this._selectionHighlight.init()), this._debugRenderer = xe.Get(this.renderer), await this._debugRenderer?.init(), await this.loadDone();
9012
+ this._environment = await this.loadEnvironment(), this._environment || (this._environment = this.renderer.factory.environment(), await this._environment?.load()), this._sceneRenderer = this.renderer.factory.scene(), await this.sceneRenderer?.init({ shadowMapSize: new h(4096, 4096) }), this.environment && await this.sceneRenderer?.setEnvironment(this.environment), await this.sceneRenderer?.bindRenderer(this.sceneRoot), this.selectionManagerEnabled && (this._selectionManager = new d0(this.renderer), await this._selectionManager.init(), this._selectionManager.sceneRoot = this.sceneRoot), this.selectionHighlightEnabled && (this._selectionHighlight = new c0(this.renderer), await this._selectionHighlight.init()), this._debugRenderer = xe.Get(this.renderer), await this._debugRenderer?.init(), await this.loadDone();
8993
9013
  }
8994
9014
  reshape(e, r) {
8995
9015
  !this.sceneRoot || !this.sceneRenderer || (this.sceneRenderer.resize(this.sceneRoot, e, r), this.selectionManager?.setViewportSize(e, r), this.selectionHighlight?.setViewportSize(e, r), this._debugRenderer?.setViewportSize(e, r));
@@ -9002,7 +9022,7 @@ class d0 extends rn {
9002
9022
  return;
9003
9023
  this.sceneRenderer.draw();
9004
9024
  const e = j.GetMain(this.sceneRoot);
9005
- this.selectionHighlight && this.selectionHighlight.draw(this.sceneRoot, e), e && this._debugRenderer?.draw(e);
9025
+ e && (this.selectionHighlight && this.selectionHighlight.draw(this.sceneRoot, e), this._debugRenderer?.draw(e));
9006
9026
  }
9007
9027
  destroy() {
9008
9028
  this.sceneRenderer?.destroy(), this.selectionManagerEnabled && this.selectionManager?.destroy();
@@ -9126,13 +9146,13 @@ class Qn {
9126
9146
  let o = null;
9127
9147
  if (r instanceof ge ? (o = r.node, s = r) : r instanceof Ae && (o = r, s = r.lightComponent || null), !o || !s)
9128
9148
  throw Error("ShadowRenderer.getLightPosition(): invalid light. Light must be a Node or a LightComponent");
9129
- const a = n.focusDistance, f = oe.GetWorldMatrix(i), l = h.Add(d.GetPosition(f), h.Mult(f.forwardVector, -a)), w = oe.GetWorldMatrix(o), P = d.GetRotation(w).forwardVector;
9149
+ const a = n.focusDistance, f = oe.GetWorldMatrix(i), c = h.Add(w.GetPosition(f), h.Mult(f.forwardVector, -a)), d = oe.GetWorldMatrix(o), P = w.GetRotation(d).forwardVector;
9130
9150
  P.scale(this._shadowMapRenderDistance);
9131
- const C = h.Add(l, P);
9132
- return w.setPosition(C), this._debug && (xe.Get(this._renderer).drawSphere({ radius: 0.1, color: p.Red(), position: l }), xe.Get(this.renderer).drawSphere({ radius: 0.1, color: p.Blue(), position: C }), xe.Get(this.renderer).drawArrow({ length: 0.8, color: p.Green(), transformMatrix: w })), w;
9151
+ const C = h.Add(c, P);
9152
+ return d.setPosition(C), this._debug && (xe.Get(this._renderer).drawSphere({ radius: 0.1, color: p.Red(), position: c }), xe.Get(this.renderer).drawSphere({ radius: 0.1, color: p.Blue(), position: C }), xe.Get(this.renderer).drawArrow({ length: 0.8, color: p.Green(), transformMatrix: d })), d;
9133
9153
  }
9134
9154
  update(e, r, i) {
9135
- const n = d.GetInverted(this.getLightTransform(e, r));
9155
+ const n = w.GetInverted(this.getLightTransform(e, r));
9136
9156
  this._renderBuffer?.update(() => {
9137
9157
  this._renderBuffer.renderer.state.clear();
9138
9158
  const s = k.OPAQUE_DEFAULT, o = i.getQueue(s);
@@ -9189,10 +9209,10 @@ class Tn extends V {
9189
9209
  throw new Error("SkyCubeShader: shader program is not loaded");
9190
9210
  const o = this.renderer, { gl: a } = o;
9191
9211
  o.state.shaderProgram = this._program;
9192
- const f = d.Mult(s, n);
9212
+ const f = w.Mult(s, n);
9193
9213
  this._program.uniformMatrix4fv("uMVP", !1, f), a.activeTexture(a.TEXTURE0), this._program.uniform1i("uCubemap", 0);
9194
- const l = r.getTextureRenderer("albedoTexture")?.getApiObject();
9195
- a.bindTexture(a.TEXTURE_CUBE_MAP, l), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
9214
+ const c = r.getTextureRenderer("albedoTexture")?.getApiObject();
9215
+ a.bindTexture(a.TEXTURE_CUBE_MAP, c), this._program.positionAttribPointer(e.positionAttribParams("vertPosition"));
9196
9216
  }
9197
9217
  destroy() {
9198
9218
  this._program && (T.Delete(this._program), this._program = null);
@@ -9216,7 +9236,7 @@ class yn {
9216
9236
  this._texture = e, this._material = new ne(), this._material.albedoTexture = this._texture, this._shader = r ? new r(this.renderer) : new Tn(this.renderer), await this._shader?.load();
9217
9237
  }
9218
9238
  updateRenderState({ viewMatrix: e, projectionMatrix: r = null }) {
9219
- const i = d.GetRotation(e);
9239
+ const i = w.GetRotation(e);
9220
9240
  if (this._renderState)
9221
9241
  this._renderState.viewMatrix = i, r && (this._renderState.projectionMatrix = r);
9222
9242
  else {
@@ -9227,7 +9247,7 @@ class yn {
9227
9247
  polyListRenderer: this.polyListRenderer,
9228
9248
  materialRenderer: this.renderer.factory.material(this._material),
9229
9249
  viewMatrix: i,
9230
- projectionMatrix: r || d.MakeIdentity()
9250
+ projectionMatrix: r || w.MakeIdentity()
9231
9251
  });
9232
9252
  }
9233
9253
  return this._renderState;
@@ -9404,13 +9424,13 @@ class Ln extends fn {
9404
9424
  }
9405
9425
  }
9406
9426
  var Se = /* @__PURE__ */ ((t) => (t[t.ARRAY_BUFFER = 0] = "ARRAY_BUFFER", t[t.ELEMENT_ARRAY_BUFFER = 1] = "ELEMENT_ARRAY_BUFFER", t[t.COPY_READ_BUFFER = 2] = "COPY_READ_BUFFER", t[t.COPY_WRITE_BUFFER = 3] = "COPY_WRITE_BUFFER", t[t.TRANSFORM_FEEDBACK_BUFFER = 4] = "TRANSFORM_FEEDBACK_BUFFER", t[t.UNIFORM_BUFFER = 5] = "UNIFORM_BUFFER", t[t.PIXEL_PACK_BUFFER = 6] = "PIXEL_PACK_BUFFER", t[t.PIXEL_UNPACK_BUFFER = 7] = "PIXEL_UNPACK_BUFFER", t))(Se || {}), In = /* @__PURE__ */ ((t) => (t[t.STATIC_DRAW = 0] = "STATIC_DRAW", t[t.DYNAMIC_DRAW = 1] = "DYNAMIC_DRAW", t[t.STREAM_DRAW = 2] = "STREAM_DRAW", t[t.STATIC_READ = 3] = "STATIC_READ", t[t.DYNAMIC_READ = 4] = "DYNAMIC_READ", t[t.STREAM_READ = 5] = "STREAM_READ", t[t.STATIC_COPY = 6] = "STATIC_COPY", t[t.DYNAMIC_COPY = 7] = "DYNAMIC_COPY", t[t.STREAM_COPY = 8] = "STREAM_COPY", t))(In || {});
9407
- const Xe = [], ke = [], de = {};
9427
+ const Xe = [], ke = [], we = {};
9408
9428
  let Jr = 0;
9409
9429
  class he {
9410
9430
  static Delete(e) {
9411
9431
  if (!e._buffer || !e._gl) return;
9412
9432
  const r = e._gl._bg2_id_, i = e._buffer._bg2e_id_;
9413
- de[r]?.[i] && delete de[r][i], e._gl.deleteBuffer(e._buffer), e._buffer = null;
9433
+ we[r]?.[i] && delete we[r][i], e._gl.deleteBuffer(e._buffer), e._buffer = null;
9414
9434
  }
9415
9435
  static CreateArrayBuffer(e, r, i = 0) {
9416
9436
  const n = new he(e);
@@ -9435,9 +9455,9 @@ class he {
9435
9455
  else
9436
9456
  return;
9437
9457
  const n = e._bg2_id_;
9438
- de[n] = de[n] || {};
9458
+ we[n] = we[n] || {};
9439
9459
  const s = e.getParameter(i);
9440
- return de[n]?.[s?._bg2e_id_];
9460
+ return we[n]?.[s?._bg2e_id_];
9441
9461
  }
9442
9462
  get id() {
9443
9463
  return this._buffer?._bg2e_id_;
@@ -9445,7 +9465,7 @@ class he {
9445
9465
  constructor(e) {
9446
9466
  this._gl = e, this._buffer = e.createBuffer(), e._bg2_id_ = e._bg2_id_ ?? ++Jr, this._buffer._bg2e_id_ = ++Jr;
9447
9467
  const r = e._bg2_id_;
9448
- de[r] = de[r] || {}, de[r][this._buffer._bg2e_id_] = this, Xe.length === 0 && (Xe.push(e.ARRAY_BUFFER), Xe.push(e.ELEMENT_ARRAY_BUFFER)), ke.length === 0 && (ke.push(e.STATIC_DRAW), ke.push(e.DYNAMIC_DRAW), ke.push(e.STREAM_DRAW));
9468
+ we[r] = we[r] || {}, we[r][this._buffer._bg2e_id_] = this, Xe.length === 0 && (Xe.push(e.ARRAY_BUFFER), Xe.push(e.ELEMENT_ARRAY_BUFFER)), ke.length === 0 && (ke.push(e.STATIC_DRAW), ke.push(e.DYNAMIC_DRAW), ke.push(e.STREAM_DRAW));
9449
9469
  }
9450
9470
  get buffer() {
9451
9471
  return this._buffer;
@@ -9461,7 +9481,7 @@ class he {
9461
9481
  );
9462
9482
  }
9463
9483
  }
9464
- class Sn extends cn {
9484
+ class Sn extends ln {
9465
9485
  constructor(e, r) {
9466
9486
  super(e, r), this._vertexBuffer = null, this._indexBuffer = null, this._indexArrayFormat = null, this._stride = 0, this._offsets = { vertex: 0, normal: 0, texCoord0: 0, texCoord1: 0, texCoord2: 0, color: 0, tangent: 0 };
9467
9487
  }
@@ -9487,8 +9507,8 @@ class Sn extends cn {
9487
9507
  }
9488
9508
  this._stride = 3;
9489
9509
  const s = 0, o = 3;
9490
- let a = 3, f = 3, l = 3, w = 3, P = 3;
9491
- this.hasNormal && (this._stride += 3, a += 3, f += 3, l += 3, w += 3, P += 3), this.hasTexCoord0 && (this._stride += 2, f += 2, l += 2, w += 2, P += 2), this.hasTexCoord1 && (this._stride += 2, l += 2, w += 2, P += 2), this.hasTexCoord2 && (this._stride += 2, w += 2, P += 2), this.hasColor && (this._stride += 4, P += 4), this.hasTangent && (this._stride += 3), this._offsets = { vertex: s, normal: o, texCoord0: a, texCoord1: f, texCoord2: l, color: w, tangent: P }, this._vertexBuffer = he.CreateArrayBuffer(e, new Float32Array(n));
9510
+ let a = 3, f = 3, c = 3, d = 3, P = 3;
9511
+ this.hasNormal && (this._stride += 3, a += 3, f += 3, c += 3, d += 3, P += 3), this.hasTexCoord0 && (this._stride += 2, f += 2, c += 2, d += 2, P += 2), this.hasTexCoord1 && (this._stride += 2, c += 2, d += 2, P += 2), this.hasTexCoord2 && (this._stride += 2, d += 2, P += 2), this.hasColor && (this._stride += 4, P += 4), this.hasTangent && (this._stride += 3), this._offsets = { vertex: s, normal: o, texCoord0: a, texCoord1: f, texCoord2: c, color: d, tangent: P }, this._vertexBuffer = he.CreateArrayBuffer(e, new Float32Array(n));
9492
9512
  const C = this.polyList.index.length < 65535 ? new Uint16Array(this.polyList.index) : new Uint32Array(this.polyList.index);
9493
9513
  this._indexBuffer = he.CreateElementArrayBuffer(e, C), this._indexArrayFormat = C instanceof Uint16Array ? e.UNSIGNED_SHORT : e.UNSIGNED_INT;
9494
9514
  }
@@ -9670,13 +9690,13 @@ class Rn extends gn {
9670
9690
  throw new Error("Unexpected number of texture attachments rendering cube map. The cube map renderer supports only one color attachment.");
9671
9691
  this.destroy(), this._framebuffers = [], this._depthBuffers = [];
9672
9692
  const { width: a, height: f } = s.size;
9673
- for (let l = 0; l < 6; ++l) {
9674
- const w = r.createFramebuffer();
9675
- r.bindFramebuffer(r.FRAMEBUFFER, w), this._framebuffers.push(w), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_CUBE_MAP_POSITIVE_X + l, n, 0);
9693
+ for (let c = 0; c < 6; ++c) {
9694
+ const d = r.createFramebuffer();
9695
+ r.bindFramebuffer(r.FRAMEBUFFER, d), this._framebuffers.push(d), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_CUBE_MAP_POSITIVE_X + c, n, 0);
9676
9696
  const P = r.createRenderbuffer();
9677
9697
  if (this._depthBuffers.push(P), r.bindRenderbuffer(r.RENDERBUFFER, P), r.renderbufferStorage(r.RENDERBUFFER, r.DEPTH_COMPONENT16, a, f), r.framebufferRenderbuffer(r.FRAMEBUFFER, r.DEPTH_ATTACHMENT, r.RENDERBUFFER, P), r.checkFramebufferStatus(r.FRAMEBUFFER) != r.FRAMEBUFFER_COMPLETE) {
9678
9698
  const C = r.checkFramebufferStatus(r.FRAMEBUFFER);
9679
- throw new Error(`Cubemap frame buffer not complete in cube side #${l}: ${b0(r, C)}`);
9699
+ throw new Error(`Cubemap frame buffer not complete in cube side #${c}: ${b0(r, C)}`);
9680
9700
  }
9681
9701
  }
9682
9702
  this.setUpdated(!0);
@@ -10295,7 +10315,7 @@ class Xn extends V {
10295
10315
  throw new Error("BasicPBRLightShader: Invalid light array set.");
10296
10316
  this._lights = e, this._lightTypes = [], this._lightPositions = [], this._lightDirections = [], this._lightColors = [], this._lightIntensities = [], this._lights.forEach((r, i) => {
10297
10317
  this._lightTypes.push(r.type);
10298
- const n = this._lightTransforms[i], s = n && d.GetRotation(n), o = new h(r.position), a = new h(r.direction);
10318
+ const n = this._lightTransforms[i], s = n && w.GetRotation(n), o = new h(r.position), a = new h(r.direction);
10299
10319
  this._lightPositions.push(n ? n.multVector(o).xyz : o), this._lightDirections.push(s ? s.multVector(a).xyz.normalize() : a), this._lightColors.push(new h(r.color)), this._lightIntensities.push(r.intensity);
10300
10320
  }), this._program = z0.apply(this, [this.renderer, this._lights.length]);
10301
10321
  }
@@ -10322,18 +10342,18 @@ class Xn extends V {
10322
10342
  throw new Error("BasicPBRLightShader: lights array not specified");
10323
10343
  const a = r.material;
10324
10344
  r.mergeTextures(), o.state.shaderProgram = this._program;
10325
- const f = d.GetNormalMatrix(i);
10326
- if (this._program.bindMatrix("uNormMatrix", f), this._program.bindMatrix("uWorld", i), this._program.bindMatrix("uView", n), this._program.bindMatrix("uViewInverse", d.GetInverted(n)), this._program.bindMatrix("uProj", s), this._cameraPosition ? this._program.bindVector("uCameraPos", this._cameraPosition) : (console.warn("Serious performance warning: camera position not set in BasicPBRLightShader. Extracting the camera position from the view matrix involves inverting the matrix."), this._program.bindVector("uCameraPos", d.GetPosition(d.GetInverted(n)))), r.bindTexture(this._program, "albedoTexture", "uAlbedoTexture", 0), r.bindTexture(this._program, "normalTexture", "uNormalTexture", 1, zn(this.renderer)), r.bindMetalnessRoughnessHeightAOTexture(this._program, "uMetallicRoughnessHeightAOTexture", 2), this._program.uniform1f("uAlphaTresshold", a.alphaCutoff), r.bindColor(this._program, "albedo", "uAlbedo"), r.bindValue(this._program, "metalness", "uMetallic"), r.bindValue(this._program, "roughness", "uRoughness"), r.bindValue(this._program, "lightEmission", "uLightEmission", 0), this._program.uniform1i("uAlbedoMap", a.albedoUV), this._program.uniform1i("uNormalMap", a.normalUV), this._program.uniform1i("uAOMap", a.ambientOcclussionUV), this._program.uniform1i("uMetallicMap", a.metalnessChannel), this._program.uniform1i("uRoughnessMap", a.roughnessChannel), this._program.uniform1i("uLightemissionMap", a.lightEmissionChannel), this._program.bindVector("uAlbedoScale", a.albedoScale), this._program.bindVector("uNormalScale", a.normalScale), this._program.bindVector("uMetallicScale", a.metalnessScale), this._program.bindVector("uRoughnessScale", a.roughnessScale), this._program.bindVector("uLightEmissionScale", a.lightEmissionScale), this._program.bindVector("uFresnelTint", a.fresnelTint), this._program.bindVector("uSheenColor", a.sheenColor), this._program.uniform1f("uSheenIntensity", a.sheenIntensity), !this.irradianceMap || !this.specularMap || !this.environmentMap || !this._brdfIntegrationTexture)
10345
+ const f = w.GetNormalMatrix(i);
10346
+ if (this._program.bindMatrix("uNormMatrix", f), this._program.bindMatrix("uWorld", i), this._program.bindMatrix("uView", n), this._program.bindMatrix("uViewInverse", w.GetInverted(n)), this._program.bindMatrix("uProj", s), this._cameraPosition ? this._program.bindVector("uCameraPos", this._cameraPosition) : (console.warn("Serious performance warning: camera position not set in BasicPBRLightShader. Extracting the camera position from the view matrix involves inverting the matrix."), this._program.bindVector("uCameraPos", w.GetPosition(w.GetInverted(n)))), r.bindTexture(this._program, "albedoTexture", "uAlbedoTexture", 0), r.bindTexture(this._program, "normalTexture", "uNormalTexture", 1, zn(this.renderer)), r.bindMetalnessRoughnessHeightAOTexture(this._program, "uMetallicRoughnessHeightAOTexture", 2), this._program.uniform1f("uAlphaTresshold", a.alphaCutoff), r.bindColor(this._program, "albedo", "uAlbedo"), r.bindValue(this._program, "metalness", "uMetallic"), r.bindValue(this._program, "roughness", "uRoughness"), r.bindValue(this._program, "lightEmission", "uLightEmission", 0), this._program.uniform1i("uAlbedoMap", a.albedoUV), this._program.uniform1i("uNormalMap", a.normalUV), this._program.uniform1i("uAOMap", a.ambientOcclussionUV), this._program.uniform1i("uMetallicMap", a.metalnessChannel), this._program.uniform1i("uRoughnessMap", a.roughnessChannel), this._program.uniform1i("uLightemissionMap", a.lightEmissionChannel), this._program.bindVector("uAlbedoScale", a.albedoScale), this._program.bindVector("uNormalScale", a.normalScale), this._program.bindVector("uMetallicScale", a.metalnessScale), this._program.bindVector("uRoughnessScale", a.roughnessScale), this._program.bindVector("uLightEmissionScale", a.lightEmissionScale), this._program.bindVector("uFresnelTint", a.fresnelTint), this._program.bindVector("uSheenColor", a.sheenColor), this._program.uniform1f("uSheenIntensity", a.sheenIntensity), !this.irradianceMap || !this.specularMap || !this.environmentMap || !this._brdfIntegrationTexture)
10327
10347
  throw new Error("PBRLightIBLShader: Environment maps not set.");
10328
- const l = this.renderer.factory.texture(this.irradianceMap), w = this.renderer.factory.texture(this.specularMap), P = this.renderer.factory.texture(this.environmentMap), C = this.renderer.factory.texture(this._brdfIntegrationTexture);
10329
- this._program.bindTexture("uIrradianceMap", l, 3), this._program.bindTexture("uSpecularMap", w, 4), this._program.bindTexture("uEnvMap", P, 5), this._program.bindTexture("uBRDFIntegrationMap", C, 6), this._program.uniform1f("uBrightness", this._brightness), this._program.uniform1f("uContrast", this._contrast), this._program.uniform1f("uAmbientIntensity", 1);
10348
+ const c = this.renderer.factory.texture(this.irradianceMap), d = this.renderer.factory.texture(this.specularMap), P = this.renderer.factory.texture(this.environmentMap), C = this.renderer.factory.texture(this._brdfIntegrationTexture);
10349
+ this._program.bindTexture("uIrradianceMap", c, 3), this._program.bindTexture("uSpecularMap", d, 4), this._program.bindTexture("uEnvMap", P, 5), this._program.bindTexture("uBRDFIntegrationMap", C, 6), this._program.uniform1f("uBrightness", this._brightness), this._program.uniform1f("uContrast", this._contrast), this._program.uniform1f("uAmbientIntensity", 1);
10330
10350
  let v = this._lights.find((D) => D.depthTexture) || null;
10331
10351
  if (this._lights.forEach((D, B) => {
10332
10352
  D.depthTexture && (v = D), this._program?.uniform1i(`uLightTypes[${B}]`, this._lightTypes[B]), this._program?.bindVector(`uLightPositions[${B}]`, this._lightPositions[B]), this._program?.bindVector(`uLightDirections[${B}]`, this._lightDirections[B]), this._program?.bindVector(`uLightColors[${B}]`, this._lightColors[B].rgb), this._program?.uniform1f(`uLightIntensities[${B}]`, this._lightIntensities[B]), this._program?.bindMatrix(`uLightTransforms[${B}]`, this._lightTransforms[B]);
10333
10353
  }), v?.depthTexture) {
10334
10354
  const D = this.renderer.factory.texture(v.depthTexture);
10335
10355
  this._program.bindTexture("uShadowMap", D, 7);
10336
- const B = d.Mult(v.projection, v.viewMatrix || d.MakeIdentity());
10356
+ const B = w.Mult(v.projection, v.viewMatrix || w.MakeIdentity());
10337
10357
  this._program.bindMatrix("uLightPovMvp", B), this._program.uniform1f("uShadowBias", v.shadowBias * 30), this._program.uniform1f("uShadowStrength", v.shadowStrength);
10338
10358
  }
10339
10359
  this._program.bindAttribs(e, {
@@ -10348,7 +10368,7 @@ class Xn extends V {
10348
10368
  this._program && T.Delete(this._program);
10349
10369
  }
10350
10370
  }
10351
- class kn extends dn {
10371
+ class kn extends wn {
10352
10372
  constructor(e) {
10353
10373
  super(e), this._shader = new Xn(this.renderer);
10354
10374
  }
@@ -10379,7 +10399,7 @@ class kn extends dn {
10379
10399
  await super.frame(e, r);
10380
10400
  const i = j.GetMain(e);
10381
10401
  this.shader.lights = this.renderQueue.lights.map(({ light: o }) => o), this.shader.lightTransforms = this.renderQueue.lights.map(({ transform: o }) => o);
10382
- const n = i ? oe.GetWorldMatrix(i.node) : d.MakeIdentity(), s = d.GetPosition(n);
10402
+ const n = i ? oe.GetWorldMatrix(i.node) : w.MakeIdentity(), s = w.GetPosition(n);
10383
10403
  this.shader.cameraPosition = s;
10384
10404
  }
10385
10405
  }
@@ -10394,7 +10414,7 @@ class jn extends yn {
10394
10414
  e.depthMask = !1, this._renderState.draw(), e.depthMask = r;
10395
10415
  }
10396
10416
  }
10397
- class Vn extends wr {
10417
+ class Vn extends dr {
10398
10418
  draw() {
10399
10419
  const e = this.renderer;
10400
10420
  if (!this._renderState)
@@ -10519,7 +10539,7 @@ const L0 = (t, e) => {
10519
10539
  default:
10520
10540
  throw new Error("Error creating WebGL Texture: invalid target");
10521
10541
  }
10522
- }, ct = (t, e) => {
10542
+ }, lt = (t, e) => {
10523
10543
  if (e === 1)
10524
10544
  return t.CLAMP_TO_EDGE;
10525
10545
  {
@@ -10552,15 +10572,15 @@ const L0 = (t, e) => {
10552
10572
  if (t.bindTexture(r, e._apiObject), e.dataType === Qe.RENDER_TARGET) {
10553
10573
  const { width: n, height: s } = e.size, o = e.renderTargetAttachment === Y.DEPTH_ATTACHMENT, a = o ? t.DEPTH_COMPONENT : t.RGBA;
10554
10574
  let f = o ? t.DEPTH_COMPONENT : t.RGBA;
10555
- const l = o ? t.UNSIGNED_SHORT : i;
10556
- if (t.texParameteri(r, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_WRAP_S, ct(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, ct(t, e.wrapModeY)), r === t.TEXTURE_CUBE_MAP)
10557
- for (let w = 0; w < 6; ++w)
10558
- t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X + w, 0, a, n, s, 0, f, l, null);
10575
+ const c = o ? t.UNSIGNED_SHORT : i;
10576
+ if (t.texParameteri(r, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_WRAP_S, lt(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, lt(t, e.wrapModeY)), r === t.TEXTURE_CUBE_MAP)
10577
+ for (let d = 0; d < 6; ++d)
10578
+ t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X + d, 0, a, n, s, 0, f, c, null);
10559
10579
  else
10560
- t.texImage2D(r, 0, a, n, s, 0, f, l, null);
10580
+ t.texImage2D(r, 0, a, n, s, 0, f, c, null);
10561
10581
  e.imageData.currentSize = new h(e.size);
10562
10582
  } else
10563
- t.texImage2D(r, 0, t.RGBA, t.RGBA, i, e._imageData), t.texParameteri(r, t.TEXTURE_WRAP_S, ct(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, ct(t, e.wrapModeY)), t.texParameteri(r, t.TEXTURE_MAG_FILTER, qr(t, e.magFilter)), t.texParameteri(r, t.TEXTURE_MIN_FILTER, qr(t, e.minFilter)), e.mipmapRequired && t.generateMipmap(r);
10583
+ t.texImage2D(r, 0, t.RGBA, t.RGBA, i, e._imageData), t.texParameteri(r, t.TEXTURE_WRAP_S, lt(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, lt(t, e.wrapModeY)), t.texParameteri(r, t.TEXTURE_MAG_FILTER, qr(t, e.magFilter)), t.texParameteri(r, t.TEXTURE_MIN_FILTER, qr(t, e.minFilter)), e.mipmapRequired && t.generateMipmap(r);
10564
10584
  };
10565
10585
  class Jn extends Mn {
10566
10586
  static ListTextures(e) {
@@ -10642,19 +10662,19 @@ class Zn extends Et {
10642
10662
  await super.init(e), this._canvas = e, this._gl = e.domElement.getContext("webgl", { preserveDrawingBuffer: !0 }), this._gl._bg2e_object = this;
10643
10663
  const r = new URLSearchParams(location.search).get("debug") == "true";
10644
10664
  if (this._debugMode = r, window.WebGLDebugUtils && r) {
10645
- let i = function(a, f, l) {
10665
+ let i = function(a, f, c) {
10646
10666
  throw window.WebGLDebugUtils.glEnumToString(a) + " was caused by call to: " + f;
10647
10667
  }, n = function(a, f) {
10648
10668
  if (console.log("gl." + a + "(" + window.WebGLDebugUtils.glFunctionArgsToString(a, f) + ")"), /drawElements/.test(a)) {
10649
- const l = he.CurrentBuffer(s, Se.ELEMENT_ARRAY_BUFFER), w = he.CurrentBuffer(s, Se.ARRAY_BUFFER);
10650
- o(l?.id, "ELEMENT_ARRAY_BUFFER"), o(w?.id, "ARRAY_BUFFER");
10669
+ const c = he.CurrentBuffer(s, Se.ELEMENT_ARRAY_BUFFER), d = he.CurrentBuffer(s, Se.ARRAY_BUFFER);
10670
+ o(c?.id, "ELEMENT_ARRAY_BUFFER"), o(d?.id, "ARRAY_BUFFER");
10651
10671
  } else /bindBuffer/.test(a) && f[0] === s.ELEMENT_ARRAY_BUFFER ? console.log(` BufferID: ${f[1]._bg2e_id_}`) : /bindBuffer/.test(a) && f[0] === s.ARRAY_BUFFER && console.log(` BufferID: ${f[1]._bg2e_id_}`);
10652
10672
  };
10653
10673
  const s = this._gl;
10654
10674
  console.warn("Using WebGLDebugUtils: this must cause an impact in performance");
10655
10675
  const o = (a, f) => {
10656
- const l = s.getBufferParameter(s[f], s.BUFFER_SIZE);
10657
- console.log(` ${f} id: ${a}, size: ${l}`);
10676
+ const c = s.getBufferParameter(s[f], s.BUFFER_SIZE);
10677
+ console.log(` ${f} id: ${a}, size: ${c}`);
10658
10678
  };
10659
10679
  this._gl = window.WebGLDebugUtils.makeDebugContext(this._gl, i, n);
10660
10680
  }
@@ -10735,25 +10755,25 @@ const U0 = {
10735
10755
  Pipeline: fn,
10736
10756
  BlendEquation: Ke,
10737
10757
  BlendFunction: R,
10738
- PolyListRenderer: cn,
10758
+ PolyListRenderer: ln,
10739
10759
  RenderBuffer: gn,
10740
10760
  RenderBufferType: ve,
10741
- RenderBufferTypeName: ln,
10761
+ RenderBufferTypeName: cn,
10742
10762
  CubeMapFace: vt,
10743
10763
  Renderer: Et,
10744
10764
  EngineFeatures: Ve,
10745
10765
  RenderQueue: St,
10746
10766
  RenderState: Dt,
10747
- SceneAppController: d0,
10748
- SceneRenderer: dn,
10767
+ SceneAppController: w0,
10768
+ SceneRenderer: wn,
10749
10769
  FrameVisitor: Rt,
10750
10770
  BindRendererVisitor: un,
10751
- InitVisitor: wn,
10771
+ InitVisitor: dn,
10752
10772
  EventCallbackVisitor: _,
10753
10773
  Shader: V,
10754
10774
  ShadowRenderer: Qn,
10755
10775
  SkyCube: yn,
10756
- SkySphere: wr,
10776
+ SkySphere: dr,
10757
10777
  TextureMergerRenderer: Ri,
10758
10778
  TextureRenderer: Mn,
10759
10779
  webgl: O0,
@@ -10951,9 +10971,9 @@ class Y0 extends V {
10951
10971
  throw new Error("BasicPBRLightShader: lights array not specified");
10952
10972
  const o = r.material, a = this.renderer;
10953
10973
  a.state.shaderProgram = this._program;
10954
- const f = d.GetNormalMatrix(i);
10955
- this._program.bindMatrix("uNormMatrix", f), this._program.bindMatrix("uWorld", i), this._program.bindMatrix("uView", n), this._program.bindMatrix("uProj", s), this._cameraPosition ? this._program.bindVector("uCameraPos", this._cameraPosition) : (console.warn("Serious performance warning: camera position not set in BasicPBRLightShader. Extracting the camera position from the view matrix involves inverting the matrix."), this._program.bindVector("uCameraPos", d.GetPosition(d.GetInverted(n)))), r.bindTexture(this._program, "albedoTexture", "uAlbedoTexture", 0), r.bindTexture(this._program, "normalTexture", "uNormalTexture", 1, zn(this.renderer)), r.bindTexture(this._program, "metalnessTexture", "uMetallicTexture", 2), r.bindTexture(this._program, "roughnessTexture", "uRoughnessTexture", 3), r.bindColor(this._program, "albedo", "uAlbedo"), r.bindValue(this._program, "metalness", "uMetallic"), r.bindValue(this._program, "roughness", "uRoughness"), this._program.bindVector("uAlbedoScale", o.albedoScale), this._program.bindVector("uNormalScale", o.normalScale), this._program.bindVector("uMetallicScale", o.metalnessScale), this._program.bindVector("uRoughnessScale", o.roughnessScale), this._lights.forEach((l, w) => {
10956
- this._program?.uniform1i(`uLightTypes[${w}]`, this._lightTypes[w]), this._program?.bindVector(`uLightPositions[${w}]`, this._lightPositions[w]), this._program?.bindVector(`uLightDirections[${w}]`, this._lightDirections[w]), this._program?.bindVector(`uLightColors[${w}]`, this._lightColors[w].rgb), this._program?.uniform1f(`uLightIntensities[${w}]`, this._lightIntensities[w]);
10974
+ const f = w.GetNormalMatrix(i);
10975
+ this._program.bindMatrix("uNormMatrix", f), this._program.bindMatrix("uWorld", i), this._program.bindMatrix("uView", n), this._program.bindMatrix("uProj", s), this._cameraPosition ? this._program.bindVector("uCameraPos", this._cameraPosition) : (console.warn("Serious performance warning: camera position not set in BasicPBRLightShader. Extracting the camera position from the view matrix involves inverting the matrix."), this._program.bindVector("uCameraPos", w.GetPosition(w.GetInverted(n)))), r.bindTexture(this._program, "albedoTexture", "uAlbedoTexture", 0), r.bindTexture(this._program, "normalTexture", "uNormalTexture", 1, zn(this.renderer)), r.bindTexture(this._program, "metalnessTexture", "uMetallicTexture", 2), r.bindTexture(this._program, "roughnessTexture", "uRoughnessTexture", 3), r.bindColor(this._program, "albedo", "uAlbedo"), r.bindValue(this._program, "metalness", "uMetallic"), r.bindValue(this._program, "roughness", "uRoughness"), this._program.bindVector("uAlbedoScale", o.albedoScale), this._program.bindVector("uNormalScale", o.normalScale), this._program.bindVector("uMetallicScale", o.metalnessScale), this._program.bindVector("uRoughnessScale", o.roughnessScale), this._lights.forEach((c, d) => {
10976
+ this._program?.uniform1i(`uLightTypes[${d}]`, this._lightTypes[d]), this._program?.bindVector(`uLightPositions[${d}]`, this._lightPositions[d]), this._program?.bindVector(`uLightDirections[${d}]`, this._lightDirections[d]), this._program?.bindVector(`uLightColors[${d}]`, this._lightColors[d].rgb), this._program?.uniform1f(`uLightIntensities[${d}]`, this._lightIntensities[d]);
10957
10977
  }), this._program.bindAttribs(e, {
10958
10978
  position: "inPosition",
10959
10979
  normal: "inNormal",
@@ -10982,7 +11002,7 @@ const j0 = {
10982
11002
  SpecularMapCubeShader: Hi,
10983
11003
  TextureMergerShader: bt,
10984
11004
  shaderLib: {
10985
- webgl: c0
11005
+ webgl: l0
10986
11006
  }
10987
11007
  };
10988
11008
  class V0 {
@@ -11011,8 +11031,8 @@ class V0 {
11011
11031
  r.bindFramebuffer(r.FRAMEBUFFER, o), r.framebufferTexture2D(r.FRAMEBUFFER, r.COLOR_ATTACHMENT0, r.TEXTURE_2D, i._apiObject, 0);
11012
11032
  let a = new Uint8Array(e.size.width * e.size.height * 4);
11013
11033
  r.readPixels(0, 0, e.size[0], e.size[1], r.RGBA, r.UNSIGNED_BYTE, a);
11014
- const f = new ImageData(new Uint8ClampedArray(a), e.size.width, e.size.height), l = f.width, w = f.height, P = f.data;
11015
- Array.from({ length: w }, (v, D) => a.slice(D * l * 4, (D + 1) * l * 4)).forEach((v, D) => P.set(v, (w - D - 1) * l * 4));
11034
+ const f = new ImageData(new Uint8ClampedArray(a), e.size.width, e.size.height), c = f.width, d = f.height, P = f.data;
11035
+ Array.from({ length: d }, (v, D) => a.slice(D * c * 4, (D + 1) * c * 4)).forEach((v, D) => P.set(v, (d - D - 1) * c * 4));
11016
11036
  const C = this._context;
11017
11037
  C && C.putImageData(f, 0, 0), r.bindTexture(r.TEXTURE_2D, n), r.bindFramebuffer(r.FRAMEBUFFER, s);
11018
11038
  }
@@ -11021,9 +11041,9 @@ const K0 = {
11021
11041
  DebugRenderer: xe,
11022
11042
  WebGLTextureViewer: V0
11023
11043
  }, J0 = _o, Z0 = To, q0 = Qo, _0 = K0, $0 = {
11024
- ...ds,
11044
+ ...ws,
11025
11045
  Mat3: te,
11026
- Mat4: d,
11046
+ Mat4: w,
11027
11047
  Vec: h,
11028
11048
  Quat: vs,
11029
11049
  MatrixStrategy: ni