@mlightcad/geometry-engine 1.0.6 → 1.0.7

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.
@@ -839,8 +839,8 @@ const C = {
839
839
  * @returns Return this vector
840
840
  */
841
841
  rotateAround(t, s) {
842
- const e = Math.cos(s), n = Math.sin(s), i = this.x - t.x, r = this.y - t.y;
843
- return this.x = i * e - r * n + t.x, this.y = i * n + r * e + t.y, this;
842
+ const e = Math.cos(s), n = Math.sin(s), i = this.x - t.x, h = this.y - t.y;
843
+ return this.x = i * e - h * n + t.x, this.y = i * n + h * e + t.y, this;
844
844
  }
845
845
  /**
846
846
  * Set each component of this vector to a pseudo-random value between 0 and 1, excluding 1.
@@ -875,8 +875,8 @@ const H = class H {
875
875
  * @param n32 Input element in the third row and the second column
876
876
  * @param n33 Input element in the third row and the third column
877
877
  */
878
- constructor(t, s, e, n, i, r, h, a, o) {
879
- this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && r != null && h != null && a != null && o != null && this.set(t, s, e, n, i, r, h, a, o);
878
+ constructor(t, s, e, n, i, h, r, a, o) {
879
+ this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && h != null && r != null && a != null && o != null && this.set(t, s, e, n, i, h, r, a, o);
880
880
  }
881
881
  /**
882
882
  * Set the 3x3 matrix values to the given row-major sequence of values.
@@ -892,9 +892,9 @@ const H = class H {
892
892
  * @param n33 Input element in the third row and the third column
893
893
  * @returns Return this matrix
894
894
  */
895
- set(t, s, e, n, i, r, h, a, o) {
895
+ set(t, s, e, n, i, h, r, a, o) {
896
896
  const c = this.elements;
897
- return c[0] = t, c[1] = n, c[2] = h, c[3] = s, c[4] = i, c[5] = a, c[6] = e, c[7] = r, c[8] = o, this;
897
+ return c[0] = t, c[1] = n, c[2] = r, c[3] = s, c[4] = i, c[5] = a, c[6] = e, c[7] = h, c[8] = o, this;
898
898
  }
899
899
  /**
900
900
  * Reset this matrix to the 3x3 identity matrix:
@@ -954,8 +954,8 @@ const H = class H {
954
954
  * @returns Return this matrix
955
955
  */
956
956
  multiplyMatrices(t, s) {
957
- const e = t.elements, n = s.elements, i = this.elements, r = e[0], h = e[3], a = e[6], o = e[1], c = e[4], l = e[7], m = e[2], d = e[5], x = e[8], g = n[0], p = n[3], _ = n[6], w = n[1], f = n[4], A = n[7], M = n[2], B = n[5], z = n[8];
958
- return i[0] = r * g + h * w + a * M, i[3] = r * p + h * f + a * B, i[6] = r * _ + h * A + a * z, i[1] = o * g + c * w + l * M, i[4] = o * p + c * f + l * B, i[7] = o * _ + c * A + l * z, i[2] = m * g + d * w + x * M, i[5] = m * p + d * f + x * B, i[8] = m * _ + d * A + x * z, this;
957
+ const e = t.elements, n = s.elements, i = this.elements, h = e[0], r = e[3], a = e[6], o = e[1], c = e[4], l = e[7], d = e[2], m = e[5], x = e[8], g = n[0], p = n[3], _ = n[6], f = n[1], w = n[4], A = n[7], M = n[2], B = n[5], z = n[8];
958
+ return i[0] = h * g + r * f + a * M, i[3] = h * p + r * w + a * B, i[6] = h * _ + r * A + a * z, i[1] = o * g + c * f + l * M, i[4] = o * p + c * w + l * B, i[7] = o * _ + c * A + l * z, i[2] = d * g + m * f + x * M, i[5] = d * p + m * w + x * B, i[8] = d * _ + m * A + x * z, this;
959
959
  }
960
960
  /**
961
961
  * Multiply every component of the matrix by the scalar value s.
@@ -971,8 +971,8 @@ const H = class H {
971
971
  * @returns Return the determinant of this matrix
972
972
  */
973
973
  determinant() {
974
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], h = t[5], a = t[6], o = t[7], c = t[8];
975
- return s * r * c - s * h * o - e * i * c + e * h * a + n * i * o - n * r * a;
974
+ const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], h = t[4], r = t[5], a = t[6], o = t[7], c = t[8];
975
+ return s * h * c - s * r * o - e * i * c + e * r * a + n * i * o - n * h * a;
976
976
  }
977
977
  /**
978
978
  * Invert this matrix, using the analytic method. You can not invert with a determinant of zero.
@@ -980,10 +980,10 @@ const H = class H {
980
980
  * @returns Return this matrix
981
981
  */
982
982
  invert() {
983
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], h = t[5], a = t[6], o = t[7], c = t[8], l = c * r - h * o, m = h * a - c * i, d = o * i - r * a, x = s * l + e * m + n * d;
983
+ const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], h = t[4], r = t[5], a = t[6], o = t[7], c = t[8], l = c * h - r * o, d = r * a - c * i, m = o * i - h * a, x = s * l + e * d + n * m;
984
984
  if (x === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
985
985
  const g = 1 / x;
986
- return t[0] = l * g, t[1] = (n * o - c * e) * g, t[2] = (h * e - n * r) * g, t[3] = m * g, t[4] = (c * s - n * a) * g, t[5] = (n * i - h * s) * g, t[6] = d * g, t[7] = (e * a - o * s) * g, t[8] = (r * s - e * i) * g, this;
986
+ return t[0] = l * g, t[1] = (n * o - c * e) * g, t[2] = (r * e - n * h) * g, t[3] = d * g, t[4] = (c * s - n * a) * g, t[5] = (n * i - r * s) * g, t[6] = m * g, t[7] = (e * a - o * s) * g, t[8] = (h * s - e * i) * g, this;
987
987
  }
988
988
  /**
989
989
  * Transpose this matrix in place.
@@ -1024,15 +1024,15 @@ const H = class H {
1024
1024
  * @param cy Input center y of rotation
1025
1025
  * @returns Return this matrix
1026
1026
  */
1027
- setUvTransform(t, s, e, n, i, r, h) {
1027
+ setUvTransform(t, s, e, n, i, h, r) {
1028
1028
  const a = Math.cos(i), o = Math.sin(i);
1029
1029
  return this.set(
1030
1030
  e * a,
1031
1031
  e * o,
1032
- -e * (a * r + o * h) + r + t,
1032
+ -e * (a * h + o * r) + h + t,
1033
1033
  -n * o,
1034
1034
  n * a,
1035
- -n * (-o * r + a * h) + h + s,
1035
+ -n * (-o * h + a * r) + r + s,
1036
1036
  0,
1037
1037
  0,
1038
1038
  1
@@ -1214,11 +1214,11 @@ const Ft = new ds();
1214
1214
  function Xt(u, t, s = !1) {
1215
1215
  const e = u.x, n = u.y;
1216
1216
  let i = !1;
1217
- const r = t.length;
1218
- for (let h = 0, a = r - 1; h < r; a = h++) {
1219
- const o = t[h].x, c = t[h].y, l = t[a].x, m = t[a].y;
1220
- let d = c > n != m > n;
1221
- s && (d = c >= n != m >= n), d && e < (l - o) * (n - c) / (m - c) + o && (i = !i);
1217
+ const h = t.length;
1218
+ for (let r = 0, a = h - 1; r < h; a = r++) {
1219
+ const o = t[r].x, c = t[r].y, l = t[a].x, d = t[a].y;
1220
+ let m = c > n != d > n;
1221
+ s && (m = c >= n != d >= n), m && e < (l - o) * (n - c) / (d - c) + o && (i = !i);
1222
1222
  }
1223
1223
  return i;
1224
1224
  }
@@ -1252,70 +1252,70 @@ function ys(u, t) {
1252
1252
  function gs(u, t) {
1253
1253
  const s = t.length - 1, e = u, n = [0];
1254
1254
  let i = 0;
1255
- for (let h = 1; h <= s; h++) {
1256
- const a = t[h][0] - t[h - 1][0], o = t[h][1] - t[h - 1][1], c = t[h][2] - t[h - 1][2], l = Math.sqrt(a * a + o * o + c * c);
1255
+ for (let r = 1; r <= s; r++) {
1256
+ const a = t[r][0] - t[r - 1][0], o = t[r][1] - t[r - 1][1], c = t[r][2] - t[r - 1][2], l = Math.sqrt(a * a + o * o + c * c);
1257
1257
  i += l, n.push(i);
1258
1258
  }
1259
- const r = [];
1260
- for (let h = 0; h <= e; h++)
1261
- r.push(0);
1262
- for (let h = 1; h <= s - e; h++) {
1263
- const a = n[h] / i;
1264
- r.push(a * (s - e + 1));
1259
+ const h = [];
1260
+ for (let r = 0; r <= e; r++)
1261
+ h.push(0);
1262
+ for (let r = 1; r <= s - e; r++) {
1263
+ const a = n[r] / i;
1264
+ h.push(a * (s - e + 1));
1265
1265
  }
1266
- for (let h = 0; h <= e; h++)
1267
- r.push(s - e + 1);
1268
- return r;
1266
+ for (let r = 0; r <= e; r++)
1267
+ h.push(s - e + 1);
1268
+ return h;
1269
1269
  }
1270
1270
  function _s(u, t) {
1271
1271
  const s = t.length - 1, e = u, n = [0];
1272
1272
  let i = 0;
1273
- for (let h = 1; h <= s; h++) {
1274
- const a = t[h][0] - t[h - 1][0], o = t[h][1] - t[h - 1][1], c = t[h][2] - t[h - 1][2], l = Math.sqrt(a * a + o * o + c * c), m = Math.sqrt(l);
1275
- i += m, n.push(i);
1276
- }
1277
- const r = [];
1278
- for (let h = 0; h <= e; h++)
1279
- r.push(0);
1280
- for (let h = 1; h <= s - e; h++) {
1281
- const a = n[h] / i;
1282
- r.push(a * (s - e + 1));
1283
- }
1284
- for (let h = 0; h <= e; h++)
1285
- r.push(s - e + 1);
1286
- return r;
1273
+ for (let r = 1; r <= s; r++) {
1274
+ const a = t[r][0] - t[r - 1][0], o = t[r][1] - t[r - 1][1], c = t[r][2] - t[r - 1][2], l = Math.sqrt(a * a + o * o + c * c), d = Math.sqrt(l);
1275
+ i += d, n.push(i);
1276
+ }
1277
+ const h = [];
1278
+ for (let r = 0; r <= e; r++)
1279
+ h.push(0);
1280
+ for (let r = 1; r <= s - e; r++) {
1281
+ const a = n[r] / i;
1282
+ h.push(a * (s - e + 1));
1283
+ }
1284
+ for (let r = 0; r <= e; r++)
1285
+ h.push(s - e + 1);
1286
+ return h;
1287
1287
  }
1288
1288
  function bt(u, t, s, e) {
1289
1289
  if (t === 0)
1290
1290
  return s >= e[u] && s < e[u + 1] ? 1 : 0;
1291
- const n = e[u + t] - e[u], i = e[u + t + 1] - e[u + 1], r = n > 1e-10 ? (s - e[u]) / n : 0, h = i > 1e-10 ? (e[u + t + 1] - s) / i : 0;
1292
- return r * bt(u, t - 1, s, e) + h * bt(u + 1, t - 1, s, e);
1291
+ const n = e[u + t] - e[u], i = e[u + t + 1] - e[u + 1], h = n > 1e-10 ? (s - e[u]) / n : 0, r = i > 1e-10 ? (e[u + t + 1] - s) / i : 0;
1292
+ return h * bt(u, t - 1, s, e) + r * bt(u + 1, t - 1, s, e);
1293
1293
  }
1294
1294
  function xt(u, t, s, e, n) {
1295
- const i = e.length - 1, r = t;
1296
- if (u = Math.max(s[r], Math.min(s[i + 1], u)), Math.abs(u - s[i + 1]) < 1e-8)
1295
+ const i = e.length - 1, h = t;
1296
+ if (u = Math.max(s[h], Math.min(s[i + 1], u)), Math.abs(u - s[i + 1]) < 1e-8)
1297
1297
  return [...e[i]];
1298
- if (Math.abs(u - s[r]) < 1e-8)
1298
+ if (Math.abs(u - s[h]) < 1e-8)
1299
1299
  return [...e[0]];
1300
- const h = [0, 0, 0];
1300
+ const r = [0, 0, 0];
1301
1301
  let a = 0;
1302
1302
  for (let o = 0; o <= i; o++) {
1303
- const c = bt(o, r, u, s), l = n[o] * c;
1304
- h[0] += e[o][0] * l, h[1] += e[o][1] * l, h[2] += e[o][2] * l, a += l;
1303
+ const c = bt(o, h, u, s), l = n[o] * c;
1304
+ r[0] += e[o][0] * l, r[1] += e[o][1] * l, r[2] += e[o][2] * l, a += l;
1305
1305
  }
1306
1306
  if (a < 1e-10) {
1307
- const o = s[s.length - r - 1];
1307
+ const o = s[s.length - h - 1];
1308
1308
  if (Math.abs(u - o) < 1e-8)
1309
1309
  return [...e[i]];
1310
- if (Math.abs(u - s[r]) < 1e-8)
1310
+ if (Math.abs(u - s[h]) < 1e-8)
1311
1311
  return [...e[0]];
1312
1312
  }
1313
- return a > 1e-10 && (h[0] /= a, h[1] /= a, h[2] /= a), h;
1313
+ return a > 1e-10 && (r[0] /= a, r[1] /= a, r[2] /= a), r;
1314
1314
  }
1315
1315
  function ps(u, t, s, e) {
1316
- const n = u, i = t[n], r = t[t.length - n - 1];
1317
- let h = 0;
1318
- const a = 1e3, o = (r - i) / a;
1316
+ const n = u, i = t[n], h = t[t.length - n - 1];
1317
+ let r = 0;
1318
+ const a = 1e3, o = (h - i) / a;
1319
1319
  let c = xt(
1320
1320
  i,
1321
1321
  u,
@@ -1324,17 +1324,17 @@ function ps(u, t, s, e) {
1324
1324
  e
1325
1325
  );
1326
1326
  for (let g = 1; g <= a; g++) {
1327
- const p = i + g * o, _ = xt(p, u, t, s, e), w = _[0] - c[0], f = _[1] - c[1], A = _[2] - c[2];
1328
- h += Math.sqrt(w * w + f * f + A * A), c = _;
1327
+ const p = i + g * o, _ = xt(p, u, t, s, e), f = _[0] - c[0], w = _[1] - c[1], A = _[2] - c[2];
1328
+ r += Math.sqrt(f * f + w * w + A * A), c = _;
1329
1329
  }
1330
1330
  const l = xt(
1331
- r,
1331
+ h,
1332
1332
  u,
1333
1333
  t,
1334
1334
  s,
1335
1335
  e
1336
- ), m = l[0] - c[0], d = l[1] - c[1], x = l[2] - c[2];
1337
- return h += Math.sqrt(m * m + d * d + x * x), h;
1336
+ ), d = l[0] - c[0], m = l[1] - c[1], x = l[2] - c[2];
1337
+ return r += Math.sqrt(d * d + m * m + x * x), r;
1338
1338
  }
1339
1339
  function zs(u) {
1340
1340
  return u.map((t) => [...t]);
@@ -1360,26 +1360,26 @@ class pt {
1360
1360
  * @param srcOffset1 Input an offset into the array src1.
1361
1361
  * @param t Input normalized interpolation factor (between 0 and 1).
1362
1362
  */
1363
- static slerpFlat(t, s, e, n, i, r, h) {
1363
+ static slerpFlat(t, s, e, n, i, h, r) {
1364
1364
  let a = e[n + 0], o = e[n + 1], c = e[n + 2], l = e[n + 3];
1365
- const m = i[r + 0], d = i[r + 1], x = i[r + 2], g = i[r + 3];
1366
- if (h === 0) {
1365
+ const d = i[h + 0], m = i[h + 1], x = i[h + 2], g = i[h + 3];
1366
+ if (r === 0) {
1367
1367
  t[s + 0] = a, t[s + 1] = o, t[s + 2] = c, t[s + 3] = l;
1368
1368
  return;
1369
1369
  }
1370
- if (h === 1) {
1371
- t[s + 0] = m, t[s + 1] = d, t[s + 2] = x, t[s + 3] = g;
1370
+ if (r === 1) {
1371
+ t[s + 0] = d, t[s + 1] = m, t[s + 2] = x, t[s + 3] = g;
1372
1372
  return;
1373
1373
  }
1374
- if (l !== g || a !== m || o !== d || c !== x) {
1375
- let p = 1 - h;
1376
- const _ = a * m + o * d + c * x + l * g, w = _ >= 0 ? 1 : -1, f = 1 - _ * _;
1377
- if (f > Number.EPSILON) {
1378
- const M = Math.sqrt(f), B = Math.atan2(M, _ * w);
1379
- p = Math.sin(p * B) / M, h = Math.sin(h * B) / M;
1374
+ if (l !== g || a !== d || o !== m || c !== x) {
1375
+ let p = 1 - r;
1376
+ const _ = a * d + o * m + c * x + l * g, f = _ >= 0 ? 1 : -1, w = 1 - _ * _;
1377
+ if (w > Number.EPSILON) {
1378
+ const M = Math.sqrt(w), B = Math.atan2(M, _ * f);
1379
+ p = Math.sin(p * B) / M, r = Math.sin(r * B) / M;
1380
1380
  }
1381
- const A = h * w;
1382
- if (a = a * p + m * A, o = o * p + d * A, c = c * p + x * A, l = l * p + g * A, p === 1 - h) {
1381
+ const A = r * f;
1382
+ if (a = a * p + d * A, o = o * p + m * A, c = c * p + x * A, l = l * p + g * A, p === 1 - r) {
1383
1383
  const M = 1 / Math.sqrt(a * a + o * o + c * c + l * l);
1384
1384
  a *= M, o *= M, c *= M, l *= M;
1385
1385
  }
@@ -1396,9 +1396,9 @@ class pt {
1396
1396
  * @param srcOffset1 Input an offset into the array src1.
1397
1397
  * @returns Return an array
1398
1398
  */
1399
- static multiplyQuaternionsFlat(t, s, e, n, i, r) {
1400
- const h = e[n], a = e[n + 1], o = e[n + 2], c = e[n + 3], l = i[r], m = i[r + 1], d = i[r + 2], x = i[r + 3];
1401
- return t[s] = h * x + c * l + a * d - o * m, t[s + 1] = a * x + c * m + o * l - h * d, t[s + 2] = o * x + c * d + h * m - a * l, t[s + 3] = c * x - h * l - a * m - o * d, t;
1399
+ static multiplyQuaternionsFlat(t, s, e, n, i, h) {
1400
+ const r = e[n], a = e[n + 1], o = e[n + 2], c = e[n + 3], l = i[h], d = i[h + 1], m = i[h + 2], x = i[h + 3];
1401
+ return t[s] = r * x + c * l + a * m - o * d, t[s + 1] = a * x + c * d + o * l - r * m, t[s + 2] = o * x + c * m + r * d - a * l, t[s + 3] = c * x - r * l - a * d - o * m, t;
1402
1402
  }
1403
1403
  /**
1404
1404
  * X cooridinate
@@ -1469,29 +1469,29 @@ class pt {
1469
1469
  * @returns Return this quaternion
1470
1470
  */
1471
1471
  setFromEuler(t, s = !0) {
1472
- const e = t.x, n = t.y, i = t.z, r = t.order, h = Math.cos, a = Math.sin, o = h(e / 2), c = h(n / 2), l = h(i / 2), m = a(e / 2), d = a(n / 2), x = a(i / 2);
1473
- switch (r) {
1472
+ const e = t.x, n = t.y, i = t.z, h = t.order, r = Math.cos, a = Math.sin, o = r(e / 2), c = r(n / 2), l = r(i / 2), d = a(e / 2), m = a(n / 2), x = a(i / 2);
1473
+ switch (h) {
1474
1474
  case "XYZ":
1475
- this._x = m * c * l + o * d * x, this._y = o * d * l - m * c * x, this._z = o * c * x + m * d * l, this._w = o * c * l - m * d * x;
1475
+ this._x = d * c * l + o * m * x, this._y = o * m * l - d * c * x, this._z = o * c * x + d * m * l, this._w = o * c * l - d * m * x;
1476
1476
  break;
1477
1477
  case "YXZ":
1478
- this._x = m * c * l + o * d * x, this._y = o * d * l - m * c * x, this._z = o * c * x - m * d * l, this._w = o * c * l + m * d * x;
1478
+ this._x = d * c * l + o * m * x, this._y = o * m * l - d * c * x, this._z = o * c * x - d * m * l, this._w = o * c * l + d * m * x;
1479
1479
  break;
1480
1480
  case "ZXY":
1481
- this._x = m * c * l - o * d * x, this._y = o * d * l + m * c * x, this._z = o * c * x + m * d * l, this._w = o * c * l - m * d * x;
1481
+ this._x = d * c * l - o * m * x, this._y = o * m * l + d * c * x, this._z = o * c * x + d * m * l, this._w = o * c * l - d * m * x;
1482
1482
  break;
1483
1483
  case "ZYX":
1484
- this._x = m * c * l - o * d * x, this._y = o * d * l + m * c * x, this._z = o * c * x - m * d * l, this._w = o * c * l + m * d * x;
1484
+ this._x = d * c * l - o * m * x, this._y = o * m * l + d * c * x, this._z = o * c * x - d * m * l, this._w = o * c * l + d * m * x;
1485
1485
  break;
1486
1486
  case "YZX":
1487
- this._x = m * c * l + o * d * x, this._y = o * d * l + m * c * x, this._z = o * c * x - m * d * l, this._w = o * c * l - m * d * x;
1487
+ this._x = d * c * l + o * m * x, this._y = o * m * l + d * c * x, this._z = o * c * x - d * m * l, this._w = o * c * l - d * m * x;
1488
1488
  break;
1489
1489
  case "XZY":
1490
- this._x = m * c * l - o * d * x, this._y = o * d * l - m * c * x, this._z = o * c * x + m * d * l, this._w = o * c * l + m * d * x;
1490
+ this._x = d * c * l - o * m * x, this._y = o * m * l - d * c * x, this._z = o * c * x + d * m * l, this._w = o * c * l + d * m * x;
1491
1491
  break;
1492
1492
  default:
1493
1493
  console.warn(
1494
- "THREE.Quaternion: .setFromEuler() encountered an unknown order: " + r
1494
+ "THREE.Quaternion: .setFromEuler() encountered an unknown order: " + h
1495
1495
  );
1496
1496
  }
1497
1497
  return s === !0 && this._onChangeCallback(), this;
@@ -1513,19 +1513,19 @@ class pt {
1513
1513
  * @returns Return this quaternion
1514
1514
  */
1515
1515
  setFromRotationMatrix(t) {
1516
- const s = t.elements, e = s[0], n = s[4], i = s[8], r = s[1], h = s[5], a = s[9], o = s[2], c = s[6], l = s[10], m = e + h + l;
1517
- if (m > 0) {
1518
- const d = 0.5 / Math.sqrt(m + 1);
1519
- this._w = 0.25 / d, this._x = (c - a) * d, this._y = (i - o) * d, this._z = (r - n) * d;
1520
- } else if (e > h && e > l) {
1521
- const d = 2 * Math.sqrt(1 + e - h - l);
1522
- this._w = (c - a) / d, this._x = 0.25 * d, this._y = (n + r) / d, this._z = (i + o) / d;
1523
- } else if (h > l) {
1524
- const d = 2 * Math.sqrt(1 + h - e - l);
1525
- this._w = (i - o) / d, this._x = (n + r) / d, this._y = 0.25 * d, this._z = (a + c) / d;
1516
+ const s = t.elements, e = s[0], n = s[4], i = s[8], h = s[1], r = s[5], a = s[9], o = s[2], c = s[6], l = s[10], d = e + r + l;
1517
+ if (d > 0) {
1518
+ const m = 0.5 / Math.sqrt(d + 1);
1519
+ this._w = 0.25 / m, this._x = (c - a) * m, this._y = (i - o) * m, this._z = (h - n) * m;
1520
+ } else if (e > r && e > l) {
1521
+ const m = 2 * Math.sqrt(1 + e - r - l);
1522
+ this._w = (c - a) / m, this._x = 0.25 * m, this._y = (n + h) / m, this._z = (i + o) / m;
1523
+ } else if (r > l) {
1524
+ const m = 2 * Math.sqrt(1 + r - e - l);
1525
+ this._w = (i - o) / m, this._x = (n + h) / m, this._y = 0.25 * m, this._z = (a + c) / m;
1526
1526
  } else {
1527
- const d = 2 * Math.sqrt(1 + l - e - h);
1528
- this._w = (r - n) / d, this._x = (i + o) / d, this._y = (a + c) / d, this._z = 0.25 * d;
1527
+ const m = 2 * Math.sqrt(1 + l - e - r);
1528
+ this._w = (h - n) / m, this._x = (i + o) / m, this._y = (a + c) / m, this._z = 0.25 * m;
1529
1529
  }
1530
1530
  return this._onChangeCallback(), this;
1531
1531
  }
@@ -1642,8 +1642,8 @@ class pt {
1642
1642
  * @returns Return this quaternion
1643
1643
  */
1644
1644
  multiplyQuaternions(t, s) {
1645
- const e = t._x, n = t._y, i = t._z, r = t._w, h = s._x, a = s._y, o = s._z, c = s._w;
1646
- return this._x = e * c + r * h + n * o - i * a, this._y = n * c + r * a + i * h - e * o, this._z = i * c + r * o + e * a - n * h, this._w = r * c - e * h - n * a - i * o, this._onChangeCallback(), this;
1645
+ const e = t._x, n = t._y, i = t._z, h = t._w, r = s._x, a = s._y, o = s._z, c = s._w;
1646
+ return this._x = e * c + h * r + n * o - i * a, this._y = n * c + h * a + i * r - e * o, this._z = i * c + h * o + e * a - n * r, this._w = h * c - e * r - n * a - i * o, this._onChangeCallback(), this;
1647
1647
  }
1648
1648
  /**
1649
1649
  * Handles the spherical linear interpolation between quaternions. t represents the amount of rotation
@@ -1655,17 +1655,17 @@ class pt {
1655
1655
  slerp(t, s) {
1656
1656
  if (s === 0) return this;
1657
1657
  if (s === 1) return this.copy(t);
1658
- const e = this._x, n = this._y, i = this._z, r = this._w;
1659
- let h = r * t._w + e * t._x + n * t._y + i * t._z;
1660
- if (h < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, h = -h) : this.copy(t), h >= 1)
1661
- return this._w = r, this._x = e, this._y = n, this._z = i, this;
1662
- const a = 1 - h * h;
1658
+ const e = this._x, n = this._y, i = this._z, h = this._w;
1659
+ let r = h * t._w + e * t._x + n * t._y + i * t._z;
1660
+ if (r < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, r = -r) : this.copy(t), r >= 1)
1661
+ return this._w = h, this._x = e, this._y = n, this._z = i, this;
1662
+ const a = 1 - r * r;
1663
1663
  if (a <= Number.EPSILON) {
1664
- const d = 1 - s;
1665
- return this._w = d * r + s * this._w, this._x = d * e + s * this._x, this._y = d * n + s * this._y, this._z = d * i + s * this._z, this.normalize(), this;
1664
+ const m = 1 - s;
1665
+ return this._w = m * h + s * this._w, this._x = m * e + s * this._x, this._y = m * n + s * this._y, this._z = m * i + s * this._z, this.normalize(), this;
1666
1666
  }
1667
- const o = Math.sqrt(a), c = Math.atan2(o, h), l = Math.sin((1 - s) * c) / o, m = Math.sin(s * c) / o;
1668
- return this._w = r * l + this._w * m, this._x = e * l + this._x * m, this._y = n * l + this._y * m, this._z = i * l + this._z * m, this._onChangeCallback(), this;
1667
+ const o = Math.sqrt(a), c = Math.atan2(o, r), l = Math.sin((1 - s) * c) / o, d = Math.sin(s * c) / o;
1668
+ return this._w = h * l + this._w * d, this._x = e * l + this._x * d, this._y = n * l + this._y * d, this._z = i * l + this._z * d, this._onChangeCallback(), this;
1669
1669
  }
1670
1670
  /**
1671
1671
  * Perform a spherical linear interpolation between the given quaternions and stores the result in
@@ -1744,8 +1744,8 @@ const N = class N {
1744
1744
  return;
1745
1745
  }
1746
1746
  if (n === 1) {
1747
- const { x: i, y: r, z: h } = t;
1748
- this.x = i, this.y = r, this.z = h || 0;
1747
+ const { x: i, y: h, z: r } = t;
1748
+ this.x = i, this.y = h, this.z = r || 0;
1749
1749
  return;
1750
1750
  }
1751
1751
  if (n === 3) {
@@ -1981,8 +1981,8 @@ const N = class N {
1981
1981
  * @returns Return this vector
1982
1982
  */
1983
1983
  applyMatrix3d(t) {
1984
- const s = this.x, e = this.y, n = this.z, i = t.elements, r = 1 / (i[3] * s + i[7] * e + i[11] * n + i[15]);
1985
- return this.x = (i[0] * s + i[4] * e + i[8] * n + i[12]) * r, this.y = (i[1] * s + i[5] * e + i[9] * n + i[13]) * r, this.z = (i[2] * s + i[6] * e + i[10] * n + i[14]) * r, this;
1984
+ const s = this.x, e = this.y, n = this.z, i = t.elements, h = 1 / (i[3] * s + i[7] * e + i[11] * n + i[15]);
1985
+ return this.x = (i[0] * s + i[4] * e + i[8] * n + i[12]) * h, this.y = (i[1] * s + i[5] * e + i[9] * n + i[13]) * h, this.z = (i[2] * s + i[6] * e + i[10] * n + i[14]) * h, this;
1986
1986
  }
1987
1987
  /**
1988
1988
  * Apply a quaternion transform to this vector.
@@ -1990,8 +1990,8 @@ const N = class N {
1990
1990
  * @returns Return this vector
1991
1991
  */
1992
1992
  applyQuaternion(t) {
1993
- const s = this.x, e = this.y, n = this.z, i = t.x, r = t.y, h = t.z, a = t.w, o = 2 * (r * n - h * e), c = 2 * (h * s - i * n), l = 2 * (i * e - r * s);
1994
- return this.x = s + a * o + r * l - h * c, this.y = e + a * c + h * o - i * l, this.z = n + a * l + i * c - r * o, this;
1993
+ const s = this.x, e = this.y, n = this.z, i = t.x, h = t.y, r = t.z, a = t.w, o = 2 * (h * n - r * e), c = 2 * (r * s - i * n), l = 2 * (i * e - h * s);
1994
+ return this.x = s + a * o + h * l - r * c, this.y = e + a * c + r * o - i * l, this.z = n + a * l + i * c - h * o, this;
1995
1995
  }
1996
1996
  /**
1997
1997
  * Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a m) and
@@ -2202,8 +2202,8 @@ const N = class N {
2202
2202
  * @returns Return this vector
2203
2203
  */
2204
2204
  crossVectors(t, s) {
2205
- const e = t.x, n = t.y, i = t.z, r = s.x, h = s.y, a = s.z;
2206
- return this.x = n * a - i * h, this.y = i * r - e * a, this.z = e * h - n * r, this;
2205
+ const e = t.x, n = t.y, i = t.z, h = s.x, r = s.y, a = s.z;
2206
+ return this.x = n * a - i * r, this.y = i * h - e * a, this.z = e * r - n * h, this;
2207
2207
  }
2208
2208
  /**
2209
2209
  * Project this vector onto v.
@@ -2223,7 +2223,7 @@ const N = class N {
2223
2223
  * @returns Return this vector
2224
2224
  */
2225
2225
  projectOnPlane(t) {
2226
- return ft.copy(this).projectOnVector(t), this.sub(ft);
2226
+ return wt.copy(this).projectOnVector(t), this.sub(wt);
2227
2227
  }
2228
2228
  /**
2229
2229
  * Reflect this vector off of plane orthogonal to normal. Normal is assumed to have unit length.
@@ -2231,7 +2231,7 @@ const N = class N {
2231
2231
  * @returns Return this vector
2232
2232
  */
2233
2233
  reflect(t) {
2234
- return this.sub(ft.copy(t).multiplyScalar(2 * this.dot(t)));
2234
+ return this.sub(wt.copy(t).multiplyScalar(2 * this.dot(t)));
2235
2235
  }
2236
2236
  /**
2237
2237
  * Return the angle between this vector and vector v in radians.
@@ -2374,7 +2374,7 @@ const N = class N {
2374
2374
  };
2375
2375
  N.X_AXIS = Object.freeze(new N(1, 0, 0)), N.NEGATIVE_X_AXIS = Object.freeze(new N(-1, 0, 0)), N.Y_AXIS = Object.freeze(new N(0, 1, 0)), N.NEGATIVE_Y_AXIS = Object.freeze(new N(0, -1, 0)), N.Z_AXIS = Object.freeze(new N(0, 0, 1)), N.NEGATIVE_Z_AXIS = Object.freeze(new N(0, 0, -1));
2376
2376
  let y = N;
2377
- const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2377
+ const wt = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2378
2378
  /**
2379
2379
  * Create a 4x4 matrix with the given arguments in row-major order. If no arguments are provided,
2380
2380
  * the constructor initializes the Matrix4 to the 4x4 identity matrix.
@@ -2396,21 +2396,21 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2396
2396
  * @param n43 Input element in the forth row and the third column
2397
2397
  * @param n44 Input element in the forth row and the forth column
2398
2398
  */
2399
- constructor(t, s, e, n, i, r, h, a, o, c, l, m, d, x, g, p) {
2400
- this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && r != null && h != null && a != null && o != null && c != null && l != null && m != null && d != null && x != null && g != null && p != null && this.set(
2399
+ constructor(t, s, e, n, i, h, r, a, o, c, l, d, m, x, g, p) {
2400
+ this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && h != null && r != null && a != null && o != null && c != null && l != null && d != null && m != null && x != null && g != null && p != null && this.set(
2401
2401
  t,
2402
2402
  s,
2403
2403
  e,
2404
2404
  n,
2405
2405
  i,
2406
- r,
2407
2406
  h,
2407
+ r,
2408
2408
  a,
2409
2409
  o,
2410
2410
  c,
2411
2411
  l,
2412
- m,
2413
2412
  d,
2413
+ m,
2414
2414
  x,
2415
2415
  g,
2416
2416
  p
@@ -2437,9 +2437,9 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2437
2437
  * @param n44 Input element in the forth row and the forth column
2438
2438
  * @returns Return this matrix
2439
2439
  */
2440
- set(t, s, e, n, i, r, h, a, o, c, l, m, d, x, g, p) {
2440
+ set(t, s, e, n, i, h, r, a, o, c, l, d, m, x, g, p) {
2441
2441
  const _ = this.elements;
2442
- return _[0] = t, _[4] = s, _[8] = e, _[12] = n, _[1] = i, _[5] = r, _[9] = h, _[13] = a, _[2] = o, _[6] = c, _[10] = l, _[14] = m, _[3] = d, _[7] = x, _[11] = g, _[15] = p, this;
2442
+ return _[0] = t, _[4] = s, _[8] = e, _[12] = n, _[1] = i, _[5] = h, _[9] = r, _[13] = a, _[2] = o, _[6] = c, _[10] = l, _[14] = d, _[3] = m, _[7] = x, _[11] = g, _[15] = p, this;
2443
2443
  }
2444
2444
  /**
2445
2445
  * Reset this matrix to the identity matrix.
@@ -2571,8 +2571,8 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2571
2571
  * @returns Return this matrix
2572
2572
  */
2573
2573
  extractRotation(t) {
2574
- const s = this.elements, e = t.elements, n = 1 / O.setFromMatrixColumn(t, 0).length(), i = 1 / O.setFromMatrixColumn(t, 1).length(), r = 1 / O.setFromMatrixColumn(t, 2).length();
2575
- return s[0] = e[0] * n, s[1] = e[1] * n, s[2] = e[2] * n, s[3] = 0, s[4] = e[4] * i, s[5] = e[5] * i, s[6] = e[6] * i, s[7] = 0, s[8] = e[8] * r, s[9] = e[9] * r, s[10] = e[10] * r, s[11] = 0, s[12] = 0, s[13] = 0, s[14] = 0, s[15] = 1, this;
2574
+ const s = this.elements, e = t.elements, n = 1 / O.setFromMatrixColumn(t, 0).length(), i = 1 / O.setFromMatrixColumn(t, 1).length(), h = 1 / O.setFromMatrixColumn(t, 2).length();
2575
+ return s[0] = e[0] * n, s[1] = e[1] * n, s[2] = e[2] * n, s[3] = 0, s[4] = e[4] * i, s[5] = e[5] * i, s[6] = e[6] * i, s[7] = 0, s[8] = e[8] * h, s[9] = e[9] * h, s[10] = e[10] * h, s[11] = 0, s[12] = 0, s[13] = 0, s[14] = 0, s[15] = 1, this;
2576
2576
  }
2577
2577
  // makeRotationFromEuler(euler) {
2578
2578
  // const te = this.elements
@@ -2723,8 +2723,8 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2723
2723
  * @returns Return this matrix
2724
2724
  */
2725
2725
  multiplyMatrices(t, s) {
2726
- const e = t.elements, n = s.elements, i = this.elements, r = e[0], h = e[4], a = e[8], o = e[12], c = e[1], l = e[5], m = e[9], d = e[13], x = e[2], g = e[6], p = e[10], _ = e[14], w = e[3], f = e[7], A = e[11], M = e[15], B = n[0], z = n[4], E = n[8], Z = n[12], G = n[1], F = n[5], K = n[9], et = n[13], nt = n[2], it = n[6], rt = n[10], ht = n[14], ot = n[3], at = n[7], ct = n[11], lt = n[15];
2727
- return i[0] = r * B + h * G + a * nt + o * ot, i[4] = r * z + h * F + a * it + o * at, i[8] = r * E + h * K + a * rt + o * ct, i[12] = r * Z + h * et + a * ht + o * lt, i[1] = c * B + l * G + m * nt + d * ot, i[5] = c * z + l * F + m * it + d * at, i[9] = c * E + l * K + m * rt + d * ct, i[13] = c * Z + l * et + m * ht + d * lt, i[2] = x * B + g * G + p * nt + _ * ot, i[6] = x * z + g * F + p * it + _ * at, i[10] = x * E + g * K + p * rt + _ * ct, i[14] = x * Z + g * et + p * ht + _ * lt, i[3] = w * B + f * G + A * nt + M * ot, i[7] = w * z + f * F + A * it + M * at, i[11] = w * E + f * K + A * rt + M * ct, i[15] = w * Z + f * et + A * ht + M * lt, this;
2726
+ const e = t.elements, n = s.elements, i = this.elements, h = e[0], r = e[4], a = e[8], o = e[12], c = e[1], l = e[5], d = e[9], m = e[13], x = e[2], g = e[6], p = e[10], _ = e[14], f = e[3], w = e[7], A = e[11], M = e[15], B = n[0], z = n[4], E = n[8], Z = n[12], G = n[1], F = n[5], K = n[9], et = n[13], nt = n[2], it = n[6], rt = n[10], ht = n[14], ot = n[3], at = n[7], ct = n[11], lt = n[15];
2727
+ return i[0] = h * B + r * G + a * nt + o * ot, i[4] = h * z + r * F + a * it + o * at, i[8] = h * E + r * K + a * rt + o * ct, i[12] = h * Z + r * et + a * ht + o * lt, i[1] = c * B + l * G + d * nt + m * ot, i[5] = c * z + l * F + d * it + m * at, i[9] = c * E + l * K + d * rt + m * ct, i[13] = c * Z + l * et + d * ht + m * lt, i[2] = x * B + g * G + p * nt + _ * ot, i[6] = x * z + g * F + p * it + _ * at, i[10] = x * E + g * K + p * rt + _ * ct, i[14] = x * Z + g * et + p * ht + _ * lt, i[3] = f * B + w * G + A * nt + M * ot, i[7] = f * z + w * F + A * it + M * at, i[11] = f * E + w * K + A * rt + M * ct, i[15] = f * Z + w * et + A * ht + M * lt, this;
2728
2728
  }
2729
2729
  /**
2730
2730
  * Multiply every component of the matrix by a scalar value s.
@@ -2740,8 +2740,8 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2740
2740
  * @returns Return the determinant of this matrix.
2741
2741
  */
2742
2742
  determinant() {
2743
- const t = this.elements, s = t[0], e = t[4], n = t[8], i = t[12], r = t[1], h = t[5], a = t[9], o = t[13], c = t[2], l = t[6], m = t[10], d = t[14], x = t[3], g = t[7], p = t[11], _ = t[15];
2744
- return x * (+i * a * l - n * o * l - i * h * m + e * o * m + n * h * d - e * a * d) + g * (+s * a * d - s * o * m + i * r * m - n * r * d + n * o * c - i * a * c) + p * (+s * o * l - s * h * d - i * r * l + e * r * d + i * h * c - e * o * c) + _ * (-n * h * c - s * a * l + s * h * m + n * r * l - e * r * m + e * a * c);
2743
+ const t = this.elements, s = t[0], e = t[4], n = t[8], i = t[12], h = t[1], r = t[5], a = t[9], o = t[13], c = t[2], l = t[6], d = t[10], m = t[14], x = t[3], g = t[7], p = t[11], _ = t[15];
2744
+ return x * (+i * a * l - n * o * l - i * r * d + e * o * d + n * r * m - e * a * m) + g * (+s * a * m - s * o * d + i * h * d - n * h * m + n * o * c - i * a * c) + p * (+s * o * l - s * r * m - i * h * l + e * h * m + i * r * c - e * o * c) + _ * (-n * r * c - s * a * l + s * r * d + n * h * l - e * h * d + e * a * c);
2745
2745
  }
2746
2746
  /**
2747
2747
  * Transposes this matrix.
@@ -2769,11 +2769,11 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2769
2769
  * @returns Return this matrix
2770
2770
  */
2771
2771
  invert() {
2772
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], h = t[5], a = t[6], o = t[7], c = t[8], l = t[9], m = t[10], d = t[11], x = t[12], g = t[13], p = t[14], _ = t[15], w = l * p * o - g * m * o + g * a * d - h * p * d - l * a * _ + h * m * _, f = x * m * o - c * p * o - x * a * d + r * p * d + c * a * _ - r * m * _, A = c * g * o - x * l * o + x * h * d - r * g * d - c * h * _ + r * l * _, M = x * l * a - c * g * a - x * h * m + r * g * m + c * h * p - r * l * p, B = s * w + e * f + n * A + i * M;
2772
+ const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], h = t[4], r = t[5], a = t[6], o = t[7], c = t[8], l = t[9], d = t[10], m = t[11], x = t[12], g = t[13], p = t[14], _ = t[15], f = l * p * o - g * d * o + g * a * m - r * p * m - l * a * _ + r * d * _, w = x * d * o - c * p * o - x * a * m + h * p * m + c * a * _ - h * d * _, A = c * g * o - x * l * o + x * r * m - h * g * m - c * r * _ + h * l * _, M = x * l * a - c * g * a - x * r * d + h * g * d + c * r * p - h * l * p, B = s * f + e * w + n * A + i * M;
2773
2773
  if (B === 0)
2774
2774
  return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2775
2775
  const z = 1 / B;
2776
- return t[0] = w * z, t[1] = (g * m * i - l * p * i - g * n * d + e * p * d + l * n * _ - e * m * _) * z, t[2] = (h * p * i - g * a * i + g * n * o - e * p * o - h * n * _ + e * a * _) * z, t[3] = (l * a * i - h * m * i - l * n * o + e * m * o + h * n * d - e * a * d) * z, t[4] = f * z, t[5] = (c * p * i - x * m * i + x * n * d - s * p * d - c * n * _ + s * m * _) * z, t[6] = (x * a * i - r * p * i - x * n * o + s * p * o + r * n * _ - s * a * _) * z, t[7] = (r * m * i - c * a * i + c * n * o - s * m * o - r * n * d + s * a * d) * z, t[8] = A * z, t[9] = (x * l * i - c * g * i - x * e * d + s * g * d + c * e * _ - s * l * _) * z, t[10] = (r * g * i - x * h * i + x * e * o - s * g * o - r * e * _ + s * h * _) * z, t[11] = (c * h * i - r * l * i - c * e * o + s * l * o + r * e * d - s * h * d) * z, t[12] = M * z, t[13] = (c * g * n - x * l * n + x * e * m - s * g * m - c * e * p + s * l * p) * z, t[14] = (x * h * n - r * g * n - x * e * a + s * g * a + r * e * p - s * h * p) * z, t[15] = (r * l * n - c * h * n + c * e * a - s * l * a - r * e * m + s * h * m) * z, this;
2776
+ return t[0] = f * z, t[1] = (g * d * i - l * p * i - g * n * m + e * p * m + l * n * _ - e * d * _) * z, t[2] = (r * p * i - g * a * i + g * n * o - e * p * o - r * n * _ + e * a * _) * z, t[3] = (l * a * i - r * d * i - l * n * o + e * d * o + r * n * m - e * a * m) * z, t[4] = w * z, t[5] = (c * p * i - x * d * i + x * n * m - s * p * m - c * n * _ + s * d * _) * z, t[6] = (x * a * i - h * p * i - x * n * o + s * p * o + h * n * _ - s * a * _) * z, t[7] = (h * d * i - c * a * i + c * n * o - s * d * o - h * n * m + s * a * m) * z, t[8] = A * z, t[9] = (x * l * i - c * g * i - x * e * m + s * g * m + c * e * _ - s * l * _) * z, t[10] = (h * g * i - x * r * i + x * e * o - s * g * o - h * e * _ + s * r * _) * z, t[11] = (c * r * i - h * l * i - c * e * o + s * l * o + h * e * m - s * r * m) * z, t[12] = M * z, t[13] = (c * g * n - x * l * n + x * e * d - s * g * d - c * e * p + s * l * p) * z, t[14] = (x * r * n - h * g * n - x * e * a + s * g * a + h * e * p - s * r * p) * z, t[15] = (h * l * n - c * r * n + c * e * a - s * l * a - h * e * d + s * r * d) * z, this;
2777
2777
  }
2778
2778
  /**
2779
2779
  * Multiply the columns of this matrix by vector v.
@@ -2836,18 +2836,18 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2836
2836
  * @returns Return this matrix
2837
2837
  */
2838
2838
  makeRotationAxis(t, s) {
2839
- const e = Math.cos(s), n = Math.sin(s), i = 1 - e, r = t.x, h = t.y, a = t.z, o = i * r, c = i * h;
2839
+ const e = Math.cos(s), n = Math.sin(s), i = 1 - e, h = t.x, r = t.y, a = t.z, o = i * h, c = i * r;
2840
2840
  return this.set(
2841
- o * r + e,
2842
- o * h - n * a,
2843
- o * a + n * h,
2841
+ o * h + e,
2842
+ o * r - n * a,
2843
+ o * a + n * r,
2844
2844
  0,
2845
- o * h + n * a,
2846
- c * h + e,
2847
- c * a - n * r,
2845
+ o * r + n * a,
2846
+ c * r + e,
2847
+ c * a - n * h,
2848
2848
  0,
2849
- o * a - n * h,
2850
- c * a + n * r,
2849
+ o * a - n * r,
2850
+ c * a + n * h,
2851
2851
  i * a * a + e,
2852
2852
  0,
2853
2853
  0,
@@ -2876,8 +2876,8 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2876
2876
  * @param zy Input the amount to shear Z by Y.
2877
2877
  * @returns Return this matrix
2878
2878
  */
2879
- makeShear(t, s, e, n, i, r) {
2880
- return this.set(1, e, i, 0, t, 1, r, 0, s, n, 1, 0, 0, 0, 0, 1), this;
2879
+ makeShear(t, s, e, n, i, h) {
2880
+ return this.set(1, e, i, 0, t, 1, h, 0, s, n, 1, 0, 0, 0, 0, 1), this;
2881
2881
  }
2882
2882
  /**
2883
2883
  * Set this matrix to the transformation composed of position, quaternion and scale.
@@ -2887,8 +2887,8 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2887
2887
  * @returns Return this matrix
2888
2888
  */
2889
2889
  compose(t, s, e) {
2890
- const n = this.elements, i = s.x, r = s.y, h = s.z, a = s.w, o = i + i, c = r + r, l = h + h, m = i * o, d = i * c, x = i * l, g = r * c, p = r * l, _ = h * l, w = a * o, f = a * c, A = a * l, M = e.x, B = e.y, z = e.z;
2891
- return n[0] = (1 - (g + _)) * M, n[1] = (d + A) * M, n[2] = (x - f) * M, n[3] = 0, n[4] = (d - A) * B, n[5] = (1 - (m + _)) * B, n[6] = (p + w) * B, n[7] = 0, n[8] = (x + f) * z, n[9] = (p - w) * z, n[10] = (1 - (m + g)) * z, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
2890
+ const n = this.elements, i = s.x, h = s.y, r = s.z, a = s.w, o = i + i, c = h + h, l = r + r, d = i * o, m = i * c, x = i * l, g = h * c, p = h * l, _ = r * l, f = a * o, w = a * c, A = a * l, M = e.x, B = e.y, z = e.z;
2891
+ return n[0] = (1 - (g + _)) * M, n[1] = (m + A) * M, n[2] = (x - w) * M, n[3] = 0, n[4] = (m - A) * B, n[5] = (1 - (d + _)) * B, n[6] = (p + f) * B, n[7] = 0, n[8] = (x + w) * z, n[9] = (p - f) * z, n[10] = (1 - (d + g)) * z, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
2892
2892
  }
2893
2893
  /**
2894
2894
  * Decompose this matrix into its position, quaternion and scale components.
@@ -2904,10 +2904,10 @@ const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
2904
2904
  decompose(t, s, e) {
2905
2905
  const n = this.elements;
2906
2906
  let i = O.set(n[0], n[1], n[2]).length();
2907
- const r = O.set(n[4], n[5], n[6]).length(), h = O.set(n[8], n[9], n[10]).length();
2907
+ const h = O.set(n[4], n[5], n[6]).length(), r = O.set(n[8], n[9], n[10]).length();
2908
2908
  this.determinant() < 0 && (i = -i), t.x = n[12], t.y = n[13], t.z = n[14], R.copy(this);
2909
- const o = 1 / i, c = 1 / r, l = 1 / h;
2910
- return R.elements[0] *= o, R.elements[1] *= o, R.elements[2] *= o, R.elements[4] *= c, R.elements[5] *= c, R.elements[6] *= c, R.elements[8] *= l, R.elements[9] *= l, R.elements[10] *= l, s.setFromRotationMatrix(R), e.x = i, e.y = r, e.z = h, this;
2909
+ const o = 1 / i, c = 1 / h, l = 1 / r;
2910
+ return R.elements[0] *= o, R.elements[1] *= o, R.elements[2] *= o, R.elements[4] *= c, R.elements[5] *= c, R.elements[6] *= c, R.elements[8] *= l, R.elements[9] *= l, R.elements[10] *= l, s.setFromRotationMatrix(R), e.x = i, e.y = h, e.z = r, this;
2911
2911
  }
2912
2912
  // makePerspective(
2913
2913
  // left,
@@ -3065,7 +3065,7 @@ class Y {
3065
3065
  setFromArray(t) {
3066
3066
  this.makeEmpty();
3067
3067
  for (let s = 0, e = t.length; s < e; s += 3)
3068
- this.expandByPoint(wt.fromArray(t, s));
3068
+ this.expandByPoint(ft.fromArray(t, s));
3069
3069
  return this;
3070
3070
  }
3071
3071
  /**
@@ -3086,7 +3086,7 @@ class Y {
3086
3086
  * @returns Return this box
3087
3087
  */
3088
3088
  setFromCenterAndSize(t, s) {
3089
- const e = wt.copy(s).multiplyScalar(0.5);
3089
+ const e = ft.copy(s).multiplyScalar(0.5);
3090
3090
  return this.min.copy(t).sub(e), this.max.copy(t).add(e), this;
3091
3091
  }
3092
3092
  /**
@@ -3237,7 +3237,7 @@ class Y {
3237
3237
  * @returns Return the distance from any edge of this box to the specified point.
3238
3238
  */
3239
3239
  distanceToPoint(t) {
3240
- return this.clampPoint(t, wt).distanceTo(t);
3240
+ return this.clampPoint(t, ft).distanceTo(t);
3241
3241
  }
3242
3242
  /**
3243
3243
  * Compute the intersection of this and box, setting the upper bound of this box to the lesser of the
@@ -3293,7 +3293,7 @@ const U = [
3293
3293
  /* @__PURE__ */ new y(),
3294
3294
  /* @__PURE__ */ new y(),
3295
3295
  /* @__PURE__ */ new y()
3296
- ], wt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new P();
3296
+ ], ft = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new P();
3297
3297
  class V {
3298
3298
  /**
3299
3299
  * Create a 2d box bounded by min and max.
@@ -3511,7 +3511,7 @@ class V {
3511
3511
  return t.min.equals(this.min) && t.max.equals(this.max);
3512
3512
  }
3513
3513
  }
3514
- const It = /* @__PURE__ */ new y(), fs = /* @__PURE__ */ new y(), ws = /* @__PURE__ */ new v();
3514
+ const It = /* @__PURE__ */ new y(), ws = /* @__PURE__ */ new y(), fs = /* @__PURE__ */ new v();
3515
3515
  class zt {
3516
3516
  /**
3517
3517
  * Create one plane
@@ -3560,7 +3560,7 @@ class zt {
3560
3560
  * @returns Return this plane
3561
3561
  */
3562
3562
  setFromCoplanarPoints(t, s, e) {
3563
- const n = It.subVectors(e, s).cross(fs.subVectors(t, s)).normalize();
3563
+ const n = It.subVectors(e, s).cross(ws.subVectors(t, s)).normalize();
3564
3564
  return this.setFromNormalAndCoplanarPoint(n, t), this;
3565
3565
  }
3566
3566
  /**
@@ -3662,7 +3662,7 @@ class zt {
3662
3662
  * @returns Return this plane
3663
3663
  */
3664
3664
  applyMatrix4(t, s) {
3665
- const e = s || ws.getNormalMatrix(t), n = this.coplanarPoint(It).applyMatrix3d(t), i = this.normal.applyMatrix3(e).normalize();
3665
+ const e = s || fs.getNormalMatrix(t), n = this.coplanarPoint(It).applyMatrix3d(t), i = this.normal.applyMatrix3(e).normalize();
3666
3666
  return this.constant = -n.dot(i), this;
3667
3667
  }
3668
3668
  /**
@@ -3712,8 +3712,8 @@ class S extends y {
3712
3712
  */
3713
3713
  static pointArrayToNumberArray(t, s = !0) {
3714
3714
  const e = s ? 3 : 2, n = new Array(t.length * e);
3715
- return t.forEach((i, r) => {
3716
- i.toArray(n, r * e);
3715
+ return t.forEach((i, h) => {
3716
+ i.toArray(n, h * e);
3717
3717
  }), n;
3718
3718
  }
3719
3719
  }
@@ -3809,25 +3809,25 @@ const Et = /* @__PURE__ */ new tt(), kt = /* @__PURE__ */ new pt(), J = class J
3809
3809
  * @returns Return this euler
3810
3810
  */
3811
3811
  setFromRotationMatrix(t, s = this._order, e = !0) {
3812
- const n = t.elements, i = n[0], r = n[4], h = n[8], a = n[1], o = n[5], c = n[9], l = n[2], m = n[6], d = n[10];
3812
+ const n = t.elements, i = n[0], h = n[4], r = n[8], a = n[1], o = n[5], c = n[9], l = n[2], d = n[6], m = n[10];
3813
3813
  switch (s) {
3814
3814
  case "XYZ":
3815
- this._y = Math.asin(j(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(-c, d), this._z = Math.atan2(-r, i)) : (this._x = Math.atan2(m, o), this._z = 0);
3815
+ this._y = Math.asin(j(r, -1, 1)), Math.abs(r) < 0.9999999 ? (this._x = Math.atan2(-c, m), this._z = Math.atan2(-h, i)) : (this._x = Math.atan2(d, o), this._z = 0);
3816
3816
  break;
3817
3817
  case "YXZ":
3818
- this._x = Math.asin(-j(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._y = Math.atan2(h, d), this._z = Math.atan2(a, o)) : (this._y = Math.atan2(-l, i), this._z = 0);
3818
+ this._x = Math.asin(-j(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._y = Math.atan2(r, m), this._z = Math.atan2(a, o)) : (this._y = Math.atan2(-l, i), this._z = 0);
3819
3819
  break;
3820
3820
  case "ZXY":
3821
- this._x = Math.asin(j(m, -1, 1)), Math.abs(m) < 0.9999999 ? (this._y = Math.atan2(-l, d), this._z = Math.atan2(-r, o)) : (this._y = 0, this._z = Math.atan2(a, i));
3821
+ this._x = Math.asin(j(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-l, m), this._z = Math.atan2(-h, o)) : (this._y = 0, this._z = Math.atan2(a, i));
3822
3822
  break;
3823
3823
  case "ZYX":
3824
- this._y = Math.asin(-j(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(m, d), this._z = Math.atan2(a, i)) : (this._x = 0, this._z = Math.atan2(-r, o));
3824
+ this._y = Math.asin(-j(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(d, m), this._z = Math.atan2(a, i)) : (this._x = 0, this._z = Math.atan2(-h, o));
3825
3825
  break;
3826
3826
  case "YZX":
3827
- this._z = Math.asin(j(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(-c, o), this._y = Math.atan2(-l, i)) : (this._x = 0, this._y = Math.atan2(h, d));
3827
+ this._z = Math.asin(j(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(-c, o), this._y = Math.atan2(-l, i)) : (this._x = 0, this._y = Math.atan2(r, m));
3828
3828
  break;
3829
3829
  case "XZY":
3830
- this._z = Math.asin(-j(r, -1, 1)), Math.abs(r) < 0.9999999 ? (this._x = Math.atan2(m, o), this._y = Math.atan2(h, i)) : (this._x = Math.atan2(-c, d), this._y = 0);
3830
+ this._z = Math.asin(-j(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(d, o), this._y = Math.atan2(r, i)) : (this._x = Math.atan2(-c, m), this._y = 0);
3831
3831
  break;
3832
3832
  default:
3833
3833
  console.warn(
@@ -3994,30 +3994,30 @@ class Cs extends Yt {
3994
3994
  return s;
3995
3995
  }
3996
3996
  buildHierarchy() {
3997
- var h;
3997
+ var r;
3998
3998
  const t = this.getPoints(100), s = this.calculateBoundaryBoxes(t), e = this.sortBoundaryBoxesByAreas(s), n = /* @__PURE__ */ new Map(), i = e.length;
3999
3999
  for (let a = 0; a < i; a++)
4000
4000
  n.set(e[a], {
4001
4001
  index: e[a],
4002
4002
  children: []
4003
4003
  });
4004
- const r = { index: -1, children: [] };
4004
+ const h = { index: -1, children: [] };
4005
4005
  for (let a = 0; a < i; a++) {
4006
4006
  const o = e[a], c = t[o], l = s[o];
4007
- let m = a + 1;
4008
- for (; m < i; m++) {
4009
- const d = e[m], x = t[d];
4010
- if (s[d].containsBox(l) && xs.isPointInPolygon(
4007
+ let d = a + 1;
4008
+ for (; d < i; d++) {
4009
+ const m = e[d], x = t[m];
4010
+ if (s[m].containsBox(l) && xs.isPointInPolygon(
4011
4011
  c[C.randInt(0, c.length - 1)],
4012
4012
  x
4013
4013
  )) {
4014
- (h = n.get(d)) == null || h.children.push(n.get(o));
4014
+ (r = n.get(m)) == null || r.children.push(n.get(o));
4015
4015
  break;
4016
4016
  }
4017
4017
  }
4018
- m === i && r.children.push(n.get(o));
4018
+ d === i && h.children.push(n.get(o));
4019
4019
  }
4020
- return r;
4020
+ return h;
4021
4021
  }
4022
4022
  /**
4023
4023
  * Calcuate bounding box of each loop in this area and return an array of their bounding box
@@ -4038,9 +4038,9 @@ class Cs extends Yt {
4038
4038
  sortBoundaryBoxesByAreas(t) {
4039
4039
  const s = [];
4040
4040
  t.forEach((n, i) => {
4041
- const r = n.size, h = r.width * r.height;
4041
+ const h = n.size, r = h.width * h.height;
4042
4042
  s.push({
4043
- area: h,
4043
+ area: r,
4044
4044
  index: i
4045
4045
  });
4046
4046
  }), s.sort((n, i) => n.area - i.area);
@@ -4130,8 +4130,8 @@ class st extends Yt {
4130
4130
  const s = [];
4131
4131
  let e, n = this.getPoint(0), i = 0;
4132
4132
  s.push(0);
4133
- for (let r = 1; r <= t; r++)
4134
- e = this.getPoint(r / t), i += e.distanceTo(n), s.push(i), n = e;
4133
+ for (let h = 1; h <= t; h++)
4134
+ e = this.getPoint(h / t), i += e.distanceTo(n), s.push(i), n = e;
4135
4135
  return s;
4136
4136
  }
4137
4137
  /**
@@ -4142,22 +4142,22 @@ class st extends Yt {
4142
4142
  const e = this.getLengths();
4143
4143
  let n = 0;
4144
4144
  const i = e.length;
4145
- let r;
4146
- s ? r = s : r = t * e[i - 1];
4147
- let h = 0, a = i - 1, o;
4148
- for (; h <= a; )
4149
- if (n = Math.floor(h + (a - h) / 2), o = e[n] - r, o < 0)
4150
- h = n + 1;
4145
+ let h;
4146
+ s ? h = s : h = t * e[i - 1];
4147
+ let r = 0, a = i - 1, o;
4148
+ for (; r <= a; )
4149
+ if (n = Math.floor(r + (a - r) / 2), o = e[n] - h, o < 0)
4150
+ r = n + 1;
4151
4151
  else if (o > 0)
4152
4152
  a = n - 1;
4153
4153
  else {
4154
4154
  a = n;
4155
4155
  break;
4156
4156
  }
4157
- if (n = a, e[n] === r)
4157
+ if (n = a, e[n] === h)
4158
4158
  return n / (i - 1);
4159
- const c = e[n], m = e[n + 1] - c, d = (r - c) / m;
4160
- return (n + d) / (i - 1);
4159
+ const c = e[n], d = e[n + 1] - c, m = (h - c) / d;
4160
+ return (n + m) / (i - 1);
4161
4161
  }
4162
4162
  /**
4163
4163
  * Return a unit vector tangent at `t`. If the derived curve does not implement its tangent derivation,
@@ -4169,8 +4169,8 @@ class st extends Yt {
4169
4169
  getTangent(t) {
4170
4170
  let e = t - 1e-4, n = t + 1e-4;
4171
4171
  e < 0 && (e = 0), n > 1 && (n = 1);
4172
- const i = this.getPoint(e), r = this.getPoint(n), h = new b();
4173
- return h.copy(r).sub(i).normalize(), h;
4172
+ const i = this.getPoint(e), h = this.getPoint(n), r = new b();
4173
+ return r.copy(h).sub(i).normalize(), r;
4174
4174
  }
4175
4175
  /**
4176
4176
  * Return tangent at a point which is equidistant to the ends of the curve from the point given in
@@ -4187,8 +4187,8 @@ class st extends Yt {
4187
4187
  class gt extends st {
4188
4188
  constructor(t, s, e, n, i) {
4189
4189
  super();
4190
- const r = +(t !== void 0) + +(s !== void 0) + +(e !== void 0) + +(n !== void 0) + +(i !== void 0);
4191
- if (r == 3)
4190
+ const h = +(t !== void 0) + +(s !== void 0) + +(e !== void 0) + +(n !== void 0) + +(i !== void 0);
4191
+ if (h == 3)
4192
4192
  typeof t == "object" && typeof s == "object" && typeof e == "object" ? this.createByThreePoints(
4193
4193
  t,
4194
4194
  s,
@@ -4198,9 +4198,9 @@ class gt extends st {
4198
4198
  s,
4199
4199
  e
4200
4200
  );
4201
- else if (r == 5) {
4202
- const h = t;
4203
- this.center = new b(h.x, h.y), this.radius = s, this.startAngle = e, this.endAngle = n, this.clockwise = i;
4201
+ else if (h == 5) {
4202
+ const r = t;
4203
+ this.center = new b(r.x, r.y), this.radius = s, this.startAngle = e, this.endAngle = n, this.clockwise = i;
4204
4204
  } else
4205
4205
  throw T.ILLEGAL_PARAMETERS;
4206
4206
  }
@@ -4214,13 +4214,13 @@ class gt extends st {
4214
4214
  const n = (z, E) => ({
4215
4215
  x: (z.x + E.x) / 2,
4216
4216
  y: (z.y + E.y) / 2
4217
- }), i = (z, E) => (E.y - z.y) / (E.x - z.x), r = (z) => -1 / z, h = n(t, s), a = n(s, e), o = i(t, s), c = i(s, e), l = r(o), m = r(c), d = (z, E, Z, G) => {
4217
+ }), i = (z, E) => (E.y - z.y) / (E.x - z.x), h = (z) => -1 / z, r = n(t, s), a = n(s, e), o = i(t, s), c = i(s, e), l = h(o), d = h(c), m = (z, E, Z, G) => {
4218
4218
  const F = (G - E) / (z - Z), K = z * F + E;
4219
4219
  return { x: F, y: K };
4220
- }, x = h.y - l * h.x, g = a.y - m * a.x, p = d(l, x, m, g), _ = Math.sqrt(
4220
+ }, x = r.y - l * r.x, g = a.y - d * a.x, p = m(l, x, d, g), _ = Math.sqrt(
4221
4221
  Math.pow(t.x - p.x, 2) + Math.pow(t.y - p.y, 2)
4222
- ), w = (z, E) => Math.atan2(z.y - E.y, z.x - E.x), f = w(t, p), A = w(s, p), M = w(e, p), B = M > f && M < A || f > M && f < A || A > M && A < f;
4223
- this.center = p, this.radius = _, this.startAngle = f, this.endAngle = M, this.clockwise = !B;
4222
+ ), f = (z, E) => Math.atan2(z.y - E.y, z.x - E.x), w = f(t, p), A = f(s, p), M = f(e, p), B = M > w && M < A || w > M && w < A || A > M && A < w;
4223
+ this.center = p, this.radius = _, this.startAngle = w, this.endAngle = M, this.clockwise = !B;
4224
4224
  }
4225
4225
  /**
4226
4226
  * Create circular arc by two points and one bugle factor
@@ -4234,24 +4234,24 @@ class gt extends st {
4234
4234
  * - https://www.afralisp.net/archive/lisp/Bulges1.htm
4235
4235
  */
4236
4236
  createByStartEndPointsAndBulge(t, s, e) {
4237
- let n, i, r;
4238
- e < 0 ? (n = Math.atan(-e) * 4, i = new P(t), r = new P(s)) : (n = Math.atan(e) * 4, i = new P(s), r = new P(t));
4239
- const h = new P().subVectors(r, i), a = h.length(), o = new P().addVectors(i, h.multiplyScalar(0.5)), c = Math.abs(a / 2 / Math.tan(n / 2)), l = h.normalize();
4240
- let m;
4237
+ let n, i, h;
4238
+ e < 0 ? (n = Math.atan(-e) * 4, i = new P(t), h = new P(s)) : (n = Math.atan(e) * 4, i = new P(s), h = new P(t));
4239
+ const r = new P().subVectors(h, i), a = r.length(), o = new P().addVectors(i, r.multiplyScalar(0.5)), c = Math.abs(a / 2 / Math.tan(n / 2)), l = r.normalize();
4240
+ let d;
4241
4241
  if (n < Math.PI) {
4242
- const d = new P(
4242
+ const m = new P(
4243
4243
  l.x * Math.cos(Math.PI / 2) - l.y * Math.sin(Math.PI / 2),
4244
4244
  l.y * Math.cos(Math.PI / 2) + l.x * Math.sin(Math.PI / 2)
4245
4245
  );
4246
- m = o.add(d.multiplyScalar(-c));
4246
+ d = o.add(m.multiplyScalar(-c));
4247
4247
  } else {
4248
- const d = new P(
4248
+ const m = new P(
4249
4249
  l.x * Math.cos(Math.PI / 2) - l.y * Math.sin(Math.PI / 2),
4250
4250
  l.y * Math.cos(Math.PI / 2) + l.x * Math.sin(Math.PI / 2)
4251
4251
  );
4252
- m = o.add(d.multiplyScalar(c));
4252
+ d = o.add(m.multiplyScalar(c));
4253
4253
  }
4254
- e < 0 ? (this.startAngle = Math.atan2(i.y - m.y, i.x - m.x), this.endAngle = Math.atan2(r.y - m.y, r.x - m.x)) : (this.startAngle = Math.atan2(r.y - m.y, r.x - m.x), this.endAngle = Math.atan2(i.y - m.y, i.x - m.x)), this.clockwise = e < 0, this.center = m, this.radius = r.sub(m).length();
4254
+ e < 0 ? (this.startAngle = Math.atan2(i.y - d.y, i.x - d.x), this.endAngle = Math.atan2(h.y - d.y, h.x - d.x)) : (this.startAngle = Math.atan2(h.y - d.y, h.x - d.x), this.endAngle = Math.atan2(i.y - d.y, i.x - d.x)), this.clockwise = e < 0, this.center = d, this.radius = h.sub(d).length();
4255
4255
  }
4256
4256
  /**
4257
4257
  * Center of circular arc
@@ -4392,13 +4392,13 @@ class gt extends st {
4392
4392
  let e = this.deltaAngle, n = this.startAngle;
4393
4393
  if (this.closed && (e = I, n = 0), this.clockwise)
4394
4394
  for (let i = 0; i <= t; i++) {
4395
- const r = n - e * (i / t), h = this.getPointAtAngle(r);
4396
- s.push(new b(h.x, h.y));
4395
+ const h = n - e * (i / t), r = this.getPointAtAngle(h);
4396
+ s.push(new b(r.x, r.y));
4397
4397
  }
4398
4398
  else
4399
4399
  for (let i = 0; i <= t; i++) {
4400
- const r = n + e * (i / t), h = this.getPointAtAngle(r);
4401
- s.push(new b(h.x, h.y));
4400
+ const h = n + e * (i / t), r = this.getPointAtAngle(h);
4401
+ s.push(new b(r.x, r.y));
4402
4402
  }
4403
4403
  return s;
4404
4404
  }
@@ -4588,8 +4588,8 @@ class _t extends Mt {
4588
4588
  * @returns Return the point on the line that is the closest to the given point.
4589
4589
  */
4590
4590
  perpPoint(t) {
4591
- const s = this.direction, e = this.startPoint, i = X.subVectors(t, e).dot(s), r = X.copy(s).multiplyScalar(i);
4592
- return new S().addVectors(e, r);
4591
+ const s = this.direction, e = this.startPoint, i = X.subVectors(t, e).dot(s), h = X.copy(s).multiplyScalar(i);
4592
+ return new S().addVectors(e, h);
4593
4593
  }
4594
4594
  /**
4595
4595
  * @inheritdoc
@@ -4641,11 +4641,11 @@ class yt extends Mt {
4641
4641
  * @returns Return center point of the arc
4642
4642
  */
4643
4643
  static computeCenterPoint(t, s, e) {
4644
- const n = new y().addVectors(t, s).multiplyScalar(0.5), i = new y().addVectors(t, e).multiplyScalar(0.5), r = new y().subVectors(s, t), h = new y().subVectors(e, t), a = new y().crossVectors(r, h).normalize();
4644
+ const n = new y().addVectors(t, s).multiplyScalar(0.5), i = new y().addVectors(t, e).multiplyScalar(0.5), h = new y().subVectors(s, t), r = new y().subVectors(e, t), a = new y().crossVectors(h, r).normalize();
4645
4645
  if (a.lengthSq() === 0)
4646
4646
  return console.error("Points are collinear and cannot form a valid arc."), null;
4647
- const o = new y().crossVectors(r, a).normalize(), c = new y().crossVectors(h, a).normalize(), l = o.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), m = c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), d = new _t(n, n.clone().add(l)), x = new _t(i, i.clone().add(m)), g = new y();
4648
- return d.closestPointToPoint(x.startPoint, !0, g) ? g : (console.error("Cannot find a valid center for the arc."), null);
4647
+ const o = new y().crossVectors(h, a).normalize(), c = new y().crossVectors(r, a).normalize(), l = o.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), d = c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), m = new _t(n, n.clone().add(l)), x = new _t(i, i.clone().add(d)), g = new y();
4648
+ return m.closestPointToPoint(x.startPoint, !0, g) ? g : (console.error("Cannot find a valid center for the arc."), null);
4649
4649
  }
4650
4650
  /**
4651
4651
  * Create arc by three points
@@ -4660,7 +4660,7 @@ class yt extends Mt {
4660
4660
  e
4661
4661
  );
4662
4662
  if (n) {
4663
- const i = n.distanceTo(t), r = new y().subVectors(t, n), h = new y().subVectors(s, n), a = Math.atan2(r.y, r.x), o = Math.atan2(h.y, h.x);
4663
+ const i = n.distanceTo(t), h = new y().subVectors(t, n), r = new y().subVectors(s, n), a = Math.atan2(h.y, h.x), o = Math.atan2(r.y, r.x);
4664
4664
  return new yt(
4665
4665
  n,
4666
4666
  i,
@@ -4679,8 +4679,8 @@ class yt extends Mt {
4679
4679
  * @param normal The normal vector of the plane in which the arc lies.
4680
4680
  * @param refVec The reference vector from which angles are measured. Default value is x axis.
4681
4681
  */
4682
- constructor(t, s, e, n, i, r = y.X_AXIS) {
4683
- super(), this.center = t, this.radius = s, this.startAngle = e, this.endAngle = n, this.normal = i, this.refVec = r, (n - e) % I == 0 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = e, this.endAngle = n);
4682
+ constructor(t, s, e, n, i, h = y.X_AXIS) {
4683
+ super(), this.center = t, this.radius = s, this.startAngle = e, this.endAngle = n, this.normal = i, this.refVec = h, (n - e) % I == 0 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = e, this.endAngle = n);
4684
4684
  }
4685
4685
  /**
4686
4686
  * Center of circular arc
@@ -4780,14 +4780,14 @@ class yt extends Mt {
4780
4780
  const t = [this.startAngle, this.endAngle];
4781
4781
  for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
4782
4782
  C.isBetweenAngle(a, this.startAngle, this.endAngle) && t.push(a);
4783
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, h = -1 / 0;
4783
+ let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, h = -1 / 0, r = -1 / 0;
4784
4784
  for (const a of t) {
4785
4785
  const o = this.getPointAtAngle(a);
4786
- o.x < s && (s = o.x), o.y < e && (e = o.y), o.z < n && (n = o.z), o.x > i && (i = o.x), o.y > r && (r = o.y), o.z > h && (h = o.z);
4786
+ o.x < s && (s = o.x), o.y < e && (e = o.y), o.z < n && (n = o.z), o.x > i && (i = o.x), o.y > h && (h = o.y), o.z > r && (r = o.z);
4787
4787
  }
4788
4788
  return new Y(
4789
4789
  { x: s, y: e, z: n },
4790
- { x: i, y: r, z: h }
4790
+ { x: i, y: h, z: r }
4791
4791
  );
4792
4792
  }
4793
4793
  /**
@@ -4807,8 +4807,8 @@ class yt extends Mt {
4807
4807
  let e = this.deltaAngle, n = this.startAngle;
4808
4808
  this.closed && (e = I, n = 0);
4809
4809
  for (let i = 0; i <= t; i++) {
4810
- const r = n + e * (i / t), h = this.getPointAtAngle(r);
4811
- s.push(h);
4810
+ const h = n + e * (i / t), r = this.getPointAtAngle(h);
4811
+ s.push(r);
4812
4812
  }
4813
4813
  return s;
4814
4814
  }
@@ -4858,11 +4858,11 @@ class yt extends Mt {
4858
4858
  x: s.y * e.z - s.z * e.y,
4859
4859
  y: s.z * e.x - s.x * e.z,
4860
4860
  z: s.x * e.y - s.y * e.x
4861
- }, i = this.center, r = this.radius;
4861
+ }, i = this.center, h = this.radius;
4862
4862
  return new S(
4863
- i.x + r * (e.x * Math.cos(t) + n.x * Math.sin(t)),
4864
- i.y + r * (e.y * Math.cos(t) + n.y * Math.sin(t)),
4865
- i.z + r * (e.z * Math.cos(t) + n.z * Math.sin(t))
4863
+ i.x + h * (e.x * Math.cos(t) + n.x * Math.sin(t)),
4864
+ i.y + h * (e.y * Math.cos(t) + n.y * Math.sin(t)),
4865
+ i.z + h * (e.z * Math.cos(t) + n.z * Math.sin(t))
4866
4866
  );
4867
4867
  }
4868
4868
  /**
@@ -4886,8 +4886,8 @@ class Zt extends st {
4886
4886
  * @param rotation The rotation angle of the ellipse in radians, counterclockwise from the positive X
4887
4887
  * axis (optional). Default is 0.
4888
4888
  */
4889
- constructor(t, s, e, n = 0, i = I, r = !1, h = 0) {
4890
- super(), this.center = t, this.majorAxisRadius = s, this.minorAxisRadius = e, (i - n) % I == 0 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = n, this.endAngle = i), this.clockwise = r, this.rotation = h;
4889
+ constructor(t, s, e, n = 0, i = I, h = !1, r = 0) {
4890
+ super(), this.center = t, this.majorAxisRadius = s, this.minorAxisRadius = e, (i - n) % I == 0 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = n, this.endAngle = i), this.clockwise = h, this.rotation = r;
4891
4891
  }
4892
4892
  /**
4893
4893
  * Center of the ellipse in 3d space
@@ -4974,9 +4974,9 @@ class Zt extends st {
4974
4974
  */
4975
4975
  calculateBoundingBox() {
4976
4976
  let s = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
4977
- for (let r = 0; r <= 100; r++) {
4978
- const h = this.getPoint(r / 100);
4979
- s = Math.min(s, h.x), e = Math.min(e, h.y), n = Math.max(n, h.x), i = Math.max(i, h.y);
4977
+ for (let h = 0; h <= 100; h++) {
4978
+ const r = this.getPoint(h / 100);
4979
+ s = Math.min(s, r.x), e = Math.min(e, r.y), n = Math.max(n, r.x), i = Math.max(i, r.y);
4980
4980
  }
4981
4981
  return new V({ x: s, y: e }, { x: n, y: i });
4982
4982
  }
@@ -4999,12 +4999,12 @@ class Zt extends st {
4999
4999
  for (; e > s; ) e -= s;
5000
5000
  e < Number.EPSILON && (n ? e = 0 : e = s), this.clockwise === !0 && !n && (e === s ? e = -s : e = e - s);
5001
5001
  const i = this.startAngle + t * e;
5002
- let r = this.center.x + this.majorAxisRadius * Math.cos(i), h = this.center.y + this.minorAxisRadius * Math.sin(i);
5002
+ let h = this.center.x + this.majorAxisRadius * Math.cos(i), r = this.center.y + this.minorAxisRadius * Math.sin(i);
5003
5003
  if (this.rotation !== 0) {
5004
- const a = Math.cos(this.rotation), o = Math.sin(this.rotation), c = r - this.center.x, l = h - this.center.y;
5005
- r = c * a - l * o + this.center.x, h = c * o + l * a + this.center.y;
5004
+ const a = Math.cos(this.rotation), o = Math.sin(this.rotation), c = h - this.center.x, l = r - this.center.y;
5005
+ h = c * a - l * o + this.center.x, r = c * o + l * a + this.center.y;
5006
5006
  }
5007
- return new b(r, h);
5007
+ return new b(h, r);
5008
5008
  }
5009
5009
  /**
5010
5010
  * @inheritdoc
@@ -5044,10 +5044,10 @@ class Gt extends Mt {
5044
5044
  * @param startAngle Start angle of the ellipse arc in radians.
5045
5045
  * @param endAngle End angle of the ellipse arc in radians.
5046
5046
  */
5047
- constructor(t, s, e, n, i, r = 0, h = I) {
5047
+ constructor(t, s, e, n, i, h = 0, r = I) {
5048
5048
  super(), this.center = t, this.normal = s, this.majorAxis = e, this.majorAxisRadius = n, this.minorAxisRadius = i;
5049
- const a = Math.abs(h - r);
5050
- Math.abs(a - I) < 1e-10 || Math.abs(a - 2 * I) < 1e-10 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = r, this.endAngle = h);
5049
+ const a = Math.abs(r - h);
5050
+ Math.abs(a - I) < 1e-10 || Math.abs(a - 2 * I) < 1e-10 ? (this.startAngle = 0, this.endAngle = I) : (this.startAngle = h, this.endAngle = r);
5051
5051
  }
5052
5052
  /**
5053
5053
  * Center of the ellipse in 3d space
@@ -5161,8 +5161,8 @@ class Gt extends Mt {
5161
5161
  const s = this.deltaAngle / 1e3;
5162
5162
  let e = 0, n = this.getPointAtAngle(this.startAngle);
5163
5163
  for (let i = 1; i <= 1e3; i++) {
5164
- const r = this.startAngle + i * s, h = this.getPointAtAngle(r), a = h.x - n.x, o = h.y - n.y, c = h.z - n.z;
5165
- e += Math.sqrt(a * a + o * o + c * c), n = h;
5164
+ const h = this.startAngle + i * s, r = this.getPointAtAngle(h), a = r.x - n.x, o = r.y - n.y, c = r.z - n.z;
5165
+ e += Math.sqrt(a * a + o * o + c * c), n = r;
5166
5166
  }
5167
5167
  return e;
5168
5168
  }
@@ -5176,24 +5176,24 @@ class Gt extends Mt {
5176
5176
  const t = [this.startAngle, this.endAngle];
5177
5177
  for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
5178
5178
  C.isBetweenAngle(a, this.startAngle, this.endAngle) && t.push(a);
5179
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, h = -1 / 0;
5179
+ let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, h = -1 / 0, r = -1 / 0;
5180
5180
  for (const a of t) {
5181
5181
  const o = this.getPointAtAngle(a);
5182
- o.x < s && (s = o.x), o.y < e && (e = o.y), o.z < n && (n = o.z), o.x > i && (i = o.x), o.y > r && (r = o.y), o.z > h && (h = o.z);
5182
+ o.x < s && (s = o.x), o.y < e && (e = o.y), o.z < n && (n = o.z), o.x > i && (i = o.x), o.y > h && (h = o.y), o.z > r && (r = o.z);
5183
5183
  }
5184
5184
  return new Y(
5185
5185
  { x: s, y: e, z: n },
5186
- { x: i, y: r, z: h }
5186
+ { x: i, y: h, z: r }
5187
5187
  );
5188
5188
  } else {
5189
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, h = -1 / 0;
5189
+ let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, h = -1 / 0, r = -1 / 0;
5190
5190
  for (let a = 0; a <= 100; a++) {
5191
5191
  const o = this.startAngle + this.deltaAngle * (a / 100), c = this.getPointAtAngle(o);
5192
- s = Math.min(s, c.x), e = Math.min(e, c.y), n = Math.min(n, c.z), i = Math.max(i, c.x), r = Math.max(r, c.y), h = Math.max(h, c.z);
5192
+ s = Math.min(s, c.x), e = Math.min(e, c.y), n = Math.min(n, c.z), i = Math.max(i, c.x), h = Math.max(h, c.y), r = Math.max(r, c.z);
5193
5193
  }
5194
5194
  return new Y(
5195
5195
  { x: s, y: e, z: n },
5196
- { x: i, y: r, z: h }
5196
+ { x: i, y: h, z: r }
5197
5197
  );
5198
5198
  }
5199
5199
  }
@@ -5208,8 +5208,8 @@ class Gt extends Mt {
5208
5208
  let e = this.deltaAngle, n = this.startAngle;
5209
5209
  this.closed && (e = I, n = 0);
5210
5210
  for (let i = 0; i <= t; i++) {
5211
- const r = n + e * (i / t), h = this.getPointAtAngle(r);
5212
- s.push(h);
5211
+ const h = n + e * (i / t), r = this.getPointAtAngle(h);
5212
+ s.push(r);
5213
5213
  }
5214
5214
  return s;
5215
5215
  }
@@ -5232,8 +5232,8 @@ class Gt extends Mt {
5232
5232
  * @returns - True if the point is inside the ellipse, false otherwise.
5233
5233
  */
5234
5234
  contains(t) {
5235
- const s = new y(t).sub(this.center), e = s.dot(this.majorAxis), n = s.dot(this.minorAxis), i = e / this.majorAxisRadius, r = n / this.minorAxisRadius;
5236
- return i * i + r * r <= 1;
5235
+ const s = new y(t).sub(this.center), e = s.dot(this.majorAxis), n = s.dot(this.minorAxis), i = e / this.majorAxisRadius, h = n / this.minorAxisRadius;
5236
+ return i * i + h * h <= 1;
5237
5237
  }
5238
5238
  /**
5239
5239
  * @inheritdoc
@@ -5321,8 +5321,8 @@ class Bs extends st {
5321
5321
  let i = null;
5322
5322
  if (e < s - 1 ? i = this._vertices[e + 1] : e == s - 1 && this.closed && (i = this._vertices[0]), i)
5323
5323
  if (n.bulge) {
5324
- const r = new gt(n, i, n.bulge);
5325
- t += r.length;
5324
+ const h = new gt(n, i, n.bulge);
5325
+ t += h.length;
5326
5326
  } else
5327
5327
  t += new b(n.x, n.y).distanceTo(i);
5328
5328
  }
@@ -5392,9 +5392,9 @@ class Bs extends st {
5392
5392
  for (let n = 0; n < e; ++n) {
5393
5393
  const i = this._vertices[n];
5394
5394
  if (i.bulge) {
5395
- let r = null;
5396
- if (n < e - 1 ? r = this._vertices[n + 1] : n == e - 1 && this.closed && (r = this._vertices[0]), r) {
5397
- const a = new gt(i, r, i.bulge).getPoints(t), o = a.length;
5395
+ let h = null;
5396
+ if (n < e - 1 ? h = this._vertices[n + 1] : n == e - 1 && this.closed && (h = this._vertices[0]), h) {
5397
+ const a = new gt(i, h, i.bulge).getPoints(t), o = a.length;
5398
5398
  for (let c = 0; c < o; ++c) {
5399
5399
  const l = a[c];
5400
5400
  s.push(new b(l.x, l.y));
@@ -5629,8 +5629,8 @@ class D {
5629
5629
  n = ys(s, t.length);
5630
5630
  break;
5631
5631
  }
5632
- const i = zs(t), r = new Array(i.length).fill(1);
5633
- return new D(s, n, i, r);
5632
+ const i = zs(t), h = new Array(i.length).fill(1);
5633
+ return new D(s, n, i, h);
5634
5634
  }
5635
5635
  }
5636
5636
  class Es extends Mt {
@@ -5643,20 +5643,20 @@ class Es extends Mt {
5643
5643
  if (this._closed = !1, n == 2 && !Array.isArray(s)) {
5644
5644
  if (this._fitPoints = t, this._knotParameterization = s, this._fitPoints.length < 4)
5645
5645
  throw T.ILLEGAL_PARAMETERS;
5646
- const r = this.toNurbsPoints(this._fitPoints);
5646
+ const h = this.toNurbsPoints(this._fitPoints);
5647
5647
  this._nurbsCurve = D.byPoints(
5648
- r,
5648
+ h,
5649
5649
  i,
5650
5650
  this._knotParameterization
5651
5651
  ), this._controlPoints = this.toGePoints(this._nurbsCurve.controlPoints()), this._originalControlPoints = [...this._controlPoints], this._originalKnots = [...this._nurbsCurve.knots()], this._originalWeights = [...this._nurbsCurve.weights()];
5652
5652
  } else {
5653
5653
  if (this._controlPoints = t, this._controlPoints.length < 4)
5654
5654
  throw T.ILLEGAL_PARAMETERS;
5655
- const r = this.toNurbsPoints(this._controlPoints);
5655
+ const h = this.toNurbsPoints(this._controlPoints);
5656
5656
  this._nurbsCurve = D.byKnotsControlPointsWeights(
5657
5657
  i,
5658
5658
  s,
5659
- r,
5659
+ h,
5660
5660
  e
5661
5661
  ), this._originalControlPoints = [...this._controlPoints], this._originalKnots = [...this._nurbsCurve.knots()], this._originalWeights = e ? [...e] : new Array(this._controlPoints.length).fill(1);
5662
5662
  }
@@ -5671,15 +5671,18 @@ class Es extends Mt {
5671
5671
  * Make the spline closed by adding control points and adjusting knots
5672
5672
  */
5673
5673
  makeClosed() {
5674
- const t = this._nurbsCurve.degree(), s = this._nurbsCurve.controlPoints(), e = this._nurbsCurve.knots(), n = this._nurbsCurve.weights(), i = [...s], r = [...n];
5675
- for (let a = 0; a < t; a++)
5676
- i.push([...s[a]]), r.push(n[a]);
5677
- const h = this.createClosedKnotVector(e, t);
5674
+ const t = this._nurbsCurve.degree(), s = this._nurbsCurve.controlPoints(), e = this._nurbsCurve.weights(), n = s.length, i = [
5675
+ ...s,
5676
+ ...s.slice(0, t)
5677
+ ], h = [
5678
+ ...e,
5679
+ ...e.slice(0, t)
5680
+ ], r = this.createClosedKnotVector(n, t);
5678
5681
  this._nurbsCurve = D.byKnotsControlPointsWeights(
5679
5682
  t,
5680
- h,
5683
+ r,
5681
5684
  i,
5682
- r
5685
+ h
5683
5686
  ), this._controlPoints = this.toGePoints(i);
5684
5687
  }
5685
5688
  /**
@@ -5697,13 +5700,13 @@ class Es extends Mt {
5697
5700
  ), this._controlPoints = [...this._originalControlPoints];
5698
5701
  }
5699
5702
  /**
5700
- * Create knot vector for closed curve
5703
+ * Create periodic knot vector for closed curve
5701
5704
  */
5702
5705
  createClosedKnotVector(t, s) {
5703
- const e = [...t], n = t[t.length - 1], i = t[0], r = (n - i) / (t.length - 1), h = s;
5704
- for (let a = 1; a <= h; a++)
5705
- e.push(n + a * r);
5706
- return e;
5706
+ const e = t + 2 * s + 1, n = [];
5707
+ for (let i = 0; i < e; i++)
5708
+ n.push(i);
5709
+ return n;
5707
5710
  }
5708
5711
  /**
5709
5712
  * Degree of the spline to be created.
@@ -5761,34 +5764,33 @@ class Es extends Mt {
5761
5764
  return this._controlPoints[e];
5762
5765
  }
5763
5766
  /**
5764
- * Divide this spline into the specified nubmer of points
5767
+ * Divide this spline into the specified number of points
5765
5768
  * those points as an array of points.
5766
- * @param numPoints Input the nubmer of points returned
5769
+ * @param numPoints Input the number of points returned
5767
5770
  * @returns Return an array of point
5768
5771
  */
5769
5772
  getPoints(t = 100) {
5770
- const s = this._nurbsCurve, e = [], n = s.knots(), i = this._nurbsCurve.degree(), r = n[i], h = n[n.length - i - 1];
5773
+ const s = this._nurbsCurve, e = [], n = s.knots(), i = s.degree(), h = n[i], r = n[n.length - i - 1];
5771
5774
  if (this._closed) {
5772
- const a = (h - r) / (t - 1);
5773
- for (let o = 0; o < t; o++) {
5774
- let c;
5775
- o === t - 1 ? c = r : c = r + o * a;
5776
- const l = s.point(c);
5777
- e.push(new S(l[0], l[1], l[2]));
5775
+ const o = (r - h) / (t - 1);
5776
+ for (let c = 0; c < t - 1; c++) {
5777
+ const l = h + c * o, d = s.point(l);
5778
+ e.push(new S(d[0], d[1], d[2]));
5778
5779
  }
5780
+ e.push(e[0]);
5779
5781
  } else {
5780
- const a = (h - r) / (t - 1);
5782
+ const a = (r - h) / (t - 1);
5781
5783
  for (let o = 0; o < t; o++) {
5782
- const c = o === t - 1 ? h : r + o * a, l = s.point(c);
5784
+ const c = o === t - 1 ? r : h + o * a, l = s.point(c);
5783
5785
  e.push(new S(l[0], l[1], l[2]));
5784
5786
  }
5785
5787
  }
5786
5788
  return e;
5787
5789
  }
5788
5790
  getCurvePoints(t, s) {
5789
- const e = [], n = t.knots(), i = n[3], h = (n[n.length - 4] - i) / (s - 1);
5791
+ const e = [], n = t.knots(), i = n[3], r = (n[n.length - 4] - i) / (s - 1);
5790
5792
  for (let a = 0; a < s; a++) {
5791
- const o = i + a * h;
5793
+ const o = i + a * r;
5792
5794
  e.push(t.point(o));
5793
5795
  }
5794
5796
  return e;