build-dxf 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/build.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as q from "three";
2
- import { EventDispatcher as ot } from "three";
2
+ import { EventDispatcher as rt } from "three";
3
3
  import Z from "clipper-lib";
4
4
  import W from "dxf-writer";
5
- import { OBJExporter as rt } from "three/examples/jsm/exporters/OBJExporter.js";
5
+ import { OBJExporter as ot } from "three/examples/jsm/exporters/OBJExporter.js";
6
6
  import { GLTFExporter as at } from "three/examples/jsm/exporters/GLTFExporter.js";
7
7
  function k() {
8
8
  return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(M) {
@@ -10,13 +10,13 @@ function k() {
10
10
  return e.toString(16);
11
11
  });
12
12
  }
13
- class tt extends ot {
13
+ class tt extends rt {
14
14
  uuid = k();
15
15
  addEventListener(t, e, n) {
16
- const { once: i = !1 } = n ?? {}, s = (r) => {
17
- e(r), i && o();
18
- }, o = () => this.removeEventListener(t, s);
19
- return super.addEventListener(t, s), o;
16
+ const { once: i = !1 } = n ?? {}, s = (o) => {
17
+ e(o), i && r();
18
+ }, r = () => this.removeEventListener(t, s);
19
+ return super.addEventListener(t, s), r;
20
20
  }
21
21
  eventRecordStack = /* @__PURE__ */ new Map();
22
22
  addEventRecord(t, ...e) {
@@ -207,8 +207,8 @@ class g {
207
207
  * @param angle 旋转角度,单位为弧度
208
208
  */
209
209
  rotate(t, e) {
210
- const n = this.x - t.x, i = this.y - t.y, s = Math.cos(e), o = Math.sin(e), r = n * s - i * o, l = n * o + i * s;
211
- return this.x = r + t.x, this.y = l + t.y, this;
210
+ const n = this.x - t.x, i = this.y - t.y, s = Math.cos(e), r = Math.sin(e), o = n * s - i * r, l = n * r + i * s;
211
+ return this.x = o + t.x, this.y = l + t.y, this;
212
212
  }
213
213
  /**
214
214
  * 保留小数位数
@@ -233,8 +233,8 @@ class g {
233
233
  * @returns
234
234
  */
235
235
  normal(t) {
236
- const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n), s = -n / i, o = e / i;
237
- return new g(s, o);
236
+ const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n), s = -n / i, r = e / i;
237
+ return new g(s, r);
238
238
  }
239
239
  /**
240
240
  * 获取由传入的点到该点的单位方向向量
@@ -277,9 +277,9 @@ class g {
277
277
  * @returns
278
278
  */
279
279
  angleBetween(t, e = "radian", n = "180") {
280
- const i = this.dot(t), s = this.magnitude(), o = t.magnitude();
281
- if (s === 0 || o === 0) return 0;
282
- const r = i / (s * o), l = Math.max(-1, Math.min(1, r));
280
+ const i = this.dot(t), s = this.magnitude(), r = t.magnitude();
281
+ if (s === 0 || r === 0) return 0;
282
+ const o = i / (s * r), l = Math.max(-1, Math.min(1, o));
283
283
  return e === "radian" ? Math.acos(l) : e === "cos" ? l : n === "180" || this.cross(t) < 0 ? Math.acos(l) / (Math.PI / 180) : 360 - Math.acos(l) / (Math.PI / 180);
284
284
  }
285
285
  /** 获取向量长度
@@ -361,8 +361,8 @@ class C {
361
361
  getPaths3D(t = 0) {
362
362
  const e = this.points, n = [];
363
363
  return e.forEach((i, s) => {
364
- const o = e[(s + 1) % e.length];
365
- n.push(i.x, i.y, t), n.push(o.x, o.y, t);
364
+ const r = e[(s + 1) % e.length];
365
+ n.push(i.x, i.y, t), n.push(r.x, r.y, t);
366
366
  }), n;
367
367
  }
368
368
  /**
@@ -374,18 +374,18 @@ class C {
374
374
  const e = t.points[0], n = t.points[1], i = n.x - e.x, s = n.y - e.y;
375
375
  if (i === 0 && s === 0)
376
376
  return this.minX <= e.x && e.x <= this.maxX && this.minY <= e.y && e.y <= this.maxY;
377
- let o = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY;
377
+ let r = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY;
378
378
  if (i !== 0) {
379
379
  const l = (this.minX - e.x) / i, c = (this.maxX - e.x) / i;
380
- o = Math.max(o, Math.min(l, c)), r = Math.min(r, Math.max(l, c));
380
+ r = Math.max(r, Math.min(l, c)), o = Math.min(o, Math.max(l, c));
381
381
  } else if (e.x < this.minX || e.x > this.maxX)
382
382
  return !1;
383
383
  if (s !== 0) {
384
384
  const l = (this.minY - e.y) / s, c = (this.maxY - e.y) / s;
385
- o = Math.max(o, Math.min(l, c)), r = Math.min(r, Math.max(l, c));
385
+ r = Math.max(r, Math.min(l, c)), o = Math.min(o, Math.max(l, c));
386
386
  } else if (e.y < this.minY || e.y > this.maxY)
387
387
  return !1;
388
- return o <= r && o <= 1 && r >= 0;
388
+ return r <= o && r <= 1 && o >= 0;
389
389
  }
390
390
  /**
391
391
  * 判断线段是在包围盒内
@@ -401,19 +401,19 @@ class C {
401
401
  */
402
402
  intersectRectangle(t) {
403
403
  const e = t.points;
404
- let n = e[0].x, i = e[0].y, s = e[0].x, o = e[0].y;
404
+ let n = e[0].x, i = e[0].y, s = e[0].x, r = e[0].y;
405
405
  for (let c = 1; c < 4; c++) {
406
406
  const a = e[c];
407
- a.x < n && (n = a.x), a.y < i && (i = a.y), a.x > s && (s = a.x), a.y > o && (o = a.y);
407
+ a.x < n && (n = a.x), a.y < i && (i = a.y), a.x > s && (s = a.x), a.y > r && (r = a.y);
408
408
  }
409
- if (this.maxX < n || this.minX > s || this.maxY < i || this.minY > o)
409
+ if (this.maxX < n || this.minX > s || this.maxY < i || this.minY > r)
410
410
  return !1;
411
- const r = this.points;
411
+ const o = this.points;
412
412
  for (let c = 0; c < 4; c++) {
413
- const a = r[c], h = r[(c + 1) % 4];
413
+ const a = o[c], h = o[(c + 1) % 4];
414
414
  for (let d = 0; d < 4; d++) {
415
- const u = e[d], f = e[(d + 1) % 4], y = (h.x - a.x) * (u.y - a.y) - (h.y - a.y) * (u.x - a.x), p = (h.x - a.x) * (f.y - a.y) - (h.y - a.y) * (f.x - a.x), x = (f.x - u.x) * (a.y - u.y) - (f.y - u.y) * (a.x - u.x), D = (f.x - u.x) * (h.y - u.y) - (f.y - u.y) * (h.x - u.x);
416
- if (y * p < 0 && x * D < 0 || y === 0 && Math.min(a.x, h.x) <= u.x && u.x <= Math.max(a.x, h.x) && Math.min(a.y, h.y) <= u.y && u.y <= Math.max(a.y, h.y) || p === 0 && Math.min(a.x, h.x) <= f.x && f.x <= Math.max(a.x, h.x) && Math.min(a.y, h.y) <= f.y && f.y <= Math.max(a.y, h.y) || x === 0 && Math.min(u.x, f.x) <= a.x && a.x <= Math.max(u.x, f.x) && Math.min(u.y, f.y) <= a.y && a.y <= Math.max(u.y, f.y) || D === 0 && Math.min(u.x, f.x) <= h.x && h.x <= Math.max(u.x, f.x) && Math.min(u.y, f.y) <= h.y && h.y <= Math.max(u.y, f.y))
415
+ const u = e[d], f = e[(d + 1) % 4], y = (h.x - a.x) * (u.y - a.y) - (h.y - a.y) * (u.x - a.x), m = (h.x - a.x) * (f.y - a.y) - (h.y - a.y) * (f.x - a.x), x = (f.x - u.x) * (a.y - u.y) - (f.y - u.y) * (a.x - u.x), D = (f.x - u.x) * (h.y - u.y) - (f.y - u.y) * (h.x - u.x);
416
+ if (y * m < 0 && x * D < 0 || y === 0 && Math.min(a.x, h.x) <= u.x && u.x <= Math.max(a.x, h.x) && Math.min(a.y, h.y) <= u.y && u.y <= Math.max(a.y, h.y) || m === 0 && Math.min(a.x, h.x) <= f.x && f.x <= Math.max(a.x, h.x) && Math.min(a.y, h.y) <= f.y && f.y <= Math.max(a.y, h.y) || x === 0 && Math.min(u.x, f.x) <= a.x && a.x <= Math.max(u.x, f.x) && Math.min(u.y, f.y) <= a.y && a.y <= Math.max(u.y, f.y) || D === 0 && Math.min(u.x, f.x) <= h.x && h.x <= Math.max(u.x, f.x) && Math.min(u.y, f.y) <= h.y && h.y <= Math.max(u.y, f.y))
417
417
  return !0;
418
418
  }
419
419
  }
@@ -427,8 +427,8 @@ class C {
427
427
  for (let h = 0; h < 4; h++) {
428
428
  const d = e[h], u = e[(h + 1) % 4], f = (u.x - d.x) * (c.y - d.y) - (u.y - d.y) * (c.x - d.x);
429
429
  if (f === 0) {
430
- const y = Math.abs(u.x - d.x) > 1e-10 ? u.x - d.x : u.y - d.y, p = y ? (c.x - d.x) / y : 0;
431
- if (p >= 0 && p <= 1) return !0;
430
+ const y = Math.abs(u.x - d.x) > 1e-10 ? u.x - d.x : u.y - d.y, m = y ? (c.x - d.x) / y : 0;
431
+ if (m >= 0 && m <= 1) return !0;
432
432
  } else {
433
433
  const y = f > 0 ? 1 : -1;
434
434
  if (a === 0) a = y;
@@ -438,7 +438,7 @@ class C {
438
438
  return !0;
439
439
  };
440
440
  for (let c = 0; c < 4; c++)
441
- if (l(r[c])) return !0;
441
+ if (l(o[c])) return !0;
442
442
  return !1;
443
443
  }
444
444
  /**
@@ -603,10 +603,10 @@ class U {
603
603
  * @returns 相交的节点数组
604
604
  */
605
605
  queryRect(t) {
606
- const e = t.toBox(), n = Math.ceil(e.minX / this.gridSize), i = Math.ceil(e.maxX / this.gridSize), s = Math.ceil(e.minY / this.gridSize), o = Math.ceil(e.maxY / this.gridSize);
607
- for (let r = n; r <= i; r++)
608
- for (let l = s; l <= o; l++) {
609
- const c = `${r}.${l}`;
606
+ const e = t.toBox(), n = Math.ceil(e.minX / this.gridSize), i = Math.ceil(e.maxX / this.gridSize), s = Math.ceil(e.minY / this.gridSize), r = Math.ceil(e.maxY / this.gridSize);
607
+ for (let o = n; o <= i; o++)
608
+ for (let l = s; l <= r; l++) {
609
+ const c = `${o}.${l}`;
610
610
  if (!this.map.has(c)) continue;
611
611
  this.map.get(c)?.forEach((h) => {
612
612
  t.containsPoint(h.point);
@@ -620,9 +620,9 @@ class U {
620
620
  * @returns 相交的节点数组
621
621
  */
622
622
  queryCircle(t, e) {
623
- const n = new C(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), s = Math.ceil(n.maxX / this.gridSize), o = Math.ceil(n.minY / this.gridSize), r = Math.ceil(n.maxY / this.gridSize), l = [];
623
+ const n = new C(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), s = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), l = [];
624
624
  for (let c = i; c <= s; c++)
625
- for (let a = o; a <= r; a++) {
625
+ for (let a = r; a <= o; a++) {
626
626
  const h = `${c}.${a}`;
627
627
  if (!this.map.has(h)) continue;
628
628
  this.map.get(h)?.forEach((u) => {
@@ -637,16 +637,16 @@ class U {
637
637
  * @returns 相交的节点数组
638
638
  */
639
639
  queryBox(t) {
640
- const e = Math.ceil(t.minX / this.gridSize), n = Math.ceil(t.maxX / this.gridSize), i = Math.ceil(t.minY / this.gridSize), s = Math.ceil(t.maxY / this.gridSize), o = [];
641
- for (let r = e; r <= n; r++)
640
+ const e = Math.ceil(t.minX / this.gridSize), n = Math.ceil(t.maxX / this.gridSize), i = Math.ceil(t.minY / this.gridSize), s = Math.ceil(t.maxY / this.gridSize), r = [];
641
+ for (let o = e; o <= n; o++)
642
642
  for (let l = i; l <= s; l++) {
643
- const c = `${r}.${l}`;
643
+ const c = `${o}.${l}`;
644
644
  if (!this.map.has(c)) continue;
645
645
  this.map.get(c)?.forEach((h) => {
646
- t.containsPoint(h.point) && o.push(h);
646
+ t.containsPoint(h.point) && r.push(h);
647
647
  });
648
648
  }
649
- return o;
649
+ return r;
650
650
  }
651
651
  /**
652
652
  * 查找相同点
@@ -716,15 +716,15 @@ class J {
716
716
  if (t.points.length !== 2)
717
717
  throw new Error("LineSegment must have exactly 2 points");
718
718
  const [e, n] = t.points, i = n.x - e.x, s = n.y - e.y;
719
- for (let o = 0; o < 4; o++) {
720
- const r = this.points[o], l = this.points[(o + 1) % 4], c = l.x - r.x, a = l.y - r.y, h = i * a - s * c;
719
+ for (let r = 0; r < 4; r++) {
720
+ const o = this.points[r], l = this.points[(r + 1) % 4], c = l.x - o.x, a = l.y - o.y, h = i * a - s * c;
721
721
  if (h === 0) {
722
- if ((e.x - r.x) * a - (e.y - r.y) * c !== 0) continue;
723
- const u = c * c + a * a, f = ((e.x - r.x) * c + (e.y - r.y) * a) / u, y = ((n.x - r.x) * c + (n.y - r.y) * a) / u;
722
+ if ((e.x - o.x) * a - (e.y - o.y) * c !== 0) continue;
723
+ const u = c * c + a * a, f = ((e.x - o.x) * c + (e.y - o.y) * a) / u, y = ((n.x - o.x) * c + (n.y - o.y) * a) / u;
724
724
  if (Math.max(f, y) >= 0 && Math.min(f, y) <= 1)
725
725
  return !0;
726
726
  } else {
727
- const d = ((r.x - e.x) * a - (r.y - e.y) * c) / h, u = ((r.x - e.x) * s - (r.y - e.y) * i) / h;
727
+ const d = ((o.x - e.x) * a - (o.y - e.y) * c) / h, u = ((o.x - e.x) * s - (o.y - e.y) * i) / h;
728
728
  if (d >= 0 && d <= 1 && u >= 0 && u <= 1)
729
729
  return !0;
730
730
  }
@@ -742,9 +742,9 @@ class J {
742
742
  const e = (n) => {
743
743
  let i = 0;
744
744
  for (let s = 0; s < 4; s++) {
745
- const o = this.points[s], r = this.points[(s + 1) % 4], l = { x: r.x - o.x, y: r.y - o.y }, c = { x: n.x - o.x, y: n.y - o.y }, a = l.x * c.y - l.y * c.x;
745
+ const r = this.points[s], o = this.points[(s + 1) % 4], l = { x: o.x - r.x, y: o.y - r.y }, c = { x: n.x - r.x, y: n.y - r.y }, a = l.x * c.y - l.y * c.x;
746
746
  if (a === 0) {
747
- const h = l.x !== 0 ? (n.x - o.x) / l.x : (n.y - o.y) / l.y;
747
+ const h = l.x !== 0 ? (n.x - r.x) / l.x : (n.y - r.y) / l.y;
748
748
  if (h >= 0 && h <= 1) return !0;
749
749
  } else {
750
750
  const h = a > 0 ? 1 : -1;
@@ -764,23 +764,23 @@ class J {
764
764
  intersectRectangle(t) {
765
765
  const e = [];
766
766
  for (let s = 0; s < 4; s++) {
767
- const o = this.points[s], r = this.points[(s + 1) % 4];
768
- e.push(o.normal(r));
767
+ const r = this.points[s], o = this.points[(s + 1) % 4];
768
+ e.push(r.normal(o));
769
769
  }
770
770
  for (let s = 0; s < 4; s++) {
771
- const o = t.points[s], r = t.points[(s + 1) % 4];
772
- e.push(o.normal(r));
771
+ const r = t.points[s], o = t.points[(s + 1) % 4];
772
+ e.push(r.normal(o));
773
773
  }
774
- function n(s, o) {
775
- const r = s.points.map((l) => l.dot(o));
776
- return [Math.min(...r), Math.max(...r)];
774
+ function n(s, r) {
775
+ const o = s.points.map((l) => l.dot(r));
776
+ return [Math.min(...o), Math.max(...o)];
777
777
  }
778
- function i(s, o) {
779
- return s[0] < o[1] && o[0] < s[1];
778
+ function i(s, r) {
779
+ return s[0] < r[1] && r[0] < s[1];
780
780
  }
781
781
  for (const s of e) {
782
- const o = n(this, s), r = n(t, s);
783
- if (!i(o, r))
782
+ const r = n(this, s), o = n(t, s);
783
+ if (!i(r, o))
784
784
  return !1;
785
785
  }
786
786
  return !0;
@@ -792,9 +792,9 @@ class J {
792
792
  containsPoint(t) {
793
793
  let e = 0, n = 0;
794
794
  for (let i = 0; i < 4; i++) {
795
- const s = this.points[i], o = this.points[(i + 1) % 4], r = (o.x - s.x) * (t.y - s.y) - (o.y - s.y) * (t.x - s.x);
796
- if (r > 0) e++;
797
- else if (r < 0) n++;
795
+ const s = this.points[i], r = this.points[(i + 1) % 4], o = (r.x - s.x) * (t.y - s.y) - (r.y - s.y) * (t.x - s.x);
796
+ if (o > 0) e++;
797
+ else if (o < 0) n++;
798
798
  else return !1;
799
799
  }
800
800
  return e === 4 || n === 4;
@@ -816,11 +816,11 @@ class J {
816
816
  * @returns
817
817
  */
818
818
  static fromByLineSegment(t, e = 0.1, n = !1, i = 0.5) {
819
- const s = t.points[0], o = t.points[1], r = o.normal(s), l = n ? o.direction(s).mutiplyScalar(e * i) : g.zero(), c = n ? s.direction(o).mutiplyScalar(e * i) : g.zero(), a = r.x * e * 0.5, h = r.y * e * 0.5;
819
+ const s = t.points[0], r = t.points[1], o = r.normal(s), l = n ? r.direction(s).mutiplyScalar(e * i) : g.zero(), c = n ? s.direction(r).mutiplyScalar(e * i) : g.zero(), a = o.x * e * 0.5, h = o.y * e * 0.5;
820
820
  return new J([
821
821
  new g(s.x + a, s.y + h).add(c),
822
- new g(o.x + a, o.y + h).add(l),
823
- new g(o.x - a, o.y - h).add(l),
822
+ new g(r.x + a, r.y + h).add(l),
823
+ new g(r.x - a, r.y - h).add(l),
824
824
  new g(s.x - a, s.y - h).add(c)
825
825
  ]);
826
826
  }
@@ -881,8 +881,8 @@ class T {
881
881
  */
882
882
  getQuadrant(t) {
883
883
  const e = this.children[0].bounds.intersectLineSegment(t), n = this.children[1].bounds.intersectLineSegment(t), i = this.children[2].bounds.intersectLineSegment(t), s = this.children[3].bounds.intersectLineSegment(t);
884
- let o = 0, r = -1;
885
- return e && (o++, r = 0), n && (o++, r = 1), i && (o++, r = 2), s && (o++, r = 3), o === 1 ? r : -1;
884
+ let r = 0, o = -1;
885
+ return e && (r++, o = 0), n && (r++, o = 1), i && (r++, o = 2), s && (r++, o = 3), r === 1 ? o : -1;
886
886
  }
887
887
  /**
888
888
  * 细分当前节点为四个子节点
@@ -945,10 +945,10 @@ class T {
945
945
  if (!this.bounds.intersectBox(i))
946
946
  return n;
947
947
  for (const s of this.nodes) {
948
- const [o, r] = s.line.points, l = r.x - o.x, c = r.y - o.y, a = l * l + c * c;
949
- let h = ((t.x - o.x) * l + (t.y - o.y) * c) / a;
948
+ const [r, o] = s.line.points, l = o.x - r.x, c = o.y - r.y, a = l * l + c * c;
949
+ let h = ((t.x - r.x) * l + (t.y - r.y) * c) / a;
950
950
  h = Math.max(0, Math.min(1, h));
951
- const d = o.x + h * l, u = o.y + h * c;
951
+ const d = r.x + h * l, u = r.y + h * c;
952
952
  t.distance(new g(d, u)) <= e && n.push(s);
953
953
  }
954
954
  if (!this.isLeaf)
@@ -995,9 +995,9 @@ class T {
995
995
  * @returns
996
996
  */
997
997
  boundsToArray(t = [], e, n = !0) {
998
- return !this.isLeaf && n && this.children?.forEach((i) => i.boundsToArray(t, e)), t.push(...this.bounds.points.flatMap((i, s, o) => {
999
- const r = o[(s + 1) % o.length];
1000
- return e?.push(...this.color), e?.push(...this.color), [i.x, i.y, 0, r.x, r.y, 0];
998
+ return !this.isLeaf && n && this.children?.forEach((i) => i.boundsToArray(t, e)), t.push(...this.bounds.points.flatMap((i, s, r) => {
999
+ const o = r[(s + 1) % r.length];
1000
+ return e?.push(...this.color), e?.push(...this.color), [i.x, i.y, 0, o.x, o.y, 0];
1001
1001
  })), t;
1002
1002
  }
1003
1003
  }
@@ -1094,13 +1094,13 @@ class I {
1094
1094
  * @returns {Rectangle}
1095
1095
  */
1096
1096
  expandToRectangle(t = 0.1, e = "all") {
1097
- const n = this.start, i = this.end, s = i.normal(n), o = e === "bothSides" ? g.zero() : i.direction(n).mutiplyScalar(t * 0.5), r = e === "bothSides" ? g.zero() : n.direction(i).mutiplyScalar(t * 0.5), l = s.x * t * 0.5, c = s.y * t * 0.5, a = [
1097
+ const n = this.start, i = this.end, s = i.normal(n), r = e === "bothSides" ? g.zero() : i.direction(n).mutiplyScalar(t * 0.5), o = e === "bothSides" ? g.zero() : n.direction(i).mutiplyScalar(t * 0.5), l = s.x * t * 0.5, c = s.y * t * 0.5, a = [
1098
1098
  // 第一条线
1099
- new g(n.x + l, n.y + c).add(r),
1100
- new g(i.x + l, i.y + c).add(o),
1099
+ new g(n.x + l, n.y + c).add(o),
1100
+ new g(i.x + l, i.y + c).add(r),
1101
1101
  // 第二条线
1102
- new g(n.x - l, n.y - c).add(r),
1103
- new g(i.x - l, i.y - c).add(o)
1102
+ new g(n.x - l, n.y - c).add(o),
1103
+ new g(i.x - l, i.y - c).add(r)
1104
1104
  ];
1105
1105
  return new J([0, 1, 3, 2].map((h) => a[h]));
1106
1106
  }
@@ -1139,22 +1139,22 @@ class I {
1139
1139
  projectLineSegment(t) {
1140
1140
  if (t.points.length !== 2 || this.points.length !== 2)
1141
1141
  throw new Error("每条线段必须由两个点定义");
1142
- const [e, n] = t.points, [i, s] = this.points, o = new g(s.x - i.x, s.y - i.y);
1143
- if (o.x === 0 && o.y === 0)
1142
+ const [e, n] = t.points, [i, s] = this.points, r = new g(s.x - i.x, s.y - i.y);
1143
+ if (r.x === 0 && r.y === 0)
1144
1144
  throw new Error("投影目标线段的两个点不能重合");
1145
- const r = (f) => {
1146
- const y = new g(f.x - i.x, f.y - i.y), p = o.x * o.x + o.y * o.y, D = (y.x * o.x + y.y * o.y) / p, w = i.x + D * o.x, b = i.y + D * o.y;
1147
- return new g(w, b);
1145
+ const o = (f) => {
1146
+ const y = new g(f.x - i.x, f.y - i.y), m = r.x * r.x + r.y * r.y, D = (y.x * r.x + y.y * r.y) / m, w = i.x + D * r.x, P = i.y + D * r.y;
1147
+ return new g(w, P);
1148
1148
  };
1149
- let l = r(e), c = r(n);
1149
+ let l = o(e), c = o(n);
1150
1150
  const a = (f) => {
1151
- const y = new g(f.x - i.x, f.y - i.y), p = o.x * o.x + o.y * o.y;
1152
- return (y.x * o.x + y.y * o.y) / p;
1151
+ const y = new g(f.x - i.x, f.y - i.y), m = r.x * r.x + r.y * r.y;
1152
+ return (y.x * r.x + y.y * r.y) / m;
1153
1153
  };
1154
1154
  let h = a(l), d = a(c);
1155
1155
  const u = (f) => {
1156
- const y = Math.max(0, Math.min(1, f)), p = i.x + y * o.x, x = i.y + y * o.y;
1157
- return new g(p, x);
1156
+ const y = Math.max(0, Math.min(1, f)), m = i.x + y * r.x, x = i.y + y * r.y;
1157
+ return new g(m, x);
1158
1158
  };
1159
1159
  return (h < 0 || h > 1) && (l = u(h)), (d < 0 || d > 1) && (c = u(d)), l.x === c.x && l.y === c.y ? new I(l, l) : new I(l, c);
1160
1160
  }
@@ -1168,16 +1168,16 @@ class I {
1168
1168
  const [n, i] = this.points, s = new g(i.x - n.x, i.y - n.y);
1169
1169
  if (s.x === 0 && s.y === 0)
1170
1170
  throw new Error("投影目标线段的两个点不能重合");
1171
- let r = ((a) => {
1172
- const h = new g(a.x - n.x, a.y - n.y), d = s.x * s.x + s.y * s.y, f = (h.x * s.x + h.y * s.y) / d, y = n.x + f * s.x, p = n.y + f * s.y;
1173
- return new g(y, p);
1171
+ let o = ((a) => {
1172
+ const h = new g(a.x - n.x, a.y - n.y), d = s.x * s.x + s.y * s.y, f = (h.x * s.x + h.y * s.y) / d, y = n.x + f * s.x, m = n.y + f * s.y;
1173
+ return new g(y, m);
1174
1174
  })(t);
1175
- if (!e) return r;
1175
+ if (!e) return o;
1176
1176
  let c = ((a) => {
1177
1177
  const h = new g(a.x - n.x, a.y - n.y), d = s.x * s.x + s.y * s.y;
1178
1178
  return (h.x * s.x + h.y * s.y) / d;
1179
- })(r);
1180
- return c < 0 || c > 1 ? null : r;
1179
+ })(o);
1180
+ return c < 0 || c > 1 ? null : o;
1181
1181
  }
1182
1182
  /**
1183
1183
  * 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
@@ -1186,15 +1186,15 @@ class I {
1186
1186
  * @returns
1187
1187
  */
1188
1188
  intersectLineSegment(t, e = !0) {
1189
- const n = this.start, i = this.end, s = t.start, o = t.end;
1190
- function r(u, f, y) {
1189
+ const n = this.start, i = this.end, s = t.start, r = t.end;
1190
+ function o(u, f, y) {
1191
1191
  return (f.x - u.x) * (y.y - u.y) - (f.y - u.y) * (y.x - u.x);
1192
1192
  }
1193
1193
  function l(u, f, y) {
1194
1194
  return Math.min(f.x, y.x) - 1e-10 <= u.x && u.x <= Math.max(f.x, y.x) + 1e-10 && Math.min(f.y, y.y) - 1e-10 <= u.y && u.y <= Math.max(f.y, y.y) + 1e-10;
1195
1195
  }
1196
- const c = r(n, i, s), a = r(n, i, o), h = r(s, o, n), d = r(s, o, i);
1197
- return !!(c * a < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && l(s, n, i) || Math.abs(a) < 1e-10 && l(o, n, i) || Math.abs(h) < 1e-10 && l(n, s, o) || Math.abs(d) < 1e-10 && l(i, s, o)));
1196
+ const c = o(n, i, s), a = o(n, i, r), h = o(s, r, n), d = o(s, r, i);
1197
+ return !!(c * a < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && l(s, n, i) || Math.abs(a) < 1e-10 && l(r, n, i) || Math.abs(h) < 1e-10 && l(n, s, r) || Math.abs(d) < 1e-10 && l(i, s, r)));
1198
1198
  }
1199
1199
  /**
1200
1200
  * 判断一个点是否在线段上(含端点)
@@ -1211,10 +1211,10 @@ class I {
1211
1211
  * @returns
1212
1212
  */
1213
1213
  getIntersection(t) {
1214
- const e = this.start, n = this.end, i = t.start, s = t.end, o = (e.x - n.x) * (i.y - s.y) - (e.y - n.y) * (i.x - s.x);
1215
- if (Math.abs(o) < 1e-10)
1214
+ const e = this.start, n = this.end, i = t.start, s = t.end, r = (e.x - n.x) * (i.y - s.y) - (e.y - n.y) * (i.x - s.x);
1215
+ if (Math.abs(r) < 1e-10)
1216
1216
  return null;
1217
- const r = ((e.x - i.x) * (i.y - s.y) - (e.y - i.y) * (i.x - s.x)) / o, l = e.x + r * (n.x - e.x), c = e.y + r * (n.y - e.y);
1217
+ const o = ((e.x - i.x) * (i.y - s.y) - (e.y - i.y) * (i.x - s.x)) / r, l = e.x + o * (n.x - e.x), c = e.y + o * (n.y - e.y);
1218
1218
  return new g(l, c);
1219
1219
  }
1220
1220
  /**
@@ -1261,8 +1261,8 @@ class I {
1261
1261
  * @returns
1262
1262
  */
1263
1263
  areLinesCoincident(t) {
1264
- const e = this.start, n = this.end, i = t.start, s = t.end, o = (n.y - e.y) / (n.x - e.x), r = e.y - o * e.x, l = (s.y - i.y) / (s.x - i.x), c = i.y - l * i.x;
1265
- return !isFinite(o) && !isFinite(l) ? e.x === i.x && n.x === i.x : Math.abs(o - l) < 1e-3 && Math.abs(r - c) < 1e-3;
1264
+ const e = this.start, n = this.end, i = t.start, s = t.end, r = (n.y - e.y) / (n.x - e.x), o = e.y - r * e.x, l = (s.y - i.y) / (s.x - i.x), c = i.y - l * i.x;
1265
+ return !isFinite(r) && !isFinite(l) ? e.x === i.x && n.x === i.x : Math.abs(r - l) < 1e-3 && Math.abs(o - c) < 1e-3;
1266
1266
  }
1267
1267
  clone() {
1268
1268
  const t = new I(
@@ -1280,155 +1280,160 @@ class I {
1280
1280
  static axisAlignmentCorrection(t, e) {
1281
1281
  function n(x) {
1282
1282
  const D = new U();
1283
- x.forEach((b) => b.points.forEach((P) => D.insert(P, b)));
1283
+ x.forEach((P) => P.userData.isDoor || P.points.forEach((b) => D.insert(b, P)));
1284
1284
  const w = [];
1285
- for (let b = 0; b < x.length; b++) {
1286
- const P = x[b], S = /* @__PURE__ */ new Map();
1287
- P.points.forEach((m) => {
1288
- if (D.queryPoint(m).length > 1) return;
1289
- const A = D.queryCircle(m, 0.4).filter((E) => {
1290
- const L = m.distance(E.point);
1291
- return S.set(E.point, L), E.userData !== P || L > 1e-3;
1292
- }).sort((E, L) => {
1293
- const v = S.get(E.point), B = S.get(L.point);
1285
+ for (let P = 0; P < x.length; P++) {
1286
+ const b = x[P], L = /* @__PURE__ */ new Map();
1287
+ b.userData.isDoor || b.points.forEach((p) => {
1288
+ if (D.queryPoint(p).length > 1) return;
1289
+ const A = D.queryCircle(p, 0.4).filter((E) => {
1290
+ const S = E.userData;
1291
+ if (S === b || !b.parallel(S, 25)) return !1;
1292
+ if (D.queryPoint(E.point).length > 1) return;
1293
+ const v = new I(p, E.point), B = new I(b.start === p ? b.end : b.start, S.start === E.point ? S.end : S.start);
1294
+ if (!v.intersectLineSegment(B)) return !1;
1295
+ const Y = p.distance(E.point);
1296
+ return Y < 1e-3 ? !1 : (L.set(E.point, Y), !0);
1297
+ }).sort((E, S) => {
1298
+ const v = L.get(E.point), B = L.get(S.point);
1294
1299
  return v - B;
1295
1300
  });
1296
- A.length !== 0 && w.push(new I(m.clone(), A[0].point.clone()));
1301
+ A.length !== 0 && w.push(new I(p.clone(), A[0].point.clone()));
1297
1302
  });
1298
1303
  }
1299
1304
  return [...x, ...w];
1300
1305
  }
1301
1306
  function i(x, D) {
1302
- const w = [x], b = [], P = [];
1303
- for (let S = 0; S < D.length; S++) {
1304
- const m = D[S];
1305
- if (x !== m) {
1306
- if (m.userData.isDoor) {
1307
- P.push(m);
1307
+ const w = [x], P = [], b = [];
1308
+ for (let L = 0; L < D.length; L++) {
1309
+ const p = D[L];
1310
+ if (x !== p) {
1311
+ if (p.userData.isDoor) {
1312
+ b.push(p);
1308
1313
  continue;
1309
1314
  }
1310
- if (m.parallel(x, 45)) {
1311
- const A = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x);
1312
- let L = Math.atan2(x.end.y - x.start.y, x.end.x - x.start.x) - A;
1313
- for (; L > Math.PI; ) L -= 2 * Math.PI;
1314
- for (; L < -Math.PI; ) L += 2 * Math.PI;
1315
- const v = m.center;
1316
- m.start.rotate(v, L), m.end.rotate(v, L), w.push(m);
1315
+ if (p.parallel(x, 45)) {
1316
+ const A = Math.atan2(p.end.y - p.start.y, p.end.x - p.start.x);
1317
+ let S = Math.atan2(x.end.y - x.start.y, x.end.x - x.start.x) - A;
1318
+ for (; S > Math.PI; ) S -= 2 * Math.PI;
1319
+ for (; S < -Math.PI; ) S += 2 * Math.PI;
1320
+ const v = p.center;
1321
+ p.start.rotate(v, S), p.end.rotate(v, S), w.push(p);
1317
1322
  } else {
1318
- const A = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x), E = Math.atan2(x.end.y - x.start.y, x.end.x - x.start.x);
1319
- let L = E + Math.PI / 2 - A, v = E - Math.PI / 2 - A;
1320
- for (; L > Math.PI; ) L -= 2 * Math.PI;
1321
- for (; L < -Math.PI; ) L += 2 * Math.PI;
1323
+ const A = Math.atan2(p.end.y - p.start.y, p.end.x - p.start.x), E = Math.atan2(x.end.y - x.start.y, x.end.x - x.start.x);
1324
+ let S = E + Math.PI / 2 - A, v = E - Math.PI / 2 - A;
1325
+ for (; S > Math.PI; ) S -= 2 * Math.PI;
1326
+ for (; S < -Math.PI; ) S += 2 * Math.PI;
1322
1327
  for (; v > Math.PI; ) v -= 2 * Math.PI;
1323
1328
  for (; v < -Math.PI; ) v += 2 * Math.PI;
1324
- const B = Math.abs(L) < Math.abs(v) ? L : v, X = m.center;
1325
- m.start.rotate(X, B), m.end.rotate(X, B), b.push(m);
1329
+ const B = Math.abs(S) < Math.abs(v) ? S : v, Y = p.center;
1330
+ p.start.rotate(Y, B), p.end.rotate(Y, B), P.push(p);
1326
1331
  }
1327
1332
  }
1328
1333
  }
1329
- return { parallelLines: w, verticalLines: b, doorLines: P };
1334
+ return { parallelLines: w, verticalLines: P, doorLines: b };
1330
1335
  }
1331
- function s(x, D, w, b = 0.3, P = 0.06) {
1332
- const S = [];
1336
+ function s(x, D, w, P = 0.3, b = 0.06) {
1337
+ const L = [];
1333
1338
  x.forEach((E) => {
1334
- const L = w.projectPoint(E.start, !1);
1335
- L && (L.userData = E, S.push(L));
1336
- }), S.sort((E, L) => L.distance(w.start) - E.distance(w.start));
1337
- const m = [], A = [];
1338
- for (let E = 0; E < S.length; E++) {
1339
- const L = S[E];
1339
+ const S = w.projectPoint(E.start, !1);
1340
+ S && (S.userData = E, L.push(S));
1341
+ }), L.sort((E, S) => S.distance(w.start) - E.distance(w.start));
1342
+ const p = [], A = [];
1343
+ for (let E = 0; E < L.length; E++) {
1344
+ const S = L[E];
1340
1345
  if (E === 0) {
1341
- A.push(L);
1346
+ A.push(S);
1342
1347
  continue;
1343
1348
  }
1344
- S[E - 1].distance(L) < P || (m.push([...A]), A.length = 0), A.push(L), E === S.length - 1 && m.push(A);
1349
+ L[E - 1].distance(S) < b || (p.push([...A]), A.length = 0), A.push(S), E === L.length - 1 && p.push(A);
1345
1350
  }
1346
- return m.flatMap((E) => {
1347
- const L = E.flatMap((j) => {
1348
- const G = j.userData;
1349
- return G.points.map((R) => {
1350
- const Y = D.projectPoint(R, !1);
1351
- return Y.userData = G, Y;
1351
+ return p.flatMap((E) => {
1352
+ const S = E.flatMap((j) => {
1353
+ const X = j.userData;
1354
+ return X.points.map((R) => {
1355
+ const G = D.projectPoint(R, !1);
1356
+ return G.userData = X, G;
1352
1357
  });
1353
1358
  });
1354
- L.sort((j, G) => j.distance(D.start) - G.distance(D.start));
1355
- const v = /* @__PURE__ */ new Map(), B = [], X = [];
1356
- return L.forEach((j, G) => {
1357
- v.size === 0 && G > 0 && L[G - 1].distance(j) > b && (B.push([...X]), X.length = 0), v.set(j.userData, (v.get(j.userData) ?? 0) + 1);
1359
+ S.sort((j, X) => j.distance(D.start) - X.distance(D.start));
1360
+ const v = /* @__PURE__ */ new Map(), B = [], Y = [];
1361
+ return S.forEach((j, X) => {
1362
+ v.size === 0 && X > 0 && S[X - 1].distance(j) > P && (B.push([...Y]), Y.length = 0), v.set(j.userData, (v.get(j.userData) ?? 0) + 1);
1358
1363
  for (const R of v.values()) if (R !== 2) return;
1359
- X.push(...v.keys()), v.clear();
1360
- }), B.push([...X]), B;
1364
+ Y.push(...v.keys()), v.clear();
1365
+ }), B.push([...Y]), B;
1361
1366
  });
1362
1367
  }
1363
- function o(x, D = 0.1) {
1368
+ function r(x, D = 0.1) {
1364
1369
  return x.map((w) => {
1365
1370
  if (w.length === 0) return;
1366
1371
  if (w.length === 1) return w[0];
1367
- const b = [];
1368
- w.forEach((Y) => {
1369
- b.push(Y.start.clone(), Y.end.clone());
1372
+ const P = [];
1373
+ w.forEach((G) => {
1374
+ P.push(G.start.clone(), G.end.clone());
1370
1375
  });
1371
- const P = w[0].direction().normalize();
1372
- let S = 1 / 0, m = -1 / 0, A = 0, E = 0;
1373
- b.forEach((Y) => {
1374
- const F = Y.x * P.x + Y.y * P.y;
1375
- S = Math.min(S, F), m = Math.max(m, F), A += Y.x, E += Y.y;
1376
+ const b = w[0].direction().normalize();
1377
+ let L = 1 / 0, p = -1 / 0, A = 0, E = 0;
1378
+ P.forEach((G) => {
1379
+ const F = G.x * b.x + G.y * b.y;
1380
+ L = Math.min(L, F), p = Math.max(p, F), A += G.x, E += G.y;
1376
1381
  });
1377
- const L = new g(A / b.length, E / b.length), v = L.x * P.x + L.y * P.y, B = new g(L.x + (S - v) * P.x, L.y + (S - v) * P.y), X = new g(L.x + (m - v) * P.x, L.y + (m - v) * P.y), j = new I(B, X), G = w[0].normal().normalize();
1378
- S = 1 / 0, m = -1 / 0, b.forEach((Y) => {
1379
- const F = Y.x * G.x + Y.y * G.y;
1380
- S = Math.min(S, F), m = Math.max(m, F);
1382
+ const S = new g(A / P.length, E / P.length), v = S.x * b.x + S.y * b.y, B = new g(S.x + (L - v) * b.x, S.y + (L - v) * b.y), Y = new g(S.x + (p - v) * b.x, S.y + (p - v) * b.y), j = new I(B, Y), X = w[0].normal().normalize();
1383
+ L = 1 / 0, p = -1 / 0, P.forEach((G) => {
1384
+ const F = G.x * X.x + G.y * X.y;
1385
+ L = Math.min(L, F), p = Math.max(p, F);
1381
1386
  });
1382
- const R = m - S;
1387
+ const R = p - L;
1383
1388
  return R >= D && (j.userData.wallWidth = R), j;
1384
1389
  }).filter((w) => !!w);
1385
1390
  }
1386
- function r(x, D = 0.2) {
1387
- const w = new T(C.fromByLineSegment(...x)), b = /* @__PURE__ */ new Map();
1388
- x.forEach((S) => {
1389
- b.set(S, { line: S, userData: void 0 }), w.insert(b.get(S));
1391
+ function o(x, D = 0.2) {
1392
+ const w = new T(C.fromByLineSegment(...x)), P = /* @__PURE__ */ new Map();
1393
+ x.forEach((L) => {
1394
+ P.set(L, { line: L, userData: void 0 }), w.insert(P.get(L));
1390
1395
  });
1391
- const P = new I();
1392
- for (let S = 0; S < x.length; S++) {
1393
- const m = x[S];
1394
- if (m.userData.isAdsorbed) continue;
1395
- const A = m.direction().multiplyScalar(D), [E, L] = m.points.map((v) => {
1396
- P.set(v, v), P.start.add(A), P.end.add(A.multiplyScalar(-1));
1397
- const B = /* @__PURE__ */ new Map(), X = w.queryRect(P.expandToRectangle(0.1, "bothSides")).filter((j) => j.line !== m).map((j) => {
1398
- const G = j.line.getIntersection(P);
1399
- return B.set(j.line, G), j.line;
1400
- }).sort((j, G) => {
1401
- const R = B.get(j), Y = B.get(G);
1402
- return R && Y ? R.distance(v) - Y.distance(v) : 0;
1396
+ const b = new I();
1397
+ for (let L = 0; L < x.length; L++) {
1398
+ const p = x[L];
1399
+ if (p.userData.isAdsorbed) continue;
1400
+ const A = p.direction().multiplyScalar(D), [E, S] = p.points.map((v) => {
1401
+ b.set(v, v), b.start.add(A), b.end.add(A.multiplyScalar(-1));
1402
+ const B = /* @__PURE__ */ new Map(), Y = w.queryRect(b.expandToRectangle(0.1, "bothSides")).filter((j) => j.line !== p).map((j) => {
1403
+ const X = j.line.getIntersection(b);
1404
+ return B.set(j.line, X), j.line;
1405
+ }).sort((j, X) => {
1406
+ const R = B.get(j), G = B.get(X);
1407
+ return R && G ? R.distance(v) - G.distance(v) : 0;
1403
1408
  });
1404
- return X.length ? B.get(X[0]) : void 0;
1409
+ return Y.length ? B.get(Y[0]) : void 0;
1405
1410
  });
1406
- if (E && L) {
1407
- if (E.equal(L)) {
1408
- const v = m.start.distance(E), B = m.end.distance(L);
1409
- v < B ? m.directionMove(m.start.direction(m.end), v) : m.directionMove(m.end.direction(m.start), B);
1411
+ if (E && S) {
1412
+ if (E.equal(S)) {
1413
+ const v = p.start.distance(E), B = p.end.distance(S);
1414
+ v < B ? p.directionMove(p.start.direction(p.end), v) : p.directionMove(p.end.direction(p.start), B);
1410
1415
  } else
1411
- m.start.copy(E), m.end.copy(L);
1412
- m.userData.isAdsorbed = !0;
1413
- } else E ? m.start.copy(E) : L && m.end.copy(L);
1414
- w.remove(b.get(m)), w.insert(b.get(m));
1416
+ p.start.copy(E), p.end.copy(S);
1417
+ p.userData.isAdsorbed = !0;
1418
+ } else E ? p.start.copy(E) : S && p.end.copy(S);
1419
+ w.remove(P.get(p)), w.insert(P.get(p));
1415
1420
  }
1416
- return x.filter((S) => S.length() > 1e-3);
1421
+ return x.filter((L) => L.length() > 1e-3);
1417
1422
  }
1418
1423
  function l(x) {
1419
1424
  const D = new T(C.fromByLineSegment(...x));
1420
1425
  return x.forEach((w) => D.insert({ line: w, userData: void 0 })), x.flatMap((w) => {
1421
- const b = D.queryLineSegment(w, !0).map((P) => {
1422
- if (P.line === w) return;
1423
- const S = P.line.getIntersection(w);
1424
- if (!(!S || w.start.equal(S) || w.end.equal(S)))
1425
- return S;
1426
- }).filter((P) => !!P);
1427
- return b.length ? (w = w.clone(), b.sort((S, m) => w.start.distance(S) - w.start.distance(m)), [...b.map((S) => {
1428
- const m = w.clone();
1429
- return m.set(w.start.clone(), S), w.start.copy(S), m;
1426
+ const P = D.queryLineSegment(w, !0).map((b) => {
1427
+ if (b.line === w) return;
1428
+ const L = b.line.getIntersection(w);
1429
+ if (!(!L || w.start.equal(L) || w.end.equal(L)))
1430
+ return L;
1431
+ }).filter((b) => !!b);
1432
+ return P.length ? (w = w.clone(), P.sort((L, p) => w.start.distance(L) - w.start.distance(p)), [...P.map((L) => {
1433
+ const p = w.clone();
1434
+ return p.set(w.start.clone(), L), w.start.copy(L), p;
1430
1435
  }), w]) : w;
1431
- }).filter((w) => w.length() > 0.1);
1436
+ }).filter((w) => w.length() > 0.05);
1432
1437
  }
1433
1438
  t = n(t);
1434
1439
  const { parallelLines: c, verticalLines: a } = i(e, t.map((x) => x.clone())), h = e.normal(), d = e.center, u = e.direction(), f = new I(
@@ -1438,11 +1443,11 @@ class I {
1438
1443
  d.clone().add(u.clone().multiplyScalar(-1e3)),
1439
1444
  d.clone().add(u.clone().multiplyScalar(1e3))
1440
1445
  );
1441
- let p = o([
1446
+ let m = r([
1442
1447
  ...s.call(this, c, y, f),
1443
1448
  ...s.call(this, a, f, y)
1444
1449
  ]);
1445
- return p = r.call(this, p), p = r.call(this, p), p = l.call(this, p), p;
1450
+ return m = o.call(this, m), m = o.call(this, m), m = l.call(this, m), m;
1446
1451
  }
1447
1452
  /**
1448
1453
  * 获取最长线段
@@ -1512,7 +1517,7 @@ const lt = {
1512
1517
  Parsecs: 3240779289666404e-32
1513
1518
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
1514
1519
  };
1515
- function _(M) {
1520
+ function K(M) {
1516
1521
  const t = [];
1517
1522
  for (let e = 0; e < M.length; e++)
1518
1523
  t.push(new I(
@@ -1521,7 +1526,7 @@ function _(M) {
1521
1526
  ));
1522
1527
  return t;
1523
1528
  }
1524
- function K(M) {
1529
+ function Q(M) {
1525
1530
  return M.flatMap((t, e) => (e === M.length - 1 && [...t.points, M[0].points[0]], [t.points[0]]));
1526
1531
  }
1527
1532
  class z extends V {
@@ -1571,19 +1576,19 @@ class z extends V {
1571
1576
  preprocessing(t, e = !1) {
1572
1577
  const n = [];
1573
1578
  let i = -1;
1574
- t.forEach(({ start: o, end: r, ...l }, c) => {
1579
+ t.forEach(({ start: r, end: o, ...l }, c) => {
1575
1580
  const a = new I(
1576
- g.from(o),
1577
- g.from(r)
1581
+ g.from(r),
1582
+ g.from(o)
1578
1583
  );
1579
1584
  a.userData = l, n.push(a), l.isVerticalReferenceLine && (i = c);
1580
1585
  }), i === -1 && (i = I.maxLengthLineIndex(n));
1581
1586
  const s = n[i];
1582
1587
  if (s.userData.isVerticalReferenceLine = !0, t[i].isVerticalReferenceLine = !0, e) {
1583
- const o = I.axisAlignmentCorrection(n, s);
1584
- return i = I.maxLengthLineIndex(o), o[i].userData.isVerticalReferenceLine = !0, {
1585
- lineSegments: o,
1586
- data: this.lineDataToOriginalData(o)
1588
+ const r = I.axisAlignmentCorrection(n, s);
1589
+ return i = I.maxLengthLineIndex(r), r[i].userData.isVerticalReferenceLine = !0, {
1590
+ lineSegments: r,
1591
+ data: this.lineDataToOriginalData(r)
1587
1592
  };
1588
1593
  }
1589
1594
  return {
@@ -1610,9 +1615,9 @@ class z extends V {
1610
1615
  this.scale = n, this.width = e;
1611
1616
  const s = this.preprocessing(t, i);
1612
1617
  t = s.data, this.lineSegments = s.lineSegments, this.originalData = t;
1613
- const o = [];
1614
- this.data = t.map(({ start: r, end: l, insetionArr: c, isDoor: a = !1 }, h) => {
1615
- o.push(r.z ?? 0, l.z ?? 0);
1618
+ const r = [];
1619
+ this.data = t.map(({ start: o, end: l, insetionArr: c, isDoor: a = !1 }, h) => {
1620
+ r.push(o.z ?? 0, l.z ?? 0);
1616
1621
  const d = this.lineSegments[h];
1617
1622
  return [
1618
1623
  d.points[0],
@@ -1621,7 +1626,7 @@ class z extends V {
1621
1626
  a,
1622
1627
  h
1623
1628
  ];
1624
- }), this.originalZAverage = o.reduce((r, l) => r + l, 0) / o.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
1629
+ }), this.originalZAverage = r.reduce((o, l) => o + l, 0) / r.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
1625
1630
  type: "setDta",
1626
1631
  originalData: this.originalData,
1627
1632
  data: this.data
@@ -1635,18 +1640,18 @@ class z extends V {
1635
1640
  * @returns
1636
1641
  */
1637
1642
  createGroups() {
1638
- const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), s = (o, r, l = -1) => {
1639
- const [c, a, h, d] = this.data[o];
1640
- if (e.add(o), d)
1641
- return i.has(o) || i.set(o, []), i.get(o)?.push(l), n.add(this.data[o]);
1642
- r.push([c, a]), h.forEach((u) => {
1643
- e.has(u) || s(u, r, o);
1643
+ const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), s = (r, o, l = -1) => {
1644
+ const [c, a, h, d] = this.data[r];
1645
+ if (e.add(r), d)
1646
+ return i.has(r) || i.set(r, []), i.get(r)?.push(l), n.add(this.data[r]);
1647
+ o.push([c, a]), h.forEach((u) => {
1648
+ e.has(u) || s(u, o, r);
1644
1649
  });
1645
1650
  };
1646
- return this.data.forEach((o, r) => {
1647
- if (!e.has(r)) {
1651
+ return this.data.forEach((r, o) => {
1652
+ if (!e.has(o)) {
1648
1653
  const l = [];
1649
- s(r, l), t.push(l);
1654
+ s(o, l), t.push(l);
1650
1655
  }
1651
1656
  }), this.doors = [...n], this.pointsGroups = t, t;
1652
1657
  }
@@ -1656,8 +1661,8 @@ class z extends V {
1656
1661
  * @returns
1657
1662
  */
1658
1663
  computedSize() {
1659
- const t = this.pointsGroups.flatMap((r) => r.flatMap((l) => [l[0].x, l[1].x])), e = this.pointsGroups.flatMap((r) => r.flatMap((l) => [l[0].y, l[1].y])), n = Math.min(...t), i = Math.min(...e), s = Math.max(...t), o = Math.max(...e);
1660
- return this.box.set(n, i, s, o), this.box;
1664
+ const t = this.pointsGroups.flatMap((o) => o.flatMap((l) => [l[0].x, l[1].x])), e = this.pointsGroups.flatMap((o) => o.flatMap((l) => [l[0].y, l[1].y])), n = Math.min(...t), i = Math.min(...e), s = Math.max(...t), r = Math.max(...e);
1665
+ return this.box.set(n, i, s, r), this.box;
1661
1666
  }
1662
1667
  /** 线路拓扑
1663
1668
  * @description 处理线路拓扑,使线路有序链接,形成长路径
@@ -1665,20 +1670,20 @@ class z extends V {
1665
1670
  */
1666
1671
  lineTopology(t) {
1667
1672
  const e = [];
1668
- function n(s, o) {
1669
- const [r, l] = t[s];
1670
- e[s] = !0, o.push(l);
1673
+ function n(s, r) {
1674
+ const [o, l] = t[s];
1675
+ e[s] = !0, r.push(l);
1671
1676
  for (let c = 0; c < t.length; c++) {
1672
1677
  const [a, h] = t[c];
1673
1678
  if (!e[c] && Math.abs(l.x - a.x) < 1e-6 && Math.abs(l.y - a.y) < 1e-6)
1674
- return n(c, o);
1679
+ return n(c, r);
1675
1680
  }
1676
1681
  }
1677
1682
  const i = [];
1678
1683
  for (let s = 0; s < t.length; s++)
1679
1684
  if (!e[s]) {
1680
- const o = [t[s][0]];
1681
- n(s, o), i.push(o);
1685
+ const r = [t[s][0]];
1686
+ n(s, r), i.push(r);
1682
1687
  }
1683
1688
  return i;
1684
1689
  }
@@ -1693,8 +1698,8 @@ class z extends V {
1693
1698
  }
1694
1699
  const n = [t[0]];
1695
1700
  for (let i = 1; i < t.length; i++) {
1696
- const s = t[i], o = t[i - 1];
1697
- o.includedAngle(s) < e ? o.end.copy(s.end) : n.push(s);
1701
+ const s = t[i], r = t[i - 1];
1702
+ r.includedAngle(s) < e ? r.end.copy(s.end) : n.push(s);
1698
1703
  }
1699
1704
  return n;
1700
1705
  }
@@ -1707,13 +1712,13 @@ class z extends V {
1707
1712
  for (let n = 1; n < t.length; n++) {
1708
1713
  const i = t[n - 1], s = t[n];
1709
1714
  if (i.distance(s) < this.width * 0.5) {
1710
- let r = 0;
1715
+ let o = 0;
1711
1716
  for (let l = n + 1; l < t.length; l++) {
1712
1717
  const c = t[l - 1], a = t[l];
1713
- if (c.distance(a) < this.width * 0.8) r++;
1718
+ if (c.distance(a) < this.width * 0.8) o++;
1714
1719
  else break;
1715
1720
  }
1716
- r === 0 && n + r === t.length - 1 || n == 1 && r === 1 || (r === 3 ? (e.push(t[n + 1]), n += r) : r === 5 ? (e.push(t[n + 2]), n += r) : e.push(s));
1721
+ o === 0 && n + o === t.length - 1 || n == 1 && o === 1 || (o === 3 ? (e.push(t[n + 1]), n += o) : o === 5 ? (e.push(t[n + 2]), n += o) : e.push(s));
1717
1722
  } else
1718
1723
  e.push(s);
1719
1724
  }
@@ -1726,28 +1731,28 @@ class z extends V {
1726
1731
  */
1727
1732
  lineSegmentStraightening(t) {
1728
1733
  for (let i = 0; i < t.length; i++) {
1729
- const s = t[i], o = t[(i + 1) % t.length];
1730
- if (s.distance(o) > this.shortLine) {
1734
+ const s = t[i], r = t[(i + 1) % t.length];
1735
+ if (s.distance(r) > this.shortLine) {
1731
1736
  t.push(...t.slice(0, i + 1)), t.splice(0, i + 1);
1732
1737
  break;
1733
1738
  }
1734
1739
  }
1735
- const e = this.mergeSameDirectionLine(_(t)), n = [e[0]];
1740
+ const e = this.mergeSameDirectionLine(K(t)), n = [e[0]];
1736
1741
  for (let i = 1; i < e.length; i++) {
1737
- const s = e[i], o = e[(e.length + i - 1) % e.length];
1742
+ const s = e[i], r = e[(e.length + i - 1) % e.length];
1738
1743
  if (s.length() > this.width * 0.9) {
1739
1744
  n.push(s);
1740
1745
  continue;
1741
1746
  }
1742
- const r = e[i + 1];
1743
- if (r && r.length() > this.width * 0.9) {
1744
- n.push(s), n.push(r), i = i + 1;
1747
+ const o = e[i + 1];
1748
+ if (o && o.length() > this.width * 0.9) {
1749
+ n.push(s), n.push(o), i = i + 1;
1745
1750
  continue;
1746
1751
  }
1747
1752
  const l = e[i + 2];
1748
- l && o.includedAngle(l) < 2 ? (i = i + 2, n.push(l)) : n.push(s);
1753
+ l && r.includedAngle(l) < 2 ? (i = i + 2, n.push(l)) : n.push(s);
1749
1754
  }
1750
- return n.length > 3 ? K(this.mergeSameDirectionLine(n)) : [];
1755
+ return n.length > 3 ? Q(this.mergeSameDirectionLine(n)) : [];
1751
1756
  }
1752
1757
  /**
1753
1758
  * 移除短线段
@@ -1755,35 +1760,35 @@ class z extends V {
1755
1760
  * @param path
1756
1761
  */
1757
1762
  removeShortLine(t, e = this.shortLine) {
1758
- const n = _(t), i = [], s = Math.PI / 180;
1759
- for (let o = 0; o < n.length; o++) {
1760
- const r = n[o], l = r.length(), c = o;
1763
+ const n = K(t), i = [], s = Math.PI / 180;
1764
+ for (let r = 0; r < n.length; r++) {
1765
+ const o = n[r], l = o.length(), c = r;
1761
1766
  if (l > e || i.length === 0) {
1762
- i.push(r);
1767
+ i.push(o);
1763
1768
  continue;
1764
1769
  }
1765
- let a = n[++o];
1770
+ let a = n[++r];
1766
1771
  const h = i[i.length - 1], d = h.direction();
1767
- for (; o < n.length; ) {
1772
+ for (; r < n.length; ) {
1768
1773
  const f = d.angleBetween(a.direction()) / s;
1769
1774
  if (a.length() <= e || f < 4 || f > 176)
1770
- a = n[++o];
1775
+ a = n[++r];
1771
1776
  else break;
1772
1777
  }
1773
1778
  if (!a) continue;
1774
- const u = n[o - 1];
1779
+ const u = n[r - 1];
1775
1780
  if (h.length() > u.length()) {
1776
1781
  const f = h.getIntersection(a);
1777
1782
  if (f) {
1778
- const y = h.points[1].clone(), p = a.points[0].clone();
1779
- h.points[1].copy(f), a.points[0].copy(f), h.length() < this.width ? (h.points[1].copy(y), a.points[0].copy(y)) : a.length() < this.width && (h.points[1].copy(p), a.points[0].copy(p));
1783
+ const y = h.points[1].clone(), m = a.points[0].clone();
1784
+ h.points[1].copy(f), a.points[0].copy(f), h.length() < this.width ? (h.points[1].copy(y), a.points[0].copy(y)) : a.length() < this.width && (h.points[1].copy(m), a.points[0].copy(m));
1780
1785
  } else
1781
1786
  h.points[1].copy(a.points[0]);
1782
1787
  i.push(a);
1783
1788
  } else
1784
- o = c;
1789
+ r = c;
1785
1790
  }
1786
- return i.length > 3 ? K(i) : [];
1791
+ return i.length > 3 ? Q(i) : [];
1787
1792
  }
1788
1793
  /** 线偏移
1789
1794
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
@@ -1791,12 +1796,12 @@ class z extends V {
1791
1796
  lineOffset(t = z.EndType.etOpenSquare, e = z.JoinType.jtMiter, n = 1e4) {
1792
1797
  let i = new Z.Paths();
1793
1798
  const s = new Z.ClipperOffset(20, 0.25);
1794
- return this.pointsGroups.forEach((o) => {
1795
- const r = this.lineTopology(o).map((l) => l.map((c) => c.clone().mutiplyScalar(n)));
1796
- s.AddPaths(r, e, t);
1797
- }), s.Execute(i, this.width / 2 * n), this.wallsGroup = i.map((o) => {
1798
- let r = o.map((l) => g.from(l).divisionScalar(n));
1799
- return r = this.lineSegmentStraightening(r), t == z.EndType.etOpenSquare && (r = this.squareRemoveBurr(r)), r;
1799
+ return this.pointsGroups.forEach((r) => {
1800
+ const o = this.lineTopology(r).map((l) => l.map((c) => c.clone().mutiplyScalar(n)));
1801
+ s.AddPaths(o, e, t);
1802
+ }), s.Execute(i, this.width / 2 * n), this.wallsGroup = i.map((r) => {
1803
+ let o = r.map((l) => g.from(l).divisionScalar(n));
1804
+ return o = this.lineSegmentStraightening(o), t == z.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
1800
1805
  }), this.dispatchEvent({
1801
1806
  type: "lineOffset",
1802
1807
  wallsGroup: this.wallsGroup
@@ -1809,8 +1814,8 @@ class z extends V {
1809
1814
  const n = [];
1810
1815
  return this.wallsGroup.forEach((i) => {
1811
1816
  for (let s = 0; s < i.length; s++) {
1812
- const o = i[s], r = s === i.length - 1 ? 0 : s + 1, l = i[r];
1813
- n.push(o.X * t, o.Y * t, e, l.X * t, l.Y * t, e);
1817
+ const r = i[s], o = s === i.length - 1 ? 0 : s + 1, l = i[o];
1818
+ n.push(r.X * t, r.Y * t, e, l.X * t, l.Y * t, e);
1814
1819
  }
1815
1820
  }), new Float32Array(n);
1816
1821
  }
@@ -1821,8 +1826,8 @@ class z extends V {
1821
1826
  * @returns
1822
1827
  */
1823
1828
  getArcAngleRange(t, e, n) {
1824
- const i = e.x - t.x, s = e.y - t.y, o = n.x - t.x, r = n.y - t.y;
1825
- let l = Math.atan2(s, i), c = Math.atan2(r, o);
1829
+ const i = e.x - t.x, s = e.y - t.y, r = n.x - t.x, o = n.y - t.y;
1830
+ let l = Math.atan2(s, i), c = Math.atan2(o, r);
1826
1831
  l = l < 0 ? l + 2 * Math.PI : l, c = c < 0 ? c + 2 * Math.PI : c;
1827
1832
  let a, h;
1828
1833
  return Math.abs(c - l) <= Math.PI ? (a = Math.min(l, c), h = Math.max(l, c)) : (a = Math.max(l, c), h = Math.min(l, c) + 2 * Math.PI), [a / (Math.PI / 180), h / (Math.PI / 180)];
@@ -1831,24 +1836,22 @@ class z extends V {
1831
1836
  * 线段数据转为原始json数据
1832
1837
  */
1833
1838
  lineDataToOriginalData(t, e) {
1834
- return t.map((n) => {
1835
- const i = n.userData, s = i.drawWindow;
1836
- e = e ?? new T(C.fromByLineSegment(...t));
1837
- const o = e.queryLineSegment(n).filter((r) => r.line !== n && !r.userData?.isDoor).map((r) => ({ index: this.lines.indexOf(r.line) }));
1839
+ return e || (e = new T(C.fromByLineSegment(...t)), t.forEach((n) => e?.insert({ line: n, userData: void 0 }))), t.map((n) => {
1840
+ const i = n.userData, s = i.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: this.lines.indexOf(o.line) }));
1838
1841
  return {
1839
1842
  start: n.start.toJson(this.originalZAverage),
1840
1843
  end: n.end.toJson(this.originalZAverage),
1841
- insetionArr: o,
1844
+ insetionArr: r,
1842
1845
  isDoor: i.isDoor,
1843
1846
  doorDirectConnection: i.isDoor,
1844
1847
  length: n.length(),
1845
1848
  isWindow: i.isWindow,
1846
1849
  isVerticalReferenceLine: i.isVerticalReferenceLine,
1847
1850
  wallWidth: n.userData.wallWidth,
1848
- drawWindow: s && s.map((r) => ({
1849
- p: { x: r.p.x, y: r.p.y, z: r.p.z },
1850
- width: r.width,
1851
- full: r.full
1851
+ drawWindow: s && s.map((o) => ({
1852
+ p: { x: o.p.x, y: o.p.y, z: o.p.z },
1853
+ width: o.width,
1854
+ full: o.full
1852
1855
  }))
1853
1856
  };
1854
1857
  });
@@ -1871,7 +1874,7 @@ class z extends V {
1871
1874
  function s(c, a) {
1872
1875
  n.line.push([c.X * e, c.Y * e, a.X * e, a.Y * e, i]);
1873
1876
  }
1874
- function o(c, a, h, d) {
1877
+ function r(c, a, h, d) {
1875
1878
  n.arc.push([
1876
1879
  c.x * e,
1877
1880
  c.y * e,
@@ -1894,36 +1897,36 @@ class z extends V {
1894
1897
  s(h, u);
1895
1898
  }
1896
1899
  });
1897
- const r = this.width * 0.2, l = [];
1900
+ const o = this.width * 0.2, l = [];
1898
1901
  return this.doorLineSegment.forEach((c) => {
1899
1902
  if (c.length() < 0.4) return;
1900
1903
  const a = c.clone().expansion(-this.width * 0.5);
1901
1904
  if (i = "cyan", a.length() < 1.2) {
1902
- a.expansion(-r * 0.5);
1905
+ a.expansion(-o * 0.5);
1903
1906
  const h = c.normal();
1904
1907
  let d = new I(
1905
1908
  a.start.clone(),
1906
1909
  a.start.clone().add(h.clone().multiplyScalar(a.length()))
1907
1910
  );
1908
1911
  const u = d.clone().directionMove(d.normal(), a.length() * -0.5).expandToRectangle(a.length(), "bothSides");
1909
- for (let b = 0; b < l.length; b++)
1910
- if (l[b].intersectRectangle(u)) {
1912
+ for (let P = 0; P < l.length; P++)
1913
+ if (l[P].intersectRectangle(u)) {
1911
1914
  d = new I(
1912
1915
  a.start.clone(),
1913
1916
  a.start.clone().add(h.clone().multiplyScalar(-a.length()))
1914
1917
  );
1915
1918
  break;
1916
1919
  }
1917
- d.expansion(-r * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((b, P) => s(b, P));
1918
- const f = a.length(), y = d.length(), p = (f ** 2 + y ** 2) / (2 * y), x = d.end.clone().add(d.direction().multiplyScalar(-p)), [D, w] = this.getArcAngleRange(x, a.end, d.end);
1919
- o(x, p, Math.min(D, w), Math.max(D, w)), l.push(u);
1920
+ d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((P, b) => s(P, b));
1921
+ const f = a.length(), y = d.length(), m = (f ** 2 + y ** 2) / (2 * y), x = d.end.clone().add(d.direction().multiplyScalar(-m)), [D, w] = this.getArcAngleRange(x, a.end, d.end);
1922
+ r(x, m, Math.min(D, w), Math.max(D, w)), l.push(u);
1920
1923
  } else
1921
- a.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => s(h, d)), a.clone().directionMove(a.normal(), r * 0.5).directionMove(a.direction(), r * 0.5).expansion(-a.length() * 0.45, "end").forward(r * 0.5).expandToRectangle(r).path2D((h, d) => s(h, d)), a.clone().directionMove(a.normal(), -r * 0.5).directionMove(a.direction(), -r * 0.5).expansion(-a.length() * 0.45, "start").forward(-r * 0.5).expandToRectangle(r).path2D((h, d) => s(h, d));
1924
+ a.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => s(h, d)), a.clone().directionMove(a.normal(), o * 0.5).directionMove(a.direction(), o * 0.5).expansion(-a.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => s(h, d)), a.clone().directionMove(a.normal(), -o * 0.5).directionMove(a.direction(), -o * 0.5).expansion(-a.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => s(h, d));
1922
1925
  }), i = "yellow", this.lineSegments.forEach((c) => {
1923
1926
  if (!c.userData.isWindow) return !1;
1924
1927
  Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((a) => {
1925
- const { p: h, width: d } = a, u = g.from(h), f = u.clone().add(c.direction().multiplyScalar(d * 0.5)), y = u.clone().add(c.direction().multiplyScalar(-d * 0.5)), p = new I(f, y);
1926
- s(p.start, p.end), p.expandToRectangle(this.width, "bothSides").path2D((x, D) => s(x, D));
1928
+ const { p: h, width: d } = a, u = g.from(h), f = u.clone().add(c.direction().multiplyScalar(d * 0.5)), y = u.clone().add(c.direction().multiplyScalar(-d * 0.5)), m = new I(f, y);
1929
+ s(m.start, m.end), m.expandToRectangle(this.width, "bothSides").path2D((x, D) => s(x, D));
1927
1930
  });
1928
1931
  }), n;
1929
1932
  }
@@ -1941,21 +1944,21 @@ class z extends V {
1941
1944
  s = c();
1942
1945
  } else
1943
1946
  throw new Error("创建画布失败");
1944
- const o = 2 * i.scale, r = {
1947
+ const r = 2 * i.scale, o = {
1945
1948
  cyan: "cyan",
1946
1949
  yellow: "yellow",
1947
1950
  white: "white"
1948
1951
  };
1949
- s.width = i.width + o * 2, s.height = i.height + o * 2;
1952
+ s.width = i.width + r * 2, s.height = i.height + r * 2;
1950
1953
  const l = s.getContext("2d");
1951
- return n && (l.fillStyle = n, l.fillRect(0, 0, s.width, s.height)), l.translate(i.width * 0.5 + o, i.height * 0.5 + o), i.line.forEach(([c, a, h, d, u]) => {
1952
- l.strokeStyle = r[u], l.beginPath(), l.moveTo(c, a), l.lineTo(h, d), l.closePath(), l.stroke();
1954
+ return n && (l.fillStyle = n, l.fillRect(0, 0, s.width, s.height)), l.translate(i.width * 0.5 + r, i.height * 0.5 + r), i.line.forEach(([c, a, h, d, u]) => {
1955
+ l.strokeStyle = o[u], l.beginPath(), l.moveTo(c, a), l.lineTo(h, d), l.closePath(), l.stroke();
1953
1956
  }), i.arc.forEach(([c, a, h, d, u, f]) => {
1954
- l.strokeStyle = r[f], l.beginPath(), l.arc(c, a, h, d * (Math.PI / 180), u * (Math.PI / 180)), l.stroke();
1957
+ l.strokeStyle = o[f], l.beginPath(), l.arc(c, a, h, d * (Math.PI / 180), u * (Math.PI / 180)), l.stroke();
1955
1958
  }), l.beginPath(), i.dimensionLine.forEach((c) => {
1956
1959
  let [a, h, d, u] = c;
1957
- const f = Math.min(h, u), y = Math.max(h, u), p = (s.width * 0.5 - 0.4 * i.scale) * (a < 0 ? -1 : 1), x = (y - f) * 0.45;
1958
- l.fillStyle = "#fff", l.font = `${0.15 * i.scale}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText((y - f).toFixed(2) + "cm", p, f + (y - f) * 0.5), l.moveTo(p - 0.1 * i.scale, f), l.lineTo(p + 0.1 * i.scale, f), l.moveTo(p, f), l.lineTo(p, x + f), l.moveTo(p, y), l.lineTo(p, y - x), l.moveTo(p - 0.1 * i.scale, y), l.lineTo(p + 0.1 * i.scale, y);
1960
+ const f = Math.min(h, u), y = Math.max(h, u), m = (s.width * 0.5 - 0.4 * i.scale) * (a < 0 ? -1 : 1), x = (y - f) * 0.45;
1961
+ l.fillStyle = "#fff", l.font = `${0.15 * i.scale}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText((y - f).toFixed(2) + "cm", m, f + (y - f) * 0.5), l.moveTo(m - 0.1 * i.scale, f), l.lineTo(m + 0.1 * i.scale, f), l.moveTo(m, f), l.lineTo(m, x + f), l.moveTo(m, y), l.lineTo(m, y - x), l.moveTo(m - 0.1 * i.scale, y), l.lineTo(m + 0.1 * i.scale, y);
1959
1962
  }), l.closePath(), l.strokeStyle = "#fff", l.stroke(), "toBlob" in s ? new Promise((c) => {
1960
1963
  s.toBlob((a) => {
1961
1964
  c(a);
@@ -1970,11 +1973,11 @@ class z extends V {
1970
1973
  e.setUnits(t), e.addLayer("cyan", W.ACI.CYAN, "DOTTED"), e.addLayer("yellow", W.ACI.YELLOW, "DOTTED"), e.addLayer("white", W.ACI.WHITE, "DOTTED");
1971
1974
  const n = this.toDrawDataJson();
1972
1975
  return n.line.forEach((i) => {
1973
- let [s, o, r, l, c] = i;
1974
- e.setActiveLayer(c), e.drawLine(s, o, r, l);
1976
+ let [s, r, o, l, c] = i;
1977
+ e.setActiveLayer(c), e.drawLine(s, r, o, l);
1975
1978
  }), n.arc.forEach((i) => {
1976
- const [s, o, r, l, c, a] = i;
1977
- e.setActiveLayer(a), e.drawArc(s, o, r, l, c);
1979
+ const [s, r, o, l, c, a] = i;
1980
+ e.setActiveLayer(a), e.drawArc(s, r, o, l, c);
1978
1981
  }), e.toDxfString();
1979
1982
  }
1980
1983
  /**
@@ -2024,8 +2027,8 @@ class z extends V {
2024
2027
  * @returns
2025
2028
  */
2026
2029
  computedOriginalSize(t, e = new C(0, 0, 0, 0)) {
2027
- const n = t.flatMap((c) => [c.start.x, c.end.x]), i = t.flatMap((c) => [c.start.y, c.end.y]), s = Math.min(...n), o = Math.min(...i), r = Math.max(...n), l = Math.max(...i);
2028
- return e.set(s, o, r, l), e;
2030
+ const n = t.flatMap((c) => [c.start.x, c.end.x]), i = t.flatMap((c) => [c.start.y, c.end.y]), s = Math.min(...n), r = Math.min(...i), o = Math.max(...n), l = Math.max(...i);
2031
+ return e.set(s, r, o, l), e;
2029
2032
  }
2030
2033
  /**
2031
2034
  * 创建数据
@@ -2035,10 +2038,10 @@ class z extends V {
2035
2038
  static createData(t, e = !0) {
2036
2039
  let n = 0;
2037
2040
  return t.flatMap((s) => {
2038
- const o = s.map((r, l) => {
2041
+ const r = s.map((o, l) => {
2039
2042
  const c = l === s.length - 1 ? 0 : l + 1, a = s[c];
2040
2043
  return {
2041
- start: { x: r.x, y: r.y },
2044
+ start: { x: o.x, y: o.y },
2042
2045
  end: { x: a.x, y: a.y },
2043
2046
  insetionArr: [
2044
2047
  {
@@ -2047,7 +2050,7 @@ class z extends V {
2047
2050
  ]
2048
2051
  };
2049
2052
  });
2050
- return n += s.length, e || (o.pop(), o[o.length - 1].insetionArr.length = 0, n--), o;
2053
+ return n += s.length, e || (r.pop(), r[r.length - 1].insetionArr.length = 0, n--), r;
2051
2054
  });
2052
2055
  }
2053
2056
  }
@@ -2084,15 +2087,15 @@ class ht extends z {
2084
2087
  const [c, a] = s.start.y < s.end.y ? [s.start, s.end] : [s.end, s.start];
2085
2088
  i = -new I(c, a).direction().angleBetween(new g(0, 1), "angle", "360");
2086
2089
  }
2087
- const o = e.originalBox.center, r = g.zero(), l = e.originalData.map((c) => {
2088
- const a = r.copy(c.start).division(o).rotate(g.zero(), i * (Math.PI / 180)).toJson(c.start.z), h = r.copy(c.end).division(o).rotate(g.zero(), i * (Math.PI / 180)).toJson(c.end.z), d = Object.assign($(c), { start: a, end: h });
2090
+ const r = e.originalBox.center, o = g.zero(), l = e.originalData.map((c) => {
2091
+ const a = o.copy(c.start).division(r).rotate(g.zero(), i * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(g.zero(), i * (Math.PI / 180)).toJson(c.end.z), d = Object.assign($(c), { start: a, end: h });
2089
2092
  return d.drawWindow && d.drawWindow.forEach((u) => {
2090
- u.p = r.copy(u.p).division(o).rotate(g.zero(), i * (Math.PI / 180)).toJson(u.p.z);
2093
+ u.p = o.copy(u.p).division(r).rotate(g.zero(), i * (Math.PI / 180)).toJson(u.p.z);
2091
2094
  }), d;
2092
2095
  });
2093
2096
  n.appendLineSegmentList.forEach((c) => {
2094
2097
  const a = c.clone();
2095
- a.start.division(o).rotate(g.zero(), i * (Math.PI / 180)), a.end.division(o).rotate(g.zero(), i * (Math.PI / 180)), l.push({
2098
+ a.start.division(r).rotate(g.zero(), i * (Math.PI / 180)), a.end.division(r).rotate(g.zero(), i * (Math.PI / 180)), l.push({
2096
2099
  start: a.start.toJson(e.originalZAverage),
2097
2100
  end: a.end.toJson(e.originalZAverage),
2098
2101
  insetionArr: [],
@@ -2100,7 +2103,7 @@ class ht extends z {
2100
2103
  });
2101
2104
  }), await this.set(l, e.width, e.scale), this.lineOffset(), this.doorLineSegment = e.doorLineSegment.map((c) => {
2102
2105
  const a = c.clone();
2103
- return a.start.division(o).rotate(g.zero(), i * (Math.PI / 180)), a.end.division(o).rotate(g.zero(), i * (Math.PI / 180)), a;
2106
+ return a.start.division(r).rotate(g.zero(), i * (Math.PI / 180)), a.end.division(r).rotate(g.zero(), i * (Math.PI / 180)), a;
2104
2107
  }), this.angle = i, this.dispatchEvent({
2105
2108
  type: "updateData"
2106
2109
  });
@@ -2157,16 +2160,16 @@ class dt {
2157
2160
  }), this.doorPoint = this.getDoorPoint(), !this.continueFind) return;
2158
2161
  const e = this.searchDoubleLinePoint();
2159
2162
  this.addPointsExcludeRule((n, i, s) => {
2160
- const o = this.lineSegments.indexOf(n), r = e.get(o);
2161
- return typeof r == "number" ? r === -1 || r === s : !1;
2163
+ const r = this.lineSegments.indexOf(n), o = e.get(r);
2164
+ return typeof o == "number" ? o === -1 || o === s : !1;
2162
2165
  }), this.addPointsExcludeRule((n, i) => !!this.doorPoint.find((s) => s.point.equal(i))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((n) => this.findPointVirtualGrid.insert(n.point, n.line)), this.handle();
2163
2166
  }
2164
2167
  handle() {
2165
2168
  this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.doorPoint.length < 2 && this.dxf.doorLineSegment.push(...this.search(this.possibleDoorPoints, this.possibleDoorPoints, 0.6));
2166
2169
  }
2167
2170
  search(t, e = [], n = 0.6, i = this.doorSearchDistance, s = this.doorSearchNearAngle) {
2168
- const o = this.dxf, r = this.searchNearby(t, e, i, s);
2169
- r.push(
2171
+ const r = this.dxf, o = this.searchNearby(t, e, i, s);
2172
+ o.push(
2170
2173
  ...t.map((c) => {
2171
2174
  const a = this.searchAlongDirection(c, i);
2172
2175
  if (a) return {
@@ -2181,14 +2184,14 @@ class dt {
2181
2184
  }).filter((c) => !!c && c.start.distance(c.end) < i)
2182
2185
  );
2183
2186
  const l = [];
2184
- return r.forEach((c) => {
2187
+ return o.forEach((c) => {
2185
2188
  const a = new I(c?.start, c?.end), h = a.length();
2186
2189
  if (h < n) return;
2187
- const d = a.normal(), u = a.direction(), f = (h - o.width * 2) / 2;
2190
+ const d = a.normal(), u = a.direction(), f = (h - r.width * 2) / 2;
2188
2191
  for (let y = 0; y < 3; y++) {
2189
- const p = a.start.clone().add(u.clone().multiplyScalar(o.width + f * y)), x = new I(
2190
- p,
2191
- p.clone().add(d.clone().multiplyScalar(1))
2192
+ const m = a.start.clone().add(u.clone().multiplyScalar(r.width + f * y)), x = new I(
2193
+ m,
2194
+ m.clone().add(d.clone().multiplyScalar(1))
2192
2195
  );
2193
2196
  if (x.directionMove(d, -0.5), this.quadtree.queryLineSegment(x).length) return;
2194
2197
  }
@@ -2209,8 +2212,8 @@ class dt {
2209
2212
  const t = [];
2210
2213
  return this.lineSegments.forEach((e) => {
2211
2214
  e.points.forEach((n, i) => {
2212
- for (let o = 0; o < this._pointsExcludeRule.length; o++) if (this._pointsExcludeRule[o](e, n, i)) return;
2213
- this.pointVirtualGrid.queryPoint(n).filter((o) => o.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: k() });
2215
+ for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, i)) return;
2216
+ this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: k() });
2214
2217
  });
2215
2218
  }), t;
2216
2219
  }
@@ -2220,27 +2223,27 @@ class dt {
2220
2223
  getDoorPoint() {
2221
2224
  const t = [], e = this.dxf, n = this.pointVirtualGrid;
2222
2225
  return e.doors.forEach((i) => {
2223
- const s = e.lineSegments[i[4]], o = e.originalData[i[4]];
2224
- if (o.drawDoorData) {
2225
- const r = g.from(o.drawDoorData.start), l = g.from(o.drawDoorData.n), c = n.queryPoint(r).filter((a) => {
2226
+ const s = e.lineSegments[i[4]], r = e.originalData[i[4]];
2227
+ if (r.drawDoorData) {
2228
+ const o = g.from(r.drawDoorData.start), l = g.from(r.drawDoorData.n), c = n.queryPoint(o).filter((a) => {
2226
2229
  if (a.userData === s) return !1;
2227
2230
  const h = a.userData, d = h.direction();
2228
- h.start.equal(r) && d.multiplyScalar(-1);
2231
+ h.start.equal(o) && d.multiplyScalar(-1);
2229
2232
  const u = l.angleBetween(d, "angle");
2230
2233
  return u > 80 || u < 10;
2231
2234
  });
2232
2235
  c.length && t.push({
2233
2236
  line: c[0].userData,
2234
- point: r,
2237
+ point: o,
2235
2238
  uuid: k()
2236
2239
  });
2237
- } else if (o.doorDirectConnection) {
2240
+ } else if (r.doorDirectConnection) {
2238
2241
  this.continueFind = !1;
2239
- const r = new I(g.from(o.start), g.from(o.end));
2240
- r.userData = {
2242
+ const o = new I(g.from(r.start), g.from(r.end));
2243
+ o.userData = {
2241
2244
  doorDirectConnection: !0,
2242
2245
  isDoor: !0
2243
- }, this.dxf.doorLineSegment.push(r);
2246
+ }, this.dxf.doorLineSegment.push(o);
2244
2247
  } else
2245
2248
  console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
2246
2249
  }), t;
@@ -2252,7 +2255,7 @@ class dt {
2252
2255
  searchDoubleLinePoint() {
2253
2256
  const t = /* @__PURE__ */ new Map();
2254
2257
  return this.resultList.flatMap((e) => {
2255
- const n = this.lineSegments[e.sourceIndex], i = this.lineSegments[e.targetIndex], s = i.projectPoint(n.start), o = i.projectPoint(n.end), r = n.projectPoint(i.start), l = n.projectPoint(i.end), c = s && o ? -1 : s ? 0 : o ? 1 : -1, a = r && l ? -1 : r ? 0 : l ? 1 : -1;
2258
+ const n = this.lineSegments[e.sourceIndex], i = this.lineSegments[e.targetIndex], s = i.projectPoint(n.start), r = i.projectPoint(n.end), o = n.projectPoint(i.start), l = n.projectPoint(i.end), c = s && r ? -1 : s ? 0 : r ? 1 : -1, a = o && l ? -1 : o ? 0 : l ? 1 : -1;
2256
2259
  t.has(e.sourceIndex) ? t.get(e.sourceIndex) != c && t.set(e.sourceIndex, -1) : t.set(e.sourceIndex, c), t.has(e.targetIndex) ? t.get(e.targetIndex) != a && t.set(e.targetIndex, -1) : t.set(e.targetIndex, a);
2257
2260
  }), t;
2258
2261
  }
@@ -2265,94 +2268,94 @@ class dt {
2265
2268
  * @returns
2266
2269
  */
2267
2270
  searchNearby(t, e = [], n = this.doorSearchDistance, i = this.doorSearchNearAngle) {
2268
- const s = this.findPointVirtualGrid, o = this.quadtree;
2269
- function r({ point: p, line: x }, D, w) {
2270
- const b = x.direction();
2271
- x.start === p && b.multiplyScalar(-1);
2272
- const P = s.queryCircle(p, n).filter((m) => m.userData !== x).sort((m, A) => m.point.distance(p) - A.point.distance(p)), S = [];
2273
- for (let m = 0; m < P.length; m++) {
2274
- const A = e.findIndex((j) => j.point === P[m].point), E = t[D].uuid, L = e[A].uuid;
2275
- if (w.has(`${E}.${L}`)) continue;
2276
- w.add(`${E}.${L}`), w.add(`${L}.${E}`);
2277
- const v = P[m].point, B = new I(p.clone(), v.clone());
2278
- if (B.direction().angleBetween(b, "angle") < i) {
2271
+ const s = this.findPointVirtualGrid, r = this.quadtree;
2272
+ function o({ point: m, line: x }, D, w) {
2273
+ const P = x.direction();
2274
+ x.start === m && P.multiplyScalar(-1);
2275
+ const b = s.queryCircle(m, n).filter((p) => p.userData !== x).sort((p, A) => p.point.distance(m) - A.point.distance(m)), L = [];
2276
+ for (let p = 0; p < b.length; p++) {
2277
+ const A = e.findIndex((j) => j.point === b[p].point), E = t[D].uuid, S = e[A].uuid;
2278
+ if (w.has(`${E}.${S}`)) continue;
2279
+ w.add(`${E}.${S}`), w.add(`${S}.${E}`);
2280
+ const v = b[p].point, B = new I(m.clone(), v.clone());
2281
+ if (B.direction().angleBetween(P, "angle") < i) {
2279
2282
  const j = t[A].line.direction();
2280
- P[m].userData.start.equal(P[m].point) && j.multiplyScalar(-1), B.direction().multiplyScalar(-1).angleBetween(j, "angle") < i && (o.queryLineSegment(B).length || S.push({
2281
- findData: P[m],
2282
- findUuid: L,
2283
+ b[p].userData.start.equal(b[p].point) && j.multiplyScalar(-1), B.direction().multiplyScalar(-1).angleBetween(j, "angle") < i && (r.queryLineSegment(B).length || L.push({
2284
+ findData: b[p],
2285
+ findUuid: S,
2283
2286
  doorLine: B,
2284
2287
  doorUuid: E
2285
2288
  }));
2286
2289
  }
2287
2290
  }
2288
- return S;
2291
+ return L;
2289
2292
  }
2290
- function l(p, x, D, w, b) {
2291
- w.add(p);
2292
- const P = [];
2293
- b && P.push(b);
2294
- for (let S = 0; S < D.length; S++) {
2295
- const m = D[S];
2296
- if (x.has(m.findUuid)) {
2297
- const A = x.get(m.findUuid);
2298
- l(m.findUuid, x, A, w, m) && P.push(m);
2299
- } else P.push(m);
2293
+ function l(m, x, D, w, P) {
2294
+ w.add(m);
2295
+ const b = [];
2296
+ P && b.push(P);
2297
+ for (let L = 0; L < D.length; L++) {
2298
+ const p = D[L];
2299
+ if (x.has(p.findUuid)) {
2300
+ const A = x.get(p.findUuid);
2301
+ l(p.findUuid, x, A, w, p) && b.push(p);
2302
+ } else b.push(p);
2300
2303
  }
2301
- return P.sort((S, m) => S.doorLine.length() - m.doorLine.length()), b && P[0] === b ? (D.splice(0), !0) : (D.splice(1), !1);
2304
+ return b.sort((L, p) => L.doorLine.length() - p.doorLine.length()), P && b[0] === P ? (D.splice(0), !0) : (D.splice(1), !1);
2302
2305
  }
2303
2306
  const c = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
2304
- t.map((p, x) => {
2305
- const D = r(p, x, c);
2306
- D.length && a.set(p.uuid, D);
2307
+ t.map((m, x) => {
2308
+ const D = o(m, x, c);
2309
+ D.length && a.set(m.uuid, D);
2307
2310
  }), c.clear();
2308
2311
  const h = /* @__PURE__ */ new Map();
2309
- a.forEach((p, x) => {
2310
- if (!c.has(x) && p.length && l(x, a, p, c), p.length) {
2311
- const D = p[0];
2312
+ a.forEach((m, x) => {
2313
+ if (!c.has(x) && m.length && l(x, a, m, c), m.length) {
2314
+ const D = m[0];
2312
2315
  h.has(D.doorUuid) || h.set(D.doorUuid, []), h.get(D.doorUuid)?.push(D), h.has(D.findUuid) || h.set(D.findUuid, []), h.get(D.findUuid)?.push(D);
2313
2316
  }
2314
2317
  });
2315
2318
  const d = /* @__PURE__ */ new Set();
2316
- h.forEach((p) => {
2317
- if (p.length > 1) {
2318
- p.sort((x, D) => x.doorLine.length() - D.doorLine.length());
2319
- for (let x = 1; x < p.length; x++) d.add(p[x]);
2319
+ h.forEach((m) => {
2320
+ if (m.length > 1) {
2321
+ m.sort((x, D) => x.doorLine.length() - D.doorLine.length());
2322
+ for (let x = 1; x < m.length; x++) d.add(m[x]);
2320
2323
  }
2321
2324
  });
2322
2325
  const u = [], f = [];
2323
- a.forEach((p) => {
2324
- if (p.length) {
2325
- const x = p[0];
2326
+ a.forEach((m) => {
2327
+ if (m.length) {
2328
+ const x = m[0];
2326
2329
  d.has(x) || (u.push(x), f.push(x.doorUuid, x.findUuid));
2327
2330
  }
2328
2331
  });
2329
2332
  const y = [];
2330
- return u.forEach((p) => {
2331
- const x = t.findIndex((A) => A.uuid === p.doorUuid), D = e.findIndex((A) => A.uuid === p.findUuid), w = t[x].point.clone(), b = e[D].point.clone(), P = this.findLongLineSegment(t[x].line), S = this.findLongLineSegment(e[D].line), m = P.projectPoint(b);
2332
- if (m) {
2333
- w.copy(m);
2334
- const A = new I(w, b), E = S.includedAngle(A);
2333
+ return u.forEach((m) => {
2334
+ const x = t.findIndex((A) => A.uuid === m.doorUuid), D = e.findIndex((A) => A.uuid === m.findUuid), w = t[x].point.clone(), P = e[D].point.clone(), b = this.findLongLineSegment(t[x].line), L = this.findLongLineSegment(e[D].line), p = b.projectPoint(P);
2335
+ if (p) {
2336
+ w.copy(p);
2337
+ const A = new I(w, P), E = L.includedAngle(A);
2335
2338
  (E < 10 || E > 170 || Math.abs(90 - E) < 10) && y.push({
2336
2339
  start: w,
2337
- end: b
2340
+ end: P
2338
2341
  });
2339
2342
  } else {
2340
- const A = S.projectPoint(w);
2341
- A && b.copy(A);
2342
- const E = new I(w, b), L = P.includedAngle(E);
2343
- (L < 10 || L > 170 || Math.abs(90 - L) < 10) && y.push({
2343
+ const A = L.projectPoint(w);
2344
+ A && P.copy(A);
2345
+ const E = new I(w, P), S = b.includedAngle(E);
2346
+ (S < 10 || S > 170 || Math.abs(90 - S) < 10) && y.push({
2344
2347
  start: w,
2345
- end: b
2348
+ end: P
2346
2349
  });
2347
2350
  }
2348
2351
  }), e.splice(
2349
2352
  0,
2350
2353
  e.length,
2351
- ...e.filter((p) => f.indexOf(p.uuid) === -1)
2354
+ ...e.filter((m) => f.indexOf(m.uuid) === -1)
2352
2355
  ), t.splice(
2353
2356
  0,
2354
2357
  t.length,
2355
- ...t.filter((p) => f.indexOf(p.uuid) === -1)
2358
+ ...t.filter((m) => f.indexOf(m.uuid) === -1)
2356
2359
  ), y;
2357
2360
  }
2358
2361
  /** 方案二: 沿方向查找
@@ -2363,8 +2366,8 @@ class dt {
2363
2366
  searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
2364
2367
  const i = this.quadtree, s = e.direction();
2365
2368
  e.start === t && s.multiplyScalar(-1);
2366
- const o = t.clone().add(s.clone().multiplyScalar(n)), r = new I(t.clone(), o), l = i.queryLineSegment(r).map((c) => ({
2367
- point: c.line.getIntersection(r),
2369
+ const r = t.clone().add(s.clone().multiplyScalar(n)), o = new I(t.clone(), r), l = i.queryLineSegment(o).map((c) => ({
2370
+ point: c.line.getIntersection(o),
2368
2371
  line: c.line
2369
2372
  })).filter((c) => c.point).sort((c, a) => t.distance(c.point) - t.distance(a.point));
2370
2373
  if (l.length) {
@@ -2380,23 +2383,23 @@ class dt {
2380
2383
  * @returns
2381
2384
  */
2382
2385
  searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
2383
- const i = this.pointVirtualGrid, s = this.quadtree, o = e.direction(), r = e.start.normal(e.end), l = e.start.clone();
2384
- e.start === t && o.multiplyScalar(-1), e.start === t && l.copy(e.end);
2386
+ const i = this.pointVirtualGrid, s = this.quadtree, r = e.direction(), o = e.start.normal(e.end), l = e.start.clone();
2387
+ e.start === t && r.multiplyScalar(-1), e.start === t && l.copy(e.end);
2385
2388
  const c = i.queryPoint(l).filter((d) => d.userData !== e);
2386
2389
  for (let d = 0; d < c.length; d++) {
2387
2390
  const u = c[d], f = u.userData, y = f.direction();
2388
- if (f.start === u.point && o.multiplyScalar(-1), y.angleBetween(r) / (Math.PI / 180) > 90) {
2389
- r.multiplyScalar(-1);
2391
+ if (f.start === u.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
2392
+ o.multiplyScalar(-1);
2390
2393
  break;
2391
2394
  }
2392
2395
  }
2393
- const a = new I(t.clone(), t.clone().add(r.multiplyScalar(n))), h = s.queryLineSegment(a).map((d) => ({
2396
+ const a = new I(t.clone(), t.clone().add(o.multiplyScalar(n))), h = s.queryLineSegment(a).map((d) => ({
2394
2397
  point: d.line.getIntersection(a),
2395
2398
  line: d.line
2396
2399
  })).filter((d) => d.point).sort((d, u) => t.distance(d.point) - t.distance(u.point));
2397
2400
  if (h.length) {
2398
2401
  const d = h[0];
2399
- if (Math.abs(90 - d.line.direction().angleBetween(r, "angle")) < 5)
2402
+ if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
2400
2403
  return d;
2401
2404
  }
2402
2405
  }
@@ -2408,16 +2411,16 @@ class dt {
2408
2411
  findLongLineSegment(t) {
2409
2412
  const e = t.clone(), n = this.pointVirtualGrid.queryPoint(t.start), i = this.pointVirtualGrid.queryPoint(t.end);
2410
2413
  for (let s = 0; s < n.length; s++) {
2411
- const { userData: o } = n[s];
2412
- if (o !== t && o && o.directionEqual(t)) {
2413
- o.start.equal(t.start) ? e.start.copy(o.end) : e.start.copy(o.start);
2414
+ const { userData: r } = n[s];
2415
+ if (r !== t && r && r.directionEqual(t)) {
2416
+ r.start.equal(t.start) ? e.start.copy(r.end) : e.start.copy(r.start);
2414
2417
  break;
2415
2418
  }
2416
2419
  }
2417
2420
  for (let s = 0; s < i.length; s++) {
2418
- const { userData: o } = i[s];
2419
- if (o !== t && o && o.directionEqual(t)) {
2420
- o.end.equal(t.end) ? e.end.copy(o.start) : e.end.copy(o.end);
2421
+ const { userData: r } = i[s];
2422
+ if (r !== t && r && r.directionEqual(t)) {
2423
+ r.end.equal(t.end) ? e.end.copy(r.start) : e.end.copy(r.end);
2421
2424
  break;
2422
2425
  }
2423
2426
  }
@@ -2448,15 +2451,15 @@ class ut extends V {
2448
2451
  * @returns
2449
2452
  */
2450
2453
  expandLineSegment(t, e, n = 0.1) {
2451
- const i = e.normal(t), s = e.direction(t).mutiplyScalar(n * 0.5), o = t.direction(e).mutiplyScalar(n * 0.5), r = i.x * n * 0.5, l = i.y * n * 0.5;
2454
+ const i = e.normal(t), s = e.direction(t).mutiplyScalar(n * 0.5), r = t.direction(e).mutiplyScalar(n * 0.5), o = i.x * n * 0.5, l = i.y * n * 0.5;
2452
2455
  return {
2453
2456
  points: [
2454
2457
  // 第一条线
2455
- new g(t.x + r, t.y + l).add(o),
2456
- new g(e.x + r, e.y + l).add(s),
2458
+ new g(t.x + o, t.y + l).add(r),
2459
+ new g(e.x + o, e.y + l).add(s),
2457
2460
  // 第二条线
2458
- new g(t.x - r, t.y - l).add(o),
2459
- new g(e.x - r, e.y - l).add(s)
2461
+ new g(t.x - o, t.y - l).add(r),
2462
+ new g(e.x - o, e.y - l).add(s)
2460
2463
  ],
2461
2464
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2462
2465
  rectIndices: [0, 1, 3, 2, 0]
@@ -2478,14 +2481,14 @@ class ut extends V {
2478
2481
  createRectangle(t) {
2479
2482
  const e = this.Dxf, n = t.project, i = t.project2;
2480
2483
  n.includedAngle(i) > 135 && (i.points = [i.points[1], i.points[0]]), this.addData(n.points[0], i.points[0]), this.addData(n.points[1], i.points[1]);
2481
- const s = n.points[0].distance(i.points[0]), o = n.points[1].distance(i.points[1]), r = Math.ceil(Math.max(s, o) / e.width), l = s / r, c = o / r, a = i.points[0].direction(n.points[0]), h = i.points[1].direction(n.points[1]), d = n.points[0].clone(), u = n.points[1].clone(), f = u.direction(d);
2484
+ const s = n.points[0].distance(i.points[0]), r = n.points[1].distance(i.points[1]), o = Math.ceil(Math.max(s, r) / e.width), l = s / o, c = r / o, a = i.points[0].direction(n.points[0]), h = i.points[1].direction(n.points[1]), d = n.points[0].clone(), u = n.points[1].clone(), f = u.direction(d);
2482
2485
  f.multiplyScalar(e.width * 0.5);
2483
- const y = d.clone().add(f), p = u.clone().add(f.multiplyScalar(-1)), x = d.direction(u), D = y.direction(p);
2486
+ const y = d.clone().add(f), m = u.clone().add(f.multiplyScalar(-1)), x = d.direction(u), D = y.direction(m);
2484
2487
  if (!(x.x > 0 && D.x < 0 || x.x < 0 && D.x > 0 || x.y > 0 && D.y < 0 || x.y < 0 && D.y > 0)) {
2485
- d.set(y.x, y.y), u.set(p.x, p.y);
2486
- for (let w = 1; w < r; w++) {
2487
- const b = a.clone().multiplyScalar(l * w), P = h.clone().multiplyScalar(c * w), S = d.clone().add(b), m = u.clone().add(P);
2488
- this.addData(S, m);
2488
+ d.set(y.x, y.y), u.set(m.x, m.y);
2489
+ for (let w = 1; w < o; w++) {
2490
+ const P = a.clone().multiplyScalar(l * w), b = h.clone().multiplyScalar(c * w), L = d.clone().add(P), p = u.clone().add(b);
2491
+ this.addData(L, p);
2489
2492
  }
2490
2493
  }
2491
2494
  }
@@ -2511,13 +2514,13 @@ class ut extends V {
2511
2514
  lineAnalysis() {
2512
2515
  this.buildQuadtree();
2513
2516
  const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), i = [];
2514
- e.forEach((s, o) => {
2515
- const r = e[o], l = J.fromByLineSegment(r, this.width * 2, !1, -0.01);
2516
- t.queryRect(l).map((a) => a.userData).filter((a) => a !== o).forEach((a) => {
2517
+ e.forEach((s, r) => {
2518
+ const o = e[r], l = J.fromByLineSegment(o, this.width * 2, !1, -0.01);
2519
+ t.queryRect(l).map((a) => a.userData).filter((a) => a !== r).forEach((a) => {
2517
2520
  try {
2518
- if (n.has(`${o}-${a}`) || n.has(`${a}-${o}`)) return;
2519
- const h = this.projectionAnalysis(a, o, r, e);
2520
- h && i.push(h), n.add(`${o}-${a}`);
2521
+ if (n.has(`${r}-${a}`) || n.has(`${a}-${r}`)) return;
2522
+ const h = this.projectionAnalysis(a, r, o, e);
2523
+ h && i.push(h), n.add(`${r}-${a}`);
2521
2524
  } catch {
2522
2525
  }
2523
2526
  });
@@ -2530,7 +2533,7 @@ class ut extends V {
2530
2533
  * @returns
2531
2534
  */
2532
2535
  projectionAnalysis(t, e, n, i) {
2533
- const s = i[t], o = n.direction(), r = s.direction(), l = o.angleBetween(r) / (Math.PI / 180);
2536
+ const s = i[t], r = n.direction(), o = s.direction(), l = r.angleBetween(o) / (Math.PI / 180);
2534
2537
  if (l < this.errorAngle || l > 180 - this.errorAngle) {
2535
2538
  let c;
2536
2539
  const a = s.projectLineSegment(n), h = n.projectLineSegment(s);
@@ -2571,22 +2574,22 @@ class ft extends V {
2571
2574
  const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf");
2572
2575
  this.parent?.findComponentByName("Renderer");
2573
2576
  const n = this.parent?.findComponentByName("AngleCorrectionDxf"), i = /* @__PURE__ */ new Map();
2574
- let s = [...e.lineSegments], o = [], r = [];
2577
+ let s = [...e.lineSegments], r = [], o = [];
2575
2578
  t.resultList.forEach((a) => {
2576
2579
  const h = i.get(a.target) ?? [], d = i.get(a.source) ?? [], u = a.project.clone(), f = a.project2.clone();
2577
2580
  u.includedAngle(f) > 135 && (f.points = [f.points[1], f.points[0]]), h.push(...u.points), d.push(...f.points), i.set(a.target, h), i.set(a.source, d);
2578
- const y = new I(u.start, f.start), p = new I(u.end, f.end), x = new I(y.center, p.center);
2579
- x.userData.wallWidth = Math.max(y.length(), p.length()), o.push(x);
2581
+ const y = new I(u.start, f.start), m = new I(u.end, f.end), x = new I(y.center, m.center);
2582
+ x.userData.wallWidth = Math.max(y.length(), m.length()), r.push(x);
2580
2583
  });
2581
2584
  const l = [];
2582
2585
  s = s.filter((a) => {
2583
- if (r.indexOf(a) > -1) return !1;
2586
+ if (o.indexOf(a) > -1) return !1;
2584
2587
  if (i.has(a)) {
2585
2588
  const h = i.get(a), d = a.clone();
2586
2589
  if (h) {
2587
2590
  for (let f = 0; f < h.length; f += 2) {
2588
- const y = h[f], p = h[f + 1];
2589
- y.userData.length = y.distance(d.start), p.userData.length = p.distance(d.start), y.userData.type = "start", p.userData.type = "end", d.start.distance(y) > d.start.distance(p) && (h[f] = p, h[f + 1] = y, y.userData.type = "end", p.userData.type = "start");
2591
+ const y = h[f], m = h[f + 1];
2592
+ y.userData.length = y.distance(d.start), m.userData.length = m.distance(d.start), y.userData.type = "start", m.userData.type = "end", d.start.distance(y) > d.start.distance(m) && (h[f] = m, h[f + 1] = y, y.userData.type = "end", m.userData.type = "start");
2590
2593
  }
2591
2594
  h.sort((f, y) => f.userData.length - y.userData.length);
2592
2595
  const u = [];
@@ -2599,7 +2602,7 @@ class ft extends V {
2599
2602
  return !1;
2600
2603
  }
2601
2604
  return !0;
2602
- }), s.push(...o), s.push(...l.filter((a) => a.length() > 0.05));
2605
+ }), s.push(...r), s.push(...l.filter((a) => a.length() > 0.05));
2603
2606
  const c = e.box.center;
2604
2607
  s = s.map((a) => {
2605
2608
  const h = a.clone();
@@ -2650,17 +2653,17 @@ class ft extends V {
2650
2653
  };
2651
2654
  if (i.userData.isWindow)
2652
2655
  return i.userData.drawWindow.map((s) => {
2653
- const o = g.from(s.p), r = o.clone().add(
2656
+ const r = g.from(s.p), o = r.clone().add(
2654
2657
  i.direction().multiplyScalar(s.width * 0.5)
2655
- ), l = o.clone().add(
2658
+ ), l = r.clone().add(
2656
2659
  i.direction().multiplyScalar(-s.width * 0.5)
2657
2660
  );
2658
2661
  return {
2659
2662
  id: n++,
2660
2663
  type: "WINDOW",
2661
2664
  start: {
2662
- x: r.x * 1,
2663
- y: r.y * 1
2665
+ x: o.x * 1,
2666
+ y: o.y * 1
2664
2667
  },
2665
2668
  end: {
2666
2669
  x: l.x * 1,
@@ -2710,17 +2713,17 @@ class pt extends ct {
2710
2713
  });
2711
2714
  }
2712
2715
  }
2713
- const mt = new rt(), xt = new at();
2716
+ const mt = new ot(), xt = new at();
2714
2717
  function yt(M, t, e = 0.1) {
2715
- const n = t.normal(M), i = t.direction(M).mutiplyScalar(e * 0.5), s = M.direction(t).mutiplyScalar(e * 0.5), o = n.x * e * 0.5, r = n.y * e * 0.5;
2718
+ const n = t.normal(M), i = t.direction(M).mutiplyScalar(e * 0.5), s = M.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
2716
2719
  return {
2717
2720
  points: [
2718
2721
  // 第一条线
2719
- new g(M.x + o, M.y + r).add(s),
2720
- new g(t.x + o, t.y + r).add(i),
2722
+ new g(M.x + r, M.y + o).add(s),
2723
+ new g(t.x + r, t.y + o).add(i),
2721
2724
  // 第二条线
2722
- new g(M.x - o, M.y - r).add(s),
2723
- new g(t.x - o, t.y - r).add(i)
2725
+ new g(M.x - r, M.y - o).add(s),
2726
+ new g(t.x - r, t.y - o).add(i)
2724
2727
  ],
2725
2728
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2726
2729
  rectIndices: [0, 1, 3, 2, 0]
@@ -2747,16 +2750,16 @@ class nt extends V {
2747
2750
  const t = this.Dxf;
2748
2751
  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) => {
2749
2752
  const i = new q.Shape();
2750
- n.forEach((r, l) => l === 0 ? i.moveTo(r.x / t.scale, r.y / t.scale) : i.lineTo(r.x / t.scale, r.y / t.scale));
2753
+ n.forEach((o, l) => l === 0 ? i.moveTo(o.x / t.scale, o.y / t.scale) : i.lineTo(o.x / t.scale, o.y / t.scale));
2751
2754
  const s = new q.ExtrudeGeometry(i, {
2752
2755
  depth: 2.8,
2753
2756
  bevelSize: 0
2754
- }), o = new q.Mesh(s, this.material);
2755
- this.whiteModelGroup.add(o), this.whiteModelLineGroup.add(
2757
+ }), r = new q.Mesh(s, this.material);
2758
+ this.whiteModelGroup.add(r), this.whiteModelLineGroup.add(
2756
2759
  new q.LineSegments(new q.EdgesGeometry(s), new q.LineBasicMaterial({ color: 0 }))
2757
2760
  );
2758
2761
  }), t.originalData.map(({ start: n, end: i, insetionArr: s }) => {
2759
- const o = new g(n.x, n.y).mutiplyScalar(t.scale), r = new g(i.x, i.y).mutiplyScalar(t.scale), { points: l, indices: c, rectIndices: a } = yt(o, r, t.width);
2762
+ const r = new g(n.x, n.y).mutiplyScalar(t.scale), o = new g(i.x, i.y).mutiplyScalar(t.scale), { points: l, indices: c, rectIndices: a } = yt(r, o, t.width);
2760
2763
  return {
2761
2764
  points: l,
2762
2765
  indices: c,
@@ -2765,17 +2768,17 @@ class nt extends V {
2765
2768
  };
2766
2769
  }).forEach((n) => {
2767
2770
  const i = new q.Shape();
2768
- n.rectIndices.forEach((r, l) => {
2769
- const c = n.points[r];
2771
+ n.rectIndices.forEach((o, l) => {
2772
+ const c = n.points[o];
2770
2773
  l === 0 ? i.moveTo(c.x, c.y) : i.lineTo(c.x, c.y);
2771
2774
  });
2772
2775
  const s = new q.ExtrudeGeometry(i, {
2773
2776
  depth: 2.8,
2774
2777
  bevelSize: 0
2775
2778
  });
2776
- if (s.attributes.position.array.filter((r) => Number.isNaN(r)).length) return;
2777
- const o = new q.Mesh(s);
2778
- this.originalWhiteMode?.add(o);
2779
+ if (s.attributes.position.array.filter((o) => Number.isNaN(o)).length) return;
2780
+ const r = new q.Mesh(s);
2781
+ this.originalWhiteMode?.add(r);
2779
2782
  }), this.dispatchEvent({
2780
2783
  type: "updateModel",
2781
2784
  originalWhiteMode: this.originalWhiteMode,
@@ -2811,12 +2814,12 @@ class nt extends V {
2811
2814
  });
2812
2815
  else if (typeof global != "function")
2813
2816
  try {
2814
- const n = await O("obj2gltf", !0), i = await O("fs", !1), s = await this.toOBJ(), o = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16);
2815
- i.writeFileSync(o, s ?? "存贮失败");
2816
- const r = await n(o, {
2817
+ const n = await O("obj2gltf", !0), i = await O("fs", !1), s = await this.toOBJ(), r = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16);
2818
+ i.writeFileSync(r, s ?? "存贮失败");
2819
+ const o = await n(r, {
2817
2820
  binary: t
2818
2821
  });
2819
- i.unlinkSync(o), e(t ? r : JSON.stringify(r));
2822
+ i.unlinkSync(r), e(t ? o : JSON.stringify(o));
2820
2823
  } catch (n) {
2821
2824
  e(void 0), console.log(n);
2822
2825
  }
@@ -2935,9 +2938,9 @@ class it extends V {
2935
2938
  e.direction.z
2936
2939
  ), s = 100;
2937
2940
  this.racasterHelper(n, i, s), i.z = 0;
2938
- const r = new q.Raycaster(n, i, 0, s).intersectObject(t.originalWhiteMode);
2939
- if (r.length) {
2940
- const { point: l } = r[0];
2941
+ const o = new q.Raycaster(n, i, 0, s).intersectObject(t.originalWhiteMode);
2942
+ if (o.length) {
2943
+ const { point: l } = o[0];
2941
2944
  this.desPoints.push({
2942
2945
  message: e.desc,
2943
2946
  position: n,
@@ -2966,7 +2969,7 @@ class st extends V {
2966
2969
  const e = t.to3DArray(1 / t.scale, 0);
2967
2970
  this.dxfLineModel.geometry = new q.BufferGeometry().setAttribute("position", new q.BufferAttribute(e, 3, !0));
2968
2971
  const n = new Float32Array(
2969
- t.doorLineSegment.flatMap(({ start: s, end: o }) => [s.x, s.y, 0, o.x, o.y, 0])
2972
+ t.doorLineSegment.flatMap(({ start: s, end: r }) => [s.x, s.y, 0, r.x, r.y, 0])
2970
2973
  ).map((s) => s / t.scale), i = new Float32Array(t.doorLineSegment.flatMap(() => [1, 0, 0, 0, 1, 0]));
2971
2974
  this.dxfDoorsLineModel.geometry = new q.BufferGeometry().setAttribute("position", new q.BufferAttribute(n, 3, !0)).setAttribute("color", new q.BufferAttribute(i, 3)), this.dxfModelGroup.position.z = t.originalZAverage, this.dispatchEvent({
2972
2975
  type: "modelUpdate",
@@ -2980,7 +2983,7 @@ const gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2980
2983
  DxfLineModel: st,
2981
2984
  WhiteModel: nt
2982
2985
  }, Symbol.toStringTag, { value: "Module" }));
2983
- function Q(M, t = {}) {
2986
+ function _(M, t = {}) {
2984
2987
  const {
2985
2988
  detailsPoint: e = !0,
2986
2989
  whiteModel: n = !0,
@@ -2988,9 +2991,9 @@ function Q(M, t = {}) {
2988
2991
  } = t;
2989
2992
  i && M.addComponent(new st()), n && M.addComponent(new nt()), e && M.addComponent(new it());
2990
2993
  }
2991
- const wt = Object.assign(Q, {
2994
+ const wt = Object.assign(_, {
2992
2995
  create(M = {}) {
2993
- return (t) => Q(t, M);
2996
+ return (t) => _(t, M);
2994
2997
  }
2995
2998
  }), Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2996
2999
  __proto__: null,
@@ -3005,7 +3008,7 @@ function St() {
3005
3008
  }
3006
3009
  let H = null;
3007
3010
  async function It(M, t, e = !1, n) {
3008
- const i = await Promise.resolve().then(() => Mt), s = await Dt(), o = await St(), r = new pt().usePlugin(i.ModelDataPlugin.create({
3011
+ const i = await Promise.resolve().then(() => Mt), s = await Dt(), r = await St(), o = new pt().usePlugin(i.ModelDataPlugin.create({
3009
3012
  detailsPoint: !1,
3010
3013
  whiteModel: !0
3011
3014
  })).usePlugin(s.RenderPlugin.create({
@@ -3014,19 +3017,19 @@ async function It(M, t, e = !1, n) {
3014
3017
  detailsPoint: !1,
3015
3018
  orbitControls: e,
3016
3019
  camera: t
3017
- })).usePlugin(o.Editor.create({ viewPermission: n })), l = r.findComponentByType(s.components.DomContainer);
3018
- return l && M.appendChild(l.domElement), H = r, {
3019
- dxfSystem: r,
3020
- getFileAll: () => Lt(r)
3020
+ })).usePlugin(r.Editor.create({ viewPermission: n })), l = o.findComponentByType(s.components.DomContainer);
3021
+ return l && M.appendChild(l.domElement), H = o, {
3022
+ dxfSystem: o,
3023
+ getFileAll: () => Lt(o)
3021
3024
  };
3022
3025
  }
3023
3026
  async function Lt(M = H) {
3024
- const t = M.findComponentByName("WhiteModel"), e = new File([await M.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([M.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([M.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), l = new File([JSON.stringify(M.Dxf.originalData)], "json.json", { type: "application/json" });
3027
+ const t = M.findComponentByName("WhiteModel"), e = new File([await M.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([M.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([M.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = 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" }), l = new File([JSON.stringify(M.Dxf.originalData)], "json.json", { type: "application/json" });
3025
3028
  return {
3026
3029
  dxf: n,
3027
3030
  obj: s,
3028
- glb: o,
3029
- gltf: r,
3031
+ glb: r,
3032
+ gltf: o,
3030
3033
  json: l,
3031
3034
  jpg: e,
3032
3035
  correctionDxf: i