build-dxf 0.0.48 → 0.0.50

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.
Files changed (31) hide show
  1. package/README.md +50 -1
  2. package/package.json +1 -1
  3. package/src/build.js +1652 -1223
  4. package/src/index.css +1 -1
  5. package/src/index3.js +975 -927
  6. package/src/utils/CommandManager/CommandFlow.d.ts +2 -0
  7. package/src/utils/DxfSystem/components/DoorsAnalysis.d.ts +1 -1
  8. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +1 -1
  9. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +7 -0
  10. package/src/utils/DxfSystem/type.d.ts +9 -1
  11. package/src/utils/DxfSystem/utils/DoubleWallHelper.d.ts +0 -1
  12. package/src/utils/DxfSystem/utils/LineGroupType.d.ts +81 -0
  13. package/src/utils/DxfSystem/utils/findClosedPolygons01.d.ts +4 -17
  14. package/src/utils/DxfSystem/utils/findDiscretePointLine.d.ts +1 -1
  15. package/src/utils/DxfSystem/utils/findLargestCircle.d.ts +14 -0
  16. package/src/utils/DxfSystem/utils/index.d.ts +11 -0
  17. package/src/utils/DxfSystem/utils/mergeSmallestCircle.d.ts +14 -0
  18. package/src/utils/DxfSystem/utils/recomputedWindow.d.ts +5 -0
  19. package/src/utils/DxfSystem/utils/smallestCircle.d.ts +6 -0
  20. package/src/utils/LineIndexGenerator.d.ts +3 -1
  21. package/src/utils/LineSegment.d.ts +16 -1
  22. package/src/utils/Map.d.ts +3 -0
  23. package/src/utils/Point.d.ts +1 -0
  24. package/src/utils/PointVirtualGrid/index.d.ts +5 -4
  25. package/src/utils/Polygon.d.ts +26 -0
  26. package/src/utils/UndirectedGraph.d.ts +39 -9
  27. package/src/utils/index.d.ts +17 -0
  28. package/src/utils/DxfSystem/utils/BoundExtOld.d.ts +0 -16
  29. package/src/utils/DxfSystem/utils/TrajectoryHelper.d.ts +0 -29
  30. package/src/utils/DxfSystem/utils/findClosedPolygons.d.ts +0 -22
  31. package/src/utils/Path.d.ts +0 -6
package/src/build.js CHANGED
@@ -1,16 +1,16 @@
1
- import * as P from "three";
2
- import { EventDispatcher as $t, Color as Kt, Matrix4 as Ct, Vector3 as it, Quaternion as Zt, BufferAttribute as _, REVISION as Qt, CompressedTexture as ct, Source as te, NoColorSpace as ee, MathUtils as dt, RGBAFormat as ne, ImageUtils as se, DoubleSide as ie, PropertyBinding as rt, InterpolateDiscrete as re, Scene as yt, SRGBColorSpace as oe, NearestFilter as ae, NearestMipmapNearestFilter as ce, NearestMipmapLinearFilter as le, LinearFilter as he, LinearMipmapNearestFilter as ue, LinearMipmapLinearFilter as de, ClampToEdgeWrapping as fe, RepeatWrapping as pe, MirroredRepeatWrapping as ge, InterpolateLinear as ye } from "three";
3
- import xt from "clipper-lib";
1
+ import * as v from "three";
2
+ import { EventDispatcher as oe, Color as ae, Matrix4 as Gt, Vector3 as it, Quaternion as ce, BufferAttribute as Y, REVISION as le, CompressedTexture as ht, Source as he, NoColorSpace as ue, MathUtils as pt, RGBAFormat as de, ImageUtils as fe, DoubleSide as pe, PropertyBinding as rt, InterpolateDiscrete as ge, Scene as Dt, SRGBColorSpace as ye, NearestFilter as xe, NearestMipmapNearestFilter as me, NearestMipmapLinearFilter as we, LinearFilter as Me, LinearMipmapNearestFilter as De, LinearMipmapLinearFilter as Le, ClampToEdgeWrapping as Se, RepeatWrapping as Ee, MirroredRepeatWrapping as Ae, InterpolateLinear as Te } from "three";
3
+ import Lt from "clipper-lib";
4
4
  import st from "dxf-writer";
5
- import { OBJExporter as xe } from "three/examples/jsm/exporters/OBJExporter.js";
6
- function tt() {
5
+ import { OBJExporter as be } from "three/examples/jsm/exporters/OBJExporter.js";
6
+ function $() {
7
7
  return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(u) {
8
8
  var t = Math.random() * 16 | 0, e = u == "x" ? t : t & 3 | 8;
9
9
  return e.toString(16);
10
10
  });
11
11
  }
12
- class Nt extends $t {
13
- uuid = tt();
12
+ class Ut extends oe {
13
+ uuid = $();
14
14
  addEventListener(t, e, n) {
15
15
  const { once: s = !1 } = n ?? {}, i = (o) => {
16
16
  e(o), s && r();
@@ -30,7 +30,7 @@ class Nt extends $t {
30
30
  e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
31
31
  }
32
32
  }
33
- class G extends Nt {
33
+ class z extends Ut {
34
34
  parent;
35
35
  destroyed = !1;
36
36
  constructor(...t) {
@@ -48,7 +48,7 @@ class G extends Nt {
48
48
  this.destroyed = !0;
49
49
  }
50
50
  }
51
- class me extends Nt {
51
+ class Pe extends Ut {
52
52
  static EventType = {
53
53
  ADD_COMPONENT: "addComponent"
54
54
  };
@@ -71,7 +71,7 @@ class me extends Nt {
71
71
  * @param component
72
72
  */
73
73
  removeComponent(t) {
74
- if (t instanceof G) {
74
+ if (t instanceof z) {
75
75
  const e = this.components.indexOf(t);
76
76
  e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
77
77
  type: "removeComponent",
@@ -116,17 +116,17 @@ class me extends Nt {
116
116
  return e || null;
117
117
  }
118
118
  }
119
- class I {
119
+ class R {
120
120
  minX = 0;
121
121
  maxX = 0;
122
122
  minY = 0;
123
123
  maxY = 0;
124
124
  get points() {
125
125
  return [
126
- new w(this.minX, this.minY),
127
- new w(this.maxX, this.minY),
128
- new w(this.maxX, this.maxY),
129
- new w(this.minX, this.maxY)
126
+ new D(this.minX, this.minY),
127
+ new D(this.maxX, this.minY),
128
+ new D(this.maxX, this.maxY),
129
+ new D(this.minX, this.maxY)
130
130
  ];
131
131
  }
132
132
  get width() {
@@ -136,7 +136,7 @@ class I {
136
136
  return this.maxY - this.minY;
137
137
  }
138
138
  get center() {
139
- return new w(
139
+ return new D(
140
140
  this.minX + (this.maxX - this.minX) * 0.5,
141
141
  this.minY + (this.maxY - this.minY) * 0.5
142
142
  );
@@ -202,9 +202,9 @@ class I {
202
202
  const o = this.points;
203
203
  for (let c = 0; c < 4; c++) {
204
204
  const l = o[c], h = o[(c + 1) % 4];
205
- for (let d = 0; d < 4; d++) {
206
- const f = e[d], p = e[(d + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), g = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), x = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), m = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
207
- if (y * g < 0 && x * m < 0 || y === 0 && Math.min(l.x, h.x) <= f.x && f.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= f.y && f.y <= Math.max(l.y, h.y) || g === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || x === 0 && Math.min(f.x, p.x) <= l.x && l.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= l.y && l.y <= Math.max(f.y, p.y) || m === 0 && Math.min(f.x, p.x) <= h.x && h.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= h.y && h.y <= Math.max(f.y, p.y))
205
+ for (let f = 0; f < 4; f++) {
206
+ const d = e[f], p = e[(f + 1) % 4], g = (h.x - l.x) * (d.y - l.y) - (h.y - l.y) * (d.x - l.x), y = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), x = (p.x - d.x) * (l.y - d.y) - (p.y - d.y) * (l.x - d.x), m = (p.x - d.x) * (h.y - d.y) - (p.y - d.y) * (h.x - d.x);
207
+ if (g * y < 0 && x * m < 0 || g === 0 && Math.min(l.x, h.x) <= d.x && d.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= d.y && d.y <= Math.max(l.y, h.y) || y === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || x === 0 && Math.min(d.x, p.x) <= l.x && l.x <= Math.max(d.x, p.x) && Math.min(d.y, p.y) <= l.y && l.y <= Math.max(d.y, p.y) || m === 0 && Math.min(d.x, p.x) <= h.x && h.x <= Math.max(d.x, p.x) && Math.min(d.y, p.y) <= h.y && h.y <= Math.max(d.y, p.y))
208
208
  return !0;
209
209
  }
210
210
  }
@@ -216,14 +216,14 @@ class I {
216
216
  const a = (c) => {
217
217
  let l = 0;
218
218
  for (let h = 0; h < 4; h++) {
219
- const d = e[h], f = e[(h + 1) % 4], p = (f.x - d.x) * (c.y - d.y) - (f.y - d.y) * (c.x - d.x);
219
+ const f = e[h], d = e[(h + 1) % 4], p = (d.x - f.x) * (c.y - f.y) - (d.y - f.y) * (c.x - f.x);
220
220
  if (p === 0) {
221
- const y = Math.abs(f.x - d.x) > 1e-10 ? f.x - d.x : f.y - d.y, g = y ? (c.x - d.x) / y : 0;
222
- if (g >= 0 && g <= 1) return !0;
221
+ const g = Math.abs(d.x - f.x) > 1e-10 ? d.x - f.x : d.y - f.y, y = g ? (c.x - f.x) / g : 0;
222
+ if (y >= 0 && y <= 1) return !0;
223
223
  } else {
224
- const y = p > 0 ? 1 : -1;
225
- if (l === 0) l = y;
226
- else if (l !== y) return !1;
224
+ const g = p > 0 ? 1 : -1;
225
+ if (l === 0) l = g;
226
+ else if (l !== g) return !1;
227
227
  }
228
228
  }
229
229
  return !0;
@@ -299,7 +299,7 @@ class I {
299
299
  * @returns
300
300
  */
301
301
  clone() {
302
- return new I(this.minX, this.maxX, this.minY, this.maxY);
302
+ return new R(this.minX, this.maxX, this.minY, this.maxY);
303
303
  }
304
304
  /**
305
305
  *
@@ -310,7 +310,7 @@ class I {
310
310
  const e = [], n = [];
311
311
  return t.forEach((s) => {
312
312
  e.push(s.x), n.push(s.y);
313
- }), new I(
313
+ }), new R(
314
314
  Math.min(...e),
315
315
  Math.max(...e),
316
316
  Math.min(...n),
@@ -328,7 +328,7 @@ class I {
328
328
  s?.points?.forEach((i) => {
329
329
  e.push(i.x), n.push(i.y);
330
330
  });
331
- }), new I(
331
+ }), new R(
332
332
  Math.min(...e),
333
333
  Math.max(...e),
334
334
  Math.min(...n),
@@ -336,7 +336,7 @@ class I {
336
336
  );
337
337
  }
338
338
  }
339
- class we extends Array {
339
+ class Ie extends Array {
340
340
  userDataList() {
341
341
  return this.map((t) => t.userData);
342
342
  }
@@ -344,7 +344,7 @@ class we extends Array {
344
344
  return this.map((t) => t.point);
345
345
  }
346
346
  }
347
- class Y {
347
+ class q {
348
348
  map = /* @__PURE__ */ new Map();
349
349
  gridSize;
350
350
  id;
@@ -365,7 +365,7 @@ class Y {
365
365
  const s = this.map.get(n), i = { point: t, userData: e };
366
366
  s.add(i);
367
367
  const r = { set: s, target: i, id: n };
368
- t.currentData.pointVirtualGrid = r, t.currentData[this.id] = r;
368
+ return t.currentData.pointVirtualGrid = r, t.currentData[this.id] = r, this;
369
369
  }
370
370
  /**
371
371
  * 批量加入
@@ -383,6 +383,7 @@ class Y {
383
383
  const { target: e, set: n, id: s } = t.currentData[this.id];
384
384
  n && (n.delete(e), delete t?.userData?.pointVirtualGridMap, delete t.currentData[this.id], n.size === 0 && this.map.delete(s));
385
385
  }
386
+ return this;
386
387
  }
387
388
  update(t) {
388
389
  const { target: e, set: n } = t.currentData[this.id];
@@ -416,7 +417,7 @@ class Y {
416
417
  */
417
418
  decodeGridId(t) {
418
419
  const [e, n] = t.split(".").map(Number);
419
- return new w(e, n);
420
+ return new D(e, n);
420
421
  }
421
422
  /**
422
423
  * 查询与矩形相交的点
@@ -441,13 +442,13 @@ class Y {
441
442
  * @returns 相交的节点数组
442
443
  */
443
444
  queryCircle(t, e) {
444
- const n = new I(t.x - e, t.x + e, t.y - e, t.y + e), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
445
+ const n = new R(t.x - e, t.x + e, t.y - e, t.y + e), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
445
446
  for (let c = s; c <= i; c++)
446
447
  for (let l = r; l <= o; l++) {
447
448
  const h = `${c}.${l}`;
448
449
  if (!this.map.has(h)) continue;
449
- this.map.get(h)?.forEach((f) => {
450
- t.distance(f.point) <= e && a.push(f);
450
+ this.map.get(h)?.forEach((d) => {
451
+ t.distance(d.point) <= e && a.push(d);
451
452
  });
452
453
  }
453
454
  return a;
@@ -474,7 +475,7 @@ class Y {
474
475
  * @param point
475
476
  */
476
477
  queryPoint(t, e = !1) {
477
- const n = new we();
478
+ const n = new Ie();
478
479
  let s;
479
480
  if (t.currentData[this.id])
480
481
  s = t.currentData[this.id]?.set;
@@ -515,7 +516,7 @@ class Y {
515
516
  if (t.size === 1) return [...t][0];
516
517
  }
517
518
  }
518
- function J(u) {
519
+ function V(u) {
519
520
  if (!u || typeof u != "object")
520
521
  return u;
521
522
  const t = Array.isArray(u) ? [] : {}, e = Object.keys(u);
@@ -526,17 +527,17 @@ function J(u) {
526
527
  continue;
527
528
  }
528
529
  if (Array.isArray(s)) {
529
- t[n] = s.map((i) => J(i));
530
+ t[n] = s.map((i) => V(i));
530
531
  continue;
531
532
  }
532
533
  if (Object.getPrototypeOf(s) === Object.prototype) {
533
- t[n] = J(s);
534
+ t[n] = V(s);
534
535
  continue;
535
536
  }
536
537
  }
537
538
  return t;
538
539
  }
539
- class nt {
540
+ class et {
540
541
  points;
541
542
  get p0() {
542
543
  return this.points[0];
@@ -559,7 +560,7 @@ class nt {
559
560
  path2D(t) {
560
561
  return this.points.flatMap((e, n) => {
561
562
  const s = this.points[(n + 1) % this.points.length];
562
- return t && t(new w(e.x, e.y), new w(s.x, s.y)), [e.x, e.y, s.x, s.y];
563
+ return t && t(new D(e.x, e.y), new D(s.x, s.y)), [e.x, e.y, s.x, s.y];
563
564
  });
564
565
  }
565
566
  createGeometry() {
@@ -590,12 +591,12 @@ class nt {
590
591
  const o = this.points[r], a = this.points[(r + 1) % 4], c = a.x - o.x, l = a.y - o.y, h = s * l - i * c;
591
592
  if (h === 0) {
592
593
  if ((e.x - o.x) * l - (e.y - o.y) * c !== 0) continue;
593
- const f = c * c + l * l, p = ((e.x - o.x) * c + (e.y - o.y) * l) / f, y = ((n.x - o.x) * c + (n.y - o.y) * l) / f;
594
- if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
594
+ const d = c * c + l * l, p = ((e.x - o.x) * c + (e.y - o.y) * l) / d, g = ((n.x - o.x) * c + (n.y - o.y) * l) / d;
595
+ if (Math.max(p, g) >= 0 && Math.min(p, g) <= 1)
595
596
  return !0;
596
597
  } else {
597
- const d = ((o.x - e.x) * l - (o.y - e.y) * c) / h, f = ((o.x - e.x) * i - (o.y - e.y) * s) / h;
598
- if (d >= 0 && d <= 1 && f >= 0 && f <= 1)
598
+ const f = ((o.x - e.x) * l - (o.y - e.y) * c) / h, d = ((o.x - e.x) * i - (o.y - e.y) * s) / h;
599
+ if (f >= 0 && f <= 1 && d >= 0 && d <= 1)
599
600
  return !0;
600
601
  }
601
602
  }
@@ -677,7 +678,7 @@ class nt {
677
678
  let t = 1 / 0, e = -1 / 0, n = 1 / 0, s = -1 / 0;
678
679
  return this.points.forEach((i) => {
679
680
  e = Math.max(i.x, e), t = Math.min(i.x, t), s = Math.max(i.x, s), n = Math.min(i.x, n);
680
- }), new I(t, e, n, s);
681
+ }), new R(t, e, n, s);
681
682
  }
682
683
  /**
683
684
  *
@@ -686,16 +687,16 @@ class nt {
686
687
  * @returns
687
688
  */
688
689
  static fromByLineSegment(t, e = 0.1, n = !1, s = 0.5) {
689
- const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : w.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : w.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
690
- return new nt([
691
- new w(i.x + l, i.y + h).add(c),
692
- new w(r.x + l, r.y + h).add(a),
693
- new w(r.x - l, r.y - h).add(a),
694
- new w(i.x - l, i.y - h).add(c)
690
+ const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : D.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : D.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
691
+ return new et([
692
+ new D(i.x + l, i.y + h).add(c),
693
+ new D(r.x + l, r.y + h).add(a),
694
+ new D(r.x - l, r.y - h).add(a),
695
+ new D(i.x - l, i.y - h).add(c)
695
696
  ]);
696
697
  }
697
698
  }
698
- class B {
699
+ class j {
699
700
  bounds;
700
701
  // 包围盒
701
702
  capacity;
@@ -721,7 +722,7 @@ class B {
721
722
  * @param node 线段节点
722
723
  */
723
724
  insert(t) {
724
- if (t instanceof D) {
725
+ if (t instanceof L) {
725
726
  this.insert({ line: t, userData: {} });
726
727
  return;
727
728
  }
@@ -746,7 +747,7 @@ class B {
746
747
  * @param node
747
748
  */
748
749
  remove(t) {
749
- if (t instanceof D) {
750
+ if (t instanceof L) {
750
751
  t = t.currentData[this.id], t && this.remove(t);
751
752
  return;
752
753
  }
@@ -781,26 +782,26 @@ class B {
781
782
  if (!this.isLeaf) return;
782
783
  this.isLeaf = !1, this.children = [];
783
784
  const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
784
- this.children[0] = new B(
785
- new I(this.bounds.minX, t, this.bounds.minY, e),
785
+ this.children[0] = new j(
786
+ new R(this.bounds.minX, t, this.bounds.minY, e),
786
787
  this.capacity,
787
788
  this.maxDepth,
788
789
  this.depth + 1,
789
790
  this.id
790
- ), this.children[1] = new B(
791
- new I(t, this.bounds.maxX, this.bounds.minY, e),
791
+ ), this.children[1] = new j(
792
+ new R(t, this.bounds.maxX, this.bounds.minY, e),
792
793
  this.capacity,
793
794
  this.maxDepth,
794
795
  this.depth + 1,
795
796
  this.id
796
- ), this.children[2] = new B(
797
- new I(this.bounds.minX, t, e, this.bounds.maxY),
797
+ ), this.children[2] = new j(
798
+ new R(this.bounds.minX, t, e, this.bounds.maxY),
798
799
  this.capacity,
799
800
  this.maxDepth,
800
801
  this.depth + 1,
801
802
  this.id
802
- ), this.children[3] = new B(
803
- new I(t, this.bounds.maxX, e, this.bounds.maxY),
803
+ ), this.children[3] = new j(
804
+ new R(t, this.bounds.maxX, e, this.bounds.maxY),
804
805
  this.capacity,
805
806
  this.maxDepth,
806
807
  this.depth + 1,
@@ -830,7 +831,7 @@ class B {
830
831
  * @returns 相交的节点数组
831
832
  */
832
833
  queryCircle(t, e) {
833
- const n = [], s = new I(
834
+ const n = [], s = new R(
834
835
  t.x - e,
835
836
  t.x + e,
836
837
  t.y - e,
@@ -842,8 +843,8 @@ class B {
842
843
  const [r, o] = i.line.points, a = o.x - r.x, c = o.y - r.y, l = a * a + c * c;
843
844
  let h = ((t.x - r.x) * a + (t.y - r.y) * c) / l;
844
845
  h = Math.max(0, Math.min(1, h));
845
- const d = r.x + h * a, f = r.y + h * c;
846
- t.distance(new w(d, f)) <= e && n.push(i);
846
+ const f = r.x + h * a, d = r.y + h * c;
847
+ t.distance(new D(f, d)) <= e && n.push(i);
847
848
  }
848
849
  if (!this.isLeaf)
849
850
  for (const i of this.children)
@@ -911,13 +912,110 @@ class B {
911
912
  })), t;
912
913
  }
913
914
  }
914
- class D {
915
- points = [new w(), new w()];
915
+ class gt extends Map {
916
+ get valueArray() {
917
+ return [...this.values()];
918
+ }
919
+ map(t) {
920
+ const e = [];
921
+ for (const [n, s] of this)
922
+ e.push(t(s, n));
923
+ return e;
924
+ }
925
+ filter(t) {
926
+ const e = [];
927
+ for (const [n, s] of this)
928
+ t(s, n) && e.push(s);
929
+ return e;
930
+ }
931
+ reduce(t, e) {
932
+ for (const [n, s] of this)
933
+ e = t(e, s, n);
934
+ return e;
935
+ }
936
+ some(t) {
937
+ for (const [e, n] of this)
938
+ if (t(n, e)) return !0;
939
+ return !1;
940
+ }
941
+ every(t) {
942
+ for (const [e, n] of this)
943
+ if (!t(n, e)) return !1;
944
+ return !0;
945
+ }
946
+ find(t) {
947
+ for (const [e, n] of this)
948
+ if (t(n, e)) return n;
949
+ }
950
+ findKey(t) {
951
+ for (const [e, n] of this)
952
+ if (t(n, e)) return e;
953
+ }
954
+ someKeys(t) {
955
+ return t.some((e) => this.has(e));
956
+ }
957
+ everyKeys(t) {
958
+ return t.every((e) => this.has(e));
959
+ }
960
+ group(t) {
961
+ const e = new J();
962
+ for (const [n, s] of this) {
963
+ const i = t(s, n);
964
+ e.append(i, s);
965
+ }
966
+ return e;
967
+ }
968
+ toObject() {
969
+ return this.reduce((t, e, n) => (t[`${n}`] = e, t), {});
970
+ }
971
+ }
972
+ class J extends gt {
973
+ append(t, ...e) {
974
+ return e.forEach((n) => {
975
+ this.has(t) || this.set(t, []), this.get(t)?.push(n);
976
+ }), this;
977
+ }
978
+ }
979
+ class qt extends gt {
980
+ set(t) {
981
+ let e = super.get(t) ?? 0;
982
+ return super.set(t, ++e), this;
983
+ }
984
+ }
985
+ class ct {
986
+ parent;
987
+ rank;
988
+ constructor(t) {
989
+ this.parent = Array(t).fill(0).map((e, n) => n), this.rank = Array(t).fill(1);
990
+ }
991
+ // 查找操作,使用路径压缩优化
992
+ find(t) {
993
+ return this.parent[t] !== t && (this.parent[t] = this.find(this.parent[t])), this.parent[t];
994
+ }
995
+ // 合并操作,使用按秩合并优化
996
+ union(t, e) {
997
+ let n = this.find(t), s = this.find(e);
998
+ n !== s && (this.rank[n] > this.rank[s] ? this.parent[s] = n : this.rank[n] < this.rank[s] ? this.parent[n] = s : (this.parent[s] = n, this.rank[n] += 1));
999
+ }
1000
+ /** 获取所有集合
1001
+ * @returns
1002
+ */
1003
+ getAllSets() {
1004
+ const t = new J();
1005
+ for (const e of this.parent.keys()) {
1006
+ const n = this.find(e);
1007
+ t.append(n, e);
1008
+ }
1009
+ return t;
1010
+ }
1011
+ }
1012
+ class L {
1013
+ points = [new D(), new D()];
916
1014
  userData = {};
917
1015
  currentData = {};
918
1016
  // line: any
919
1017
  get center() {
920
- return new w(
1018
+ return new D(
921
1019
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
922
1020
  this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
923
1021
  );
@@ -928,8 +1026,7 @@ class D {
928
1026
  get end() {
929
1027
  return this.points[1];
930
1028
  }
931
- id = 0;
932
- constructor(t = new w(), e = new w()) {
1029
+ constructor(t = new D(), e = new D()) {
933
1030
  this.points = [t, e];
934
1031
  }
935
1032
  set(t, e) {
@@ -1019,21 +1116,32 @@ class D {
1019
1116
  const e = this.center;
1020
1117
  return this.start.rotate(e, t), this.end.rotate(e, t), this;
1021
1118
  }
1119
+ /** 镜像线段
1120
+ */
1121
+ mirror() {
1122
+ this.end.rotate(this.start, Math.PI);
1123
+ }
1124
+ /** 交换两个端点
1125
+ */
1126
+ swap() {
1127
+ const t = this.points[1];
1128
+ this.points[0] = this.points[1], this.points[1] = t;
1129
+ }
1022
1130
  /** 膨胀为矩形
1023
1131
  *
1024
1132
  * @param width
1025
1133
  * @returns {Rectangle}
1026
1134
  */
1027
1135
  expandToRectangle(t = 0.1, e = "all") {
1028
- const n = this.start, s = this.end, i = s.normal(n), r = e === "bothSides" ? w.zero() : s.direction(n).mutiplyScalar(t * 0.5), o = e === "bothSides" ? w.zero() : n.direction(s).mutiplyScalar(t * 0.5), a = i.x * t * 0.5, c = i.y * t * 0.5, l = [
1136
+ const n = this.start, s = this.end, i = s.normal(n), r = e === "bothSides" ? D.zero() : s.direction(n).mutiplyScalar(t * 0.5), o = e === "bothSides" ? D.zero() : n.direction(s).mutiplyScalar(t * 0.5), a = i.x * t * 0.5, c = i.y * t * 0.5, l = [
1029
1137
  // 第一条线
1030
- new w(n.x + a, n.y + c).add(o),
1031
- new w(s.x + a, s.y + c).add(r),
1138
+ new D(n.x + a, n.y + c).add(o),
1139
+ new D(s.x + a, s.y + c).add(r),
1032
1140
  // 第二条线
1033
- new w(n.x - a, n.y - c).add(o),
1034
- new w(s.x - a, s.y - c).add(r)
1141
+ new D(n.x - a, n.y - c).add(o),
1142
+ new D(s.x - a, s.y - c).add(r)
1035
1143
  ];
1036
- return new nt([0, 1, 3, 2].map((h) => l[h]));
1144
+ return new et([0, 1, 3, 2].map((h) => l[h]));
1037
1145
  }
1038
1146
  /**
1039
1147
  * 计算线段的长度
@@ -1070,24 +1178,24 @@ class D {
1070
1178
  projectLineSegment(t) {
1071
1179
  if (t.points.length !== 2 || this.points.length !== 2)
1072
1180
  throw new Error("每条线段必须由两个点定义");
1073
- const [e, n] = t.points, [s, i] = this.points, r = new w(i.x - s.x, i.y - s.y);
1181
+ const [e, n] = t.points, [s, i] = this.points, r = new D(i.x - s.x, i.y - s.y);
1074
1182
  if (r.x === 0 && r.y === 0)
1075
1183
  throw new Error("投影目标线段的两个点不能重合");
1076
1184
  const o = (p) => {
1077
- const y = new w(p.x - s.x, p.y - s.y), g = r.x * r.x + r.y * r.y, m = (y.x * r.x + y.y * r.y) / g, L = s.x + m * r.x, M = s.y + m * r.y;
1078
- return new w(L, M);
1185
+ const g = new D(p.x - s.x, p.y - s.y), y = r.x * r.x + r.y * r.y, m = (g.x * r.x + g.y * r.y) / y, w = s.x + m * r.x, M = s.y + m * r.y;
1186
+ return new D(w, M);
1079
1187
  };
1080
1188
  let a = o(e), c = o(n);
1081
1189
  const l = (p) => {
1082
- const y = new w(p.x - s.x, p.y - s.y), g = r.x * r.x + r.y * r.y;
1083
- return (y.x * r.x + y.y * r.y) / g;
1190
+ const g = new D(p.x - s.x, p.y - s.y), y = r.x * r.x + r.y * r.y;
1191
+ return (g.x * r.x + g.y * r.y) / y;
1084
1192
  };
1085
- let h = l(a), d = l(c);
1086
- const f = (p) => {
1087
- const y = Math.max(0, Math.min(1, p)), g = s.x + y * r.x, x = s.y + y * r.y;
1088
- return new w(g, x);
1193
+ let h = l(a), f = l(c);
1194
+ const d = (p) => {
1195
+ const g = Math.max(0, Math.min(1, p)), y = s.x + g * r.x, x = s.y + g * r.y;
1196
+ return new D(y, x);
1089
1197
  };
1090
- return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new D(a, a) : new D(a, c);
1198
+ return (h < 0 || h > 1) && (a = d(h)), (f < 0 || f > 1) && (c = d(f)), a.x === c.x && a.y === c.y ? new L(a, a) : new L(a, c);
1091
1199
  }
1092
1200
  /**
1093
1201
  * 计算一条线段在另一条直线上的投影
@@ -1096,27 +1204,27 @@ class D {
1096
1204
  * @returns 投影并裁剪后的线段
1097
1205
  */
1098
1206
  projectPoint(t, e = !0) {
1099
- const [n, s] = this.points, i = new w(s.x - n.x, s.y - n.y);
1207
+ const [n, s] = this.points, i = new D(s.x - n.x, s.y - n.y);
1100
1208
  if (i.x === 0 && i.y === 0)
1101
1209
  return null;
1102
1210
  let o = ((l) => {
1103
- const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, y = n.x + p * i.x, g = n.y + p * i.y;
1104
- return new w(y, g);
1211
+ const h = new D(l.x - n.x, l.y - n.y), f = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / f, g = n.x + p * i.x, y = n.y + p * i.y;
1212
+ return new D(g, y);
1105
1213
  })(t);
1106
1214
  if (!e) return o;
1107
1215
  let c = ((l) => {
1108
- const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y;
1109
- return (h.x * i.x + h.y * i.y) / d;
1216
+ const h = new D(l.x - n.x, l.y - n.y), f = i.x * i.x + i.y * i.y;
1217
+ return (h.x * i.x + h.y * i.y) / f;
1110
1218
  })(o);
1111
1219
  return c < 0 || c > 1 ? null : o;
1112
1220
  }
1113
1221
  /** 获取点的投影值
1114
1222
  */
1115
1223
  projectValue(t) {
1116
- const [e, n] = this.points, s = new w(n.x - e.x, n.y - e.y);
1224
+ const [e, n] = this.points, s = new D(n.x - e.x, n.y - e.y);
1117
1225
  if (s.x === 0 && s.y === 0)
1118
1226
  return 0;
1119
- const i = new w(t.x - e.x, t.y - e.y), r = s.x * s.x + s.y * s.y;
1227
+ const i = new D(t.x - e.x, t.y - e.y), r = s.x * s.x + s.y * s.y;
1120
1228
  return (i.x * s.x + i.y * s.y) / r;
1121
1229
  }
1122
1230
  /**
@@ -1137,14 +1245,14 @@ class D {
1137
1245
  */
1138
1246
  intersectLineSegment(t, e = !0) {
1139
1247
  const n = this.start, s = this.end, i = t.start, r = t.end;
1140
- function o(f, p, y) {
1141
- return (p.x - f.x) * (y.y - f.y) - (p.y - f.y) * (y.x - f.x);
1248
+ function o(d, p, g) {
1249
+ return (p.x - d.x) * (g.y - d.y) - (p.y - d.y) * (g.x - d.x);
1142
1250
  }
1143
- function a(f, p, y) {
1144
- return Math.min(p.x, y.x) - 1e-10 <= f.x && f.x <= Math.max(p.x, y.x) + 1e-10 && Math.min(p.y, y.y) - 1e-10 <= f.y && f.y <= Math.max(p.y, y.y) + 1e-10;
1251
+ function a(d, p, g) {
1252
+ return Math.min(p.x, g.x) - 1e-10 <= d.x && d.x <= Math.max(p.x, g.x) + 1e-10 && Math.min(p.y, g.y) - 1e-10 <= d.y && d.y <= Math.max(p.y, g.y) + 1e-10;
1145
1253
  }
1146
- const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
1147
- return !!(c * l < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
1254
+ const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), f = o(i, r, s);
1255
+ return !!(c * l < 0 && h * f < 0 || e && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(f) < 1e-10 && a(s, i, r)));
1148
1256
  }
1149
1257
  /**
1150
1258
  * 判断一个点是否在线段上(含端点)
@@ -1165,7 +1273,7 @@ class D {
1165
1273
  if (Math.abs(r) < 1e-10)
1166
1274
  return null;
1167
1275
  const o = ((e.x - s.x) * (s.y - i.y) - (e.y - s.y) * (s.x - i.x)) / r, a = e.x + o * (n.x - e.x), c = e.y + o * (n.y - e.y);
1168
- return new w(a, c);
1276
+ return new D(a, c);
1169
1277
  }
1170
1278
  /**
1171
1279
  * 获取两条线段夹角
@@ -1187,7 +1295,7 @@ class D {
1187
1295
  * @param line
1188
1296
  */
1189
1297
  parallel(t, e = 1) {
1190
- return t instanceof D ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
1298
+ return t instanceof L ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
1191
1299
  }
1192
1300
  /** 两条线段或角度是否 垂直
1193
1301
  * @param line
@@ -1195,7 +1303,7 @@ class D {
1195
1303
  * @returns
1196
1304
  */
1197
1305
  vertical(t, e = 0.1) {
1198
- return t instanceof D ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
1306
+ return t instanceof L ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
1199
1307
  }
1200
1308
  /**
1201
1309
  * 两条线段方向相反否一致
@@ -1246,8 +1354,8 @@ class D {
1246
1354
  if (l > 1)
1247
1355
  return n.distance(r);
1248
1356
  {
1249
- const h = i.x + l * o, d = i.y + l * a;
1250
- return n.distance(new w(h, d));
1357
+ const h = i.x + l * o, f = i.y + l * a;
1358
+ return n.distance(new D(h, f));
1251
1359
  }
1252
1360
  };
1253
1361
  return Math.min(
@@ -1270,11 +1378,11 @@ class D {
1270
1378
  * @returns
1271
1379
  */
1272
1380
  clone() {
1273
- const t = new D(
1381
+ const t = new L(
1274
1382
  this.points[0].clone(),
1275
1383
  this.points[1].clone()
1276
1384
  );
1277
- return t.userData = J(this.userData), t;
1385
+ return t.userData = V(this.userData), t;
1278
1386
  }
1279
1387
  /**
1280
1388
  * 获取最长线段
@@ -1293,7 +1401,7 @@ class D {
1293
1401
  * @param lines
1294
1402
  */
1295
1403
  static groupBySamePointAndParallel(t) {
1296
- const e = new Y(), n = new B(I.fromByLineSegment(...t));
1404
+ const e = new q(), n = new j(R.fromByLineSegment(...t));
1297
1405
  t.forEach((o) => {
1298
1406
  o.points.forEach((a) => e.insert(a, o)), n.insert(o);
1299
1407
  });
@@ -1331,22 +1439,60 @@ class D {
1331
1439
  n.has(i) || n.set(i, []), n.get(i)?.push(s);
1332
1440
  }), [...n.values()];
1333
1441
  }
1442
+ /** 通过路径,给线段分组
1443
+ * @param lines
1444
+ * @returns
1445
+ */
1446
+ static groupByPath(t) {
1447
+ const e = new q();
1448
+ t.forEach((r) => r.points.forEach((o) => e.insert(o, r)));
1449
+ function n(r, o, a) {
1450
+ e.queryPoint(r, !0).forEach((l) => {
1451
+ const h = l.userData;
1452
+ if (a.has(h)) return;
1453
+ a.add(h), o.push(h);
1454
+ const f = h.getAnotherPoint(l.point);
1455
+ n(f, o, a);
1456
+ });
1457
+ }
1458
+ const s = /* @__PURE__ */ new Set(), i = [];
1459
+ for (let r = 0; r < t.length; r++) {
1460
+ const o = t[r];
1461
+ if (s.has(o)) continue;
1462
+ const a = [o];
1463
+ s.add(o), n(o.start, a, s), n(o.end, a, s), i.push(a);
1464
+ }
1465
+ return i;
1466
+ }
1467
+ /** 分组,通过点
1468
+ * @param lines
1469
+ * @returns
1470
+ */
1471
+ static groupByPoint(t) {
1472
+ const e = new ct(t.length), n = /* @__PURE__ */ new Map();
1473
+ for (let s = 0; s < t.length; s++)
1474
+ t[s].points.forEach((i) => {
1475
+ const r = i.hashCode();
1476
+ n.has(r) && e.union(n.get(r), s), n.set(r, s);
1477
+ });
1478
+ return e.getAllSets().valueArray.map((s) => s.map((i) => t[i]));
1479
+ }
1334
1480
  /** 合并线段到最长线段
1335
1481
  * @param lines
1336
1482
  * @returns
1337
1483
  */
1338
1484
  static mergeLinesByMaxlength(...t) {
1339
1485
  if (t.length === 1) return t[0];
1340
- const n = t.slice(0).sort((h, d) => d.length() - h.length())[0], s = n.direction().normalize();
1486
+ const n = t.slice(0).sort((h, f) => f.length() - h.length())[0], s = n.direction().normalize();
1341
1487
  let i = n.start.clone(), r = n.end.clone();
1342
1488
  const o = (h) => h.x * s.x + h.y * s.y;
1343
1489
  let a = o(i), c = o(r);
1344
1490
  for (const h of t)
1345
- for (const d of h.points) {
1346
- const f = o(d);
1347
- f < a && (a = f, i = n.projectPoint(d, !1)), f > c && (c = f, r = n.projectPoint(d, !1));
1491
+ for (const f of h.points) {
1492
+ const d = o(f);
1493
+ d < a && (a = d, i = n.projectPoint(f, !1)), d > c && (c = d, r = n.projectPoint(f, !1));
1348
1494
  }
1349
- const l = new D(i, r);
1495
+ const l = new L(i, r);
1350
1496
  return t.forEach((h) => h.userData.fittedLine = l), l;
1351
1497
  }
1352
1498
  /** 合并平行线段
@@ -1355,18 +1501,18 @@ class D {
1355
1501
  */
1356
1502
  static mergeLines(...t) {
1357
1503
  if (t.length === 1) return t[0];
1358
- const e = t.slice(0).sort((p, y) => y.length() - p.length()), n = [];
1504
+ const e = t.slice(0).sort((p, g) => g.length() - p.length()), n = [];
1359
1505
  t.forEach((p) => {
1360
1506
  n.push(p.start.clone(), p.end.clone());
1361
1507
  });
1362
1508
  const s = e[0].direction().normalize();
1363
1509
  let i = 1 / 0, r = -1 / 0, o = 0, a = 0;
1364
1510
  n.forEach((p) => {
1365
- const y = p.x * s.x + p.y * s.y;
1366
- i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
1511
+ const g = p.x * s.x + p.y * s.y;
1512
+ i = Math.min(i, g), r = Math.max(r, g), o += p.x, a += p.y;
1367
1513
  });
1368
- const c = new w(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new w(c.x + (i - l) * s.x, c.y + (i - l) * s.y), d = new w(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new D(h, d);
1369
- return t.forEach((p) => p.userData.fittedLine = f), f;
1514
+ const c = new D(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new D(c.x + (i - l) * s.x, c.y + (i - l) * s.y), f = new D(c.x + (r - l) * s.x, c.y + (r - l) * s.y), d = new L(h, f);
1515
+ return t.forEach((p) => p.userData.fittedLine = d), d;
1370
1516
  }
1371
1517
  /** 合并满足平行的线段
1372
1518
  * @param selectLines
@@ -1397,18 +1543,18 @@ class D {
1397
1543
  const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1398
1544
  function r(c) {
1399
1545
  const l = i.get(c[0]), h = i.get(c[1]);
1400
- let d;
1546
+ let f;
1401
1547
  if (l && h) {
1402
- d = l;
1548
+ f = l;
1403
1549
  const p = s.get(l);
1404
- [...s.get(h)].forEach((g) => {
1405
- p.add(g), i.set(g, d);
1550
+ [...s.get(h)].forEach((y) => {
1551
+ p.add(y), i.set(y, f);
1406
1552
  });
1407
- } else d = l ?? h ?? (Math.random() * 16777215).toString(16);
1408
- s.has(d) || s.set(d, /* @__PURE__ */ new Set());
1409
- const f = s.get(d);
1553
+ } else f = l ?? h ?? (Math.random() * 16777215).toString(16);
1554
+ s.has(f) || s.set(f, /* @__PURE__ */ new Set());
1555
+ const d = s.get(f);
1410
1556
  c.forEach((p) => {
1411
- i.set(p, d), f?.add(p);
1557
+ i.set(p, f), d?.add(p);
1412
1558
  });
1413
1559
  }
1414
1560
  for (const c of n.values()) {
@@ -1419,7 +1565,7 @@ class D {
1419
1565
  const o = /* @__PURE__ */ new Set(), a = [];
1420
1566
  for (const c of s.values()) {
1421
1567
  const l = [...c], h = this.mergeLines(...l);
1422
- e && e(h, l), l.forEach((d) => o.add(d)), a.push(h);
1568
+ e && e(h, l), l.forEach((f) => o.add(f)), a.push(h);
1423
1569
  }
1424
1570
  return t = t.filter((c) => !o.has(c)), t.push(...a), t;
1425
1571
  }
@@ -1441,7 +1587,7 @@ class D {
1441
1587
  * @returns
1442
1588
  */
1443
1589
  static clipping(t, e, n) {
1444
- if (!(t instanceof D)) throw new Error("参数1并非线段");
1590
+ if (!(t instanceof L)) throw new Error("参数1并非线段");
1445
1591
  e = e.map((r) => t.projectPoint(r)).filter((r) => !!r);
1446
1592
  const s = t.clone();
1447
1593
  e.sort((r, o) => s.start.distance(r) - s.start.distance(o));
@@ -1460,7 +1606,7 @@ class D {
1460
1606
  return this.clipping(t, [s, i].filter((o) => !!o), n).filter((o) => !(e.projectLineSegment(o).length() / e.length() > 0.8));
1461
1607
  }
1462
1608
  }
1463
- class w {
1609
+ class D {
1464
1610
  x;
1465
1611
  y;
1466
1612
  get X() {
@@ -1554,6 +1700,9 @@ class w {
1554
1700
  add(t) {
1555
1701
  return this.x += t.x, this.y += t.y, this;
1556
1702
  }
1703
+ parseInt() {
1704
+ return this.x = ~~this.x, this.y = ~~this.y, this;
1705
+ }
1557
1706
  /**
1558
1707
  * 绕point旋转angle
1559
1708
  * @param point
@@ -1587,7 +1736,7 @@ class w {
1587
1736
  */
1588
1737
  normal(t) {
1589
1738
  const e = this.x - t.x, n = this.y - t.y, s = Math.sqrt(e * e + n * n), i = -n / s, r = e / s;
1590
- return new w(i, r);
1739
+ return new D(i, r);
1591
1740
  }
1592
1741
  /**
1593
1742
  * 获取由传入的点到该点的单位方向向量
@@ -1597,14 +1746,14 @@ class w {
1597
1746
  */
1598
1747
  direction(t) {
1599
1748
  const e = this.x - t.x, n = this.y - t.y, s = Math.sqrt(e * e + n * n);
1600
- return s === 0 ? new w(0, 0) : new w(e / s, n / s);
1749
+ return s === 0 ? new D(0, 0) : new D(e / s, n / s);
1601
1750
  }
1602
1751
  /** 展开为线
1603
1752
  * @param direction
1604
1753
  * @param length
1605
1754
  */
1606
1755
  expandAsLine(t, e, n) {
1607
- const s = new D(
1756
+ const s = new L(
1608
1757
  this.clone(),
1609
1758
  this.clone().add(t.clone().multiplyScalar(e))
1610
1759
  );
@@ -1679,7 +1828,7 @@ class w {
1679
1828
  * @returns
1680
1829
  */
1681
1830
  clone() {
1682
- return new w(this.x, this.y);
1831
+ return new D(this.x, this.y);
1683
1832
  }
1684
1833
  /**
1685
1834
  * 克隆
@@ -1696,10 +1845,10 @@ class w {
1696
1845
  };
1697
1846
  }
1698
1847
  static from(t) {
1699
- return Array.isArray(t) ? new w(t[0], t[1]) : "x" in t && "y" in t ? new w(t.x, t.y) : "X" in t && "Y" in t ? new w(t.X, t.Y) : this.zero();
1848
+ return Array.isArray(t) ? new D(t[0], t[1]) : "x" in t && "y" in t ? new D(t.x, t.y) : "X" in t && "Y" in t ? new D(t.X, t.Y) : this.zero();
1700
1849
  }
1701
1850
  static zero() {
1702
- return new w(0, 0);
1851
+ return new D(0, 0);
1703
1852
  }
1704
1853
  }
1705
1854
  async function H(u, t = !0) {
@@ -1713,25 +1862,25 @@ async function H(u, t = !0) {
1713
1862
  return t && (e = e.default), e;
1714
1863
  }
1715
1864
  }
1716
- function Bt(u, t = 0, e, n) {
1865
+ function zt(u, t = 0, e, n) {
1717
1866
  const s = u.userData, i = s.drawWindow, r = e ? e.queryLineSegment(u).filter((a) => a.line !== u && !a.userData?.isDoor).map((a) => ({ index: n?.indexOf(a.line) })) : [];
1718
1867
  return {
1719
- ...J(s),
1868
+ ...V(s),
1720
1869
  start: u.start.toJson(t),
1721
1870
  end: u.end.toJson(t),
1722
1871
  insetionArr: r,
1723
1872
  length: u.length(),
1724
1873
  drawWindow: i && i.map((a) => ({
1725
- ...J(a),
1874
+ ...V(a),
1726
1875
  p: { x: a.p.x, y: a.p.y, z: a.p.z }
1727
1876
  }))
1728
1877
  };
1729
1878
  }
1730
- function et(u, t = 0, e) {
1731
- return e || (e = new B(I.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 })), Promise.resolve().then(() => e?.clear())), u.map((n) => Bt(n, t, e, u));
1879
+ function tt(u, t = 0, e) {
1880
+ return e || (e = new j(R.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 })), Promise.resolve().then(() => e?.clear())), u.map((n) => zt(n, t, e, u));
1732
1881
  }
1733
- function ft(u, t = 0.03) {
1734
- const e = new B(I.fromByLineSegment(...u));
1882
+ function ot(u, t = 0.03) {
1883
+ const e = new j(R.fromByLineSegment(...u));
1735
1884
  u.forEach((s) => e.insert({ line: s, userData: void 0 }));
1736
1885
  const n = u.flatMap((s) => {
1737
1886
  const i = e.queryLineSegment(s, !0).map((r) => {
@@ -1745,247 +1894,72 @@ function ft(u, t = 0.03) {
1745
1894
  i.sort((a, c) => r.start.distance(a) - r.start.distance(c));
1746
1895
  const o = i.map((a) => {
1747
1896
  const c = r.clone();
1748
- return c.set(r.start.clone(), a), r.start.copy(a), r.userData.isWindow && (c.userData.isWindow = !0, c.userData.drawWindow = r.userData.drawWindow?.filter((l) => c.isPointOnSegment(w.from(l.p))) ?? []), c;
1897
+ return c.set(r.start.clone(), a), r.start.copy(a), r.userData.isWindow && (c.userData.isWindow = !0, c.userData.drawWindow = r.userData.drawWindow?.filter((l) => c.isPointOnSegment(D.from(l.p))) ?? []), c;
1749
1898
  });
1750
- return r.userData.drawWindow = r.userData.drawWindow?.filter((a) => r.isPointOnSegment(w.from(a.p))) ?? [], [...o, r];
1899
+ return r.userData.drawWindow = r.userData.drawWindow?.filter((a) => r.isPointOnSegment(D.from(a.p))) ?? [], [...o, r];
1751
1900
  }
1752
1901
  return s;
1753
1902
  }).filter((s) => s.length() >= t);
1754
1903
  return e.clear(), n;
1755
1904
  }
1756
- function X(...u) {
1905
+ function K(...u) {
1757
1906
  u.forEach((t) => {
1758
1907
  const e = t.direction();
1759
1908
  t.userData.drawWindow?.forEach((n) => {
1760
1909
  try {
1761
- const s = w.from(n.p), i = t.projectPoint(
1762
- s.clone().add(e.clone().multiplyScalar(n.width * 0.5)),
1763
- !1
1764
- ), r = t.projectPoint(
1765
- s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
1766
- !1
1767
- ), o = t.projectLineSegment(new D(i, r)), a = o.center;
1768
- n.p = {
1769
- x: a?.x ?? 0,
1770
- y: a?.y ?? 0,
1771
- z: n.p.z
1772
- }, n.width = o.length();
1910
+ if (n.full) {
1911
+ const s = t.center;
1912
+ n.p = { x: s?.x ?? 0, y: s?.y ?? 0, z: n.p.z }, n.width = t.length();
1913
+ } else {
1914
+ const s = D.from(n.p), i = t.projectPoint(
1915
+ s.clone().add(e.clone().multiplyScalar(n.width * 0.5)),
1916
+ !1
1917
+ ), r = t.projectPoint(
1918
+ s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
1919
+ !1
1920
+ ), o = t.projectLineSegment(new L(i, r)), a = o.center;
1921
+ n.p = {
1922
+ x: a?.x ?? 0,
1923
+ y: a?.y ?? 0,
1924
+ z: n.p.z
1925
+ }, n.width = o.length();
1926
+ }
1773
1927
  } catch {
1774
1928
  }
1775
1929
  }), t.userData.drawWindow = t.userData.drawWindow?.filter((n) => n.width > 1e-9);
1776
1930
  });
1777
1931
  }
1778
- function Ot(u) {
1779
- if (u.length < 3) return 0;
1780
- let t = 0;
1781
- const e = u.length;
1782
- for (let n = 0; n < e; n++) {
1783
- const s = (n + 1) % e;
1784
- t += u[n].x * u[s].y, t -= u[s].x * u[n].y;
1785
- }
1786
- return Math.abs(t) / 2;
1787
- }
1788
- function V(u) {
1789
- const t = new Y();
1790
- for (const e of u)
1791
- t.insert(e.start, e), t.insert(e.end, e);
1792
- return t;
1793
- }
1794
- class Me extends Map {
1795
- get valueArray() {
1796
- return [...this.values()];
1797
- }
1798
- map(t) {
1799
- const e = [];
1800
- for (const [n, s] of this)
1801
- e.push(t(s, n));
1802
- return e;
1803
- }
1804
- filter(t) {
1805
- const e = [];
1806
- for (const [n, s] of this)
1807
- t(s, n) && e.push(s);
1808
- return e;
1809
- }
1810
- reduce(t, e) {
1811
- for (const [n, s] of this)
1812
- e = t(e, s, n);
1813
- return e;
1814
- }
1815
- some(t) {
1816
- for (const [e, n] of this)
1817
- if (t(n, e)) return !0;
1818
- return !1;
1819
- }
1820
- every(t) {
1821
- for (const [e, n] of this)
1822
- if (!t(n, e)) return !1;
1823
- return !0;
1824
- }
1825
- find(t) {
1826
- for (const [e, n] of this)
1827
- if (t(n, e)) return n;
1828
- }
1829
- findKey(t) {
1830
- for (const [e, n] of this)
1831
- if (t(n, e)) return e;
1832
- }
1833
- someKeys(t) {
1834
- return t.some((e) => this.has(e));
1835
- }
1836
- everyKeys(t) {
1837
- return t.every((e) => this.has(e));
1838
- }
1839
- group(t) {
1840
- const e = new at();
1841
- for (const [n, s] of this) {
1842
- const i = t(s, n);
1843
- e.append(i, s);
1844
- }
1845
- return e;
1846
- }
1847
- toObject() {
1848
- return this.reduce((t, e, n) => (t[`${n}`] = e, t), {});
1849
- }
1850
- }
1851
- class at extends Me {
1852
- append(t, ...e) {
1853
- return e.forEach((n) => {
1854
- this.has(t) || this.set(t, []), this.get(t)?.push(n);
1855
- }), this;
1856
- }
1857
- }
1858
- function De(u, t, e, n = !0) {
1859
- e = e ?? /* @__PURE__ */ new Set();
1860
- const s = !!t, i = t || V(u);
1861
- function r(o) {
1862
- if (!(o instanceof D) || e?.has(o)) return;
1863
- const a = i?.queryPoint(o.start, !0), c = i?.queryPoint(o.end, !0);
1864
- a && c && (a?.length === 0 || c?.length === 0) && (e?.add(o), i.remove(o.start), i.remove(o.end), n && (a.forEach(({ userData: l }) => r(l)), c.forEach(({ userData: l }) => r(l))));
1865
- }
1866
- for (let o = 0; o < u.length; o++) {
1867
- const a = u[o];
1868
- r(a);
1869
- }
1870
- return s || i.clear(), e;
1871
- }
1872
- function jt(u, t) {
1873
- const e = t || V(u);
1874
- function n(r, o, a) {
1875
- e.queryPoint(r, !0).forEach((l) => {
1876
- const h = l.userData;
1877
- if (a.has(h)) return;
1878
- a.add(h), o.push(h);
1879
- const d = h.getAnotherPoint(l.point);
1880
- n(d, o, a);
1881
- });
1882
- }
1883
- const s = /* @__PURE__ */ new Set(), i = [];
1884
- for (let r = 0; r < u.length; r++) {
1885
- const o = u[r];
1886
- if (s.has(o)) continue;
1887
- const a = [o];
1888
- s.add(o), n(o.start, a, s), n(o.end, a, s), i.push(a);
1889
- }
1890
- return i;
1891
- }
1892
- function Le(u, t = /* @__PURE__ */ new Set(), e) {
1893
- const n = e ?? V(u), s = /* @__PURE__ */ new Set();
1894
- let i = 0;
1895
- function r(a, c, l, h = /* @__PURE__ */ new Set()) {
1896
- const d = a.getAnotherPoint(c);
1897
- if (l.length > 1 && d.equal(l[0].end)) return !1;
1898
- const f = n.queryPoint(d, !0);
1899
- for (let p = 0; p < f.length; p++) {
1900
- const y = f[p].userData, g = f[p].point;
1901
- if (y === l[0]) {
1902
- if (y.end === g) continue;
1903
- return !0;
1904
- }
1905
- if (!h.has(y)) {
1906
- if (l.push(y), h.add(y), r(y, g, l, h)) return !0;
1907
- l.pop();
1908
- }
1909
- }
1910
- }
1911
- for (i = 0; i < u.length; i++) {
1912
- const a = u[i];
1913
- if (s.has(a)) continue;
1914
- const c = [a];
1915
- r(a, a.start, c) ? c.forEach((l) => s.add(l)) : (t.add(a), n.remove(a.start), n.remove(a.end));
1916
- }
1917
- const o = u.length;
1918
- return u = u.filter((a) => !t.has(a)), o !== u.length ? jt(u) : [u];
1919
- }
1920
- function Se(u) {
1921
- const t = V(u), e = u[0].start, n = /* @__PURE__ */ new Set();
1922
- let s = e;
1923
- for (n.add(s); ; ) {
1924
- const i = t.queryPoint(s, !0);
1925
- if (i.length !== 1) break;
1926
- const { point: r, userData: o } = i[0];
1927
- if (s = o?.getAnotherPoint(r), n.has(s)) break;
1928
- n.add(s);
1929
- }
1930
- return n.add(e.clone()), [...n];
1931
- }
1932
- function Ee(u) {
1933
- const t = V(u), e = [], n = /* @__PURE__ */ new Set(), s = performance.now();
1934
- function i(c, l = [], h) {
1935
- if (performance.now() - s > 200)
1936
- return;
1937
- let d = c.start;
1938
- h && (d = c.getAnotherPoint(h)), t.queryPoint(d, !0).forEach((p) => {
1939
- const y = p.userData;
1940
- if (l.includes(y)) {
1941
- if (l[0] === y) {
1942
- const g = [...l];
1943
- e.push(g), g.forEach((x) => n.add(x));
1944
- }
1945
- return;
1932
+ function _t(...u) {
1933
+ u.forEach((t) => {
1934
+ t.userData.drawWindow?.forEach((e) => {
1935
+ try {
1936
+ const n = t.projectPoint(D.from(e.p));
1937
+ e.p = {
1938
+ x: n?.x ?? 0,
1939
+ y: n?.y ?? 0,
1940
+ z: e.p.z
1941
+ };
1942
+ } catch {
1946
1943
  }
1947
- l.push(y), i(y, l, p.point), l.pop();
1948
- });
1949
- }
1950
- for (let c = 0; c < u.length; c++) {
1951
- const l = u[c];
1952
- n.has(l) || i(l, [l]);
1953
- }
1954
- let r = 0, o = [];
1955
- e.forEach((c) => {
1956
- const l = Se(c), h = Ot(l);
1957
- h >= r && (r = h, o = c);
1944
+ }), t.userData.drawWindow = t.userData.drawWindow?.filter((e) => e.width > 1e-9);
1958
1945
  });
1959
- const a = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
1960
- return o.forEach((c) => Object.assign(c.userData, { groupId: a, groupType: "doubleWall" })), t.clear(), o;
1961
1946
  }
1962
- function Ft(u) {
1963
- if (u.length === 0) return { lines: u, groups: [], removeLines: [] };
1964
- const t = V(u), e = De(u, t);
1965
- let n = u.filter((i) => !e.has(i));
1966
- const s = jt(n, t).flatMap((i) => Le(i, e, t)).map((i) => Ee(i));
1967
- return u = [...e, ...s.flat()], t.clear(), {
1968
- removeLines: [...e],
1969
- groups: s,
1970
- lines: u
1971
- };
1972
- }
1973
- function $(u, t) {
1947
+ function U(u, t) {
1974
1948
  if (Array.isArray(t))
1975
- return t.forEach((s) => $(u, s));
1949
+ return t.forEach((s) => U(u, s));
1976
1950
  const { drawWindow: e, ...n } = t.userData;
1977
1951
  Object.keys(n).forEach((s) => {
1978
1952
  n[s] === void 0 && delete n[s];
1979
1953
  }), e && (u.userData.drawWindow || (u.userData.drawWindow = []), u.userData.drawWindow.push(...e)), Object.assign(u.userData, n);
1980
1954
  }
1981
- function qt(u, t) {
1955
+ function yt(u, t) {
1982
1956
  const { drawWindow: e, ...n } = t.userData;
1983
1957
  e && (u.userData.drawWindow || (u.userData.drawWindow = []), e.forEach((s) => {
1984
- const i = w.from(s.p);
1958
+ const i = D.from(s.p);
1985
1959
  u.projectPoint(i) && u.userData.drawWindow?.push(s);
1986
- }), X(u)), Object.assign(u.userData, n);
1960
+ }), K(u)), Object.assign(u.userData, n);
1987
1961
  }
1988
- class Ae {
1962
+ class kt {
1989
1963
  static errorAngle = 4;
1990
1964
  /** 线段投影分析
1991
1965
  * @param index
@@ -2015,55 +1989,63 @@ class Ae {
2015
1989
  }, !c || c.project.getLength() < 0.08 || c.project2.getLength() < 0.08 ? void 0 : c;
2016
1990
  }
2017
1991
  }
2018
- /**
2019
- *
1992
+ /**
2020
1993
  * @param lines
2021
1994
  * @param wallWidth
2022
1995
  * @returns
2023
1996
  */
2024
1997
  static complementSide(t, e = 0.4) {
2025
1998
  const n = t.filter((h) => !h.userData.isDoor && !h.userData.groupId), s = /* @__PURE__ */ new Set(), i = [];
2026
- let r = new B(I.fromByLineSegment(...n));
2027
- n.forEach((h, d) => r.insert({ line: h, userData: d })), n.forEach((h, d) => {
2028
- const f = nt.fromByLineSegment(h, e * 2, !1, -0.01);
2029
- r.queryRect(f).map((y) => y.userData).filter((y) => y !== d).forEach((y) => {
1999
+ let r = new j(R.fromByLineSegment(...n));
2000
+ n.forEach((h, f) => r.insert({ line: h, userData: f })), n.forEach((h, f) => {
2001
+ const d = et.fromByLineSegment(h, e * 2, !1, -0.01);
2002
+ r.queryRect(d).map((g) => g.userData).filter((g) => g !== f).forEach((g) => {
2030
2003
  try {
2031
- if (s.has(`${d}-${y}`) || s.has(`${y}-${d}`)) return;
2032
- const g = this.projectionAnalysis(y, d, h, n);
2033
- g && i.push(g), s.add(`${d}-${y}`);
2034
- } catch (g) {
2035
- console.log(g);
2004
+ if (s.has(`${f}-${g}`) || s.has(`${g}-${f}`)) return;
2005
+ const y = this.projectionAnalysis(g, f, h, n);
2006
+ y && i.push(y), s.add(`${f}-${g}`);
2007
+ } catch (y) {
2008
+ console.log(y);
2036
2009
  }
2037
2010
  });
2038
2011
  });
2039
2012
  let o = [];
2040
2013
  const a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
2041
- function l(h, d) {
2014
+ function l(h, f) {
2042
2015
  c.has(h) || c.set(h, []);
2043
- const f = h.projectPoint(d.start), p = h.projectPoint(d.end), y = c.get(h);
2044
- f && y.push(f), p && y.push(p), a.add(h), r.remove(h);
2016
+ const d = h.projectPoint(f.start), p = h.projectPoint(f.end), g = c.get(h);
2017
+ d && g.push(d), p && g.push(p), a.add(h), r.remove(h);
2045
2018
  }
2046
2019
  return i.forEach((h) => {
2047
- const d = h.project, f = h.project2, p = h.source, y = h.target;
2048
- d.includedAngle(f) > 135 && (f.points = [f.points[1], f.points[0]]);
2049
- const g = new D(d.start.clone(), f.start.clone()), x = new D(d.end.clone(), f.end.clone());
2050
- o.push(g, x), l(p, d), l(y, f);
2051
- }), c.forEach((h, d) => {
2052
- const f = D.clipping(d, h, qt);
2053
- t.push(...f);
2054
- }), t = t.filter((h) => !a.has(h)), r.clear(), r = new B(I.fromByLineSegment(...t)), t.forEach((h) => h.userData.isDoor || r.insert(h)), o = D.autoMergeLines(o).lines, o = o.filter((h) => h.length() !== 0).map((h) => {
2055
- const d = r.queryLineSegment(h).filter((p) => !(!p.line.parallel(h) || p.line.projectLineSegment(h).length() === 0)).map((p) => p.line);
2056
- if (d.length === 0)
2020
+ const f = h.project, d = h.project2, p = h.source, g = h.target;
2021
+ f.includedAngle(d) > 135 && (d.points = [d.points[1], d.points[0]]);
2022
+ const y = new L(f.start.clone(), d.start.clone()), x = new L(f.end.clone(), d.end.clone());
2023
+ o.push(y, x), l(p, f), l(g, d);
2024
+ }), c.forEach((h, f) => {
2025
+ const d = L.clipping(f, h, yt);
2026
+ t.push(...d);
2027
+ }), t = t.filter((h) => !a.has(h)), r.clear(), r = new j(R.fromByLineSegment(...t)), t.forEach((h) => h.userData.isDoor || r.insert(h)), o = L.autoMergeLines(o).lines, o = o.filter((h) => h.length() !== 0).map((h) => {
2028
+ const f = r.queryLineSegment(h).filter((p) => !(!p.line.parallel(h) || p.line.projectLineSegment(h).length() === 0)).map((p) => p.line);
2029
+ if (f.length === 0)
2057
2030
  return r.insert(h), h;
2058
- const f = D.mergeLines(...d, h);
2059
- return d.forEach((p) => {
2060
- $(f, p), r.remove(p), a.add(p);
2061
- }), r.insert(f), f;
2062
- }), t = t.filter((h) => !a.has(h)), t.push(...o), r.clear(), t;
2031
+ const d = L.mergeLines(...f, h);
2032
+ return f.forEach((p) => {
2033
+ U(d, p), r.remove(p), a.add(p);
2034
+ }), r.insert(d), d;
2035
+ }), o = o.filter((h) => !a.has(h)), t = t.filter((h) => !a.has(h)), t.push(...o), t = ot(t, 1e-9), r.clear(), t;
2063
2036
  }
2064
2037
  }
2065
- class be {
2038
+ class Yt {
2066
2039
  index = 0;
2040
+ get size() {
2041
+ return this.index;
2042
+ }
2043
+ constructor(t = []) {
2044
+ t.forEach((e) => {
2045
+ const n = this.next();
2046
+ this.map.set(e, n), this.lineMap.set(n, e);
2047
+ });
2048
+ }
2067
2049
  next() {
2068
2050
  return this.index++;
2069
2051
  }
@@ -2083,35 +2065,418 @@ class be {
2083
2065
  return this.lineMap.get(t);
2084
2066
  }
2085
2067
  }
2086
- class Te {
2087
- parent;
2088
- rank;
2089
- constructor(t) {
2090
- this.parent = Array(t).fill(0).map((e, n) => n), this.rank = Array(t).fill(1);
2068
+ class ve {
2069
+ adjacencyList;
2070
+ get size() {
2071
+ return this.adjacencyList.size;
2091
2072
  }
2092
- // 查找操作,使用路径压缩优化
2093
- find(t) {
2094
- return this.parent[t] !== t && (this.parent[t] = this.find(this.parent[t])), this.parent[t];
2073
+ constructor() {
2074
+ this.adjacencyList = /* @__PURE__ */ new Map();
2075
+ }
2076
+ // 添加一个节点到图中
2077
+ addNode(t) {
2078
+ this.adjacencyList.has(t) || this.adjacencyList.set(t, /* @__PURE__ */ new Set());
2079
+ }
2080
+ // 添加一条边(无向边),连接节点 u 和 v
2081
+ addEdge(t, e) {
2082
+ this.adjacencyList.get(t)?.add(e) ?? this.adjacencyList.set(t, /* @__PURE__ */ new Set([e])), this.adjacencyList.get(e)?.add(t) ?? this.adjacencyList.set(e, /* @__PURE__ */ new Set([t]));
2083
+ }
2084
+ // 删除一条边,断开节点 u 和 v 的连接
2085
+ removeEdge(t, e) {
2086
+ this.adjacencyList.get(t)?.delete(e), this.adjacencyList.get(e)?.delete(t);
2087
+ }
2088
+ // 删除一个节点及其相关的所有边
2089
+ removeNode(t) {
2090
+ const e = this.adjacencyList.get(t);
2091
+ if (e) {
2092
+ for (const n of e)
2093
+ this.adjacencyList.get(n)?.delete(t);
2094
+ this.adjacencyList.delete(t);
2095
+ }
2095
2096
  }
2096
- // 合并操作,使用按秩合并优化
2097
- union(t, e) {
2098
- let n = this.find(t), s = this.find(e);
2099
- n !== s && (this.rank[n] > this.rank[s] ? this.parent[s] = n : this.rank[n] < this.rank[s] ? this.parent[n] = s : (this.parent[s] = n, this.rank[n] += 1));
2097
+ // 获取节点的邻居列表
2098
+ getNeighbors(t) {
2099
+ return this.adjacencyList.get(t);
2100
2100
  }
2101
- /** 获取所有集合
2101
+ // 打印图的所有节点及其邻居
2102
+ printGraph() {
2103
+ for (let [t, e] of this.adjacencyList.entries())
2104
+ console.log(`${t} -> ${[...e].join(", ")}`);
2105
+ }
2106
+ /** 循环
2107
+ * @param callbackFun
2108
+ */
2109
+ forEach(t) {
2110
+ for (let [e, n] of this.adjacencyList.entries())
2111
+ t(e, n);
2112
+ }
2113
+ }
2114
+ class Re extends ve {
2115
+ // 线段存储:使用规范化 key (小索引-大索引) 避免双向存储
2116
+ lineMap = /* @__PURE__ */ new Map();
2117
+ // 点坐标映射
2118
+ pointToIndex = /* @__PURE__ */ new Map();
2119
+ indexToPoint = /* @__PURE__ */ new Map();
2120
+ nextIndex = 0;
2121
+ constructor(t = []) {
2122
+ super(), t.length > 0 && this.buildFromLines(t);
2123
+ }
2124
+ buildFromLines(t) {
2125
+ t.length > 1e3 && (this.pointToIndex.clear(), this.indexToPoint.clear(), this.nextIndex = 0);
2126
+ for (const e of t) {
2127
+ const n = this.getOrCreateIndex(e.start), s = this.getOrCreateIndex(e.end);
2128
+ super.addEdge(n, s);
2129
+ const i = n < s ? `${n}-${s}` : `${s}-${n}`;
2130
+ this.lineMap.set(i, e);
2131
+ }
2132
+ }
2133
+ /**
2134
+ * 获取两点之间的线段(无向)
2135
+ */
2136
+ getLine(t, e) {
2137
+ const n = t < e ? `${t}-${e}` : `${e}-${t}`;
2138
+ return this.lineMap.get(n);
2139
+ }
2140
+ /**
2141
+ * 获取或创建点的索引
2142
+ */
2143
+ getOrCreateIndex(t) {
2144
+ const e = t.hashCode();
2145
+ let n = this.pointToIndex.get(e);
2146
+ return n === void 0 && (n = this.nextIndex++, this.pointToIndex.set(e, n), this.indexToPoint.set(n, t)), n;
2147
+ }
2148
+ /**
2149
+ * 安全获取点索引(已存在才返回)
2150
+ */
2151
+ getIndex(t) {
2152
+ return this.pointToIndex.get(t.hashCode());
2153
+ }
2154
+ /**
2155
+ * @param index
2102
2156
  * @returns
2103
2157
  */
2104
- getAllSets() {
2105
- const t = new at();
2106
- for (const e of this.parent.keys()) {
2107
- const n = this.find(e);
2108
- t.append(n, e);
2158
+ getPoint(t) {
2159
+ return this.indexToPoint.get(t);
2160
+ }
2161
+ /**
2162
+ * 获取所有点(只读数组,懒计算或缓存可进一步优化)
2163
+ */
2164
+ get points() {
2165
+ return Array.from(this.indexToPoint.values());
2166
+ }
2167
+ /**
2168
+ * 获取所有线段
2169
+ */
2170
+ get lines() {
2171
+ return Array.from(this.lineMap.values());
2172
+ }
2173
+ /**
2174
+ * 批量添加线段(比逐条 addLine 更快)
2175
+ */
2176
+ addLines(t) {
2177
+ return this.buildFromLines(t), this;
2178
+ }
2179
+ /**
2180
+ * 清空图
2181
+ */
2182
+ clear() {
2183
+ this.adjacencyList.clear(), this.lineMap.clear(), this.pointToIndex.clear(), this.indexToPoint.clear(), this.nextIndex = 0;
2184
+ }
2185
+ }
2186
+ function nt(u) {
2187
+ const t = new q();
2188
+ for (const e of u)
2189
+ t.insert(e.start, e), t.insert(e.end, e);
2190
+ return t;
2191
+ }
2192
+ const Ce = Math.PI / 180;
2193
+ function Wt(u, t, e = !1) {
2194
+ const n = nt(u), s = new L(), i = new L(), r = [], o = /* @__PURE__ */ new Set();
2195
+ function a(f, d, p) {
2196
+ const g = f.center, y = f.normal(), x = f.getAnotherPoint(d), m = x.direction(d);
2197
+ s.start.copy(g), s.end.copy(g).add(y.clone().multiplyScalar(1));
2198
+ const w = p.getIntersection(s);
2199
+ return s.end.copy(w), p.direction().angleBetween(m) > Ce * 170 && s.mirror(), s.clone();
2200
+ }
2201
+ function c(f, d, p, g, y, x, m = !0) {
2202
+ if (x.length > u.length || o.has(d)) return;
2203
+ o.add(d);
2204
+ let w;
2205
+ const M = d.getAnotherPoint(p);
2206
+ if (m)
2207
+ if (d.vertical(g))
2208
+ w = a(d, p, y);
2209
+ else {
2210
+ const A = d.center, S = A.distance(y.start), T = A.direction(y.start);
2211
+ w = y.directionMove(T, S);
2212
+ }
2213
+ else w = y;
2214
+ let E = n.queryPoint(M, !0);
2215
+ if (E.length === 1) {
2216
+ const A = E[0], S = A.userData, T = S.getAnotherPoint(A.point), P = T.direction(A.point);
2217
+ if (f === S) return x;
2218
+ if (S.vertical(d)) {
2219
+ const I = M.direction(p), C = S.center, N = P.angleBetween(w.direction()) < 1e-9;
2220
+ w.start.copy(C), w.end.copy(C).add(I.multiplyScalar(0.02)), N && w.mirror();
2221
+ } else {
2222
+ const I = S.center, C = S.center.direction(w.start);
2223
+ w.directionMove(C, I.distance(w.start));
2224
+ }
2225
+ if (x.push(S), c(f, S, A.point, d, w, x, !1)) return x;
2226
+ } else {
2227
+ i.start.copy(w.start).add(w.direction().multiplyScalar(5e-3));
2228
+ const A = [d, ...E.map((S) => {
2229
+ const T = S.userData;
2230
+ return T.length(), T;
2231
+ })];
2232
+ for (let S = 0; S < E.length; S++) {
2233
+ const T = E[S], P = T.userData;
2234
+ if (f === P) return x;
2235
+ if (!(E.length === 4 && P.parallel(d)) && (i.end.copy(P.center), !A.some((I) => I === P ? !1 : I.intersectLineSegment(i))))
2236
+ return x.push(P), c(f, P, T.point, d, w, x);
2237
+ }
2109
2238
  }
2110
- return t;
2111
2239
  }
2240
+ function l(f) {
2241
+ const d = n.queryPoint(f.start, !0), p = n.queryPoint(f.end, !0), g = d.length < p.length ? d : p;
2242
+ return g.filter((x) => {
2243
+ if (g.length === 3 && x.userData?.parallel(f)) return !1;
2244
+ const m = x.userData?.getAnotherPoint(x.point);
2245
+ return x.line = x.userData, x.direct = m.direction(x.point), !0;
2246
+ });
2247
+ }
2248
+ function h(f, d) {
2249
+ const p = [], g = f.center;
2250
+ for (let y = 0; y < d.length; y++) {
2251
+ const x = d[y];
2252
+ let m = x.direct;
2253
+ o.clear(), x.line.parallel(f) && (m = d[y ? 0 : 1].direct.clone().multiplyScalar(-1));
2254
+ const w = new L(g.clone(), g.clone().add(m.clone().multiplyScalar(0.2))), M = [f, x.line];
2255
+ (c(f, x.line, x.point, f, w, M) || e) && p.push(M);
2256
+ }
2257
+ return p;
2258
+ }
2259
+ for (let f = 0; f < t.length; f++) {
2260
+ const d = t[f], p = l(d);
2261
+ let g = h(d, p);
2262
+ if (g.length === 0) {
2263
+ const y = p.filter((x) => x.line.parallel(d) ? !1 : (x.direct.multiplyScalar(-1), !0));
2264
+ g = h(d, y);
2265
+ }
2266
+ if (g.length === 2) {
2267
+ const y = new Set(g[0]);
2268
+ g[1].filter((m) => y.has(m)).length > 1 && g.splice(0, 2, g[0].length < g[1].length ? g[0] : g[1]);
2269
+ }
2270
+ r.push(...g);
2271
+ }
2272
+ return r;
2273
+ }
2274
+ function Ne(u) {
2275
+ const t = new J(), e = [];
2276
+ u.forEach((n) => t.append(n.length, n));
2277
+ for (const n of t.values()) {
2278
+ const s = new Yt(n.flat()), i = new J();
2279
+ n.map((r) => {
2280
+ const o = r.map((a) => s.getIndex(a)).sort((a, c) => a - c).join(",");
2281
+ i.append(o, r);
2282
+ }), i.forEach((r) => e.push(r[0]));
2283
+ }
2284
+ return e;
2112
2285
  }
2113
- function Pe(u, t = 0.1, e) {
2114
- e || (e = new Y(), u.forEach((i) => {
2286
+ function Be(u) {
2287
+ const t = /* @__PURE__ */ new Map(), e = new ct(u.length), n = [];
2288
+ u.forEach((r, o) => {
2289
+ for (let a = 0; a < r.length; a++) {
2290
+ const c = r[a];
2291
+ t.has(c) ? e.union(o, t.get(c)) : t.set(c, o);
2292
+ }
2293
+ });
2294
+ const s = new qt(), i = e.getAllSets().valueArray.map((r) => {
2295
+ let o = r.map((c) => u[c]);
2296
+ return o.length === 1 ? o[0] : (s.clear(), o = Ne(o), o.forEach((c) => c.forEach((l) => s.set(l))), s.reduce((c, l, h) => (l === 1 ? c.push(h) : n.push(h), c), []));
2297
+ });
2298
+ return {
2299
+ internalEdges: n,
2300
+ rings: i
2301
+ };
2302
+ }
2303
+ function Vt(u) {
2304
+ const t = new Re(u), e = new ct(t.size), n = /* @__PURE__ */ new Set(), s = [];
2305
+ function i(r) {
2306
+ n.add(r), t.getNeighbors(r)?.forEach((a) => {
2307
+ if (!n.has(a))
2308
+ if (e.find(r) === e.find(a)) {
2309
+ const c = t.getLine(r, a);
2310
+ s.push(c);
2311
+ } else
2312
+ e.union(r, a);
2313
+ });
2314
+ }
2315
+ return t.forEach((r) => {
2316
+ n.has(r) || i(r);
2317
+ }), s;
2318
+ }
2319
+ function Xt(u) {
2320
+ Log.clear();
2321
+ const t = L.groupByPath(u), e = [], n = [];
2322
+ t.forEach((r, o) => {
2323
+ try {
2324
+ let a = Vt(r);
2325
+ const c = Be(Wt(r, a));
2326
+ e.push(...c.rings), n.push(...c.internalEdges);
2327
+ } catch (a) {
2328
+ console.warn("环查找出现异常:", a.message);
2329
+ }
2330
+ });
2331
+ const s = /* @__PURE__ */ new Set([...n]), i = /* @__PURE__ */ new Set([...e.flat()]);
2332
+ return u = u.filter((r) => !s.has(r)), u.forEach((r) => !i.has(r)), u = [...new Set(u)], Log.timeConsuming("找环时间"), {
2333
+ newLines: u,
2334
+ rings: e,
2335
+ internalEdges: n
2336
+ };
2337
+ }
2338
+ class O {
2339
+ /**
2340
+ * 获取线段的所有分组信息
2341
+ * @param line
2342
+ * @returns
2343
+ */
2344
+ static get(t) {
2345
+ const e = [];
2346
+ return typeof t.userData.groupId < "u" && e.push({
2347
+ id: t.userData.groupId,
2348
+ type: t.userData.groupType
2349
+ }), t.userData?.groups?.forEach((n) => e.push({
2350
+ id: n.id,
2351
+ type: n.type
2352
+ })), e;
2353
+ }
2354
+ /**
2355
+ * 为线段添加新的分组
2356
+ * @param line
2357
+ * @param id
2358
+ * @param type
2359
+ * @returns
2360
+ */
2361
+ static set(t, e, n) {
2362
+ if (!(this.hasId(t, e) || this.hasType(t, n))) {
2363
+ if (typeof t.userData.groupId > "u") {
2364
+ t.userData.groupId = e, t.userData.groupType = n;
2365
+ return;
2366
+ }
2367
+ typeof t.userData.groups > "u" && (t.userData.groups = []), t.userData?.groups?.push({ id: e, type: n });
2368
+ }
2369
+ }
2370
+ /**
2371
+ * 替换线段中的分组信息
2372
+ * @param line
2373
+ * @param id
2374
+ * @param type
2375
+ * @returns
2376
+ */
2377
+ static replace(t, e, n) {
2378
+ if (t.userData.groupId === e)
2379
+ return t.userData.groupType = n, !0;
2380
+ if (t.userData.groupType === n)
2381
+ return t.userData.groupId = e, !0;
2382
+ if (t.userData.groups)
2383
+ for (let s = 0; s < t.userData.groups.length; s++) {
2384
+ const i = t.userData.groups[s];
2385
+ if (i.id === e)
2386
+ return i.type = n, !0;
2387
+ if (i.type === n)
2388
+ return i.id = e, !0;
2389
+ }
2390
+ return !1;
2391
+ }
2392
+ /**
2393
+ * 检查线段是否包含指定的分组ID
2394
+ * @param line
2395
+ * @param id
2396
+ * @returns
2397
+ */
2398
+ static hasId(t, e) {
2399
+ return typeof t.userData.groupId < "u" && t.userData.groupId === e ? !0 : t.userData?.groups?.some((n) => n.id === e);
2400
+ }
2401
+ /**
2402
+ * 检查线段是否包含指定的分组类型
2403
+ * @param line
2404
+ * @param type
2405
+ * @returns
2406
+ */
2407
+ static hasType(t, e) {
2408
+ return typeof t.userData.groupType < "u" && t.userData.groupType === e ? !0 : !!t.userData?.groups?.some((n) => n.type === e);
2409
+ }
2410
+ /**
2411
+ * 检查线段是否包含所有指定的分组类型
2412
+ * @param line
2413
+ * @param types
2414
+ * @returns
2415
+ */
2416
+ static hasTypes(t, e) {
2417
+ return e.every((n) => this.hasType(t, n));
2418
+ }
2419
+ /**
2420
+ * 检查线段是否包含所有指定的分组类型
2421
+ * @param lines
2422
+ * @param type
2423
+ * @returns
2424
+ */
2425
+ static everyType(t, e) {
2426
+ return !t || t.length === 0 ? !1 : t.every((n) => this.hasType(n, e));
2427
+ }
2428
+ /**
2429
+ * 获取所有线段的交集类型(所有线段都包含的类型)
2430
+ * @param lines
2431
+ * @returns
2432
+ */
2433
+ static getIntersectionTypes(t) {
2434
+ const e = new qt();
2435
+ t.forEach((s) => {
2436
+ s.userData.groups && s.userData.groups.forEach((i) => e.set(i.type)), s.userData.groupType && e.set(s.userData.groupType);
2437
+ });
2438
+ const n = [];
2439
+ return e.forEach((s, i) => {
2440
+ s === t.length && n.push(i);
2441
+ }), n;
2442
+ }
2443
+ /**
2444
+ * 获取所有线段的交集类型(所有线段都包含的类型)
2445
+ * @param lines
2446
+ * @returns
2447
+ */
2448
+ static getUnionTypes(t) {
2449
+ const e = /* @__PURE__ */ new Set();
2450
+ return t.forEach((n) => {
2451
+ n.userData.groups && n.userData.groups.forEach((s) => e.add(s.type)), n.userData.groupType && e.add(n.userData.groupType);
2452
+ }), Array.from(e);
2453
+ }
2454
+ /**
2455
+ * 获取所有线段的交集类型(所有线段都包含的类型)
2456
+ * @param line
2457
+ * @param id
2458
+ * @returns
2459
+ */
2460
+ static remove(t, e) {
2461
+ if (typeof t.userData.groupType < "u" && t.userData.groupId === e)
2462
+ return delete t.userData.groupId, delete t.userData.groupType, !0;
2463
+ if (t.userData?.groups) {
2464
+ for (let n = 0; n < t.userData.groups.length; n++)
2465
+ if (t.userData.groups[n].id === e)
2466
+ return t.userData.groups.splice(n, 1), !0;
2467
+ }
2468
+ return !1;
2469
+ }
2470
+ /**
2471
+ * 清空线段的所有分组信息
2472
+ * @param line
2473
+ */
2474
+ static clear(t) {
2475
+ delete t.userData.groupId, delete t.userData.groupType, delete t.userData.groups;
2476
+ }
2477
+ }
2478
+ function je(u, t = 0.1, e) {
2479
+ e || (e = new q(), u.forEach((i) => {
2115
2480
  i.userData.isDoor || i.points.forEach((r) => e?.insert(r, i));
2116
2481
  }));
2117
2482
  const n = [], s = /* @__PURE__ */ new Set();
@@ -2120,38 +2485,38 @@ function Pe(u, t = 0.1, e) {
2120
2485
  r.userData.isDoor || r.points.forEach((a) => {
2121
2486
  if (s.has(a)) return !1;
2122
2487
  if (e.queryPoint(a).length > 1) return;
2123
- const c = e.queryCircle(a, t).filter((y) => {
2124
- if (s.has(y.point)) return !1;
2125
- const g = y.userData;
2126
- if (g === r || !r.parallel(g, 25) || e.queryPoint(y.point).length > 1) return !1;
2127
- const x = a.distance(y.point);
2488
+ const c = e.queryCircle(a, t).filter((g) => {
2489
+ if (s.has(g.point)) return !1;
2490
+ const y = g.userData;
2491
+ if (y === r || !r.parallel(y, 25) || e.queryPoint(g.point).length > 1) return !1;
2492
+ const x = a.distance(g.point);
2128
2493
  if (x < 1e-3) return !1;
2129
- const m = a.direction(r.getAnotherPoint(a)), L = y.point.direction(g.getAnotherPoint(y.point));
2130
- if (180 - m.angleBetween(L, "angle") < 25)
2131
- return o.set(y.point, x), !0;
2132
- }).sort((y, g) => {
2133
- const x = o.get(y.point), m = o.get(g.point);
2494
+ const m = a.direction(r.getAnotherPoint(a)), w = g.point.direction(y.getAnotherPoint(g.point));
2495
+ if (180 - m.angleBetween(w, "angle") < 25)
2496
+ return o.set(g.point, x), !0;
2497
+ }).sort((g, y) => {
2498
+ const x = o.get(g.point), m = o.get(y.point);
2134
2499
  return x - m;
2135
2500
  });
2136
2501
  if (c.length === 0) return;
2137
2502
  s.add(a), s.add(c[0].point);
2138
- const l = c[0].userData, h = r.projectLineSegment(l), d = l.projectLineSegment(r), f = h.length(), p = d.length();
2139
- f === 0 && p === 0 ? n.push(new D(a.clone(), c[0].point.clone())) : n.push(new D(h.center, d.center));
2503
+ const l = c[0].userData, h = r.projectLineSegment(l), f = l.projectLineSegment(r), d = h.length(), p = f.length();
2504
+ d === 0 && p === 0 ? n.push(new L(a.clone(), c[0].point.clone())) : n.push(new L(h.center, f.center));
2140
2505
  });
2141
2506
  }
2142
2507
  return [...u, ...n];
2143
2508
  }
2144
- function Ie(u) {
2145
- const t = new Y(), e = new B(I.fromByLineSegment(...u)), n = [];
2509
+ function Oe(u) {
2510
+ const t = new q(), e = new j(R.fromByLineSegment(...u)), n = [];
2146
2511
  return u.forEach((s) => {
2147
2512
  s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert(s));
2148
2513
  }), n.forEach((s) => {
2149
2514
  const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
2150
2515
  i.length ? s.userData.startIntersection = i[0].userData : s.userData.startIntersection = e.queryPoint(s.start)[0]?.line, r.length ? s.userData.endIntersection = r[0].userData : s.userData.endIntersection = e.queryPoint(s.end)[0]?.line;
2151
- }), u = Pe(u, 0.4, t), t.clear(), e.clear(), u;
2516
+ }), u = je(u, 0.4, t), t.clear(), e.clear(), u;
2152
2517
  }
2153
- function ve(u) {
2154
- const t = new B(I.fromByLineSegment(...u));
2518
+ function Fe(u) {
2519
+ const t = new j(R.fromByLineSegment(...u));
2155
2520
  u.forEach((n) => {
2156
2521
  n.userData.isDoor || t.insert({ line: n, userData: void 0 });
2157
2522
  });
@@ -2170,59 +2535,59 @@ function ve(u) {
2170
2535
  }
2171
2536
  return t.clear(), e;
2172
2537
  }
2173
- function Re(u, t, e, n = 15) {
2538
+ function Ge(u, t, e, n = 15) {
2174
2539
  const s = [u], i = [], r = [], o = [];
2175
- function a(d) {
2176
- if (d.userData.isDoor) return r.push(d);
2177
- const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x);
2178
- let y = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x) - f;
2179
- for (; y > Math.PI; ) y -= 2 * Math.PI;
2180
- for (; y < -Math.PI; ) y += 2 * Math.PI;
2181
- const g = d.center;
2182
- return d.start.rotate(g, y), d.end.rotate(g, y), d.userData.isDoor ? r.push(d) : s.push(d), d;
2540
+ function a(f) {
2541
+ if (f.userData.isDoor) return r.push(f);
2542
+ const d = Math.atan2(f.end.y - f.start.y, f.end.x - f.start.x);
2543
+ let g = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x) - d;
2544
+ for (; g > Math.PI; ) g -= 2 * Math.PI;
2545
+ for (; g < -Math.PI; ) g += 2 * Math.PI;
2546
+ const y = f.center;
2547
+ return f.start.rotate(y, g), f.end.rotate(y, g), f.userData.isDoor ? r.push(f) : s.push(f), f;
2183
2548
  }
2184
- function c(d) {
2185
- if (d.userData.isDoor) return r.push(d);
2186
- const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x), p = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
2187
- let y = p + Math.PI / 2 - f, g = p - Math.PI / 2 - f;
2188
- for (; y > Math.PI; ) y -= 2 * Math.PI;
2189
- for (; y < -Math.PI; ) y += 2 * Math.PI;
2549
+ function c(f) {
2550
+ if (f.userData.isDoor) return r.push(f);
2551
+ const d = Math.atan2(f.end.y - f.start.y, f.end.x - f.start.x), p = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
2552
+ let g = p + Math.PI / 2 - d, y = p - Math.PI / 2 - d;
2190
2553
  for (; g > Math.PI; ) g -= 2 * Math.PI;
2191
2554
  for (; g < -Math.PI; ) g += 2 * Math.PI;
2192
- const x = Math.abs(y) < Math.abs(g) ? y : g, m = d.center;
2193
- return d.start.rotate(m, x), d.end.rotate(m, x), d.userData.isDoor ? r.push(d) : i.push(d), d;
2555
+ for (; y > Math.PI; ) y -= 2 * Math.PI;
2556
+ for (; y < -Math.PI; ) y += 2 * Math.PI;
2557
+ const x = Math.abs(g) < Math.abs(y) ? g : y, m = f.center;
2558
+ return f.start.rotate(m, x), f.end.rotate(m, x), f.userData.isDoor ? r.push(f) : i.push(f), f;
2194
2559
  }
2195
- function l(d, f, p = !1) {
2196
- if (p) return l(d === "parallel" ? "vertical" : "parallel", f);
2197
- d === "parallel" ? a(f) : c(f);
2560
+ function l(f, d, p = !1) {
2561
+ if (p) return l(f === "parallel" ? "vertical" : "parallel", d);
2562
+ f === "parallel" ? a(d) : c(d);
2198
2563
  }
2199
2564
  const h = [];
2200
- for (let d = 0; d < t.length; d++) {
2201
- const f = t[d];
2202
- if (u !== f)
2203
- if (f.userData.isWindow && o.push(f), f.parallel(u, n)) a(f);
2204
- else if (f.vertical(u, n)) c(f);
2565
+ for (let f = 0; f < t.length; f++) {
2566
+ const d = t[f];
2567
+ if (u !== d)
2568
+ if (d.userData.isWindow && o.push(d), d.parallel(u, n)) a(d);
2569
+ else if (d.vertical(u, n)) c(d);
2205
2570
  else {
2206
- const y = e.get(f)?.reduce((g, x) => (x.sourcePoint && (g.has(x.sourcePoint) || g.set(x.sourcePoint, []), g.get(x.sourcePoint)?.push(x)), g), /* @__PURE__ */ new Map());
2207
- y && y.size > 1 ? h.push(() => {
2208
- const g = [...y.values()].map(
2209
- (L) => L.map((M) => s.includes(M.line) ? "parallel" : i.includes(M.line) ? "vertical" : null).filter((M) => !!M)
2210
- ).map((L) => [...new Set(L)]), x = g[0], m = g[1];
2571
+ const g = e.get(d)?.reduce((y, x) => (x.sourcePoint && (y.has(x.sourcePoint) || y.set(x.sourcePoint, []), y.get(x.sourcePoint)?.push(x)), y), /* @__PURE__ */ new Map());
2572
+ g && g.size > 1 ? h.push(() => {
2573
+ const y = [...g.values()].map(
2574
+ (w) => w.map((M) => s.includes(M.line) ? "parallel" : i.includes(M.line) ? "vertical" : null).filter((M) => !!M)
2575
+ ).map((w) => [...new Set(w)]), x = y[0], m = y[1];
2211
2576
  if (x.length === 1 && m.length === 1) {
2212
- if (x[0] === m[0]) return l(x[0], f, !0);
2577
+ if (x[0] === m[0]) return l(x[0], d, !0);
2213
2578
  if (x.length === 1) {
2214
- if (m.includes(x[0])) return l(x[0], f, !0);
2579
+ if (m.includes(x[0])) return l(x[0], d, !0);
2215
2580
  if (m.length === 1 && x.includes(m[0]))
2216
- return l(m[0], f, !0);
2581
+ return l(m[0], d, !0);
2217
2582
  }
2218
2583
  }
2219
- c(f);
2220
- }) : c(f);
2584
+ c(d);
2585
+ }) : c(d);
2221
2586
  }
2222
2587
  }
2223
- return h.forEach((d) => d()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
2588
+ return h.forEach((f) => f()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
2224
2589
  }
2225
- function mt(u, t, e, n, s) {
2590
+ function St(u, t, e, n, s) {
2226
2591
  const i = [], r = /* @__PURE__ */ new Map();
2227
2592
  u.forEach((c) => {
2228
2593
  const l = e.projectPoint(c.start, !1);
@@ -2239,91 +2604,72 @@ function mt(u, t, e, n, s) {
2239
2604
  }
2240
2605
  return o.flatMap((c) => {
2241
2606
  const l = c.flatMap((p) => {
2242
- const y = p.userData;
2243
- return y.points.map((g) => {
2244
- const x = t.projectPoint(g, !1);
2245
- return x.userData = y, x;
2607
+ const g = p.userData;
2608
+ return g.points.map((y) => {
2609
+ const x = t.projectPoint(y, !1);
2610
+ return x.userData = g, x;
2246
2611
  });
2247
2612
  });
2248
- l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
2249
- const h = /* @__PURE__ */ new Map(), d = [];
2250
- let f = [];
2251
- return l.forEach((p, y) => {
2252
- h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...d]), d.length = 0), h.set(p.userData, (h.get(p.userData) ?? 0) + 1);
2253
- for (const g of h.values()) if (g !== 2) return;
2254
- d.push(...h.keys()), h.clear();
2255
- }), f.push([...d]), f;
2613
+ l.sort((p, g) => p.distance(t.start) - g.distance(t.start));
2614
+ const h = /* @__PURE__ */ new Map(), f = [];
2615
+ let d = [];
2616
+ return l.forEach((p, g) => {
2617
+ h.size === 0 && g > 0 && l[g - 1].distance(p) > n && (d.push([...f]), f.length = 0), h.set(p.userData, (h.get(p.userData) ?? 0) + 1);
2618
+ for (const y of h.values()) if (y !== 2) return;
2619
+ f.push(...h.keys()), h.clear();
2620
+ }), d.push([...f]), d;
2256
2621
  });
2257
2622
  }
2258
- function wt(u, t, e, n) {
2259
- const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
2260
- u.forEach((p) => {
2261
- const y = e.projectPoint(p.start, !1);
2262
- y && (y.userData = p, s.set(p, y), o.push(y)), p.points.forEach((g, x) => {
2263
- const m = t.projectPoint(g, !1);
2264
- m && (m.userData = p, x === 0 ? i.set(p, m) : r.set(p, m));
2623
+ function Et(u, t, e, n) {
2624
+ const s = /* @__PURE__ */ new Map(), i = [], r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
2625
+ u.forEach((d) => {
2626
+ const p = e.projectValue(d.start), g = e.projectPoint(d.start, !1), y = { value: p, line: d, point: g, index: -1 };
2627
+ s.set(d, y), i.push(y), d.points.forEach((x, m) => {
2628
+ const w = t.projectValue(x);
2629
+ m === 0 ? r.set(d, w) : o.set(d, w);
2265
2630
  });
2266
- }), o.sort((p, y) => y.distance(e.start) - p.distance(e.start));
2267
- const a = o.map((p) => {
2268
- const y = p.userData, g = i.get(y), x = r.get(y), m = new D(g, x), L = [];
2269
- for (let M = 0; M < o.length; M++) {
2270
- const S = o[M];
2271
- if (p !== S && p.distance(S) < n) {
2272
- const A = S.userData, E = i.get(A), T = r.get(A);
2273
- (m.isPointOnSegment(E) || m.isPointOnSegment(T)) && L.push(M);
2274
- }
2275
- }
2276
- return L;
2277
- });
2278
- function c(p, y, g = /* @__PURE__ */ new Set()) {
2279
- if (g.has(p)) return g;
2280
- const x = y[p];
2281
- g.add(p);
2282
- for (let m = 0; m < x.length; m++) {
2283
- const L = x[m];
2284
- c(L, y, g);
2285
- }
2286
- return g;
2287
- }
2288
- const l = /* @__PURE__ */ new Set();
2289
- let h = [];
2290
- for (let p = 0; p < o.length; p++) {
2291
- if (l.has(p)) continue;
2292
- const y = c(p, a), g = [];
2293
- if (y.forEach((x) => {
2294
- l.add(x), g.push(o[x].userData);
2295
- }), g.length > 2) {
2296
- const x = g.map((S) => s.get(S));
2297
- x.sort((S, A) => A.distance(e.start) - S.distance(e.start));
2298
- const m = x[0], L = x[x.length - 1];
2299
- if (m.distance(L) > n) {
2300
- const S = [...g].sort((R, v) => v.length() - R.length()), A = S[0], E = S[1], T = s.get(A), C = s.get(E), N = A.length(), O = E.length(), q = A.projectLineSegment(E), U = q.length();
2301
- if (T.distance(C) || O / N > 0.5 && U / O < 0.5) {
2302
- const R = [A], v = [E];
2303
- for (let K = 0; K < x.length; K++) {
2304
- const F = x[K], W = F.userData;
2305
- if (F === T || F === C) continue;
2306
- const Ht = E.projectLineSegment(W), Jt = Ht.length();
2307
- C.distance(F) <= n && Jt / O > 0 ? v.push(W) : R.push(W);
2308
- }
2309
- h.push(R, v);
2310
- } else {
2311
- const R = Math.floor(g.length * 0.5);
2312
- h.push(g.slice(0, R), g.slice(R));
2631
+ }), i.sort((d, p) => p.value - d.value).forEach((d, p) => d.index = p);
2632
+ const a = new ct(u.length), c = new Yt(u);
2633
+ function l(d, p) {
2634
+ return d.point.distance(p.point) <= n;
2635
+ }
2636
+ function h(d, p, g) {
2637
+ const y = r.get(d.line), x = o.get(d.line), m = y < x ? y : x, w = y > x ? y : x;
2638
+ return m >= p && m <= g || w >= p && w <= g || p >= m && p <= w || g >= m && g <= w;
2639
+ }
2640
+ for (let d = 0; d < i.length; d++) {
2641
+ const p = i[d], { line: g } = p, y = r.get(g), x = o.get(g), m = y < x ? y : x, w = y > x ? y : x;
2642
+ for (let M = d - 1; M >= 0; M--) {
2643
+ const E = i[M];
2644
+ if (l(E, p)) {
2645
+ if (h(E, m, w)) {
2646
+ a.union(c.getIndex(g), c.getIndex(E.line));
2647
+ break;
2313
2648
  }
2314
- continue;
2315
- }
2649
+ } else break;
2316
2650
  }
2317
- h.push(g);
2318
2651
  }
2319
- const d = new be(), f = new Te(u.length);
2320
- return h.forEach((p) => {
2321
- const y = p.map((g) => d.getIndex(g));
2322
- for (let g = 1; g < y.length; g++)
2323
- f.union(y[0], y[g]);
2324
- }), h = f.getAllSets().valueArray.map((p) => p.map((y) => d.getLine(y))), h;
2652
+ let f = a.getAllSets().valueArray.map((d) => d.map((p) => c.getLine(p)));
2653
+ return f = f.map((d) => {
2654
+ if (d.length <= 2) return [d];
2655
+ const p = d.map((P) => s.get(P)).sort((P, I) => P.value - I.value), g = p[0], y = p[p.length - 1];
2656
+ if (g.point.distance(y.point) < n) return [d];
2657
+ const x = [...p].sort((P, I) => I.line.length() - P.line.length()), m = x[0], w = x[0], M = m.line.length(), E = w.line.length(), A = m.line.projectLineSegment(w.line), S = A.length();
2658
+ if (m.point.distance(w.point) > n || E / M > 0.5 && S / E < 0.5) {
2659
+ const P = [m.line], I = [w.line];
2660
+ for (let C = 0; C < p.length; C++) {
2661
+ const N = p[C];
2662
+ if (N === m || N === w) continue;
2663
+ const _ = w.line.projectLineSegment(N.line), G = _.length();
2664
+ w.point.distance(N.point) <= n && G / E > 0 ? I.push(N.line) : P.push(N.line);
2665
+ }
2666
+ return [P, I];
2667
+ }
2668
+ const T = Math.floor(p.length * 0.5);
2669
+ return [p.slice(0, T).map((P) => P.line), p.slice(T).map((P) => P.line)];
2670
+ }).flat(1), f;
2325
2671
  }
2326
- function Mt(u, t) {
2672
+ function At(u, t) {
2327
2673
  function e(i, r = /* @__PURE__ */ new Set()) {
2328
2674
  if (r.has(i)) return r;
2329
2675
  r.add(i);
@@ -2344,28 +2690,28 @@ function Mt(u, t) {
2344
2690
  }
2345
2691
  return s;
2346
2692
  }
2347
- function Ce(u, t, e, n, s, i) {
2693
+ function Ue(u, t, e, n, s, i) {
2348
2694
  const {
2349
2695
  principalAxisThreshold: r = 0.3,
2350
- crossAxistThreshold: o = 0.06,
2696
+ crossAxistThreshold: o = 0.08,
2351
2697
  groupMethod: a = "principalAndCross"
2352
2698
  } = i ?? {}, c = {
2353
2699
  cross: () => [
2354
- ...wt(u, n, e, o),
2355
- ...wt(t, e, n, o)
2700
+ ...Et(u, n, e, o),
2701
+ ...Et(t, e, n, o)
2356
2702
  ],
2357
2703
  principalAndCross: () => [
2358
- ...mt(u, n, e, r, o),
2359
- ...mt(t, e, n, r, o)
2704
+ ...St(u, n, e, r, o),
2705
+ ...St(t, e, n, r, o)
2360
2706
  ],
2361
2707
  originalInterPoint: () => [
2362
- ...Mt(u, s),
2363
- ...Mt(t, s)
2708
+ ...At(u, s),
2709
+ ...At(t, s)
2364
2710
  ]
2365
2711
  };
2366
2712
  return c[a] ? c[a]() : c.originalInterPoint();
2367
2713
  }
2368
- function Ne(u, t) {
2714
+ function qe(u, t) {
2369
2715
  const e = /* @__PURE__ */ new Set();
2370
2716
  return u.forEach((n) => {
2371
2717
  const s = /* @__PURE__ */ new Map();
@@ -2381,141 +2727,144 @@ function Ne(u, t) {
2381
2727
  }
2382
2728
  }), u.map((n) => n.filter((s) => !e.has(s)));
2383
2729
  }
2384
- function Be(u, t = 0.1, e) {
2730
+ function ze(u, t = 0.1, e) {
2385
2731
  const { fittingMethod: n = "average" } = e ?? {};
2386
2732
  return u.map((s) => {
2387
2733
  if (s.length === 0) return;
2388
2734
  if (s.length === 1) return s[0];
2389
2735
  const i = [];
2390
- s.forEach((h) => i.push(h.start.clone(), h.end.clone()));
2391
- const r = n === "average" ? D.mergeLines(...s) : D.mergeLinesByMaxlength(...s);
2392
- r.userData.rooftopPz = Math.min(
2393
- ...s.map((h) => {
2394
- const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } = h.userData;
2395
- return Object.assign(r.userData, y), p ?? 1 / 0;
2396
- })
2397
- ), r.userData.rooftopPz === 1 / 0 && (r.userData.rooftopPz = 0);
2398
- let o = 1 / 0, a = -1 / 0;
2399
- const c = s[0].normal().normalize();
2400
- o = 1 / 0, a = -1 / 0, i.forEach((h) => {
2401
- const d = h.x * c.x + h.y * c.y;
2402
- o = Math.min(o, d), a = Math.max(a, d);
2736
+ s.forEach((d) => i.push(d.start.clone(), d.end.clone()));
2737
+ const r = n === "average" ? L.mergeLines(...s) : L.mergeLinesByMaxlength(...s);
2738
+ let o = [], a = [];
2739
+ s.forEach((d) => {
2740
+ const { drawDoorData: p, drawWindow: g, rooftopPz: y, isWindow: x, ...m } = d.userData;
2741
+ Object.assign(r.userData, m), o.push(y ?? 1 / 0), x && (a.push(...g), r.userData.isWindow = !0);
2742
+ }), a.length && (r.userData.drawWindow = a, _t(r)), r.userData.rooftopPz = Math.min(...o), r.userData.rooftopPz === 1 / 0 && (r.userData.rooftopPz = 0);
2743
+ let c = 1 / 0, l = -1 / 0;
2744
+ const h = s[0].normal().normalize();
2745
+ c = 1 / 0, l = -1 / 0, i.forEach((d) => {
2746
+ const p = d.x * h.x + d.y * h.y;
2747
+ c = Math.min(c, p), l = Math.max(l, p);
2403
2748
  });
2404
- const l = a - o;
2405
- return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
2749
+ const f = l - c;
2750
+ return f >= t && (r.userData.wallWidth = f), s.forEach((d) => d.userData.fittedLine = r), r.currentData.isFittedLine = !0, r;
2406
2751
  }).filter((s) => !!s);
2407
2752
  }
2408
- function Oe(u, t, e) {
2409
- const { snapThreshold: n = 0.2 } = e ?? {}, s = new Y(), i = new B(I.fromByLineSegment(...u)), r = new D(), o = /* @__PURE__ */ new Map();
2410
- u.forEach((d) => {
2411
- d.userData.isDoor || (i.insert(d), d.points.forEach((f) => s.insert(f, d)));
2753
+ function _e(u, t, e) {
2754
+ const { snapThreshold: n = 0.2 } = e ?? {}, s = new q(), i = new j(R.fromByLineSegment(...u)), r = new L(), o = /* @__PURE__ */ new Map();
2755
+ u.forEach((f) => {
2756
+ f.userData.isDoor || (i.insert(f), f.points.forEach((d) => s.insert(d, f)));
2412
2757
  });
2413
- function a(d, f) {
2414
- o.has(d) || o.set(d, []), o.get(d)?.push(f);
2415
- }
2416
- function c(d, f) {
2417
- if (i.queryPoint(d).length > 1) return;
2418
- const p = f.direction().multiplyScalar(n);
2419
- r.set(d, d), r.start.add(p), r.end.add(p.multiplyScalar(-1));
2420
- const y = /* @__PURE__ */ new Map(), g = i.queryLineSegment(r).filter((x) => x.line !== f).map((x) => {
2758
+ function a(f, d) {
2759
+ o.has(f) || o.set(f, []), o.get(f)?.push(d);
2760
+ }
2761
+ function c(f, d) {
2762
+ if (i.queryPoint(f).length > 1) return;
2763
+ const p = d.direction().multiplyScalar(n);
2764
+ r.set(f, f), r.start.add(p), r.end.add(p.multiplyScalar(-1));
2765
+ const g = /* @__PURE__ */ new Map(), y = i.queryLineSegment(r).filter((x) => x.line !== d).map((x) => {
2421
2766
  const m = x.line.getIntersection(r);
2422
- return y.set(x.line, m), x.line;
2767
+ return g.set(x.line, m), x.line;
2423
2768
  }).sort((x, m) => {
2424
- const L = y.get(x), M = y.get(m);
2425
- return L && M ? L.distance(d) - M.distance(d) : 0;
2769
+ const w = g.get(x), M = g.get(m);
2770
+ return w && M ? w.distance(f) - M.distance(f) : 0;
2426
2771
  });
2427
- if (g.length) return y.get(g[0]);
2772
+ if (y.length) return g.get(y[0]);
2428
2773
  }
2429
- function l(d, f) {
2430
- let p = c(d, f);
2774
+ function l(f, d) {
2775
+ let p = c(f, d);
2431
2776
  if (p)
2432
- return a(f, new D(d.clone(), p.clone()));
2433
- if (s.queryPoint(d).filter((L) => L.userData !== f).length !== 0 || i.queryCircle(d, 1e-3).filter((L) => L.line !== f).length > 0) return;
2434
- const g = s.queryCircle(d, n).filter((L) => L.userData !== f && L.userData?.vertical(f)).sort((L, M) => L.point.distance(d) - M.point.distance(d));
2435
- if (!g.length) return;
2436
- const x = g[0], m = x.userData?.projectPoint(d, !1);
2777
+ return a(d, new L(f.clone(), p.clone()));
2778
+ if (s.queryPoint(f).filter((w) => w.userData !== d).length !== 0 || i.queryCircle(f, 1e-3).filter((w) => w.line !== d).length > 0) return;
2779
+ const y = s.queryCircle(f, n).filter((w) => w.userData !== d && w.userData?.vertical(d)).sort((w, M) => w.point.distance(f) - M.point.distance(f));
2780
+ if (!y.length) return;
2781
+ const x = y[0], m = x.userData?.projectPoint(f, !1);
2437
2782
  if (m) {
2438
- const L = x.userData;
2439
- a(f, new D(d.clone(), m.clone())), a(L, new D(x.point.clone(), m.clone()));
2783
+ const w = x.userData;
2784
+ a(d, new L(f.clone(), m.clone())), a(w, new L(x.point.clone(), m.clone()));
2440
2785
  }
2441
2786
  }
2442
- function h(d, f, p) {
2443
- if (p.length) {
2444
- const y = p.map(({ line: g }) => {
2445
- if (g.userData.fittedLine && (g = g.userData.fittedLine), g.vertical(d)) {
2446
- const x = g.projectPoint(f, !0);
2447
- return x && f.distance(x) / d.length() > 0.9 ? void 0 : x;
2448
- }
2449
- }).filter((g) => !!g).sort((g, x) => g.distance(f) - x.distance(f));
2450
- if (y.length) return y[0];
2451
- }
2787
+ function h(f, d, p) {
2788
+ return null;
2452
2789
  }
2453
- for (let d = 0; d < u.length; d++) {
2454
- const f = u[d], y = (t.get(f) ?? []).reduce((m, L) => (L.sourcePoint === f.start ? m[0].push(L) : m[1].push(L), m), [[], []]), [g, x] = f.points.map((m, L) => {
2790
+ for (let f = 0; f < u.length; f++) {
2791
+ const d = u[f], g = (t.get(d) ?? []).reduce((m, w) => (w.sourcePoint === d.start ? m[0].push(w) : m[1].push(w), m), [[], []]), [y, x] = d.points.map((m, w) => {
2455
2792
  if (!s.queryPoint(m, !0).length) {
2456
- const M = h(f, m, y[L]);
2793
+ const M = h(d, m, g[w]);
2457
2794
  if (M)
2458
- m.copy(M), s.update(m), i.update(f);
2795
+ m.copy(M), s.update(m), i.update(d);
2459
2796
  else return !1;
2460
2797
  }
2461
2798
  return !0;
2462
2799
  });
2463
- g || l(f.start, f), x || l(f.end, f);
2800
+ y || l(d.start, d), x || l(d.end, d);
2464
2801
  }
2465
- return o.forEach((d, f) => {
2466
- const p = D.mergeLines(f, ...d);
2467
- f.set(p.start, p.end);
2802
+ return o.forEach((f, d) => {
2803
+ const p = L.mergeLines(d, ...f);
2804
+ d.set(p.start, p.end);
2468
2805
  }), s.clear(), i.clear(), u;
2469
2806
  }
2470
- function je(u) {
2471
- const t = /* @__PURE__ */ new Set();
2472
- for (let e = 0; e < u.length; e++) {
2473
- const n = u[e], s = n.userData.fittedLine;
2474
- s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : X(n);
2475
- }
2476
- t.forEach((e) => X(e));
2807
+ function ke(u) {
2808
+ const t = u.filter((n) => n.userData.isBayWindow), e = /* @__PURE__ */ new Set();
2809
+ return t.forEach((n) => {
2810
+ let s = Wt(u, [n], !1);
2811
+ if (s = s.filter((i) => i.some((r) => r.userData.isWindow && O.hasType(r, "bayWindow"))), s.length) {
2812
+ const i = s[0], r = $();
2813
+ i.forEach((o) => {
2814
+ O.clear(o), O.set(o, r, "bayWindow"), e.add(o);
2815
+ });
2816
+ } else O.clear(n);
2817
+ }), u.forEach((n) => e.has(n) || O.clear(n)), u;
2477
2818
  }
2478
- function Fe(u) {
2479
- for (let t = 0; t < u.length; t++) {
2480
- const e = u[t];
2481
- let { endIntersection: n, startIntersection: s } = e.userData;
2482
- if (!(!n || !s)) {
2483
- if (s.userData.fittedLine && (s = s.userData.fittedLine), n.userData.fittedLine && (n = n.userData.fittedLine), e.parallel(s))
2484
- e.start.distance(s.start) < e.start.distance(s.end) ? e.start.copy(s.start) : e.start.copy(s.end);
2819
+ function Ye(u) {
2820
+ const t = $();
2821
+ for (let e = 0; e < u.length; e++) {
2822
+ const n = u[e];
2823
+ let { endIntersection: s, startIntersection: i } = n.userData;
2824
+ if (O.replace(n, t, "door") || O.set(n, t, "door"), !(!s || !i)) {
2825
+ if (i.userData.fittedLine && (i = i.userData.fittedLine), s.userData.fittedLine && (s = s.userData.fittedLine), n.parallel(i))
2826
+ n.start.distance(i.start) < n.start.distance(i.end) ? n.start.copy(i.start) : n.start.copy(i.end);
2485
2827
  else {
2486
- const i = s.projectPoint(e.start);
2487
- i && e.start.copy(i);
2828
+ const r = i.projectPoint(n.start);
2829
+ r && n.start.copy(r);
2488
2830
  }
2489
- if (e.parallel(n))
2490
- e.end.distance(n.start) < e.end.distance(n.end) ? e.end.copy(n.start) : e.end.copy(n.end);
2831
+ if (n.parallel(s))
2832
+ n.end.distance(s.start) < n.end.distance(s.end) ? n.end.copy(s.start) : n.end.copy(s.end);
2491
2833
  else {
2492
- const i = n.projectPoint(e.end);
2493
- i && e.end.copy(i);
2834
+ const r = s.projectPoint(n.end);
2835
+ r && n.end.copy(r);
2494
2836
  }
2495
2837
  }
2496
2838
  }
2497
2839
  return u;
2498
2840
  }
2499
- function Dt(u, t = 0.01) {
2500
- const e = new Y();
2841
+ function Tt(u, t = 0.01) {
2842
+ const e = new q();
2501
2843
  return u.forEach((n) => n.points.forEach((s) => e.insert(s, n))), u = u.filter((n) => {
2502
2844
  if (n.length() <= t) {
2503
2845
  const s = e.queryPoint(n.start).filter((r) => r.userData !== n).length === 0, i = e.queryPoint(n.end).filter((r) => r.userData !== n).length === 0;
2504
2846
  if (s || i) return !1;
2505
2847
  }
2506
2848
  return !0;
2507
- }), u = D.brokenLineMerging(u, (n, s) => {
2508
- s.forEach((i) => $(n, i)), X(n);
2849
+ }), u = L.brokenLineMerging(u, (n, s) => {
2850
+ s.forEach((i) => U(n, i)), K(n);
2509
2851
  }), e.clear(), u;
2510
2852
  }
2511
- function qe(u) {
2512
- const { lines: t, groups: e, removeLines: n } = Ft(u);
2513
- return e.forEach((s) => {
2514
- const i = tt();
2515
- s.forEach((r) => Object.assign(r.userData, { groupId: i, groupType: "doubleWall" }));
2516
- }), n.forEach((s) => Object.assign(s.userData, { groupId: "default", groupType: "wall" })), u = t, u;
2853
+ function bt(u) {
2854
+ const t = [];
2855
+ u = u.filter((i) => i.userData.isBayWindow || i.userData.isWindow ? (t.push(i), !1) : !0);
2856
+ const { newLines: e, rings: n } = Xt(u), s = new Set(n.flat());
2857
+ return n.forEach((i) => {
2858
+ const r = $();
2859
+ i.forEach((o) => {
2860
+ O.replace(o, r, "doubleWall") || O.set(o, r, "doubleWall");
2861
+ });
2862
+ }), e.forEach((i) => {
2863
+ s.has(i) || O.hasType(i, "bayWindow") || Object.assign(i.userData, O.set(i, "default", "wall"));
2864
+ }), e.push(...t), e;
2517
2865
  }
2518
- class Gt {
2866
+ class Ht {
2867
+ // private
2519
2868
  /**
2520
2869
  * 轴对齐垂直修正
2521
2870
  * @param lines 待调整线段组
@@ -2524,43 +2873,43 @@ class Gt {
2524
2873
  */
2525
2874
  static correction(t, e, n) {
2526
2875
  const s = t.indexOf(e);
2527
- t = t.map((L) => L.clone()), e = s > -1 ? t[s] : e, t = Ie(t);
2528
- const i = ve(t), { parallelLines: r, verticalLines: o, doorLines: a, windowLines: c } = Re(e, t, i, 25), l = e.normal(), h = e.center, d = e.direction(), f = new D(
2529
- h.clone().add(l.clone().multiplyScalar(-1e3)),
2530
- h.clone().add(l.clone().multiplyScalar(1e3))
2531
- ), p = new D(
2532
- h.clone().add(d.clone().multiplyScalar(-1e3)),
2533
- h.clone().add(d.clone().multiplyScalar(1e3))
2876
+ t = t.map((x) => x.clone()), e = s > -1 ? t[s] : e, t = Oe(t);
2877
+ const i = Fe(t), { parallelLines: r, verticalLines: o, doorLines: a } = Ge(e, t, i, 25), c = e.normal(), l = e.center, h = e.direction(), f = new L(
2878
+ l.clone().add(c.clone().multiplyScalar(-1e3)),
2879
+ l.clone().add(c.clone().multiplyScalar(1e3))
2880
+ ), d = new L(
2881
+ l.clone().add(h.clone().multiplyScalar(-1e3)),
2882
+ l.clone().add(h.clone().multiplyScalar(1e3))
2534
2883
  );
2535
- let y = Ce(r, o, f, p, i, n);
2536
- y = Ne(y, i);
2537
- let g = Be(y, 0.1, n);
2538
- g = D.brokenLineMerging(g, $), X(...g), g = Oe(g, i, n), je(c), g = ft(g, 1e-9), g = Dt(g, 0.15);
2539
- const { removeClosedLine: x = !0, wallGroup: m = !0 } = n ?? {};
2540
- return x && (g = Ft(g).lines, m && (g = Ae.complementSide(g), g = D.brokenLineMerging(g, $), X(...g), g = ft(g, 1e-9), g = qe(g)), g = Dt(g, 0.15)), Fe(a), g.push(...a), g;
2884
+ let p = Ue(r, o, f, d, i, n);
2885
+ p = qe(p, i);
2886
+ let g = ze(p, 0.1, n);
2887
+ g = L.brokenLineMerging(g, U), g = _e(g, i, n), g = ot(g, 1e-9), g = Tt(g, 0.15);
2888
+ const { wallGroup: y = !0 } = n ?? {};
2889
+ return g = ke(g), y && (g = bt(g), g = kt.complementSide(g), g = L.brokenLineMerging(g, U), K(...g), g = ot(g, 1e-9), g = bt(g)), g = Tt(g, 0.15), g = L.brokenLineMerging(g, U), K(...g), Ye(a), g.push(...a), g;
2541
2890
  }
2542
2891
  }
2543
- const Ge = new D(
2544
- new w(0, 0),
2545
- new w(0, 1)
2892
+ const We = new L(
2893
+ new D(0, 0),
2894
+ new D(0, 1)
2546
2895
  );
2547
- function Ue(u) {
2896
+ function $t(u) {
2548
2897
  const t = [...u].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
2549
- let r = parseInt(Ge.includedAngle(i) + "");
2898
+ let r = parseInt(We.includedAngle(i) + "");
2550
2899
  return r > 90 && (r = 180 - r), r;
2551
2900
  }), n = /* @__PURE__ */ new Map();
2552
2901
  return e.forEach((i, r) => {
2553
2902
  n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
2554
2903
  }), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
2555
2904
  }
2556
- function ze(u) {
2905
+ function Jt(u) {
2557
2906
  let t = [], e = -1;
2558
2907
  const n = [];
2559
2908
  return u.forEach(({ start: i, end: r, ...o }, a) => {
2560
2909
  n.push(i.z ?? 0, r.z ?? 0);
2561
- const c = new D(
2562
- w.from(i),
2563
- w.from(r)
2910
+ const c = new L(
2911
+ D.from(i),
2912
+ D.from(r)
2564
2913
  );
2565
2914
  c.userData = o, t.push(c), o.isVerticalReferenceLine && (e = a);
2566
2915
  }), {
@@ -2569,7 +2918,17 @@ function ze(u) {
2569
2918
  verticalReferenceIndex: e
2570
2919
  };
2571
2920
  }
2572
- const _e = {
2921
+ function Kt(u) {
2922
+ if (u.length < 3) return 0;
2923
+ let t = 0;
2924
+ const e = u.length;
2925
+ for (let n = 0; n < e; n++) {
2926
+ const s = (n + 1) % e;
2927
+ t += u[n].x * u[s].y, t -= u[s].x * u[n].y;
2928
+ }
2929
+ return Math.abs(t) / 2;
2930
+ }
2931
+ const Ve = {
2573
2932
  Unitless: 1,
2574
2933
  // 无单位,1米 = 1(无单位)
2575
2934
  Inches: 39.37007874015748,
@@ -2613,27 +2972,27 @@ const _e = {
2613
2972
  Parsecs: 3240779289666404e-32
2614
2973
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
2615
2974
  };
2616
- function Lt(u) {
2975
+ function Pt(u) {
2617
2976
  const t = [];
2618
2977
  for (let e = 0; e < u.length; e++)
2619
- t.push(new D(
2978
+ t.push(new L(
2620
2979
  u[e].clone(),
2621
2980
  u[(e + 1) % u.length].clone()
2622
2981
  ));
2623
2982
  return t;
2624
2983
  }
2625
- function St(u) {
2984
+ function It(u) {
2626
2985
  return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
2627
2986
  }
2628
- class k extends G {
2987
+ class W extends z {
2629
2988
  static name = "Dxf";
2630
2989
  shortLine = 0.04;
2631
2990
  width = 0.04;
2632
2991
  scale = 1;
2633
2992
  originalData = [];
2634
2993
  data = [];
2635
- originalBox = new I(0, 0, 0, 0);
2636
- box = new I(0, 0, 0, 0);
2994
+ originalBox = new R(0, 0, 0, 0);
2995
+ box = new R(0, 0, 0, 0);
2637
2996
  pointsGroups = [];
2638
2997
  wallsGroup = [];
2639
2998
  doors = [];
@@ -2670,9 +3029,9 @@ class k extends G {
2670
3029
  * @param data
2671
3030
  */
2672
3031
  preprocessing(t) {
2673
- let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = ze(t);
3032
+ let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = Jt(t);
2674
3033
  if (this.originalZAverage = s, n === -1) {
2675
- const r = Ue(e);
3034
+ const r = $t(e);
2676
3035
  n = e.indexOf(r);
2677
3036
  }
2678
3037
  const i = e[n];
@@ -2681,7 +3040,7 @@ class k extends G {
2681
3040
  data: t,
2682
3041
  setData(r) {
2683
3042
  e = r.map(({ start: o, end: a, ...c }) => {
2684
- const l = new D(w.from(o), w.from(a));
3043
+ const l = new L(D.from(o), D.from(a));
2685
3044
  return l.userData = c, l;
2686
3045
  }), t = r;
2687
3046
  }
@@ -2738,15 +3097,17 @@ class k extends G {
2738
3097
  createGroups() {
2739
3098
  const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
2740
3099
  if (!this.data[r]) return;
2741
- const [c, l, h, d] = this.data[r];
2742
- if (e.add(r), d)
2743
- return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
2744
- o.push([c, l]), h.forEach((f) => {
2745
- e.has(f) || i(f, o, r);
2746
- });
3100
+ const [c, l, h, f] = this.data[r];
3101
+ if (!this.lineSegments[r]?.userData.isBayWindow) {
3102
+ if (e.add(r), f)
3103
+ return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
3104
+ o.push([c, l]), h.forEach((d) => {
3105
+ e.has(d) || i(d, o, r);
3106
+ });
3107
+ }
2747
3108
  };
2748
3109
  return this.data.forEach((r, o) => {
2749
- if (!e.has(o)) {
3110
+ if (!this.lineSegments[o]?.userData.isBayWindow && !e.has(o)) {
2750
3111
  const a = [];
2751
3112
  i(o, a), t.push(a);
2752
3113
  }
@@ -2834,7 +3195,7 @@ class k extends G {
2834
3195
  break;
2835
3196
  }
2836
3197
  }
2837
- const e = this.mergeSameDirectionLine(Lt(t)), n = [e[0]];
3198
+ const e = this.mergeSameDirectionLine(Pt(t)), n = [e[0]];
2838
3199
  for (let s = 1; s < e.length; s++) {
2839
3200
  const i = e[s], r = e[(e.length + s - 1) % e.length];
2840
3201
  if (i.length() > this.width * 0.9) {
@@ -2849,7 +3210,7 @@ class k extends G {
2849
3210
  const a = e[s + 2];
2850
3211
  a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
2851
3212
  }
2852
- return n.length > 3 ? St(this.mergeSameDirectionLine(n)) : [];
3213
+ return n.length > 3 ? It(this.mergeSameDirectionLine(n)) : [];
2853
3214
  }
2854
3215
  /**
2855
3216
  * 移除短线段
@@ -2857,7 +3218,7 @@ class k extends G {
2857
3218
  * @param path
2858
3219
  */
2859
3220
  removeShortLine(t, e = this.shortLine) {
2860
- const n = Lt(t), s = [], i = Math.PI / 180;
3221
+ const n = Pt(t), s = [], i = Math.PI / 180;
2861
3222
  for (let r = 0; r < n.length; r++) {
2862
3223
  const o = n[r], a = o.length(), c = r;
2863
3224
  if (a > e || s.length === 0) {
@@ -2865,41 +3226,41 @@ class k extends G {
2865
3226
  continue;
2866
3227
  }
2867
3228
  let l = n[++r];
2868
- const h = s[s.length - 1], d = h.direction();
3229
+ const h = s[s.length - 1], f = h.direction();
2869
3230
  for (; r < n.length; ) {
2870
- const p = d.angleBetween(l.direction()) / i;
3231
+ const p = f.angleBetween(l.direction()) / i;
2871
3232
  if (l.length() <= e || p < 4 || p > 176)
2872
3233
  l = n[++r];
2873
3234
  else break;
2874
3235
  }
2875
3236
  if (!l) continue;
2876
- const f = n[r - 1];
2877
- if (h.length() > f.length()) {
3237
+ const d = n[r - 1];
3238
+ if (h.length() > d.length()) {
2878
3239
  const p = h.getIntersection(l);
2879
3240
  if (p) {
2880
- const y = h.points[1].clone(), g = l.points[0].clone();
2881
- h.points[1].copy(p), l.points[0].copy(p), h.length() < this.width ? (h.points[1].copy(y), l.points[0].copy(y)) : l.length() < this.width && (h.points[1].copy(g), l.points[0].copy(g));
3241
+ const g = h.points[1].clone(), y = l.points[0].clone();
3242
+ h.points[1].copy(p), l.points[0].copy(p), h.length() < this.width ? (h.points[1].copy(g), l.points[0].copy(g)) : l.length() < this.width && (h.points[1].copy(y), l.points[0].copy(y));
2882
3243
  } else
2883
3244
  h.points[1].copy(l.points[0]);
2884
3245
  s.push(l);
2885
3246
  } else
2886
3247
  r = c;
2887
3248
  }
2888
- return s.length > 3 ? St(s) : [];
3249
+ return s.length > 3 ? It(s) : [];
2889
3250
  }
2890
3251
  /** 线偏移
2891
3252
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
2892
3253
  */
2893
- lineOffset(t = k.EndType.etOpenSquare, e = k.JoinType.jtMiter, n = 1e4) {
2894
- let s = new xt.Paths();
2895
- const i = new xt.ClipperOffset(20, 0.25);
3254
+ lineOffset(t = W.EndType.etOpenSquare, e = W.JoinType.jtMiter, n = 1e4) {
3255
+ let s = new Lt.Paths();
3256
+ const i = new Lt.ClipperOffset(20, 0.25);
2896
3257
  return this.pointsGroups.forEach((r) => {
2897
3258
  const o = this.lineTopology(r).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
2898
3259
  i.AddPaths(o, e, t);
2899
3260
  }), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
2900
- let o = r.map((a) => w.from(a).divisionScalar(n));
2901
- return o = this.lineSegmentStraightening(o), t == k.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
2902
- }).filter((r) => r.length > 4 || Ot(r) > 0.2), this.dispatchEvent({
3261
+ let o = r.map((a) => D.from(a).divisionScalar(n));
3262
+ return o = this.lineSegmentStraightening(o), t == W.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
3263
+ }).filter((r) => r.length > 4 || Kt(r) > 0.2), this.dispatchEvent({
2903
3264
  type: "lineOffset",
2904
3265
  wallsGroup: this.wallsGroup
2905
3266
  }), this.wallsGroup;
@@ -2909,10 +3270,9 @@ class k extends G {
2909
3270
  */
2910
3271
  axisAlignCorr(t) {
2911
3272
  if (this.verticalReferenceLine) {
2912
- this.doorLineSegment;
2913
- const e = this.getLineSegments(), n = performance.now(), s = Gt.correction(e, this.verticalReferenceLine, t);
3273
+ const e = this.getLineSegments(), n = performance.now(), s = Ht.correction(e, this.verticalReferenceLine, t);
2914
3274
  console.log("垂直纠正消耗时间:", (performance.now() - n).toFixed(2), "ms", "处理线段数量:", e.length);
2915
- const i = et(s);
3275
+ const i = tt(s);
2916
3276
  this.set(i);
2917
3277
  } else
2918
3278
  throw new Error("未找到一条垂直纠正基准轴线");
@@ -2956,13 +3316,13 @@ class k extends G {
2956
3316
  * 线段数据转为原始json数据
2957
3317
  */
2958
3318
  lineDataToOriginalData(t, e) {
2959
- return et(t, this.originalZAverage, e);
3319
+ return tt(t, this.originalZAverage, e);
2960
3320
  }
2961
3321
  /**
2962
3322
  * 转为绘制数据
2963
3323
  */
2964
3324
  toDrawDataJson(t = "Millimeters") {
2965
- const e = _e[t], n = {
3325
+ const e = Ve[t], n = {
2966
3326
  unit: t,
2967
3327
  line: [],
2968
3328
  arc: [],
@@ -2976,13 +3336,13 @@ class k extends G {
2976
3336
  function i(c, l) {
2977
3337
  n.line.push([c.x * e, c.y * e, l.x * e, l.y * e, s]);
2978
3338
  }
2979
- function r(c, l, h, d) {
3339
+ function r(c, l, h, f) {
2980
3340
  n.arc.push([
2981
3341
  c.x * e,
2982
3342
  c.y * e,
2983
3343
  l * e,
2984
3344
  h,
2985
- d,
3345
+ f,
2986
3346
  s
2987
3347
  ]);
2988
3348
  }
@@ -2995,8 +3355,8 @@ class k extends G {
2995
3355
  }
2996
3356
  this.wallsGroup.forEach((c) => {
2997
3357
  for (let l = 0; l < c.length; l++) {
2998
- const h = c[l], d = l === c.length - 1 ? 0 : l + 1, f = c[d];
2999
- i(h, f);
3358
+ const h = c[l], f = l === c.length - 1 ? 0 : l + 1, d = c[f];
3359
+ i(h, d);
3000
3360
  }
3001
3361
  });
3002
3362
  const o = this.width * 0.2, a = [];
@@ -3006,29 +3366,29 @@ class k extends G {
3006
3366
  if (s = "cyan", l.length() < 1.2) {
3007
3367
  l.expansion(-o * 0.5);
3008
3368
  const h = c.normal();
3009
- let d = new D(
3369
+ let f = new L(
3010
3370
  l.start.clone(),
3011
3371
  l.start.clone().add(h.clone().multiplyScalar(l.length()))
3012
3372
  );
3013
- const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
3373
+ const d = f.clone().directionMove(f.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
3014
3374
  for (let M = 0; M < a.length; M++)
3015
- if (a[M].intersectRectangle(f)) {
3016
- d = new D(
3375
+ if (a[M].intersectRectangle(d)) {
3376
+ f = new L(
3017
3377
  l.start.clone(),
3018
3378
  l.start.clone().add(h.clone().multiplyScalar(-l.length()))
3019
3379
  );
3020
3380
  break;
3021
3381
  }
3022
- d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((M, S) => i(M, S));
3023
- const p = l.length(), y = d.length(), g = (p ** 2 + y ** 2) / (2 * y), x = d.end.clone().add(d.direction().multiplyScalar(-g)), [m, L] = this.getArcAngleRange(x, l.end, d.end);
3024
- r(x, g, Math.min(m, L), Math.max(m, L)), a.push(f);
3382
+ f.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((M, E) => i(M, E));
3383
+ const p = l.length(), g = f.length(), y = (p ** 2 + g ** 2) / (2 * g), x = f.end.clone().add(f.direction().multiplyScalar(-y)), [m, w] = this.getArcAngleRange(x, l.end, f.end);
3384
+ r(x, y, Math.min(m, w), Math.max(m, w)), a.push(d);
3025
3385
  } else
3026
- l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
3386
+ l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, f) => i(h, f)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, f) => i(h, f)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, f) => i(h, f));
3027
3387
  }), s = "yellow", this.lineSegments.forEach((c) => {
3028
3388
  if (!c.userData.isWindow) return !1;
3029
3389
  Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
3030
- const { p: h, width: d } = l, f = w.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), g = new D(p, y);
3031
- i(g.start, g.end), g.expandToRectangle(this.width, "bothSides").path2D((x, m) => i(x, m));
3390
+ const { p: h, width: f } = l, d = D.from(h), p = d.clone().add(c.direction().multiplyScalar(f * 0.5)), g = d.clone().add(c.direction().multiplyScalar(-f * 0.5)), y = new L(p, g);
3391
+ i(y.start, y.end), y.expandToRectangle(this.width, "bothSides").path2D((x, m) => i(x, m));
3032
3392
  });
3033
3393
  }), n;
3034
3394
  }
@@ -3053,14 +3413,14 @@ class k extends G {
3053
3413
  };
3054
3414
  i.width = s.width + r * 2, i.height = s.height + r * 2;
3055
3415
  const a = i.getContext("2d");
3056
- return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, d, f]) => {
3057
- a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h, d), a.closePath(), a.stroke();
3058
- }), s.arc.forEach(([c, l, h, d, f, p]) => {
3059
- a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
3416
+ return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, f, d]) => {
3417
+ a.strokeStyle = o[d], a.beginPath(), a.moveTo(c, l), a.lineTo(h, f), a.closePath(), a.stroke();
3418
+ }), s.arc.forEach(([c, l, h, f, d, p]) => {
3419
+ a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, f * (Math.PI / 180), d * (Math.PI / 180)), a.stroke();
3060
3420
  }), a.beginPath(), s.dimensionLine.forEach((c) => {
3061
- let [l, h, d, f] = c;
3062
- const p = Math.min(h, f), y = Math.max(h, f), g = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), x = (y - p) * 0.45;
3063
- a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(g, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(g - 0.1 * s.scale, p), a.lineTo(g + 0.1 * s.scale, p), a.moveTo(g, p), a.lineTo(g, x + p), a.moveTo(g, y), a.lineTo(g, y - x), a.moveTo(g - 0.1 * s.scale, y), a.lineTo(g + 0.1 * s.scale, y);
3421
+ let [l, h, f, d] = c;
3422
+ const p = Math.min(h, d), g = Math.max(h, d), y = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), x = (g - p) * 0.45;
3423
+ a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(y, p + (g - p) * 0.5), a.scale(1, -1), a.fillText((g - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(y - 0.1 * s.scale, p), a.lineTo(y + 0.1 * s.scale, p), a.moveTo(y, p), a.lineTo(y, x + p), a.moveTo(y, g), a.lineTo(y, g - x), a.moveTo(y - 0.1 * s.scale, g), a.lineTo(y + 0.1 * s.scale, g);
3064
3424
  }), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
3065
3425
  i.toBlob((l) => {
3066
3426
  c(l);
@@ -3094,7 +3454,7 @@ class k extends G {
3094
3454
  * @param filename
3095
3455
  */
3096
3456
  async downloadOriginalData(t) {
3097
- const e = et(this.getLineSegments()), n = JSON.stringify(e);
3457
+ const e = tt(this.getLineSegments()), n = JSON.stringify(e);
3098
3458
  if (typeof window < "u") {
3099
3459
  const s = new Blob([n], { type: "application/json" }), i = document.createElement("a");
3100
3460
  i.href = URL.createObjectURL(s), i.download = t, i.click();
@@ -3128,7 +3488,7 @@ class k extends G {
3128
3488
  * @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
3129
3489
  * @returns
3130
3490
  */
3131
- computedOriginalSize(t, e = new I(0, 0, 0, 0)) {
3491
+ computedOriginalSize(t, e = new R(0, 0, 0, 0)) {
3132
3492
  const n = t.flatMap((c) => [c.start.x, c.end.x]), s = t.flatMap((c) => [c.start.y, c.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
3133
3493
  return e.set(i, r, o, a), e;
3134
3494
  }
@@ -3156,8 +3516,8 @@ class k extends G {
3156
3516
  });
3157
3517
  }
3158
3518
  }
3159
- const z = new D();
3160
- class ke extends k {
3519
+ const k = new L();
3520
+ class Xe extends W {
3161
3521
  static name = "AngleCorrectionDxf";
3162
3522
  angle = 0;
3163
3523
  onAddFromParent(t) {
@@ -3168,24 +3528,24 @@ class ke extends k {
3168
3528
  let s = 0, i = null;
3169
3529
  for (let l = 0; l < e.originalData.length; l++) {
3170
3530
  const h = e.originalData[l];
3171
- if (z.start.copy(h.start), z.end.copy(h.end), h.isVerticalReferenceLine) {
3172
- const [d, f] = h.start.y < h.end.y ? [z.start, z.end] : [z.end, z.start];
3173
- s = -new D(d, f).direction().angleBetween(new w(0, 1), "angle", "360"), i = null;
3531
+ if (k.start.copy(h.start), k.end.copy(h.end), h.isVerticalReferenceLine) {
3532
+ const [f, d] = h.start.y < h.end.y ? [k.start, k.end] : [k.end, k.start];
3533
+ s = -new L(f, d).direction().angleBetween(new D(0, 1), "angle", "360"), i = null;
3174
3534
  break;
3175
3535
  }
3176
- (!i || z.length() > i.length()) && (i = z.clone(), i.userData.index = l);
3536
+ (!i || k.length() > i.length()) && (i = k.clone(), i.userData.index = l);
3177
3537
  }
3178
3538
  if (i) {
3179
3539
  e.originalData[i.userData.index].isVerticalReferenceLine = !0;
3180
3540
  const [l, h] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
3181
- s = -new D(l, h).direction().angleBetween(new w(0, 1), "angle", "360");
3541
+ s = -new L(l, h).direction().angleBetween(new D(0, 1), "angle", "360");
3182
3542
  }
3183
3543
  function r(l, h) {
3184
- return l.division(o).rotate(w.zero(), h * (Math.PI / 180));
3544
+ return l.division(o).rotate(D.zero(), h * (Math.PI / 180));
3185
3545
  }
3186
- const o = e.originalBox.center, a = w.zero(), c = e.originalData.map((l) => {
3187
- const h = r(a.copy(l.start), s).toJson(l.start.z), d = r(a.copy(l.end), s).toJson(l.start.z), f = Object.assign(J(l), { start: h, end: d });
3188
- return f.drawWindow && f.drawWindow.forEach((p) => p.p = r(a.copy(p.p), s).toJson(p.p.z)), f;
3546
+ const o = e.originalBox.center, a = D.zero(), c = e.originalData.map((l) => {
3547
+ const h = r(a.copy(l.start), s).toJson(l.start.z), f = r(a.copy(l.end), s).toJson(l.start.z), d = Object.assign(V(l), { start: h, end: f });
3548
+ return d.drawWindow && d.drawWindow.forEach((p) => p.p = r(a.copy(p.p), s).toJson(p.p.z)), d;
3189
3549
  });
3190
3550
  n.appendLineSegmentList.forEach((l) => {
3191
3551
  const h = l.clone();
@@ -3197,13 +3557,13 @@ class ke extends k {
3197
3557
  });
3198
3558
  }), await this.set(c, e.width, e.scale), this.lineOffset(), this.doorLineSegment = e.doorLineSegment.map((l) => {
3199
3559
  const h = l.clone();
3200
- return h.start.division(o).rotate(w.zero(), s * (Math.PI / 180)), h.end.division(o).rotate(w.zero(), s * (Math.PI / 180)), h;
3560
+ return h.start.division(o).rotate(D.zero(), s * (Math.PI / 180)), h.end.division(o).rotate(D.zero(), s * (Math.PI / 180)), h;
3201
3561
  }), this.angle = s, this.dispatchEvent({
3202
3562
  type: "updateData"
3203
3563
  });
3204
3564
  }
3205
3565
  }
3206
- class Ut extends G {
3566
+ class Zt extends z {
3207
3567
  static name = "Variable";
3208
3568
  originalLineVisible = !0;
3209
3569
  dxfVisible = !0;
@@ -3230,12 +3590,12 @@ class Ut extends G {
3230
3590
  if (t in this) return this[t];
3231
3591
  }
3232
3592
  }
3233
- class zt extends G {
3593
+ class Qt extends z {
3234
3594
  static name = "LineAnalysis";
3235
3595
  Dxf = null;
3236
3596
  Variable = null;
3237
3597
  lineSegmentList = [];
3238
- container = new P.Group();
3598
+ container = new v.Group();
3239
3599
  // 误差角度
3240
3600
  errorAngle = 4;
3241
3601
  width = 0.4;
@@ -3244,7 +3604,7 @@ class zt extends G {
3244
3604
  * @param parent
3245
3605
  */
3246
3606
  onAddFromParent(t) {
3247
- this.Dxf = t.findComponentByType(k), this.Variable = this.parent?.findComponentByType(Ut), this.Dxf.addEventListener("setDta", () => {
3607
+ this.Dxf = t.findComponentByType(W), this.Variable = this.parent?.findComponentByType(Zt), this.Dxf.addEventListener("setDta", () => {
3248
3608
  this.lineAnalysis(), this.dispatchEvent({ type: "analysisCompleted" });
3249
3609
  });
3250
3610
  }
@@ -3260,11 +3620,11 @@ class zt extends G {
3260
3620
  return {
3261
3621
  points: [
3262
3622
  // 第一条线
3263
- new w(t.x + o, t.y + a).add(r),
3264
- new w(e.x + o, e.y + a).add(i),
3623
+ new D(t.x + o, t.y + a).add(r),
3624
+ new D(e.x + o, e.y + a).add(i),
3265
3625
  // 第二条线
3266
- new w(t.x - o, t.y - a).add(r),
3267
- new w(e.x - o, e.y - a).add(i)
3626
+ new D(t.x - o, t.y - a).add(r),
3627
+ new D(e.x - o, e.y - a).add(i)
3268
3628
  ],
3269
3629
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
3270
3630
  rectIndices: [0, 1, 3, 2, 0]
@@ -3278,7 +3638,7 @@ class zt extends G {
3278
3638
  */
3279
3639
  addData(t, e) {
3280
3640
  const n = this.Dxf;
3281
- n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new D(t.clone(), e.clone()));
3641
+ n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new L(t.clone(), e.clone()));
3282
3642
  }
3283
3643
  /** 结果分析创建矩形
3284
3644
  * @param result
@@ -3286,14 +3646,14 @@ class zt extends G {
3286
3646
  createRectangle(t) {
3287
3647
  const e = this.Dxf, n = t.project, s = t.project2;
3288
3648
  n.includedAngle(s) > 135 && (s.points = [s.points[1], s.points[0]]), this.addData(n.points[0], s.points[0]), this.addData(n.points[1], s.points[1]);
3289
- const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(d);
3649
+ const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), f = n.points[0].clone(), d = n.points[1].clone(), p = d.direction(f);
3290
3650
  p.multiplyScalar(e.width * 0.5);
3291
- const y = d.clone().add(p), g = f.clone().add(p.multiplyScalar(-1)), x = d.direction(f), m = y.direction(g);
3651
+ const g = f.clone().add(p), y = d.clone().add(p.multiplyScalar(-1)), x = f.direction(d), m = g.direction(y);
3292
3652
  if (!(x.x > 0 && m.x < 0 || x.x < 0 && m.x > 0 || x.y > 0 && m.y < 0 || x.y < 0 && m.y > 0)) {
3293
- d.set(y.x, y.y), f.set(g.x, g.y);
3294
- for (let L = 1; L < o; L++) {
3295
- const M = l.clone().multiplyScalar(a * L), S = h.clone().multiplyScalar(c * L), A = d.clone().add(M), E = f.clone().add(S);
3296
- this.addData(A, E);
3653
+ f.set(g.x, g.y), d.set(y.x, y.y);
3654
+ for (let w = 1; w < o; w++) {
3655
+ const M = l.clone().multiplyScalar(a * w), E = h.clone().multiplyScalar(c * w), A = f.clone().add(M), S = d.clone().add(E);
3656
+ this.addData(A, S);
3297
3657
  }
3298
3658
  }
3299
3659
  }
@@ -3303,7 +3663,7 @@ class zt extends G {
3303
3663
  */
3304
3664
  buildQuadtree() {
3305
3665
  const t = this.Dxf, e = [];
3306
- this.quadtree = new B(t.originalBox, 2), t.lineSegments.forEach((n) => {
3666
+ this.quadtree = new j(t.originalBox, 2), t.lineSegments.forEach((n) => {
3307
3667
  n.userData?.isDoor || (this.quadtree?.insert({
3308
3668
  line: n,
3309
3669
  userData: e.length
@@ -3320,7 +3680,7 @@ class zt extends G {
3320
3680
  this.buildQuadtree();
3321
3681
  const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
3322
3682
  e.forEach((i, r) => {
3323
- const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
3683
+ const o = e[r], a = et.fromByLineSegment(o, this.width * 2, !1, -0.01);
3324
3684
  t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
3325
3685
  try {
3326
3686
  if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
@@ -3360,14 +3720,14 @@ class zt extends G {
3360
3720
  }
3361
3721
  }
3362
3722
  }
3363
- class Ye {
3723
+ class He {
3364
3724
  // 所有可查找的点位
3365
3725
  possibleDoorPoints = [];
3366
3726
  doorPoint = [];
3367
3727
  calculatedDoorPoint = [];
3368
3728
  dxf;
3369
3729
  // 包含所有点的虚拟网格
3370
- pointVirtualGrid = new Y();
3730
+ pointVirtualGrid = new q();
3371
3731
  // 只包含可查找点的虚拟网格
3372
3732
  findPointVirtualGrid;
3373
3733
  quadtree;
@@ -3379,17 +3739,17 @@ class Ye {
3379
3739
  doors = [];
3380
3740
  lineAnalysis;
3381
3741
  continueFind = !0;
3382
- constructor(t) {
3383
- this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new Y(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((i) => {
3384
- this.pointVirtualGrid.insert(i.start, i), this.pointVirtualGrid.insert(i.end, i);
3742
+ constructor(t, e) {
3743
+ this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new q(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((r) => {
3744
+ this.pointVirtualGrid.insert(r.start, r), this.pointVirtualGrid.insert(r.end, r);
3385
3745
  });
3386
- const { doorPoints: e, calculatedDoorPoint: n } = this.getDoorPoint();
3387
- this.doorPoint = e, this.calculatedDoorPoint = n;
3388
- const s = this.searchDoubleLinePoint();
3389
- this.addPointsExcludeRule((i, r, o) => {
3390
- const a = this.lineSegments.indexOf(i), c = s.get(a);
3391
- return typeof c == "number" ? c === -1 || c === o : !1;
3392
- }), this.addPointsExcludeRule((i, r) => !!this.doorPoint.find((o) => o.point.equal(r))), this.addPointsExcludeRule((i, r) => !!this.calculatedDoorPoint.find((o) => o.point.equal(r))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((i) => this.findPointVirtualGrid.insert(i.point, i.line)), this.handle();
3746
+ const { doorPoints: n, calculatedDoorPoint: s } = this.getDoorPoint();
3747
+ if (this.doorPoint = n, this.calculatedDoorPoint = s, e) return;
3748
+ const i = this.searchDoubleLinePoint();
3749
+ this.addPointsExcludeRule((r, o, a) => {
3750
+ const c = this.lineSegments.indexOf(r), l = i.get(c);
3751
+ return typeof l == "number" ? l === -1 || l === a : !1;
3752
+ }), this.addPointsExcludeRule((r, o) => !!this.doorPoint.find((a) => a.point.equal(o))), this.addPointsExcludeRule((r, o) => !!this.calculatedDoorPoint.find((a) => a.point.equal(o))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((r) => this.findPointVirtualGrid.insert(r.point, r.line)), this.handle();
3393
3753
  }
3394
3754
  handle() {
3395
3755
  this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.dxf.doors.length < 2 && this.dxf.doorLineSegment.push(...this.search(this.possibleDoorPoints, this.possibleDoorPoints, 0.6));
@@ -3420,18 +3780,18 @@ class Ye {
3420
3780
  );
3421
3781
  const a = [];
3422
3782
  return o.forEach((c) => {
3423
- const l = new D(c?.start, c?.end), h = l.length();
3783
+ const l = new L(c?.start, c?.end), h = l.length();
3424
3784
  if (h < n) return;
3425
- const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
3426
- for (let y = 0; y < 3; y++) {
3427
- const g = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), x = new D(
3428
- g,
3429
- g.clone().add(d.clone().multiplyScalar(1))
3785
+ const f = l.normal(), d = l.direction(), p = (h - r.width * 2) / 2;
3786
+ for (let g = 0; g < 3; g++) {
3787
+ const y = l.start.clone().add(d.clone().multiplyScalar(r.width + p * g)), x = new L(
3788
+ y,
3789
+ y.clone().add(f.clone().multiplyScalar(1))
3430
3790
  );
3431
- if (x.directionMove(d, -0.5), this.quadtree.queryLineSegment(x).length) return;
3791
+ if (x.directionMove(f, -0.5), this.quadtree.queryLineSegment(x).length) return;
3432
3792
  }
3433
3793
  a.push(l);
3434
- }), a;
3794
+ }), a.forEach((c) => c.userData.doorAutomaticFind = !0), a;
3435
3795
  }
3436
3796
  /** 添加可查找点的过滤规则
3437
3797
  * @param rule
@@ -3448,7 +3808,7 @@ class Ye {
3448
3808
  return this.lineSegments.forEach((e) => {
3449
3809
  e.points.forEach((n, s) => {
3450
3810
  for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
3451
- this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: tt() });
3811
+ this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: $() });
3452
3812
  });
3453
3813
  }), t;
3454
3814
  }
@@ -3460,31 +3820,33 @@ class Ye {
3460
3820
  return n.doors.forEach((i) => {
3461
3821
  const r = n.lineSegments[i[4]], o = n.originalData[i[4]];
3462
3822
  if (o.doorDirectConnection) {
3823
+ const { start: a, end: c, ...l } = o;
3463
3824
  this.continueFind = !1;
3464
- const a = new D(w.from(o.start), w.from(o.end));
3465
- a.userData = {
3825
+ const h = new L(D.from(a), D.from(c));
3826
+ h.userData = {
3827
+ ...V(l),
3466
3828
  doorDirectConnection: !0,
3467
3829
  isDoor: !0
3468
- }, this.dxf.doorLineSegment.push(a), a.points.forEach((c) => {
3469
- const l = s.queryPoint(c);
3470
- l.length && e.push({
3471
- line: l[0].userData,
3472
- point: l[0].point,
3473
- uuid: tt()
3830
+ }, this.dxf.doorLineSegment.push(h), h.points.forEach((f) => {
3831
+ const d = s.queryPoint(f);
3832
+ d.length && e.push({
3833
+ line: d[0].userData,
3834
+ point: d[0].point,
3835
+ uuid: $()
3474
3836
  });
3475
3837
  });
3476
3838
  } else if (o.drawDoorData) {
3477
- const a = w.from(o.drawDoorData.start), c = w.from(o.drawDoorData.n), l = s.queryPoint(a).filter((h) => {
3839
+ const a = D.from(o.drawDoorData.start), c = D.from(o.drawDoorData.n), l = s.queryPoint(a).filter((h) => {
3478
3840
  if (h.userData === r) return !1;
3479
- const d = h.userData, f = d.direction();
3480
- d.start.equal(a) && f.multiplyScalar(-1);
3481
- const p = c.angleBetween(f, "angle");
3841
+ const f = h.userData, d = f.direction();
3842
+ f.start.equal(a) && d.multiplyScalar(-1);
3843
+ const p = c.angleBetween(d, "angle");
3482
3844
  return p > 170 || p < 10;
3483
3845
  });
3484
3846
  l.length && t.push({
3485
3847
  line: l[0].userData,
3486
3848
  point: a,
3487
- uuid: tt()
3849
+ uuid: $()
3488
3850
  });
3489
3851
  } else
3490
3852
  console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
@@ -3511,96 +3873,96 @@ class Ye {
3511
3873
  */
3512
3874
  searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
3513
3875
  const i = this.findPointVirtualGrid, r = this.quadtree;
3514
- function o({ point: g, line: x }, m, L) {
3876
+ function o({ point: y, line: x }, m, w) {
3515
3877
  const M = x.direction();
3516
- x.start === g && M.multiplyScalar(-1);
3517
- const S = i.queryCircle(g, n).filter((E) => E.userData !== x).sort((E, T) => E.point.distance(g) - T.point.distance(g)), A = [];
3518
- for (let E = 0; E < S.length; E++) {
3519
- const T = e.findIndex((R) => R.point === S[E].point);
3878
+ x.start === y && M.multiplyScalar(-1);
3879
+ const E = i.queryCircle(y, n).filter((S) => S.userData !== x).sort((S, T) => S.point.distance(y) - T.point.distance(y)), A = [];
3880
+ for (let S = 0; S < E.length; S++) {
3881
+ const T = e.findIndex((G) => G.point === E[S].point);
3520
3882
  if (T === -1) continue;
3521
- const C = t[m].uuid, N = e[T].uuid;
3522
- if (L.has(`${C}.${N}`)) continue;
3523
- L.add(`${C}.${N}`), L.add(`${N}.${C}`);
3524
- const O = S[E].point, q = new D(g.clone(), O.clone());
3525
- if (q.direction().angleBetween(M, "angle") < s) {
3526
- const R = t[m].line.direction(), v = S[E].userData;
3527
- v.start.equal(S[E].point) && R.multiplyScalar(-1), q.direction().multiplyScalar(-1).angleBetween(R, "angle") < s && (r.queryLineSegment(q).filter((W) => !(W.line.start.equal(g) || W.line.end.equal(g) || W.line === v)).length || A.push({
3528
- findData: S[E],
3529
- findUuid: N,
3530
- doorLine: q,
3531
- doorUuid: C
3883
+ const P = t[m].uuid, I = e[T].uuid;
3884
+ if (w.has(`${P}.${I}`)) continue;
3885
+ w.add(`${P}.${I}`), w.add(`${I}.${P}`);
3886
+ const C = E[S].point, N = new L(y.clone(), C.clone());
3887
+ if (N.direction().angleBetween(M, "angle") < s) {
3888
+ const G = t[m].line.direction(), B = E[S].userData;
3889
+ B.start.equal(E[S].point) && G.multiplyScalar(-1), N.direction().multiplyScalar(-1).angleBetween(G, "angle") < s && (r.queryLineSegment(N).filter((lt) => !(lt.line.start.equal(y) || lt.line.end.equal(y) || lt.line === B)).length || A.push({
3890
+ findData: E[S],
3891
+ findUuid: I,
3892
+ doorLine: N,
3893
+ doorUuid: P
3532
3894
  }));
3533
3895
  }
3534
3896
  }
3535
3897
  return A;
3536
3898
  }
3537
- function a(g, x, m, L, M) {
3538
- L.add(g);
3539
- const S = [];
3540
- M && S.push(M);
3899
+ function a(y, x, m, w, M) {
3900
+ w.add(y);
3901
+ const E = [];
3902
+ M && E.push(M);
3541
3903
  for (let A = 0; A < m.length; A++) {
3542
- const E = m[A];
3543
- if (x.has(E.findUuid)) {
3544
- const T = x.get(E.findUuid);
3545
- a(E.findUuid, x, T, L, E) && S.push(E);
3546
- } else S.push(E);
3904
+ const S = m[A];
3905
+ if (x.has(S.findUuid)) {
3906
+ const T = x.get(S.findUuid);
3907
+ a(S.findUuid, x, T, w, S) && E.push(S);
3908
+ } else E.push(S);
3547
3909
  }
3548
- return S.sort((A, E) => A.doorLine.length() - E.doorLine.length()), M && S[0] === M ? (m.splice(0), !0) : (m.splice(1), !1);
3910
+ return E.sort((A, S) => A.doorLine.length() - S.doorLine.length()), M && E[0] === M ? (m.splice(0), !0) : (m.splice(1), !1);
3549
3911
  }
3550
3912
  const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
3551
- t.map((g, x) => {
3552
- const m = o(g, x, c);
3553
- m.length && l.set(g.uuid, m);
3913
+ t.map((y, x) => {
3914
+ const m = o(y, x, c);
3915
+ m.length && l.set(y.uuid, m);
3554
3916
  }), c.clear();
3555
3917
  const h = /* @__PURE__ */ new Map();
3556
- l.forEach((g, x) => {
3557
- if (!c.has(x) && g.length && a(x, l, g, c), g.length) {
3558
- const m = g[0];
3918
+ l.forEach((y, x) => {
3919
+ if (!c.has(x) && y.length && a(x, l, y, c), y.length) {
3920
+ const m = y[0];
3559
3921
  h.has(m.doorUuid) || h.set(m.doorUuid, []), h.get(m.doorUuid)?.push(m), h.has(m.findUuid) || h.set(m.findUuid, []), h.get(m.findUuid)?.push(m);
3560
3922
  }
3561
3923
  });
3562
- const d = /* @__PURE__ */ new Set();
3563
- h.forEach((g) => {
3564
- if (g.length > 1) {
3565
- g.sort((x, m) => x.doorLine.length() - m.doorLine.length());
3566
- for (let x = 1; x < g.length; x++) d.add(g[x]);
3924
+ const f = /* @__PURE__ */ new Set();
3925
+ h.forEach((y) => {
3926
+ if (y.length > 1) {
3927
+ y.sort((x, m) => x.doorLine.length() - m.doorLine.length());
3928
+ for (let x = 1; x < y.length; x++) f.add(y[x]);
3567
3929
  }
3568
3930
  });
3569
- const f = [], p = [];
3570
- l.forEach((g) => {
3571
- if (g.length) {
3572
- const x = g[0];
3573
- d.has(x) || (f.push(x), p.push(x.doorUuid, x.findUuid));
3931
+ const d = [], p = [];
3932
+ l.forEach((y) => {
3933
+ if (y.length) {
3934
+ const x = y[0];
3935
+ f.has(x) || (d.push(x), p.push(x.doorUuid, x.findUuid));
3574
3936
  }
3575
3937
  });
3576
- const y = [];
3577
- return f.forEach((g) => {
3578
- const x = t.findIndex((T) => T.uuid === g.doorUuid), m = e.findIndex((T) => T.uuid === g.findUuid), L = t[x].point.clone(), M = e[m].point.clone(), S = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[m].line), E = S.projectPoint(M);
3579
- if (E) {
3580
- L.copy(E);
3581
- const T = new D(L, M), C = A.includedAngle(T);
3582
- (C < 10 || C > 170 || Math.abs(90 - C) < 10) && y.push({
3583
- start: L,
3938
+ const g = [];
3939
+ return d.forEach((y) => {
3940
+ const x = t.findIndex((T) => T.uuid === y.doorUuid), m = e.findIndex((T) => T.uuid === y.findUuid), w = t[x].point.clone(), M = e[m].point.clone(), E = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[m].line), S = E.projectPoint(M);
3941
+ if (S) {
3942
+ w.copy(S);
3943
+ const T = new L(w, M), P = A.includedAngle(T);
3944
+ (P < 10 || P > 170 || Math.abs(90 - P) < 10) && g.push({
3945
+ start: w,
3584
3946
  end: M
3585
3947
  });
3586
3948
  } else {
3587
- const T = A.projectPoint(L);
3949
+ const T = A.projectPoint(w);
3588
3950
  T && M.copy(T);
3589
- const C = new D(L, M), N = S.includedAngle(C);
3590
- (N < 10 || N > 170 || Math.abs(90 - N) < 10) && y.push({
3591
- start: L,
3951
+ const P = new L(w, M), I = E.includedAngle(P);
3952
+ (I < 10 || I > 170 || Math.abs(90 - I) < 10) && g.push({
3953
+ start: w,
3592
3954
  end: M
3593
3955
  });
3594
3956
  }
3595
3957
  }), e.splice(
3596
3958
  0,
3597
3959
  e.length,
3598
- ...e.filter((g) => p.indexOf(g.uuid) === -1)
3960
+ ...e.filter((y) => p.indexOf(y.uuid) === -1)
3599
3961
  ), t.splice(
3600
3962
  0,
3601
3963
  t.length,
3602
- ...t.filter((g) => p.indexOf(g.uuid) === -1)
3603
- ), y;
3964
+ ...t.filter((y) => p.indexOf(y.uuid) === -1)
3965
+ ), g;
3604
3966
  }
3605
3967
  /** 方案二: 沿方向查找
3606
3968
  * @description
@@ -3610,7 +3972,7 @@ class Ye {
3610
3972
  searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
3611
3973
  const s = this.quadtree, i = e.direction();
3612
3974
  e.start === t && i.multiplyScalar(-1);
3613
- const r = t.clone().add(i.clone().multiplyScalar(n)), o = new D(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
3975
+ const r = t.clone().add(i.clone().multiplyScalar(n)), o = new L(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
3614
3976
  point: c.line.getIntersection(o),
3615
3977
  line: c.line
3616
3978
  })).filter((c) => c.point).sort((c, l) => t.distance(c.point) - t.distance(l.point));
@@ -3629,22 +3991,22 @@ class Ye {
3629
3991
  searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
3630
3992
  const s = this.pointVirtualGrid, i = this.quadtree, r = e.direction(), o = e.start.normal(e.end), a = e.start.clone();
3631
3993
  e.start === t && r.multiplyScalar(-1), e.start === t && a.copy(e.end);
3632
- const c = s.queryPoint(a).filter((d) => d.userData !== e);
3633
- for (let d = 0; d < c.length; d++) {
3634
- const f = c[d], p = f.userData, y = p.direction();
3635
- if (p.start === f.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
3994
+ const c = s.queryPoint(a).filter((f) => f.userData !== e);
3995
+ for (let f = 0; f < c.length; f++) {
3996
+ const d = c[f], p = d.userData, g = p.direction();
3997
+ if (p.start === d.point && r.multiplyScalar(-1), g.angleBetween(o) / (Math.PI / 180) > 90) {
3636
3998
  o.multiplyScalar(-1);
3637
3999
  break;
3638
4000
  }
3639
4001
  }
3640
- const l = new D(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
3641
- point: d.line.getIntersection(l),
3642
- line: d.line
3643
- })).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
4002
+ const l = new L(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((f) => ({
4003
+ point: f.line.getIntersection(l),
4004
+ line: f.line
4005
+ })).filter((f) => f.point).sort((f, d) => t.distance(f.point) - t.distance(d.point));
3644
4006
  if (h.length) {
3645
- const d = h[0];
3646
- if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
3647
- return d;
4007
+ const f = h[0];
4008
+ if (Math.abs(90 - f.line.direction().angleBetween(o, "angle")) < 5)
4009
+ return f;
3648
4010
  }
3649
4011
  }
3650
4012
  /**
@@ -3671,7 +4033,7 @@ class Ye {
3671
4033
  return e;
3672
4034
  }
3673
4035
  }
3674
- class Xe extends G {
4036
+ class $e extends z {
3675
4037
  doorSearchNearAngle = 110;
3676
4038
  doorSearchDistance = 2;
3677
4039
  DoorsAnalysis;
@@ -3683,28 +4045,28 @@ class Xe extends G {
3683
4045
  * @param parent
3684
4046
  */
3685
4047
  onAddFromParent(t) {
3686
- const e = t.findComponentByType(k), n = this.parent?.findComponentByType(zt);
4048
+ const e = t.findComponentByType(W), n = this.parent?.findComponentByType(Qt);
3687
4049
  e.addEventListener("createGroup", () => {
3688
- this.skipFindDoor ? this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])) : this.DoorsAnalysis = new Ye(n), this.skipFindDoor = !1, this.dispatchEvent({ type: "analysisCompleted" });
4050
+ this.DoorsAnalysis = new He(n, this.skipFindDoor), this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])), this.skipFindDoor = !1, this.dispatchEvent({ type: "analysisCompleted" });
3689
4051
  });
3690
4052
  }
3691
4053
  }
3692
- function Ve(u, t) {
4054
+ function Je(u, t) {
3693
4055
  const e = t.queryPoint(u.start, !0)[0], n = t.queryPoint(u.end, !0)[0];
3694
4056
  if (e && n) {
3695
4057
  const s = e.userData.length(), i = n.userData.length();
3696
4058
  if (Math.abs(s - i) < 1e-9) return null;
3697
4059
  const r = e.userData?.getAnotherPoint(e.point), o = n.userData?.getAnotherPoint(n.point), a = r.direction(e.point), c = o.direction(n.point);
3698
4060
  if (a.angleBetween(c) > 1e-9) return null;
3699
- const l = s > i ? n : e, h = l.userData, d = h.getAnotherPoint(l.point), f = t.queryPoint(d, !0)[0];
3700
- if (!f) return null;
3701
- const p = f.userData?.getAnotherPoint(f.point), y = p.direction(f.point);
3702
- return (u.start.equal(l.point) ? u.end : u.start).direction(l.point).angleBetween(y, "angle") < 1 ? null : h;
4061
+ const l = s > i ? n : e, h = l.userData, f = h.getAnotherPoint(l.point), d = t.queryPoint(f, !0)[0];
4062
+ if (!d) return null;
4063
+ const p = d.userData?.getAnotherPoint(d.point), g = p.direction(d.point);
4064
+ return (u.start.equal(l.point) ? u.end : u.start).direction(l.point).angleBetween(g, "angle") < 1 ? null : h;
3703
4065
  }
3704
4066
  return null;
3705
4067
  }
3706
- function We(u, t) {
3707
- const e = new B(I.fromByLineSegment(...u)), n = t.clone().expansion(100), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
4068
+ function Ke(u, t) {
4069
+ const e = new j(R.fromByLineSegment(...u)), n = t.clone().expansion(100), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
3708
4070
  u.forEach((a) => e.insert(a));
3709
4071
  const r = e.queryLineSegment(n);
3710
4072
  for (let a = 0; a < r.length; a++) {
@@ -3716,41 +4078,41 @@ function We(u, t) {
3716
4078
  const l = c.getIntersection(n);
3717
4079
  if (l) {
3718
4080
  if (c.start.equal(l) || c.end.equal(l)) continue;
3719
- const h = D.clipping(c, [l], qt);
3720
- s.add(c), h.forEach((d) => i.add(d));
4081
+ const h = L.clipping(c, [l], yt);
4082
+ s.add(c), h.forEach((f) => i.add(f));
3721
4083
  }
3722
4084
  }
3723
4085
  u = u.filter((a) => !s.has(a)), u.push(...i);
3724
- const o = D.groupByPosition(u, n);
4086
+ const o = L.groupByPosition(u, n);
3725
4087
  return o.forEach((a) => {
3726
- const c = new at();
4088
+ const c = new J();
3727
4089
  for (let h = 0; h < a.length; h++) {
3728
- const d = a[h], f = d.start.hashCode(), p = d.end.hashCode();
3729
- c.append(f, d.start), c.append(p, d.end);
4090
+ const f = a[h], d = f.start.hashCode(), p = f.end.hashCode();
4091
+ c.append(d, f.start), c.append(p, f.end);
3730
4092
  }
3731
4093
  const l = c.filter((h) => h.length === 1).map((h) => h[0]);
3732
4094
  if (l.length === 2) {
3733
- const h = new D(l[0].clone(), l[1].clone());
4095
+ const h = new L(l[0].clone(), l[1].clone());
3734
4096
  a.push(h);
3735
4097
  }
3736
4098
  }), e.clear(), o;
3737
4099
  }
3738
- function _t(u) {
3739
- if (u = u.map((n) => n.clone()), u = D.brokenLineMerging(u, $), u.length <= 4) return [u];
4100
+ function xt(u) {
4101
+ if (u = u.map((n) => n.clone()), u = L.brokenLineMerging(u, U), u.length <= 4) return [u];
3740
4102
  u = u.sort((n, s) => s.length() - n.length());
3741
- const t = V(u), e = [];
4103
+ const t = nt(u), e = [];
3742
4104
  for (let n = 0; n < u.length; n++) {
3743
- const s = u[n], i = Ve(s, t);
4105
+ const s = u[n], i = Je(s, t);
3744
4106
  if (i) {
3745
- We(u, i).forEach((r) => {
3746
- r.length === 4 ? e.push(r) : e.push(..._t(r));
4107
+ Ke(u, i).forEach((r) => {
4108
+ r.length === 4 ? e.push(r) : e.push(...xt(r));
3747
4109
  });
3748
4110
  break;
3749
4111
  }
3750
4112
  }
3751
4113
  return t.clear(), e;
3752
4114
  }
3753
- class He extends G {
4115
+ class Ze extends z {
3754
4116
  static name = "ThreeVJia";
3755
4117
  lineSegments = [];
3756
4118
  neededUpdate = !0;
@@ -3764,10 +4126,10 @@ class He extends G {
3764
4126
  * @returns
3765
4127
  */
3766
4128
  getGroups(t) {
3767
- const e = t.reduce((n, s) => {
3768
- let i = s.userData.groupId ?? "door";
3769
- return s.userData.groupType === "wall" && (i = "wall"), n.append(i, s);
3770
- }, new at());
4129
+ const e = t.reduce((n, s) => (O.get(s).forEach((r) => {
4130
+ let o = r.id ?? "wall";
4131
+ r.type === "wall" && (o = "wall"), n.append(o, s);
4132
+ }), n), new J());
3771
4133
  return e.size === 1 ? null : e;
3772
4134
  }
3773
4135
  /** 更新
@@ -3780,16 +4142,18 @@ class He extends G {
3780
4142
  * @param map
3781
4143
  */
3782
4144
  handleGroup(t) {
3783
- const e = t.group((r, o) => ({ wall: "wall", door: "wall" })[o] ?? "doubleWall"), n = e.get("wall") ?? [], s = e.get("doubleWall") ?? [];
3784
- let i = [];
3785
- n.forEach((r) => i.push(...r)), s.forEach((r) => {
3786
- _t(r).forEach((a) => {
3787
- if (a.length < 4) return i.push(...a);
3788
- a = a.sort((d, f) => d.length() - f.length());
3789
- const c = a[0], l = a[1], h = new D(c.center.clone(), l.center.clone());
3790
- $(h, a), h.userData.wallWidth = c.length(), i.push(h);
4145
+ const e = t.group((o) => O.everyType(o, "bayWindow") ? "wall" : O.everyType(o, "doubleWall") ? "doubleWall" : "wall"), n = e.get("wall") ?? [], s = e.get("doubleWall") ?? [];
4146
+ let i = [], r = new Set(s.flat());
4147
+ n.forEach((o) => {
4148
+ o.forEach((a) => r.has(a) || i.push(a));
4149
+ }), s.forEach((o) => {
4150
+ xt(o).forEach((c) => {
4151
+ if (c.length < 4) return i.push(...c);
4152
+ c = c.sort((d, p) => d.length() - p.length());
4153
+ const l = c[0], h = c[1], f = new L(l.center.clone(), h.center.clone());
4154
+ U(f, c), f.userData.wallWidth = l.length(), i.push(f);
3791
4155
  });
3792
- }), i = i.map((r) => r.clone()), this.lineSegments = i;
4156
+ }), i = i.map((o) => o.clone()), this.lineSegments = i.filter((o) => !o.userData.isBayWindow);
3793
4157
  }
3794
4158
  /**
3795
4159
  * 角度纠正
@@ -3797,7 +4161,7 @@ class He extends G {
3797
4161
  angleCorrection() {
3798
4162
  const t = this.parent?.findComponentByName("Dxf"), e = this.parent?.findComponentByName("AngleCorrectionDxf"), n = t.box.center;
3799
4163
  this.lineSegments = this.lineSegments.map((s) => (s.start.rotate(n, e.angle * (Math.PI / 180)), s.end.rotate(n, e.angle * (Math.PI / 180)), s.userData.drawWindow && s.userData.drawWindow.forEach((i) => {
3800
- const r = w.from(i.p);
4164
+ const r = D.from(i.p);
3801
4165
  r.rotate(n, e.angle * (Math.PI / 180)), i.p = r.toJson(i.p.z);
3802
4166
  }), s));
3803
4167
  }
@@ -3808,10 +4172,10 @@ class He extends G {
3808
4172
  const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf"), n = /* @__PURE__ */ new Map();
3809
4173
  let s = [...e.lineSegments], i = [], r = [];
3810
4174
  t.resultList.forEach((a) => {
3811
- const c = n.get(a.target) ?? [], l = n.get(a.source) ?? [], h = a.project.clone(), d = a.project2.clone();
3812
- h.includedAngle(d) > 135 && (d.points = [d.points[1], d.points[0]]), c.push(...h.points), l.push(...d.points), n.set(a.target, c), n.set(a.source, l);
3813
- const f = new D(h.start, d.start), p = new D(h.end, d.end), y = new D(f.center, p.center);
3814
- y.userData.wallWidth = Math.max(f.length(), p.length()), i.push(y);
4175
+ const c = n.get(a.target) ?? [], l = n.get(a.source) ?? [], h = a.project.clone(), f = a.project2.clone();
4176
+ h.includedAngle(f) > 135 && (f.points = [f.points[1], f.points[0]]), c.push(...h.points), l.push(...f.points), n.set(a.target, c), n.set(a.source, l);
4177
+ const d = new L(h.start, f.start), p = new L(h.end, f.end), g = new L(d.center, p.center);
4178
+ g.userData.wallWidth = Math.max(d.length(), p.length()), i.push(g);
3815
4179
  });
3816
4180
  const o = [];
3817
4181
  s = s.filter((a) => {
@@ -3819,15 +4183,15 @@ class He extends G {
3819
4183
  if (n.has(a)) {
3820
4184
  const c = n.get(a), l = a.clone();
3821
4185
  if (c) {
3822
- for (let d = 0; d < c.length; d += 2) {
3823
- const f = c[d], p = c[d + 1];
3824
- f.userData.length = f.distance(l.start), p.userData.length = p.distance(l.start), f.userData.type = "start", p.userData.type = "end", l.start.distance(f) > l.start.distance(p) && (c[d] = p, c[d + 1] = f, f.userData.type = "end", p.userData.type = "start");
4186
+ for (let f = 0; f < c.length; f += 2) {
4187
+ const d = c[f], p = c[f + 1];
4188
+ d.userData.length = d.distance(l.start), p.userData.length = p.distance(l.start), d.userData.type = "start", p.userData.type = "end", l.start.distance(d) > l.start.distance(p) && (c[f] = p, c[f + 1] = d, d.userData.type = "end", p.userData.type = "start");
3825
4189
  }
3826
- c.sort((d, f) => d.userData.length - f.userData.length);
4190
+ c.sort((f, d) => f.userData.length - d.userData.length);
3827
4191
  const h = [];
3828
- for (let d = 0; d < c.length; d++) {
3829
- const f = c[d];
3830
- f.userData.type === "start" ? (h.length === 0 && (o.push(new D(l.start.clone(), f.clone())), l.start.copy(f)), h.push("start")) : (h.pop(), h.length === 0 && l.start.copy(f));
4192
+ for (let f = 0; f < c.length; f++) {
4193
+ const d = c[f];
4194
+ d.userData.type === "start" ? (h.length === 0 && (o.push(new L(l.start.clone(), d.clone())), l.start.copy(d)), h.push("start")) : (h.pop(), h.length === 0 && l.start.copy(d));
3831
4195
  }
3832
4196
  o.push(l);
3833
4197
  }
@@ -3882,7 +4246,7 @@ class He extends G {
3882
4246
  };
3883
4247
  if (s.userData.isWindow && s.userData.drawWindow)
3884
4248
  return s.userData.drawWindow.map((i) => {
3885
- const r = w.from(i.p), o = r.clone().add(
4249
+ const r = D.from(i.p), o = r.clone().add(
3886
4250
  s.direction().multiplyScalar(i.width * 0.5)
3887
4251
  ), a = r.clone().add(
3888
4252
  s.direction().multiplyScalar(-i.width * 0.5)
@@ -3899,8 +4263,8 @@ class He extends G {
3899
4263
  y: a.y * t
3900
4264
  },
3901
4265
  height: 1.6 * t,
3902
- groundClearance: 0.9 * t,
3903
- sillHeiqht: (s.userData?.sillHeight ?? 0.9) * t
4266
+ groundClearance: (s.userData?.groundClearance ?? 0.9) * t,
4267
+ sillHeiqht: (s.userData?.groundClearance ?? 0.9) * t
3904
4268
  };
3905
4269
  });
3906
4270
  }).filter((s) => !!s),
@@ -3918,7 +4282,7 @@ class He extends G {
3918
4282
  } else typeof global < "u" && (await H("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
3919
4283
  }
3920
4284
  }
3921
- class Z extends me {
4285
+ class Z extends Pe {
3922
4286
  Dxf;
3923
4287
  AngleCorrectionDxf;
3924
4288
  Variable;
@@ -3932,7 +4296,7 @@ class Z extends me {
3932
4296
  * @param scale 原始数据缩放比例
3933
4297
  */
3934
4298
  constructor(t = 0.1, e = 1) {
3935
- super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new ke(), this.Variable = new Ut(), this.LineAnalysis = new zt(), this.DoorsAnalysis = new Xe(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(this.LineAnalysis), this.addComponent(this.DoorsAnalysis), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new He()), Z.finalInstance = this;
4299
+ super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new W(this.wallWidth, e), this.AngleCorrectionDxf = new Xe(), this.Variable = new Zt(), this.LineAnalysis = new Qt(), this.DoorsAnalysis = new $e(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(this.LineAnalysis), this.addComponent(this.DoorsAnalysis), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new Ze()), Z.finalInstance = this;
3936
4300
  }
3937
4301
  usePlugin(t) {
3938
4302
  return typeof t == "function" && t.call(this, this), this;
@@ -3945,7 +4309,7 @@ class Z extends me {
3945
4309
  });
3946
4310
  }
3947
4311
  }
3948
- function Et(u, t, e) {
4312
+ function vt(u, t, e) {
3949
4313
  return e.reduce((n, s, i) => {
3950
4314
  const r = s.userData;
3951
4315
  if (r.parallel(u)) n[0] = i;
@@ -3956,23 +4320,23 @@ function Et(u, t, e) {
3956
4320
  return n;
3957
4321
  }, [-1, -1, -1]);
3958
4322
  }
3959
- function Je(u, t, e, n, s) {
3960
- const { point: i } = u[e[0]], r = new D(i.clone(), t.clone());
4323
+ function Qe(u, t, e, n, s) {
4324
+ const { point: i } = u[e[0]], r = new L(i.clone(), t.clone());
3961
4325
  return r.points.forEach((o) => s.insert(o, r)), n.push(r), r;
3962
4326
  }
3963
- function $e(u, t, e, n) {
4327
+ function tn(u, t, e, n) {
3964
4328
  const { point: s } = u[e[1]];
3965
4329
  s.copy(t), n.update(s);
3966
4330
  }
3967
- function Ke(u, t, e, n) {
4331
+ function en(u, t, e, n) {
3968
4332
  const { point: s } = u[e[2]];
3969
4333
  s.copy(t), n.update(s);
3970
4334
  }
3971
- function At(u, t, e, n, s) {
4335
+ function Rt(u, t, e, n, s) {
3972
4336
  const i = e[0] > -1, r = e[1] > -1, o = e[2] > -1;
3973
- if (r && $e(t, u, e, s), i) {
3974
- const a = Je(t, u, e, n, s);
3975
- r && (a.userData = J(t[e[1]].userData?.userData ?? {}));
4337
+ if (r && tn(t, u, e, s), i) {
4338
+ const a = Qe(t, u, e, n, s);
4339
+ r && (a.userData = V(t[e[1]].userData?.userData ?? {}));
3976
4340
  return;
3977
4341
  }
3978
4342
  if (o) {
@@ -3980,27 +4344,27 @@ function At(u, t, e, n, s) {
3980
4344
  const a = t[e[1]].userData;
3981
4345
  u = a.start.distance(t[e[2]].point) < a.end.distance(t[e[2]].point) ? a.start : a.end;
3982
4346
  }
3983
- Ke(t, u, e, s);
4347
+ en(t, u, e, s);
3984
4348
  }
3985
4349
  }
3986
- function Ze(u, t = 0.12, e, n) {
3987
- const s = n.queryPoint(u.start, !0), i = n.queryPoint(u.end, !0), r = u.userData.expandDirect, o = Et(u, r, s), a = Et(u, r, i), c = r === "left" ? u.getRightDirection() : u.getLeftDirection();
3988
- u.directionMove(c, t * 0.5), u.points.forEach((l) => n.update(l)), At(u.start, s, o, e, n), At(u.end, i, a, e, n);
4350
+ function nn(u, t = 0.12, e, n) {
4351
+ const s = n.queryPoint(u.start, !0), i = n.queryPoint(u.end, !0), r = u.userData.expandDirect, o = vt(u, r, s), a = vt(u, r, i), c = r === "left" ? u.getRightDirection() : u.getLeftDirection();
4352
+ u.directionMove(c, t * 0.5), u.points.forEach((l) => n.update(l)), Rt(u.start, s, o, e, n), Rt(u.end, i, a, e, n);
3989
4353
  }
3990
- class pt {
4354
+ class mt {
3991
4355
  /** 通过轨迹点查找外墙
3992
4356
  * @param lines
3993
4357
  * @param trajectoryPoints
3994
4358
  * @returns
3995
4359
  */
3996
4360
  static findExtWallByTraj(t, e, n = 0.4) {
3997
- const s = new B(I.fromByLineSegment(...t));
4361
+ const s = new j(R.fromByLineSegment(...t));
3998
4362
  return t.forEach((i) => s.insert({ line: i, userData: void 0 })), t = t.filter((i) => {
3999
4363
  if (i.userData.groupType === "doubleWall" || i.userData.isDoor) return;
4000
4364
  const r = i.center, o = /* @__PURE__ */ new Set();
4001
4365
  for (const a of e) {
4002
4366
  if (o.size === 2) break;
4003
- const c = new D(r, a);
4367
+ const c = new L(r, a);
4004
4368
  if (!s.queryLineSegment(c).filter((h) => h.line === i ? !1 : i.userData.groupType === "wall" ? !0 : !(h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
4005
4369
  const h = i.pointPosition(a);
4006
4370
  h !== "on" && o.add(h);
@@ -4014,29 +4378,77 @@ class pt {
4014
4378
  * @param trajectoryPoints
4015
4379
  */
4016
4380
  static boundExtbyTraj(t, e, n = 0.12, s) {
4017
- const i = Object.keys(e).map((f) => w.from(e[f])), r = [];
4018
- let o = t.map(({ start: f, end: p, ...y }) => {
4019
- const g = new D(w.from(f), w.from(p));
4020
- return g.userData = y, r.push(f.z ?? 0, p.z ?? 0), g;
4381
+ const i = Object.keys(e).map((d) => D.from(e[d])), r = [];
4382
+ let o = t.map(({ start: d, end: p, ...g }) => {
4383
+ const y = new L(D.from(d), D.from(p));
4384
+ return y.userData = g, r.push(d.z ?? 0, p.z ?? 0), y;
4385
+ });
4386
+ const a = r.reduce((d, p) => d + p, 0) / r.length;
4387
+ let l = mt.findExtWallByTraj(o, i).filter((d) => d.userData.expandDirect);
4388
+ o = o.filter((d) => !l.includes(d)), o.push(...l), s && s(l, i);
4389
+ const h = nt(o), f = [];
4390
+ return l.forEach((d) => {
4391
+ d.userData.isDoor || nn(d, n, f, h);
4392
+ }), o.push(...f.filter((d) => d.length() > 1e-9)), K(...o), tt(o, a);
4393
+ }
4394
+ }
4395
+ function sn(u, t, e, n = !0) {
4396
+ e = e ?? /* @__PURE__ */ new Set();
4397
+ const s = !!t, i = t || nt(u);
4398
+ function r(o) {
4399
+ if (!(o instanceof L) || e?.has(o)) return;
4400
+ const a = i?.queryPoint(o.start, !0), c = i?.queryPoint(o.end, !0);
4401
+ a && c && (a?.length === 0 || c?.length === 0) && (e?.add(o), i.remove(o.start), i.remove(o.end), n && (a.forEach(({ userData: l }) => r(l)), c.forEach(({ userData: l }) => r(l))));
4402
+ }
4403
+ for (let o = 0; o < u.length; o++) {
4404
+ const a = u[o];
4405
+ r(a);
4406
+ }
4407
+ return s || i.clear(), e;
4408
+ }
4409
+ function rn(u, t, e = !1) {
4410
+ t = t || /* @__PURE__ */ new Set();
4411
+ const n = new gt();
4412
+ for (u.forEach((s) => {
4413
+ t.size && t.has(s) || s.points.forEach((i) => {
4414
+ const r = i.hashCode();
4415
+ n.has(r) || n.set(r, /* @__PURE__ */ new Set()), n.get(r)?.add(s);
4021
4416
  });
4022
- const a = r.reduce((f, p) => f + p, 0) / r.length;
4023
- let l = pt.findExtWallByTraj(o, i).filter((f) => f.userData.expandDirect);
4024
- o = o.filter((f) => !l.includes(f)), o.push(...l), s && s(l, i);
4025
- const h = V(o), d = [];
4026
- return l.forEach((f) => {
4027
- f.userData.isDoor || Ze(f, n, d, h);
4028
- }), o.push(...d.filter((f) => f.length() > 1e-9)), X(...o), et(o, a);
4417
+ }); ; ) {
4418
+ const s = /* @__PURE__ */ new Set();
4419
+ for (const [i, r] of n.entries()) {
4420
+ if (r.size !== 1) continue;
4421
+ const o = r.values().next().value;
4422
+ t.add(o), n.delete(i), s.add(o);
4423
+ }
4424
+ if (s.forEach((i) => {
4425
+ n.get(i.start.hashCode())?.delete(i), n.get(i.end.hashCode())?.delete(i);
4426
+ }), s.size === 0 || !e) break;
4029
4427
  }
4428
+ return t;
4030
4429
  }
4031
- const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4430
+ const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4032
4431
  __proto__: null,
4033
- AxisAlignCorr: Gt,
4034
- BoundExt: pt,
4035
- lineDataToOriginalData: et,
4036
- lineSegmentClipping: ft,
4037
- recomputedWindow: X,
4038
- toOriginalDataItem: Bt
4039
- }, Symbol.toStringTag, { value: "Module" })), bt = {
4432
+ AxisAlignCorr: Ht,
4433
+ BoundExt: mt,
4434
+ DoubleWallHelper: kt,
4435
+ clippingDoubleWall: xt,
4436
+ clippingLineUserData: yt,
4437
+ closedPathArea: Kt,
4438
+ createPointVirtualGrid: nt,
4439
+ findCircleEdges: Vt,
4440
+ findDiscretePointLine: sn,
4441
+ findDiscretePointLine2: rn,
4442
+ findLargestCircle: Xt,
4443
+ findVerticalReference: $t,
4444
+ lineDataToOriginalData: tt,
4445
+ lineSegmentClipping: ot,
4446
+ mergeLineUserData: U,
4447
+ originalDataToLineData: Jt,
4448
+ recomputedWindow: K,
4449
+ recomputedWindowCenter: _t,
4450
+ toOriginalDataItem: zt
4451
+ }, Symbol.toStringTag, { value: "Module" })), Ct = {
4040
4452
  POSITION: [
4041
4453
  "byte",
4042
4454
  "byte normalized",
@@ -4064,36 +4476,36 @@ const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4064
4476
  "unsigned short"
4065
4477
  ]
4066
4478
  };
4067
- class ot {
4479
+ class at {
4068
4480
  constructor() {
4069
4481
  this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
4070
- return new hn(t);
4071
- }), this.register(function(t) {
4072
- return new un(t);
4073
- }), this.register(function(t) {
4074
- return new gn(t);
4075
- }), this.register(function(t) {
4076
4482
  return new yn(t);
4077
4483
  }), this.register(function(t) {
4078
4484
  return new xn(t);
4079
4485
  }), this.register(function(t) {
4080
- return new mn(t);
4486
+ return new Dn(t);
4081
4487
  }), this.register(function(t) {
4082
- return new dn(t);
4488
+ return new Ln(t);
4489
+ }), this.register(function(t) {
4490
+ return new Sn(t);
4083
4491
  }), this.register(function(t) {
4084
- return new fn(t);
4492
+ return new En(t);
4085
4493
  }), this.register(function(t) {
4086
- return new pn(t);
4494
+ return new mn(t);
4087
4495
  }), this.register(function(t) {
4088
4496
  return new wn(t);
4089
4497
  }), this.register(function(t) {
4090
4498
  return new Mn(t);
4091
4499
  }), this.register(function(t) {
4092
- return new Dn(t);
4500
+ return new An(t);
4093
4501
  }), this.register(function(t) {
4094
- return new Ln(t);
4502
+ return new Tn(t);
4095
4503
  }), this.register(function(t) {
4096
- return new Sn(t);
4504
+ return new bn(t);
4505
+ }), this.register(function(t) {
4506
+ return new Pn(t);
4507
+ }), this.register(function(t) {
4508
+ return new In(t);
4097
4509
  });
4098
4510
  }
4099
4511
  register(t) {
@@ -4106,7 +4518,7 @@ class ot {
4106
4518
  return this.textureUtils = t, this;
4107
4519
  }
4108
4520
  parse(t, e, n, s) {
4109
- const i = new ln(), r = [];
4521
+ const i = new gn(), r = [];
4110
4522
  for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
4111
4523
  r.push(this.pluginCallbacks[o](i));
4112
4524
  i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
@@ -4142,34 +4554,34 @@ const b = {
4142
4554
  CLAMP_TO_EDGE: 33071,
4143
4555
  MIRRORED_REPEAT: 33648,
4144
4556
  REPEAT: 10497
4145
- }, lt = "KHR_mesh_quantization", j = {};
4146
- j[ae] = b.NEAREST;
4147
- j[ce] = b.NEAREST_MIPMAP_NEAREST;
4148
- j[le] = b.NEAREST_MIPMAP_LINEAR;
4149
- j[he] = b.LINEAR;
4150
- j[ue] = b.LINEAR_MIPMAP_NEAREST;
4151
- j[de] = b.LINEAR_MIPMAP_LINEAR;
4152
- j[fe] = b.CLAMP_TO_EDGE;
4153
- j[pe] = b.REPEAT;
4154
- j[ge] = b.MIRRORED_REPEAT;
4155
- const Tt = {
4557
+ }, ut = "KHR_mesh_quantization", F = {};
4558
+ F[xe] = b.NEAREST;
4559
+ F[me] = b.NEAREST_MIPMAP_NEAREST;
4560
+ F[we] = b.NEAREST_MIPMAP_LINEAR;
4561
+ F[Me] = b.LINEAR;
4562
+ F[De] = b.LINEAR_MIPMAP_NEAREST;
4563
+ F[Le] = b.LINEAR_MIPMAP_LINEAR;
4564
+ F[Se] = b.CLAMP_TO_EDGE;
4565
+ F[Ee] = b.REPEAT;
4566
+ F[Ae] = b.MIRRORED_REPEAT;
4567
+ const Nt = {
4156
4568
  scale: "scale",
4157
4569
  position: "translation",
4158
4570
  quaternion: "rotation",
4159
4571
  morphTargetInfluences: "weights"
4160
- }, Qe = new Kt(), Pt = 12, tn = 1179937895, en = 2, It = 8, nn = 1313821514, sn = 5130562;
4572
+ }, on = new ae(), Bt = 12, an = 1179937895, cn = 2, jt = 8, ln = 1313821514, hn = 5130562;
4161
4573
  function Q(u, t) {
4162
4574
  return u.length === t.length && u.every(function(e, n) {
4163
4575
  return e === t[n];
4164
4576
  });
4165
4577
  }
4166
- function rn(u) {
4578
+ function un(u) {
4167
4579
  return new TextEncoder().encode(u).buffer;
4168
4580
  }
4169
- function on(u) {
4581
+ function dn(u) {
4170
4582
  return Q(u.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
4171
4583
  }
4172
- function an(u, t, e) {
4584
+ function fn(u, t, e) {
4173
4585
  const n = {
4174
4586
  min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
4175
4587
  max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
@@ -4177,15 +4589,15 @@ function an(u, t, e) {
4177
4589
  for (let s = t; s < t + e; s++)
4178
4590
  for (let i = 0; i < u.itemSize; i++) {
4179
4591
  let r;
4180
- u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r = dt.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
4592
+ u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r = pt.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
4181
4593
  }
4182
4594
  return n;
4183
4595
  }
4184
- function kt(u) {
4596
+ function te(u) {
4185
4597
  return Math.ceil(u / 4) * 4;
4186
4598
  }
4187
- function ht(u, t = 0) {
4188
- const e = kt(u.byteLength);
4599
+ function dt(u, t = 0) {
4600
+ const e = te(u.byteLength);
4189
4601
  if (e !== u.byteLength) {
4190
4602
  const n = new Uint8Array(e);
4191
4603
  if (n.set(new Uint8Array(u)), t !== 0)
@@ -4195,10 +4607,10 @@ function ht(u, t = 0) {
4195
4607
  }
4196
4608
  return u;
4197
4609
  }
4198
- function vt() {
4610
+ function Ot() {
4199
4611
  return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
4200
4612
  }
4201
- function cn(u, t) {
4613
+ function pn(u, t) {
4202
4614
  if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
4203
4615
  let e;
4204
4616
  return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8), u.convertToBlob({
@@ -4208,12 +4620,12 @@ function cn(u, t) {
4208
4620
  } else
4209
4621
  return new Promise((e) => u.toBlob(e, t));
4210
4622
  }
4211
- class ln {
4623
+ class gn {
4212
4624
  constructor() {
4213
4625
  this.plugins = [], this.options = {}, this.pending = [], this.buffers = [], this.byteOffset = 0, this.buffers = [], this.nodeMap = /* @__PURE__ */ new Map(), this.skins = [], this.extensionsUsed = {}, this.extensionsRequired = {}, this.uids = /* @__PURE__ */ new Map(), this.uid = 0, this.json = {
4214
4626
  asset: {
4215
4627
  version: "2.0",
4216
- generator: "THREE.GLTFExporter r" + Qt
4628
+ generator: "THREE.GLTFExporter r" + le
4217
4629
  }
4218
4630
  }, this.cache = {
4219
4631
  meshes: /* @__PURE__ */ new Map(),
@@ -4250,27 +4662,27 @@ class ln {
4250
4662
  const s = this, i = s.buffers, r = s.json;
4251
4663
  n = s.options;
4252
4664
  const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
4253
- l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ? ut(c).then(function(d) {
4254
- const f = ht(d), p = new DataView(new ArrayBuffer(It));
4255
- p.setUint32(0, f.byteLength, !0), p.setUint32(4, sn, !0);
4256
- const y = ht(rn(JSON.stringify(r)), 32), g = new DataView(new ArrayBuffer(It));
4257
- g.setUint32(0, y.byteLength, !0), g.setUint32(4, nn, !0);
4258
- const x = new ArrayBuffer(Pt), m = new DataView(x);
4259
- m.setUint32(0, tn, !0), m.setUint32(4, en, !0);
4260
- const L = Pt + g.byteLength + y.byteLength + p.byteLength + f.byteLength;
4261
- m.setUint32(8, L, !0);
4665
+ l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ? ft(c).then(function(f) {
4666
+ const d = dt(f), p = new DataView(new ArrayBuffer(jt));
4667
+ p.setUint32(0, d.byteLength, !0), p.setUint32(4, hn, !0);
4668
+ const g = dt(un(JSON.stringify(r)), 32), y = new DataView(new ArrayBuffer(jt));
4669
+ y.setUint32(0, g.byteLength, !0), y.setUint32(4, ln, !0);
4670
+ const x = new ArrayBuffer(Bt), m = new DataView(x);
4671
+ m.setUint32(0, an, !0), m.setUint32(4, cn, !0);
4672
+ const w = Bt + y.byteLength + g.byteLength + p.byteLength + d.byteLength;
4673
+ m.setUint32(8, w, !0);
4262
4674
  const M = new Blob([
4263
4675
  x,
4264
- g,
4265
4676
  y,
4677
+ g,
4266
4678
  p,
4267
- f
4679
+ d
4268
4680
  ], { type: "application/octet-stream" });
4269
- ut(M).then((S) => {
4270
- e(S);
4681
+ ft(M).then((E) => {
4682
+ e(E);
4271
4683
  });
4272
- }) : r.buffers && r.buffers.length > 0 ? En(c).then((d) => {
4273
- r.buffers[0].uri = d, e(r);
4684
+ }) : r.buffers && r.buffers.length > 0 ? vn(c).then((f) => {
4685
+ r.buffers[0].uri = f, e(r);
4274
4686
  }) : e(r);
4275
4687
  }
4276
4688
  /**
@@ -4351,15 +4763,15 @@ class ln {
4351
4763
  }
4352
4764
  async buildMetalRoughTextureAsync(t, e) {
4353
4765
  if (t === e) return t;
4354
- function n(f) {
4355
- return f.colorSpace === oe ? function(y) {
4356
- return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
4357
- } : function(y) {
4358
- return y;
4766
+ function n(d) {
4767
+ return d.colorSpace === ye ? function(g) {
4768
+ return g < 0.04045 ? g * 0.0773993808 : Math.pow(g * 0.9478672986 + 0.0521327014, 2.4);
4769
+ } : function(g) {
4770
+ return g;
4359
4771
  };
4360
4772
  }
4361
- t instanceof ct && (t = await this.decompressTextureAsync(t)), e instanceof ct && (e = await this.decompressTextureAsync(e));
4362
- const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = vt();
4773
+ t instanceof ht && (t = await this.decompressTextureAsync(t)), e instanceof ht && (e = await this.decompressTextureAsync(e));
4774
+ const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = Ot();
4363
4775
  a.width = r, a.height = o;
4364
4776
  const c = a.getContext("2d", {
4365
4777
  willReadFrequently: !0
@@ -4368,19 +4780,19 @@ class ln {
4368
4780
  const l = c.getImageData(0, 0, r, o);
4369
4781
  if (s) {
4370
4782
  c.drawImage(s, 0, 0, r, o);
4371
- const f = n(t), p = c.getImageData(0, 0, r, o).data;
4372
- for (let y = 2; y < p.length; y += 4)
4373
- l.data[y] = f(p[y] / 256) * 256;
4783
+ const d = n(t), p = c.getImageData(0, 0, r, o).data;
4784
+ for (let g = 2; g < p.length; g += 4)
4785
+ l.data[g] = d(p[g] / 256) * 256;
4374
4786
  }
4375
4787
  if (i) {
4376
4788
  c.drawImage(i, 0, 0, r, o);
4377
- const f = n(e), p = c.getImageData(0, 0, r, o).data;
4378
- for (let y = 1; y < p.length; y += 4)
4379
- l.data[y] = f(p[y] / 256) * 256;
4789
+ const d = n(e), p = c.getImageData(0, 0, r, o).data;
4790
+ for (let g = 1; g < p.length; g += 4)
4791
+ l.data[g] = d(p[g] / 256) * 256;
4380
4792
  }
4381
4793
  c.putImageData(l, 0, 0);
4382
- const d = (t || e).clone();
4383
- return d.source = new te(a), d.colorSpace = ee, d.channel = (t || e).channel, t && e && t.channel !== e.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
4794
+ const f = (t || e).clone();
4795
+ return f.source = new he(a), f.colorSpace = ue, f.channel = (t || e).channel, t && e && t.channel !== e.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), f;
4384
4796
  }
4385
4797
  async decompressTextureAsync(t, e = 1 / 0) {
4386
4798
  if (this.textureUtils === null)
@@ -4423,21 +4835,21 @@ class ln {
4423
4835
  }
4424
4836
  let a = t.itemSize * o;
4425
4837
  i === b.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
4426
- const c = kt(s * a), l = new DataView(new ArrayBuffer(c));
4838
+ const c = te(s * a), l = new DataView(new ArrayBuffer(c));
4427
4839
  let h = 0;
4428
4840
  for (let p = n; p < n + s; p++) {
4429
- for (let y = 0; y < t.itemSize; y++) {
4430
- let g;
4431
- t.itemSize > 4 ? g = t.array[p * t.itemSize + y] : (y === 0 ? g = t.getX(p) : y === 1 ? g = t.getY(p) : y === 2 ? g = t.getZ(p) : y === 3 && (g = t.getW(p)), t.normalized === !0 && (g = dt.normalize(g, t.array))), e === b.FLOAT ? l.setFloat32(h, g, !0) : e === b.INT ? l.setInt32(h, g, !0) : e === b.UNSIGNED_INT ? l.setUint32(h, g, !0) : e === b.SHORT ? l.setInt16(h, g, !0) : e === b.UNSIGNED_SHORT ? l.setUint16(h, g, !0) : e === b.BYTE ? l.setInt8(h, g) : e === b.UNSIGNED_BYTE && l.setUint8(h, g), h += o;
4841
+ for (let g = 0; g < t.itemSize; g++) {
4842
+ let y;
4843
+ t.itemSize > 4 ? y = t.array[p * t.itemSize + g] : (g === 0 ? y = t.getX(p) : g === 1 ? y = t.getY(p) : g === 2 ? y = t.getZ(p) : g === 3 && (y = t.getW(p)), t.normalized === !0 && (y = pt.normalize(y, t.array))), e === b.FLOAT ? l.setFloat32(h, y, !0) : e === b.INT ? l.setInt32(h, y, !0) : e === b.UNSIGNED_INT ? l.setUint32(h, y, !0) : e === b.SHORT ? l.setInt16(h, y, !0) : e === b.UNSIGNED_SHORT ? l.setUint16(h, y, !0) : e === b.BYTE ? l.setInt8(h, y) : e === b.UNSIGNED_BYTE && l.setUint8(h, y), h += o;
4432
4844
  }
4433
4845
  h % a !== 0 && (h += a - h % a);
4434
4846
  }
4435
- const d = {
4847
+ const f = {
4436
4848
  buffer: this.processBuffer(l.buffer),
4437
4849
  byteOffset: this.byteOffset,
4438
4850
  byteLength: c
4439
4851
  };
4440
- return i !== void 0 && (d.target = i), i === b.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
4852
+ return i !== void 0 && (f.target = i), i === b.ARRAY_BUFFER && (f.byteStride = a), this.byteOffset += c, r.bufferViews.push(f), {
4441
4853
  id: r.bufferViews.length - 1,
4442
4854
  byteLength: 0
4443
4855
  };
@@ -4450,8 +4862,8 @@ class ln {
4450
4862
  processBufferViewImage(t) {
4451
4863
  const e = this, n = e.json;
4452
4864
  return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
4453
- ut(t).then((i) => {
4454
- const r = ht(i), o = {
4865
+ ft(t).then((i) => {
4866
+ const r = dt(i), o = {
4455
4867
  buffer: e.processBuffer(r),
4456
4868
  byteOffset: e.byteOffset,
4457
4869
  byteLength: r.byteLength
@@ -4495,7 +4907,7 @@ class ln {
4495
4907
  else
4496
4908
  throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
4497
4909
  if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
4498
- const a = an(t, n, s);
4910
+ const a = fn(t, n, s);
4499
4911
  let c;
4500
4912
  e !== void 0 && (c = t === e.index ? b.ELEMENT_ARRAY_BUFFER : b.ARRAY_BUFFER);
4501
4913
  const l = this.processBufferView(t, o, n, s, c), h = {
@@ -4524,28 +4936,28 @@ class ln {
4524
4936
  const l = r.images.get(t), h = s + ":flipY/" + n.toString();
4525
4937
  if (l[h] !== void 0) return l[h];
4526
4938
  o.images || (o.images = []);
4527
- const d = { mimeType: s }, f = vt();
4528
- f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
4529
- const p = f.getContext("2d", {
4939
+ const f = { mimeType: s }, d = Ot();
4940
+ d.width = Math.min(t.width, a.maxTextureSize), d.height = Math.min(t.height, a.maxTextureSize);
4941
+ const p = d.getContext("2d", {
4530
4942
  willReadFrequently: !0
4531
4943
  });
4532
- if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
4533
- e !== ne && console.error("GLTFExporter: Only RGBAFormat is supported.", e), (t.width > a.maxTextureSize || t.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", t);
4534
- const g = new Uint8ClampedArray(t.height * t.width * 4);
4535
- for (let x = 0; x < g.length; x += 4)
4536
- g[x + 0] = t.data[x + 0], g[x + 1] = t.data[x + 1], g[x + 2] = t.data[x + 2], g[x + 3] = t.data[x + 3];
4537
- p.putImageData(new ImageData(g, t.width, t.height), 0, 0);
4944
+ if (n === !0 && (p.translate(0, d.height), p.scale(1, -1)), t.data !== void 0) {
4945
+ e !== de && console.error("GLTFExporter: Only RGBAFormat is supported.", e), (t.width > a.maxTextureSize || t.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", t);
4946
+ const y = new Uint8ClampedArray(t.height * t.width * 4);
4947
+ for (let x = 0; x < y.length; x += 4)
4948
+ y[x + 0] = t.data[x + 0], y[x + 1] = t.data[x + 1], y[x + 2] = t.data[x + 2], y[x + 3] = t.data[x + 3];
4949
+ p.putImageData(new ImageData(y, t.width, t.height), 0, 0);
4538
4950
  } else if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas)
4539
- p.drawImage(t, 0, 0, f.width, f.height);
4951
+ p.drawImage(t, 0, 0, d.width, d.height);
4540
4952
  else
4541
4953
  throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
4542
4954
  a.binary === !0 ? c.push(
4543
- cn(f, s).then((g) => i.processBufferViewImage(g)).then((g) => {
4544
- d.bufferView = g;
4955
+ pn(d, s).then((y) => i.processBufferViewImage(y)).then((y) => {
4956
+ f.bufferView = y;
4545
4957
  })
4546
- ) : d.uri = se.getDataURL(f, s);
4547
- const y = o.images.push(d) - 1;
4548
- return l[h] = y, y;
4958
+ ) : f.uri = fe.getDataURL(d, s);
4959
+ const g = o.images.push(f) - 1;
4960
+ return l[h] = g, g;
4549
4961
  } else
4550
4962
  throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
4551
4963
  }
@@ -4558,10 +4970,10 @@ class ln {
4558
4970
  const e = this.json;
4559
4971
  e.samplers || (e.samplers = []);
4560
4972
  const n = {
4561
- magFilter: j[t.magFilter],
4562
- minFilter: j[t.minFilter],
4563
- wrapS: j[t.wrapS],
4564
- wrapT: j[t.wrapT]
4973
+ magFilter: F[t.magFilter],
4974
+ minFilter: F[t.minFilter],
4975
+ wrapS: F[t.wrapS],
4976
+ wrapT: F[t.wrapT]
4565
4977
  };
4566
4978
  return e.samplers.push(n) - 1;
4567
4979
  }
@@ -4573,7 +4985,7 @@ class ln {
4573
4985
  async processTextureAsync(t) {
4574
4986
  const n = this.options, s = this.cache, i = this.json;
4575
4987
  if (s.textures.has(t)) return s.textures.get(t);
4576
- i.textures || (i.textures = []), t instanceof ct && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
4988
+ i.textures || (i.textures = []), t instanceof ht && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
4577
4989
  let r = t.userData.mimeType;
4578
4990
  r === "image/webp" && (r = "image/png");
4579
4991
  const o = {
@@ -4638,7 +5050,7 @@ class ln {
4638
5050
  };
4639
5051
  t.aoMapIntensity !== 1 && (o.strength = t.aoMapIntensity), this.applyTextureTransform(o, t.aoMap), s.occlusionTexture = o;
4640
5052
  }
4641
- t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === ie && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
5053
+ t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === pe && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
4642
5054
  o.writeMaterialAsync && await o.writeMaterialAsync(t, s);
4643
5055
  });
4644
5056
  const r = n.materials.push(s) - 1;
@@ -4652,7 +5064,7 @@ class ln {
4652
5064
  async processMeshAsync(t) {
4653
5065
  const e = this.cache, n = this.json, s = [t.geometry.uuid];
4654
5066
  if (Array.isArray(t.material))
4655
- for (let M = 0, S = t.material.length; M < S; M++)
5067
+ for (let M = 0, E = t.material.length; M < E; M++)
4656
5068
  s.push(t.material[M].uuid);
4657
5069
  else
4658
5070
  s.push(t.material.uuid);
@@ -4661,7 +5073,7 @@ class ln {
4661
5073
  const r = t.geometry;
4662
5074
  let o;
4663
5075
  t.isLineSegments ? o = b.LINES : t.isLineLoop ? o = b.LINE_LOOP : t.isLine ? o = b.LINE_STRIP : t.isPoints ? o = b.POINTS : o = t.material.wireframe ? b.LINES : b.TRIANGLES;
4664
- const a = {}, c = {}, l = [], h = [], d = {
5076
+ const a = {}, c = {}, l = [], h = [], f = {
4665
5077
  uv: "TEXCOORD_0",
4666
5078
  uv1: "TEXCOORD_1",
4667
5079
  uv2: "TEXCOORD_2",
@@ -4669,63 +5081,63 @@ class ln {
4669
5081
  color: "COLOR_0",
4670
5082
  skinWeight: "WEIGHTS_0",
4671
5083
  skinIndex: "JOINTS_0"
4672
- }, f = r.getAttribute("normal");
4673
- f !== void 0 && !this.isNormalizedNormalAttribute(f) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(f)));
5084
+ }, d = r.getAttribute("normal");
5085
+ d !== void 0 && !this.isNormalizedNormalAttribute(d) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(d)));
4674
5086
  let p = null;
4675
5087
  for (let M in r.attributes) {
4676
5088
  if (M.slice(0, 5) === "morph") continue;
4677
- const S = r.attributes[M];
4678
- if (M = d[M] || M.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(M) || (M = "_" + M), e.attributes.has(this.getUID(S))) {
4679
- c[M] = e.attributes.get(this.getUID(S));
5089
+ const E = r.attributes[M];
5090
+ if (M = f[M] || M.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(M) || (M = "_" + M), e.attributes.has(this.getUID(E))) {
5091
+ c[M] = e.attributes.get(this.getUID(E));
4680
5092
  continue;
4681
5093
  }
4682
5094
  p = null;
4683
- const E = S.array;
4684
- M === "JOINTS_0" && !(E instanceof Uint16Array) && !(E instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new _(new Uint16Array(E), S.itemSize, S.normalized)) : (E instanceof Uint32Array || E instanceof Int32Array) && !M.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${M}" converted to type FLOAT.`), p = ot.Utils.toFloat32BufferAttribute(S));
4685
- const T = this.processAccessor(p || S, r);
4686
- T !== null && (M.startsWith("_") || this.detectMeshQuantization(M, S), c[M] = T, e.attributes.set(this.getUID(S), T));
5095
+ const S = E.array;
5096
+ M === "JOINTS_0" && !(S instanceof Uint16Array) && !(S instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new Y(new Uint16Array(S), E.itemSize, E.normalized)) : (S instanceof Uint32Array || S instanceof Int32Array) && !M.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${M}" converted to type FLOAT.`), p = at.Utils.toFloat32BufferAttribute(E));
5097
+ const T = this.processAccessor(p || E, r);
5098
+ T !== null && (M.startsWith("_") || this.detectMeshQuantization(M, E), c[M] = T, e.attributes.set(this.getUID(E), T));
4687
5099
  }
4688
- if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
5100
+ if (d !== void 0 && r.setAttribute("normal", d), Object.keys(c).length === 0) return null;
4689
5101
  if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
4690
- const M = [], S = [], A = {};
5102
+ const M = [], E = [], A = {};
4691
5103
  if (t.morphTargetDictionary !== void 0)
4692
- for (const E in t.morphTargetDictionary)
4693
- A[t.morphTargetDictionary[E]] = E;
4694
- for (let E = 0; E < t.morphTargetInfluences.length; ++E) {
5104
+ for (const S in t.morphTargetDictionary)
5105
+ A[t.morphTargetDictionary[S]] = S;
5106
+ for (let S = 0; S < t.morphTargetInfluences.length; ++S) {
4695
5107
  const T = {};
4696
- let C = !1;
4697
- for (const N in r.morphAttributes) {
4698
- if (N !== "position" && N !== "normal") {
4699
- C || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), C = !0);
5108
+ let P = !1;
5109
+ for (const I in r.morphAttributes) {
5110
+ if (I !== "position" && I !== "normal") {
5111
+ P || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), P = !0);
4700
5112
  continue;
4701
5113
  }
4702
- const O = r.morphAttributes[N][E], q = N.toUpperCase(), U = r.attributes[N];
4703
- if (e.attributes.has(this.getUID(O, !0))) {
4704
- T[q] = e.attributes.get(this.getUID(O, !0));
5114
+ const C = r.morphAttributes[I][S], N = I.toUpperCase(), _ = r.attributes[I];
5115
+ if (e.attributes.has(this.getUID(C, !0))) {
5116
+ T[N] = e.attributes.get(this.getUID(C, !0));
4705
5117
  continue;
4706
5118
  }
4707
- const R = O.clone();
5119
+ const G = C.clone();
4708
5120
  if (!r.morphTargetsRelative)
4709
- for (let v = 0, K = O.count; v < K; v++)
4710
- for (let F = 0; F < O.itemSize; F++)
4711
- F === 0 && R.setX(v, O.getX(v) - U.getX(v)), F === 1 && R.setY(v, O.getY(v) - U.getY(v)), F === 2 && R.setZ(v, O.getZ(v) - U.getZ(v)), F === 3 && R.setW(v, O.getW(v) - U.getW(v));
4712
- T[q] = this.processAccessor(R, r), e.attributes.set(this.getUID(U, !0), T[q]);
5121
+ for (let B = 0, Mt = C.count; B < Mt; B++)
5122
+ for (let X = 0; X < C.itemSize; X++)
5123
+ X === 0 && G.setX(B, C.getX(B) - _.getX(B)), X === 1 && G.setY(B, C.getY(B) - _.getY(B)), X === 2 && G.setZ(B, C.getZ(B) - _.getZ(B)), X === 3 && G.setW(B, C.getW(B) - _.getW(B));
5124
+ T[N] = this.processAccessor(G, r), e.attributes.set(this.getUID(_, !0), T[N]);
4713
5125
  }
4714
- h.push(T), M.push(t.morphTargetInfluences[E]), t.morphTargetDictionary !== void 0 && S.push(A[E]);
5126
+ h.push(T), M.push(t.morphTargetInfluences[S]), t.morphTargetDictionary !== void 0 && E.push(A[S]);
4715
5127
  }
4716
- a.weights = M, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
5128
+ a.weights = M, E.length > 0 && (a.extras = {}, a.extras.targetNames = E);
4717
5129
  }
4718
- const y = Array.isArray(t.material);
4719
- if (y && r.groups.length === 0) return null;
4720
- let g = !1;
4721
- if (y && r.index === null) {
5130
+ const g = Array.isArray(t.material);
5131
+ if (g && r.groups.length === 0) return null;
5132
+ let y = !1;
5133
+ if (g && r.index === null) {
4722
5134
  const M = [];
4723
- for (let S = 0, A = r.attributes.position.count; S < A; S++)
4724
- M[S] = S;
4725
- r.setIndex(M), g = !0;
5135
+ for (let E = 0, A = r.attributes.position.count; E < A; E++)
5136
+ M[E] = E;
5137
+ r.setIndex(M), y = !0;
4726
5138
  }
4727
- const x = y ? t.material : [t.material], m = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
4728
- for (let M = 0, S = m.length; M < S; M++) {
5139
+ const x = g ? t.material : [t.material], m = g ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
5140
+ for (let M = 0, E = m.length; M < E; M++) {
4729
5141
  const A = {
4730
5142
  mode: o,
4731
5143
  attributes: c
@@ -4734,14 +5146,14 @@ class ln {
4734
5146
  let T = this.getUID(r.index);
4735
5147
  (m[M].start !== void 0 || m[M].count !== void 0) && (T += ":" + m[M].start + ":" + m[M].count), e.attributes.has(T) ? A.indices = e.attributes.get(T) : (A.indices = this.processAccessor(r.index, r, m[M].start, m[M].count), e.attributes.set(T, A.indices)), A.indices === null && delete A.indices;
4736
5148
  }
4737
- const E = await this.processMaterialAsync(x[m[M].materialIndex]);
4738
- E !== null && (A.material = E), l.push(A);
5149
+ const S = await this.processMaterialAsync(x[m[M].materialIndex]);
5150
+ S !== null && (A.material = S), l.push(A);
4739
5151
  }
4740
- g === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(M) {
5152
+ y === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(M) {
4741
5153
  M.writeMesh && M.writeMesh(t, a);
4742
5154
  });
4743
- const L = n.meshes.push(a) - 1;
4744
- return e.meshes.set(i, L), L;
5155
+ const w = n.meshes.push(a) - 1;
5156
+ return e.meshes.set(i, w), w;
4745
5157
  }
4746
5158
  /**
4747
5159
  * If a vertex attribute with a
@@ -4755,7 +5167,7 @@ class ln {
4755
5167
  * @param {THREE.BufferAttribute} attribute
4756
5168
  */
4757
5169
  detectMeshQuantization(t, e) {
4758
- if (this.extensionsUsed[lt]) return;
5170
+ if (this.extensionsUsed[ut]) return;
4759
5171
  let n;
4760
5172
  switch (e.array.constructor) {
4761
5173
  case Int8Array:
@@ -4775,7 +5187,7 @@ class ln {
4775
5187
  }
4776
5188
  e.normalized && (n += " normalized");
4777
5189
  const s = t.split("_", 1)[0];
4778
- bt[s] && bt[s].includes(n) && (this.extensionsUsed[lt] = !0, this.extensionsRequired[lt] = !0);
5190
+ Ct[s] && Ct[s].includes(n) && (this.extensionsUsed[ut] = !0, this.extensionsRequired[ut] = !0);
4779
5191
  }
4780
5192
  /**
4781
5193
  * Process camera
@@ -4795,7 +5207,7 @@ class ln {
4795
5207
  znear: t.near < 0 ? 0 : t.near
4796
5208
  } : s.perspective = {
4797
5209
  aspectRatio: t.aspect,
4798
- yfov: dt.degToRad(t.fov),
5210
+ yfov: pt.degToRad(t.fov),
4799
5211
  zfar: t.far <= 0 ? 1e-3 : t.far,
4800
5212
  znear: t.near < 0 ? 0 : t.near
4801
5213
  }, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
@@ -4812,29 +5224,29 @@ class ln {
4812
5224
  */
4813
5225
  processAnimation(t, e) {
4814
5226
  const n = this.json, s = this.nodeMap;
4815
- n.animations || (n.animations = []), t = ot.Utils.mergeMorphTargetTracks(t.clone(), e);
5227
+ n.animations || (n.animations = []), t = at.Utils.mergeMorphTargetTracks(t.clone(), e);
4816
5228
  const i = t.tracks, r = [], o = [];
4817
5229
  for (let c = 0; c < i.length; ++c) {
4818
5230
  const l = i[c], h = rt.parseTrackName(l.name);
4819
- let d = rt.findNode(e, h.nodeName);
4820
- const f = Tt[h.propertyName];
4821
- if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !f) {
5231
+ let f = rt.findNode(e, h.nodeName);
5232
+ const d = Nt[h.propertyName];
5233
+ if (h.objectName === "bones" && (f.isSkinnedMesh === !0 ? f = f.skeleton.getBoneByName(h.objectIndex) : f = void 0), !f || !d) {
4822
5234
  console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
4823
5235
  continue;
4824
5236
  }
4825
5237
  const p = 1;
4826
- let y = l.values.length / l.times.length;
4827
- f === Tt.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
4828
- let g;
4829
- l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (g = "CUBICSPLINE", y /= 3) : l.getInterpolation() === re ? g = "STEP" : g = "LINEAR", o.push({
4830
- input: this.processAccessor(new _(l.times, p)),
4831
- output: this.processAccessor(new _(l.values, y)),
4832
- interpolation: g
5238
+ let g = l.values.length / l.times.length;
5239
+ d === Nt.morphTargetInfluences && (g /= f.morphTargetInfluences.length);
5240
+ let y;
5241
+ l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (y = "CUBICSPLINE", g /= 3) : l.getInterpolation() === ge ? y = "STEP" : y = "LINEAR", o.push({
5242
+ input: this.processAccessor(new Y(l.times, p)),
5243
+ output: this.processAccessor(new Y(l.values, g)),
5244
+ interpolation: y
4833
5245
  }), r.push({
4834
5246
  sampler: o.length - 1,
4835
5247
  target: {
4836
- node: s.get(d),
4837
- path: f
5248
+ node: s.get(f),
5249
+ path: d
4838
5250
  }
4839
5251
  });
4840
5252
  }
@@ -4854,11 +5266,11 @@ class ln {
4854
5266
  if (i === void 0) return null;
4855
5267
  const r = t.skeleton.bones[0];
4856
5268
  if (r === void 0) return null;
4857
- const o = [], a = new Float32Array(i.bones.length * 16), c = new Ct();
5269
+ const o = [], a = new Float32Array(i.bones.length * 16), c = new Gt();
4858
5270
  for (let h = 0; h < i.bones.length; ++h)
4859
5271
  o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
4860
5272
  return e.skins === void 0 && (e.skins = []), e.skins.push({
4861
- inverseBindMatrices: this.processAccessor(new _(a, 16)),
5273
+ inverseBindMatrices: this.processAccessor(new Y(a, 16)),
4862
5274
  joints: o,
4863
5275
  skeleton: n.get(r)
4864
5276
  }), s.skin = e.skins.length - 1;
@@ -4876,7 +5288,7 @@ class ln {
4876
5288
  const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
4877
5289
  Q(o, [0, 0, 0, 1]) || (i.rotation = o), Q(a, [0, 0, 0]) || (i.translation = a), Q(c, [1, 1, 1]) || (i.scale = c);
4878
5290
  } else
4879
- t.matrixAutoUpdate && t.updateMatrix(), on(t.matrix) === !1 && (i.matrix = t.matrix.elements);
5291
+ t.matrixAutoUpdate && t.updateMatrix(), dn(t.matrix) === !1 && (i.matrix = t.matrix.elements);
4880
5292
  if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
4881
5293
  const o = await this.processMeshAsync(t);
4882
5294
  o !== null && (i.mesh = o);
@@ -4922,7 +5334,7 @@ class ln {
4922
5334
  * @param {Array<THREE.Object3D>} objects List of objects to process
4923
5335
  */
4924
5336
  async processObjectsAsync(t) {
4925
- const e = new yt();
5337
+ const e = new Dt();
4926
5338
  e.name = "AuxScene";
4927
5339
  for (let n = 0; n < t.length; n++)
4928
5340
  e.children.push(t[n]);
@@ -4938,7 +5350,7 @@ class ln {
4938
5350
  });
4939
5351
  const n = [];
4940
5352
  for (let s = 0; s < t.length; s++)
4941
- t[s] instanceof yt ? await this.processSceneAsync(t[s]) : n.push(t[s]);
5353
+ t[s] instanceof Dt ? await this.processSceneAsync(t[s]) : n.push(t[s]);
4942
5354
  n.length > 0 && await this.processObjectsAsync(n);
4943
5355
  for (let s = 0; s < this.skins.length; ++s)
4944
5356
  this.processSkin(this.skins[s]);
@@ -4953,7 +5365,7 @@ class ln {
4953
5365
  await t(this.plugins[e]);
4954
5366
  }
4955
5367
  }
4956
- class hn {
5368
+ class yn {
4957
5369
  constructor(t) {
4958
5370
  this.writer = t, this.name = "KHR_lights_punctual";
4959
5371
  }
@@ -4969,7 +5381,7 @@ class hn {
4969
5381
  o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
4970
5382
  }
4971
5383
  }
4972
- class un {
5384
+ class xn {
4973
5385
  constructor(t) {
4974
5386
  this.writer = t, this.name = "KHR_materials_unlit";
4975
5387
  }
@@ -4979,7 +5391,7 @@ class un {
4979
5391
  e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
4980
5392
  }
4981
5393
  }
4982
- class dn {
5394
+ class mn {
4983
5395
  constructor(t) {
4984
5396
  this.writer = t, this.name = "KHR_materials_clearcoat";
4985
5397
  }
@@ -5010,7 +5422,7 @@ class dn {
5010
5422
  e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5011
5423
  }
5012
5424
  }
5013
- class fn {
5425
+ class wn {
5014
5426
  constructor(t) {
5015
5427
  this.writer = t, this.name = "KHR_materials_dispersion";
5016
5428
  }
@@ -5020,7 +5432,7 @@ class fn {
5020
5432
  i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5021
5433
  }
5022
5434
  }
5023
- class pn {
5435
+ class Mn {
5024
5436
  constructor(t) {
5025
5437
  this.writer = t, this.name = "KHR_materials_iridescence";
5026
5438
  }
@@ -5044,7 +5456,7 @@ class pn {
5044
5456
  e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5045
5457
  }
5046
5458
  }
5047
- class gn {
5459
+ class Dn {
5048
5460
  constructor(t) {
5049
5461
  this.writer = t, this.name = "KHR_materials_transmission";
5050
5462
  }
@@ -5061,7 +5473,7 @@ class gn {
5061
5473
  e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5062
5474
  }
5063
5475
  }
5064
- class yn {
5476
+ class Ln {
5065
5477
  constructor(t) {
5066
5478
  this.writer = t, this.name = "KHR_materials_volume";
5067
5479
  }
@@ -5078,7 +5490,7 @@ class yn {
5078
5490
  t.attenuationDistance !== 1 / 0 && (i.attenuationDistance = t.attenuationDistance), i.attenuationColor = t.attenuationColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5079
5491
  }
5080
5492
  }
5081
- class xn {
5493
+ class Sn {
5082
5494
  constructor(t) {
5083
5495
  this.writer = t, this.name = "KHR_materials_ior";
5084
5496
  }
@@ -5088,12 +5500,12 @@ class xn {
5088
5500
  i.ior = t.ior, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5089
5501
  }
5090
5502
  }
5091
- class mn {
5503
+ class En {
5092
5504
  constructor(t) {
5093
5505
  this.writer = t, this.name = "KHR_materials_specular";
5094
5506
  }
5095
5507
  async writeMaterialAsync(t, e) {
5096
- if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(Qe) && !t.specularIntensityMap && !t.specularColorMap) return;
5508
+ if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(on) && !t.specularIntensityMap && !t.specularColorMap) return;
5097
5509
  const n = this.writer, s = n.extensionsUsed, i = {};
5098
5510
  if (t.specularIntensityMap) {
5099
5511
  const r = {
@@ -5112,7 +5524,7 @@ class mn {
5112
5524
  i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5113
5525
  }
5114
5526
  }
5115
- class wn {
5527
+ class An {
5116
5528
  constructor(t) {
5117
5529
  this.writer = t, this.name = "KHR_materials_sheen";
5118
5530
  }
@@ -5136,7 +5548,7 @@ class wn {
5136
5548
  i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5137
5549
  }
5138
5550
  }
5139
- class Mn {
5551
+ class Tn {
5140
5552
  constructor(t) {
5141
5553
  this.writer = t, this.name = "KHR_materials_anisotropy";
5142
5554
  }
@@ -5150,7 +5562,7 @@ class Mn {
5150
5562
  i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5151
5563
  }
5152
5564
  }
5153
- class Dn {
5565
+ class bn {
5154
5566
  constructor(t) {
5155
5567
  this.writer = t, this.name = "KHR_materials_emissive_strength";
5156
5568
  }
@@ -5160,7 +5572,7 @@ class Dn {
5160
5572
  i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5161
5573
  }
5162
5574
  }
5163
- class Ln {
5575
+ class Pn {
5164
5576
  constructor(t) {
5165
5577
  this.writer = t, this.name = "EXT_materials_bump";
5166
5578
  }
@@ -5177,24 +5589,24 @@ class Ln {
5177
5589
  i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
5178
5590
  }
5179
5591
  }
5180
- class Sn {
5592
+ class In {
5181
5593
  constructor(t) {
5182
5594
  this.writer = t, this.name = "EXT_mesh_gpu_instancing";
5183
5595
  }
5184
5596
  writeNode(t, e) {
5185
5597
  if (!t.isInstancedMesh) return;
5186
- const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Ct(), c = new it(), l = new Zt(), h = new it();
5187
- for (let f = 0; f < s.count; f++)
5188
- s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
5189
- const d = {
5190
- TRANSLATION: n.processAccessor(new _(i, 3)),
5191
- ROTATION: n.processAccessor(new _(r, 4)),
5192
- SCALE: n.processAccessor(new _(o, 3))
5598
+ const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Gt(), c = new it(), l = new ce(), h = new it();
5599
+ for (let d = 0; d < s.count; d++)
5600
+ s.getMatrixAt(d, a), a.decompose(c, l, h), c.toArray(i, d * 3), l.toArray(r, d * 4), h.toArray(o, d * 3);
5601
+ const f = {
5602
+ TRANSLATION: n.processAccessor(new Y(i, 3)),
5603
+ ROTATION: n.processAccessor(new Y(r, 4)),
5604
+ SCALE: n.processAccessor(new Y(o, 3))
5193
5605
  };
5194
- s.instanceColor && (d._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: d }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
5606
+ s.instanceColor && (f._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: f }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
5195
5607
  }
5196
5608
  }
5197
- ot.Utils = {
5609
+ at.Utils = {
5198
5610
  insertKeyframe: function(u, t) {
5199
5611
  const n = u.getValueSize(), s = new u.TimeBufferType(u.times.length + 1), i = new u.ValueBufferType(u.values.length + n), r = u.createInterpolant(new u.ValueBufferType(n));
5200
5612
  let o;
@@ -5232,7 +5644,7 @@ ot.Utils = {
5232
5644
  if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
5233
5645
  if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
5234
5646
  throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
5235
- console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(ye);
5647
+ console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(Te);
5236
5648
  }
5237
5649
  const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
5238
5650
  if (l === void 0)
@@ -5240,25 +5652,25 @@ ot.Utils = {
5240
5652
  let h;
5241
5653
  if (n[a.uuid] === void 0) {
5242
5654
  h = r.clone();
5243
- const f = new h.ValueBufferType(c * h.times.length);
5655
+ const d = new h.ValueBufferType(c * h.times.length);
5244
5656
  for (let p = 0; p < h.times.length; p++)
5245
- f[p * c + l] = h.values[p];
5246
- h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = f, n[a.uuid] = h, e.push(h);
5657
+ d[p * c + l] = h.values[p];
5658
+ h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = d, n[a.uuid] = h, e.push(h);
5247
5659
  continue;
5248
5660
  }
5249
- const d = r.createInterpolant(new r.ValueBufferType(1));
5661
+ const f = r.createInterpolant(new r.ValueBufferType(1));
5250
5662
  h = n[a.uuid];
5251
- for (let f = 0; f < h.times.length; f++)
5252
- h.values[f * c + l] = d.evaluate(h.times[f]);
5253
- for (let f = 0; f < r.times.length; f++) {
5254
- const p = this.insertKeyframe(h, r.times[f]);
5255
- h.values[p * c + l] = r.values[f];
5663
+ for (let d = 0; d < h.times.length; d++)
5664
+ h.values[d * c + l] = f.evaluate(h.times[d]);
5665
+ for (let d = 0; d < r.times.length; d++) {
5666
+ const p = this.insertKeyframe(h, r.times[d]);
5667
+ h.values[p * c + l] = r.values[d];
5256
5668
  }
5257
5669
  }
5258
5670
  return u.tracks = e, u;
5259
5671
  },
5260
5672
  toFloat32BufferAttribute: function(u) {
5261
- const t = new _(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
5673
+ const t = new Y(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
5262
5674
  if (!u.normalized && !u.isInterleavedBufferAttribute)
5263
5675
  return t.array.set(u.array), t;
5264
5676
  for (let e = 0, n = u.count; e < n; e++)
@@ -5267,7 +5679,7 @@ ot.Utils = {
5267
5679
  return t;
5268
5680
  }
5269
5681
  };
5270
- async function En(u) {
5682
+ async function vn(u) {
5271
5683
  if (typeof FileReader > "u") {
5272
5684
  const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
5273
5685
  return `data:${u.type};base64,${n}`;
@@ -5277,7 +5689,7 @@ async function En(u) {
5277
5689
  n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(u);
5278
5690
  });
5279
5691
  }
5280
- async function ut(u) {
5692
+ async function ft(u) {
5281
5693
  if (typeof u.arrayBuffer == "function")
5282
5694
  return await u.arrayBuffer();
5283
5695
  if (typeof FileReader < "u")
@@ -5290,33 +5702,33 @@ async function ut(u) {
5290
5702
  return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
5291
5703
  }
5292
5704
  }
5293
- const An = new xe(), bn = new ot();
5294
- function Tn(u, t, e = 0.1) {
5705
+ const Rn = new be(), Cn = new at();
5706
+ function Nn(u, t, e = 0.1) {
5295
5707
  const n = t.normal(u), s = t.direction(u).mutiplyScalar(e * 0.5), i = u.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
5296
5708
  return {
5297
5709
  points: [
5298
5710
  // 第一条线
5299
- new w(u.x + r, u.y + o).add(i),
5300
- new w(t.x + r, t.y + o).add(s),
5711
+ new D(u.x + r, u.y + o).add(i),
5712
+ new D(t.x + r, t.y + o).add(s),
5301
5713
  // 第二条线
5302
- new w(u.x - r, u.y - o).add(i),
5303
- new w(t.x - r, t.y - o).add(s)
5714
+ new D(u.x - r, u.y - o).add(i),
5715
+ new D(t.x - r, t.y - o).add(s)
5304
5716
  ],
5305
5717
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
5306
5718
  rectIndices: [0, 1, 3, 2, 0]
5307
5719
  };
5308
5720
  }
5309
- class Yt extends G {
5721
+ class ee extends z {
5310
5722
  static name = "WhiteModel";
5311
5723
  Dxf = null;
5312
5724
  Variable = null;
5313
5725
  // dxf数据白模
5314
- whiteModelGroup = new P.Group();
5726
+ whiteModelGroup = new v.Group();
5315
5727
  // dxf数据白模边缘线
5316
- whiteModelLineGroup = new P.Group();
5728
+ whiteModelLineGroup = new v.Group();
5317
5729
  // 原始数据白模
5318
- originalWhiteMode = new P.Group();
5319
- material = new P.MeshStandardMaterial({ color: 16777215, transparent: !0, opacity: 0.8, side: P.DoubleSide });
5730
+ originalWhiteMode = new v.Group();
5731
+ material = new v.MeshStandardMaterial({ color: 16777215, transparent: !0, opacity: 0.8, side: v.DoubleSide });
5320
5732
  onAddFromParent(t) {
5321
5733
  this.Dxf = t.findComponentByName("Dxf"), this.Variable = t.findComponentByName("Variable"), this.originalWhiteMode.visible = !1, this.Dxf?.addEventListener("lineOffset", () => {
5322
5734
  this.updateModel();
@@ -5326,17 +5738,17 @@ class Yt extends G {
5326
5738
  this.Variable?.set("whiteModelVisible", !1);
5327
5739
  const t = this.Dxf;
5328
5740
  this.originalWhiteMode.clear(), this.whiteModelGroup.clear(), this.whiteModelLineGroup.clear(), this.whiteModelGroup.add(this.whiteModelLineGroup), this.whiteModelGroup.position.z = t.originalZAverage, this.originalWhiteMode.position.z = t.originalZAverage, t.wallsGroup.forEach((n) => {
5329
- const s = new P.Shape();
5741
+ const s = new v.Shape();
5330
5742
  n.forEach((o, a) => a === 0 ? s.moveTo(o.x / t.scale, o.y / t.scale) : s.lineTo(o.x / t.scale, o.y / t.scale));
5331
- const i = new P.ExtrudeGeometry(s, {
5743
+ const i = new v.ExtrudeGeometry(s, {
5332
5744
  depth: 2.8,
5333
5745
  bevelSize: 0
5334
- }), r = new P.Mesh(i, this.material);
5746
+ }), r = new v.Mesh(i, this.material);
5335
5747
  this.whiteModelGroup.add(r), this.whiteModelLineGroup.add(
5336
- new P.LineSegments(new P.EdgesGeometry(i), new P.LineBasicMaterial({ color: 0 }))
5748
+ new v.LineSegments(new v.EdgesGeometry(i), new v.LineBasicMaterial({ color: 0 }))
5337
5749
  );
5338
5750
  }), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
5339
- const r = new w(n.x, n.y).mutiplyScalar(t.scale), o = new w(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = Tn(r, o, t.width);
5751
+ const r = new D(n.x, n.y).mutiplyScalar(t.scale), o = new D(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = Nn(r, o, t.width);
5340
5752
  return {
5341
5753
  points: a,
5342
5754
  indices: c,
@@ -5344,17 +5756,17 @@ class Yt extends G {
5344
5756
  insetions: (i ?? []).map((h) => h.index)
5345
5757
  };
5346
5758
  }).forEach((n) => {
5347
- const s = new P.Shape();
5759
+ const s = new v.Shape();
5348
5760
  n.rectIndices.forEach((o, a) => {
5349
5761
  const c = n.points[o];
5350
5762
  a === 0 ? s.moveTo(c.x, c.y) : s.lineTo(c.x, c.y);
5351
5763
  });
5352
- const i = new P.ExtrudeGeometry(s, {
5764
+ const i = new v.ExtrudeGeometry(s, {
5353
5765
  depth: 2.8,
5354
5766
  bevelSize: 0
5355
5767
  });
5356
5768
  if (i.attributes.position.array.filter((o) => Number.isNaN(o)).length) return;
5357
- const r = new P.Mesh(i);
5769
+ const r = new v.Mesh(i);
5358
5770
  this.originalWhiteMode?.add(r);
5359
5771
  }), this.dispatchEvent({
5360
5772
  type: "updateModel",
@@ -5369,7 +5781,7 @@ class Yt extends G {
5369
5781
  toOBJ() {
5370
5782
  return new Promise((t) => {
5371
5783
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
5372
- t(An.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
5784
+ t(Rn.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
5373
5785
  }, 20);
5374
5786
  });
5375
5787
  }
@@ -5381,7 +5793,7 @@ class Yt extends G {
5381
5793
  toGltf(t = !0) {
5382
5794
  return new Promise((e) => {
5383
5795
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
5384
- bn.parse(this.whiteModelGroup.children, (n) => {
5796
+ Cn.parse(this.whiteModelGroup.children, (n) => {
5385
5797
  e(n), this.material.opacity = 0.8, this.material.transparent = !0;
5386
5798
  }, () => {
5387
5799
  e(void 0);
@@ -5442,7 +5854,7 @@ class Yt extends G {
5442
5854
  }
5443
5855
  }
5444
5856
  }
5445
- class Xt extends G {
5857
+ class ne extends z {
5446
5858
  static name = "DetailsPoint";
5447
5859
  Dxf = null;
5448
5860
  WhiteModel = null;
@@ -5493,17 +5905,17 @@ class Xt extends G {
5493
5905
  this._timer = null;
5494
5906
  const t = this.parent?.findComponentByName("WhiteModel");
5495
5907
  this.raylines.length = 0, this.desPoints.length = 0, this.data.forEach((e) => {
5496
- const n = new P.Vector3(
5908
+ const n = new v.Vector3(
5497
5909
  e.position.x,
5498
5910
  e.position.y,
5499
5911
  e.position.z
5500
- ), s = new P.Vector3(
5912
+ ), s = new v.Vector3(
5501
5913
  e.direction.x,
5502
5914
  e.direction.y,
5503
5915
  e.direction.z
5504
5916
  ), i = 100;
5505
5917
  this.racasterHelper(n, s, i), s.z = 0;
5506
- const o = new P.Raycaster(n, s, 0, i).intersectObject(t.originalWhiteMode);
5918
+ const o = new v.Raycaster(n, s, 0, i).intersectObject(t.originalWhiteMode);
5507
5919
  if (o.length) {
5508
5920
  const { point: a } = o[0];
5509
5921
  this.desPoints.push({
@@ -5519,71 +5931,73 @@ class Xt extends G {
5519
5931
  }, 50);
5520
5932
  }
5521
5933
  }
5522
- class Vt extends G {
5934
+ class se extends z {
5523
5935
  static name = "DxfLineModel";
5524
- dxfLineModel = new P.LineSegments();
5525
- dxfDoorsLineModel = new P.LineSegments();
5526
- dxfModelGroup = new P.Group();
5936
+ dxfLineModel = new v.LineSegments();
5937
+ dxfDoorsLineModel = new v.LineSegments();
5938
+ dxfModelGroup = new v.Group();
5527
5939
  onAddFromParent(t) {
5528
5940
  const e = t.findComponentByName("Dxf");
5529
- this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new P.LineBasicMaterial({ color: 16776960, vertexColors: !0 }), e?.addEventListener("lineOffset", () => this.updateMode());
5941
+ this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new v.LineBasicMaterial({ color: 16776960, vertexColors: !0 }), e?.addEventListener("lineOffset", () => this.updateMode());
5530
5942
  }
5531
5943
  updateMode() {
5532
5944
  const t = this.parent?.findComponentByName("Dxf");
5533
5945
  this.dxfLineModel.clear();
5534
5946
  const e = t.to3DArray(1 / t.scale, 0);
5535
- this.dxfLineModel.geometry = new P.BufferGeometry().setAttribute("position", new P.BufferAttribute(e, 3, !0));
5947
+ this.dxfLineModel.geometry = new v.BufferGeometry().setAttribute("position", new v.BufferAttribute(e, 3, !0));
5536
5948
  const n = new Float32Array(
5537
5949
  t.doorLineSegment.flatMap(({ start: i, end: r }) => [i.x, i.y, 0, r.x, r.y, 0])
5538
5950
  ).map((i) => i / t.scale), s = new Float32Array(t.doorLineSegment.flatMap(() => [1, 0, 0, 0, 1, 0]));
5539
- this.dxfDoorsLineModel.geometry = new P.BufferGeometry().setAttribute("position", new P.BufferAttribute(n, 3, !0)).setAttribute("color", new P.BufferAttribute(s, 3)), this.dxfModelGroup.position.z = t.originalZAverage, this.dispatchEvent({
5951
+ this.dxfDoorsLineModel.geometry = new v.BufferGeometry().setAttribute("position", new v.BufferAttribute(n, 3, !0)).setAttribute("color", new v.BufferAttribute(s, 3)), this.dxfModelGroup.position.z = t.originalZAverage, this.dispatchEvent({
5540
5952
  type: "modelUpdate",
5541
5953
  model: this.dxfModelGroup
5542
5954
  });
5543
5955
  }
5544
5956
  }
5545
- const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5957
+ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5546
5958
  __proto__: null,
5547
- DetailsPoint: Xt,
5548
- DxfLineModel: Vt,
5549
- WhiteModel: Yt
5959
+ DetailsPoint: ne,
5960
+ DxfLineModel: se,
5961
+ WhiteModel: ee
5550
5962
  }, Symbol.toStringTag, { value: "Module" }));
5551
- function Rt(u, t = {}) {
5963
+ function Ft(u, t = {}) {
5552
5964
  const {
5553
5965
  detailsPoint: e = !0,
5554
5966
  whiteModel: n = !0,
5555
5967
  dxfLineModel: s = !0
5556
5968
  } = t;
5557
- s && u.addComponent(new Vt()), n && u.addComponent(new Yt()), e && u.addComponent(new Xt());
5969
+ s && u.addComponent(new se()), n && u.addComponent(new ee()), e && u.addComponent(new ne());
5558
5970
  }
5559
- const In = Object.assign(Rt, {
5971
+ const jn = Object.assign(Ft, {
5560
5972
  create(u = {}) {
5561
- return (t) => Rt(t, u);
5973
+ return (t) => Ft(t, u);
5562
5974
  }
5563
- }), vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5975
+ }), On = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5564
5976
  __proto__: null,
5565
- ModelDataPlugin: In,
5566
- components: Pn
5977
+ ModelDataPlugin: jn,
5978
+ components: Bn
5567
5979
  }, Symbol.toStringTag, { value: "Module" }));
5568
- function Wt(u, t, e = 1e-3) {
5569
- if (Array.isArray(u) && u[0] instanceof w) {
5980
+ function ie(u, t, e = 1e-3) {
5981
+ if (Array.isArray(u) && u[0] instanceof D) {
5570
5982
  const s = u;
5571
5983
  u = s.map((i, r) => {
5572
5984
  const o = s[(r + 1) % s.length];
5573
- return new D(i, o);
5985
+ return new L(i, o);
5574
5986
  });
5575
5987
  }
5576
- if (u instanceof D) return Wt([u], t, e);
5988
+ if (u instanceof L) return ie([u], t, e);
5577
5989
  const n = Z.finalInstance;
5578
5990
  if (n) {
5579
5991
  const s = n.findComponentByName("Renderer");
5580
5992
  if (s) {
5581
- const i = n.findComponentByName("Editor"), r = s.createLineSegments(u, 0, t, i?.container);
5993
+ const i = n.findComponentByName("Editor");
5994
+ if (u.length === 0) return;
5995
+ const r = s.createLineSegments(u, 0, t, i?.container);
5582
5996
  return r.position.z = e, r;
5583
5997
  }
5584
5998
  }
5585
5999
  }
5586
- function Rn(u, t, e = 1e-3) {
6000
+ function Fn(u, t, e = 1e-3) {
5587
6001
  const n = Z.finalInstance;
5588
6002
  if (n) {
5589
6003
  const s = n.findComponentByName("Renderer");
@@ -5593,7 +6007,7 @@ function Rn(u, t, e = 1e-3) {
5593
6007
  }
5594
6008
  }
5595
6009
  }
5596
- function Cn(u, t, e, n = 1e-3) {
6010
+ function Gn(u, t, e, n = 1e-3) {
5597
6011
  const s = Z.finalInstance;
5598
6012
  if (s) {
5599
6013
  const i = s.findComponentByName("Renderer"), r = s.findComponentByName("Editor");
@@ -5603,16 +6017,31 @@ function Cn(u, t, e, n = 1e-3) {
5603
6017
  }
5604
6018
  }
5605
6019
  }
5606
- function Nn() {
6020
+ function Un() {
5607
6021
  return import("./index2.js");
5608
6022
  }
5609
- function Bn() {
6023
+ function qn() {
5610
6024
  return import("./index3.js");
5611
6025
  }
5612
- let gt = null;
5613
- typeof window < "u" && (window.drawLines = Wt, window.drawPoint = Rn, window.drawText = Cn, window.randomColor = () => Math.floor(Math.random() * 16777215));
5614
- async function zn(u, t, e = !1, n) {
5615
- const s = await Promise.resolve().then(() => vn), i = await Nn(), r = await Bn(), o = new Z().usePlugin(s.ModelDataPlugin.create({
6026
+ let wt = null, re = class {
6027
+ static preTime = performance.now();
6028
+ static firstTime = performance.now();
6029
+ static clear() {
6030
+ this.preTime = performance.now(), this.firstTime = this.preTime;
6031
+ }
6032
+ static timeConsuming(t = "") {
6033
+ const e = performance.now(), n = e - this.preTime;
6034
+ return console.log(t + " %c time " + parseFloat(n.toFixed(6)) + "ms", "color: green;"), this.preTime = e, n;
6035
+ }
6036
+ static totalTime(t = "") {
6037
+ const e = performance.now(), n = e - this.firstTime;
6038
+ return console.log(t + " %c totalTime " + parseFloat(n.toFixed(6)) + "ms", "color: green;"), this.preTime = e, n;
6039
+ }
6040
+ };
6041
+ typeof window < "u" && (window.drawLines = ie, window.drawPoint = Fn, window.drawText = Gn, window.randomColor = () => Math.floor(Math.random() * 16777215), window.Log = re);
6042
+ typeof globalThis < "u" && (globalThis.Log = re);
6043
+ async function Hn(u, t, e = !1, n) {
6044
+ const s = await Promise.resolve().then(() => On), i = await Un(), r = await qn(), o = new Z().usePlugin(s.ModelDataPlugin.create({
5616
6045
  detailsPoint: !1,
5617
6046
  whiteModel: !0
5618
6047
  })).usePlugin(i.RenderPlugin.create({
@@ -5622,12 +6051,12 @@ async function zn(u, t, e = !1, n) {
5622
6051
  orbitControls: e,
5623
6052
  camera: t
5624
6053
  })).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
5625
- return a && u.appendChild(a.domElement), gt = o, {
6054
+ return a && u.appendChild(a.domElement), wt = o, {
5626
6055
  dxfSystem: o,
5627
- getFileAll: () => On(o)
6056
+ getFileAll: () => zn(o)
5628
6057
  };
5629
6058
  }
5630
- async function On(u = gt) {
6059
+ async function zn(u = wt) {
5631
6060
  const t = u.findComponentByName("WhiteModel"), e = new File([await u.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([u.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([u.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(u.Dxf.originalData)], "json.json", { type: "application/json" });
5632
6061
  return {
5633
6062
  dxf: n,
@@ -5639,32 +6068,32 @@ async function On(u = gt) {
5639
6068
  correctionDxf: s
5640
6069
  };
5641
6070
  }
5642
- function _n() {
5643
- return gt;
6071
+ function $n() {
6072
+ return wt;
5644
6073
  }
5645
6074
  export {
5646
- Gt as A,
5647
- I as B,
5648
- G as C,
6075
+ Ht as A,
6076
+ R as B,
6077
+ z as C,
5649
6078
  Z as D,
5650
- Nt as E,
5651
- D as L,
5652
- In as M,
5653
- w as P,
5654
- B as Q,
5655
- He as T,
5656
- Ut as V,
5657
- Yt as W,
5658
- Xt as a,
5659
- Y as b,
5660
- J as c,
5661
- Xe as d,
5662
- zn as e,
5663
- _n as f,
5664
- On as g,
5665
- k as h,
5666
- Pn as i,
5667
- Un as j,
5668
- X as r,
5669
- tt as u
6079
+ Ut as E,
6080
+ L,
6081
+ jn as M,
6082
+ D as P,
6083
+ j as Q,
6084
+ Ze as T,
6085
+ Zt as V,
6086
+ ee as W,
6087
+ ne as a,
6088
+ q as b,
6089
+ V as c,
6090
+ $e as d,
6091
+ Hn as e,
6092
+ $n as f,
6093
+ zn as g,
6094
+ W as h,
6095
+ Bn as i,
6096
+ Vn as j,
6097
+ K as r,
6098
+ $ as u
5670
6099
  };