build-dxf 0.0.34 → 0.0.36

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,16 +1,16 @@
1
1
  import * as z from "three";
2
- import { EventDispatcher as Ge, Color as ze, Matrix4 as ve, Vector3 as ce, Quaternion as _e, BufferAttribute as te, REVISION as qe, CompressedTexture as de, Source as je, NoColorSpace as Ye, MathUtils as ye, RGBAFormat as ke, ImageUtils as Xe, DoubleSide as Ve, PropertyBinding as le, InterpolateDiscrete as We, Scene as Se, SRGBColorSpace as He, NearestFilter as Je, NearestMipmapNearestFilter as Ke, NearestMipmapLinearFilter as $e, LinearFilter as Ze, LinearMipmapNearestFilter as Qe, LinearMipmapLinearFilter as et, ClampToEdgeWrapping as tt, RepeatWrapping as nt, MirroredRepeatWrapping as st, InterpolateLinear as it } from "three";
3
- import Le from "clipper-lib";
4
- import ae from "dxf-writer";
5
- import { OBJExporter as rt } from "three/examples/jsm/exporters/OBJExporter.js";
6
- function me() {
2
+ import { EventDispatcher as Oe, Color as Fe, Matrix4 as Ie, Vector3 as ie, Quaternion as Ue, BufferAttribute as Z, REVISION as Ge, CompressedTexture as le, Source as ze, NoColorSpace as qe, MathUtils as fe, RGBAFormat as _e, ImageUtils as je, DoubleSide as Ye, PropertyBinding as re, InterpolateDiscrete as ke, Scene as ge, SRGBColorSpace as Xe, NearestFilter as Ve, NearestMipmapNearestFilter as We, NearestMipmapLinearFilter as He, LinearFilter as Je, LinearMipmapNearestFilter as $e, LinearMipmapLinearFilter as Ke, ClampToEdgeWrapping as Ze, RepeatWrapping as Qe, MirroredRepeatWrapping as et, InterpolateLinear as tt } from "three";
3
+ import we from "clipper-lib";
4
+ import se from "dxf-writer";
5
+ import { OBJExporter as nt } from "three/examples/jsm/exporters/OBJExporter.js";
6
+ function pe() {
7
7
  return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(f) {
8
8
  var e = Math.random() * 16 | 0, t = f == "x" ? e : e & 3 | 8;
9
9
  return t.toString(16);
10
10
  });
11
11
  }
12
- class Ne extends Ge {
13
- uuid = me();
12
+ class Pe extends Oe {
13
+ uuid = pe();
14
14
  addEventListener(e, t, n) {
15
15
  const { once: s = !1 } = n ?? {}, i = (o) => {
16
16
  t(o), s && r();
@@ -30,7 +30,7 @@ class Ne extends Ge {
30
30
  t && (t.forEach((n) => n()), this.eventRecordStack.delete(e));
31
31
  }
32
32
  }
33
- class ne extends Ne {
33
+ class Q extends Pe {
34
34
  parent;
35
35
  destroyed = !1;
36
36
  constructor(...e) {
@@ -48,7 +48,7 @@ class ne extends Ne {
48
48
  this.destroyed = !0;
49
49
  }
50
50
  }
51
- class ot extends Ne {
51
+ class st extends Pe {
52
52
  static EventType = {
53
53
  ADD_COMPONENT: "addComponent"
54
54
  };
@@ -71,7 +71,7 @@ class ot extends Ne {
71
71
  * @param component
72
72
  */
73
73
  removeComponent(e) {
74
- if (e instanceof ne) {
74
+ if (e instanceof Q) {
75
75
  const t = this.components.indexOf(e);
76
76
  t > -1 && (this.components.splice(t, 1), this.dispatchEvent({
77
77
  type: "removeComponent",
@@ -123,10 +123,10 @@ class j {
123
123
  maxY = 0;
124
124
  get points() {
125
125
  return [
126
- new g(this.minX, this.minY),
127
- new g(this.maxX, this.minY),
128
- new g(this.maxX, this.maxY),
129
- new g(this.minX, this.maxY)
126
+ new w(this.minX, this.minY),
127
+ new w(this.maxX, this.minY),
128
+ new w(this.maxX, this.maxY),
129
+ new w(this.minX, this.maxY)
130
130
  ];
131
131
  }
132
132
  get width() {
@@ -136,7 +136,7 @@ class j {
136
136
  return this.maxY - this.minY;
137
137
  }
138
138
  get center() {
139
- return new g(
139
+ return new w(
140
140
  this.minX + (this.maxX - this.minX) * 0.5,
141
141
  this.minY + (this.maxY - this.minY) * 0.5
142
142
  );
@@ -167,13 +167,13 @@ class j {
167
167
  return this.minX <= t.x && t.x <= this.maxX && this.minY <= t.y && t.y <= this.maxY;
168
168
  let r = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY;
169
169
  if (s !== 0) {
170
- const a = (this.minX - t.x) / s, l = (this.maxX - t.x) / s;
171
- r = Math.max(r, Math.min(a, l)), o = Math.min(o, Math.max(a, l));
170
+ const a = (this.minX - t.x) / s, c = (this.maxX - t.x) / s;
171
+ r = Math.max(r, Math.min(a, c)), o = Math.min(o, Math.max(a, c));
172
172
  } else if (t.x < this.minX || t.x > this.maxX)
173
173
  return !1;
174
174
  if (i !== 0) {
175
- const a = (this.minY - t.y) / i, l = (this.maxY - t.y) / i;
176
- r = Math.max(r, Math.min(a, l)), o = Math.min(o, Math.max(a, l));
175
+ const a = (this.minY - t.y) / i, c = (this.maxY - t.y) / i;
176
+ r = Math.max(r, Math.min(a, c)), o = Math.min(o, Math.max(a, c));
177
177
  } else if (t.y < this.minY || t.y > this.maxY)
178
178
  return !1;
179
179
  return r <= o && r <= 1 && o >= 0;
@@ -193,43 +193,43 @@ class j {
193
193
  intersectRectangle(e) {
194
194
  const t = e.points;
195
195
  let n = t[0].x, s = t[0].y, i = t[0].x, r = t[0].y;
196
- for (let l = 1; l < 4; l++) {
197
- const c = t[l];
198
- c.x < n && (n = c.x), c.y < s && (s = c.y), c.x > i && (i = c.x), c.y > r && (r = c.y);
196
+ for (let c = 1; c < 4; c++) {
197
+ const l = t[c];
198
+ l.x < n && (n = l.x), l.y < s && (s = l.y), l.x > i && (i = l.x), l.y > r && (r = l.y);
199
199
  }
200
200
  if (this.maxX < n || this.minX > i || this.maxY < s || this.minY > r)
201
201
  return !1;
202
202
  const o = this.points;
203
- for (let l = 0; l < 4; l++) {
204
- const c = o[l], h = o[(l + 1) % 4];
203
+ for (let c = 0; c < 4; c++) {
204
+ const l = o[c], h = o[(c + 1) % 4];
205
205
  for (let d = 0; d < 4; d++) {
206
- const u = t[d], p = t[(d + 1) % 4], y = (h.x - c.x) * (u.y - c.y) - (h.y - c.y) * (u.x - c.x), x = (h.x - c.x) * (p.y - c.y) - (h.y - c.y) * (p.x - c.x), S = (p.x - u.x) * (c.y - u.y) - (p.y - u.y) * (c.x - u.x), T = (p.x - u.x) * (h.y - u.y) - (p.y - u.y) * (h.x - u.x);
207
- if (y * x < 0 && S * T < 0 || y === 0 && Math.min(c.x, h.x) <= u.x && u.x <= Math.max(c.x, h.x) && Math.min(c.y, h.y) <= u.y && u.y <= Math.max(c.y, h.y) || x === 0 && Math.min(c.x, h.x) <= p.x && p.x <= Math.max(c.x, h.x) && Math.min(c.y, h.y) <= p.y && p.y <= Math.max(c.y, h.y) || S === 0 && Math.min(u.x, p.x) <= c.x && c.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= c.y && c.y <= Math.max(u.y, p.y) || T === 0 && Math.min(u.x, p.x) <= h.x && h.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= h.y && h.y <= Math.max(u.y, p.y))
206
+ const u = t[d], p = t[(d + 1) % 4], x = (h.x - l.x) * (u.y - l.y) - (h.y - l.y) * (u.x - l.x), y = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), m = (p.x - u.x) * (l.y - u.y) - (p.y - u.y) * (l.x - u.x), M = (p.x - u.x) * (h.y - u.y) - (p.y - u.y) * (h.x - u.x);
207
+ if (x * y < 0 && m * M < 0 || x === 0 && Math.min(l.x, h.x) <= u.x && u.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= u.y && u.y <= Math.max(l.y, h.y) || y === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || m === 0 && Math.min(u.x, p.x) <= l.x && l.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= l.y && l.y <= Math.max(u.y, p.y) || M === 0 && Math.min(u.x, p.x) <= h.x && h.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= h.y && h.y <= Math.max(u.y, p.y))
208
208
  return !0;
209
209
  }
210
210
  }
211
- for (let l = 0; l < 4; l++) {
212
- const c = t[l];
213
- if (c.x >= this.minX && c.x <= this.maxX && c.y >= this.minY && c.y <= this.maxY)
211
+ for (let c = 0; c < 4; c++) {
212
+ const l = t[c];
213
+ if (l.x >= this.minX && l.x <= this.maxX && l.y >= this.minY && l.y <= this.maxY)
214
214
  return !0;
215
215
  }
216
- const a = (l) => {
217
- let c = 0;
216
+ const a = (c) => {
217
+ let l = 0;
218
218
  for (let h = 0; h < 4; h++) {
219
- const d = t[h], u = t[(h + 1) % 4], p = (u.x - d.x) * (l.y - d.y) - (u.y - d.y) * (l.x - d.x);
219
+ const d = t[h], u = t[(h + 1) % 4], p = (u.x - d.x) * (c.y - d.y) - (u.y - d.y) * (c.x - d.x);
220
220
  if (p === 0) {
221
- const y = Math.abs(u.x - d.x) > 1e-10 ? u.x - d.x : u.y - d.y, x = y ? (l.x - d.x) / y : 0;
222
- if (x >= 0 && x <= 1) return !0;
221
+ const x = Math.abs(u.x - d.x) > 1e-10 ? u.x - d.x : u.y - d.y, y = x ? (c.x - d.x) / x : 0;
222
+ if (y >= 0 && y <= 1) return !0;
223
223
  } else {
224
- const y = p > 0 ? 1 : -1;
225
- if (c === 0) c = y;
226
- else if (c !== y) return !1;
224
+ const x = p > 0 ? 1 : -1;
225
+ if (l === 0) l = x;
226
+ else if (l !== x) return !1;
227
227
  }
228
228
  }
229
229
  return !0;
230
230
  };
231
- for (let l = 0; l < 4; l++)
232
- if (a(o[l])) return !0;
231
+ for (let c = 0; c < 4; c++)
232
+ if (a(o[c])) return !0;
233
233
  return !1;
234
234
  }
235
235
  /**
@@ -336,7 +336,136 @@ class j {
336
336
  );
337
337
  }
338
338
  }
339
- class ue {
339
+ class oe {
340
+ map = /* @__PURE__ */ new Map();
341
+ targetMap = /* @__PURE__ */ new Map();
342
+ gridSize;
343
+ constructor(e = 2) {
344
+ this.gridSize = e;
345
+ }
346
+ /**
347
+ * 插入
348
+ * @param point
349
+ * @param userData
350
+ */
351
+ insert(e, t) {
352
+ if (!e || isNaN(e.x) || isNaN(e.y))
353
+ throw new Error("无效的点坐标");
354
+ this.targetMap.has(e) && this.remove(e);
355
+ const n = this.getGridId(e);
356
+ this.map.has(n) || this.map.set(n, /* @__PURE__ */ new Set());
357
+ const s = this.map.get(n), i = { point: e, userData: t };
358
+ s.add(i), e.userData.pointVirtualGrid = { set: s, target: i }, this.targetMap.set(e, { set: s, target: i });
359
+ }
360
+ /**
361
+ * 批量加入
362
+ * @param points
363
+ */
364
+ insertBatch(e) {
365
+ for (const { point: t, userData: n } of e)
366
+ this.insert(t, n);
367
+ }
368
+ /** 移除点
369
+ * @param point
370
+ */
371
+ remove(e) {
372
+ if (this.targetMap.has(e)) {
373
+ const { target: t, set: n } = this.targetMap.get(e);
374
+ n && (n.delete(t), delete e?.userData?.pointVirtualGridMap, this.targetMap.delete(e));
375
+ }
376
+ }
377
+ /**
378
+ * 获取通过坐标,获取唯一网格索引
379
+ * @param point
380
+ * @returns
381
+ */
382
+ getGridId(e) {
383
+ const t = Math.ceil(e.x / this.gridSize), n = Math.ceil(e.y / this.gridSize);
384
+ return `${t}.${n}`;
385
+ }
386
+ /**
387
+ *
388
+ * @param gridId
389
+ * @returns
390
+ */
391
+ decodeGridId(e) {
392
+ const [t, n] = e.split(".").map(Number);
393
+ return new w(t, n);
394
+ }
395
+ /**
396
+ * 查询与矩形相交的点
397
+ * @param rectangle 矩形
398
+ * @returns 相交的节点数组
399
+ */
400
+ queryRect(e) {
401
+ const t = e.toBox(), n = Math.ceil(t.minX / this.gridSize), s = Math.ceil(t.maxX / this.gridSize), i = Math.ceil(t.minY / this.gridSize), r = Math.ceil(t.maxY / this.gridSize);
402
+ for (let o = n; o <= s; o++)
403
+ for (let a = i; a <= r; a++) {
404
+ const c = `${o}.${a}`;
405
+ if (!this.map.has(c)) continue;
406
+ this.map.get(c)?.forEach((h) => {
407
+ e.containsPoint(h.point);
408
+ });
409
+ }
410
+ }
411
+ /**
412
+ * 查询与圆形区域相交的点
413
+ * @param pos 圆心
414
+ * @param radius 半径
415
+ * @returns 相交的节点数组
416
+ */
417
+ queryCircle(e, t) {
418
+ const n = new j(e.x - t, e.x + t, e.y - t, e.y + t), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
419
+ for (let c = s; c <= i; c++)
420
+ for (let l = r; l <= o; l++) {
421
+ const h = `${c}.${l}`;
422
+ if (!this.map.has(h)) continue;
423
+ this.map.get(h)?.forEach((u) => {
424
+ e.distance(u.point) <= t && a.push(u);
425
+ });
426
+ }
427
+ return a;
428
+ }
429
+ /**
430
+ * 查询与包围盒相交的点
431
+ * @param box2 包围盒
432
+ * @returns 相交的节点数组
433
+ */
434
+ queryBox(e) {
435
+ const t = Math.ceil(e.minX / this.gridSize), n = Math.ceil(e.maxX / this.gridSize), s = Math.ceil(e.minY / this.gridSize), i = Math.ceil(e.maxY / this.gridSize), r = [];
436
+ for (let o = t; o <= n; o++)
437
+ for (let a = s; a <= i; a++) {
438
+ const c = `${o}.${a}`;
439
+ if (!this.map.has(c)) continue;
440
+ this.map.get(c)?.forEach((h) => {
441
+ e.containsPoint(h.point) && r.push(h);
442
+ });
443
+ }
444
+ return r;
445
+ }
446
+ /**
447
+ * 查找相同点
448
+ * @param point
449
+ */
450
+ queryPoint(e) {
451
+ const t = this.getGridId(e), n = [];
452
+ return this.map.has(t) && this.map.get(t)?.forEach((i) => {
453
+ e.equal(i.point) && n.push(i);
454
+ }), n;
455
+ }
456
+ /**
457
+ * 查找点自己
458
+ * @param point
459
+ */
460
+ queryPointSelf(e) {
461
+ if (this.targetMap.has(e)) {
462
+ const { target: t } = this.targetMap.get(e);
463
+ return t;
464
+ }
465
+ return null;
466
+ }
467
+ }
468
+ class ce {
340
469
  points;
341
470
  get p0() {
342
471
  return this.points[0];
@@ -359,7 +488,7 @@ class ue {
359
488
  path2D(e) {
360
489
  return this.points.flatMap((t, n) => {
361
490
  const s = this.points[(n + 1) % this.points.length];
362
- return e && e(new g(t.x, t.y), new g(s.x, s.y)), [t.x, t.y, s.x, s.y];
491
+ return e && e(new w(t.x, t.y), new w(s.x, s.y)), [t.x, t.y, s.x, s.y];
363
492
  });
364
493
  }
365
494
  createGeometry() {
@@ -387,14 +516,14 @@ class ue {
387
516
  throw new Error("LineSegment must have exactly 2 points");
388
517
  const [t, n] = e.points, s = n.x - t.x, i = n.y - t.y;
389
518
  for (let r = 0; r < 4; r++) {
390
- const o = this.points[r], a = this.points[(r + 1) % 4], l = a.x - o.x, c = a.y - o.y, h = s * c - i * l;
519
+ const o = this.points[r], a = this.points[(r + 1) % 4], c = a.x - o.x, l = a.y - o.y, h = s * l - i * c;
391
520
  if (h === 0) {
392
- if ((t.x - o.x) * c - (t.y - o.y) * l !== 0) continue;
393
- const u = l * l + c * c, p = ((t.x - o.x) * l + (t.y - o.y) * c) / u, y = ((n.x - o.x) * l + (n.y - o.y) * c) / u;
394
- if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
521
+ if ((t.x - o.x) * l - (t.y - o.y) * c !== 0) continue;
522
+ const u = c * c + l * l, p = ((t.x - o.x) * c + (t.y - o.y) * l) / u, x = ((n.x - o.x) * c + (n.y - o.y) * l) / u;
523
+ if (Math.max(p, x) >= 0 && Math.min(p, x) <= 1)
395
524
  return !0;
396
525
  } else {
397
- const d = ((o.x - t.x) * c - (o.y - t.y) * l) / h, u = ((o.x - t.x) * i - (o.y - t.y) * s) / h;
526
+ const d = ((o.x - t.x) * l - (o.y - t.y) * c) / h, u = ((o.x - t.x) * i - (o.y - t.y) * s) / h;
398
527
  if (d >= 0 && d <= 1 && u >= 0 && u <= 1)
399
528
  return !0;
400
529
  }
@@ -412,12 +541,12 @@ class ue {
412
541
  const t = (n) => {
413
542
  let s = 0;
414
543
  for (let i = 0; i < 4; i++) {
415
- const r = this.points[i], o = this.points[(i + 1) % 4], a = { x: o.x - r.x, y: o.y - r.y }, l = { x: n.x - r.x, y: n.y - r.y }, c = a.x * l.y - a.y * l.x;
416
- if (c === 0) {
544
+ const r = this.points[i], o = this.points[(i + 1) % 4], a = { x: o.x - r.x, y: o.y - r.y }, c = { x: n.x - r.x, y: n.y - r.y }, l = a.x * c.y - a.y * c.x;
545
+ if (l === 0) {
417
546
  const h = a.x !== 0 ? (n.x - r.x) / a.x : (n.y - r.y) / a.y;
418
547
  if (h >= 0 && h <= 1) return !0;
419
548
  } else {
420
- const h = c > 0 ? 1 : -1;
549
+ const h = l > 0 ? 1 : -1;
421
550
  if (s === 0 && (s = h), s !== h) return !1;
422
551
  }
423
552
  }
@@ -486,21 +615,21 @@ class ue {
486
615
  * @returns
487
616
  */
488
617
  static fromByLineSegment(e, t = 0.1, n = !1, s = 0.5) {
489
- const i = e.points[0], r = e.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(t * s) : g.zero(), l = n ? i.direction(r).mutiplyScalar(t * s) : g.zero(), c = o.x * t * 0.5, h = o.y * t * 0.5;
490
- return new ue([
491
- new g(i.x + c, i.y + h).add(l),
492
- new g(r.x + c, r.y + h).add(a),
493
- new g(r.x - c, r.y - h).add(a),
494
- new g(i.x - c, i.y - h).add(l)
618
+ const i = e.points[0], r = e.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(t * s) : w.zero(), c = n ? i.direction(r).mutiplyScalar(t * s) : w.zero(), l = o.x * t * 0.5, h = o.y * t * 0.5;
619
+ return new ce([
620
+ new w(i.x + l, i.y + h).add(c),
621
+ new w(r.x + l, r.y + h).add(a),
622
+ new w(r.x - l, r.y - h).add(a),
623
+ new w(i.x - l, i.y - h).add(c)
495
624
  ]);
496
625
  }
497
626
  }
498
- class N {
499
- points = [new g(), new g()];
627
+ class R {
628
+ points = [new w(), new w()];
500
629
  userData = {};
501
630
  // line: any
502
631
  get center() {
503
- return new g(
632
+ return new w(
504
633
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
505
634
  this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
506
635
  );
@@ -511,7 +640,7 @@ class N {
511
640
  get end() {
512
641
  return this.points[1];
513
642
  }
514
- constructor(e = new g(), t = new g()) {
643
+ constructor(e = new w(), t = new w()) {
515
644
  this.points = [e, t];
516
645
  }
517
646
  set(e, t) {
@@ -597,15 +726,15 @@ class N {
597
726
  * @returns {Rectangle}
598
727
  */
599
728
  expandToRectangle(e = 0.1, t = "all") {
600
- const n = this.start, s = this.end, i = s.normal(n), r = t === "bothSides" ? g.zero() : s.direction(n).mutiplyScalar(e * 0.5), o = t === "bothSides" ? g.zero() : n.direction(s).mutiplyScalar(e * 0.5), a = i.x * e * 0.5, l = i.y * e * 0.5, c = [
729
+ const n = this.start, s = this.end, i = s.normal(n), r = t === "bothSides" ? w.zero() : s.direction(n).mutiplyScalar(e * 0.5), o = t === "bothSides" ? w.zero() : n.direction(s).mutiplyScalar(e * 0.5), a = i.x * e * 0.5, c = i.y * e * 0.5, l = [
601
730
  // 第一条线
602
- new g(n.x + a, n.y + l).add(o),
603
- new g(s.x + a, s.y + l).add(r),
731
+ new w(n.x + a, n.y + c).add(o),
732
+ new w(s.x + a, s.y + c).add(r),
604
733
  // 第二条线
605
- new g(n.x - a, n.y - l).add(o),
606
- new g(s.x - a, s.y - l).add(r)
734
+ new w(n.x - a, n.y - c).add(o),
735
+ new w(s.x - a, s.y - c).add(r)
607
736
  ];
608
- return new ue([0, 1, 3, 2].map((h) => c[h]));
737
+ return new ce([0, 1, 3, 2].map((h) => l[h]));
609
738
  }
610
739
  /**
611
740
  * 计算线段的长度
@@ -642,24 +771,24 @@ class N {
642
771
  projectLineSegment(e) {
643
772
  if (e.points.length !== 2 || this.points.length !== 2)
644
773
  throw new Error("每条线段必须由两个点定义");
645
- const [t, n] = e.points, [s, i] = this.points, r = new g(i.x - s.x, i.y - s.y);
774
+ const [t, n] = e.points, [s, i] = this.points, r = new w(i.x - s.x, i.y - s.y);
646
775
  if (r.x === 0 && r.y === 0)
647
776
  throw new Error("投影目标线段的两个点不能重合");
648
777
  const o = (p) => {
649
- const y = new g(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, T = (y.x * r.x + y.y * r.y) / x, G = s.x + T * r.x, E = s.y + T * r.y;
650
- return new g(G, E);
778
+ const x = new w(p.x - s.x, p.y - s.y), y = r.x * r.x + r.y * r.y, M = (x.x * r.x + x.y * r.y) / y, T = s.x + M * r.x, g = s.y + M * r.y;
779
+ return new w(T, g);
651
780
  };
652
- let a = o(t), l = o(n);
653
- const c = (p) => {
654
- const y = new g(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
655
- return (y.x * r.x + y.y * r.y) / x;
781
+ let a = o(t), c = o(n);
782
+ const l = (p) => {
783
+ const x = new w(p.x - s.x, p.y - s.y), y = r.x * r.x + r.y * r.y;
784
+ return (x.x * r.x + x.y * r.y) / y;
656
785
  };
657
- let h = c(a), d = c(l);
786
+ let h = l(a), d = l(c);
658
787
  const u = (p) => {
659
- const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, S = s.y + y * r.y;
660
- return new g(x, S);
788
+ const x = Math.max(0, Math.min(1, p)), y = s.x + x * r.x, m = s.y + x * r.y;
789
+ return new w(y, m);
661
790
  };
662
- return (h < 0 || h > 1) && (a = u(h)), (d < 0 || d > 1) && (l = u(d)), a.x === l.x && a.y === l.y ? new N(a, a) : new N(a, l);
791
+ return (h < 0 || h > 1) && (a = u(h)), (d < 0 || d > 1) && (c = u(d)), a.x === c.x && a.y === c.y ? new R(a, a) : new R(a, c);
663
792
  }
664
793
  /**
665
794
  * 计算一条线段在另一条直线上的投影
@@ -668,19 +797,19 @@ class N {
668
797
  * @returns 投影并裁剪后的线段
669
798
  */
670
799
  projectPoint(e, t = !0) {
671
- const [n, s] = this.points, i = new g(s.x - n.x, s.y - n.y);
800
+ const [n, s] = this.points, i = new w(s.x - n.x, s.y - n.y);
672
801
  if (i.x === 0 && i.y === 0)
673
802
  throw new Error("投影目标线段的两个点不能重合");
674
- let o = ((c) => {
675
- const h = new g(c.x - n.x, c.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, y = n.x + p * i.x, x = n.y + p * i.y;
676
- return new g(y, x);
803
+ let o = ((l) => {
804
+ const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, x = n.x + p * i.x, y = n.y + p * i.y;
805
+ return new w(x, y);
677
806
  })(e);
678
807
  if (!t) return o;
679
- let l = ((c) => {
680
- const h = new g(c.x - n.x, c.y - n.y), d = i.x * i.x + i.y * i.y;
808
+ let c = ((l) => {
809
+ const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y;
681
810
  return (h.x * i.x + h.y * i.y) / d;
682
811
  })(o);
683
- return l < 0 || l > 1 ? null : o;
812
+ return c < 0 || c > 1 ? null : o;
684
813
  }
685
814
  /**
686
815
  * 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
@@ -690,14 +819,14 @@ class N {
690
819
  */
691
820
  intersectLineSegment(e, t = !0) {
692
821
  const n = this.start, s = this.end, i = e.start, r = e.end;
693
- function o(u, p, y) {
694
- return (p.x - u.x) * (y.y - u.y) - (p.y - u.y) * (y.x - u.x);
822
+ function o(u, p, x) {
823
+ return (p.x - u.x) * (x.y - u.y) - (p.y - u.y) * (x.x - u.x);
695
824
  }
696
- function a(u, p, y) {
697
- return Math.min(p.x, y.x) - 1e-10 <= u.x && u.x <= Math.max(p.x, y.x) + 1e-10 && Math.min(p.y, y.y) - 1e-10 <= u.y && u.y <= Math.max(p.y, y.y) + 1e-10;
825
+ function a(u, p, x) {
826
+ return Math.min(p.x, x.x) - 1e-10 <= u.x && u.x <= Math.max(p.x, x.x) + 1e-10 && Math.min(p.y, x.y) - 1e-10 <= u.y && u.y <= Math.max(p.y, x.y) + 1e-10;
698
827
  }
699
- const l = o(n, s, i), c = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
700
- return !!(l * c < 0 && h * d < 0 || t && (Math.abs(l) < 1e-10 && a(i, n, s) || Math.abs(c) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
828
+ const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
829
+ return !!(c * l < 0 && h * d < 0 || t && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
701
830
  }
702
831
  /**
703
832
  * 判断一个点是否在线段上(含端点)
@@ -717,8 +846,8 @@ class N {
717
846
  const t = this.start, n = this.end, s = e.start, i = e.end, r = (t.x - n.x) * (s.y - i.y) - (t.y - n.y) * (s.x - i.x);
718
847
  if (Math.abs(r) < 1e-10)
719
848
  return null;
720
- const o = ((t.x - s.x) * (s.y - i.y) - (t.y - s.y) * (s.x - i.x)) / r, a = t.x + o * (n.x - t.x), l = t.y + o * (n.y - t.y);
721
- return new g(a, l);
849
+ const o = ((t.x - s.x) * (s.y - i.y) - (t.y - s.y) * (s.x - i.x)) / r, a = t.x + o * (n.x - t.x), c = t.y + o * (n.y - t.y);
850
+ return new w(a, c);
722
851
  }
723
852
  /**
724
853
  * 获取两条线段夹角
@@ -784,17 +913,17 @@ class N {
784
913
  if (this.intersectLineSegment(e))
785
914
  return 0;
786
915
  const t = (n, s) => {
787
- const i = s.start, r = s.end, o = r.x - i.x, a = r.y - i.y, l = o * o + a * a;
788
- if (l < 1e-10)
916
+ const i = s.start, r = s.end, o = r.x - i.x, a = r.y - i.y, c = o * o + a * a;
917
+ if (c < 1e-10)
789
918
  return n.distance(i);
790
- const c = ((n.x - i.x) * o + (n.y - i.y) * a) / l;
791
- if (c < 0)
919
+ const l = ((n.x - i.x) * o + (n.y - i.y) * a) / c;
920
+ if (l < 0)
792
921
  return n.distance(i);
793
- if (c > 1)
922
+ if (l > 1)
794
923
  return n.distance(r);
795
924
  {
796
- const h = i.x + c * o, d = i.y + c * a;
797
- return n.distance(new g(h, d));
925
+ const h = i.x + l * o, d = i.y + l * a;
926
+ return n.distance(new w(h, d));
798
927
  }
799
928
  };
800
929
  return Math.min(
@@ -810,14 +939,14 @@ class N {
810
939
  * @returns
811
940
  */
812
941
  areLinesCoincident(e) {
813
- const t = this.start, n = this.end, s = e.start, i = e.end, r = (n.y - t.y) / (n.x - t.x), o = t.y - r * t.x, a = (i.y - s.y) / (i.x - s.x), l = s.y - a * s.x;
814
- return !isFinite(r) && !isFinite(a) ? t.x === s.x && n.x === s.x : Math.abs(r - a) < 1e-3 && Math.abs(o - l) < 1e-3;
942
+ const t = this.start, n = this.end, s = e.start, i = e.end, r = (n.y - t.y) / (n.x - t.x), o = t.y - r * t.x, a = (i.y - s.y) / (i.x - s.x), c = s.y - a * s.x;
943
+ return !isFinite(r) && !isFinite(a) ? t.x === s.x && n.x === s.x : Math.abs(r - a) < 1e-3 && Math.abs(o - c) < 1e-3;
815
944
  }
816
945
  /** 克隆
817
946
  * @returns
818
947
  */
819
948
  clone() {
820
- const e = new N(
949
+ const e = new R(
821
950
  this.points[0].clone(),
822
951
  this.points[1].clone()
823
952
  );
@@ -836,8 +965,74 @@ class N {
836
965
  }
837
966
  return s;
838
967
  }
968
+ /** 对平行并且共线线段分组
969
+ * @param selectLines
970
+ */
971
+ static groupBySamePointAndParallel(e) {
972
+ const t = new oe();
973
+ e.forEach((r) => r.points.forEach((o) => t.insert(o, r)));
974
+ const n = /* @__PURE__ */ new Set();
975
+ function s(r, o, a) {
976
+ if (o.has(r)) return;
977
+ const c = t.queryPoint(r.start).filter((u) => u.userData !== r && r.parallel(u.userData, 0.1)), l = t.queryPoint(r.end).filter((u) => u.userData !== r && r.parallel(u.userData, 0.1)), h = c[0]?.userData, d = l[0]?.userData;
978
+ return h && !a.has(h) && (a.add(h), s(h, o, a)), d && !a.has(d) && (a.add(d), s(d, o, a)), o.add(r), a;
979
+ }
980
+ const i = [];
981
+ for (let r = 0; r < e.length; r++) {
982
+ const o = e[r];
983
+ if (n.has(o)) continue;
984
+ const a = s(o, n, /* @__PURE__ */ new Set([o]));
985
+ a && i.push([...a]);
986
+ }
987
+ return i;
988
+ }
989
+ /** 合并平行线段
990
+ * @param lines
991
+ * @returns
992
+ */
993
+ static mergeLines(...e) {
994
+ if (e.length === 1) return e[0];
995
+ const t = [];
996
+ e.forEach((u) => {
997
+ t.push(u.start.clone(), u.end.clone());
998
+ });
999
+ const n = e[0].direction().normalize();
1000
+ let s = 1 / 0, i = -1 / 0, r = 0, o = 0;
1001
+ t.forEach((u) => {
1002
+ const p = u.x * n.x + u.y * n.y;
1003
+ s = Math.min(s, p), i = Math.max(i, p), r += u.x, o += u.y;
1004
+ });
1005
+ const a = new w(r / t.length, o / t.length), c = a.x * n.x + a.y * n.y, l = new w(a.x + (s - c) * n.x, a.y + (s - c) * n.y), h = new w(a.x + (i - c) * n.x, a.y + (i - c) * n.y), d = new R(l, h);
1006
+ return e.forEach((u) => u.userData.fittedLine = d), d;
1007
+ }
1008
+ /** 合并满足平行的线段
1009
+ * @param selectLines
1010
+ */
1011
+ static autoMergeLines(e) {
1012
+ const t = this.groupBySamePointAndParallel(e), n = [], s = [];
1013
+ return t.forEach((i) => {
1014
+ const r = this.mergeLines(...i);
1015
+ r && (n.push(r), s.push(...i));
1016
+ }), e.push(...n), {
1017
+ lines: e.filter((i) => !s.includes(i)),
1018
+ newLines: n,
1019
+ deleteLines: s
1020
+ };
1021
+ }
1022
+ /** 去重
1023
+ * @param lines
1024
+ * @returns
1025
+ */
1026
+ static deduplication(e) {
1027
+ const t = /* @__PURE__ */ new Set(), n = [];
1028
+ for (const s of e) {
1029
+ const i = s.start, r = s.end, o = `${i.x.toFixed(10)}_${i.y.toFixed(10)}`, a = `${r.x.toFixed(10)}_${r.y.toFixed(10)}`, c = o < a ? `${o}_${a}` : `${a}_${o}`;
1030
+ t.has(c) || (t.add(c), n.push(s));
1031
+ }
1032
+ return n;
1033
+ }
839
1034
  }
840
- class g {
1035
+ class w {
841
1036
  x;
842
1037
  y;
843
1038
  get X() {
@@ -954,7 +1149,7 @@ class g {
954
1149
  */
955
1150
  normal(e) {
956
1151
  const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n), i = -n / s, r = t / s;
957
- return new g(i, r);
1152
+ return new w(i, r);
958
1153
  }
959
1154
  /**
960
1155
  * 获取由传入的点到该点的单位方向向量
@@ -964,14 +1159,14 @@ class g {
964
1159
  */
965
1160
  direction(e) {
966
1161
  const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n);
967
- return s === 0 ? new g(0, 0) : new g(t / s, n / s);
1162
+ return s === 0 ? new w(0, 0) : new w(t / s, n / s);
968
1163
  }
969
1164
  /** 展开为线
970
1165
  * @param direction
971
1166
  * @param length
972
1167
  */
973
1168
  expandAsLine(e, t, n) {
974
- const s = new N(
1169
+ const s = new R(
975
1170
  this.clone(),
976
1171
  this.clone().add(e.clone().multiplyScalar(t))
977
1172
  );
@@ -1033,7 +1228,7 @@ class g {
1033
1228
  * @returns
1034
1229
  */
1035
1230
  clone() {
1036
- return new g(this.x, this.y);
1231
+ return new w(this.x, this.y);
1037
1232
  }
1038
1233
  /**
1039
1234
  * 克隆
@@ -1050,13 +1245,13 @@ class g {
1050
1245
  };
1051
1246
  }
1052
1247
  static from(e) {
1053
- return Array.isArray(e) ? new g(e[0], e[1]) : "x" in e && "y" in e ? new g(e.x, e.y) : "X" in e && "Y" in e ? new g(e.X, e.Y) : this.zero();
1248
+ return Array.isArray(e) ? new w(e[0], e[1]) : "x" in e && "y" in e ? new w(e.x, e.y) : "X" in e && "Y" in e ? new w(e.X, e.Y) : this.zero();
1054
1249
  }
1055
1250
  static zero() {
1056
- return new g(0, 0);
1251
+ return new w(0, 0);
1057
1252
  }
1058
1253
  }
1059
- async function se(f, e = !0) {
1254
+ async function ee(f, e = !0) {
1060
1255
  if (typeof global < "u" && typeof require < "u")
1061
1256
  return require(f);
1062
1257
  {
@@ -1067,7 +1262,7 @@ async function se(f, e = !0) {
1067
1262
  return e && (t = t.default), t;
1068
1263
  }
1069
1264
  }
1070
- class Z {
1265
+ class J {
1071
1266
  bounds;
1072
1267
  // 包围盒
1073
1268
  capacity;
@@ -1084,14 +1279,19 @@ class Z {
1084
1279
  // 存储的节点
1085
1280
  color = [Math.random(), Math.random(), Math.random()];
1086
1281
  // 颜色
1087
- constructor(e, t = 8, n = 10, s = 1) {
1088
- this.bounds = e, this.capacity = t, this.depth = s, this.maxDepth = n;
1282
+ targetMap;
1283
+ constructor(e, t = 8, n = 10, s = 1, i = /* @__PURE__ */ new Map()) {
1284
+ this.bounds = e, this.capacity = t, this.depth = s, this.maxDepth = n, this.targetMap = i;
1089
1285
  }
1090
1286
  /**
1091
1287
  * 插入线段节点
1092
1288
  * @param node 线段节点
1093
1289
  */
1094
1290
  insert(e) {
1291
+ if (e instanceof R) {
1292
+ this.insert({ line: e, userData: {} });
1293
+ return;
1294
+ }
1095
1295
  if (!this.isLeaf) {
1096
1296
  const t = this.getQuadrant(e.line);
1097
1297
  if (t !== -1) {
@@ -1099,13 +1299,13 @@ class Z {
1099
1299
  return;
1100
1300
  }
1101
1301
  }
1102
- if (this.nodes.push(e), e.parent = this, this.isLeaf && this.nodes.length > this.capacity && this.depth < this.maxDepth) {
1302
+ if (this.nodes.push(e), this.targetMap.set(e.line, e), e.parent = this, this.isLeaf && this.nodes.length > this.capacity && this.depth < this.maxDepth) {
1103
1303
  this.subdivide();
1104
1304
  const t = this.nodes;
1105
1305
  this.nodes = [];
1106
1306
  for (const n of t) {
1107
1307
  const s = this.getQuadrant(n.line);
1108
- s !== -1 ? this.children[s].insert(n) : (n.parent = this, this.nodes.push(n));
1308
+ s !== -1 ? this.children[s].insert(n) : (n.parent = this, this.nodes.push(n), this.targetMap.set(e.line, e));
1109
1309
  }
1110
1310
  }
1111
1311
  }
@@ -1113,8 +1313,18 @@ class Z {
1113
1313
  * @param node
1114
1314
  */
1115
1315
  remove(e) {
1316
+ if (e instanceof R) {
1317
+ e = this.targetMap.get(e), e && this.remove(e);
1318
+ return;
1319
+ }
1116
1320
  const t = e.parent?.nodes.indexOf(e);
1117
- t > -1 && e.parent?.nodes.splice(t, 1);
1321
+ t > -1 && (e.parent?.nodes.splice(t, 1), this.targetMap.delete(e.line));
1322
+ }
1323
+ /** 移除
1324
+ * @param node
1325
+ */
1326
+ update(e) {
1327
+ this.remove(e), this.insert(e);
1118
1328
  }
1119
1329
  /**
1120
1330
  * 获取线段所属的象限
@@ -1133,26 +1343,30 @@ class Z {
1133
1343
  if (!this.isLeaf) return;
1134
1344
  this.isLeaf = !1, this.children = [];
1135
1345
  const e = (this.bounds.minX + this.bounds.maxX) / 2, t = (this.bounds.minY + this.bounds.maxY) / 2;
1136
- this.children[0] = new Z(
1346
+ this.children[0] = new J(
1137
1347
  new j(this.bounds.minX, e, this.bounds.minY, t),
1138
1348
  this.capacity,
1139
1349
  this.maxDepth,
1140
- this.depth + 1
1141
- ), this.children[1] = new Z(
1350
+ this.depth + 1,
1351
+ this.targetMap
1352
+ ), this.children[1] = new J(
1142
1353
  new j(e, this.bounds.maxX, this.bounds.minY, t),
1143
1354
  this.capacity,
1144
1355
  this.maxDepth,
1145
- this.depth + 1
1146
- ), this.children[2] = new Z(
1356
+ this.depth + 1,
1357
+ this.targetMap
1358
+ ), this.children[2] = new J(
1147
1359
  new j(this.bounds.minX, e, t, this.bounds.maxY),
1148
1360
  this.capacity,
1149
1361
  this.maxDepth,
1150
- this.depth + 1
1151
- ), this.children[3] = new Z(
1362
+ this.depth + 1,
1363
+ this.targetMap
1364
+ ), this.children[3] = new J(
1152
1365
  new j(e, this.bounds.maxX, t, this.bounds.maxY),
1153
1366
  this.capacity,
1154
1367
  this.maxDepth,
1155
- this.depth + 1
1368
+ this.depth + 1,
1369
+ this.targetMap
1156
1370
  );
1157
1371
  }
1158
1372
  /**
@@ -1187,11 +1401,11 @@ class Z {
1187
1401
  if (!this.bounds.intersectBox(s))
1188
1402
  return n;
1189
1403
  for (const i of this.nodes) {
1190
- const [r, o] = i.line.points, a = o.x - r.x, l = o.y - r.y, c = a * a + l * l;
1191
- let h = ((e.x - r.x) * a + (e.y - r.y) * l) / c;
1404
+ const [r, o] = i.line.points, a = o.x - r.x, c = o.y - r.y, l = a * a + c * c;
1405
+ let h = ((e.x - r.x) * a + (e.y - r.y) * c) / l;
1192
1406
  h = Math.max(0, Math.min(1, h));
1193
- const d = r.x + h * a, u = r.y + h * l;
1194
- e.distance(new g(d, u)) <= t && n.push(i);
1407
+ const d = r.x + h * a, u = r.y + h * c;
1408
+ e.distance(new w(d, u)) <= t && n.push(i);
1195
1409
  }
1196
1410
  if (!this.isLeaf)
1197
1411
  for (const i of this.children)
@@ -1259,136 +1473,7 @@ class Z {
1259
1473
  })), e;
1260
1474
  }
1261
1475
  }
1262
- class ge {
1263
- map = /* @__PURE__ */ new Map();
1264
- targetMap = /* @__PURE__ */ new Map();
1265
- gridSize;
1266
- constructor(e = 2) {
1267
- this.gridSize = e;
1268
- }
1269
- /**
1270
- * 插入
1271
- * @param point
1272
- * @param userData
1273
- */
1274
- insert(e, t) {
1275
- if (!e || isNaN(e.x) || isNaN(e.y))
1276
- throw new Error("无效的点坐标");
1277
- this.targetMap.has(e) && this.remove(e);
1278
- const n = this.getGridId(e);
1279
- this.map.has(n) || this.map.set(n, /* @__PURE__ */ new Set());
1280
- const s = this.map.get(n), i = { point: e, userData: t };
1281
- s.add(i), e.userData.pointVirtualGrid = { set: s, target: i }, this.targetMap.set(e, { set: s, target: i });
1282
- }
1283
- /**
1284
- * 批量加入
1285
- * @param points
1286
- */
1287
- insertBatch(e) {
1288
- for (const { point: t, userData: n } of e)
1289
- this.insert(t, n);
1290
- }
1291
- /** 移除点
1292
- * @param point
1293
- */
1294
- remove(e) {
1295
- if (this.targetMap.has(e)) {
1296
- const { target: t, set: n } = this.targetMap.get(e);
1297
- n && (n.delete(t), delete e?.userData?.pointVirtualGridMap, this.targetMap.delete(e));
1298
- }
1299
- }
1300
- /**
1301
- * 获取通过坐标,获取唯一网格索引
1302
- * @param point
1303
- * @returns
1304
- */
1305
- getGridId(e) {
1306
- const t = Math.ceil(e.x / this.gridSize), n = Math.ceil(e.y / this.gridSize);
1307
- return `${t}.${n}`;
1308
- }
1309
- /**
1310
- *
1311
- * @param gridId
1312
- * @returns
1313
- */
1314
- decodeGridId(e) {
1315
- const [t, n] = e.split(".").map(Number);
1316
- return new g(t, n);
1317
- }
1318
- /**
1319
- * 查询与矩形相交的点
1320
- * @param rectangle 矩形
1321
- * @returns 相交的节点数组
1322
- */
1323
- queryRect(e) {
1324
- const t = e.toBox(), n = Math.ceil(t.minX / this.gridSize), s = Math.ceil(t.maxX / this.gridSize), i = Math.ceil(t.minY / this.gridSize), r = Math.ceil(t.maxY / this.gridSize);
1325
- for (let o = n; o <= s; o++)
1326
- for (let a = i; a <= r; a++) {
1327
- const l = `${o}.${a}`;
1328
- if (!this.map.has(l)) continue;
1329
- this.map.get(l)?.forEach((h) => {
1330
- e.containsPoint(h.point);
1331
- });
1332
- }
1333
- }
1334
- /**
1335
- * 查询与圆形区域相交的点
1336
- * @param pos 圆心
1337
- * @param radius 半径
1338
- * @returns 相交的节点数组
1339
- */
1340
- queryCircle(e, t) {
1341
- const n = new j(e.x - t, e.x + t, e.y - t, e.y + t), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
1342
- for (let l = s; l <= i; l++)
1343
- for (let c = r; c <= o; c++) {
1344
- const h = `${l}.${c}`;
1345
- if (!this.map.has(h)) continue;
1346
- this.map.get(h)?.forEach((u) => {
1347
- e.distance(u.point) <= t && a.push(u);
1348
- });
1349
- }
1350
- return a;
1351
- }
1352
- /**
1353
- * 查询与包围盒相交的点
1354
- * @param box2 包围盒
1355
- * @returns 相交的节点数组
1356
- */
1357
- queryBox(e) {
1358
- const t = Math.ceil(e.minX / this.gridSize), n = Math.ceil(e.maxX / this.gridSize), s = Math.ceil(e.minY / this.gridSize), i = Math.ceil(e.maxY / this.gridSize), r = [];
1359
- for (let o = t; o <= n; o++)
1360
- for (let a = s; a <= i; a++) {
1361
- const l = `${o}.${a}`;
1362
- if (!this.map.has(l)) continue;
1363
- this.map.get(l)?.forEach((h) => {
1364
- e.containsPoint(h.point) && r.push(h);
1365
- });
1366
- }
1367
- return r;
1368
- }
1369
- /**
1370
- * 查找相同点
1371
- * @param point
1372
- */
1373
- queryPoint(e) {
1374
- const t = this.getGridId(e), n = [];
1375
- return this.map.has(t) && this.map.get(t)?.forEach((i) => {
1376
- e.equal(i.point) && n.push(i);
1377
- }), n;
1378
- }
1379
- /**
1380
- * 查找点自己
1381
- * @param point
1382
- */
1383
- queryPointSelf(e) {
1384
- if (this.targetMap.has(e)) {
1385
- const { target: t } = this.targetMap.get(e);
1386
- return t;
1387
- }
1388
- return null;
1389
- }
1390
- }
1391
- const at = {
1476
+ const it = {
1392
1477
  Unitless: 1,
1393
1478
  // 无单位,1米 = 1(无单位)
1394
1479
  Inches: 39.37007874015748,
@@ -1432,19 +1517,19 @@ const at = {
1432
1517
  Parsecs: 3240779289666404e-32
1433
1518
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
1434
1519
  };
1435
- function Ee(f) {
1520
+ function Me(f) {
1436
1521
  const e = [];
1437
1522
  for (let t = 0; t < f.length; t++)
1438
- e.push(new N(
1523
+ e.push(new R(
1439
1524
  f[t].clone(),
1440
1525
  f[(t + 1) % f.length].clone()
1441
1526
  ));
1442
1527
  return e;
1443
1528
  }
1444
- function De(f) {
1529
+ function Se(f) {
1445
1530
  return f.flatMap((e, t) => (t === f.length - 1 && [...e.points, f[0].points[0]], [e.points[0]]));
1446
1531
  }
1447
- class $ extends ne {
1532
+ class W extends Q {
1448
1533
  static name = "Dxf";
1449
1534
  shortLine = 0.04;
1450
1535
  width = 0.04;
@@ -1490,21 +1575,21 @@ class $ extends ne {
1490
1575
  preprocessing(e, t = !1, n) {
1491
1576
  let s = [], i = -1;
1492
1577
  const r = [];
1493
- e.forEach(({ start: a, end: l, ...c }, h) => {
1494
- r.push(a.z ?? 0, l.z ?? 0);
1495
- const d = new N(
1496
- g.from(a),
1497
- g.from(l)
1578
+ e.forEach(({ start: a, end: c, ...l }, h) => {
1579
+ r.push(a.z ?? 0, c.z ?? 0);
1580
+ const d = new R(
1581
+ w.from(a),
1582
+ w.from(c)
1498
1583
  );
1499
- d.userData = c, s.push(d), c.isVerticalReferenceLine && (i = h);
1500
- }), this.originalZAverage = r.reduce((a, l) => a + l, 0) / r.length, i === -1 && (i = N.maxLengthLineIndex(s, (a) => !a.userData.insetionArr?.length));
1584
+ d.userData = l, s.push(d), l.isVerticalReferenceLine && (i = h);
1585
+ }), this.originalZAverage = r.reduce((a, c) => a + c, 0) / r.length, i === -1 && (i = R.maxLengthLineIndex(s, (a) => !a.userData.insetionArr?.length));
1501
1586
  const o = s[i];
1502
- return o.userData.isVerticalReferenceLine = !0, e[i].isVerticalReferenceLine = !0, t && (s = $.axisAlignmentCorrection.call(this, s, o, n), e = this.lineDataToOriginalData(s)), this.dispatchEvent({
1587
+ return o.userData.isVerticalReferenceLine = !0, e[i].isVerticalReferenceLine = !0, t && (s = W.axisAlignmentCorrection.call(this, s, o, n), e = this.lineDataToOriginalData(s)), this.dispatchEvent({
1503
1588
  type: "preprocessing",
1504
1589
  data: e,
1505
1590
  setData(a) {
1506
- s = a.map(({ start: l, end: c, ...h }) => {
1507
- const d = new N(g.from(l), g.from(c));
1591
+ s = a.map(({ start: c, end: l, ...h }) => {
1592
+ const d = new R(w.from(c), w.from(l));
1508
1593
  return d.userData = h, d;
1509
1594
  }), e = a;
1510
1595
  }
@@ -1521,10 +1606,10 @@ class $ extends ne {
1521
1606
  async set(e, t = this.width, n = this.scale, s = !1, i) {
1522
1607
  if (typeof e == "string")
1523
1608
  if (typeof global < "u") {
1524
- const { default: l } = await import(
1609
+ const { default: c } = await import(
1525
1610
  /* @vite-ignore */
1526
1611
  "fs"
1527
- ), c = l.readFileSync(e), h = JSON.parse(c.toString("utf-8"));
1612
+ ), l = c.readFileSync(e), h = JSON.parse(l.toString("utf-8"));
1528
1613
  return this.set(h, t, n, s);
1529
1614
  } else
1530
1615
  throw new Error("非node环境不允许使用路径");
@@ -1532,17 +1617,17 @@ class $ extends ne {
1532
1617
  const r = this.preprocessing(e, s, i);
1533
1618
  e = r.data, this.lineSegments = r.lineSegments, this.originalData = e;
1534
1619
  const o = [];
1535
- this.data = e.map(({ start: a, end: l, insetionArr: c, isDoor: h = !1 }, d) => {
1536
- o.push(a.z ?? 0, l.z ?? 0);
1620
+ this.data = e.map(({ start: a, end: c, insetionArr: l, isDoor: h = !1 }, d) => {
1621
+ o.push(a.z ?? 0, c.z ?? 0);
1537
1622
  const u = this.lineSegments[d];
1538
1623
  return [
1539
1624
  u.points[0],
1540
1625
  u.points[1],
1541
- (c ?? []).map((p) => p.index),
1626
+ (l ?? []).map((p) => p.index),
1542
1627
  h,
1543
1628
  d
1544
1629
  ];
1545
- }), this.originalZAverage = o.reduce((a, l) => a + l, 0) / o.length, this.computedOriginalSize(e, this.originalBox), this.dispatchEvent({
1630
+ }), this.originalZAverage = o.reduce((a, c) => a + c, 0) / o.length, this.computedOriginalSize(e, this.originalBox), this.dispatchEvent({
1546
1631
  type: "setDta",
1547
1632
  originalData: this.originalData,
1548
1633
  data: this.data
@@ -1557,10 +1642,10 @@ class $ extends ne {
1557
1642
  */
1558
1643
  createGroups() {
1559
1644
  const e = [], t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
1560
- const [l, c, h, d] = this.data[r];
1645
+ const [c, l, h, d] = this.data[r];
1561
1646
  if (t.add(r), d)
1562
1647
  return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
1563
- o.push([l, c]), h.forEach((u) => {
1648
+ o.push([c, l]), h.forEach((u) => {
1564
1649
  t.has(u) || i(u, o, r);
1565
1650
  });
1566
1651
  };
@@ -1589,10 +1674,10 @@ class $ extends ne {
1589
1674
  function n(i, r) {
1590
1675
  const [o, a] = e[i];
1591
1676
  t[i] = !0, r.push(a);
1592
- for (let l = 0; l < e.length; l++) {
1593
- const [c, h] = e[l];
1594
- if (!t[l] && Math.abs(a.x - c.x) < 1e-6 && Math.abs(a.y - c.y) < 1e-6)
1595
- return n(l, r);
1677
+ for (let c = 0; c < e.length; c++) {
1678
+ const [l, h] = e[c];
1679
+ if (!t[c] && Math.abs(a.x - l.x) < 1e-6 && Math.abs(a.y - l.y) < 1e-6)
1680
+ return n(c, r);
1596
1681
  }
1597
1682
  }
1598
1683
  const s = [];
@@ -1630,8 +1715,8 @@ class $ extends ne {
1630
1715
  if (s.distance(i) < this.width * 0.5) {
1631
1716
  let o = 0;
1632
1717
  for (let a = n + 1; a < e.length; a++) {
1633
- const l = e[a - 1], c = e[a];
1634
- if (l.distance(c) < this.width * 0.8) o++;
1718
+ const c = e[a - 1], l = e[a];
1719
+ if (c.distance(l) < this.width * 0.8) o++;
1635
1720
  else break;
1636
1721
  }
1637
1722
  o === 0 && n + o === e.length - 1 || n == 1 && o === 1 || (o === 3 ? (t.push(e[n + 1]), n += o) : o === 5 ? (t.push(e[n + 2]), n += o) : t.push(i));
@@ -1653,7 +1738,7 @@ class $ extends ne {
1653
1738
  break;
1654
1739
  }
1655
1740
  }
1656
- const t = this.mergeSameDirectionLine(Ee(e)), n = [t[0]];
1741
+ const t = this.mergeSameDirectionLine(Me(e)), n = [t[0]];
1657
1742
  for (let s = 1; s < t.length; s++) {
1658
1743
  const i = t[s], r = t[(t.length + s - 1) % t.length];
1659
1744
  if (i.length() > this.width * 0.9) {
@@ -1668,7 +1753,7 @@ class $ extends ne {
1668
1753
  const a = t[s + 2];
1669
1754
  a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
1670
1755
  }
1671
- return n.length > 3 ? De(this.mergeSameDirectionLine(n)) : [];
1756
+ return n.length > 3 ? Se(this.mergeSameDirectionLine(n)) : [];
1672
1757
  }
1673
1758
  /**
1674
1759
  * 移除短线段
@@ -1676,48 +1761,48 @@ class $ extends ne {
1676
1761
  * @param path
1677
1762
  */
1678
1763
  removeShortLine(e, t = this.shortLine) {
1679
- const n = Ee(e), s = [], i = Math.PI / 180;
1764
+ const n = Me(e), s = [], i = Math.PI / 180;
1680
1765
  for (let r = 0; r < n.length; r++) {
1681
- const o = n[r], a = o.length(), l = r;
1766
+ const o = n[r], a = o.length(), c = r;
1682
1767
  if (a > t || s.length === 0) {
1683
1768
  s.push(o);
1684
1769
  continue;
1685
1770
  }
1686
- let c = n[++r];
1771
+ let l = n[++r];
1687
1772
  const h = s[s.length - 1], d = h.direction();
1688
1773
  for (; r < n.length; ) {
1689
- const p = d.angleBetween(c.direction()) / i;
1690
- if (c.length() <= t || p < 4 || p > 176)
1691
- c = n[++r];
1774
+ const p = d.angleBetween(l.direction()) / i;
1775
+ if (l.length() <= t || p < 4 || p > 176)
1776
+ l = n[++r];
1692
1777
  else break;
1693
1778
  }
1694
- if (!c) continue;
1779
+ if (!l) continue;
1695
1780
  const u = n[r - 1];
1696
1781
  if (h.length() > u.length()) {
1697
- const p = h.getIntersection(c);
1782
+ const p = h.getIntersection(l);
1698
1783
  if (p) {
1699
- const y = h.points[1].clone(), x = c.points[0].clone();
1700
- h.points[1].copy(p), c.points[0].copy(p), h.length() < this.width ? (h.points[1].copy(y), c.points[0].copy(y)) : c.length() < this.width && (h.points[1].copy(x), c.points[0].copy(x));
1784
+ const x = h.points[1].clone(), y = l.points[0].clone();
1785
+ h.points[1].copy(p), l.points[0].copy(p), h.length() < this.width ? (h.points[1].copy(x), l.points[0].copy(x)) : l.length() < this.width && (h.points[1].copy(y), l.points[0].copy(y));
1701
1786
  } else
1702
- h.points[1].copy(c.points[0]);
1703
- s.push(c);
1787
+ h.points[1].copy(l.points[0]);
1788
+ s.push(l);
1704
1789
  } else
1705
- r = l;
1790
+ r = c;
1706
1791
  }
1707
- return s.length > 3 ? De(s) : [];
1792
+ return s.length > 3 ? Se(s) : [];
1708
1793
  }
1709
1794
  /** 线偏移
1710
1795
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
1711
1796
  */
1712
- lineOffset(e = $.EndType.etOpenSquare, t = $.JoinType.jtMiter, n = 1e4) {
1713
- let s = new Le.Paths();
1714
- const i = new Le.ClipperOffset(20, 0.25);
1797
+ lineOffset(e = W.EndType.etOpenSquare, t = W.JoinType.jtMiter, n = 1e4) {
1798
+ let s = new we.Paths();
1799
+ const i = new we.ClipperOffset(20, 0.25);
1715
1800
  return this.pointsGroups.forEach((r) => {
1716
- const o = this.lineTopology(r).map((a) => a.map((l) => l.clone().mutiplyScalar(n)));
1801
+ const o = this.lineTopology(r).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
1717
1802
  i.AddPaths(o, t, e);
1718
1803
  }), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
1719
- let o = r.map((a) => g.from(a).divisionScalar(n));
1720
- return o = this.lineSegmentStraightening(o), e == $.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
1804
+ let o = r.map((a) => w.from(a).divisionScalar(n));
1805
+ return o = this.lineSegmentStraightening(o), e == W.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
1721
1806
  }), this.dispatchEvent({
1722
1807
  type: "lineOffset",
1723
1808
  wallsGroup: this.wallsGroup
@@ -1743,22 +1828,22 @@ class $ extends ne {
1743
1828
  */
1744
1829
  getArcAngleRange(e, t, n) {
1745
1830
  const s = t.x - e.x, i = t.y - e.y, r = n.x - e.x, o = n.y - e.y;
1746
- let a = Math.atan2(i, s), l = Math.atan2(o, r);
1747
- a = a < 0 ? a + 2 * Math.PI : a, l = l < 0 ? l + 2 * Math.PI : l;
1748
- let c, h;
1749
- return Math.abs(l - a) <= Math.PI ? (c = Math.min(a, l), h = Math.max(a, l)) : (c = Math.max(a, l), h = Math.min(a, l) + 2 * Math.PI), [c / (Math.PI / 180), h / (Math.PI / 180)];
1831
+ let a = Math.atan2(i, s), c = Math.atan2(o, r);
1832
+ a = a < 0 ? a + 2 * Math.PI : a, c = c < 0 ? c + 2 * Math.PI : c;
1833
+ let l, h;
1834
+ return Math.abs(c - a) <= Math.PI ? (l = Math.min(a, c), h = Math.max(a, c)) : (l = Math.max(a, c), h = Math.min(a, c) + 2 * Math.PI), [l / (Math.PI / 180), h / (Math.PI / 180)];
1750
1835
  }
1751
1836
  /**
1752
1837
  * 线段数据转为原始json数据
1753
1838
  */
1754
1839
  lineDataToOriginalData(e, t) {
1755
- return $.lineDataToOriginalData(e, this.originalZAverage, t);
1840
+ return W.lineDataToOriginalData(e, this.originalZAverage, t);
1756
1841
  }
1757
1842
  /**
1758
1843
  * 转为绘制数据
1759
1844
  */
1760
1845
  toDrawDataJson(e = "Millimeters") {
1761
- const t = at[e], n = {
1846
+ const t = it[e], n = {
1762
1847
  unit: e,
1763
1848
  line: [],
1764
1849
  arc: [],
@@ -1769,62 +1854,62 @@ class $ extends ne {
1769
1854
  scale: t
1770
1855
  };
1771
1856
  let s = "white";
1772
- function i(l, c) {
1773
- n.line.push([l.x * t, l.y * t, c.x * t, c.y * t, s]);
1857
+ function i(c, l) {
1858
+ n.line.push([c.x * t, c.y * t, l.x * t, l.y * t, s]);
1774
1859
  }
1775
- function r(l, c, h, d) {
1860
+ function r(c, l, h, d) {
1776
1861
  n.arc.push([
1777
- l.x * t,
1778
- l.y * t,
1779
- c * t,
1862
+ c.x * t,
1863
+ c.y * t,
1864
+ l * t,
1780
1865
  h,
1781
1866
  d,
1782
1867
  s
1783
1868
  ]);
1784
1869
  }
1785
- for (let l = 0; l < this.originalData.length; l++) {
1786
- const c = this.originalData[l];
1787
- if (c.isVerticalReferenceLine) {
1788
- n.dimensionLine.push([c.start.x * t, c.start.y * t, c.end.x * t, c.end.y * t]);
1870
+ for (let c = 0; c < this.originalData.length; c++) {
1871
+ const l = this.originalData[c];
1872
+ if (l.isVerticalReferenceLine) {
1873
+ n.dimensionLine.push([l.start.x * t, l.start.y * t, l.end.x * t, l.end.y * t]);
1789
1874
  break;
1790
1875
  }
1791
1876
  }
1792
- this.wallsGroup.forEach((l) => {
1793
- for (let c = 0; c < l.length; c++) {
1794
- const h = l[c], d = c === l.length - 1 ? 0 : c + 1, u = l[d];
1877
+ this.wallsGroup.forEach((c) => {
1878
+ for (let l = 0; l < c.length; l++) {
1879
+ const h = c[l], d = l === c.length - 1 ? 0 : l + 1, u = c[d];
1795
1880
  i(h, u);
1796
1881
  }
1797
1882
  });
1798
1883
  const o = this.width * 0.2, a = [];
1799
- return this.doorLineSegment.forEach((l) => {
1800
- if (l.length() < 0.4) return;
1801
- const c = l.clone().expansion(-this.width * 0.5);
1802
- if (s = "cyan", c.length() < 1.2) {
1803
- c.expansion(-o * 0.5);
1804
- const h = l.normal();
1805
- let d = new N(
1806
- c.start.clone(),
1807
- c.start.clone().add(h.clone().multiplyScalar(c.length()))
1884
+ return this.doorLineSegment.forEach((c) => {
1885
+ if (c.length() < 0.4) return;
1886
+ const l = c.clone().expansion(-this.width * 0.5);
1887
+ if (s = "cyan", l.length() < 1.2) {
1888
+ l.expansion(-o * 0.5);
1889
+ const h = c.normal();
1890
+ let d = new R(
1891
+ l.start.clone(),
1892
+ l.start.clone().add(h.clone().multiplyScalar(l.length()))
1808
1893
  );
1809
- const u = d.clone().directionMove(d.normal(), c.length() * -0.5).expandToRectangle(c.length(), "bothSides");
1810
- for (let E = 0; E < a.length; E++)
1811
- if (a[E].intersectRectangle(u)) {
1812
- d = new N(
1813
- c.start.clone(),
1814
- c.start.clone().add(h.clone().multiplyScalar(-c.length()))
1894
+ const u = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
1895
+ for (let g = 0; g < a.length; g++)
1896
+ if (a[g].intersectRectangle(u)) {
1897
+ d = new R(
1898
+ l.start.clone(),
1899
+ l.start.clone().add(h.clone().multiplyScalar(-l.length()))
1815
1900
  );
1816
1901
  break;
1817
1902
  }
1818
- d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((E, R) => i(E, R));
1819
- const p = c.length(), y = d.length(), x = (p ** 2 + y ** 2) / (2 * y), S = d.end.clone().add(d.direction().multiplyScalar(-x)), [T, G] = this.getArcAngleRange(S, c.end, d.end);
1820
- r(S, x, Math.min(T, G), Math.max(T, G)), a.push(u);
1903
+ d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((g, L) => i(g, L));
1904
+ const p = l.length(), x = d.length(), y = (p ** 2 + x ** 2) / (2 * x), m = d.end.clone().add(d.direction().multiplyScalar(-y)), [M, T] = this.getArcAngleRange(m, l.end, d.end);
1905
+ r(m, y, Math.min(M, T), Math.max(M, T)), a.push(u);
1821
1906
  } else
1822
- c.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), c.clone().directionMove(c.normal(), o * 0.5).directionMove(c.direction(), o * 0.5).expansion(-c.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), c.clone().directionMove(c.normal(), -o * 0.5).directionMove(c.direction(), -o * 0.5).expansion(-c.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
1823
- }), s = "yellow", this.lineSegments.forEach((l) => {
1824
- if (!l.userData.isWindow) return !1;
1825
- Array.isArray(l.userData.drawWindow) && l.userData.drawWindow.forEach((c) => {
1826
- const { p: h, width: d } = c, u = g.from(h), p = u.clone().add(l.direction().multiplyScalar(d * 0.5)), y = u.clone().add(l.direction().multiplyScalar(-d * 0.5)), x = new N(p, y);
1827
- i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((S, T) => i(S, T));
1907
+ l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
1908
+ }), s = "yellow", this.lineSegments.forEach((c) => {
1909
+ if (!c.userData.isWindow) return !1;
1910
+ Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
1911
+ const { p: h, width: d } = l, u = w.from(h), p = u.clone().add(c.direction().multiplyScalar(d * 0.5)), x = u.clone().add(c.direction().multiplyScalar(-d * 0.5)), y = new R(p, x);
1912
+ i(y.start, y.end), y.expandToRectangle(this.width, "bothSides").path2D((m, M) => i(m, M));
1828
1913
  });
1829
1914
  }), n;
1830
1915
  }
@@ -1838,8 +1923,8 @@ class $ extends ne {
1838
1923
  if (typeof window < "u")
1839
1924
  i = document.createElement("canvas");
1840
1925
  else if (typeof global < "u") {
1841
- const { createCanvas: l } = await se("canvas");
1842
- i = l();
1926
+ const { createCanvas: c } = await ee("canvas");
1927
+ i = c();
1843
1928
  } else
1844
1929
  throw new Error("创建画布失败");
1845
1930
  const r = 2 * s.scale, o = {
@@ -1849,17 +1934,17 @@ class $ extends ne {
1849
1934
  };
1850
1935
  i.width = s.width + r * 2, i.height = s.height + r * 2;
1851
1936
  const a = i.getContext("2d");
1852
- return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([l, c, h, d, u]) => {
1853
- a.strokeStyle = o[u], a.beginPath(), a.moveTo(l, c), a.lineTo(h, d), a.closePath(), a.stroke();
1854
- }), s.arc.forEach(([l, c, h, d, u, p]) => {
1855
- a.strokeStyle = o[p], a.beginPath(), a.arc(l, c, h, d * (Math.PI / 180), u * (Math.PI / 180)), a.stroke();
1856
- }), a.beginPath(), s.dimensionLine.forEach((l) => {
1857
- let [c, h, d, u] = l;
1858
- const p = Math.min(h, u), y = Math.max(h, u), x = (i.width * 0.5 - 0.4 * s.scale) * (c < 0 ? -1 : 1), S = (y - p) * 0.45;
1859
- a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(x, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(x - 0.1 * s.scale, p), a.lineTo(x + 0.1 * s.scale, p), a.moveTo(x, p), a.lineTo(x, S + p), a.moveTo(x, y), a.lineTo(x, y - S), a.moveTo(x - 0.1 * s.scale, y), a.lineTo(x + 0.1 * s.scale, y);
1860
- }), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((l) => {
1861
- i.toBlob((c) => {
1862
- l(c);
1937
+ return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, d, u]) => {
1938
+ a.strokeStyle = o[u], a.beginPath(), a.moveTo(c, l), a.lineTo(h, d), a.closePath(), a.stroke();
1939
+ }), s.arc.forEach(([c, l, h, d, u, p]) => {
1940
+ a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), u * (Math.PI / 180)), a.stroke();
1941
+ }), a.beginPath(), s.dimensionLine.forEach((c) => {
1942
+ let [l, h, d, u] = c;
1943
+ const p = Math.min(h, u), x = Math.max(h, u), y = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), m = (x - p) * 0.45;
1944
+ a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(y, p + (x - p) * 0.5), a.scale(1, -1), a.fillText((x - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(y - 0.1 * s.scale, p), a.lineTo(y + 0.1 * s.scale, p), a.moveTo(y, p), a.lineTo(y, m + p), a.moveTo(y, x), a.lineTo(y, x - m), a.moveTo(y - 0.1 * s.scale, x), a.lineTo(y + 0.1 * s.scale, x);
1945
+ }), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
1946
+ i.toBlob((l) => {
1947
+ c(l);
1863
1948
  }, t, 1);
1864
1949
  }) : i.toBuffer(t, { quality: 1 });
1865
1950
  }
@@ -1867,15 +1952,15 @@ class $ extends ne {
1867
1952
  * 将点json结构转换为Dxf string
1868
1953
  */
1869
1954
  toDxfString(e = "Millimeters") {
1870
- const t = new ae();
1871
- t.setUnits(e), t.addLayer("cyan", ae.ACI.CYAN, "DOTTED"), t.addLayer("yellow", ae.ACI.YELLOW, "DOTTED"), t.addLayer("white", ae.ACI.WHITE, "DOTTED");
1955
+ const t = new se();
1956
+ t.setUnits(e), t.addLayer("cyan", se.ACI.CYAN, "DOTTED"), t.addLayer("yellow", se.ACI.YELLOW, "DOTTED"), t.addLayer("white", se.ACI.WHITE, "DOTTED");
1872
1957
  const n = this.toDrawDataJson();
1873
1958
  return n.line.forEach((s) => {
1874
- let [i, r, o, a, l] = s;
1875
- t.setActiveLayer(l), t.drawLine(i, r, o, a);
1959
+ let [i, r, o, a, c] = s;
1960
+ t.setActiveLayer(c), t.drawLine(i, r, o, a);
1876
1961
  }), n.arc.forEach((s) => {
1877
- const [i, r, o, a, l, c] = s;
1878
- t.setActiveLayer(c), t.drawArc(i, r, o, a, l);
1962
+ const [i, r, o, a, c, l] = s;
1963
+ t.setActiveLayer(l), t.drawArc(i, r, o, a, c);
1879
1964
  }), t.toDxfString();
1880
1965
  }
1881
1966
  /**
@@ -1894,7 +1979,7 @@ class $ extends ne {
1894
1979
  if (typeof window < "u") {
1895
1980
  const n = new Blob([t], { type: "application/json" }), s = document.createElement("a");
1896
1981
  s.href = URL.createObjectURL(n), s.download = e, s.click();
1897
- } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, t);
1982
+ } else typeof global < "u" && (await ee("fs", !1)).writeFileSync(e, t);
1898
1983
  }
1899
1984
  /**
1900
1985
  * 下载
@@ -1904,7 +1989,7 @@ class $ extends ne {
1904
1989
  if (typeof window < "u") {
1905
1990
  const n = this.toDxfBlob(t), s = document.createElement("a");
1906
1991
  s.href = URL.createObjectURL(n), s.download = e + ".dxf", s.click();
1907
- } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, this.toDxfString(t));
1992
+ } else typeof global < "u" && (await ee("fs", !1)).writeFileSync(e, this.toDxfString(t));
1908
1993
  }
1909
1994
  /**
1910
1995
  * 下载
@@ -1916,7 +2001,7 @@ class $ extends ne {
1916
2001
  if (typeof window < "u") {
1917
2002
  const i = document.createElement("a");
1918
2003
  i.href = URL.createObjectURL(s), i.download = e, i.click();
1919
- } else typeof global < "u" ? (await se("fs", !1)).writeFileSync(e, s) : console.error("图片下载失败");
2004
+ } else typeof global < "u" ? (await ee("fs", !1)).writeFileSync(e, s) : console.error("图片下载失败");
1920
2005
  return !0;
1921
2006
  }
1922
2007
  /**
@@ -1925,14 +2010,17 @@ class $ extends ne {
1925
2010
  * @returns
1926
2011
  */
1927
2012
  computedOriginalSize(e, t = new j(0, 0, 0, 0)) {
1928
- const n = e.flatMap((l) => [l.start.x, l.end.x]), s = e.flatMap((l) => [l.start.y, l.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
2013
+ const n = e.flatMap((c) => [c.start.x, c.end.x]), s = e.flatMap((c) => [c.start.y, c.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
1929
2014
  return t.set(i, r, o, a), t;
1930
2015
  }
2016
+ get boundaryExtension() {
2017
+ return W.boundaryExtension.bind(this);
2018
+ }
1931
2019
  /**
1932
2020
  * 线段数据转为原始json数据
1933
2021
  */
1934
2022
  static lineDataToOriginalData(e, t = 0, n) {
1935
- return n || (n = new Z(j.fromByLineSegment(...e)), e.forEach((s) => n?.insert({ line: s, userData: void 0 }))), e.map((s) => {
2023
+ return n || (n = new J(j.fromByLineSegment(...e)), e.forEach((s) => n?.insert({ line: s, userData: void 0 }))), e.map((s) => {
1936
2024
  const i = s.userData, r = i.drawWindow, o = n.queryLineSegment(s).filter((a) => a.line !== s && !a.userData?.isDoor).map((a) => ({ index: e.indexOf(a.line) }));
1937
2025
  return {
1938
2026
  start: s.start.toJson(t),
@@ -1961,13 +2049,13 @@ class $ extends ne {
1961
2049
  let n = 0;
1962
2050
  return e.flatMap((i) => {
1963
2051
  const r = i.map((o, a) => {
1964
- const l = a === i.length - 1 ? 0 : a + 1, c = i[l];
2052
+ const c = a === i.length - 1 ? 0 : a + 1, l = i[c];
1965
2053
  return {
1966
2054
  start: { x: o.x, y: o.y },
1967
- end: { x: c.x, y: c.y },
2055
+ end: { x: l.x, y: l.y },
1968
2056
  insetionArr: [
1969
2057
  {
1970
- index: l + n
2058
+ index: c + n
1971
2059
  }
1972
2060
  ]
1973
2061
  };
@@ -1975,6 +2063,48 @@ class $ extends ne {
1975
2063
  return n += i.length, t || (r.pop(), r[r.length - 1].insetionArr.length = 0, n--), r;
1976
2064
  });
1977
2065
  }
2066
+ /** 根据交点,对线段进行裁剪
2067
+ * @param this
2068
+ * @param lines
2069
+ */
2070
+ static lineSegmentClipping(e) {
2071
+ const t = new J(j.fromByLineSegment(...e));
2072
+ return e.forEach((n) => t.insert({ line: n, userData: void 0 })), e.flatMap((n) => {
2073
+ const s = t.queryLineSegment(n, !0).map((i) => {
2074
+ if (i.line === n) return;
2075
+ const r = i.line.getIntersection(n);
2076
+ if (!(!r || n.start.equal(r) || n.end.equal(r)))
2077
+ return r;
2078
+ }).filter((i) => !!i);
2079
+ if (s.length) {
2080
+ const i = n.clone();
2081
+ s.sort((o, a) => i.start.distance(o) - i.start.distance(a));
2082
+ const r = s.map((o) => {
2083
+ const a = i.clone();
2084
+ return a.set(i.start.clone(), o), i.start.copy(o), i.userData.isWindow && (a.userData.isWindow = !0, a.userData.drawWindow = i.userData.drawWindow?.filter((c) => a.isPointOnSegment(w.from(c.p))) ?? []), a;
2085
+ });
2086
+ return i.userData.drawWindow = i.userData.drawWindow?.filter((o) => i.isPointOnSegment(w.from(o.p))) ?? [], [...r, i];
2087
+ }
2088
+ return n;
2089
+ }).filter((n) => n.length() > 0.03);
2090
+ }
2091
+ /**
2092
+ * 重新计算窗户
2093
+ * @param windowLines
2094
+ */
2095
+ static recomputedWindow(...e) {
2096
+ e.forEach((t) => {
2097
+ const n = t.direction();
2098
+ t.userData.drawWindow?.forEach((s) => {
2099
+ const i = w.from(s.p), r = t.projectPoint(
2100
+ i.clone().add(n.clone().multiplyScalar(s.width * 0.5))
2101
+ ), o = t.projectPoint(
2102
+ i.clone().add(n.clone().multiplyScalar(s.width * -0.5))
2103
+ ), a = new R(r, o), c = a.center;
2104
+ s.p = new z.Vector3(c?.x ?? 0, c?.y ?? 0, s.p.z);
2105
+ });
2106
+ });
2107
+ }
1978
2108
  /**
1979
2109
  * 轴对齐垂直修正
1980
2110
  * @param lines 待调整线段组
@@ -1983,272 +2113,239 @@ class $ extends ne {
1983
2113
  */
1984
2114
  static axisAlignmentCorrection(e, t, n) {
1985
2115
  const { principalAxisThreshold: s = 0.3, crossAxistThreshold: i = 0.06, snapThreshold: r = 0.2 } = n ?? {};
1986
- function o(D, b) {
1987
- const L = [];
1988
- for (let M = 0; M < D.length; M++) {
1989
- const m = D[M], w = /* @__PURE__ */ new Map();
1990
- m.userData.isDoor || m.points.forEach((I) => {
1991
- if (b.queryPoint(I).length > 1) return;
1992
- const A = b.queryCircle(I, 0.4).filter((F) => {
1993
- const v = F.userData;
1994
- if (v === m || !m.parallel(v, 25)) return !1;
1995
- if (b.queryPoint(F.point).length > 1) return;
1996
- const _ = new N(I, F.point), q = new N(m.start === I ? m.end : m.start, v.start === F.point ? v.end : v.start);
1997
- if (!_.intersectLineSegment(q)) return !1;
1998
- const Y = I.distance(F.point);
1999
- return Y < 1e-3 ? !1 : (w.set(F.point, Y), !0);
2000
- }).sort((F, v) => {
2001
- const _ = w.get(F.point), q = w.get(v.point);
2002
- return _ - q;
2116
+ function o(b, v) {
2117
+ const E = [];
2118
+ for (let A = 0; A < b.length; A++) {
2119
+ const S = b[A], D = /* @__PURE__ */ new Map();
2120
+ S.userData.isDoor || S.points.forEach((C) => {
2121
+ if (v.queryPoint(C).length > 1) return;
2122
+ const I = v.queryCircle(C, 0.4).filter((U) => {
2123
+ const B = U.userData;
2124
+ if (B === S || !S.parallel(B, 25)) return !1;
2125
+ if (v.queryPoint(U.point).length > 1) return;
2126
+ const q = new R(C, U.point), _ = new R(S.start === C ? S.end : S.start, B.start === U.point ? B.end : B.start);
2127
+ if (!q.intersectLineSegment(_)) return !1;
2128
+ const H = C.distance(U.point);
2129
+ return H < 1e-3 ? !1 : (D.set(U.point, H), !0);
2130
+ }).sort((U, B) => {
2131
+ const q = D.get(U.point), _ = D.get(B.point);
2132
+ return q - _;
2003
2133
  });
2004
- if (A.length === 0) return;
2005
- const B = A[0].userData;
2006
- L.push(new N(m.projectLineSegment(B).center, B.projectLineSegment(m).center));
2134
+ if (I.length === 0) return;
2135
+ const G = I[0].userData;
2136
+ E.push(new R(S.projectLineSegment(G).center, G.projectLineSegment(S).center));
2007
2137
  });
2008
2138
  }
2009
- return [...D, ...L];
2139
+ return [...b, ...E];
2010
2140
  }
2011
- function a(D) {
2012
- const b = new ge(), L = new Z(j.fromByLineSegment(...D)), M = [];
2013
- return D.forEach((m) => {
2014
- m.userData.isDoor ? M.push(m) : (m.points.forEach((w) => b.insert(w, m)), L.insert({ line: m, userData: void 0 }));
2015
- }), M.forEach((m) => {
2016
- const w = b.queryPoint(m.start), I = b.queryPoint(m.end);
2017
- w.length ? m.userData.startIntersection = w[0].userData : m.userData.startIntersection = L.queryPoint(m.start)[0]?.line, I.length ? m.userData.endIntersection = I[0].userData : m.userData.endIntersection = L.queryPoint(m.end)[0]?.line;
2018
- }), D = o(D, b), D;
2141
+ function a(b) {
2142
+ const v = new oe(), E = new J(j.fromByLineSegment(...b)), A = [];
2143
+ return b.forEach((S) => {
2144
+ S.userData.isDoor ? A.push(S) : (S.points.forEach((D) => v.insert(D, S)), E.insert({ line: S, userData: void 0 }));
2145
+ }), A.forEach((S) => {
2146
+ const D = v.queryPoint(S.start), C = v.queryPoint(S.end);
2147
+ D.length ? S.userData.startIntersection = D[0].userData : S.userData.startIntersection = E.queryPoint(S.start)[0]?.line, C.length ? S.userData.endIntersection = C[0].userData : S.userData.endIntersection = E.queryPoint(S.end)[0]?.line;
2148
+ }), b = o(b, v), b;
2019
2149
  }
2020
- function l(D) {
2021
- const b = new Z(j.fromByLineSegment(...D));
2022
- D.forEach((M) => {
2023
- M.userData.isDoor || b.insert({ line: M, userData: void 0 });
2150
+ function c(b) {
2151
+ const v = new J(j.fromByLineSegment(...b));
2152
+ b.forEach((A) => {
2153
+ A.userData.isDoor || v.insert({ line: A, userData: void 0 });
2024
2154
  });
2025
- const L = /* @__PURE__ */ new Map();
2026
- for (let M = 0; M < D.length; M++) {
2027
- const m = D[M];
2028
- L.set(m, b.queryLineSegment(m).filter((w) => w.line !== m).map((w) => w.line));
2155
+ const E = /* @__PURE__ */ new Map();
2156
+ for (let A = 0; A < b.length; A++) {
2157
+ const S = b[A];
2158
+ E.set(S, v.queryLineSegment(S).filter((D) => D.line !== S && !D.line.isParallel(S)).map((D) => D.line));
2029
2159
  }
2030
- return L;
2160
+ return E;
2031
2161
  }
2032
- function c(D, b) {
2033
- const L = [D], M = [], m = [], w = [];
2034
- for (let I = 0; I < b.length; I++) {
2035
- const A = b[I];
2036
- if (D !== A)
2037
- if (A.userData.isWindow && w.push(A), A.parallel(D, 45)) {
2038
- const B = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x);
2039
- let v = Math.atan2(D.end.y - D.start.y, D.end.x - D.start.x) - B;
2040
- for (; v > Math.PI; ) v -= 2 * Math.PI;
2041
- for (; v < -Math.PI; ) v += 2 * Math.PI;
2042
- const _ = A.center;
2043
- A.start.rotate(_, v), A.end.rotate(_, v), A.userData.isDoor ? m.push(A) : L.push(A);
2162
+ function l(b, v) {
2163
+ const E = [b], A = [], S = [], D = [];
2164
+ for (let C = 0; C < v.length; C++) {
2165
+ const I = v[C];
2166
+ if (b !== I)
2167
+ if (I.userData.isWindow && D.push(I), I.parallel(b, 45)) {
2168
+ const G = Math.atan2(I.end.y - I.start.y, I.end.x - I.start.x);
2169
+ let B = Math.atan2(b.end.y - b.start.y, b.end.x - b.start.x) - G;
2170
+ for (; B > Math.PI; ) B -= 2 * Math.PI;
2171
+ for (; B < -Math.PI; ) B += 2 * Math.PI;
2172
+ const q = I.center;
2173
+ I.start.rotate(q, B), I.end.rotate(q, B), I.userData.isDoor ? S.push(I) : E.push(I);
2044
2174
  } else {
2045
- const B = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x), F = Math.atan2(D.end.y - D.start.y, D.end.x - D.start.x);
2046
- let v = F + Math.PI / 2 - B, _ = F - Math.PI / 2 - B;
2047
- for (; v > Math.PI; ) v -= 2 * Math.PI;
2048
- for (; v < -Math.PI; ) v += 2 * Math.PI;
2049
- for (; _ > Math.PI; ) _ -= 2 * Math.PI;
2050
- for (; _ < -Math.PI; ) _ += 2 * Math.PI;
2051
- const q = Math.abs(v) < Math.abs(_) ? v : _, Y = A.center;
2052
- A.start.rotate(Y, q), A.end.rotate(Y, q), A.userData.isDoor ? m.push(A) : M.push(A);
2175
+ const G = Math.atan2(I.end.y - I.start.y, I.end.x - I.start.x), U = Math.atan2(b.end.y - b.start.y, b.end.x - b.start.x);
2176
+ let B = U + Math.PI / 2 - G, q = U - Math.PI / 2 - G;
2177
+ for (; B > Math.PI; ) B -= 2 * Math.PI;
2178
+ for (; B < -Math.PI; ) B += 2 * Math.PI;
2179
+ for (; q > Math.PI; ) q -= 2 * Math.PI;
2180
+ for (; q < -Math.PI; ) q += 2 * Math.PI;
2181
+ const _ = Math.abs(B) < Math.abs(q) ? B : q, H = I.center;
2182
+ I.start.rotate(H, _), I.end.rotate(H, _), I.userData.isDoor ? S.push(I) : A.push(I);
2053
2183
  }
2054
2184
  }
2055
- return { parallelLines: L, verticalLines: M, doorLines: m, windowLines: w };
2185
+ return { parallelLines: E, verticalLines: A, doorLines: S, windowLines: D };
2056
2186
  }
2057
- function h(D, b, L) {
2058
- const M = [];
2059
- D.forEach((I) => {
2060
- const A = L.projectPoint(I.start, !1);
2061
- A && (A.userData = I, M.push(A));
2062
- }), M.sort((I, A) => A.distance(L.start) - I.distance(L.start));
2063
- const m = [], w = [];
2064
- for (let I = 0; I < M.length; I++) {
2065
- const A = M[I];
2066
- if (I === 0) {
2067
- w.push(A);
2187
+ function h(b, v, E) {
2188
+ const A = [];
2189
+ b.forEach((C) => {
2190
+ const I = E.projectPoint(C.start, !1);
2191
+ I && (I.userData = C, A.push(I));
2192
+ }), A.sort((C, I) => I.distance(E.start) - C.distance(E.start));
2193
+ const S = [], D = [];
2194
+ for (let C = 0; C < A.length; C++) {
2195
+ const I = A[C];
2196
+ if (C === 0) {
2197
+ D.push(I);
2068
2198
  continue;
2069
2199
  }
2070
- M[I - 1].distance(A) < i || (m.push([...w]), w.length = 0), w.push(A), I === M.length - 1 && m.push(w);
2200
+ A[C - 1].distance(I) < i || (S.push([...D]), D.length = 0), D.push(I), C === A.length - 1 && S.push(D);
2071
2201
  }
2072
- return m.flatMap((I) => {
2073
- const A = I.flatMap((_) => {
2074
- const q = _.userData;
2075
- return q.points.map((Y) => {
2076
- const Q = b.projectPoint(Y, !1);
2077
- return Q.userData = q, Q;
2202
+ return S.flatMap((C) => {
2203
+ const I = C.flatMap((q) => {
2204
+ const _ = q.userData;
2205
+ return _.points.map((H) => {
2206
+ const te = v.projectPoint(H, !1);
2207
+ return te.userData = _, te;
2078
2208
  });
2079
2209
  });
2080
- A.sort((_, q) => _.distance(b.start) - q.distance(b.start));
2081
- const B = /* @__PURE__ */ new Map(), F = [], v = [];
2082
- return A.forEach((_, q) => {
2083
- B.size === 0 && q > 0 && A[q - 1].distance(_) > s && (F.push([...v]), v.length = 0), B.set(_.userData, (B.get(_.userData) ?? 0) + 1);
2084
- for (const Y of B.values()) if (Y !== 2) return;
2085
- v.push(...B.keys()), B.clear();
2086
- }), F.push([...v]), F;
2210
+ I.sort((q, _) => q.distance(v.start) - _.distance(v.start));
2211
+ const G = /* @__PURE__ */ new Map(), U = [], B = [];
2212
+ return I.forEach((q, _) => {
2213
+ G.size === 0 && _ > 0 && I[_ - 1].distance(q) > s && (U.push([...B]), B.length = 0), G.set(q.userData, (G.get(q.userData) ?? 0) + 1);
2214
+ for (const H of G.values()) if (H !== 2) return;
2215
+ B.push(...G.keys()), G.clear();
2216
+ }), U.push([...B]), U;
2087
2217
  });
2088
2218
  }
2089
- function d(D, b) {
2090
- const L = /* @__PURE__ */ new Set();
2091
- return D.forEach((M) => {
2092
- for (let m = 1; m < M.length; m++) {
2093
- const w = M[m], I = M[m - 1];
2094
- [...b.get(w) ?? [], ...b.get(I) ?? []].forEach((B) => {
2095
- B.sameEndpointAsStart(w) && B.sameEndpointAsEnd(I) && B.sameEndpointAsStart(I) && B.sameEndpointAsEnd(w) && L.add(B);
2219
+ function d(b, v) {
2220
+ const E = /* @__PURE__ */ new Set();
2221
+ return b.forEach((A) => {
2222
+ for (let S = 1; S < A.length; S++) {
2223
+ const D = A[S], C = A[S - 1];
2224
+ [...v.get(D) ?? [], ...v.get(C) ?? []].forEach((G) => {
2225
+ (G.sameEndpointAsStart(D) && G.sameEndpointAsEnd(C) || G.sameEndpointAsStart(C) && G.sameEndpointAsEnd(D)) && E.add(G);
2096
2226
  });
2097
2227
  }
2098
- }), D.map((M) => M.filter((m) => !L.has(m)));
2228
+ }), b.map((A) => A.filter((S) => !E.has(S)));
2099
2229
  }
2100
- function u(D, b = 0.1) {
2101
- return D.map((L) => {
2102
- if (L.length === 0) return;
2103
- if (L.length === 1) return L[0];
2104
- const M = [];
2105
- L.forEach((K) => {
2106
- M.push(K.start.clone(), K.end.clone());
2107
- });
2108
- const m = L[0].direction().normalize();
2109
- let w = 1 / 0, I = -1 / 0, A = 0, B = 0;
2110
- M.forEach((K) => {
2111
- const re = K.x * m.x + K.y * m.y;
2112
- w = Math.min(w, re), I = Math.max(I, re), A += K.x, B += K.y;
2230
+ function u(b, v = 0.1) {
2231
+ return b.map((E) => {
2232
+ if (E.length === 0) return;
2233
+ if (E.length === 1) return E[0];
2234
+ const A = [];
2235
+ E.forEach((U) => A.push(U.start.clone(), U.end.clone()));
2236
+ const S = R.mergeLines(...E);
2237
+ let D = 1 / 0, C = -1 / 0;
2238
+ const I = E[0].normal().normalize();
2239
+ D = 1 / 0, C = -1 / 0, A.forEach((U) => {
2240
+ const B = U.x * I.x + U.y * I.y;
2241
+ D = Math.min(D, B), C = Math.max(C, B);
2113
2242
  });
2114
- const F = new g(A / M.length, B / M.length), v = F.x * m.x + F.y * m.y, _ = new g(F.x + (w - v) * m.x, F.y + (w - v) * m.y), q = new g(F.x + (I - v) * m.x, F.y + (I - v) * m.y), Y = new N(_, q), Q = L[0].normal().normalize();
2115
- w = 1 / 0, I = -1 / 0, M.forEach((K) => {
2116
- const re = K.x * Q.x + K.y * Q.y;
2117
- w = Math.min(w, re), I = Math.max(I, re);
2118
- });
2119
- const ie = I - w;
2120
- return ie >= b && (Y.userData.wallWidth = ie), L.forEach((K) => K.userData.fittedLine = Y), Y;
2121
- }).filter((L) => !!L);
2243
+ const G = C - D;
2244
+ return G >= v && (S.userData.wallWidth = G), E.forEach((U) => U.userData.fittedLine = S), S;
2245
+ }).filter((E) => !!E);
2122
2246
  }
2123
- function p(D) {
2124
- const b = new Z(j.fromByLineSegment(...D)), L = /* @__PURE__ */ new Map();
2125
- D.forEach((m) => {
2126
- L.set(m, { line: m, userData: void 0 }), b.insert(L.get(m));
2247
+ function p(b) {
2248
+ const v = new J(j.fromByLineSegment(...b)), E = /* @__PURE__ */ new Map();
2249
+ b.forEach((S) => {
2250
+ E.set(S, { line: S, userData: void 0 }), v.insert(E.get(S));
2127
2251
  });
2128
- const M = new N();
2129
- for (let m = 0; m < D.length; m++) {
2130
- const w = D[m];
2131
- if (w.userData.isAdsorbed) continue;
2132
- const I = w.direction().multiplyScalar(r), [A, B] = w.points.map((F) => {
2133
- M.set(F, F), M.start.add(I), M.end.add(I.multiplyScalar(-1));
2134
- const v = /* @__PURE__ */ new Map(), _ = b.queryRect(M.expandToRectangle(0.1, "bothSides")).filter((q) => q.line !== w).map((q) => {
2135
- const Y = q.line.getIntersection(M);
2136
- return v.set(q.line, Y), q.line;
2137
- }).sort((q, Y) => {
2138
- const Q = v.get(q), ie = v.get(Y);
2139
- return Q && ie ? Q.distance(F) - ie.distance(F) : 0;
2252
+ const A = new R();
2253
+ for (let S = 0; S < b.length; S++) {
2254
+ const D = b[S];
2255
+ if (D.userData.isAdsorbed) continue;
2256
+ const C = D.direction().multiplyScalar(r), [I, G] = D.points.map((U) => {
2257
+ A.set(U, U), A.start.add(C), A.end.add(C.multiplyScalar(-1));
2258
+ const B = /* @__PURE__ */ new Map(), q = v.queryRect(A.expandToRectangle(0.1, "bothSides")).filter((_) => _.line !== D).map((_) => {
2259
+ const H = _.line.getIntersection(A);
2260
+ return B.set(_.line, H), _.line;
2261
+ }).sort((_, H) => {
2262
+ const te = B.get(_), me = B.get(H);
2263
+ return te && me ? te.distance(U) - me.distance(U) : 0;
2140
2264
  });
2141
- return _.length ? v.get(_[0]) : void 0;
2265
+ return q.length ? B.get(q[0]) : void 0;
2142
2266
  });
2143
- if (A && B) {
2144
- if (A.equal(B)) {
2145
- const F = w.start.distance(A), v = w.end.distance(B);
2146
- F < v ? w.directionMove(w.start.direction(w.end), F) : w.directionMove(w.end.direction(w.start), v);
2267
+ if (I && G) {
2268
+ if (I.equal(G)) {
2269
+ const U = D.start.distance(I), B = D.end.distance(G);
2270
+ U < B ? D.directionMove(D.start.direction(D.end), U) : D.directionMove(D.end.direction(D.start), B);
2147
2271
  } else
2148
- w.start.copy(A), w.end.copy(B);
2149
- w.userData.isAdsorbed = !0;
2150
- } else A ? w.start.copy(A) : B && w.end.copy(B);
2151
- b.remove(L.get(w)), b.insert(L.get(w));
2272
+ D.start.copy(I), D.end.copy(G);
2273
+ D.userData.isAdsorbed = !0;
2274
+ } else I ? D.start.copy(I) : G && D.end.copy(G);
2275
+ v.remove(E.get(D)), v.insert(E.get(D));
2152
2276
  }
2153
- return D.filter((m) => m.length() > 1e-3);
2277
+ return b.filter((S) => S.length() > 1e-3);
2154
2278
  }
2155
- function y(D) {
2156
- for (let b = 0; b < D.length; b++) {
2157
- const L = D[b], M = L.userData.fittedLine;
2158
- if (M) {
2159
- const m = L.direction();
2160
- M.userData.isWindow = !0, M.userData.drawWindow = M.userData.drawWindow ?? [], L.userData.drawWindow?.forEach((w) => {
2161
- const I = g.from(w.p), A = M.projectPoint(
2162
- I.clone().add(m.clone().multiplyScalar(w.width * 0.5))
2163
- ), B = M.projectPoint(
2164
- I.clone().add(m.clone().multiplyScalar(w.width * -0.5))
2165
- ), F = new N(A, B), v = F.center;
2166
- M.userData.drawWindow?.push({
2167
- p: new z.Vector3(v?.x ?? 0, v?.y ?? 0, w.p.z),
2168
- width: F.length(),
2169
- full: w.full
2279
+ function x(b) {
2280
+ for (let v = 0; v < b.length; v++) {
2281
+ const E = b[v], A = E.userData.fittedLine;
2282
+ if (A) {
2283
+ const S = E.direction();
2284
+ A.userData.isWindow = !0, A.userData.drawWindow = A.userData.drawWindow ?? [], E.userData.drawWindow?.forEach((D) => {
2285
+ const C = w.from(D.p), I = A.projectPoint(
2286
+ C.clone().add(S.clone().multiplyScalar(D.width * 0.5))
2287
+ ), G = A.projectPoint(
2288
+ C.clone().add(S.clone().multiplyScalar(D.width * -0.5))
2289
+ ), U = new R(I, G), B = U.center;
2290
+ A.userData.drawWindow?.push({
2291
+ p: new z.Vector3(B?.x ?? 0, B?.y ?? 0, D.p.z),
2292
+ width: U.length(),
2293
+ full: D.full
2170
2294
  });
2171
2295
  });
2172
2296
  }
2173
2297
  }
2174
2298
  }
2175
- function x(D) {
2176
- for (let b = 0; b < D.length; b++) {
2177
- const L = D[b];
2178
- let { endIntersection: M, startIntersection: m } = L.userData;
2179
- if (!(!M || !m)) {
2180
- if (m.userData.fittedLine && (m = m.userData.fittedLine), M.userData.fittedLine && (M = M.userData.fittedLine), L.isParallel(m))
2181
- L.start.distance(m.start) < L.start.distance(m.end) ? L.start.copy(m.start) : L.start.copy(m.end);
2299
+ function y(b) {
2300
+ for (let v = 0; v < b.length; v++) {
2301
+ const E = b[v];
2302
+ let { endIntersection: A, startIntersection: S } = E.userData;
2303
+ if (!(!A || !S)) {
2304
+ if (S.userData.fittedLine && (S = S.userData.fittedLine), A.userData.fittedLine && (A = A.userData.fittedLine), E.isParallel(S))
2305
+ E.start.distance(S.start) < E.start.distance(S.end) ? E.start.copy(S.start) : E.start.copy(S.end);
2182
2306
  else {
2183
- const w = m.projectPoint(L.start);
2184
- w && L.start.copy(w);
2307
+ const D = S.projectPoint(E.start);
2308
+ D && E.start.copy(D);
2185
2309
  }
2186
- if (L.isParallel(M))
2187
- L.end.distance(M.start) < L.end.distance(M.end) ? L.end.copy(M.start) : L.end.copy(M.end);
2310
+ if (E.isParallel(A))
2311
+ E.end.distance(A.start) < E.end.distance(A.end) ? E.end.copy(A.start) : E.end.copy(A.end);
2188
2312
  else {
2189
- const w = M.projectPoint(L.end);
2190
- w && L.end.copy(w);
2313
+ const D = A.projectPoint(E.end);
2314
+ D && E.end.copy(D);
2191
2315
  }
2192
2316
  }
2193
2317
  }
2194
- return D;
2318
+ return b;
2195
2319
  }
2196
- function S(D) {
2197
- const b = new Z(j.fromByLineSegment(...D));
2198
- return D.forEach((L) => b.insert({ line: L, userData: void 0 })), D.flatMap((L) => {
2199
- const M = b.queryLineSegment(L, !0).map((m) => {
2200
- if (m.line === L) return;
2201
- const w = m.line.getIntersection(L);
2202
- if (!(!w || L.start.equal(w) || L.end.equal(w)))
2203
- return w;
2204
- }).filter((m) => !!m);
2205
- if (M.length) {
2206
- const m = L.clone();
2207
- M.sort((I, A) => m.start.distance(I) - m.start.distance(A));
2208
- const w = M.map((I) => {
2209
- const A = m.clone();
2210
- return A.set(m.start.clone(), I), m.start.copy(I), m.userData.isWindow && (A.userData.isWindow = !0, A.userData.drawWindow = m.userData.drawWindow?.filter((B) => A.isPointOnSegment(g.from(B.p))) ?? []), A;
2211
- });
2212
- return m.userData.drawWindow = m.userData.drawWindow?.filter((I) => m.isPointOnSegment(g.from(I.p))) ?? [], [...w, m];
2213
- }
2214
- return L;
2215
- }).filter((L) => L.length() > 0.03);
2216
- }
2217
- e = a(e.map((D) => D.clone()));
2218
- const T = l(e), { parallelLines: G, verticalLines: E, doorLines: R, windowLines: U } = c(t, e), P = t.normal(), O = t.center, X = t.direction(), k = new N(
2219
- O.clone().add(P.clone().multiplyScalar(-1e3)),
2220
- O.clone().add(P.clone().multiplyScalar(1e3))
2221
- ), W = new N(
2222
- O.clone().add(X.clone().multiplyScalar(-1e3)),
2223
- O.clone().add(X.clone().multiplyScalar(1e3))
2320
+ e = a(e.map((b) => b.clone()));
2321
+ const m = c(e), { parallelLines: M, verticalLines: T, doorLines: g, windowLines: L } = l(t, e), O = t.normal(), P = t.center, N = t.direction(), Y = new R(
2322
+ P.clone().add(O.clone().multiplyScalar(-1e3)),
2323
+ P.clone().add(O.clone().multiplyScalar(1e3))
2324
+ ), k = new R(
2325
+ P.clone().add(N.clone().multiplyScalar(-1e3)),
2326
+ P.clone().add(N.clone().multiplyScalar(1e3))
2224
2327
  );
2225
- let J = [
2226
- ...h.call(this, G, W, k),
2227
- ...h.call(this, E, k, W)
2328
+ let V = [
2329
+ ...h.call(this, M, k, Y),
2330
+ ...h.call(this, T, Y, k)
2228
2331
  ];
2229
- J = d(J, T);
2230
- let V = u(J);
2231
- return V = p.call(this, V), V = p.call(this, V), y(U), x(R), V = S.call(this, V), V.push(...R), V;
2332
+ V = d(V, m);
2333
+ let X = u(V);
2334
+ return X = p.call(this, X), X = p.call(this, X), x(L), y(g), X = W.lineSegmentClipping.call(this, X), X.push(...g), X;
2232
2335
  }
2233
- /**
2336
+ /** 查找外墙
2234
2337
  * @param lines
2235
2338
  * @param trajectoryPoints
2236
2339
  * @returns
2237
2340
  */
2238
2341
  static findExteriorWall(e, t, n = 0.4) {
2239
- const s = new Z(j.fromByLineSegment(...e));
2342
+ const s = new J(j.fromByLineSegment(...e));
2240
2343
  return e.forEach((i) => s.insert({ line: i, userData: void 0 })), e = e.filter((i) => {
2241
2344
  const r = i.center, o = /* @__PURE__ */ new Set();
2242
2345
  for (const a of t) {
2243
2346
  if (o.size === 2) break;
2244
- const l = new N(r, a);
2245
- if (!s.queryLineSegment(l).filter((h) => {
2246
- if (h.line === i) return !1;
2247
- if (h.line.isParallel(i)) {
2248
- if (i.getMinLength(h.line) < n) return !1;
2249
- } else if (h.line.sameEndpoint(i) && h.line.length() < n) return !1;
2250
- return !0;
2251
- }).length) {
2347
+ const c = new R(r, a);
2348
+ if (!s.queryLineSegment(c).filter((h) => !(h.line === i || h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
2252
2349
  const h = i.pointPosition(a);
2253
2350
  h !== "on" && o.add(h);
2254
2351
  }
@@ -2261,36 +2358,90 @@ class $ extends ne {
2261
2358
  * @param trajectoryPoints
2262
2359
  */
2263
2360
  static boundaryExtension(e, t, n = 0.1) {
2264
- const s = Object.keys(t).map((c) => g.from(t[c])), i = [];
2265
- let r = e.map(({ start: c, end: h, ...d }) => {
2266
- const u = new N(g.from(c), g.from(h));
2267
- return u.userData = d, i.push(c.z ?? 0, h.z ?? 0), u;
2361
+ function s(m, M) {
2362
+ return M.queryLineSegment(m).filter((T) => T.line !== m).map(({ line: T }) => {
2363
+ const g = { resultLine: T, type: "intersect", direction: "vertical", point: null, newLine: null };
2364
+ m.sameEndpoint(T) && (g.type = "endpoint"), m.parallel(T) && (g.direction = "parallel");
2365
+ const L = m.getSameEndpoint(T);
2366
+ if (L) g.point = L[1];
2367
+ else {
2368
+ const O = T.getIntersection(m);
2369
+ O && (g.point = T.start.equal(O) ? T.start : T.end);
2370
+ }
2371
+ return g;
2372
+ });
2373
+ }
2374
+ function i(m) {
2375
+ const M = m.userData.expandDirect;
2376
+ if (M === "left") {
2377
+ const T = m.getLeftDirection();
2378
+ m.directionMove(T, n * 0.5);
2379
+ } else if (M === "right") {
2380
+ const T = m.getRightDirection();
2381
+ m.directionMove(T, n * 0.5);
2382
+ }
2383
+ }
2384
+ function r({ resultLine: m, type: M, direction: T, point: g }, L, O, P) {
2385
+ if (M === "intersect")
2386
+ g && g.copy(L.projectPoint(g) ?? g);
2387
+ else if (T === "vertical") {
2388
+ if (g) {
2389
+ const N = L.projectPoint(g, !1);
2390
+ g.copy(N), L.isPointOnSegment(N) || (L.start.distance(N) < L.end.distance(N) ? P.push(new R(N.clone(), L.start.clone())) : P.push(new R(N.clone(), L.end.clone())));
2391
+ }
2392
+ } else if (!d.includes(m) && g) {
2393
+ let N = L.projectPoint(g, !1), Y;
2394
+ if (L.start.distance(g) < L.end.distance(g) ? Y = L.start : Y = L.end, N) {
2395
+ P.push(new R(g.clone(), N.clone()));
2396
+ const k = new R(N.clone(), Y.clone());
2397
+ k.length() && P.push(k);
2398
+ }
2399
+ }
2400
+ O.update(m);
2401
+ }
2402
+ const o = Object.keys(t).map((m) => w.from(t[m])), a = [];
2403
+ let c = e.map(({ start: m, end: M, ...T }) => {
2404
+ const g = new R(w.from(m), w.from(M));
2405
+ return g.userData = T, a.push(m.z ?? 0, M.z ?? 0), g;
2268
2406
  });
2269
- const o = i.reduce((c, h) => c + h, 0) / i.length, a = $.findExteriorWall(r, s), l = a.filter((c) => c.userData.expandDirect);
2270
- return r = r.filter((c) => !(a.includes(c) && !c.userData.expandDirect)), l.forEach((c) => {
2271
- const h = c.userData.expandDirect;
2272
- if (h === "left") {
2273
- const d = c.getLeftDirection();
2274
- c.directionMove(d, n * 0.5);
2275
- } else if (h === "right") {
2276
- const d = c.getRightDirection();
2277
- c.directionMove(d, n * 0.5);
2407
+ const l = a.reduce((m, M) => m + M, 0) / a.length, h = W.findExteriorWall(c, o);
2408
+ let d = h.filter((m) => m.userData.expandDirect);
2409
+ c = c.filter((m) => !h.includes(m)), c.push(...d);
2410
+ const u = R.groupBySamePointAndParallel(d), p = new J(j.fromByLineSegment(...c));
2411
+ c.forEach((m) => m.userData.isDoor || p.insert(m));
2412
+ const x = u.map((m) => m.flatMap((M) => s(M, p))), y = [];
2413
+ return u.flatMap((m, M) => (m.forEach((g) => (i(g), p.update(g))), x[M].filter((g) => {
2414
+ if (!d.includes(g.resultLine)) {
2415
+ let L;
2416
+ return Object.defineProperty(g, "newLine", {
2417
+ get() {
2418
+ return L || (L = R.mergeLines(...m)), L;
2419
+ }
2420
+ }), !0;
2278
2421
  }
2279
- }), $.lineDataToOriginalData(r, o);
2422
+ r(g, R.mergeLines(...m), p, y);
2423
+ }))).reduce((m, M) => (m.has(M.resultLine) || m.set(M.resultLine, []), m.get(M.resultLine)?.push(M), m), /* @__PURE__ */ new Map()).forEach((m) => {
2424
+ m.reduce((M, T) => (M.has(T.point) || M.set(T.point, []), M.get(T.point)?.push(T), M), /* @__PURE__ */ new Map()).forEach((M) => {
2425
+ const T = /* @__PURE__ */ new Set();
2426
+ for (let g = 0; g < M.length; g++) {
2427
+ const L = M[g];
2428
+ T.has(L.point) || (r(L, L.newLine, p, y), T.add(L.point));
2429
+ }
2430
+ });
2431
+ }), c.push(...R.deduplication(y)), c.forEach((m) => m.userData.isWindow && W.recomputedWindow(m)), c = W.lineSegmentClipping(c), c = R.deduplication(c), W.lineDataToOriginalData(c, l);
2280
2432
  }
2281
- boundaryExtension = $.boundaryExtension;
2282
2433
  }
2283
- function we(f) {
2434
+ function ye(f) {
2284
2435
  if (f === null || typeof f != "object") return f;
2285
2436
  if (f instanceof Date) return new Date(f.getTime());
2286
- if (Array.isArray(f)) return f.map(we);
2437
+ if (Array.isArray(f)) return f.map(ye);
2287
2438
  const e = {};
2288
2439
  for (const t in f)
2289
- Object.prototype.hasOwnProperty.call(f, t) && (e[t] = we(f[t]));
2440
+ Object.prototype.hasOwnProperty.call(f, t) && (e[t] = ye(f[t]));
2290
2441
  return e;
2291
2442
  }
2292
- const ee = new N();
2293
- class ct extends $ {
2443
+ const K = new R();
2444
+ class rt extends W {
2294
2445
  static name = "AngleCorrectionDxf";
2295
2446
  angle = 0;
2296
2447
  onAddFromParent(e) {
@@ -2299,43 +2450,43 @@ class ct extends $ {
2299
2450
  async update() {
2300
2451
  const e = this.parent, t = e.findComponentByName("Dxf"), n = e.findComponentByName("LineAnalysis");
2301
2452
  let s = 0, i = null;
2302
- for (let l = 0; l < t.originalData.length; l++) {
2303
- const c = t.originalData[l];
2304
- if (ee.start.copy(c.start), ee.end.copy(c.end), c.isVerticalReferenceLine) {
2305
- const [h, d] = c.start.y < c.end.y ? [ee.start, ee.end] : [ee.end, ee.start];
2306
- s = -new N(h, d).direction().angleBetween(new g(0, 1), "angle", "360"), i = null;
2453
+ for (let c = 0; c < t.originalData.length; c++) {
2454
+ const l = t.originalData[c];
2455
+ if (K.start.copy(l.start), K.end.copy(l.end), l.isVerticalReferenceLine) {
2456
+ const [h, d] = l.start.y < l.end.y ? [K.start, K.end] : [K.end, K.start];
2457
+ s = -new R(h, d).direction().angleBetween(new w(0, 1), "angle", "360"), i = null;
2307
2458
  break;
2308
2459
  }
2309
- (!i || ee.length() > i.length()) && (i = ee.clone(), i.userData.index = l);
2460
+ (!i || K.length() > i.length()) && (i = K.clone(), i.userData.index = c);
2310
2461
  }
2311
2462
  if (i) {
2312
2463
  t.originalData[i.userData.index].isVerticalReferenceLine = !0;
2313
- const [l, c] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
2314
- s = -new N(l, c).direction().angleBetween(new g(0, 1), "angle", "360");
2464
+ const [c, l] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
2465
+ s = -new R(c, l).direction().angleBetween(new w(0, 1), "angle", "360");
2315
2466
  }
2316
- const r = t.originalBox.center, o = g.zero(), a = t.originalData.map((l) => {
2317
- const c = o.copy(l.start).division(r).rotate(g.zero(), s * (Math.PI / 180)).toJson(l.start.z), h = o.copy(l.end).division(r).rotate(g.zero(), s * (Math.PI / 180)).toJson(l.end.z), d = Object.assign(we(l), { start: c, end: h });
2467
+ const r = t.originalBox.center, o = w.zero(), a = t.originalData.map((c) => {
2468
+ const l = o.copy(c.start).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(ye(c), { start: l, end: h });
2318
2469
  return d.drawWindow && d.drawWindow.forEach((u) => {
2319
- u.p = o.copy(u.p).division(r).rotate(g.zero(), s * (Math.PI / 180)).toJson(u.p.z);
2470
+ u.p = o.copy(u.p).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(u.p.z);
2320
2471
  }), d;
2321
2472
  });
2322
- n.appendLineSegmentList.forEach((l) => {
2323
- const c = l.clone();
2324
- c.start.division(r).rotate(g.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(g.zero(), s * (Math.PI / 180)), a.push({
2325
- start: c.start.toJson(t.originalZAverage),
2326
- end: c.end.toJson(t.originalZAverage),
2473
+ n.appendLineSegmentList.forEach((c) => {
2474
+ const l = c.clone();
2475
+ l.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), l.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), a.push({
2476
+ start: l.start.toJson(t.originalZAverage),
2477
+ end: l.end.toJson(t.originalZAverage),
2327
2478
  insetionArr: [],
2328
- length: c.length()
2479
+ length: l.length()
2329
2480
  });
2330
- }), await this.set(a, t.width, t.scale), this.lineOffset(), this.doorLineSegment = t.doorLineSegment.map((l) => {
2331
- const c = l.clone();
2332
- return c.start.division(r).rotate(g.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(g.zero(), s * (Math.PI / 180)), c;
2481
+ }), await this.set(a, t.width, t.scale), this.lineOffset(), this.doorLineSegment = t.doorLineSegment.map((c) => {
2482
+ const l = c.clone();
2483
+ return l.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), l.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), l;
2333
2484
  }), this.angle = s, this.dispatchEvent({
2334
2485
  type: "updateData"
2335
2486
  });
2336
2487
  }
2337
2488
  }
2338
- class Ce extends ne {
2489
+ class Re extends Q {
2339
2490
  static name = "Variable";
2340
2491
  originalLineVisible = !0;
2341
2492
  dxfVisible = !0;
@@ -2362,13 +2513,13 @@ class Ce extends ne {
2362
2513
  if (e in this) return this[e];
2363
2514
  }
2364
2515
  }
2365
- class lt {
2516
+ class ot {
2366
2517
  // 所有可查找的点位
2367
2518
  possibleDoorPoints = [];
2368
2519
  doorPoint = [];
2369
2520
  dxf;
2370
2521
  // 包含所有点的虚拟网格
2371
- pointVirtualGrid = new ge();
2522
+ pointVirtualGrid = new oe();
2372
2523
  // 只包含可查找点的虚拟网格
2373
2524
  findPointVirtualGrid;
2374
2525
  quadtree;
@@ -2381,7 +2532,7 @@ class lt {
2381
2532
  lineAnalysis;
2382
2533
  continueFind = !0;
2383
2534
  constructor(e) {
2384
- if (this.lineAnalysis = e, this.dxf = e.Dxf, this.findPointVirtualGrid = new ge(), this.quadtree = e.quadtree, this.resultList = e.resultList, this.lineSegments = e.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
2535
+ if (this.lineAnalysis = e, this.dxf = e.Dxf, this.findPointVirtualGrid = new oe(), this.quadtree = e.quadtree, this.resultList = e.resultList, this.lineSegments = e.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
2385
2536
  this.pointVirtualGrid.insert(n.start, n), this.pointVirtualGrid.insert(n.end, n);
2386
2537
  }), this.doorPoint = this.getDoorPoint(), !this.continueFind) return;
2387
2538
  const t = this.searchDoubleLinePoint();
@@ -2396,32 +2547,32 @@ class lt {
2396
2547
  search(e, t = [], n = 0.6, s = this.doorSearchDistance, i = this.doorSearchNearAngle) {
2397
2548
  const r = this.dxf, o = this.searchNearby(e, t, s, i);
2398
2549
  o.push(
2399
- ...e.map((l) => {
2400
- const c = this.searchAlongDirection(l, s);
2401
- if (c) return {
2402
- start: l.point,
2403
- end: c.point
2550
+ ...e.map((c) => {
2551
+ const l = this.searchAlongDirection(c, s);
2552
+ if (l) return {
2553
+ start: c.point,
2554
+ end: l.point
2404
2555
  };
2405
- const h = this.searchAlongNormalDirection(l, s);
2556
+ const h = this.searchAlongNormalDirection(c, s);
2406
2557
  if (h) return {
2407
- start: l.point,
2558
+ start: c.point,
2408
2559
  end: h.point
2409
2560
  };
2410
- }).filter((l) => !!l && l.start.distance(l.end) < s)
2561
+ }).filter((c) => !!c && c.start.distance(c.end) < s)
2411
2562
  );
2412
2563
  const a = [];
2413
- return o.forEach((l) => {
2414
- const c = new N(l?.start, l?.end), h = c.length();
2564
+ return o.forEach((c) => {
2565
+ const l = new R(c?.start, c?.end), h = l.length();
2415
2566
  if (h < n) return;
2416
- const d = c.normal(), u = c.direction(), p = (h - r.width * 2) / 2;
2417
- for (let y = 0; y < 3; y++) {
2418
- const x = c.start.clone().add(u.clone().multiplyScalar(r.width + p * y)), S = new N(
2419
- x,
2420
- x.clone().add(d.clone().multiplyScalar(1))
2567
+ const d = l.normal(), u = l.direction(), p = (h - r.width * 2) / 2;
2568
+ for (let x = 0; x < 3; x++) {
2569
+ const y = l.start.clone().add(u.clone().multiplyScalar(r.width + p * x)), m = new R(
2570
+ y,
2571
+ y.clone().add(d.clone().multiplyScalar(1))
2421
2572
  );
2422
- if (S.directionMove(d, -0.5), this.quadtree.queryLineSegment(S).length) return;
2573
+ if (m.directionMove(d, -0.5), this.quadtree.queryLineSegment(m).length) return;
2423
2574
  }
2424
- a.push(c);
2575
+ a.push(l);
2425
2576
  }), a;
2426
2577
  }
2427
2578
  /** 添加可查找点的过滤规则
@@ -2439,7 +2590,7 @@ class lt {
2439
2590
  return this.lineSegments.forEach((t) => {
2440
2591
  t.points.forEach((n, s) => {
2441
2592
  for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](t, n, s)) return;
2442
- this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid: me() });
2593
+ this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid: pe() });
2443
2594
  });
2444
2595
  }), e;
2445
2596
  }
@@ -2451,21 +2602,21 @@ class lt {
2451
2602
  return t.doors.forEach((s) => {
2452
2603
  const i = t.lineSegments[s[4]], r = t.originalData[s[4]];
2453
2604
  if (r.drawDoorData) {
2454
- const o = g.from(r.drawDoorData.start), a = g.from(r.drawDoorData.n), l = n.queryPoint(o).filter((c) => {
2455
- if (c.userData === i) return !1;
2456
- const h = c.userData, d = h.direction();
2605
+ const o = w.from(r.drawDoorData.start), a = w.from(r.drawDoorData.n), c = n.queryPoint(o).filter((l) => {
2606
+ if (l.userData === i) return !1;
2607
+ const h = l.userData, d = h.direction();
2457
2608
  h.start.equal(o) && d.multiplyScalar(-1);
2458
2609
  const u = a.angleBetween(d, "angle");
2459
2610
  return u > 80 || u < 10;
2460
2611
  });
2461
- l.length && e.push({
2462
- line: l[0].userData,
2612
+ c.length && e.push({
2613
+ line: c[0].userData,
2463
2614
  point: o,
2464
- uuid: me()
2615
+ uuid: pe()
2465
2616
  });
2466
2617
  } else if (r.doorDirectConnection) {
2467
2618
  this.continueFind = !1;
2468
- const o = new N(g.from(r.start), g.from(r.end));
2619
+ const o = new R(w.from(r.start), w.from(r.end));
2469
2620
  o.userData = {
2470
2621
  doorDirectConnection: !0,
2471
2622
  isDoor: !0
@@ -2481,8 +2632,8 @@ class lt {
2481
2632
  searchDoubleLinePoint() {
2482
2633
  const e = /* @__PURE__ */ new Map();
2483
2634
  return this.resultList.flatMap((t) => {
2484
- const n = this.lineSegments[t.sourceIndex], s = this.lineSegments[t.targetIndex], i = s.projectPoint(n.start), r = s.projectPoint(n.end), o = n.projectPoint(s.start), a = n.projectPoint(s.end), l = i && r ? -1 : i ? 0 : r ? 1 : -1, c = o && a ? -1 : o ? 0 : a ? 1 : -1;
2485
- e.has(t.sourceIndex) ? e.get(t.sourceIndex) != l && e.set(t.sourceIndex, -1) : e.set(t.sourceIndex, l), e.has(t.targetIndex) ? e.get(t.targetIndex) != c && e.set(t.targetIndex, -1) : e.set(t.targetIndex, c);
2635
+ const n = this.lineSegments[t.sourceIndex], s = this.lineSegments[t.targetIndex], i = s.projectPoint(n.start), r = s.projectPoint(n.end), o = n.projectPoint(s.start), a = n.projectPoint(s.end), c = i && r ? -1 : i ? 0 : r ? 1 : -1, l = o && a ? -1 : o ? 0 : a ? 1 : -1;
2636
+ e.has(t.sourceIndex) ? e.get(t.sourceIndex) != c && e.set(t.sourceIndex, -1) : e.set(t.sourceIndex, c), e.has(t.targetIndex) ? e.get(t.targetIndex) != l && e.set(t.targetIndex, -1) : e.set(t.targetIndex, l);
2486
2637
  }), e;
2487
2638
  }
2488
2639
  /** 查找方案一:最近点查找
@@ -2495,94 +2646,94 @@ class lt {
2495
2646
  */
2496
2647
  searchNearby(e, t = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
2497
2648
  const i = this.findPointVirtualGrid, r = this.quadtree;
2498
- function o({ point: x, line: S }, T, G) {
2499
- const E = S.direction();
2500
- S.start === x && E.multiplyScalar(-1);
2501
- const R = i.queryCircle(x, n).filter((P) => P.userData !== S).sort((P, O) => P.point.distance(x) - O.point.distance(x)), U = [];
2502
- for (let P = 0; P < R.length; P++) {
2503
- const O = t.findIndex((D) => D.point === R[P].point), X = e[T].uuid, k = t[O].uuid;
2504
- if (G.has(`${X}.${k}`)) continue;
2505
- G.add(`${X}.${k}`), G.add(`${k}.${X}`);
2506
- const W = R[P].point, J = new N(x.clone(), W.clone());
2507
- if (J.direction().angleBetween(E, "angle") < s) {
2508
- const D = e[O].line.direction();
2509
- R[P].userData.start.equal(R[P].point) && D.multiplyScalar(-1), J.direction().multiplyScalar(-1).angleBetween(D, "angle") < s && (r.queryLineSegment(J).length || U.push({
2510
- findData: R[P],
2649
+ function o({ point: y, line: m }, M, T) {
2650
+ const g = m.direction();
2651
+ m.start === y && g.multiplyScalar(-1);
2652
+ const L = i.queryCircle(y, n).filter((P) => P.userData !== m).sort((P, N) => P.point.distance(y) - N.point.distance(y)), O = [];
2653
+ for (let P = 0; P < L.length; P++) {
2654
+ const N = t.findIndex((v) => v.point === L[P].point), Y = e[M].uuid, k = t[N].uuid;
2655
+ if (T.has(`${Y}.${k}`)) continue;
2656
+ T.add(`${Y}.${k}`), T.add(`${k}.${Y}`);
2657
+ const V = L[P].point, X = new R(y.clone(), V.clone());
2658
+ if (X.direction().angleBetween(g, "angle") < s) {
2659
+ const v = e[N].line.direction();
2660
+ L[P].userData.start.equal(L[P].point) && v.multiplyScalar(-1), X.direction().multiplyScalar(-1).angleBetween(v, "angle") < s && (r.queryLineSegment(X).length || O.push({
2661
+ findData: L[P],
2511
2662
  findUuid: k,
2512
- doorLine: J,
2513
- doorUuid: X
2663
+ doorLine: X,
2664
+ doorUuid: Y
2514
2665
  }));
2515
2666
  }
2516
2667
  }
2517
- return U;
2668
+ return O;
2518
2669
  }
2519
- function a(x, S, T, G, E) {
2520
- G.add(x);
2521
- const R = [];
2522
- E && R.push(E);
2523
- for (let U = 0; U < T.length; U++) {
2524
- const P = T[U];
2525
- if (S.has(P.findUuid)) {
2526
- const O = S.get(P.findUuid);
2527
- a(P.findUuid, S, O, G, P) && R.push(P);
2528
- } else R.push(P);
2670
+ function a(y, m, M, T, g) {
2671
+ T.add(y);
2672
+ const L = [];
2673
+ g && L.push(g);
2674
+ for (let O = 0; O < M.length; O++) {
2675
+ const P = M[O];
2676
+ if (m.has(P.findUuid)) {
2677
+ const N = m.get(P.findUuid);
2678
+ a(P.findUuid, m, N, T, P) && L.push(P);
2679
+ } else L.push(P);
2529
2680
  }
2530
- return R.sort((U, P) => U.doorLine.length() - P.doorLine.length()), E && R[0] === E ? (T.splice(0), !0) : (T.splice(1), !1);
2681
+ return L.sort((O, P) => O.doorLine.length() - P.doorLine.length()), g && L[0] === g ? (M.splice(0), !0) : (M.splice(1), !1);
2531
2682
  }
2532
- const l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
2533
- e.map((x, S) => {
2534
- const T = o(x, S, l);
2535
- T.length && c.set(x.uuid, T);
2536
- }), l.clear();
2683
+ const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
2684
+ e.map((y, m) => {
2685
+ const M = o(y, m, c);
2686
+ M.length && l.set(y.uuid, M);
2687
+ }), c.clear();
2537
2688
  const h = /* @__PURE__ */ new Map();
2538
- c.forEach((x, S) => {
2539
- if (!l.has(S) && x.length && a(S, c, x, l), x.length) {
2540
- const T = x[0];
2541
- h.has(T.doorUuid) || h.set(T.doorUuid, []), h.get(T.doorUuid)?.push(T), h.has(T.findUuid) || h.set(T.findUuid, []), h.get(T.findUuid)?.push(T);
2689
+ l.forEach((y, m) => {
2690
+ if (!c.has(m) && y.length && a(m, l, y, c), y.length) {
2691
+ const M = y[0];
2692
+ h.has(M.doorUuid) || h.set(M.doorUuid, []), h.get(M.doorUuid)?.push(M), h.has(M.findUuid) || h.set(M.findUuid, []), h.get(M.findUuid)?.push(M);
2542
2693
  }
2543
2694
  });
2544
2695
  const d = /* @__PURE__ */ new Set();
2545
- h.forEach((x) => {
2546
- if (x.length > 1) {
2547
- x.sort((S, T) => S.doorLine.length() - T.doorLine.length());
2548
- for (let S = 1; S < x.length; S++) d.add(x[S]);
2696
+ h.forEach((y) => {
2697
+ if (y.length > 1) {
2698
+ y.sort((m, M) => m.doorLine.length() - M.doorLine.length());
2699
+ for (let m = 1; m < y.length; m++) d.add(y[m]);
2549
2700
  }
2550
2701
  });
2551
2702
  const u = [], p = [];
2552
- c.forEach((x) => {
2553
- if (x.length) {
2554
- const S = x[0];
2555
- d.has(S) || (u.push(S), p.push(S.doorUuid, S.findUuid));
2703
+ l.forEach((y) => {
2704
+ if (y.length) {
2705
+ const m = y[0];
2706
+ d.has(m) || (u.push(m), p.push(m.doorUuid, m.findUuid));
2556
2707
  }
2557
2708
  });
2558
- const y = [];
2559
- return u.forEach((x) => {
2560
- const S = e.findIndex((O) => O.uuid === x.doorUuid), T = t.findIndex((O) => O.uuid === x.findUuid), G = e[S].point.clone(), E = t[T].point.clone(), R = this.findLongLineSegment(e[S].line), U = this.findLongLineSegment(t[T].line), P = R.projectPoint(E);
2709
+ const x = [];
2710
+ return u.forEach((y) => {
2711
+ const m = e.findIndex((N) => N.uuid === y.doorUuid), M = t.findIndex((N) => N.uuid === y.findUuid), T = e[m].point.clone(), g = t[M].point.clone(), L = this.findLongLineSegment(e[m].line), O = this.findLongLineSegment(t[M].line), P = L.projectPoint(g);
2561
2712
  if (P) {
2562
- G.copy(P);
2563
- const O = new N(G, E), X = U.includedAngle(O);
2564
- (X < 10 || X > 170 || Math.abs(90 - X) < 10) && y.push({
2565
- start: G,
2566
- end: E
2713
+ T.copy(P);
2714
+ const N = new R(T, g), Y = O.includedAngle(N);
2715
+ (Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && x.push({
2716
+ start: T,
2717
+ end: g
2567
2718
  });
2568
2719
  } else {
2569
- const O = U.projectPoint(G);
2570
- O && E.copy(O);
2571
- const X = new N(G, E), k = R.includedAngle(X);
2572
- (k < 10 || k > 170 || Math.abs(90 - k) < 10) && y.push({
2573
- start: G,
2574
- end: E
2720
+ const N = O.projectPoint(T);
2721
+ N && g.copy(N);
2722
+ const Y = new R(T, g), k = L.includedAngle(Y);
2723
+ (k < 10 || k > 170 || Math.abs(90 - k) < 10) && x.push({
2724
+ start: T,
2725
+ end: g
2575
2726
  });
2576
2727
  }
2577
2728
  }), t.splice(
2578
2729
  0,
2579
2730
  t.length,
2580
- ...t.filter((x) => p.indexOf(x.uuid) === -1)
2731
+ ...t.filter((y) => p.indexOf(y.uuid) === -1)
2581
2732
  ), e.splice(
2582
2733
  0,
2583
2734
  e.length,
2584
- ...e.filter((x) => p.indexOf(x.uuid) === -1)
2585
- ), y;
2735
+ ...e.filter((y) => p.indexOf(y.uuid) === -1)
2736
+ ), x;
2586
2737
  }
2587
2738
  /** 方案二: 沿方向查找
2588
2739
  * @description
@@ -2592,14 +2743,14 @@ class lt {
2592
2743
  searchAlongDirection({ point: e, line: t }, n = this.doorSearchDistance) {
2593
2744
  const s = this.quadtree, i = t.direction();
2594
2745
  t.start === e && i.multiplyScalar(-1);
2595
- const r = e.clone().add(i.clone().multiplyScalar(n)), o = new N(e.clone(), r), a = s.queryLineSegment(o).map((l) => ({
2596
- point: l.line.getIntersection(o),
2597
- line: l.line
2598
- })).filter((l) => l.point).sort((l, c) => e.distance(l.point) - e.distance(c.point));
2746
+ const r = e.clone().add(i.clone().multiplyScalar(n)), o = new R(e.clone(), r), a = s.queryLineSegment(o).map((c) => ({
2747
+ point: c.line.getIntersection(o),
2748
+ line: c.line
2749
+ })).filter((c) => c.point).sort((c, l) => e.distance(c.point) - e.distance(l.point));
2599
2750
  if (a.length) {
2600
- const l = a[0];
2601
- if (Math.abs(90 - l.line.direction().angleBetween(i, "angle")) < 5)
2602
- return l;
2751
+ const c = a[0];
2752
+ if (Math.abs(90 - c.line.direction().angleBetween(i, "angle")) < 5)
2753
+ return c;
2603
2754
  }
2604
2755
  }
2605
2756
  /** 方案三: 沿法线方向查找
@@ -2611,16 +2762,16 @@ class lt {
2611
2762
  searchAlongNormalDirection({ point: e, line: t }, n = this.doorSearchDistance) {
2612
2763
  const s = this.pointVirtualGrid, i = this.quadtree, r = t.direction(), o = t.start.normal(t.end), a = t.start.clone();
2613
2764
  t.start === e && r.multiplyScalar(-1), t.start === e && a.copy(t.end);
2614
- const l = s.queryPoint(a).filter((d) => d.userData !== t);
2615
- for (let d = 0; d < l.length; d++) {
2616
- const u = l[d], p = u.userData, y = p.direction();
2617
- if (p.start === u.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
2765
+ const c = s.queryPoint(a).filter((d) => d.userData !== t);
2766
+ for (let d = 0; d < c.length; d++) {
2767
+ const u = c[d], p = u.userData, x = p.direction();
2768
+ if (p.start === u.point && r.multiplyScalar(-1), x.angleBetween(o) / (Math.PI / 180) > 90) {
2618
2769
  o.multiplyScalar(-1);
2619
2770
  break;
2620
2771
  }
2621
2772
  }
2622
- const c = new N(e.clone(), e.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(c).map((d) => ({
2623
- point: d.line.getIntersection(c),
2773
+ const l = new R(e.clone(), e.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
2774
+ point: d.line.getIntersection(l),
2624
2775
  line: d.line
2625
2776
  })).filter((d) => d.point).sort((d, u) => e.distance(d.point) - e.distance(u.point));
2626
2777
  if (h.length) {
@@ -2653,7 +2804,7 @@ class lt {
2653
2804
  return t;
2654
2805
  }
2655
2806
  }
2656
- class ht extends ne {
2807
+ class at extends Q {
2657
2808
  static name = "LineAnalysis";
2658
2809
  Dxf = null;
2659
2810
  Variable = null;
@@ -2667,7 +2818,7 @@ class ht extends ne {
2667
2818
  * @param parent
2668
2819
  */
2669
2820
  onAddFromParent(e) {
2670
- this.Dxf = e.findComponentByType($), this.Variable = this.parent?.findComponentByType(Ce), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
2821
+ this.Dxf = e.findComponentByType(W), this.Variable = this.parent?.findComponentByType(Re), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
2671
2822
  }
2672
2823
  /**
2673
2824
  *
@@ -2681,11 +2832,11 @@ class ht extends ne {
2681
2832
  return {
2682
2833
  points: [
2683
2834
  // 第一条线
2684
- new g(e.x + o, e.y + a).add(r),
2685
- new g(t.x + o, t.y + a).add(i),
2835
+ new w(e.x + o, e.y + a).add(r),
2836
+ new w(t.x + o, t.y + a).add(i),
2686
2837
  // 第二条线
2687
- new g(e.x - o, e.y - a).add(r),
2688
- new g(t.x - o, t.y - a).add(i)
2838
+ new w(e.x - o, e.y - a).add(r),
2839
+ new w(t.x - o, t.y - a).add(i)
2689
2840
  ],
2690
2841
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2691
2842
  rectIndices: [0, 1, 3, 2, 0]
@@ -2699,7 +2850,7 @@ class ht extends ne {
2699
2850
  */
2700
2851
  addData(e, t) {
2701
2852
  const n = this.Dxf;
2702
- n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new N(e.clone(), t.clone()));
2853
+ n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new R(e.clone(), t.clone()));
2703
2854
  }
2704
2855
  /** 结果分析创建矩形
2705
2856
  * @param result
@@ -2707,14 +2858,14 @@ class ht extends ne {
2707
2858
  createRectangle(e) {
2708
2859
  const t = this.Dxf, n = e.project, s = e.project2;
2709
2860
  n.includedAngle(s) > 135 && (s.points = [s.points[1], s.points[0]]), this.addData(n.points[0], s.points[0]), this.addData(n.points[1], s.points[1]);
2710
- const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / t.width), a = i / o, l = r / o, c = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), u = n.points[1].clone(), p = u.direction(d);
2861
+ const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / t.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), u = n.points[1].clone(), p = u.direction(d);
2711
2862
  p.multiplyScalar(t.width * 0.5);
2712
- const y = d.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)), S = d.direction(u), T = y.direction(x);
2713
- if (!(S.x > 0 && T.x < 0 || S.x < 0 && T.x > 0 || S.y > 0 && T.y < 0 || S.y < 0 && T.y > 0)) {
2714
- d.set(y.x, y.y), u.set(x.x, x.y);
2715
- for (let G = 1; G < o; G++) {
2716
- const E = c.clone().multiplyScalar(a * G), R = h.clone().multiplyScalar(l * G), U = d.clone().add(E), P = u.clone().add(R);
2717
- this.addData(U, P);
2863
+ const x = d.clone().add(p), y = u.clone().add(p.multiplyScalar(-1)), m = d.direction(u), M = x.direction(y);
2864
+ if (!(m.x > 0 && M.x < 0 || m.x < 0 && M.x > 0 || m.y > 0 && M.y < 0 || m.y < 0 && M.y > 0)) {
2865
+ d.set(x.x, x.y), u.set(y.x, y.y);
2866
+ for (let T = 1; T < o; T++) {
2867
+ const g = l.clone().multiplyScalar(a * T), L = h.clone().multiplyScalar(c * T), O = d.clone().add(g), P = u.clone().add(L);
2868
+ this.addData(O, P);
2718
2869
  }
2719
2870
  }
2720
2871
  }
@@ -2724,7 +2875,7 @@ class ht extends ne {
2724
2875
  */
2725
2876
  buildQuadtree() {
2726
2877
  const e = this.Dxf, t = [];
2727
- this.quadtree = new Z(e.originalBox, 2), e.lineSegments.forEach((n) => {
2878
+ this.quadtree = new J(e.originalBox, 2), e.lineSegments.forEach((n) => {
2728
2879
  n.userData?.isDoor || (this.quadtree?.insert({
2729
2880
  line: n,
2730
2881
  userData: t.length
@@ -2741,12 +2892,12 @@ class ht extends ne {
2741
2892
  this.buildQuadtree();
2742
2893
  const e = this.quadtree, t = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
2743
2894
  t.forEach((i, r) => {
2744
- const o = t[r], a = ue.fromByLineSegment(o, this.width * 2, !1, -0.01);
2745
- e.queryRect(a).map((c) => c.userData).filter((c) => c !== r).forEach((c) => {
2895
+ const o = t[r], a = ce.fromByLineSegment(o, this.width * 2, !1, -0.01);
2896
+ e.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
2746
2897
  try {
2747
- if (n.has(`${r}-${c}`) || n.has(`${c}-${r}`)) return;
2748
- const h = this.projectionAnalysis(c, r, o, t);
2749
- h && s.push(h), n.add(`${r}-${c}`);
2898
+ if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
2899
+ const h = this.projectionAnalysis(l, r, o, t);
2900
+ h && s.push(h), n.add(`${r}-${l}`);
2750
2901
  } catch {
2751
2902
  }
2752
2903
  });
@@ -2761,23 +2912,23 @@ class ht extends ne {
2761
2912
  projectionAnalysis(e, t, n, s) {
2762
2913
  const i = s[e], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
2763
2914
  if (a < this.errorAngle || a > 180 - this.errorAngle) {
2764
- let l;
2765
- const c = i.projectLineSegment(n), h = n.projectLineSegment(i);
2766
- return c.getLength() > h.getLength() ? l = {
2915
+ let c;
2916
+ const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
2917
+ return l.getLength() > h.getLength() ? c = {
2767
2918
  target: i,
2768
2919
  targetIndex: e,
2769
2920
  source: n,
2770
2921
  sourceIndex: t,
2771
- project: c,
2922
+ project: l,
2772
2923
  project2: h
2773
- } : l = {
2924
+ } : c = {
2774
2925
  target: n,
2775
2926
  targetIndex: t,
2776
2927
  source: i,
2777
2928
  sourceIndex: e,
2778
2929
  project: h,
2779
- project2: c
2780
- }, !l || l.project.getLength() < 0.2 || l.project2.getLength() < 0.2 ? void 0 : l;
2930
+ project2: l
2931
+ }, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
2781
2932
  }
2782
2933
  }
2783
2934
  doorSearchNearAngle = 110;
@@ -2785,54 +2936,52 @@ class ht extends ne {
2785
2936
  doors = [];
2786
2937
  DoorsAnalysis;
2787
2938
  doorsAnalysis() {
2788
- this.DoorsAnalysis = new lt(this), this.dispatchEvent({
2939
+ this.DoorsAnalysis = new ot(this), this.dispatchEvent({
2789
2940
  type: "analysisCompleted"
2790
2941
  });
2791
2942
  }
2792
2943
  }
2793
- class ut extends ne {
2944
+ class ct extends Q {
2794
2945
  static name = "ThreeVJia";
2795
2946
  lineSegments = [];
2796
2947
  onAddFromParent() {
2797
2948
  (this.parent?.findComponentByName("AngleCorrectionDxf")).addEventListener("updateData", async () => this.updateData());
2798
2949
  }
2799
2950
  updateData() {
2800
- const e = this.parent?.findComponentByName("LineAnalysis"), t = this.parent?.findComponentByName("Dxf");
2801
- this.parent?.findComponentByName("Renderer");
2802
- const n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
2951
+ const e = this.parent?.findComponentByName("LineAnalysis"), t = this.parent?.findComponentByName("Dxf"), n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
2803
2952
  let i = [...t.lineSegments], r = [], o = [];
2804
- e.resultList.forEach((c) => {
2805
- const h = s.get(c.target) ?? [], d = s.get(c.source) ?? [], u = c.project.clone(), p = c.project2.clone();
2806
- u.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...u.points), d.push(...p.points), s.set(c.target, h), s.set(c.source, d);
2807
- const y = new N(u.start, p.start), x = new N(u.end, p.end), S = new N(y.center, x.center);
2808
- S.userData.wallWidth = Math.max(y.length(), x.length()), r.push(S);
2953
+ e.resultList.forEach((l) => {
2954
+ const h = s.get(l.target) ?? [], d = s.get(l.source) ?? [], u = l.project.clone(), p = l.project2.clone();
2955
+ u.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...u.points), d.push(...p.points), s.set(l.target, h), s.set(l.source, d);
2956
+ const x = new R(u.start, p.start), y = new R(u.end, p.end), m = new R(x.center, y.center);
2957
+ m.userData.wallWidth = Math.max(x.length(), y.length()), r.push(m);
2809
2958
  });
2810
2959
  const a = [];
2811
- i = i.filter((c) => {
2812
- if (o.indexOf(c) > -1) return !1;
2813
- if (s.has(c)) {
2814
- const h = s.get(c), d = c.clone();
2960
+ i = i.filter((l) => {
2961
+ if (o.indexOf(l) > -1) return !1;
2962
+ if (s.has(l)) {
2963
+ const h = s.get(l), d = l.clone();
2815
2964
  if (h) {
2816
2965
  for (let p = 0; p < h.length; p += 2) {
2817
- const y = h[p], x = h[p + 1];
2818
- y.userData.length = y.distance(d.start), x.userData.length = x.distance(d.start), y.userData.type = "start", x.userData.type = "end", d.start.distance(y) > d.start.distance(x) && (h[p] = x, h[p + 1] = y, y.userData.type = "end", x.userData.type = "start");
2966
+ const x = h[p], y = h[p + 1];
2967
+ x.userData.length = x.distance(d.start), y.userData.length = y.distance(d.start), x.userData.type = "start", y.userData.type = "end", d.start.distance(x) > d.start.distance(y) && (h[p] = y, h[p + 1] = x, x.userData.type = "end", y.userData.type = "start");
2819
2968
  }
2820
- h.sort((p, y) => p.userData.length - y.userData.length);
2969
+ h.sort((p, x) => p.userData.length - x.userData.length);
2821
2970
  const u = [];
2822
2971
  for (let p = 0; p < h.length; p++) {
2823
- const y = h[p];
2824
- y.userData.type === "start" ? (u.length === 0 && (a.push(new N(d.start.clone(), y.clone())), d.start.copy(y)), u.push("start")) : (u.pop(), u.length === 0 && d.start.copy(y));
2972
+ const x = h[p];
2973
+ x.userData.type === "start" ? (u.length === 0 && (a.push(new R(d.start.clone(), x.clone())), d.start.copy(x)), u.push("start")) : (u.pop(), u.length === 0 && d.start.copy(x));
2825
2974
  }
2826
2975
  a.push(d);
2827
2976
  }
2828
2977
  return !1;
2829
2978
  }
2830
2979
  return !0;
2831
- }), i.push(...r), i.push(...a.filter((c) => c.length() > 0.05));
2832
- const l = t.box.center;
2833
- i = i.map((c) => {
2834
- const h = c.clone();
2835
- return h.start.rotate(l, n.angle * (Math.PI / 180)), h.end.rotate(l, n.angle * (Math.PI / 180)), h;
2980
+ }), i.push(...r), i.push(...a.filter((l) => l.length() > 0.05));
2981
+ const c = t.box.center;
2982
+ i = i.map((l) => {
2983
+ const h = l.clone();
2984
+ return h.start.rotate(c, n.angle * (Math.PI / 180)), h.end.rotate(c, n.angle * (Math.PI / 180)), h;
2836
2985
  }), this.lineSegments = i;
2837
2986
  }
2838
2987
  toJson() {
@@ -2879,7 +3028,7 @@ class ut extends ne {
2879
3028
  };
2880
3029
  if (s.userData.isWindow)
2881
3030
  return s.userData.drawWindow.map((i) => {
2882
- const r = g.from(i.p), o = r.clone().add(
3031
+ const r = w.from(i.p), o = r.clone().add(
2883
3032
  s.direction().multiplyScalar(i.width * 0.5)
2884
3033
  ), a = r.clone().add(
2885
3034
  s.direction().multiplyScalar(-i.width * 0.5)
@@ -2912,10 +3061,10 @@ class ut extends ne {
2912
3061
  if (typeof window < "u") {
2913
3062
  const t = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
2914
3063
  n.href = URL.createObjectURL(t), n.download = e, n.click();
2915
- } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, JSON.stringify(this.toJson()));
3064
+ } else typeof global < "u" && (await ee("fs", !1)).writeFileSync(e, JSON.stringify(this.toJson()));
2916
3065
  }
2917
3066
  }
2918
- class dt extends ot {
3067
+ class lt extends st {
2919
3068
  Dxf;
2920
3069
  AngleCorrectionDxf;
2921
3070
  Variable;
@@ -2926,7 +3075,7 @@ class dt extends ot {
2926
3075
  * @param scale 原始数据缩放比例
2927
3076
  */
2928
3077
  constructor(e = 0.1, t = 1) {
2929
- super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = e, this.Dxf = new $(this.wallWidth, t), this.AngleCorrectionDxf = new ct(), this.Variable = new Ce(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new ht()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new ut());
3078
+ super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = e, this.Dxf = new W(this.wallWidth, t), this.AngleCorrectionDxf = new rt(), this.Variable = new Re(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new at()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new ct());
2930
3079
  }
2931
3080
  usePlugin(e) {
2932
3081
  return typeof e == "function" && e.call(this, this), this;
@@ -2939,7 +3088,7 @@ class dt extends ot {
2939
3088
  });
2940
3089
  }
2941
3090
  }
2942
- const Ae = {
3091
+ const Le = {
2943
3092
  POSITION: [
2944
3093
  "byte",
2945
3094
  "byte normalized",
@@ -2967,36 +3116,36 @@ const Ae = {
2967
3116
  "unsigned short"
2968
3117
  ]
2969
3118
  };
2970
- class he {
3119
+ class ae {
2971
3120
  constructor() {
2972
3121
  this.textureUtils = null, this.pluginCallbacks = [], this.register(function(e) {
2973
- return new Et(e);
3122
+ return new Mt(e);
2974
3123
  }), this.register(function(e) {
2975
- return new Dt(e);
3124
+ return new St(e);
2976
3125
  }), this.register(function(e) {
2977
- return new It(e);
3126
+ return new At(e);
2978
3127
  }), this.register(function(e) {
2979
- return new Rt(e);
3128
+ return new Tt(e);
2980
3129
  }), this.register(function(e) {
2981
- return new Pt(e);
3130
+ return new bt(e);
2982
3131
  }), this.register(function(e) {
2983
- return new vt(e);
3132
+ return new It(e);
2984
3133
  }), this.register(function(e) {
2985
- return new At(e);
3134
+ return new Lt(e);
2986
3135
  }), this.register(function(e) {
2987
- return new Tt(e);
3136
+ return new Et(e);
2988
3137
  }), this.register(function(e) {
2989
- return new bt(e);
3138
+ return new Dt(e);
2990
3139
  }), this.register(function(e) {
2991
- return new Nt(e);
3140
+ return new Pt(e);
2992
3141
  }), this.register(function(e) {
2993
- return new Ct(e);
3142
+ return new Rt(e);
2994
3143
  }), this.register(function(e) {
2995
- return new Bt(e);
3144
+ return new vt(e);
2996
3145
  }), this.register(function(e) {
2997
- return new Ot(e);
3146
+ return new Nt(e);
2998
3147
  }), this.register(function(e) {
2999
- return new Ft(e);
3148
+ return new Ct(e);
3000
3149
  });
3001
3150
  }
3002
3151
  register(e) {
@@ -3009,7 +3158,7 @@ class he {
3009
3158
  return this.textureUtils = e, this;
3010
3159
  }
3011
3160
  parse(e, t, n, s) {
3012
- const i = new Lt(), r = [];
3161
+ const i = new wt(), r = [];
3013
3162
  for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
3014
3163
  r.push(this.pluginCallbacks[o](i));
3015
3164
  i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(e, t, s).catch(n);
@@ -3021,7 +3170,7 @@ class he {
3021
3170
  });
3022
3171
  }
3023
3172
  }
3024
- const C = {
3173
+ const F = {
3025
3174
  POINTS: 0,
3026
3175
  LINES: 1,
3027
3176
  LINE_LOOP: 2,
@@ -3045,34 +3194,34 @@ const C = {
3045
3194
  CLAMP_TO_EDGE: 33071,
3046
3195
  MIRRORED_REPEAT: 33648,
3047
3196
  REPEAT: 10497
3048
- }, fe = "KHR_mesh_quantization", H = {};
3049
- H[Je] = C.NEAREST;
3050
- H[Ke] = C.NEAREST_MIPMAP_NEAREST;
3051
- H[$e] = C.NEAREST_MIPMAP_LINEAR;
3052
- H[Ze] = C.LINEAR;
3053
- H[Qe] = C.LINEAR_MIPMAP_NEAREST;
3054
- H[et] = C.LINEAR_MIPMAP_LINEAR;
3055
- H[tt] = C.CLAMP_TO_EDGE;
3056
- H[nt] = C.REPEAT;
3057
- H[st] = C.MIRRORED_REPEAT;
3058
- const Te = {
3197
+ }, he = "KHR_mesh_quantization", $ = {};
3198
+ $[Ve] = F.NEAREST;
3199
+ $[We] = F.NEAREST_MIPMAP_NEAREST;
3200
+ $[He] = F.NEAREST_MIPMAP_LINEAR;
3201
+ $[Je] = F.LINEAR;
3202
+ $[$e] = F.LINEAR_MIPMAP_NEAREST;
3203
+ $[Ke] = F.LINEAR_MIPMAP_LINEAR;
3204
+ $[Ze] = F.CLAMP_TO_EDGE;
3205
+ $[Qe] = F.REPEAT;
3206
+ $[et] = F.MIRRORED_REPEAT;
3207
+ const Ee = {
3059
3208
  scale: "scale",
3060
3209
  position: "translation",
3061
3210
  quaternion: "rotation",
3062
3211
  morphTargetInfluences: "weights"
3063
- }, ft = new ze(), be = 12, pt = 1179937895, xt = 2, Ie = 8, yt = 1313821514, mt = 5130562;
3064
- function oe(f, e) {
3212
+ }, ht = new Fe(), De = 12, ut = 1179937895, dt = 2, Ae = 8, ft = 1313821514, pt = 5130562;
3213
+ function ne(f, e) {
3065
3214
  return f.length === e.length && f.every(function(t, n) {
3066
3215
  return t === e[n];
3067
3216
  });
3068
3217
  }
3069
- function gt(f) {
3218
+ function yt(f) {
3070
3219
  return new TextEncoder().encode(f).buffer;
3071
3220
  }
3072
- function wt(f) {
3073
- return oe(f.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
3221
+ function xt(f) {
3222
+ return ne(f.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
3074
3223
  }
3075
- function Mt(f, e, t) {
3224
+ function mt(f, e, t) {
3076
3225
  const n = {
3077
3226
  min: new Array(f.itemSize).fill(Number.POSITIVE_INFINITY),
3078
3227
  max: new Array(f.itemSize).fill(Number.NEGATIVE_INFINITY)
@@ -3080,15 +3229,15 @@ function Mt(f, e, t) {
3080
3229
  for (let s = e; s < e + t; s++)
3081
3230
  for (let i = 0; i < f.itemSize; i++) {
3082
3231
  let r;
3083
- f.itemSize > 4 ? r = f.array[s * f.itemSize + i] : (i === 0 ? r = f.getX(s) : i === 1 ? r = f.getY(s) : i === 2 ? r = f.getZ(s) : i === 3 && (r = f.getW(s)), f.normalized === !0 && (r = ye.normalize(r, f.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
3232
+ f.itemSize > 4 ? r = f.array[s * f.itemSize + i] : (i === 0 ? r = f.getX(s) : i === 1 ? r = f.getY(s) : i === 2 ? r = f.getZ(s) : i === 3 && (r = f.getW(s)), f.normalized === !0 && (r = fe.normalize(r, f.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
3084
3233
  }
3085
3234
  return n;
3086
3235
  }
3087
- function Be(f) {
3236
+ function ve(f) {
3088
3237
  return Math.ceil(f / 4) * 4;
3089
3238
  }
3090
- function pe(f, e = 0) {
3091
- const t = Be(f.byteLength);
3239
+ function ue(f, e = 0) {
3240
+ const t = ve(f.byteLength);
3092
3241
  if (t !== f.byteLength) {
3093
3242
  const n = new Uint8Array(t);
3094
3243
  if (n.set(new Uint8Array(f)), e !== 0)
@@ -3098,10 +3247,10 @@ function pe(f, e = 0) {
3098
3247
  }
3099
3248
  return f;
3100
3249
  }
3101
- function Re() {
3250
+ function Te() {
3102
3251
  return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
3103
3252
  }
3104
- function St(f, e) {
3253
+ function gt(f, e) {
3105
3254
  if (typeof OffscreenCanvas < "u" && f instanceof OffscreenCanvas) {
3106
3255
  let t;
3107
3256
  return e === "image/jpeg" ? t = 0.92 : e === "image/webp" && (t = 0.8), f.convertToBlob({
@@ -3111,12 +3260,12 @@ function St(f, e) {
3111
3260
  } else
3112
3261
  return new Promise((t) => f.toBlob(t, e));
3113
3262
  }
3114
- class Lt {
3263
+ class wt {
3115
3264
  constructor() {
3116
3265
  this.plugins = [], this.options = {}, this.pending = [], this.buffers = [], this.byteOffset = 0, this.buffers = [], this.nodeMap = /* @__PURE__ */ new Map(), this.skins = [], this.extensionsUsed = {}, this.extensionsRequired = {}, this.uids = /* @__PURE__ */ new Map(), this.uid = 0, this.json = {
3117
3266
  asset: {
3118
3267
  version: "2.0",
3119
- generator: "THREE.GLTFExporter r" + qe
3268
+ generator: "THREE.GLTFExporter r" + Ge
3120
3269
  }
3121
3270
  }, this.cache = {
3122
3271
  meshes: /* @__PURE__ */ new Map(),
@@ -3152,27 +3301,27 @@ class Lt {
3152
3301
  }, n), this.options.animations.length > 0 && (this.options.trs = !0), await this.processInputAsync(e), await Promise.all(this.pending);
3153
3302
  const s = this, i = s.buffers, r = s.json;
3154
3303
  n = s.options;
3155
- const o = s.extensionsUsed, a = s.extensionsRequired, l = new Blob(i, { type: "application/octet-stream" }), c = Object.keys(o), h = Object.keys(a);
3156
- c.length > 0 && (r.extensionsUsed = c), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = l.size), n.binary === !0 ? xe(l).then(function(d) {
3157
- const u = pe(d), p = new DataView(new ArrayBuffer(Ie));
3158
- p.setUint32(0, u.byteLength, !0), p.setUint32(4, mt, !0);
3159
- const y = pe(gt(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(Ie));
3160
- x.setUint32(0, y.byteLength, !0), x.setUint32(4, yt, !0);
3161
- const S = new ArrayBuffer(be), T = new DataView(S);
3162
- T.setUint32(0, pt, !0), T.setUint32(4, xt, !0);
3163
- const G = be + x.byteLength + y.byteLength + p.byteLength + u.byteLength;
3164
- T.setUint32(8, G, !0);
3165
- const E = new Blob([
3166
- S,
3167
- x,
3304
+ const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
3305
+ l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ? de(c).then(function(d) {
3306
+ const u = ue(d), p = new DataView(new ArrayBuffer(Ae));
3307
+ p.setUint32(0, u.byteLength, !0), p.setUint32(4, pt, !0);
3308
+ const x = ue(yt(JSON.stringify(r)), 32), y = new DataView(new ArrayBuffer(Ae));
3309
+ y.setUint32(0, x.byteLength, !0), y.setUint32(4, ft, !0);
3310
+ const m = new ArrayBuffer(De), M = new DataView(m);
3311
+ M.setUint32(0, ut, !0), M.setUint32(4, dt, !0);
3312
+ const T = De + y.byteLength + x.byteLength + p.byteLength + u.byteLength;
3313
+ M.setUint32(8, T, !0);
3314
+ const g = new Blob([
3315
+ m,
3168
3316
  y,
3317
+ x,
3169
3318
  p,
3170
3319
  u
3171
3320
  ], { type: "application/octet-stream" });
3172
- xe(E).then((R) => {
3173
- t(R);
3321
+ de(g).then((L) => {
3322
+ t(L);
3174
3323
  });
3175
- }) : r.buffers && r.buffers.length > 0 ? Ut(l).then((d) => {
3324
+ }) : r.buffers && r.buffers.length > 0 ? Bt(c).then((d) => {
3176
3325
  r.buffers[0].uri = d, t(r);
3177
3326
  }) : t(r);
3178
3327
  }
@@ -3220,7 +3369,7 @@ class Lt {
3220
3369
  */
3221
3370
  isNormalizedNormalAttribute(e) {
3222
3371
  if (this.cache.attributesNormalized.has(e)) return !1;
3223
- const n = new ce();
3372
+ const n = new ie();
3224
3373
  for (let s = 0, i = e.count; s < i; s++)
3225
3374
  if (Math.abs(n.fromBufferAttribute(e, s).length() - 1) > 5e-4) return !1;
3226
3375
  return !0;
@@ -3235,7 +3384,7 @@ class Lt {
3235
3384
  createNormalizedNormalAttribute(e) {
3236
3385
  const t = this.cache;
3237
3386
  if (t.attributesNormalized.has(e)) return t.attributesNormalized.get(e);
3238
- const n = e.clone(), s = new ce();
3387
+ const n = e.clone(), s = new ie();
3239
3388
  for (let i = 0, r = n.count; i < r; i++)
3240
3389
  s.fromBufferAttribute(n, i), s.x === 0 && s.y === 0 && s.z === 0 ? s.setX(1) : s.normalize(), n.setXYZ(i, s.x, s.y, s.z);
3241
3390
  return t.attributesNormalized.set(e, n), n;
@@ -3255,35 +3404,35 @@ class Lt {
3255
3404
  async buildMetalRoughTextureAsync(e, t) {
3256
3405
  if (e === t) return e;
3257
3406
  function n(u) {
3258
- return u.colorSpace === He ? function(y) {
3259
- return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
3260
- } : function(y) {
3261
- return y;
3407
+ return u.colorSpace === Xe ? function(x) {
3408
+ return x < 0.04045 ? x * 0.0773993808 : Math.pow(x * 0.9478672986 + 0.0521327014, 2.4);
3409
+ } : function(x) {
3410
+ return x;
3262
3411
  };
3263
3412
  }
3264
- e instanceof de && (e = await this.decompressTextureAsync(e)), t instanceof de && (t = await this.decompressTextureAsync(t));
3265
- const s = e ? e.image : null, i = t ? t.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = Re();
3413
+ e instanceof le && (e = await this.decompressTextureAsync(e)), t instanceof le && (t = await this.decompressTextureAsync(t));
3414
+ const s = e ? e.image : null, i = t ? t.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = Te();
3266
3415
  a.width = r, a.height = o;
3267
- const l = a.getContext("2d", {
3416
+ const c = a.getContext("2d", {
3268
3417
  willReadFrequently: !0
3269
3418
  });
3270
- l.fillStyle = "#00ffff", l.fillRect(0, 0, r, o);
3271
- const c = l.getImageData(0, 0, r, o);
3419
+ c.fillStyle = "#00ffff", c.fillRect(0, 0, r, o);
3420
+ const l = c.getImageData(0, 0, r, o);
3272
3421
  if (s) {
3273
- l.drawImage(s, 0, 0, r, o);
3274
- const u = n(e), p = l.getImageData(0, 0, r, o).data;
3275
- for (let y = 2; y < p.length; y += 4)
3276
- c.data[y] = u(p[y] / 256) * 256;
3422
+ c.drawImage(s, 0, 0, r, o);
3423
+ const u = n(e), p = c.getImageData(0, 0, r, o).data;
3424
+ for (let x = 2; x < p.length; x += 4)
3425
+ l.data[x] = u(p[x] / 256) * 256;
3277
3426
  }
3278
3427
  if (i) {
3279
- l.drawImage(i, 0, 0, r, o);
3280
- const u = n(t), p = l.getImageData(0, 0, r, o).data;
3281
- for (let y = 1; y < p.length; y += 4)
3282
- c.data[y] = u(p[y] / 256) * 256;
3428
+ c.drawImage(i, 0, 0, r, o);
3429
+ const u = n(t), p = c.getImageData(0, 0, r, o).data;
3430
+ for (let x = 1; x < p.length; x += 4)
3431
+ l.data[x] = u(p[x] / 256) * 256;
3283
3432
  }
3284
- l.putImageData(c, 0, 0);
3433
+ c.putImageData(l, 0, 0);
3285
3434
  const d = (e || t).clone();
3286
- return d.source = new je(a), d.colorSpace = Ye, d.channel = (e || t).channel, e && t && e.channel !== t.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
3435
+ return d.source = new ze(a), d.colorSpace = qe, d.channel = (e || t).channel, e && t && e.channel !== t.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
3287
3436
  }
3288
3437
  async decompressTextureAsync(e, t = 1 / 0) {
3289
3438
  if (this.textureUtils === null)
@@ -3313,34 +3462,34 @@ class Lt {
3313
3462
  r.bufferViews || (r.bufferViews = []);
3314
3463
  let o;
3315
3464
  switch (t) {
3316
- case C.BYTE:
3317
- case C.UNSIGNED_BYTE:
3465
+ case F.BYTE:
3466
+ case F.UNSIGNED_BYTE:
3318
3467
  o = 1;
3319
3468
  break;
3320
- case C.SHORT:
3321
- case C.UNSIGNED_SHORT:
3469
+ case F.SHORT:
3470
+ case F.UNSIGNED_SHORT:
3322
3471
  o = 2;
3323
3472
  break;
3324
3473
  default:
3325
3474
  o = 4;
3326
3475
  }
3327
3476
  let a = e.itemSize * o;
3328
- i === C.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
3329
- const l = Be(s * a), c = new DataView(new ArrayBuffer(l));
3477
+ i === F.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
3478
+ const c = ve(s * a), l = new DataView(new ArrayBuffer(c));
3330
3479
  let h = 0;
3331
3480
  for (let p = n; p < n + s; p++) {
3332
- for (let y = 0; y < e.itemSize; y++) {
3333
- let x;
3334
- e.itemSize > 4 ? x = e.array[p * e.itemSize + y] : (y === 0 ? x = e.getX(p) : y === 1 ? x = e.getY(p) : y === 2 ? x = e.getZ(p) : y === 3 && (x = e.getW(p)), e.normalized === !0 && (x = ye.normalize(x, e.array))), t === C.FLOAT ? c.setFloat32(h, x, !0) : t === C.INT ? c.setInt32(h, x, !0) : t === C.UNSIGNED_INT ? c.setUint32(h, x, !0) : t === C.SHORT ? c.setInt16(h, x, !0) : t === C.UNSIGNED_SHORT ? c.setUint16(h, x, !0) : t === C.BYTE ? c.setInt8(h, x) : t === C.UNSIGNED_BYTE && c.setUint8(h, x), h += o;
3481
+ for (let x = 0; x < e.itemSize; x++) {
3482
+ let y;
3483
+ e.itemSize > 4 ? y = e.array[p * e.itemSize + x] : (x === 0 ? y = e.getX(p) : x === 1 ? y = e.getY(p) : x === 2 ? y = e.getZ(p) : x === 3 && (y = e.getW(p)), e.normalized === !0 && (y = fe.normalize(y, e.array))), t === F.FLOAT ? l.setFloat32(h, y, !0) : t === F.INT ? l.setInt32(h, y, !0) : t === F.UNSIGNED_INT ? l.setUint32(h, y, !0) : t === F.SHORT ? l.setInt16(h, y, !0) : t === F.UNSIGNED_SHORT ? l.setUint16(h, y, !0) : t === F.BYTE ? l.setInt8(h, y) : t === F.UNSIGNED_BYTE && l.setUint8(h, y), h += o;
3335
3484
  }
3336
3485
  h % a !== 0 && (h += a - h % a);
3337
3486
  }
3338
3487
  const d = {
3339
- buffer: this.processBuffer(c.buffer),
3488
+ buffer: this.processBuffer(l.buffer),
3340
3489
  byteOffset: this.byteOffset,
3341
- byteLength: l
3490
+ byteLength: c
3342
3491
  };
3343
- return i !== void 0 && (d.target = i), i === C.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += l, r.bufferViews.push(d), {
3492
+ return i !== void 0 && (d.target = i), i === F.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
3344
3493
  id: r.bufferViews.length - 1,
3345
3494
  byteLength: 0
3346
3495
  };
@@ -3353,8 +3502,8 @@ class Lt {
3353
3502
  processBufferViewImage(e) {
3354
3503
  const t = this, n = t.json;
3355
3504
  return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
3356
- xe(e).then((i) => {
3357
- const r = pe(i), o = {
3505
+ de(e).then((i) => {
3506
+ const r = ue(i), o = {
3358
3507
  buffer: t.processBuffer(r),
3359
3508
  byteOffset: t.byteOffset,
3360
3509
  byteLength: r.byteLength
@@ -3382,28 +3531,28 @@ class Lt {
3382
3531
  };
3383
3532
  let o;
3384
3533
  if (e.array.constructor === Float32Array)
3385
- o = C.FLOAT;
3534
+ o = F.FLOAT;
3386
3535
  else if (e.array.constructor === Int32Array)
3387
- o = C.INT;
3536
+ o = F.INT;
3388
3537
  else if (e.array.constructor === Uint32Array)
3389
- o = C.UNSIGNED_INT;
3538
+ o = F.UNSIGNED_INT;
3390
3539
  else if (e.array.constructor === Int16Array)
3391
- o = C.SHORT;
3540
+ o = F.SHORT;
3392
3541
  else if (e.array.constructor === Uint16Array)
3393
- o = C.UNSIGNED_SHORT;
3542
+ o = F.UNSIGNED_SHORT;
3394
3543
  else if (e.array.constructor === Int8Array)
3395
- o = C.BYTE;
3544
+ o = F.BYTE;
3396
3545
  else if (e.array.constructor === Uint8Array)
3397
- o = C.UNSIGNED_BYTE;
3546
+ o = F.UNSIGNED_BYTE;
3398
3547
  else
3399
3548
  throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + e.array.constructor.name);
3400
3549
  if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = e.count), s === 0) return null;
3401
- const a = Mt(e, n, s);
3402
- let l;
3403
- t !== void 0 && (l = e === t.index ? C.ELEMENT_ARRAY_BUFFER : C.ARRAY_BUFFER);
3404
- const c = this.processBufferView(e, o, n, s, l), h = {
3405
- bufferView: c.id,
3406
- byteOffset: c.byteOffset,
3550
+ const a = mt(e, n, s);
3551
+ let c;
3552
+ t !== void 0 && (c = e === t.index ? F.ELEMENT_ARRAY_BUFFER : F.ARRAY_BUFFER);
3553
+ const l = this.processBufferView(e, o, n, s, c), h = {
3554
+ bufferView: l.id,
3555
+ byteOffset: l.byteOffset,
3407
3556
  componentType: o,
3408
3557
  count: s,
3409
3558
  max: a.max,
@@ -3422,33 +3571,33 @@ class Lt {
3422
3571
  */
3423
3572
  processImage(e, t, n, s = "image/png") {
3424
3573
  if (e !== null) {
3425
- const i = this, r = i.cache, o = i.json, a = i.options, l = i.pending;
3574
+ const i = this, r = i.cache, o = i.json, a = i.options, c = i.pending;
3426
3575
  r.images.has(e) || r.images.set(e, {});
3427
- const c = r.images.get(e), h = s + ":flipY/" + n.toString();
3428
- if (c[h] !== void 0) return c[h];
3576
+ const l = r.images.get(e), h = s + ":flipY/" + n.toString();
3577
+ if (l[h] !== void 0) return l[h];
3429
3578
  o.images || (o.images = []);
3430
- const d = { mimeType: s }, u = Re();
3579
+ const d = { mimeType: s }, u = Te();
3431
3580
  u.width = Math.min(e.width, a.maxTextureSize), u.height = Math.min(e.height, a.maxTextureSize);
3432
3581
  const p = u.getContext("2d", {
3433
3582
  willReadFrequently: !0
3434
3583
  });
3435
3584
  if (n === !0 && (p.translate(0, u.height), p.scale(1, -1)), e.data !== void 0) {
3436
- t !== ke && console.error("GLTFExporter: Only RGBAFormat is supported.", t), (e.width > a.maxTextureSize || e.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", e);
3437
- const x = new Uint8ClampedArray(e.height * e.width * 4);
3438
- for (let S = 0; S < x.length; S += 4)
3439
- x[S + 0] = e.data[S + 0], x[S + 1] = e.data[S + 1], x[S + 2] = e.data[S + 2], x[S + 3] = e.data[S + 3];
3440
- p.putImageData(new ImageData(x, e.width, e.height), 0, 0);
3585
+ t !== _e && console.error("GLTFExporter: Only RGBAFormat is supported.", t), (e.width > a.maxTextureSize || e.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", e);
3586
+ const y = new Uint8ClampedArray(e.height * e.width * 4);
3587
+ for (let m = 0; m < y.length; m += 4)
3588
+ y[m + 0] = e.data[m + 0], y[m + 1] = e.data[m + 1], y[m + 2] = e.data[m + 2], y[m + 3] = e.data[m + 3];
3589
+ p.putImageData(new ImageData(y, e.width, e.height), 0, 0);
3441
3590
  } else if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)
3442
3591
  p.drawImage(e, 0, 0, u.width, u.height);
3443
3592
  else
3444
3593
  throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
3445
- a.binary === !0 ? l.push(
3446
- St(u, s).then((x) => i.processBufferViewImage(x)).then((x) => {
3447
- d.bufferView = x;
3594
+ a.binary === !0 ? c.push(
3595
+ gt(u, s).then((y) => i.processBufferViewImage(y)).then((y) => {
3596
+ d.bufferView = y;
3448
3597
  })
3449
- ) : d.uri = Xe.getDataURL(u, s);
3450
- const y = o.images.push(d) - 1;
3451
- return c[h] = y, y;
3598
+ ) : d.uri = je.getDataURL(u, s);
3599
+ const x = o.images.push(d) - 1;
3600
+ return l[h] = x, x;
3452
3601
  } else
3453
3602
  throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
3454
3603
  }
@@ -3461,10 +3610,10 @@ class Lt {
3461
3610
  const t = this.json;
3462
3611
  t.samplers || (t.samplers = []);
3463
3612
  const n = {
3464
- magFilter: H[e.magFilter],
3465
- minFilter: H[e.minFilter],
3466
- wrapS: H[e.wrapS],
3467
- wrapT: H[e.wrapT]
3613
+ magFilter: $[e.magFilter],
3614
+ minFilter: $[e.minFilter],
3615
+ wrapS: $[e.wrapS],
3616
+ wrapT: $[e.wrapT]
3468
3617
  };
3469
3618
  return t.samplers.push(n) - 1;
3470
3619
  }
@@ -3476,15 +3625,15 @@ class Lt {
3476
3625
  async processTextureAsync(e) {
3477
3626
  const n = this.options, s = this.cache, i = this.json;
3478
3627
  if (s.textures.has(e)) return s.textures.get(e);
3479
- i.textures || (i.textures = []), e instanceof de && (e = await this.decompressTextureAsync(e, n.maxTextureSize));
3628
+ i.textures || (i.textures = []), e instanceof le && (e = await this.decompressTextureAsync(e, n.maxTextureSize));
3480
3629
  let r = e.userData.mimeType;
3481
3630
  r === "image/webp" && (r = "image/png");
3482
3631
  const o = {
3483
3632
  sampler: this.processSampler(e),
3484
3633
  source: this.processImage(e.image, e.format, e.flipY, r)
3485
3634
  };
3486
- e.name && (o.name = e.name), await this._invokeAllAsync(async function(l) {
3487
- l.writeTexture && await l.writeTexture(e, o);
3635
+ e.name && (o.name = e.name), await this._invokeAllAsync(async function(c) {
3636
+ c.writeTexture && await c.writeTexture(e, o);
3488
3637
  });
3489
3638
  const a = i.textures.push(o) - 1;
3490
3639
  return s.textures.set(e, a), a;
@@ -3503,7 +3652,7 @@ class Lt {
3503
3652
  const s = { pbrMetallicRoughness: {} };
3504
3653
  e.isMeshStandardMaterial !== !0 && e.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
3505
3654
  const i = e.color.toArray().concat([e.opacity]);
3506
- if (oe(i, [1, 1, 1, 1]) || (s.pbrMetallicRoughness.baseColorFactor = i), e.isMeshStandardMaterial ? (s.pbrMetallicRoughness.metallicFactor = e.metalness, s.pbrMetallicRoughness.roughnessFactor = e.roughness) : (s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 1), e.metalnessMap || e.roughnessMap) {
3655
+ if (ne(i, [1, 1, 1, 1]) || (s.pbrMetallicRoughness.baseColorFactor = i), e.isMeshStandardMaterial ? (s.pbrMetallicRoughness.metallicFactor = e.metalness, s.pbrMetallicRoughness.roughnessFactor = e.roughness) : (s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 1), e.metalnessMap || e.roughnessMap) {
3507
3656
  const o = await this.buildMetalRoughTextureAsync(e.metalnessMap, e.roughnessMap), a = {
3508
3657
  index: await this.processTextureAsync(o),
3509
3658
  texCoord: o.channel
@@ -3520,11 +3669,11 @@ class Lt {
3520
3669
  if (e.emissive) {
3521
3670
  const o = e.emissive;
3522
3671
  if (Math.max(o.r, o.g, o.b) > 0 && (s.emissiveFactor = e.emissive.toArray()), e.emissiveMap) {
3523
- const l = {
3672
+ const c = {
3524
3673
  index: await this.processTextureAsync(e.emissiveMap),
3525
3674
  texCoord: e.emissiveMap.channel
3526
3675
  };
3527
- this.applyTextureTransform(l, e.emissiveMap), s.emissiveTexture = l;
3676
+ this.applyTextureTransform(c, e.emissiveMap), s.emissiveTexture = c;
3528
3677
  }
3529
3678
  }
3530
3679
  if (e.normalMap) {
@@ -3541,7 +3690,7 @@ class Lt {
3541
3690
  };
3542
3691
  e.aoMapIntensity !== 1 && (o.strength = e.aoMapIntensity), this.applyTextureTransform(o, e.aoMap), s.occlusionTexture = o;
3543
3692
  }
3544
- e.transparent ? s.alphaMode = "BLEND" : e.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = e.alphaTest), e.side === Ve && (s.doubleSided = !0), e.name !== "" && (s.name = e.name), this.serializeUserData(e, s), await this._invokeAllAsync(async function(o) {
3693
+ e.transparent ? s.alphaMode = "BLEND" : e.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = e.alphaTest), e.side === Ye && (s.doubleSided = !0), e.name !== "" && (s.name = e.name), this.serializeUserData(e, s), await this._invokeAllAsync(async function(o) {
3545
3694
  o.writeMaterialAsync && await o.writeMaterialAsync(e, s);
3546
3695
  });
3547
3696
  const r = n.materials.push(s) - 1;
@@ -3555,16 +3704,16 @@ class Lt {
3555
3704
  async processMeshAsync(e) {
3556
3705
  const t = this.cache, n = this.json, s = [e.geometry.uuid];
3557
3706
  if (Array.isArray(e.material))
3558
- for (let E = 0, R = e.material.length; E < R; E++)
3559
- s.push(e.material[E].uuid);
3707
+ for (let g = 0, L = e.material.length; g < L; g++)
3708
+ s.push(e.material[g].uuid);
3560
3709
  else
3561
3710
  s.push(e.material.uuid);
3562
3711
  const i = s.join(":");
3563
3712
  if (t.meshes.has(i)) return t.meshes.get(i);
3564
3713
  const r = e.geometry;
3565
3714
  let o;
3566
- e.isLineSegments ? o = C.LINES : e.isLineLoop ? o = C.LINE_LOOP : e.isLine ? o = C.LINE_STRIP : e.isPoints ? o = C.POINTS : o = e.material.wireframe ? C.LINES : C.TRIANGLES;
3567
- const a = {}, l = {}, c = [], h = [], d = {
3715
+ e.isLineSegments ? o = F.LINES : e.isLineLoop ? o = F.LINE_LOOP : e.isLine ? o = F.LINE_STRIP : e.isPoints ? o = F.POINTS : o = e.material.wireframe ? F.LINES : F.TRIANGLES;
3716
+ const a = {}, c = {}, l = [], h = [], d = {
3568
3717
  uv: "TEXCOORD_0",
3569
3718
  uv1: "TEXCOORD_1",
3570
3719
  uv2: "TEXCOORD_2",
@@ -3575,76 +3724,76 @@ class Lt {
3575
3724
  }, u = r.getAttribute("normal");
3576
3725
  u !== void 0 && !this.isNormalizedNormalAttribute(u) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(u)));
3577
3726
  let p = null;
3578
- for (let E in r.attributes) {
3579
- if (E.slice(0, 5) === "morph") continue;
3580
- const R = r.attributes[E];
3581
- if (E = d[E] || E.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(E) || (E = "_" + E), t.attributes.has(this.getUID(R))) {
3582
- l[E] = t.attributes.get(this.getUID(R));
3727
+ for (let g in r.attributes) {
3728
+ if (g.slice(0, 5) === "morph") continue;
3729
+ const L = r.attributes[g];
3730
+ if (g = d[g] || g.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g) || (g = "_" + g), t.attributes.has(this.getUID(L))) {
3731
+ c[g] = t.attributes.get(this.getUID(L));
3583
3732
  continue;
3584
3733
  }
3585
3734
  p = null;
3586
- const P = R.array;
3587
- E === "JOINTS_0" && !(P instanceof Uint16Array) && !(P instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new te(new Uint16Array(P), R.itemSize, R.normalized)) : (P instanceof Uint32Array || P instanceof Int32Array) && !E.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${E}" converted to type FLOAT.`), p = he.Utils.toFloat32BufferAttribute(R));
3588
- const O = this.processAccessor(p || R, r);
3589
- O !== null && (E.startsWith("_") || this.detectMeshQuantization(E, R), l[E] = O, t.attributes.set(this.getUID(R), O));
3735
+ const P = L.array;
3736
+ g === "JOINTS_0" && !(P instanceof Uint16Array) && !(P instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new Z(new Uint16Array(P), L.itemSize, L.normalized)) : (P instanceof Uint32Array || P instanceof Int32Array) && !g.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${g}" converted to type FLOAT.`), p = ae.Utils.toFloat32BufferAttribute(L));
3737
+ const N = this.processAccessor(p || L, r);
3738
+ N !== null && (g.startsWith("_") || this.detectMeshQuantization(g, L), c[g] = N, t.attributes.set(this.getUID(L), N));
3590
3739
  }
3591
- if (u !== void 0 && r.setAttribute("normal", u), Object.keys(l).length === 0) return null;
3740
+ if (u !== void 0 && r.setAttribute("normal", u), Object.keys(c).length === 0) return null;
3592
3741
  if (e.morphTargetInfluences !== void 0 && e.morphTargetInfluences.length > 0) {
3593
- const E = [], R = [], U = {};
3742
+ const g = [], L = [], O = {};
3594
3743
  if (e.morphTargetDictionary !== void 0)
3595
3744
  for (const P in e.morphTargetDictionary)
3596
- U[e.morphTargetDictionary[P]] = P;
3745
+ O[e.morphTargetDictionary[P]] = P;
3597
3746
  for (let P = 0; P < e.morphTargetInfluences.length; ++P) {
3598
- const O = {};
3599
- let X = !1;
3747
+ const N = {};
3748
+ let Y = !1;
3600
3749
  for (const k in r.morphAttributes) {
3601
3750
  if (k !== "position" && k !== "normal") {
3602
- X || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), X = !0);
3751
+ Y || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), Y = !0);
3603
3752
  continue;
3604
3753
  }
3605
- const W = r.morphAttributes[k][P], J = k.toUpperCase(), V = r.attributes[k];
3606
- if (t.attributes.has(this.getUID(W, !0))) {
3607
- O[J] = t.attributes.get(this.getUID(W, !0));
3754
+ const V = r.morphAttributes[k][P], X = k.toUpperCase(), b = r.attributes[k];
3755
+ if (t.attributes.has(this.getUID(V, !0))) {
3756
+ N[X] = t.attributes.get(this.getUID(V, !0));
3608
3757
  continue;
3609
3758
  }
3610
- const D = W.clone();
3759
+ const v = V.clone();
3611
3760
  if (!r.morphTargetsRelative)
3612
- for (let b = 0, L = W.count; b < L; b++)
3613
- for (let M = 0; M < W.itemSize; M++)
3614
- M === 0 && D.setX(b, W.getX(b) - V.getX(b)), M === 1 && D.setY(b, W.getY(b) - V.getY(b)), M === 2 && D.setZ(b, W.getZ(b) - V.getZ(b)), M === 3 && D.setW(b, W.getW(b) - V.getW(b));
3615
- O[J] = this.processAccessor(D, r), t.attributes.set(this.getUID(V, !0), O[J]);
3761
+ for (let E = 0, A = V.count; E < A; E++)
3762
+ for (let S = 0; S < V.itemSize; S++)
3763
+ S === 0 && v.setX(E, V.getX(E) - b.getX(E)), S === 1 && v.setY(E, V.getY(E) - b.getY(E)), S === 2 && v.setZ(E, V.getZ(E) - b.getZ(E)), S === 3 && v.setW(E, V.getW(E) - b.getW(E));
3764
+ N[X] = this.processAccessor(v, r), t.attributes.set(this.getUID(b, !0), N[X]);
3616
3765
  }
3617
- h.push(O), E.push(e.morphTargetInfluences[P]), e.morphTargetDictionary !== void 0 && R.push(U[P]);
3766
+ h.push(N), g.push(e.morphTargetInfluences[P]), e.morphTargetDictionary !== void 0 && L.push(O[P]);
3618
3767
  }
3619
- a.weights = E, R.length > 0 && (a.extras = {}, a.extras.targetNames = R);
3768
+ a.weights = g, L.length > 0 && (a.extras = {}, a.extras.targetNames = L);
3620
3769
  }
3621
- const y = Array.isArray(e.material);
3622
- if (y && r.groups.length === 0) return null;
3623
- let x = !1;
3624
- if (y && r.index === null) {
3625
- const E = [];
3626
- for (let R = 0, U = r.attributes.position.count; R < U; R++)
3627
- E[R] = R;
3628
- r.setIndex(E), x = !0;
3770
+ const x = Array.isArray(e.material);
3771
+ if (x && r.groups.length === 0) return null;
3772
+ let y = !1;
3773
+ if (x && r.index === null) {
3774
+ const g = [];
3775
+ for (let L = 0, O = r.attributes.position.count; L < O; L++)
3776
+ g[L] = L;
3777
+ r.setIndex(g), y = !0;
3629
3778
  }
3630
- const S = y ? e.material : [e.material], T = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
3631
- for (let E = 0, R = T.length; E < R; E++) {
3632
- const U = {
3779
+ const m = x ? e.material : [e.material], M = x ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
3780
+ for (let g = 0, L = M.length; g < L; g++) {
3781
+ const O = {
3633
3782
  mode: o,
3634
- attributes: l
3783
+ attributes: c
3635
3784
  };
3636
- if (this.serializeUserData(r, U), h.length > 0 && (U.targets = h), r.index !== null) {
3637
- let O = this.getUID(r.index);
3638
- (T[E].start !== void 0 || T[E].count !== void 0) && (O += ":" + T[E].start + ":" + T[E].count), t.attributes.has(O) ? U.indices = t.attributes.get(O) : (U.indices = this.processAccessor(r.index, r, T[E].start, T[E].count), t.attributes.set(O, U.indices)), U.indices === null && delete U.indices;
3785
+ if (this.serializeUserData(r, O), h.length > 0 && (O.targets = h), r.index !== null) {
3786
+ let N = this.getUID(r.index);
3787
+ (M[g].start !== void 0 || M[g].count !== void 0) && (N += ":" + M[g].start + ":" + M[g].count), t.attributes.has(N) ? O.indices = t.attributes.get(N) : (O.indices = this.processAccessor(r.index, r, M[g].start, M[g].count), t.attributes.set(N, O.indices)), O.indices === null && delete O.indices;
3639
3788
  }
3640
- const P = await this.processMaterialAsync(S[T[E].materialIndex]);
3641
- P !== null && (U.material = P), c.push(U);
3789
+ const P = await this.processMaterialAsync(m[M[g].materialIndex]);
3790
+ P !== null && (O.material = P), l.push(O);
3642
3791
  }
3643
- x === !0 && r.setIndex(null), a.primitives = c, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(E) {
3644
- E.writeMesh && E.writeMesh(e, a);
3792
+ y === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(g) {
3793
+ g.writeMesh && g.writeMesh(e, a);
3645
3794
  });
3646
- const G = n.meshes.push(a) - 1;
3647
- return t.meshes.set(i, G), G;
3795
+ const T = n.meshes.push(a) - 1;
3796
+ return t.meshes.set(i, T), T;
3648
3797
  }
3649
3798
  /**
3650
3799
  * If a vertex attribute with a
@@ -3658,7 +3807,7 @@ class Lt {
3658
3807
  * @param {THREE.BufferAttribute} attribute
3659
3808
  */
3660
3809
  detectMeshQuantization(e, t) {
3661
- if (this.extensionsUsed[fe]) return;
3810
+ if (this.extensionsUsed[he]) return;
3662
3811
  let n;
3663
3812
  switch (t.array.constructor) {
3664
3813
  case Int8Array:
@@ -3678,7 +3827,7 @@ class Lt {
3678
3827
  }
3679
3828
  t.normalized && (n += " normalized");
3680
3829
  const s = e.split("_", 1)[0];
3681
- Ae[s] && Ae[s].includes(n) && (this.extensionsUsed[fe] = !0, this.extensionsRequired[fe] = !0);
3830
+ Le[s] && Le[s].includes(n) && (this.extensionsUsed[he] = !0, this.extensionsRequired[he] = !0);
3682
3831
  }
3683
3832
  /**
3684
3833
  * Process camera
@@ -3698,7 +3847,7 @@ class Lt {
3698
3847
  znear: e.near < 0 ? 0 : e.near
3699
3848
  } : s.perspective = {
3700
3849
  aspectRatio: e.aspect,
3701
- yfov: ye.degToRad(e.fov),
3850
+ yfov: fe.degToRad(e.fov),
3702
3851
  zfar: e.far <= 0 ? 1e-3 : e.far,
3703
3852
  znear: e.near < 0 ? 0 : e.near
3704
3853
  }, e.name !== "" && (s.name = e.type), t.cameras.push(s) - 1;
@@ -3715,24 +3864,24 @@ class Lt {
3715
3864
  */
3716
3865
  processAnimation(e, t) {
3717
3866
  const n = this.json, s = this.nodeMap;
3718
- n.animations || (n.animations = []), e = he.Utils.mergeMorphTargetTracks(e.clone(), t);
3867
+ n.animations || (n.animations = []), e = ae.Utils.mergeMorphTargetTracks(e.clone(), t);
3719
3868
  const i = e.tracks, r = [], o = [];
3720
- for (let l = 0; l < i.length; ++l) {
3721
- const c = i[l], h = le.parseTrackName(c.name);
3722
- let d = le.findNode(t, h.nodeName);
3723
- const u = Te[h.propertyName];
3869
+ for (let c = 0; c < i.length; ++c) {
3870
+ const l = i[c], h = re.parseTrackName(l.name);
3871
+ let d = re.findNode(t, h.nodeName);
3872
+ const u = Ee[h.propertyName];
3724
3873
  if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !u) {
3725
- console.warn('THREE.GLTFExporter: Could not export animation track "%s".', c.name);
3874
+ console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
3726
3875
  continue;
3727
3876
  }
3728
3877
  const p = 1;
3729
- let y = c.values.length / c.times.length;
3730
- u === Te.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
3731
- let x;
3732
- c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() === We ? x = "STEP" : x = "LINEAR", o.push({
3733
- input: this.processAccessor(new te(c.times, p)),
3734
- output: this.processAccessor(new te(c.values, y)),
3735
- interpolation: x
3878
+ let x = l.values.length / l.times.length;
3879
+ u === Ee.morphTargetInfluences && (x /= d.morphTargetInfluences.length);
3880
+ let y;
3881
+ l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (y = "CUBICSPLINE", x /= 3) : l.getInterpolation() === ke ? y = "STEP" : y = "LINEAR", o.push({
3882
+ input: this.processAccessor(new Z(l.times, p)),
3883
+ output: this.processAccessor(new Z(l.values, x)),
3884
+ interpolation: y
3736
3885
  }), r.push({
3737
3886
  sampler: o.length - 1,
3738
3887
  target: {
@@ -3757,11 +3906,11 @@ class Lt {
3757
3906
  if (i === void 0) return null;
3758
3907
  const r = e.skeleton.bones[0];
3759
3908
  if (r === void 0) return null;
3760
- const o = [], a = new Float32Array(i.bones.length * 16), l = new ve();
3909
+ const o = [], a = new Float32Array(i.bones.length * 16), c = new Ie();
3761
3910
  for (let h = 0; h < i.bones.length; ++h)
3762
- o.push(n.get(i.bones[h])), l.copy(i.boneInverses[h]), l.multiply(e.bindMatrix).toArray(a, h * 16);
3911
+ o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(e.bindMatrix).toArray(a, h * 16);
3763
3912
  return t.skins === void 0 && (t.skins = []), t.skins.push({
3764
- inverseBindMatrices: this.processAccessor(new te(a, 16)),
3913
+ inverseBindMatrices: this.processAccessor(new Z(a, 16)),
3765
3914
  joints: o,
3766
3915
  skeleton: n.get(r)
3767
3916
  }), s.skin = t.skins.length - 1;
@@ -3776,10 +3925,10 @@ class Lt {
3776
3925
  t.nodes || (t.nodes = []);
3777
3926
  const i = {};
3778
3927
  if (n.trs) {
3779
- const o = e.quaternion.toArray(), a = e.position.toArray(), l = e.scale.toArray();
3780
- oe(o, [0, 0, 0, 1]) || (i.rotation = o), oe(a, [0, 0, 0]) || (i.translation = a), oe(l, [1, 1, 1]) || (i.scale = l);
3928
+ const o = e.quaternion.toArray(), a = e.position.toArray(), c = e.scale.toArray();
3929
+ ne(o, [0, 0, 0, 1]) || (i.rotation = o), ne(a, [0, 0, 0]) || (i.translation = a), ne(c, [1, 1, 1]) || (i.scale = c);
3781
3930
  } else
3782
- e.matrixAutoUpdate && e.updateMatrix(), wt(e.matrix) === !1 && (i.matrix = e.matrix.elements);
3931
+ e.matrixAutoUpdate && e.updateMatrix(), xt(e.matrix) === !1 && (i.matrix = e.matrix.elements);
3783
3932
  if (e.name !== "" && (i.name = String(e.name)), this.serializeUserData(e, i), e.isMesh || e.isLine || e.isPoints) {
3784
3933
  const o = await this.processMeshAsync(e);
3785
3934
  o !== null && (i.mesh = o);
@@ -3788,10 +3937,10 @@ class Lt {
3788
3937
  const r = t.nodes.push(i) - 1;
3789
3938
  if (s.set(e, r), e.children.length > 0) {
3790
3939
  const o = [];
3791
- for (let a = 0, l = e.children.length; a < l; a++) {
3792
- const c = e.children[a];
3793
- if (c.visible || n.onlyVisible === !1) {
3794
- const h = await this.processNodeAsync(c);
3940
+ for (let a = 0, c = e.children.length; a < c; a++) {
3941
+ const l = e.children[a];
3942
+ if (l.visible || n.onlyVisible === !1) {
3943
+ const h = await this.processNodeAsync(l);
3795
3944
  h !== null && o.push(h);
3796
3945
  }
3797
3946
  }
@@ -3814,8 +3963,8 @@ class Lt {
3814
3963
  for (let r = 0, o = e.children.length; r < o; r++) {
3815
3964
  const a = e.children[r];
3816
3965
  if (a.visible || n.onlyVisible === !1) {
3817
- const l = await this.processNodeAsync(a);
3818
- l !== null && i.push(l);
3966
+ const c = await this.processNodeAsync(a);
3967
+ c !== null && i.push(c);
3819
3968
  }
3820
3969
  }
3821
3970
  i.length > 0 && (s.nodes = i), this.serializeUserData(e, s);
@@ -3825,7 +3974,7 @@ class Lt {
3825
3974
  * @param {Array<THREE.Object3D>} objects List of objects to process
3826
3975
  */
3827
3976
  async processObjectsAsync(e) {
3828
- const t = new Se();
3977
+ const t = new ge();
3829
3978
  t.name = "AuxScene";
3830
3979
  for (let n = 0; n < e.length; n++)
3831
3980
  t.children.push(e[n]);
@@ -3841,7 +3990,7 @@ class Lt {
3841
3990
  });
3842
3991
  const n = [];
3843
3992
  for (let s = 0; s < e.length; s++)
3844
- e[s] instanceof Se ? await this.processSceneAsync(e[s]) : n.push(e[s]);
3993
+ e[s] instanceof ge ? await this.processSceneAsync(e[s]) : n.push(e[s]);
3845
3994
  n.length > 0 && await this.processObjectsAsync(n);
3846
3995
  for (let s = 0; s < this.skins.length; ++s)
3847
3996
  this.processSkin(this.skins[s]);
@@ -3856,7 +4005,7 @@ class Lt {
3856
4005
  await e(this.plugins[t]);
3857
4006
  }
3858
4007
  }
3859
- class Et {
4008
+ class Mt {
3860
4009
  constructor(e) {
3861
4010
  this.writer = e, this.name = "KHR_lights_punctual";
3862
4011
  }
@@ -3872,7 +4021,7 @@ class Et {
3872
4021
  o.push(r), t.extensions = t.extensions || {}, t.extensions[this.name] = { light: o.length - 1 };
3873
4022
  }
3874
4023
  }
3875
- class Dt {
4024
+ class St {
3876
4025
  constructor(e) {
3877
4026
  this.writer = e, this.name = "KHR_materials_unlit";
3878
4027
  }
@@ -3882,7 +4031,7 @@ class Dt {
3882
4031
  t.extensions = t.extensions || {}, t.extensions[this.name] = {}, s[this.name] = !0, t.pbrMetallicRoughness.metallicFactor = 0, t.pbrMetallicRoughness.roughnessFactor = 0.9;
3883
4032
  }
3884
4033
  }
3885
- class At {
4034
+ class Lt {
3886
4035
  constructor(e) {
3887
4036
  this.writer = e, this.name = "KHR_materials_clearcoat";
3888
4037
  }
@@ -3913,7 +4062,7 @@ class At {
3913
4062
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3914
4063
  }
3915
4064
  }
3916
- class Tt {
4065
+ class Et {
3917
4066
  constructor(e) {
3918
4067
  this.writer = e, this.name = "KHR_materials_dispersion";
3919
4068
  }
@@ -3923,7 +4072,7 @@ class Tt {
3923
4072
  i.dispersion = e.dispersion, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3924
4073
  }
3925
4074
  }
3926
- class bt {
4075
+ class Dt {
3927
4076
  constructor(e) {
3928
4077
  this.writer = e, this.name = "KHR_materials_iridescence";
3929
4078
  }
@@ -3947,7 +4096,7 @@ class bt {
3947
4096
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3948
4097
  }
3949
4098
  }
3950
- class It {
4099
+ class At {
3951
4100
  constructor(e) {
3952
4101
  this.writer = e, this.name = "KHR_materials_transmission";
3953
4102
  }
@@ -3964,7 +4113,7 @@ class It {
3964
4113
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3965
4114
  }
3966
4115
  }
3967
- class Rt {
4116
+ class Tt {
3968
4117
  constructor(e) {
3969
4118
  this.writer = e, this.name = "KHR_materials_volume";
3970
4119
  }
@@ -3981,7 +4130,7 @@ class Rt {
3981
4130
  e.attenuationDistance !== 1 / 0 && (i.attenuationDistance = e.attenuationDistance), i.attenuationColor = e.attenuationColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3982
4131
  }
3983
4132
  }
3984
- class Pt {
4133
+ class bt {
3985
4134
  constructor(e) {
3986
4135
  this.writer = e, this.name = "KHR_materials_ior";
3987
4136
  }
@@ -3991,12 +4140,12 @@ class Pt {
3991
4140
  i.ior = e.ior, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3992
4141
  }
3993
4142
  }
3994
- class vt {
4143
+ class It {
3995
4144
  constructor(e) {
3996
4145
  this.writer = e, this.name = "KHR_materials_specular";
3997
4146
  }
3998
4147
  async writeMaterialAsync(e, t) {
3999
- if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(ft) && !e.specularIntensityMap && !e.specularColorMap) return;
4148
+ if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(ht) && !e.specularIntensityMap && !e.specularColorMap) return;
4000
4149
  const n = this.writer, s = n.extensionsUsed, i = {};
4001
4150
  if (e.specularIntensityMap) {
4002
4151
  const r = {
@@ -4015,7 +4164,7 @@ class vt {
4015
4164
  i.specularFactor = e.specularIntensity, i.specularColorFactor = e.specularColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
4016
4165
  }
4017
4166
  }
4018
- class Nt {
4167
+ class Pt {
4019
4168
  constructor(e) {
4020
4169
  this.writer = e, this.name = "KHR_materials_sheen";
4021
4170
  }
@@ -4039,7 +4188,7 @@ class Nt {
4039
4188
  i.sheenRoughnessFactor = e.sheenRoughness, i.sheenColorFactor = e.sheenColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
4040
4189
  }
4041
4190
  }
4042
- class Ct {
4191
+ class Rt {
4043
4192
  constructor(e) {
4044
4193
  this.writer = e, this.name = "KHR_materials_anisotropy";
4045
4194
  }
@@ -4053,7 +4202,7 @@ class Ct {
4053
4202
  i.anisotropyStrength = e.anisotropy, i.anisotropyRotation = e.anisotropyRotation, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
4054
4203
  }
4055
4204
  }
4056
- class Bt {
4205
+ class vt {
4057
4206
  constructor(e) {
4058
4207
  this.writer = e, this.name = "KHR_materials_emissive_strength";
4059
4208
  }
@@ -4063,7 +4212,7 @@ class Bt {
4063
4212
  i.emissiveStrength = e.emissiveIntensity, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
4064
4213
  }
4065
4214
  }
4066
- class Ot {
4215
+ class Nt {
4067
4216
  constructor(e) {
4068
4217
  this.writer = e, this.name = "EXT_materials_bump";
4069
4218
  }
@@ -4080,24 +4229,24 @@ class Ot {
4080
4229
  i.bumpFactor = e.bumpScale, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
4081
4230
  }
4082
4231
  }
4083
- class Ft {
4232
+ class Ct {
4084
4233
  constructor(e) {
4085
4234
  this.writer = e, this.name = "EXT_mesh_gpu_instancing";
4086
4235
  }
4087
4236
  writeNode(e, t) {
4088
4237
  if (!e.isInstancedMesh) return;
4089
- const n = this.writer, s = e, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new ve(), l = new ce(), c = new _e(), h = new ce();
4238
+ const n = this.writer, s = e, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Ie(), c = new ie(), l = new Ue(), h = new ie();
4090
4239
  for (let u = 0; u < s.count; u++)
4091
- s.getMatrixAt(u, a), a.decompose(l, c, h), l.toArray(i, u * 3), c.toArray(r, u * 4), h.toArray(o, u * 3);
4240
+ s.getMatrixAt(u, a), a.decompose(c, l, h), c.toArray(i, u * 3), l.toArray(r, u * 4), h.toArray(o, u * 3);
4092
4241
  const d = {
4093
- TRANSLATION: n.processAccessor(new te(i, 3)),
4094
- ROTATION: n.processAccessor(new te(r, 4)),
4095
- SCALE: n.processAccessor(new te(o, 3))
4242
+ TRANSLATION: n.processAccessor(new Z(i, 3)),
4243
+ ROTATION: n.processAccessor(new Z(r, 4)),
4244
+ SCALE: n.processAccessor(new Z(o, 3))
4096
4245
  };
4097
4246
  s.instanceColor && (d._COLOR_0 = n.processAccessor(s.instanceColor)), t.extensions = t.extensions || {}, t.extensions[this.name] = { attributes: d }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
4098
4247
  }
4099
4248
  }
4100
- he.Utils = {
4249
+ ae.Utils = {
4101
4250
  insertKeyframe: function(f, e) {
4102
4251
  const n = f.getValueSize(), s = new f.TimeBufferType(f.times.length + 1), i = new f.ValueBufferType(f.values.length + n), r = f.createInterpolant(new f.ValueBufferType(n));
4103
4252
  let o;
@@ -4127,7 +4276,7 @@ he.Utils = {
4127
4276
  const t = [], n = {}, s = f.tracks;
4128
4277
  for (let i = 0; i < s.length; ++i) {
4129
4278
  let r = s[i];
4130
- const o = le.parseTrackName(r.name), a = le.findNode(e, o.nodeName);
4279
+ const o = re.parseTrackName(r.name), a = re.findNode(e, o.nodeName);
4131
4280
  if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
4132
4281
  t.push(r);
4133
4282
  continue;
@@ -4135,33 +4284,33 @@ he.Utils = {
4135
4284
  if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
4136
4285
  if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
4137
4286
  throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
4138
- console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(it);
4287
+ console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(tt);
4139
4288
  }
4140
- const l = a.morphTargetInfluences.length, c = a.morphTargetDictionary[o.propertyIndex];
4141
- if (c === void 0)
4289
+ const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
4290
+ if (l === void 0)
4142
4291
  throw new Error("THREE.GLTFExporter: Morph target name not found: " + o.propertyIndex);
4143
4292
  let h;
4144
4293
  if (n[a.uuid] === void 0) {
4145
4294
  h = r.clone();
4146
- const u = new h.ValueBufferType(l * h.times.length);
4295
+ const u = new h.ValueBufferType(c * h.times.length);
4147
4296
  for (let p = 0; p < h.times.length; p++)
4148
- u[p * l + c] = h.values[p];
4297
+ u[p * c + l] = h.values[p];
4149
4298
  h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = u, n[a.uuid] = h, t.push(h);
4150
4299
  continue;
4151
4300
  }
4152
4301
  const d = r.createInterpolant(new r.ValueBufferType(1));
4153
4302
  h = n[a.uuid];
4154
4303
  for (let u = 0; u < h.times.length; u++)
4155
- h.values[u * l + c] = d.evaluate(h.times[u]);
4304
+ h.values[u * c + l] = d.evaluate(h.times[u]);
4156
4305
  for (let u = 0; u < r.times.length; u++) {
4157
4306
  const p = this.insertKeyframe(h, r.times[u]);
4158
- h.values[p * l + c] = r.values[u];
4307
+ h.values[p * c + l] = r.values[u];
4159
4308
  }
4160
4309
  }
4161
4310
  return f.tracks = t, f;
4162
4311
  },
4163
4312
  toFloat32BufferAttribute: function(f) {
4164
- const e = new te(new Float32Array(f.count * f.itemSize), f.itemSize, !1);
4313
+ const e = new Z(new Float32Array(f.count * f.itemSize), f.itemSize, !1);
4165
4314
  if (!f.normalized && !f.isInterleavedBufferAttribute)
4166
4315
  return e.array.set(f.array), e;
4167
4316
  for (let t = 0, n = f.count; t < n; t++)
@@ -4170,7 +4319,7 @@ he.Utils = {
4170
4319
  return e;
4171
4320
  }
4172
4321
  };
4173
- async function Ut(f) {
4322
+ async function Bt(f) {
4174
4323
  if (typeof FileReader > "u") {
4175
4324
  const e = await f.arrayBuffer(), n = Buffer.from(e).toString("base64");
4176
4325
  return `data:${f.type};base64,${n}`;
@@ -4180,7 +4329,7 @@ async function Ut(f) {
4180
4329
  n.onload = () => e(n.result), n.onerror = () => t(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(f);
4181
4330
  });
4182
4331
  }
4183
- async function xe(f) {
4332
+ async function de(f) {
4184
4333
  if (typeof f.arrayBuffer == "function")
4185
4334
  return await f.arrayBuffer();
4186
4335
  if (typeof FileReader < "u")
@@ -4193,23 +4342,23 @@ async function xe(f) {
4193
4342
  return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
4194
4343
  }
4195
4344
  }
4196
- const Gt = new rt(), zt = new he();
4197
- function _t(f, e, t = 0.1) {
4345
+ const Ot = new nt(), Ft = new ae();
4346
+ function Ut(f, e, t = 0.1) {
4198
4347
  const n = e.normal(f), s = e.direction(f).mutiplyScalar(t * 0.5), i = f.direction(e).mutiplyScalar(t * 0.5), r = n.x * t * 0.5, o = n.y * t * 0.5;
4199
4348
  return {
4200
4349
  points: [
4201
4350
  // 第一条线
4202
- new g(f.x + r, f.y + o).add(i),
4203
- new g(e.x + r, e.y + o).add(s),
4351
+ new w(f.x + r, f.y + o).add(i),
4352
+ new w(e.x + r, e.y + o).add(s),
4204
4353
  // 第二条线
4205
- new g(f.x - r, f.y - o).add(i),
4206
- new g(e.x - r, e.y - o).add(s)
4354
+ new w(f.x - r, f.y - o).add(i),
4355
+ new w(e.x - r, e.y - o).add(s)
4207
4356
  ],
4208
4357
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
4209
4358
  rectIndices: [0, 1, 3, 2, 0]
4210
4359
  };
4211
4360
  }
4212
- class Oe extends ne {
4361
+ class Ne extends Q {
4213
4362
  static name = "WhiteModel";
4214
4363
  Dxf = null;
4215
4364
  Variable = null;
@@ -4239,18 +4388,18 @@ class Oe extends ne {
4239
4388
  new z.LineSegments(new z.EdgesGeometry(i), new z.LineBasicMaterial({ color: 0 }))
4240
4389
  );
4241
4390
  }), e.originalData.map(({ start: n, end: s, insetionArr: i }) => {
4242
- const r = new g(n.x, n.y).mutiplyScalar(e.scale), o = new g(s.x, s.y).mutiplyScalar(e.scale), { points: a, indices: l, rectIndices: c } = _t(r, o, e.width);
4391
+ const r = new w(n.x, n.y).mutiplyScalar(e.scale), o = new w(s.x, s.y).mutiplyScalar(e.scale), { points: a, indices: c, rectIndices: l } = Ut(r, o, e.width);
4243
4392
  return {
4244
4393
  points: a,
4245
- indices: l,
4246
- rectIndices: c,
4394
+ indices: c,
4395
+ rectIndices: l,
4247
4396
  insetions: (i ?? []).map((h) => h.index)
4248
4397
  };
4249
4398
  }).forEach((n) => {
4250
4399
  const s = new z.Shape();
4251
4400
  n.rectIndices.forEach((o, a) => {
4252
- const l = n.points[o];
4253
- a === 0 ? s.moveTo(l.x, l.y) : s.lineTo(l.x, l.y);
4401
+ const c = n.points[o];
4402
+ a === 0 ? s.moveTo(c.x, c.y) : s.lineTo(c.x, c.y);
4254
4403
  });
4255
4404
  const i = new z.ExtrudeGeometry(s, {
4256
4405
  depth: 2.8,
@@ -4272,7 +4421,7 @@ class Oe extends ne {
4272
4421
  toOBJ() {
4273
4422
  return new Promise((e) => {
4274
4423
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
4275
- e(Gt.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
4424
+ e(Ot.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
4276
4425
  }, 20);
4277
4426
  });
4278
4427
  }
@@ -4284,7 +4433,7 @@ class Oe extends ne {
4284
4433
  toGltf(e = !0) {
4285
4434
  return new Promise((t) => {
4286
4435
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
4287
- zt.parse(this.whiteModelGroup.children, (n) => {
4436
+ Ft.parse(this.whiteModelGroup.children, (n) => {
4288
4437
  t(n), this.material.opacity = 0.8, this.material.transparent = !0;
4289
4438
  }, () => {
4290
4439
  t(void 0);
@@ -4325,7 +4474,7 @@ class Oe extends ne {
4325
4474
  n.href = URL.createObjectURL(t), n.download = e, n.click();
4326
4475
  } else if (typeof global < "u") {
4327
4476
  const t = await this.toOBJ();
4328
- t && (await se("fs", !1)).writeFileSync(e, t);
4477
+ t && (await ee("fs", !1)).writeFileSync(e, t);
4329
4478
  }
4330
4479
  }
4331
4480
  /**
@@ -4341,11 +4490,11 @@ class Oe extends ne {
4341
4490
  s.href = URL.createObjectURL(n), s.download = e, s.click();
4342
4491
  } else if (typeof global < "u") {
4343
4492
  const n = await this.toGltf(t);
4344
- n && (await se("fs", !1)).writeFileSync(e, t ? Buffer.from(n) : JSON.stringify(n));
4493
+ n && (await ee("fs", !1)).writeFileSync(e, t ? Buffer.from(n) : JSON.stringify(n));
4345
4494
  }
4346
4495
  }
4347
4496
  }
4348
- class Fe extends ne {
4497
+ class Ce extends Q {
4349
4498
  static name = "DetailsPoint";
4350
4499
  Dxf = null;
4351
4500
  WhiteModel = null;
@@ -4422,7 +4571,7 @@ class Fe extends ne {
4422
4571
  }, 50);
4423
4572
  }
4424
4573
  }
4425
- class Ue extends ne {
4574
+ class Be extends Q {
4426
4575
  static name = "DxfLineModel";
4427
4576
  dxfLineModel = new z.LineSegments();
4428
4577
  dxfDoorsLineModel = new z.LineSegments();
@@ -4445,38 +4594,38 @@ class Ue extends ne {
4445
4594
  });
4446
4595
  }
4447
4596
  }
4448
- const qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4597
+ const Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4449
4598
  __proto__: null,
4450
- DetailsPoint: Fe,
4451
- DxfLineModel: Ue,
4452
- WhiteModel: Oe
4599
+ DetailsPoint: Ce,
4600
+ DxfLineModel: Be,
4601
+ WhiteModel: Ne
4453
4602
  }, Symbol.toStringTag, { value: "Module" }));
4454
- function Pe(f, e = {}) {
4603
+ function be(f, e = {}) {
4455
4604
  const {
4456
4605
  detailsPoint: t = !0,
4457
4606
  whiteModel: n = !0,
4458
4607
  dxfLineModel: s = !0
4459
4608
  } = e;
4460
- s && f.addComponent(new Ue()), n && f.addComponent(new Oe()), t && f.addComponent(new Fe());
4609
+ s && f.addComponent(new Be()), n && f.addComponent(new Ne()), t && f.addComponent(new Ce());
4461
4610
  }
4462
- const jt = Object.assign(Pe, {
4611
+ const zt = Object.assign(be, {
4463
4612
  create(f = {}) {
4464
- return (e) => Pe(e, f);
4613
+ return (e) => be(e, f);
4465
4614
  }
4466
- }), Yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4615
+ }), qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
4616
  __proto__: null,
4468
- ModelDataPlugin: jt,
4469
- components: qt
4617
+ ModelDataPlugin: zt,
4618
+ components: Gt
4470
4619
  }, Symbol.toStringTag, { value: "Module" }));
4471
- function kt() {
4620
+ function _t() {
4472
4621
  return import("./index2.js");
4473
4622
  }
4474
- function Xt() {
4623
+ function jt() {
4475
4624
  return import("./index3.js");
4476
4625
  }
4477
- let Me = null;
4478
- async function $t(f, e, t = !1, n) {
4479
- const s = await Promise.resolve().then(() => Yt), i = await kt(), r = await Xt(), o = new dt().usePlugin(s.ModelDataPlugin.create({
4626
+ let xe = null;
4627
+ async function Ht(f, e, t = !1, n) {
4628
+ const s = await Promise.resolve().then(() => qt), i = await _t(), r = await jt(), o = new lt().usePlugin(s.ModelDataPlugin.create({
4480
4629
  detailsPoint: !1,
4481
4630
  whiteModel: !0
4482
4631
  })).usePlugin(i.RenderPlugin.create({
@@ -4486,12 +4635,12 @@ async function $t(f, e, t = !1, n) {
4486
4635
  orbitControls: t,
4487
4636
  camera: e
4488
4637
  })).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
4489
- return a && f.appendChild(a.domElement), Me = o, {
4638
+ return a && f.appendChild(a.domElement), xe = o, {
4490
4639
  dxfSystem: o,
4491
- getFileAll: () => Vt(o)
4640
+ getFileAll: () => Yt(o)
4492
4641
  };
4493
4642
  }
4494
- async function Vt(f = Me) {
4643
+ async function Yt(f = xe) {
4495
4644
  const e = f.findComponentByName("WhiteModel"), t = new File([await f.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([f.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([f.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await e.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await e.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await e.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(f.Dxf.originalData)], "json.json", { type: "application/json" });
4496
4645
  return {
4497
4646
  dxf: n,
@@ -4503,27 +4652,27 @@ async function Vt(f = Me) {
4503
4652
  correctionDxf: s
4504
4653
  };
4505
4654
  }
4506
- function Zt() {
4507
- return Me;
4655
+ function Jt() {
4656
+ return xe;
4508
4657
  }
4509
4658
  export {
4510
4659
  j as B,
4511
- ne as C,
4512
- dt as D,
4513
- Ne as E,
4514
- N as L,
4515
- jt as M,
4516
- g as P,
4517
- Z as Q,
4518
- ut as T,
4519
- Ce as V,
4520
- Oe as W,
4521
- Fe as a,
4522
- ge as b,
4523
- $ as c,
4524
- $t as d,
4525
- Zt as e,
4526
- Vt as g,
4527
- qt as i,
4528
- me as u
4660
+ Q as C,
4661
+ lt as D,
4662
+ Pe as E,
4663
+ R as L,
4664
+ zt as M,
4665
+ w as P,
4666
+ J as Q,
4667
+ ct as T,
4668
+ Re as V,
4669
+ Ne as W,
4670
+ Ce as a,
4671
+ oe as b,
4672
+ W as c,
4673
+ Ht as d,
4674
+ Jt as e,
4675
+ Yt as g,
4676
+ Gt as i,
4677
+ pe as u
4529
4678
  };