@mlightcad/geometry-engine 1.0.4 → 1.0.6
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/geometry-engine.js +530 -458
- package/dist/geometry-engine.umd.cjs +1 -1
- package/lib/geometry/AcGeSpline3d.d.ts +19 -0
- package/lib/geometry/AcGeSpline3d.d.ts.map +1 -1
- package/lib/geometry/AcGeSpline3d.js +116 -12
- package/lib/geometry/AcGeSpline3d.js.map +1 -1
- package/lib/util/AcGeNurbsUtil.d.ts.map +1 -1
- package/lib/util/AcGeNurbsUtil.js +31 -4
- package/lib/util/AcGeNurbsUtil.js.map +1 -1
- package/package.json +1 -1
package/dist/geometry-engine.js
CHANGED
@@ -259,7 +259,7 @@ const k = [
|
|
259
259
|
];
|
260
260
|
let St = 1234567;
|
261
261
|
const Rt = Math.PI / 180, Tt = 180 / Math.PI;
|
262
|
-
function
|
262
|
+
function Qt() {
|
263
263
|
const u = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0;
|
264
264
|
return (k[u & 255] + k[u >> 8 & 255] + k[u >> 16 & 255] + k[u >> 24 & 255] + "-" + k[t & 255] + k[t >> 8 & 255] + "-" + k[t >> 16 & 15 | 64] + k[t >> 24 & 255] + "-" + k[s & 63 | 128] + k[s >> 8 & 255] + "-" + k[s >> 16 & 255] + k[s >> 24 & 255] + k[e & 255] + k[e >> 8 & 255] + k[e >> 16 & 255] + k[e >> 24 & 255]).toLowerCase();
|
265
265
|
}
|
@@ -269,19 +269,19 @@ function j(u, t, s) {
|
|
269
269
|
function Vt(u, t) {
|
270
270
|
return (u % t + t) % t;
|
271
271
|
}
|
272
|
-
function
|
272
|
+
function Ot(u, t, s, e, n) {
|
273
273
|
return e + (u - t) * (n - e) / (s - t);
|
274
274
|
}
|
275
|
-
function
|
275
|
+
function Wt(u, t, s) {
|
276
276
|
return u !== t ? (s - u) / (t - u) : 0;
|
277
277
|
}
|
278
278
|
function Ut(u, t, s) {
|
279
279
|
return (1 - s) * u + s * t;
|
280
280
|
}
|
281
|
-
function
|
281
|
+
function Ht(u, t, s, e) {
|
282
282
|
return Ut(u, t, 1 - Math.exp(-s * e));
|
283
283
|
}
|
284
|
-
function
|
284
|
+
function $t(u, t = 1) {
|
285
285
|
return t - Math.abs(Vt(u, t * 2) - t);
|
286
286
|
}
|
287
287
|
function Jt(u, t, s) {
|
@@ -319,7 +319,7 @@ function os(u) {
|
|
319
319
|
function as(u) {
|
320
320
|
return Math.pow(2, Math.floor(Math.log(u) / Math.LN2));
|
321
321
|
}
|
322
|
-
function
|
322
|
+
function mt(u) {
|
323
323
|
const t = Math.PI * 2;
|
324
324
|
return (u % t + t) % t;
|
325
325
|
}
|
@@ -327,7 +327,7 @@ function cs(u, t, s) {
|
|
327
327
|
return u > t && u < s || u > s && u < t;
|
328
328
|
}
|
329
329
|
function ls(u, t, s, e = !1) {
|
330
|
-
return u =
|
330
|
+
return u = mt(u), t = mt(t), s = mt(s), e ? t > s ? u <= t && u >= s : u <= t || u >= s : t < s ? u >= t && u <= s : u >= t || u <= s;
|
331
331
|
}
|
332
332
|
function qt(u) {
|
333
333
|
return u = Math.abs(u), u < 1 ? 0 : Math.ceil(Math.log10(Math.abs(u) + 1));
|
@@ -336,17 +336,17 @@ function us(u, t = 1e-7) {
|
|
336
336
|
const s = qt(u);
|
337
337
|
return Math.max(Math.pow(10, s) * t, t);
|
338
338
|
}
|
339
|
-
const
|
339
|
+
const C = {
|
340
340
|
DEG2RAD: Rt,
|
341
341
|
RAD2DEG: Tt,
|
342
|
-
generateUUID:
|
342
|
+
generateUUID: Qt,
|
343
343
|
clamp: j,
|
344
344
|
euclideanModulo: Vt,
|
345
|
-
mapLinear:
|
346
|
-
inverseLerp:
|
345
|
+
mapLinear: Ot,
|
346
|
+
inverseLerp: Wt,
|
347
347
|
lerp: Ut,
|
348
|
-
damp:
|
349
|
-
pingpong:
|
348
|
+
damp: Ht,
|
349
|
+
pingpong: $t,
|
350
350
|
smoothstep: Jt,
|
351
351
|
smootherstep: vt,
|
352
352
|
randInt: ts,
|
@@ -358,12 +358,12 @@ const S = {
|
|
358
358
|
isPowerOfTwo: hs,
|
359
359
|
ceilPowerOfTwo: os,
|
360
360
|
floorPowerOfTwo: as,
|
361
|
-
normalizeAngle:
|
361
|
+
normalizeAngle: mt,
|
362
362
|
isBetween: cs,
|
363
363
|
isBetweenAngle: ls,
|
364
364
|
intPartLength: qt,
|
365
365
|
relativeEps: us
|
366
|
-
},
|
366
|
+
}, W = class W {
|
367
367
|
/**
|
368
368
|
* Construct one vector by two numbers
|
369
369
|
*/
|
@@ -479,7 +479,7 @@ const S = {
|
|
479
479
|
* @returns Return the cloned vector
|
480
480
|
*/
|
481
481
|
clone() {
|
482
|
-
return new
|
482
|
+
return new W(this.x, this.y);
|
483
483
|
}
|
484
484
|
/**
|
485
485
|
* Copy the values of the passed vector's x and y properties to this vector.
|
@@ -839,8 +839,8 @@ const S = {
|
|
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,
|
843
|
-
return this.x = i * e -
|
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;
|
844
844
|
}
|
845
845
|
/**
|
846
846
|
* Set each component of this vector to a pseudo-random value between 0 and 1, excluding 1.
|
@@ -851,17 +851,17 @@ const S = {
|
|
851
851
|
}
|
852
852
|
relativeEps(t = 1e-7) {
|
853
853
|
return Math.min(
|
854
|
-
|
855
|
-
|
854
|
+
C.relativeEps(this.x, t),
|
855
|
+
C.relativeEps(this.y, t)
|
856
856
|
);
|
857
857
|
}
|
858
858
|
*[Symbol.iterator]() {
|
859
859
|
yield this.x, yield this.y;
|
860
860
|
}
|
861
861
|
};
|
862
|
-
|
863
|
-
let
|
864
|
-
const
|
862
|
+
W.EMPTY = Object.freeze(new W(0, 0));
|
863
|
+
let P = W;
|
864
|
+
const H = class H {
|
865
865
|
/**
|
866
866
|
* Create a 3x3 matrix with the given arguments in row-major order. If no arguments are provided,
|
867
867
|
* the constructor initializes the Matrix3 to the 3x3 identity matrix.
|
@@ -875,8 +875,8 @@ const K = class K {
|
|
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,
|
879
|
-
this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null &&
|
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);
|
880
880
|
}
|
881
881
|
/**
|
882
882
|
* Set the 3x3 matrix values to the given row-major sequence of values.
|
@@ -892,9 +892,9 @@ const K = class K {
|
|
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,
|
895
|
+
set(t, s, e, n, i, r, h, a, o) {
|
896
896
|
const c = this.elements;
|
897
|
-
return c[0] = t, c[1] = n, c[2] =
|
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;
|
898
898
|
}
|
899
899
|
/**
|
900
900
|
* Reset this matrix to the 3x3 identity matrix:
|
@@ -954,8 +954,8 @@ const K = class K {
|
|
954
954
|
* @returns Return this matrix
|
955
955
|
*/
|
956
956
|
multiplyMatrices(t, s) {
|
957
|
-
const e = t.elements, n = s.elements, i = this.elements,
|
958
|
-
return i[0] =
|
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;
|
959
959
|
}
|
960
960
|
/**
|
961
961
|
* Multiply every component of the matrix by the scalar value s.
|
@@ -971,8 +971,8 @@ const K = class K {
|
|
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],
|
975
|
-
return s *
|
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;
|
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 K = class K {
|
|
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],
|
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;
|
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] = (
|
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;
|
987
987
|
}
|
988
988
|
/**
|
989
989
|
* Transpose this matrix in place.
|
@@ -1024,15 +1024,15 @@ const K = class K {
|
|
1024
1024
|
* @param cy Input center y of rotation
|
1025
1025
|
* @returns Return this matrix
|
1026
1026
|
*/
|
1027
|
-
setUvTransform(t, s, e, n, i,
|
1027
|
+
setUvTransform(t, s, e, n, i, r, h) {
|
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 *
|
1032
|
+
-e * (a * r + o * h) + r + t,
|
1033
1033
|
-n * o,
|
1034
1034
|
n * a,
|
1035
|
-
-n * (-o *
|
1035
|
+
-n * (-o * r + a * h) + h + s,
|
1036
1036
|
0,
|
1037
1037
|
0,
|
1038
1038
|
1
|
@@ -1071,7 +1071,7 @@ const K = class K {
|
|
1071
1071
|
* @returns Return this matrix
|
1072
1072
|
*/
|
1073
1073
|
makeTranslation(t, s) {
|
1074
|
-
return t instanceof
|
1074
|
+
return t instanceof P ? this.set(1, 0, t.x, 0, 1, t.y, 0, 0, 1) : this.set(1, 0, t, 0, 1, s, 0, 0, 1), this;
|
1075
1075
|
}
|
1076
1076
|
/**
|
1077
1077
|
* Set this matrix as a 2D rotational transformation by theta radians
|
@@ -1128,12 +1128,12 @@ const K = class K {
|
|
1128
1128
|
* @returns Return the cloned matrix
|
1129
1129
|
*/
|
1130
1130
|
clone() {
|
1131
|
-
return new
|
1131
|
+
return new H().fromArray(this.elements);
|
1132
1132
|
}
|
1133
1133
|
};
|
1134
|
-
|
1135
|
-
let
|
1136
|
-
const At = /* @__PURE__ */ new
|
1134
|
+
H.IDENTITY = Object.freeze(new H());
|
1135
|
+
let v = H;
|
1136
|
+
const At = /* @__PURE__ */ new v(), Q = 1e-6, I = 2 * Math.PI, Ss = {
|
1137
1137
|
x: 0,
|
1138
1138
|
y: 0
|
1139
1139
|
}, jt = {
|
@@ -1141,7 +1141,7 @@ const At = /* @__PURE__ */ new J(), Q = 1e-6, E = 2 * Math.PI, Ss = {
|
|
1141
1141
|
y: 0,
|
1142
1142
|
z: 0
|
1143
1143
|
};
|
1144
|
-
class
|
1144
|
+
class ds {
|
1145
1145
|
/**
|
1146
1146
|
* Create tolerance class with default tolerance values
|
1147
1147
|
*/
|
@@ -1155,7 +1155,7 @@ class ms {
|
|
1155
1155
|
* @returns Return true if two poitns are equal with the specified tolerance.
|
1156
1156
|
*/
|
1157
1157
|
equalPoint2d(t, s) {
|
1158
|
-
return new
|
1158
|
+
return new P(t).sub(s).length() < this.equalPointTol;
|
1159
1159
|
}
|
1160
1160
|
/**
|
1161
1161
|
* Return true if two points are equal with the specified tolerance.
|
@@ -1210,19 +1210,19 @@ class ms {
|
|
1210
1210
|
return t - s < e;
|
1211
1211
|
}
|
1212
1212
|
}
|
1213
|
-
const Ft = new
|
1213
|
+
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
|
1218
|
-
for (let
|
1219
|
-
const o = t[
|
1220
|
-
let
|
1221
|
-
s && (
|
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);
|
1222
1222
|
}
|
1223
1223
|
return i;
|
1224
1224
|
}
|
1225
|
-
function
|
1225
|
+
function ms(u, t) {
|
1226
1226
|
if (u.length === 0 || t.length === 0)
|
1227
1227
|
return !1;
|
1228
1228
|
const s = new V().setFromPoints(u), e = new V().setFromPoints(t);
|
@@ -1237,7 +1237,7 @@ function ds(u, t) {
|
|
1237
1237
|
}
|
1238
1238
|
const xs = {
|
1239
1239
|
isPointInPolygon: Xt,
|
1240
|
-
isPolygonIntersect:
|
1240
|
+
isPolygonIntersect: ms
|
1241
1241
|
};
|
1242
1242
|
function ys(u, t) {
|
1243
1243
|
const s = [], e = t - 1, n = u;
|
@@ -1252,77 +1252,94 @@ 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
|
1256
|
-
const a = t[
|
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);
|
1257
1257
|
i += l, n.push(i);
|
1258
1258
|
}
|
1259
|
-
const
|
1260
|
-
for (let
|
1261
|
-
|
1262
|
-
for (let
|
1263
|
-
const a = n[
|
1264
|
-
|
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));
|
1265
1265
|
}
|
1266
|
-
for (let
|
1267
|
-
|
1268
|
-
return
|
1266
|
+
for (let h = 0; h <= e; h++)
|
1267
|
+
r.push(s - e + 1);
|
1268
|
+
return r;
|
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
|
1274
|
-
const a = t[
|
1275
|
-
i +=
|
1276
|
-
}
|
1277
|
-
const
|
1278
|
-
for (let
|
1279
|
-
|
1280
|
-
for (let
|
1281
|
-
const a = n[
|
1282
|
-
|
1283
|
-
}
|
1284
|
-
for (let
|
1285
|
-
|
1286
|
-
return
|
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;
|
1287
1287
|
}
|
1288
|
-
function
|
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],
|
1292
|
-
return
|
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);
|
1293
1293
|
}
|
1294
|
-
function
|
1295
|
-
const i = e.length - 1,
|
1296
|
-
u = Math.max(s[
|
1297
|
-
|
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)
|
1297
|
+
return [...e[i]];
|
1298
|
+
if (Math.abs(u - s[r]) < 1e-8)
|
1299
|
+
return [...e[0]];
|
1300
|
+
const h = [0, 0, 0];
|
1298
1301
|
let a = 0;
|
1299
1302
|
for (let o = 0; o <= i; o++) {
|
1300
|
-
const c =
|
1301
|
-
|
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;
|
1305
|
+
}
|
1306
|
+
if (a < 1e-10) {
|
1307
|
+
const o = s[s.length - r - 1];
|
1308
|
+
if (Math.abs(u - o) < 1e-8)
|
1309
|
+
return [...e[i]];
|
1310
|
+
if (Math.abs(u - s[r]) < 1e-8)
|
1311
|
+
return [...e[0]];
|
1302
1312
|
}
|
1303
|
-
return a > 1e-10 && (
|
1313
|
+
return a > 1e-10 && (h[0] /= a, h[1] /= a, h[2] /= a), h;
|
1304
1314
|
}
|
1305
1315
|
function ps(u, t, s, e) {
|
1306
|
-
const n = u, i = t[n],
|
1307
|
-
let
|
1308
|
-
const a = 1e3, o = (
|
1309
|
-
let c =
|
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;
|
1319
|
+
let c = xt(
|
1310
1320
|
i,
|
1311
1321
|
u,
|
1312
1322
|
t,
|
1313
1323
|
s,
|
1314
1324
|
e
|
1315
1325
|
);
|
1316
|
-
for (let
|
1317
|
-
const
|
1318
|
-
|
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 = _;
|
1319
1329
|
}
|
1320
|
-
|
1330
|
+
const l = xt(
|
1331
|
+
r,
|
1332
|
+
u,
|
1333
|
+
t,
|
1334
|
+
s,
|
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;
|
1321
1338
|
}
|
1322
1339
|
function zs(u) {
|
1323
1340
|
return u.map((t) => [...t]);
|
1324
1341
|
}
|
1325
|
-
class
|
1342
|
+
class pt {
|
1326
1343
|
/**
|
1327
1344
|
* Create one instance of this class
|
1328
1345
|
* @param x Input x coordinate
|
@@ -1343,28 +1360,28 @@ class _t {
|
|
1343
1360
|
* @param srcOffset1 Input an offset into the array src1.
|
1344
1361
|
* @param t Input normalized interpolation factor (between 0 and 1).
|
1345
1362
|
*/
|
1346
|
-
static slerpFlat(t, s, e, n, i,
|
1363
|
+
static slerpFlat(t, s, e, n, i, r, h) {
|
1347
1364
|
let a = e[n + 0], o = e[n + 1], c = e[n + 2], l = e[n + 3];
|
1348
|
-
const
|
1349
|
-
if (
|
1365
|
+
const m = i[r + 0], d = i[r + 1], x = i[r + 2], g = i[r + 3];
|
1366
|
+
if (h === 0) {
|
1350
1367
|
t[s + 0] = a, t[s + 1] = o, t[s + 2] = c, t[s + 3] = l;
|
1351
1368
|
return;
|
1352
1369
|
}
|
1353
|
-
if (
|
1354
|
-
t[s + 0] =
|
1370
|
+
if (h === 1) {
|
1371
|
+
t[s + 0] = m, t[s + 1] = d, t[s + 2] = x, t[s + 3] = g;
|
1355
1372
|
return;
|
1356
1373
|
}
|
1357
|
-
if (l !== g || a !==
|
1358
|
-
let
|
1359
|
-
const
|
1360
|
-
if (
|
1361
|
-
const
|
1362
|
-
|
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;
|
1363
1380
|
}
|
1364
|
-
const
|
1365
|
-
if (a = a *
|
1366
|
-
const
|
1367
|
-
a *=
|
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) {
|
1383
|
+
const M = 1 / Math.sqrt(a * a + o * o + c * c + l * l);
|
1384
|
+
a *= M, o *= M, c *= M, l *= M;
|
1368
1385
|
}
|
1369
1386
|
}
|
1370
1387
|
t[s] = a, t[s + 1] = o, t[s + 2] = c, t[s + 3] = l;
|
@@ -1379,9 +1396,9 @@ class _t {
|
|
1379
1396
|
* @param srcOffset1 Input an offset into the array src1.
|
1380
1397
|
* @returns Return an array
|
1381
1398
|
*/
|
1382
|
-
static multiplyQuaternionsFlat(t, s, e, n, i,
|
1383
|
-
const
|
1384
|
-
return t[s] =
|
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;
|
1385
1402
|
}
|
1386
1403
|
/**
|
1387
1404
|
* X cooridinate
|
@@ -1435,7 +1452,7 @@ class _t {
|
|
1435
1452
|
* @returns Return cloned instance
|
1436
1453
|
*/
|
1437
1454
|
clone() {
|
1438
|
-
return new
|
1455
|
+
return new pt(this._x, this._y, this._z, this._w);
|
1439
1456
|
}
|
1440
1457
|
/**
|
1441
1458
|
* Copy the x, y, z and w properties of q into this quaternion.
|
@@ -1452,29 +1469,29 @@ class _t {
|
|
1452
1469
|
* @returns Return this quaternion
|
1453
1470
|
*/
|
1454
1471
|
setFromEuler(t, s = !0) {
|
1455
|
-
const e = t.x, n = t.y, i = t.z,
|
1456
|
-
switch (
|
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) {
|
1457
1474
|
case "XYZ":
|
1458
|
-
this._x =
|
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;
|
1459
1476
|
break;
|
1460
1477
|
case "YXZ":
|
1461
|
-
this._x =
|
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;
|
1462
1479
|
break;
|
1463
1480
|
case "ZXY":
|
1464
|
-
this._x =
|
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;
|
1465
1482
|
break;
|
1466
1483
|
case "ZYX":
|
1467
|
-
this._x =
|
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;
|
1468
1485
|
break;
|
1469
1486
|
case "YZX":
|
1470
|
-
this._x =
|
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;
|
1471
1488
|
break;
|
1472
1489
|
case "XZY":
|
1473
|
-
this._x =
|
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;
|
1474
1491
|
break;
|
1475
1492
|
default:
|
1476
1493
|
console.warn(
|
1477
|
-
"THREE.Quaternion: .setFromEuler() encountered an unknown order: " +
|
1494
|
+
"THREE.Quaternion: .setFromEuler() encountered an unknown order: " + r
|
1478
1495
|
);
|
1479
1496
|
}
|
1480
1497
|
return s === !0 && this._onChangeCallback(), this;
|
@@ -1496,19 +1513,19 @@ class _t {
|
|
1496
1513
|
* @returns Return this quaternion
|
1497
1514
|
*/
|
1498
1515
|
setFromRotationMatrix(t) {
|
1499
|
-
const s = t.elements, e = s[0], n = s[4], i = s[8],
|
1500
|
-
if (
|
1501
|
-
const
|
1502
|
-
this._w = 0.25 /
|
1503
|
-
} else if (e >
|
1504
|
-
const
|
1505
|
-
this._w = (c - a) /
|
1506
|
-
} else if (
|
1507
|
-
const
|
1508
|
-
this._w = (i - o) /
|
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;
|
1509
1526
|
} else {
|
1510
|
-
const
|
1511
|
-
this._w = (
|
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;
|
1512
1529
|
}
|
1513
1530
|
return this._onChangeCallback(), this;
|
1514
1531
|
}
|
@@ -1625,8 +1642,8 @@ class _t {
|
|
1625
1642
|
* @returns Return this quaternion
|
1626
1643
|
*/
|
1627
1644
|
multiplyQuaternions(t, s) {
|
1628
|
-
const e = t._x, n = t._y, i = t._z,
|
1629
|
-
return this._x = e * c +
|
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;
|
1630
1647
|
}
|
1631
1648
|
/**
|
1632
1649
|
* Handles the spherical linear interpolation between quaternions. t represents the amount of rotation
|
@@ -1638,17 +1655,17 @@ class _t {
|
|
1638
1655
|
slerp(t, s) {
|
1639
1656
|
if (s === 0) return this;
|
1640
1657
|
if (s === 1) return this.copy(t);
|
1641
|
-
const e = this._x, n = this._y, i = this._z,
|
1642
|
-
let
|
1643
|
-
if (
|
1644
|
-
return this._w =
|
1645
|
-
const a = 1 -
|
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;
|
1646
1663
|
if (a <= Number.EPSILON) {
|
1647
|
-
const
|
1648
|
-
return this._w =
|
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;
|
1649
1666
|
}
|
1650
|
-
const o = Math.sqrt(a), c = Math.atan2(o,
|
1651
|
-
return this._w =
|
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;
|
1652
1669
|
}
|
1653
1670
|
/**
|
1654
1671
|
* Perform a spherical linear interpolation between the given quaternions and stores the result in
|
@@ -1727,8 +1744,8 @@ const N = class N {
|
|
1727
1744
|
return;
|
1728
1745
|
}
|
1729
1746
|
if (n === 1) {
|
1730
|
-
const { x: i, y:
|
1731
|
-
this.x = i, this.y =
|
1747
|
+
const { x: i, y: r, z: h } = t;
|
1748
|
+
this.x = i, this.y = r, this.z = h || 0;
|
1732
1749
|
return;
|
1733
1750
|
}
|
1734
1751
|
if (n === 3) {
|
@@ -1930,7 +1947,7 @@ const N = class N {
|
|
1930
1947
|
* @returns Return this vector
|
1931
1948
|
*/
|
1932
1949
|
applyEuler(t) {
|
1933
|
-
return this.applyQuaternion(
|
1950
|
+
return this.applyQuaternion(Ct.setFromEuler(t));
|
1934
1951
|
}
|
1935
1952
|
/**
|
1936
1953
|
* Apply a rotation specified by an axis and an angle to this vector.
|
@@ -1939,7 +1956,7 @@ const N = class N {
|
|
1939
1956
|
* @returns Return this vector
|
1940
1957
|
*/
|
1941
1958
|
applyAxisAngle(t, s) {
|
1942
|
-
return this.applyQuaternion(
|
1959
|
+
return this.applyQuaternion(Ct.setFromAxisAngle(t, s));
|
1943
1960
|
}
|
1944
1961
|
/**
|
1945
1962
|
* Multipliy this vector by m
|
@@ -1964,8 +1981,8 @@ const N = class N {
|
|
1964
1981
|
* @returns Return this vector
|
1965
1982
|
*/
|
1966
1983
|
applyMatrix3d(t) {
|
1967
|
-
const s = this.x, e = this.y, n = this.z, i = t.elements,
|
1968
|
-
return this.x = (i[0] * s + i[4] * e + i[8] * n + i[12]) *
|
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;
|
1969
1986
|
}
|
1970
1987
|
/**
|
1971
1988
|
* Apply a quaternion transform to this vector.
|
@@ -1973,8 +1990,8 @@ const N = class N {
|
|
1973
1990
|
* @returns Return this vector
|
1974
1991
|
*/
|
1975
1992
|
applyQuaternion(t) {
|
1976
|
-
const s = this.x, e = this.y, n = this.z, i = t.x,
|
1977
|
-
return this.x = s + a * o +
|
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;
|
1978
1995
|
}
|
1979
1996
|
/**
|
1980
1997
|
* Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a m) and
|
@@ -2185,8 +2202,8 @@ const N = class N {
|
|
2185
2202
|
* @returns Return this vector
|
2186
2203
|
*/
|
2187
2204
|
crossVectors(t, s) {
|
2188
|
-
const e = t.x, n = t.y, i = t.z,
|
2189
|
-
return this.x = n * a - i *
|
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;
|
2190
2207
|
}
|
2191
2208
|
/**
|
2192
2209
|
* Project this vector onto v.
|
@@ -2206,7 +2223,7 @@ const N = class N {
|
|
2206
2223
|
* @returns Return this vector
|
2207
2224
|
*/
|
2208
2225
|
projectOnPlane(t) {
|
2209
|
-
return
|
2226
|
+
return ft.copy(this).projectOnVector(t), this.sub(ft);
|
2210
2227
|
}
|
2211
2228
|
/**
|
2212
2229
|
* Reflect this vector off of plane orthogonal to normal. Normal is assumed to have unit length.
|
@@ -2214,7 +2231,7 @@ const N = class N {
|
|
2214
2231
|
* @returns Return this vector
|
2215
2232
|
*/
|
2216
2233
|
reflect(t) {
|
2217
|
-
return this.sub(
|
2234
|
+
return this.sub(ft.copy(t).multiplyScalar(2 * this.dot(t)));
|
2218
2235
|
}
|
2219
2236
|
/**
|
2220
2237
|
* Return the angle between this vector and vector v in radians.
|
@@ -2357,7 +2374,7 @@ const N = class N {
|
|
2357
2374
|
};
|
2358
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));
|
2359
2376
|
let y = N;
|
2360
|
-
const
|
2377
|
+
const ft = /* @__PURE__ */ new y(), Ct = /* @__PURE__ */ new pt(), $ = class $ {
|
2361
2378
|
/**
|
2362
2379
|
* Create a 4x4 matrix with the given arguments in row-major order. If no arguments are provided,
|
2363
2380
|
* the constructor initializes the Matrix4 to the 4x4 identity matrix.
|
@@ -2379,24 +2396,24 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2379
2396
|
* @param n43 Input element in the forth row and the third column
|
2380
2397
|
* @param n44 Input element in the forth row and the forth column
|
2381
2398
|
*/
|
2382
|
-
constructor(t, s, e, n, i,
|
2383
|
-
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 &&
|
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(
|
2384
2401
|
t,
|
2385
2402
|
s,
|
2386
2403
|
e,
|
2387
2404
|
n,
|
2388
2405
|
i,
|
2389
|
-
h,
|
2390
2406
|
r,
|
2407
|
+
h,
|
2391
2408
|
a,
|
2392
2409
|
o,
|
2393
2410
|
c,
|
2394
2411
|
l,
|
2395
|
-
d,
|
2396
2412
|
m,
|
2413
|
+
d,
|
2397
2414
|
x,
|
2398
2415
|
g,
|
2399
|
-
|
2416
|
+
p
|
2400
2417
|
);
|
2401
2418
|
}
|
2402
2419
|
/**
|
@@ -2420,9 +2437,9 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2420
2437
|
* @param n44 Input element in the forth row and the forth column
|
2421
2438
|
* @returns Return this matrix
|
2422
2439
|
*/
|
2423
|
-
set(t, s, e, n, i,
|
2424
|
-
const
|
2425
|
-
return
|
2440
|
+
set(t, s, e, n, i, r, h, a, o, c, l, m, d, x, g, p) {
|
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;
|
2426
2443
|
}
|
2427
2444
|
/**
|
2428
2445
|
* Reset this matrix to the identity matrix.
|
@@ -2554,8 +2571,8 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2554
2571
|
* @returns Return this matrix
|
2555
2572
|
*/
|
2556
2573
|
extractRotation(t) {
|
2557
|
-
const s = this.elements, e = t.elements, n = 1 / O.setFromMatrixColumn(t, 0).length(), i = 1 / O.setFromMatrixColumn(t, 1).length(),
|
2558
|
-
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] *
|
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;
|
2559
2576
|
}
|
2560
2577
|
// makeRotationFromEuler(euler) {
|
2561
2578
|
// const te = this.elements
|
@@ -2670,7 +2687,7 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2670
2687
|
* @returns Return this matrix
|
2671
2688
|
*/
|
2672
2689
|
makeRotationFromQuaternion(t) {
|
2673
|
-
return this.compose(
|
2690
|
+
return this.compose(Ms, t, As);
|
2674
2691
|
}
|
2675
2692
|
/**
|
2676
2693
|
* Construct a rotation matrix, looking from eye towards target oriented by the up vector.
|
@@ -2706,8 +2723,8 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2706
2723
|
* @returns Return this matrix
|
2707
2724
|
*/
|
2708
2725
|
multiplyMatrices(t, s) {
|
2709
|
-
const e = t.elements, n = s.elements, i = this.elements,
|
2710
|
-
return i[0] =
|
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;
|
2711
2728
|
}
|
2712
2729
|
/**
|
2713
2730
|
* Multiply every component of the matrix by a scalar value s.
|
@@ -2723,8 +2740,8 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2723
2740
|
* @returns Return the determinant of this matrix.
|
2724
2741
|
*/
|
2725
2742
|
determinant() {
|
2726
|
-
const t = this.elements, s = t[0], e = t[4], n = t[8], i = t[12],
|
2727
|
-
return x * (+i * a * l - n * o * l - i *
|
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);
|
2728
2745
|
}
|
2729
2746
|
/**
|
2730
2747
|
* Transposes this matrix.
|
@@ -2752,11 +2769,11 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2752
2769
|
* @returns Return this matrix
|
2753
2770
|
*/
|
2754
2771
|
invert() {
|
2755
|
-
const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3],
|
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;
|
2756
2773
|
if (B === 0)
|
2757
2774
|
return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
2758
2775
|
const z = 1 / B;
|
2759
|
-
return t[0] =
|
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;
|
2760
2777
|
}
|
2761
2778
|
/**
|
2762
2779
|
* Multiply the columns of this matrix by vector v.
|
@@ -2819,18 +2836,18 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2819
2836
|
* @returns Return this matrix
|
2820
2837
|
*/
|
2821
2838
|
makeRotationAxis(t, s) {
|
2822
|
-
const e = Math.cos(s), n = Math.sin(s), i = 1 - e,
|
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;
|
2823
2840
|
return this.set(
|
2824
|
-
o *
|
2825
|
-
o *
|
2826
|
-
o * a + n *
|
2841
|
+
o * r + e,
|
2842
|
+
o * h - n * a,
|
2843
|
+
o * a + n * h,
|
2827
2844
|
0,
|
2828
|
-
o *
|
2829
|
-
c *
|
2830
|
-
c * a - n *
|
2845
|
+
o * h + n * a,
|
2846
|
+
c * h + e,
|
2847
|
+
c * a - n * r,
|
2831
2848
|
0,
|
2832
|
-
o * a - n *
|
2833
|
-
c * a + n *
|
2849
|
+
o * a - n * h,
|
2850
|
+
c * a + n * r,
|
2834
2851
|
i * a * a + e,
|
2835
2852
|
0,
|
2836
2853
|
0,
|
@@ -2859,8 +2876,8 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2859
2876
|
* @param zy Input the amount to shear Z by Y.
|
2860
2877
|
* @returns Return this matrix
|
2861
2878
|
*/
|
2862
|
-
makeShear(t, s, e, n, i,
|
2863
|
-
return this.set(1, e, i, 0, t, 1,
|
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;
|
2864
2881
|
}
|
2865
2882
|
/**
|
2866
2883
|
* Set this matrix to the transformation composed of position, quaternion and scale.
|
@@ -2870,8 +2887,8 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2870
2887
|
* @returns Return this matrix
|
2871
2888
|
*/
|
2872
2889
|
compose(t, s, e) {
|
2873
|
-
const n = this.elements, i = s.x,
|
2874
|
-
return n[0] = (1 - (g +
|
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;
|
2875
2892
|
}
|
2876
2893
|
/**
|
2877
2894
|
* Decompose this matrix into its position, quaternion and scale components.
|
@@ -2887,10 +2904,10 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
2887
2904
|
decompose(t, s, e) {
|
2888
2905
|
const n = this.elements;
|
2889
2906
|
let i = O.set(n[0], n[1], n[2]).length();
|
2890
|
-
const
|
2907
|
+
const r = O.set(n[4], n[5], n[6]).length(), h = O.set(n[8], n[9], n[10]).length();
|
2891
2908
|
this.determinant() < 0 && (i = -i), t.x = n[12], t.y = n[13], t.z = n[14], R.copy(this);
|
2892
|
-
const o = 1 / i, c = 1 /
|
2893
|
-
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 =
|
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;
|
2894
2911
|
}
|
2895
2912
|
// makePerspective(
|
2896
2913
|
// left,
|
@@ -3017,9 +3034,9 @@ const Mt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new _t(), $ = class $ {
|
|
3017
3034
|
}
|
3018
3035
|
};
|
3019
3036
|
$.IDENTITY = Object.freeze(new $());
|
3020
|
-
let
|
3021
|
-
const O = /* @__PURE__ */ new y(), R = /* @__PURE__ */ new
|
3022
|
-
class
|
3037
|
+
let tt = $;
|
3038
|
+
const O = /* @__PURE__ */ new y(), R = /* @__PURE__ */ new tt(), Ms = /* @__PURE__ */ new y(0, 0, 0), As = /* @__PURE__ */ new y(1, 1, 1), q = /* @__PURE__ */ new y(), ut = /* @__PURE__ */ new y(), L = /* @__PURE__ */ new y();
|
3039
|
+
class Y {
|
3023
3040
|
/**
|
3024
3041
|
* Create a 3d box bounded by min and max.
|
3025
3042
|
* @param min (optional) Input the lower (x, y, z) boundary of the box.
|
@@ -3077,7 +3094,7 @@ class D {
|
|
3077
3094
|
* @returns Return a new box with the same min and max as this one.
|
3078
3095
|
*/
|
3079
3096
|
clone() {
|
3080
|
-
return new
|
3097
|
+
return new Y().copy(this);
|
3081
3098
|
}
|
3082
3099
|
/**
|
3083
3100
|
* Copy the min and max from box to this box.
|
@@ -3276,7 +3293,7 @@ const U = [
|
|
3276
3293
|
/* @__PURE__ */ new y(),
|
3277
3294
|
/* @__PURE__ */ new y(),
|
3278
3295
|
/* @__PURE__ */ new y()
|
3279
|
-
], wt = /* @__PURE__ */ new y(),
|
3296
|
+
], wt = /* @__PURE__ */ new y(), Bt = /* @__PURE__ */ new P();
|
3280
3297
|
class V {
|
3281
3298
|
/**
|
3282
3299
|
* Create a 2d box bounded by min and max.
|
@@ -3286,7 +3303,7 @@ class V {
|
|
3286
3303
|
* Set it to ( - Infinity, - Infinity ) if undefined or null provided.
|
3287
3304
|
*/
|
3288
3305
|
constructor(t = void 0, s = void 0) {
|
3289
|
-
this.min = t == null ? new
|
3306
|
+
this.min = t == null ? new P(1 / 0, 1 / 0) : new P(t.x, t.y), this.max = s == null ? new P(-1 / 0, -1 / 0) : new P(s.x, s.y);
|
3290
3307
|
}
|
3291
3308
|
/**
|
3292
3309
|
* Set the lower and upper (x, y) boundaries of this box.
|
@@ -3316,7 +3333,7 @@ class V {
|
|
3316
3333
|
* @returns Return this box
|
3317
3334
|
*/
|
3318
3335
|
setFromCenterAndSize(t, s) {
|
3319
|
-
const e =
|
3336
|
+
const e = Bt.copy(s).multiplyScalar(0.5);
|
3320
3337
|
return this.min.copy(t).sub(e), this.max.copy(t).add(e), this;
|
3321
3338
|
}
|
3322
3339
|
/**
|
@@ -3369,13 +3386,13 @@ class V {
|
|
3369
3386
|
* Center point of this box
|
3370
3387
|
*/
|
3371
3388
|
get center() {
|
3372
|
-
return this.isEmpty() ? new
|
3389
|
+
return this.isEmpty() ? new P(0, 0) : new P(0, 0).addVectors(this.min, this.max).multiplyScalar(0.5);
|
3373
3390
|
}
|
3374
3391
|
/**
|
3375
3392
|
* Return the width, height and depth of this box.
|
3376
3393
|
*/
|
3377
3394
|
get size() {
|
3378
|
-
return this.isEmpty() ? new
|
3395
|
+
return this.isEmpty() ? new P(0, 0) : new P(0, 0).subVectors(this.max, this.min);
|
3379
3396
|
}
|
3380
3397
|
/**
|
3381
3398
|
* Expand the boundaries of this box to include point.
|
@@ -3456,7 +3473,7 @@ class V {
|
|
3456
3473
|
* @returns Return the distance from any edge of this box to the specified point.
|
3457
3474
|
*/
|
3458
3475
|
distanceToPoint(t) {
|
3459
|
-
return this.clampPoint(t,
|
3476
|
+
return this.clampPoint(t, Bt).distanceTo(t);
|
3460
3477
|
}
|
3461
3478
|
/**
|
3462
3479
|
* Return the intersection of this and box, setting the upper bound of this box to the lesser of the
|
@@ -3494,8 +3511,8 @@ class V {
|
|
3494
3511
|
return t.min.equals(this.min) && t.max.equals(this.max);
|
3495
3512
|
}
|
3496
3513
|
}
|
3497
|
-
const
|
3498
|
-
class
|
3514
|
+
const It = /* @__PURE__ */ new y(), fs = /* @__PURE__ */ new y(), ws = /* @__PURE__ */ new v();
|
3515
|
+
class zt {
|
3499
3516
|
/**
|
3500
3517
|
* Create one plane
|
3501
3518
|
* @param normal (optional) Input a unit length Vector3 defining the normal of the plane.
|
@@ -3543,7 +3560,7 @@ class pt {
|
|
3543
3560
|
* @returns Return this plane
|
3544
3561
|
*/
|
3545
3562
|
setFromCoplanarPoints(t, s, e) {
|
3546
|
-
const n =
|
3563
|
+
const n = It.subVectors(e, s).cross(fs.subVectors(t, s)).normalize();
|
3547
3564
|
return this.setFromNormalAndCoplanarPoint(n, t), this;
|
3548
3565
|
}
|
3549
3566
|
/**
|
@@ -3645,7 +3662,7 @@ class pt {
|
|
3645
3662
|
* @returns Return this plane
|
3646
3663
|
*/
|
3647
3664
|
applyMatrix4(t, s) {
|
3648
|
-
const e = s ||
|
3665
|
+
const e = s || ws.getNormalMatrix(t), n = this.coplanarPoint(It).applyMatrix3d(t), i = this.normal.applyMatrix3(e).normalize();
|
3649
3666
|
return this.constant = -n.dot(i), this;
|
3650
3667
|
}
|
3651
3668
|
/**
|
@@ -3670,10 +3687,10 @@ class pt {
|
|
3670
3687
|
* @returns Return the cloned plane
|
3671
3688
|
*/
|
3672
3689
|
clone() {
|
3673
|
-
return new
|
3690
|
+
return new zt().copy(this);
|
3674
3691
|
}
|
3675
3692
|
}
|
3676
|
-
class
|
3693
|
+
class b extends P {
|
3677
3694
|
/**
|
3678
3695
|
* Convert one point array to one number array
|
3679
3696
|
* @param array Input one point array
|
@@ -3686,7 +3703,7 @@ class P extends f {
|
|
3686
3703
|
}), s;
|
3687
3704
|
}
|
3688
3705
|
}
|
3689
|
-
class
|
3706
|
+
class S extends y {
|
3690
3707
|
/**
|
3691
3708
|
* Convert one point array to one number array
|
3692
3709
|
* @param array Input one point array
|
@@ -3695,12 +3712,12 @@ class I extends y {
|
|
3695
3712
|
*/
|
3696
3713
|
static pointArrayToNumberArray(t, s = !0) {
|
3697
3714
|
const e = s ? 3 : 2, n = new Array(t.length * e);
|
3698
|
-
return t.forEach((i,
|
3699
|
-
i.toArray(n,
|
3715
|
+
return t.forEach((i, r) => {
|
3716
|
+
i.toArray(n, r * e);
|
3700
3717
|
}), n;
|
3701
3718
|
}
|
3702
3719
|
}
|
3703
|
-
const
|
3720
|
+
const Et = /* @__PURE__ */ new tt(), kt = /* @__PURE__ */ new pt(), J = class J {
|
3704
3721
|
/**
|
3705
3722
|
* Create one instance of this class
|
3706
3723
|
* @param x (optional) the angle of the x axis in radians. Default is 0.
|
@@ -3709,7 +3726,7 @@ const Ct = /* @__PURE__ */ new v(), kt = /* @__PURE__ */ new _t(), W = class W {
|
|
3709
3726
|
* @param order (optional) a string representing the order that the rotations are applied,
|
3710
3727
|
* defaults to 'XYZ' (must be upper case).
|
3711
3728
|
*/
|
3712
|
-
constructor(t = 0, s = 0, e = 0, n =
|
3729
|
+
constructor(t = 0, s = 0, e = 0, n = J.DEFAULT_ORDER) {
|
3713
3730
|
this._x = t, this._y = s, this._z = e, this._order = n;
|
3714
3731
|
}
|
3715
3732
|
/**
|
@@ -3772,7 +3789,7 @@ const Ct = /* @__PURE__ */ new v(), kt = /* @__PURE__ */ new _t(), W = class W {
|
|
3772
3789
|
* @returns Return a new Euler with the same parameters as this one.
|
3773
3790
|
*/
|
3774
3791
|
clone() {
|
3775
|
-
return new
|
3792
|
+
return new J(this._x, this._y, this._z, this._order);
|
3776
3793
|
}
|
3777
3794
|
/**
|
3778
3795
|
* Copy value of euler to this euler.
|
@@ -3792,25 +3809,25 @@ const Ct = /* @__PURE__ */ new v(), kt = /* @__PURE__ */ new _t(), W = class W {
|
|
3792
3809
|
* @returns Return this euler
|
3793
3810
|
*/
|
3794
3811
|
setFromRotationMatrix(t, s = this._order, e = !0) {
|
3795
|
-
const n = t.elements, i = n[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];
|
3796
3813
|
switch (s) {
|
3797
3814
|
case "XYZ":
|
3798
|
-
this._y = Math.asin(j(
|
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);
|
3799
3816
|
break;
|
3800
3817
|
case "YXZ":
|
3801
|
-
this._x = Math.asin(-j(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._y = Math.atan2(
|
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);
|
3802
3819
|
break;
|
3803
3820
|
case "ZXY":
|
3804
|
-
this._x = Math.asin(j(
|
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));
|
3805
3822
|
break;
|
3806
3823
|
case "ZYX":
|
3807
|
-
this._y = Math.asin(-j(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(
|
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));
|
3808
3825
|
break;
|
3809
3826
|
case "YZX":
|
3810
|
-
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(
|
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));
|
3811
3828
|
break;
|
3812
3829
|
case "XZY":
|
3813
|
-
this._z = Math.asin(-j(
|
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);
|
3814
3831
|
break;
|
3815
3832
|
default:
|
3816
3833
|
console.warn(
|
@@ -3829,7 +3846,7 @@ const Ct = /* @__PURE__ */ new v(), kt = /* @__PURE__ */ new _t(), W = class W {
|
|
3829
3846
|
* @returns Return this euler
|
3830
3847
|
*/
|
3831
3848
|
setFromQuaternion(t, s, e = !0) {
|
3832
|
-
return
|
3849
|
+
return Et.makeRotationFromQuaternion(t), this.setFromRotationMatrix(Et, s, e);
|
3833
3850
|
}
|
3834
3851
|
/**
|
3835
3852
|
* Set the x, y and z, and optionally update the order.
|
@@ -3892,8 +3909,8 @@ const Ct = /* @__PURE__ */ new v(), kt = /* @__PURE__ */ new _t(), W = class W {
|
|
3892
3909
|
yield this._x, yield this._y, yield this._z, yield this._order;
|
3893
3910
|
}
|
3894
3911
|
};
|
3895
|
-
|
3896
|
-
let Nt =
|
3912
|
+
J.DEFAULT_ORDER = "XYZ";
|
3913
|
+
let Nt = J;
|
3897
3914
|
class Dt {
|
3898
3915
|
constructor() {
|
3899
3916
|
this._boundingBoxNeedsUpdate = !1;
|
@@ -3911,7 +3928,7 @@ class Yt extends Dt {
|
|
3911
3928
|
* Return new shape translated by given vector.
|
3912
3929
|
*/
|
3913
3930
|
translate(t) {
|
3914
|
-
return this.transform(new
|
3931
|
+
return this.transform(new v().makeTranslation(t.x, t.y));
|
3915
3932
|
}
|
3916
3933
|
/**
|
3917
3934
|
* The bounding box of this shape. Because it is a time-consuming operation to calculate the bounding
|
@@ -3922,7 +3939,7 @@ class Yt extends Dt {
|
|
3922
3939
|
return (this._box == null || this._boundingBoxNeedsUpdate) && (this._box = this.calculateBoundingBox(), this._boundingBoxNeedsUpdate = !1), this._box;
|
3923
3940
|
}
|
3924
3941
|
}
|
3925
|
-
class
|
3942
|
+
class Cs extends Yt {
|
3926
3943
|
/**
|
3927
3944
|
* Create one 2d area defined by one outter loop and multiple inner loops
|
3928
3945
|
*/
|
@@ -3977,30 +3994,30 @@ class Bs extends Yt {
|
|
3977
3994
|
return s;
|
3978
3995
|
}
|
3979
3996
|
buildHierarchy() {
|
3980
|
-
var
|
3997
|
+
var h;
|
3981
3998
|
const t = this.getPoints(100), s = this.calculateBoundaryBoxes(t), e = this.sortBoundaryBoxesByAreas(s), n = /* @__PURE__ */ new Map(), i = e.length;
|
3982
3999
|
for (let a = 0; a < i; a++)
|
3983
4000
|
n.set(e[a], {
|
3984
4001
|
index: e[a],
|
3985
4002
|
children: []
|
3986
4003
|
});
|
3987
|
-
const
|
4004
|
+
const r = { index: -1, children: [] };
|
3988
4005
|
for (let a = 0; a < i; a++) {
|
3989
4006
|
const o = e[a], c = t[o], l = s[o];
|
3990
|
-
let
|
3991
|
-
for (;
|
3992
|
-
const
|
3993
|
-
if (s[
|
3994
|
-
c[
|
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(
|
4011
|
+
c[C.randInt(0, c.length - 1)],
|
3995
4012
|
x
|
3996
4013
|
)) {
|
3997
|
-
(
|
4014
|
+
(h = n.get(d)) == null || h.children.push(n.get(o));
|
3998
4015
|
break;
|
3999
4016
|
}
|
4000
4017
|
}
|
4001
|
-
|
4018
|
+
m === i && r.children.push(n.get(o));
|
4002
4019
|
}
|
4003
|
-
return
|
4020
|
+
return r;
|
4004
4021
|
}
|
4005
4022
|
/**
|
4006
4023
|
* Calcuate bounding box of each loop in this area and return an array of their bounding box
|
@@ -4021,9 +4038,9 @@ class Bs extends Yt {
|
|
4021
4038
|
sortBoundaryBoxesByAreas(t) {
|
4022
4039
|
const s = [];
|
4023
4040
|
t.forEach((n, i) => {
|
4024
|
-
const
|
4041
|
+
const r = n.size, h = r.width * r.height;
|
4025
4042
|
s.push({
|
4026
|
-
area:
|
4043
|
+
area: h,
|
4027
4044
|
index: i
|
4028
4045
|
});
|
4029
4046
|
}), s.sort((n, i) => n.area - i.area);
|
@@ -4113,8 +4130,8 @@ class st extends Yt {
|
|
4113
4130
|
const s = [];
|
4114
4131
|
let e, n = this.getPoint(0), i = 0;
|
4115
4132
|
s.push(0);
|
4116
|
-
for (let
|
4117
|
-
e = this.getPoint(
|
4133
|
+
for (let r = 1; r <= t; r++)
|
4134
|
+
e = this.getPoint(r / t), i += e.distanceTo(n), s.push(i), n = e;
|
4118
4135
|
return s;
|
4119
4136
|
}
|
4120
4137
|
/**
|
@@ -4125,22 +4142,22 @@ class st extends Yt {
|
|
4125
4142
|
const e = this.getLengths();
|
4126
4143
|
let n = 0;
|
4127
4144
|
const i = e.length;
|
4128
|
-
let
|
4129
|
-
s ?
|
4130
|
-
let
|
4131
|
-
for (;
|
4132
|
-
if (n = Math.floor(
|
4133
|
-
|
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;
|
4134
4151
|
else if (o > 0)
|
4135
4152
|
a = n - 1;
|
4136
4153
|
else {
|
4137
4154
|
a = n;
|
4138
4155
|
break;
|
4139
4156
|
}
|
4140
|
-
if (n = a, e[n] ===
|
4157
|
+
if (n = a, e[n] === r)
|
4141
4158
|
return n / (i - 1);
|
4142
|
-
const c = e[n],
|
4143
|
-
return (n +
|
4159
|
+
const c = e[n], m = e[n + 1] - c, d = (r - c) / m;
|
4160
|
+
return (n + d) / (i - 1);
|
4144
4161
|
}
|
4145
4162
|
/**
|
4146
4163
|
* Return a unit vector tangent at `t`. If the derived curve does not implement its tangent derivation,
|
@@ -4152,8 +4169,8 @@ class st extends Yt {
|
|
4152
4169
|
getTangent(t) {
|
4153
4170
|
let e = t - 1e-4, n = t + 1e-4;
|
4154
4171
|
e < 0 && (e = 0), n > 1 && (n = 1);
|
4155
|
-
const i = this.getPoint(e),
|
4156
|
-
return
|
4172
|
+
const i = this.getPoint(e), r = this.getPoint(n), h = new b();
|
4173
|
+
return h.copy(r).sub(i).normalize(), h;
|
4157
4174
|
}
|
4158
4175
|
/**
|
4159
4176
|
* Return tangent at a point which is equidistant to the ends of the curve from the point given in
|
@@ -4167,11 +4184,11 @@ class st extends Yt {
|
|
4167
4184
|
return this.getTangent(s);
|
4168
4185
|
}
|
4169
4186
|
}
|
4170
|
-
class
|
4187
|
+
class gt extends st {
|
4171
4188
|
constructor(t, s, e, n, i) {
|
4172
4189
|
super();
|
4173
|
-
const
|
4174
|
-
if (
|
4190
|
+
const r = +(t !== void 0) + +(s !== void 0) + +(e !== void 0) + +(n !== void 0) + +(i !== void 0);
|
4191
|
+
if (r == 3)
|
4175
4192
|
typeof t == "object" && typeof s == "object" && typeof e == "object" ? this.createByThreePoints(
|
4176
4193
|
t,
|
4177
4194
|
s,
|
@@ -4181,9 +4198,9 @@ class yt extends st {
|
|
4181
4198
|
s,
|
4182
4199
|
e
|
4183
4200
|
);
|
4184
|
-
else if (
|
4185
|
-
const
|
4186
|
-
this.center = new
|
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;
|
4187
4204
|
} else
|
4188
4205
|
throw T.ILLEGAL_PARAMETERS;
|
4189
4206
|
}
|
@@ -4194,16 +4211,16 @@ class yt extends st {
|
|
4194
4211
|
* @param p3 Input the end point
|
4195
4212
|
*/
|
4196
4213
|
createByThreePoints(t, s, e) {
|
4197
|
-
const n = (z,
|
4198
|
-
x: (z.x +
|
4199
|
-
y: (z.y +
|
4200
|
-
}), i = (z,
|
4201
|
-
const F = (
|
4202
|
-
return { x: F, y:
|
4203
|
-
}, x =
|
4204
|
-
Math.pow(t.x -
|
4205
|
-
),
|
4206
|
-
this.center =
|
4214
|
+
const n = (z, E) => ({
|
4215
|
+
x: (z.x + E.x) / 2,
|
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) => {
|
4218
|
+
const F = (G - E) / (z - Z), K = z * F + E;
|
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(
|
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;
|
4207
4224
|
}
|
4208
4225
|
/**
|
4209
4226
|
* Create circular arc by two points and one bugle factor
|
@@ -4217,24 +4234,24 @@ class yt extends st {
|
|
4217
4234
|
* - https://www.afralisp.net/archive/lisp/Bulges1.htm
|
4218
4235
|
*/
|
4219
4236
|
createByStartEndPointsAndBulge(t, s, e) {
|
4220
|
-
let n, i,
|
4221
|
-
e < 0 ? (n = Math.atan(-e) * 4, i = new
|
4222
|
-
const
|
4223
|
-
let
|
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;
|
4224
4241
|
if (n < Math.PI) {
|
4225
|
-
const
|
4242
|
+
const d = new P(
|
4226
4243
|
l.x * Math.cos(Math.PI / 2) - l.y * Math.sin(Math.PI / 2),
|
4227
4244
|
l.y * Math.cos(Math.PI / 2) + l.x * Math.sin(Math.PI / 2)
|
4228
4245
|
);
|
4229
|
-
|
4246
|
+
m = o.add(d.multiplyScalar(-c));
|
4230
4247
|
} else {
|
4231
|
-
const
|
4248
|
+
const d = new P(
|
4232
4249
|
l.x * Math.cos(Math.PI / 2) - l.y * Math.sin(Math.PI / 2),
|
4233
4250
|
l.y * Math.cos(Math.PI / 2) + l.x * Math.sin(Math.PI / 2)
|
4234
4251
|
);
|
4235
|
-
|
4252
|
+
m = o.add(d.multiplyScalar(c));
|
4236
4253
|
}
|
4237
|
-
e < 0 ? (this.startAngle = Math.atan2(i.y -
|
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();
|
4238
4255
|
}
|
4239
4256
|
/**
|
4240
4257
|
* Center of circular arc
|
@@ -4243,7 +4260,7 @@ class yt extends st {
|
|
4243
4260
|
return this._center;
|
4244
4261
|
}
|
4245
4262
|
set center(t) {
|
4246
|
-
this._center = new
|
4263
|
+
this._center = new b(t.x, t.y), this._boundingBoxNeedsUpdate = !0;
|
4247
4264
|
}
|
4248
4265
|
/**
|
4249
4266
|
* Radius of circular arc
|
@@ -4261,7 +4278,7 @@ class yt extends st {
|
|
4261
4278
|
return this._startAngle;
|
4262
4279
|
}
|
4263
4280
|
set startAngle(t) {
|
4264
|
-
this._startAngle =
|
4281
|
+
this._startAngle = C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4265
4282
|
}
|
4266
4283
|
/**
|
4267
4284
|
* End angle in radians of circular arc in the range 0 to 2 * PI.
|
@@ -4270,13 +4287,13 @@ class yt extends st {
|
|
4270
4287
|
return this._endAngle;
|
4271
4288
|
}
|
4272
4289
|
set endAngle(t) {
|
4273
|
-
this._endAngle = this.startAngle == 0 && t ==
|
4290
|
+
this._endAngle = this.startAngle == 0 && t == I ? t : C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4274
4291
|
}
|
4275
4292
|
/**
|
4276
4293
|
* Angle between endAngle and startAngle in range 0 to 2*PI
|
4277
4294
|
*/
|
4278
4295
|
get deltaAngle() {
|
4279
|
-
return this.clockwise ?
|
4296
|
+
return this.clockwise ? C.normalizeAngle(this.startAngle - this.endAngle) : C.normalizeAngle(this.endAngle - this.startAngle);
|
4280
4297
|
}
|
4281
4298
|
/**
|
4282
4299
|
* Rotation direction of the arc.
|
@@ -4303,7 +4320,7 @@ class yt extends st {
|
|
4303
4320
|
* Middle point of circular arc
|
4304
4321
|
*/
|
4305
4322
|
get midPoint() {
|
4306
|
-
const t =
|
4323
|
+
const t = C.normalizeAngle(
|
4307
4324
|
(this.startAngle + this.endAngle) / 2
|
4308
4325
|
);
|
4309
4326
|
return this.getPointAtAngle(t);
|
@@ -4320,7 +4337,7 @@ class yt extends st {
|
|
4320
4337
|
calculateBoundingBox() {
|
4321
4338
|
const t = [this.startPoint, this.endPoint], s = [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2];
|
4322
4339
|
for (const i of s)
|
4323
|
-
|
4340
|
+
C.isBetweenAngle(
|
4324
4341
|
i,
|
4325
4342
|
this.startAngle,
|
4326
4343
|
this.endAngle,
|
@@ -4328,8 +4345,8 @@ class yt extends st {
|
|
4328
4345
|
) && t.push(this.getPointAtAngle(i));
|
4329
4346
|
const e = t.map((i) => i.x), n = t.map((i) => i.y);
|
4330
4347
|
return new V(
|
4331
|
-
new
|
4332
|
-
new
|
4348
|
+
new b(Math.min(...e), Math.min(...n)),
|
4349
|
+
new b(Math.max(...e), Math.max(...n))
|
4333
4350
|
);
|
4334
4351
|
}
|
4335
4352
|
/**
|
@@ -4348,7 +4365,7 @@ class yt extends st {
|
|
4348
4365
|
* @inheritdoc
|
4349
4366
|
*/
|
4350
4367
|
clone() {
|
4351
|
-
return new
|
4368
|
+
return new gt(
|
4352
4369
|
this.center.clone(),
|
4353
4370
|
this.radius,
|
4354
4371
|
this.startAngle,
|
@@ -4363,7 +4380,7 @@ class yt extends st {
|
|
4363
4380
|
*/
|
4364
4381
|
getPointAtAngle(t) {
|
4365
4382
|
const s = this.center.x + this.radius * Math.cos(t), e = this.center.y + this.radius * Math.sin(t);
|
4366
|
-
return new
|
4383
|
+
return new b(s, e);
|
4367
4384
|
}
|
4368
4385
|
/**
|
4369
4386
|
* Divide this arc into the specified nubmer of points and return those points as an array of points.
|
@@ -4373,15 +4390,15 @@ class yt extends st {
|
|
4373
4390
|
getPoints(t = 100) {
|
4374
4391
|
const s = [];
|
4375
4392
|
let e = this.deltaAngle, n = this.startAngle;
|
4376
|
-
if (this.closed && (e =
|
4393
|
+
if (this.closed && (e = I, n = 0), this.clockwise)
|
4377
4394
|
for (let i = 0; i <= t; i++) {
|
4378
|
-
const
|
4379
|
-
s.push(new
|
4395
|
+
const r = n - e * (i / t), h = this.getPointAtAngle(r);
|
4396
|
+
s.push(new b(h.x, h.y));
|
4380
4397
|
}
|
4381
4398
|
else
|
4382
4399
|
for (let i = 0; i <= t; i++) {
|
4383
|
-
const
|
4384
|
-
s.push(new
|
4400
|
+
const r = n + e * (i / t), h = this.getPointAtAngle(r);
|
4401
|
+
s.push(new b(h.x, h.y));
|
4385
4402
|
}
|
4386
4403
|
return s;
|
4387
4404
|
}
|
@@ -4392,7 +4409,7 @@ class Ps extends Dt {
|
|
4392
4409
|
* Translation vector may be also defined by a pair of numbers.
|
4393
4410
|
*/
|
4394
4411
|
translate(t) {
|
4395
|
-
return this.transform(new
|
4412
|
+
return this.transform(new tt().makeTranslation(t.x, t.y, t.z));
|
4396
4413
|
}
|
4397
4414
|
/**
|
4398
4415
|
* The bounding box of this shape. Because it is a time-consuming operation to calculate the bounding
|
@@ -4403,15 +4420,15 @@ class Ps extends Dt {
|
|
4403
4420
|
return (this._box == null || this._boundingBoxNeedsUpdate) && (this._box = this.calculateBoundingBox(), this._boundingBoxNeedsUpdate = !1), this._box;
|
4404
4421
|
}
|
4405
4422
|
}
|
4406
|
-
class
|
4423
|
+
class Mt extends Ps {
|
4407
4424
|
}
|
4408
|
-
class
|
4425
|
+
class _t extends Mt {
|
4409
4426
|
/**
|
4410
4427
|
* This constructor initializes the line object to use start as the start point, and end
|
4411
4428
|
* as the endpoint. Both points must be in WCS coordinates.
|
4412
4429
|
*/
|
4413
4430
|
constructor(t, s) {
|
4414
|
-
super(), this._start = new
|
4431
|
+
super(), this._start = new S(t), this._end = new S(s);
|
4415
4432
|
}
|
4416
4433
|
/**
|
4417
4434
|
* The line's startpoint in WCS coordinates
|
@@ -4441,7 +4458,7 @@ class gt extends zt {
|
|
4441
4458
|
* The middle point of this line.
|
4442
4459
|
*/
|
4443
4460
|
get midPoint() {
|
4444
|
-
return new
|
4461
|
+
return new S(
|
4445
4462
|
(this._start.x + this._end.x) / 2,
|
4446
4463
|
(this._start.y + this._end.y) / 2,
|
4447
4464
|
(this._start.z + this._end.z) / 2
|
@@ -4481,10 +4498,10 @@ class gt extends zt {
|
|
4481
4498
|
atLength(t, s = !1) {
|
4482
4499
|
if (s) {
|
4483
4500
|
const e = this.delta(X).normalize();
|
4484
|
-
return new
|
4501
|
+
return new S(this._start).addScaledVector(e, t);
|
4485
4502
|
} else {
|
4486
4503
|
const e = this.delta(X).normalize();
|
4487
|
-
return new
|
4504
|
+
return new S(this._end).addScaledVector(e, t);
|
4488
4505
|
}
|
4489
4506
|
}
|
4490
4507
|
/**
|
@@ -4497,13 +4514,13 @@ class gt extends zt {
|
|
4497
4514
|
extend(t, s = !1) {
|
4498
4515
|
if (s) {
|
4499
4516
|
const e = X.subVectors(this._start, this._end).normalize();
|
4500
|
-
this._start = new
|
4517
|
+
this._start = new S(this._start).addScaledVector(
|
4501
4518
|
e,
|
4502
4519
|
t
|
4503
4520
|
);
|
4504
4521
|
} else {
|
4505
4522
|
const e = this.delta(X).normalize();
|
4506
|
-
this._end = new
|
4523
|
+
this._end = new S(this._end).addScaledVector(e, t);
|
4507
4524
|
}
|
4508
4525
|
return this._boundingBoxNeedsUpdate = !0, this;
|
4509
4526
|
}
|
@@ -4515,10 +4532,10 @@ class gt extends zt {
|
|
4515
4532
|
* @returns Return a point parameter based on the closest point as projected on the line segment.
|
4516
4533
|
*/
|
4517
4534
|
closestPointToPointParameter(t, s) {
|
4518
|
-
Lt.subVectors(t, this._start),
|
4519
|
-
const e =
|
4520
|
-
let i =
|
4521
|
-
return s && (i =
|
4535
|
+
Lt.subVectors(t, this._start), dt.subVectors(this.endPoint, this.startPoint);
|
4536
|
+
const e = dt.dot(dt);
|
4537
|
+
let i = dt.dot(Lt) / e;
|
4538
|
+
return s && (i = C.clamp(i, 0, 1)), i;
|
4522
4539
|
}
|
4523
4540
|
/**
|
4524
4541
|
* Return the closets point on the line. If clampToLine is true, then the returned value will be
|
@@ -4561,7 +4578,7 @@ class gt extends zt {
|
|
4561
4578
|
*/
|
4562
4579
|
project(t) {
|
4563
4580
|
const s = this.direction, n = X.subVectors(t, this.startPoint).dot(s);
|
4564
|
-
return new
|
4581
|
+
return new S().copy(s).multiplyScalar(n).add(this.startPoint);
|
4565
4582
|
}
|
4566
4583
|
/**
|
4567
4584
|
* Finds the point on the line that is perpendicular to the given point. When you need the shortest distance
|
@@ -4571,23 +4588,23 @@ class gt extends zt {
|
|
4571
4588
|
* @returns Return the point on the line that is the closest to the given point.
|
4572
4589
|
*/
|
4573
4590
|
perpPoint(t) {
|
4574
|
-
const s = this.direction, e = this.startPoint, i = X.subVectors(t, e).dot(s),
|
4575
|
-
return new
|
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);
|
4576
4593
|
}
|
4577
4594
|
/**
|
4578
4595
|
* @inheritdoc
|
4579
4596
|
*/
|
4580
4597
|
calculateBoundingBox() {
|
4581
|
-
const t = new
|
4598
|
+
const t = new S(
|
4582
4599
|
Math.min(this._start.x, this._end.x),
|
4583
4600
|
Math.min(this._start.y, this._end.y),
|
4584
4601
|
Math.min(this._start.z, this._end.z)
|
4585
|
-
), s = new
|
4602
|
+
), s = new S(
|
4586
4603
|
Math.max(this._start.x, this._end.x),
|
4587
4604
|
Math.max(this._start.y, this._end.y),
|
4588
4605
|
Math.max(this._start.z, this._end.z)
|
4589
4606
|
);
|
4590
|
-
return new
|
4607
|
+
return new Y(t, s);
|
4591
4608
|
}
|
4592
4609
|
/**
|
4593
4610
|
* @inheritdoc
|
@@ -4611,11 +4628,11 @@ class gt extends zt {
|
|
4611
4628
|
* @inheritdoc
|
4612
4629
|
*/
|
4613
4630
|
clone() {
|
4614
|
-
return new
|
4631
|
+
return new _t(this._start.clone(), this._end.clone());
|
4615
4632
|
}
|
4616
4633
|
}
|
4617
|
-
const X = /* @__PURE__ */ new y(), Lt = /* @__PURE__ */ new y(),
|
4618
|
-
class
|
4634
|
+
const X = /* @__PURE__ */ new y(), Lt = /* @__PURE__ */ new y(), dt = /* @__PURE__ */ new y();
|
4635
|
+
class yt extends Mt {
|
4619
4636
|
/**
|
4620
4637
|
* Compute center point of the arc given three points
|
4621
4638
|
* @param startPoint Input start point of the arc
|
@@ -4624,11 +4641,11 @@ class xt extends zt {
|
|
4624
4641
|
* @returns Return center point of the arc
|
4625
4642
|
*/
|
4626
4643
|
static computeCenterPoint(t, s, e) {
|
4627
|
-
const n = new y().addVectors(t, s).multiplyScalar(0.5), i = new y().addVectors(t, e).multiplyScalar(0.5),
|
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();
|
4628
4645
|
if (a.lengthSq() === 0)
|
4629
4646
|
return console.error("Points are collinear and cannot form a valid arc."), null;
|
4630
|
-
const o = new y().crossVectors(
|
4631
|
-
return
|
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);
|
4632
4649
|
}
|
4633
4650
|
/**
|
4634
4651
|
* Create arc by three points
|
@@ -4637,14 +4654,14 @@ class xt extends zt {
|
|
4637
4654
|
* @param pointOnArc Input one point between the start point and the end point
|
4638
4655
|
*/
|
4639
4656
|
static createByThreePoints(t, s, e) {
|
4640
|
-
const n =
|
4657
|
+
const n = yt.computeCenterPoint(
|
4641
4658
|
t,
|
4642
4659
|
s,
|
4643
4660
|
e
|
4644
4661
|
);
|
4645
4662
|
if (n) {
|
4646
|
-
const i = n.distanceTo(t),
|
4647
|
-
return new
|
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);
|
4664
|
+
return new yt(
|
4648
4665
|
n,
|
4649
4666
|
i,
|
4650
4667
|
a,
|
@@ -4662,8 +4679,8 @@ class xt extends zt {
|
|
4662
4679
|
* @param normal The normal vector of the plane in which the arc lies.
|
4663
4680
|
* @param refVec The reference vector from which angles are measured. Default value is x axis.
|
4664
4681
|
*/
|
4665
|
-
constructor(t, s, e, n, i,
|
4666
|
-
super(), this.center = t, this.radius = s, this.startAngle = e, this.endAngle = n, this.normal = i, this.refVec =
|
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);
|
4667
4684
|
}
|
4668
4685
|
/**
|
4669
4686
|
* Center of circular arc
|
@@ -4672,7 +4689,7 @@ class xt extends zt {
|
|
4672
4689
|
return this._center;
|
4673
4690
|
}
|
4674
4691
|
set center(t) {
|
4675
|
-
this._center = new
|
4692
|
+
this._center = new S(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
|
4676
4693
|
}
|
4677
4694
|
/**
|
4678
4695
|
* Radius of circular arc
|
@@ -4691,7 +4708,7 @@ class xt extends zt {
|
|
4691
4708
|
return this._startAngle;
|
4692
4709
|
}
|
4693
4710
|
set startAngle(t) {
|
4694
|
-
this._startAngle =
|
4711
|
+
this._startAngle = C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4695
4712
|
}
|
4696
4713
|
/**
|
4697
4714
|
* End angle in radians of circular arc in the range 0 to 2 * PI.
|
@@ -4700,13 +4717,13 @@ class xt extends zt {
|
|
4700
4717
|
return this._endAngle;
|
4701
4718
|
}
|
4702
4719
|
set endAngle(t) {
|
4703
|
-
this._endAngle = this.startAngle == 0 && t ==
|
4720
|
+
this._endAngle = this.startAngle == 0 && t == I ? t : C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4704
4721
|
}
|
4705
4722
|
/**
|
4706
4723
|
* Return angle between endAngle and startAngle in range 0 to 2*PI
|
4707
4724
|
*/
|
4708
4725
|
get deltaAngle() {
|
4709
|
-
return
|
4726
|
+
return C.normalizeAngle(this.endAngle - this.startAngle);
|
4710
4727
|
}
|
4711
4728
|
/**
|
4712
4729
|
* Return true if the arc is a large arc whose delta angle value is greater than PI.
|
@@ -4762,15 +4779,15 @@ class xt extends zt {
|
|
4762
4779
|
calculateBoundingBox() {
|
4763
4780
|
const t = [this.startAngle, this.endAngle];
|
4764
4781
|
for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
|
4765
|
-
|
4766
|
-
let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0,
|
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;
|
4767
4784
|
for (const a of t) {
|
4768
4785
|
const o = this.getPointAtAngle(a);
|
4769
|
-
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 >
|
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);
|
4770
4787
|
}
|
4771
|
-
return new
|
4788
|
+
return new Y(
|
4772
4789
|
{ x: s, y: e, z: n },
|
4773
|
-
{ x: i, y:
|
4790
|
+
{ x: i, y: r, z: h }
|
4774
4791
|
);
|
4775
4792
|
}
|
4776
4793
|
/**
|
@@ -4788,10 +4805,10 @@ class xt extends zt {
|
|
4788
4805
|
getPoints(t) {
|
4789
4806
|
const s = [];
|
4790
4807
|
let e = this.deltaAngle, n = this.startAngle;
|
4791
|
-
this.closed && (e =
|
4808
|
+
this.closed && (e = I, n = 0);
|
4792
4809
|
for (let i = 0; i <= t; i++) {
|
4793
|
-
const
|
4794
|
-
s.push(
|
4810
|
+
const r = n + e * (i / t), h = this.getPointAtAngle(r);
|
4811
|
+
s.push(h);
|
4795
4812
|
}
|
4796
4813
|
return s;
|
4797
4814
|
}
|
@@ -4799,7 +4816,7 @@ class xt extends zt {
|
|
4799
4816
|
* @inheritdoc
|
4800
4817
|
*/
|
4801
4818
|
transform(t) {
|
4802
|
-
const s =
|
4819
|
+
const s = Pt.copy(this.refVec).applyAxisAngle(this.normal, this.startAngle).multiplyScalar(this.radius), e = Pt.copy(this.refVec).applyAxisAngle(this.normal, this.endAngle).multiplyScalar(this.radius);
|
4803
4820
|
return this.center.applyMatrix3d(t), s.applyMatrix3d(t), e.applyMatrix3d(t), this.normal.applyMatrix3d(t).normalize(), this.refVec.applyMatrix3d(t).normalize(), this.startAngle = this.getAngle(s), this.endAngle = this.getAngle(e), this._boundingBoxNeedsUpdate = !0, this;
|
4804
4821
|
}
|
4805
4822
|
/**
|
@@ -4812,7 +4829,7 @@ class xt extends zt {
|
|
4812
4829
|
* @inheritdoc
|
4813
4830
|
*/
|
4814
4831
|
clone() {
|
4815
|
-
return new
|
4832
|
+
return new yt(
|
4816
4833
|
this.center.clone(),
|
4817
4834
|
this.radius,
|
4818
4835
|
this.startAngle,
|
@@ -4828,7 +4845,7 @@ class xt extends zt {
|
|
4828
4845
|
*/
|
4829
4846
|
getAngle(t) {
|
4830
4847
|
return t.sub(this.center), Math.atan2(
|
4831
|
-
t.dot(
|
4848
|
+
t.dot(Pt.crossVectors(this.refVec, this.normal)),
|
4832
4849
|
t.dot(this.refVec)
|
4833
4850
|
);
|
4834
4851
|
}
|
@@ -4841,11 +4858,11 @@ class xt extends zt {
|
|
4841
4858
|
x: s.y * e.z - s.z * e.y,
|
4842
4859
|
y: s.z * e.x - s.x * e.z,
|
4843
4860
|
z: s.x * e.y - s.y * e.x
|
4844
|
-
}, i = this.center,
|
4845
|
-
return new
|
4846
|
-
i.x +
|
4847
|
-
i.y +
|
4848
|
-
i.z +
|
4861
|
+
}, i = this.center, r = this.radius;
|
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))
|
4849
4866
|
);
|
4850
4867
|
}
|
4851
4868
|
/**
|
@@ -4853,10 +4870,10 @@ class xt extends zt {
|
|
4853
4870
|
*/
|
4854
4871
|
get plane() {
|
4855
4872
|
const t = new y(this.center).distanceTo(jt);
|
4856
|
-
return new
|
4873
|
+
return new zt(this.normal, t);
|
4857
4874
|
}
|
4858
4875
|
}
|
4859
|
-
const
|
4876
|
+
const Pt = /* @__PURE__ */ new y();
|
4860
4877
|
class Zt extends st {
|
4861
4878
|
/**
|
4862
4879
|
* Construct an instance of the ellipse arc.
|
@@ -4869,8 +4886,8 @@ class Zt extends st {
|
|
4869
4886
|
* @param rotation The rotation angle of the ellipse in radians, counterclockwise from the positive X
|
4870
4887
|
* axis (optional). Default is 0.
|
4871
4888
|
*/
|
4872
|
-
constructor(t, s, e, n = 0, i =
|
4873
|
-
super(), this.center = t, this.majorAxisRadius = s, this.minorAxisRadius = e, (i - n) %
|
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;
|
4874
4891
|
}
|
4875
4892
|
/**
|
4876
4893
|
* Center of the ellipse in 3d space
|
@@ -4879,7 +4896,7 @@ class Zt extends st {
|
|
4879
4896
|
return this._center;
|
4880
4897
|
}
|
4881
4898
|
set center(t) {
|
4882
|
-
this._center = new
|
4899
|
+
this._center = new S(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
|
4883
4900
|
}
|
4884
4901
|
/**
|
4885
4902
|
* Major axis radius of the ellipse
|
@@ -4908,7 +4925,7 @@ class Zt extends st {
|
|
4908
4925
|
return this._startAngle;
|
4909
4926
|
}
|
4910
4927
|
set startAngle(t) {
|
4911
|
-
this._startAngle =
|
4928
|
+
this._startAngle = C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4912
4929
|
}
|
4913
4930
|
/**
|
4914
4931
|
* End angle of the ellipse arc in radians in the range -pi to pi.
|
@@ -4917,7 +4934,7 @@ class Zt extends st {
|
|
4917
4934
|
return this._endAngle;
|
4918
4935
|
}
|
4919
4936
|
set endAngle(t) {
|
4920
|
-
this._endAngle = this.startAngle == 0 && t ==
|
4937
|
+
this._endAngle = this.startAngle == 0 && t == I ? t : C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
4921
4938
|
}
|
4922
4939
|
/**
|
4923
4940
|
* The flag Whether the ellipse arc is drawn clockwise. Default is false.
|
@@ -4942,7 +4959,7 @@ class Zt extends st {
|
|
4942
4959
|
* Return angle between endAngle and startAngle in range 0 to 2*PI
|
4943
4960
|
*/
|
4944
4961
|
get deltaAngle() {
|
4945
|
-
return
|
4962
|
+
return C.normalizeAngle(this.endAngle - this.startAngle);
|
4946
4963
|
}
|
4947
4964
|
/**
|
4948
4965
|
* Return true if the arc is a large arc whose delta angle value is greater than PI.
|
@@ -4957,9 +4974,9 @@ class Zt extends st {
|
|
4957
4974
|
*/
|
4958
4975
|
calculateBoundingBox() {
|
4959
4976
|
let s = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
|
4960
|
-
for (let
|
4961
|
-
const
|
4962
|
-
s = Math.min(s,
|
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);
|
4963
4980
|
}
|
4964
4981
|
return new V({ x: s, y: e }, { x: n, y: i });
|
4965
4982
|
}
|
@@ -4982,12 +4999,12 @@ class Zt extends st {
|
|
4982
4999
|
for (; e > s; ) e -= s;
|
4983
5000
|
e < Number.EPSILON && (n ? e = 0 : e = s), this.clockwise === !0 && !n && (e === s ? e = -s : e = e - s);
|
4984
5001
|
const i = this.startAngle + t * e;
|
4985
|
-
let
|
5002
|
+
let r = this.center.x + this.majorAxisRadius * Math.cos(i), h = this.center.y + this.minorAxisRadius * Math.sin(i);
|
4986
5003
|
if (this.rotation !== 0) {
|
4987
|
-
const a = Math.cos(this.rotation), o = Math.sin(this.rotation), c =
|
4988
|
-
|
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;
|
4989
5006
|
}
|
4990
|
-
return new
|
5007
|
+
return new b(r, h);
|
4991
5008
|
}
|
4992
5009
|
/**
|
4993
5010
|
* @inheritdoc
|
@@ -5016,7 +5033,7 @@ class Zt extends st {
|
|
5016
5033
|
);
|
5017
5034
|
}
|
5018
5035
|
}
|
5019
|
-
class Gt extends
|
5036
|
+
class Gt extends Mt {
|
5020
5037
|
/**
|
5021
5038
|
* Construct an instance of the ellipse arc.
|
5022
5039
|
* @param center Center point of the ellipse.
|
@@ -5027,10 +5044,10 @@ class Gt extends zt {
|
|
5027
5044
|
* @param startAngle Start angle of the ellipse arc in radians.
|
5028
5045
|
* @param endAngle End angle of the ellipse arc in radians.
|
5029
5046
|
*/
|
5030
|
-
constructor(t, s, e, n, i,
|
5047
|
+
constructor(t, s, e, n, i, r = 0, h = I) {
|
5031
5048
|
super(), this.center = t, this.normal = s, this.majorAxis = e, this.majorAxisRadius = n, this.minorAxisRadius = i;
|
5032
|
-
const a = Math.abs(
|
5033
|
-
Math.abs(a -
|
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);
|
5034
5051
|
}
|
5035
5052
|
/**
|
5036
5053
|
* Center of the ellipse in 3d space
|
@@ -5039,7 +5056,7 @@ class Gt extends zt {
|
|
5039
5056
|
return this._center;
|
5040
5057
|
}
|
5041
5058
|
set center(t) {
|
5042
|
-
this._center = new
|
5059
|
+
this._center = new S(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
|
5043
5060
|
}
|
5044
5061
|
/**
|
5045
5062
|
* Major axis radius of the ellipse
|
@@ -5068,7 +5085,7 @@ class Gt extends zt {
|
|
5068
5085
|
return this._startAngle;
|
5069
5086
|
}
|
5070
5087
|
set startAngle(t) {
|
5071
|
-
this._startAngle =
|
5088
|
+
this._startAngle = C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
5072
5089
|
}
|
5073
5090
|
/**
|
5074
5091
|
* End angle of the ellipse arc in radians in the range -pi to pi.
|
@@ -5077,14 +5094,14 @@ class Gt extends zt {
|
|
5077
5094
|
return this._endAngle;
|
5078
5095
|
}
|
5079
5096
|
set endAngle(t) {
|
5080
|
-
this._endAngle = this.startAngle == 0 && t ==
|
5097
|
+
this._endAngle = this.startAngle == 0 && t == I ? t : C.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
|
5081
5098
|
}
|
5082
5099
|
/**
|
5083
5100
|
* Return angle between endAngle and startAngle in range 0 to 2*PI
|
5084
5101
|
*/
|
5085
5102
|
get deltaAngle() {
|
5086
5103
|
const t = this.endAngle - this.startAngle;
|
5087
|
-
return Math.abs(t -
|
5104
|
+
return Math.abs(t - I) < 1e-10 ? I : C.normalizeAngle(t);
|
5088
5105
|
}
|
5089
5106
|
/**
|
5090
5107
|
* Return true if the arc is a large arc whose delta angle value is greater than PI.
|
@@ -5144,8 +5161,8 @@ class Gt extends zt {
|
|
5144
5161
|
const s = this.deltaAngle / 1e3;
|
5145
5162
|
let e = 0, n = this.getPointAtAngle(this.startAngle);
|
5146
5163
|
for (let i = 1; i <= 1e3; i++) {
|
5147
|
-
const
|
5148
|
-
e += Math.sqrt(a * a + o * o + c * c), n =
|
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;
|
5149
5166
|
}
|
5150
5167
|
return e;
|
5151
5168
|
}
|
@@ -5158,25 +5175,25 @@ class Gt extends zt {
|
|
5158
5175
|
if (this.majorAxis.equals(y.X_AXIS) || this.majorAxis.equals(y.Y_AXIS) || this.majorAxis.isParallelTo(y.X_AXIS) || this.majorAxis.isParallelTo(y.Y_AXIS)) {
|
5159
5176
|
const t = [this.startAngle, this.endAngle];
|
5160
5177
|
for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
|
5161
|
-
|
5162
|
-
let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0,
|
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;
|
5163
5180
|
for (const a of t) {
|
5164
5181
|
const o = this.getPointAtAngle(a);
|
5165
|
-
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 >
|
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);
|
5166
5183
|
}
|
5167
|
-
return new
|
5184
|
+
return new Y(
|
5168
5185
|
{ x: s, y: e, z: n },
|
5169
|
-
{ x: i, y:
|
5186
|
+
{ x: i, y: r, z: h }
|
5170
5187
|
);
|
5171
5188
|
} else {
|
5172
|
-
let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0,
|
5189
|
+
let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, h = -1 / 0;
|
5173
5190
|
for (let a = 0; a <= 100; a++) {
|
5174
5191
|
const o = this.startAngle + this.deltaAngle * (a / 100), c = this.getPointAtAngle(o);
|
5175
|
-
s = Math.min(s, c.x), e = Math.min(e, c.y), n = Math.min(n, c.z), i = Math.max(i, c.x),
|
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);
|
5176
5193
|
}
|
5177
|
-
return new
|
5194
|
+
return new Y(
|
5178
5195
|
{ x: s, y: e, z: n },
|
5179
|
-
{ x: i, y:
|
5196
|
+
{ x: i, y: r, z: h }
|
5180
5197
|
);
|
5181
5198
|
}
|
5182
5199
|
}
|
@@ -5189,10 +5206,10 @@ class Gt extends zt {
|
|
5189
5206
|
getPoints(t = 100) {
|
5190
5207
|
const s = [];
|
5191
5208
|
let e = this.deltaAngle, n = this.startAngle;
|
5192
|
-
this.closed && (e =
|
5209
|
+
this.closed && (e = I, n = 0);
|
5193
5210
|
for (let i = 0; i <= t; i++) {
|
5194
|
-
const
|
5195
|
-
s.push(
|
5211
|
+
const r = n + e * (i / t), h = this.getPointAtAngle(r);
|
5212
|
+
s.push(h);
|
5196
5213
|
}
|
5197
5214
|
return s;
|
5198
5215
|
}
|
@@ -5203,7 +5220,7 @@ class Gt extends zt {
|
|
5203
5220
|
*/
|
5204
5221
|
getPointAtAngle(t) {
|
5205
5222
|
const s = Math.cos(t), e = Math.sin(t), n = this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e), i = this.majorAxis.clone().multiplyScalar(s * this.majorAxisRadius).add(n);
|
5206
|
-
return new
|
5223
|
+
return new S(
|
5207
5224
|
this.center.x + i.x,
|
5208
5225
|
this.center.y + i.y,
|
5209
5226
|
this.center.z + i.z
|
@@ -5215,8 +5232,8 @@ class Gt extends zt {
|
|
5215
5232
|
* @returns - True if the point is inside the ellipse, false otherwise.
|
5216
5233
|
*/
|
5217
5234
|
contains(t) {
|
5218
|
-
const s = new y(t).sub(this.center), e = s.dot(this.majorAxis), n = s.dot(this.minorAxis), i = e / this.majorAxisRadius,
|
5219
|
-
return i * i +
|
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;
|
5220
5237
|
}
|
5221
5238
|
/**
|
5222
5239
|
* @inheritdoc
|
@@ -5249,10 +5266,10 @@ class Gt extends zt {
|
|
5249
5266
|
*/
|
5250
5267
|
get plane() {
|
5251
5268
|
const t = new y(this.center).distanceTo(jt);
|
5252
|
-
return new
|
5269
|
+
return new zt(this.normal, t);
|
5253
5270
|
}
|
5254
5271
|
}
|
5255
|
-
class
|
5272
|
+
class Bs extends st {
|
5256
5273
|
constructor(t = null, s = !1) {
|
5257
5274
|
super(), this._vertices = t || new Array(), this._closed = s;
|
5258
5275
|
}
|
@@ -5274,7 +5291,7 @@ class Is extends st {
|
|
5274
5291
|
get startPoint() {
|
5275
5292
|
if (this.numberOfVertices > 0) {
|
5276
5293
|
const t = this._vertices[0];
|
5277
|
-
return new
|
5294
|
+
return new b(t.x, t.y);
|
5278
5295
|
}
|
5279
5296
|
throw new Error("Start point does not exist in an empty polyline.");
|
5280
5297
|
}
|
@@ -5286,10 +5303,10 @@ class Is extends st {
|
|
5286
5303
|
if (t > 0)
|
5287
5304
|
if (this.closed) {
|
5288
5305
|
const s = this._vertices[0];
|
5289
|
-
return new
|
5306
|
+
return new b(s.x, s.y);
|
5290
5307
|
} else {
|
5291
5308
|
const s = this._vertices[t - 1];
|
5292
|
-
return new
|
5309
|
+
return new b(s.x, s.y);
|
5293
5310
|
}
|
5294
5311
|
throw new Error("End point does not exist in an empty polyline.");
|
5295
5312
|
}
|
@@ -5304,10 +5321,10 @@ class Is extends st {
|
|
5304
5321
|
let i = null;
|
5305
5322
|
if (e < s - 1 ? i = this._vertices[e + 1] : e == s - 1 && this.closed && (i = this._vertices[0]), i)
|
5306
5323
|
if (n.bulge) {
|
5307
|
-
const
|
5308
|
-
t +=
|
5324
|
+
const r = new gt(n, i, n.bulge);
|
5325
|
+
t += r.length;
|
5309
5326
|
} else
|
5310
|
-
t += new
|
5327
|
+
t += new b(n.x, n.y).distanceTo(i);
|
5311
5328
|
}
|
5312
5329
|
return t;
|
5313
5330
|
}
|
@@ -5338,7 +5355,7 @@ class Is extends st {
|
|
5338
5355
|
*/
|
5339
5356
|
getPointAt(t) {
|
5340
5357
|
const s = this._vertices[t];
|
5341
|
-
return new
|
5358
|
+
return new b(s.x, s.y);
|
5342
5359
|
}
|
5343
5360
|
/**
|
5344
5361
|
* @inheritdoc
|
@@ -5362,7 +5379,7 @@ class Is extends st {
|
|
5362
5379
|
getPoints3d(t, s) {
|
5363
5380
|
const e = [];
|
5364
5381
|
return this.getPoints(t).forEach(
|
5365
|
-
(i) => e.push(new
|
5382
|
+
(i) => e.push(new S().set(i.x, i.y, s))
|
5366
5383
|
), e;
|
5367
5384
|
}
|
5368
5385
|
/**
|
@@ -5375,27 +5392,27 @@ class Is extends st {
|
|
5375
5392
|
for (let n = 0; n < e; ++n) {
|
5376
5393
|
const i = this._vertices[n];
|
5377
5394
|
if (i.bulge) {
|
5378
|
-
let
|
5379
|
-
if (n < e - 1 ?
|
5380
|
-
const a = new
|
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;
|
5381
5398
|
for (let c = 0; c < o; ++c) {
|
5382
5399
|
const l = a[c];
|
5383
|
-
s.push(new
|
5400
|
+
s.push(new b(l.x, l.y));
|
5384
5401
|
}
|
5385
5402
|
}
|
5386
5403
|
} else
|
5387
|
-
s.push(new
|
5404
|
+
s.push(new b(i.x, i.y)), n == e - 1 && this.closed && s.push(s[0]);
|
5388
5405
|
}
|
5389
5406
|
return s;
|
5390
5407
|
}
|
5391
5408
|
}
|
5392
|
-
class
|
5409
|
+
class Kt extends st {
|
5393
5410
|
/**
|
5394
5411
|
* This constructor initializes the line object to use start as the start point, and end
|
5395
5412
|
* as the endpoint. Both points must be in WCS coordinates.
|
5396
5413
|
*/
|
5397
5414
|
constructor(t, s) {
|
5398
|
-
super(), this._start = new
|
5415
|
+
super(), this._start = new b(t), this._end = new b(s);
|
5399
5416
|
}
|
5400
5417
|
/**
|
5401
5418
|
* The line's startpoint in WCS coordinates
|
@@ -5434,10 +5451,10 @@ class Qt extends st {
|
|
5434
5451
|
* @inheritdoc
|
5435
5452
|
*/
|
5436
5453
|
calculateBoundingBox() {
|
5437
|
-
const t = new
|
5454
|
+
const t = new b(
|
5438
5455
|
Math.min(this._start.x, this._end.x),
|
5439
5456
|
Math.min(this._start.y, this._end.y)
|
5440
|
-
), s = new
|
5457
|
+
), s = new b(
|
5441
5458
|
Math.max(this._start.x, this._end.x),
|
5442
5459
|
Math.max(this._start.y, this._end.y)
|
5443
5460
|
);
|
@@ -5465,10 +5482,10 @@ class Qt extends st {
|
|
5465
5482
|
* @inheritdoc
|
5466
5483
|
*/
|
5467
5484
|
clone() {
|
5468
|
-
return new
|
5485
|
+
return new Kt(this._start.clone(), this._end.clone());
|
5469
5486
|
}
|
5470
5487
|
}
|
5471
|
-
class
|
5488
|
+
class Is extends st {
|
5472
5489
|
/**
|
5473
5490
|
* Create one loop by connected curves
|
5474
5491
|
* @param curves Input one array of connected curves
|
@@ -5498,7 +5515,7 @@ class Es extends st {
|
|
5498
5515
|
get startPoint() {
|
5499
5516
|
if (this._curves.length > 0) {
|
5500
5517
|
const t = this._curves[0].startPoint;
|
5501
|
-
return new
|
5518
|
+
return new b(t.x, t.y);
|
5502
5519
|
}
|
5503
5520
|
throw new Error("Start point does not exist in an empty loop.");
|
5504
5521
|
}
|
@@ -5545,12 +5562,12 @@ class Es extends st {
|
|
5545
5562
|
const s = [];
|
5546
5563
|
return this.curves.forEach((e) => {
|
5547
5564
|
e.getPoints(t).forEach((n) => {
|
5548
|
-
s.push(new
|
5565
|
+
s.push(new b(n.x, n.y));
|
5549
5566
|
});
|
5550
5567
|
}), s;
|
5551
5568
|
}
|
5552
5569
|
}
|
5553
|
-
class
|
5570
|
+
class D {
|
5554
5571
|
constructor(t, s, e, n) {
|
5555
5572
|
this._degree = t, this._knots = [...s], this._controlPoints = e.map((i) => [...i]), this._weights = n ? [...n] : new Array(e.length).fill(1);
|
5556
5573
|
}
|
@@ -5570,7 +5587,7 @@ class tt {
|
|
5570
5587
|
* Calculate a point on the curve at parameter u
|
5571
5588
|
*/
|
5572
5589
|
point(t) {
|
5573
|
-
return
|
5590
|
+
return xt(
|
5574
5591
|
t,
|
5575
5592
|
this._degree,
|
5576
5593
|
this._knots,
|
@@ -5593,7 +5610,7 @@ class tt {
|
|
5593
5610
|
* Create a NURBS curve from control points and knots
|
5594
5611
|
*/
|
5595
5612
|
static byKnotsControlPointsWeights(t, s, e, n) {
|
5596
|
-
return new
|
5613
|
+
return new D(t, s, e, n);
|
5597
5614
|
}
|
5598
5615
|
/**
|
5599
5616
|
* Create a NURBS curve from fit points using interpolation
|
@@ -5612,11 +5629,11 @@ class tt {
|
|
5612
5629
|
n = ys(s, t.length);
|
5613
5630
|
break;
|
5614
5631
|
}
|
5615
|
-
const i = zs(t),
|
5616
|
-
return new
|
5632
|
+
const i = zs(t), r = new Array(i.length).fill(1);
|
5633
|
+
return new D(s, n, i, r);
|
5617
5634
|
}
|
5618
5635
|
}
|
5619
|
-
class
|
5636
|
+
class Es extends Mt {
|
5620
5637
|
constructor(t, s, e) {
|
5621
5638
|
super();
|
5622
5639
|
const n = +(t !== void 0) + +(s !== void 0) + +(e !== void 0);
|
@@ -5626,24 +5643,68 @@ class Cs extends zt {
|
|
5626
5643
|
if (this._closed = !1, n == 2 && !Array.isArray(s)) {
|
5627
5644
|
if (this._fitPoints = t, this._knotParameterization = s, this._fitPoints.length < 4)
|
5628
5645
|
throw T.ILLEGAL_PARAMETERS;
|
5629
|
-
const
|
5630
|
-
this._nurbsCurve =
|
5631
|
-
|
5646
|
+
const r = this.toNurbsPoints(this._fitPoints);
|
5647
|
+
this._nurbsCurve = D.byPoints(
|
5648
|
+
r,
|
5632
5649
|
i,
|
5633
5650
|
this._knotParameterization
|
5634
|
-
), this._controlPoints = this.toGePoints(this._nurbsCurve.controlPoints());
|
5651
|
+
), this._controlPoints = this.toGePoints(this._nurbsCurve.controlPoints()), this._originalControlPoints = [...this._controlPoints], this._originalKnots = [...this._nurbsCurve.knots()], this._originalWeights = [...this._nurbsCurve.weights()];
|
5635
5652
|
} else {
|
5636
5653
|
if (this._controlPoints = t, this._controlPoints.length < 4)
|
5637
5654
|
throw T.ILLEGAL_PARAMETERS;
|
5638
|
-
const
|
5639
|
-
this._nurbsCurve =
|
5655
|
+
const r = this.toNurbsPoints(this._controlPoints);
|
5656
|
+
this._nurbsCurve = D.byKnotsControlPointsWeights(
|
5640
5657
|
i,
|
5641
5658
|
s,
|
5642
|
-
|
5659
|
+
r,
|
5643
5660
|
e
|
5644
|
-
);
|
5661
|
+
), this._originalControlPoints = [...this._controlPoints], this._originalKnots = [...this._nurbsCurve.knots()], this._originalWeights = e ? [...e] : new Array(this._controlPoints.length).fill(1);
|
5645
5662
|
}
|
5646
5663
|
}
|
5664
|
+
/**
|
5665
|
+
* Set the closed property and rebuild the curve if necessary
|
5666
|
+
*/
|
5667
|
+
setClosed(t) {
|
5668
|
+
this._closed !== t && (this._closed = t, this._boundingBoxNeedsUpdate = !0, t ? this.makeClosed() : this.makeOpen());
|
5669
|
+
}
|
5670
|
+
/**
|
5671
|
+
* Make the spline closed by adding control points and adjusting knots
|
5672
|
+
*/
|
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);
|
5678
|
+
this._nurbsCurve = D.byKnotsControlPointsWeights(
|
5679
|
+
t,
|
5680
|
+
h,
|
5681
|
+
i,
|
5682
|
+
r
|
5683
|
+
), this._controlPoints = this.toGePoints(i);
|
5684
|
+
}
|
5685
|
+
/**
|
5686
|
+
* Make the spline open by restoring the original curve
|
5687
|
+
*/
|
5688
|
+
makeOpen() {
|
5689
|
+
if (!this._originalControlPoints || !this._originalKnots || !this._originalWeights)
|
5690
|
+
throw new Error("Original curve data not available");
|
5691
|
+
const t = this._nurbsCurve.degree(), s = this.toNurbsPoints(this._originalControlPoints);
|
5692
|
+
this._nurbsCurve = D.byKnotsControlPointsWeights(
|
5693
|
+
t,
|
5694
|
+
this._originalKnots,
|
5695
|
+
s,
|
5696
|
+
this._originalWeights
|
5697
|
+
), this._controlPoints = [...this._originalControlPoints];
|
5698
|
+
}
|
5699
|
+
/**
|
5700
|
+
* Create knot vector for closed curve
|
5701
|
+
*/
|
5702
|
+
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;
|
5707
|
+
}
|
5647
5708
|
/**
|
5648
5709
|
* Degree of the spline to be created.
|
5649
5710
|
*/
|
@@ -5658,14 +5719,16 @@ class Cs extends zt {
|
|
5658
5719
|
*/
|
5659
5720
|
get startPoint() {
|
5660
5721
|
const t = this._nurbsCurve.knots(), s = this._nurbsCurve.degree(), e = t[s], n = this._nurbsCurve.point(e);
|
5661
|
-
return new
|
5722
|
+
return new S(n[0], n[1], n[2]);
|
5662
5723
|
}
|
5663
5724
|
/**
|
5664
5725
|
* The end point of this spline
|
5665
5726
|
*/
|
5666
5727
|
get endPoint() {
|
5728
|
+
if (this._closed)
|
5729
|
+
return this.startPoint;
|
5667
5730
|
const t = this._nurbsCurve.knots(), s = this._nurbsCurve.degree(), e = t[t.length - s - 1], n = this._nurbsCurve.point(e);
|
5668
|
-
return new
|
5731
|
+
return new S(n[0], n[1], n[2]);
|
5669
5732
|
}
|
5670
5733
|
/**
|
5671
5734
|
* @inheritdoc
|
@@ -5704,19 +5767,28 @@ class Cs extends zt {
|
|
5704
5767
|
* @returns Return an array of point
|
5705
5768
|
*/
|
5706
5769
|
getPoints(t = 100) {
|
5707
|
-
const s = this._nurbsCurve, e = [], n = s.knots(), i = this._nurbsCurve.degree(),
|
5708
|
-
|
5709
|
-
|
5710
|
-
|
5711
|
-
|
5712
|
-
|
5770
|
+
const s = this._nurbsCurve, e = [], n = s.knots(), i = this._nurbsCurve.degree(), r = n[i], h = n[n.length - i - 1];
|
5771
|
+
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]));
|
5778
|
+
}
|
5779
|
+
} else {
|
5780
|
+
const a = (h - r) / (t - 1);
|
5781
|
+
for (let o = 0; o < t; o++) {
|
5782
|
+
const c = o === t - 1 ? h : r + o * a, l = s.point(c);
|
5783
|
+
e.push(new S(l[0], l[1], l[2]));
|
5784
|
+
}
|
5713
5785
|
}
|
5714
5786
|
return e;
|
5715
5787
|
}
|
5716
5788
|
getCurvePoints(t, s) {
|
5717
|
-
const e = [], n = t.knots(), i = n[3],
|
5789
|
+
const e = [], n = t.knots(), i = n[3], h = (n[n.length - 4] - i) / (s - 1);
|
5718
5790
|
for (let a = 0; a < s; a++) {
|
5719
|
-
const o = i + a *
|
5791
|
+
const o = i + a * h;
|
5720
5792
|
e.push(t.point(o));
|
5721
5793
|
}
|
5722
5794
|
return e;
|
@@ -5726,13 +5798,13 @@ class Cs extends zt {
|
|
5726
5798
|
*/
|
5727
5799
|
calculateBoundingBox() {
|
5728
5800
|
const t = this.getPoints(100);
|
5729
|
-
return new
|
5801
|
+
return new Y().setFromPoints(t);
|
5730
5802
|
}
|
5731
5803
|
get closed() {
|
5732
5804
|
return this._closed;
|
5733
5805
|
}
|
5734
5806
|
set closed(t) {
|
5735
|
-
this.
|
5807
|
+
this.setClosed(t);
|
5736
5808
|
}
|
5737
5809
|
/**
|
5738
5810
|
* @inheritdoc
|
@@ -5764,31 +5836,31 @@ class Cs extends zt {
|
|
5764
5836
|
}
|
5765
5837
|
}
|
5766
5838
|
export {
|
5767
|
-
|
5839
|
+
Cs as AcGeArea2d,
|
5768
5840
|
V as AcGeBox2d,
|
5769
|
-
|
5770
|
-
|
5771
|
-
|
5841
|
+
Y as AcGeBox3d,
|
5842
|
+
gt as AcGeCircArc2d,
|
5843
|
+
yt as AcGeCircArc3d,
|
5772
5844
|
st as AcGeCurve2d,
|
5773
5845
|
Zt as AcGeEllipseArc2d,
|
5774
5846
|
Gt as AcGeEllipseArc3d,
|
5775
5847
|
Nt as AcGeEuler,
|
5776
5848
|
xs as AcGeGeometryUtil,
|
5777
|
-
|
5778
|
-
|
5779
|
-
|
5780
|
-
|
5781
|
-
|
5782
|
-
|
5783
|
-
|
5784
|
-
|
5785
|
-
|
5786
|
-
|
5787
|
-
|
5849
|
+
Kt as AcGeLine2d,
|
5850
|
+
_t as AcGeLine3d,
|
5851
|
+
Is as AcGeLoop2d,
|
5852
|
+
C as AcGeMathUtil,
|
5853
|
+
v as AcGeMatrix2d,
|
5854
|
+
tt as AcGeMatrix3d,
|
5855
|
+
zt as AcGePlane,
|
5856
|
+
b as AcGePoint2d,
|
5857
|
+
S as AcGePoint3d,
|
5858
|
+
Bs as AcGePolyline2d,
|
5859
|
+
pt as AcGeQuaternion,
|
5788
5860
|
Yt as AcGeShape2d,
|
5789
|
-
|
5790
|
-
|
5791
|
-
|
5861
|
+
Es as AcGeSpline3d,
|
5862
|
+
ds as AcGeTol,
|
5863
|
+
P as AcGeVector2d,
|
5792
5864
|
y as AcGeVector3d,
|
5793
5865
|
Ft as DEFAULT_TOL,
|
5794
5866
|
Rt as DEG2RAD,
|
@@ -5796,32 +5868,32 @@ export {
|
|
5796
5868
|
Ss as ORIGIN_POINT_2D,
|
5797
5869
|
jt as ORIGIN_POINT_3D,
|
5798
5870
|
Tt as RAD2DEG,
|
5799
|
-
|
5800
|
-
|
5871
|
+
I as TAU,
|
5872
|
+
bt as basisFunction,
|
5801
5873
|
ps as calculateCurveLength,
|
5802
5874
|
os as ceilPowerOfTwo,
|
5803
5875
|
j as clamp,
|
5804
|
-
|
5876
|
+
Ht as damp,
|
5805
5877
|
is as degToRad,
|
5806
5878
|
Vt as euclideanModulo,
|
5807
|
-
|
5879
|
+
xt as evaluateNurbsPoint,
|
5808
5880
|
as as floorPowerOfTwo,
|
5809
5881
|
gs as generateChordKnots,
|
5810
5882
|
_s as generateSqrtChordKnots,
|
5811
|
-
|
5883
|
+
Qt as generateUUID,
|
5812
5884
|
ys as generateUniformKnots,
|
5813
5885
|
qt as intPartLength,
|
5814
5886
|
zs as interpolateControlPoints,
|
5815
|
-
|
5887
|
+
Wt as inverseLerp,
|
5816
5888
|
cs as isBetween,
|
5817
5889
|
ls as isBetweenAngle,
|
5818
5890
|
Xt as isPointInPolygon,
|
5819
|
-
|
5891
|
+
ms as isPolygonIntersect,
|
5820
5892
|
hs as isPowerOfTwo,
|
5821
5893
|
Ut as lerp,
|
5822
|
-
|
5823
|
-
|
5824
|
-
|
5894
|
+
Ot as mapLinear,
|
5895
|
+
mt as normalizeAngle,
|
5896
|
+
$t as pingpong,
|
5825
5897
|
rs as radToDeg,
|
5826
5898
|
ss as randFloat,
|
5827
5899
|
es as randFloatSpread,
|