build-dxf 0.0.32 → 0.0.34

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
- import * as G from "three";
2
- import { EventDispatcher as Ie, Color as Re, Matrix4 as Se, Vector3 as Z, Quaternion as Pe, BufferAttribute as k, REVISION as Ne, CompressedTexture as ne, Source as ve, NoColorSpace as Ce, MathUtils as oe, RGBAFormat as Be, ImageUtils as Oe, DoubleSide as Ge, PropertyBinding as Q, InterpolateDiscrete as Fe, Scene as ue, SRGBColorSpace as Ue, NearestFilter as _e, NearestMipmapNearestFilter as ze, NearestMipmapLinearFilter as qe, LinearFilter as je, LinearMipmapNearestFilter as Ye, LinearMipmapLinearFilter as Ve, ClampToEdgeWrapping as ke, RepeatWrapping as Xe, MirroredRepeatWrapping as We, InterpolateLinear as He } from "three";
3
- import de from "clipper-lib";
4
- import $ from "dxf-writer";
5
- import { OBJExporter as Je } from "three/examples/jsm/exporters/OBJExporter.js";
6
- function ae() {
7
- return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(d) {
8
- var e = Math.random() * 16 | 0, t = d == "x" ? e : e & 3 | 8;
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() {
7
+ return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(f) {
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 Le extends Ie {
13
- uuid = ae();
12
+ class Ne extends Ge {
13
+ uuid = me();
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 Le extends Ie {
30
30
  t && (t.forEach((n) => n()), this.eventRecordStack.delete(e));
31
31
  }
32
32
  }
33
- class W extends Le {
33
+ class ne extends Ne {
34
34
  parent;
35
35
  destroyed = !1;
36
36
  constructor(...e) {
@@ -48,7 +48,7 @@ class W extends Le {
48
48
  this.destroyed = !0;
49
49
  }
50
50
  }
51
- class Ke extends Le {
51
+ class ot extends Ne {
52
52
  static EventType = {
53
53
  ADD_COMPONENT: "addComponent"
54
54
  };
@@ -71,7 +71,7 @@ class Ke extends Le {
71
71
  * @param component
72
72
  */
73
73
  removeComponent(e) {
74
- if (e instanceof W) {
74
+ if (e instanceof ne) {
75
75
  const t = this.components.indexOf(e);
76
76
  t > -1 && (this.components.splice(t, 1), this.dispatchEvent({
77
77
  type: "removeComponent",
@@ -116,225 +116,17 @@ class Ke extends Le {
116
116
  return t || null;
117
117
  }
118
118
  }
119
- class w {
120
- x;
121
- y;
122
- get X() {
123
- return this.x;
124
- }
125
- get Y() {
126
- return this.y;
127
- }
128
- userData = {};
129
- /**
130
- *
131
- * @param x
132
- * @param y
133
- */
134
- constructor(e = 0, t = 0) {
135
- this.x = e, this.y = t;
136
- }
137
- set(e, t) {
138
- return this.x = e, this.y = t, this;
139
- }
140
- setX(e) {
141
- return this.x = e, this;
142
- }
143
- setY(e) {
144
- return this.y = e, this;
145
- }
146
- /**
147
- *
148
- * @param point
149
- * @returns
150
- */
151
- equal(e) {
152
- return Math.abs(e.x - this.x) < 1e-9 && Math.abs(e.y - this.y) < 1e-9;
153
- }
154
- /**
155
- *
156
- * @param arr
157
- */
158
- setByArray(e) {
159
- return this.x = e[0], this.y = e[1], this;
160
- }
161
- /**
162
- *
163
- */
164
- toArray() {
165
- return [this.x, this.y];
166
- }
167
- /**
168
- * multiplyScalar
169
- * @param scalar
170
- */
171
- mutiplyScalar(e) {
172
- return this.x *= e, this.y *= e, this;
173
- }
174
- multiplyScalar(e) {
175
- return this.x *= e, this.y *= e, this;
176
- }
177
- /**
178
- *
179
- * @param scalar
180
- * @returns
181
- */
182
- divisionScalar(e) {
183
- return this.x /= e, this.y /= e, this;
184
- }
185
- /**
186
- * 减法
187
- * @description 将当前点的坐标减去指定点的坐标
188
- * @param point
189
- * @returns
190
- */
191
- division(e) {
192
- return this.x -= e.x, this.y -= e.y, this;
193
- }
194
- /**
195
- * 加法
196
- * @description 将当前点的坐标加上指定点的坐标
197
- * @param point
198
- * @returns
199
- */
200
- add(e) {
201
- return this.x += e.x, this.y += e.y, this;
202
- }
203
- /**
204
- * 绕point旋转angle
205
- * @param point
206
- * @param angle 旋转角度,单位为弧度
207
- */
208
- rotate(e, t) {
209
- const n = this.x - e.x, s = this.y - e.y, i = Math.cos(t), r = Math.sin(t), o = n * i - s * r, a = n * r + s * i;
210
- return this.x = o + e.x, this.y = a + e.y, this;
211
- }
212
- /**
213
- * 保留小数位数
214
- * @param count
215
- */
216
- fixed(e) {
217
- return this.x = Number(this.x.toFixed(e)), this.y = Number(this.y.toFixed(e)), this;
218
- }
219
- /**
220
- * 归一化
221
- * @description 将当前点的坐标归一化为单位向量
222
- * @returns
223
- */
224
- normalize() {
225
- const e = Math.sqrt(this.x * this.x + this.y * this.y);
226
- return e === 0 ? this : (this.x /= e, this.y /= e, this);
227
- }
228
- /**
229
- * 获取单位法向量
230
- * @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
231
- * @param point
232
- * @returns
233
- */
234
- normal(e) {
235
- const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n), i = -n / s, r = t / s;
236
- return new w(i, r);
237
- }
238
- /**
239
- * 获取由传入的点到该点的单位方向向量
240
- * @description 计算当前点到指定点的方向向量,并返回单位方向
241
- * @param point
242
- * @returns
243
- */
244
- direction(e) {
245
- const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n);
246
- return s === 0 ? new w(0, 0) : new w(t / s, n / s);
247
- }
248
- /**
249
- * 计算模长
250
- * @returns
251
- */
252
- magnitude() {
253
- return Math.sqrt(this.x * this.x + this.y * this.y);
254
- }
255
- /**
256
- * 计算点点积
257
- * @param point
258
- * @returns
259
- */
260
- dot(e) {
261
- return this.x * e.x + this.y * e.y;
262
- }
263
- /** 求两个点叉积
264
- * @description 如果叉积大于 0,a 到 b 为逆时针方向。
265
- * @description 如果叉积小于 0,a 到 b 为顺时针方向。
266
- * @param point
267
- * @returns
268
- */
269
- cross(e) {
270
- return this.x * e.y - this.y * this.x;
271
- }
272
- /** 计算两个向量夹角
273
- * @description 公式:a · b = |a| × |b| × cosθ
274
- * @description 结果为0(0度),两个向量方向一致,结果为3.1415926(180度, PI),两个向量方向相反
275
- * @param point
276
- * @returns
277
- */
278
- angleBetween(e, t = "radian", n = "180") {
279
- const s = this.dot(e), i = this.magnitude(), r = e.magnitude();
280
- if (i === 0 || r === 0) return 0;
281
- const o = s / (i * r), a = Math.max(-1, Math.min(1, o));
282
- return t === "radian" ? Math.acos(a) : t === "cos" ? a : n === "180" || this.cross(e) < 0 ? Math.acos(a) / (Math.PI / 180) : 360 - Math.acos(a) / (Math.PI / 180);
283
- }
284
- /** 获取向量长度
285
- */
286
- length() {
287
- const e = Math.sqrt(this.x * this.x + this.y * this.y);
288
- return Math.abs(e - Math.round(e)) < 1e-9 ? Math.round(e) : e;
289
- }
290
- /**
291
- * 获取两个点长度
292
- * @param point
293
- */
294
- distance(e) {
295
- return Math.sqrt(
296
- (this.x - e.x) * (this.x - e.x) + (this.y - e.y) * (this.y - e.y)
297
- );
298
- }
299
- /**
300
- * 克隆
301
- * @returns
302
- */
303
- clone() {
304
- return new w(this.x, this.y);
305
- }
306
- /**
307
- * 克隆
308
- * @returns
309
- */
310
- copy(e) {
311
- return this.x = e.x ?? 0, this.y = e.y ?? 0, this;
312
- }
313
- toJson(e = 0) {
314
- return {
315
- x: this.x,
316
- y: this.y,
317
- z: e
318
- };
319
- }
320
- static from(e) {
321
- 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();
322
- }
323
- static zero() {
324
- return new w(0, 0);
325
- }
326
- }
327
- class _ {
119
+ class j {
328
120
  minX = 0;
329
121
  maxX = 0;
330
122
  minY = 0;
331
123
  maxY = 0;
332
124
  get points() {
333
125
  return [
334
- new w(this.minX, this.minY),
335
- new w(this.maxX, this.minY),
336
- new w(this.maxX, this.maxY),
337
- new w(this.minX, this.maxY)
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)
338
130
  ];
339
131
  }
340
132
  get width() {
@@ -344,7 +136,7 @@ class _ {
344
136
  return this.maxY - this.minY;
345
137
  }
346
138
  get center() {
347
- return new w(
139
+ return new g(
348
140
  this.minX + (this.maxX - this.minX) * 0.5,
349
141
  this.minY + (this.maxY - this.minY) * 0.5
350
142
  );
@@ -410,9 +202,9 @@ class _ {
410
202
  const o = this.points;
411
203
  for (let l = 0; l < 4; l++) {
412
204
  const c = o[l], h = o[(l + 1) % 4];
413
- for (let f = 0; f < 4; f++) {
414
- const u = t[f], p = t[(f + 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), b = (p.x - u.x) * (h.y - u.y) - (p.y - u.y) * (h.x - u.x);
415
- if (y * x < 0 && S * b < 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) || b === 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))
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))
416
208
  return !0;
417
209
  }
418
210
  }
@@ -424,9 +216,9 @@ class _ {
424
216
  const a = (l) => {
425
217
  let c = 0;
426
218
  for (let h = 0; h < 4; h++) {
427
- const f = t[h], u = t[(h + 1) % 4], p = (u.x - f.x) * (l.y - f.y) - (u.y - f.y) * (l.x - f.x);
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);
428
220
  if (p === 0) {
429
- const y = Math.abs(u.x - f.x) > 1e-10 ? u.x - f.x : u.y - f.y, x = y ? (l.x - f.x) / y : 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;
430
222
  if (x >= 0 && x <= 1) return !0;
431
223
  } else {
432
224
  const y = p > 0 ? 1 : -1;
@@ -507,7 +299,7 @@ class _ {
507
299
  * @returns
508
300
  */
509
301
  clone() {
510
- return new _(this.minX, this.maxX, this.minY, this.maxY);
302
+ return new j(this.minX, this.maxX, this.minY, this.maxY);
511
303
  }
512
304
  /**
513
305
  *
@@ -518,7 +310,7 @@ class _ {
518
310
  const t = [], n = [];
519
311
  return e.forEach((s) => {
520
312
  t.push(s.x), n.push(s.y);
521
- }), new _(
313
+ }), new j(
522
314
  Math.min(...t),
523
315
  Math.max(...t),
524
316
  Math.min(...n),
@@ -536,7 +328,7 @@ class _ {
536
328
  s?.points?.forEach((i) => {
537
329
  t.push(i.x), n.push(i.y);
538
330
  });
539
- }), new _(
331
+ }), new j(
540
332
  Math.min(...t),
541
333
  Math.max(...t),
542
334
  Math.min(...n),
@@ -544,151 +336,30 @@ class _ {
544
336
  );
545
337
  }
546
338
  }
547
- class ce {
548
- map = /* @__PURE__ */ new Map();
549
- gridSize;
550
- constructor(e = 2) {
551
- this.gridSize = e;
339
+ class ue {
340
+ points;
341
+ get p0() {
342
+ return this.points[0];
552
343
  }
553
- /**
554
- * 插入
555
- * @param point
556
- * @param userData
557
- */
558
- insert(e, t) {
559
- if (!e || isNaN(e.x) || isNaN(e.y))
560
- throw new Error("无效的点坐标");
561
- const n = this.getGridId(e);
562
- this.map.has(n) || this.map.set(n, /* @__PURE__ */ new Set());
563
- const s = this.map.get(n), i = { point: e, userData: t };
564
- s.add(i), e.userData.pointVirtualGrid = { set: s, target: i };
344
+ get p1() {
345
+ return this.points[1];
565
346
  }
566
- /**
567
- * 批量加入
568
- * @param points
569
- */
570
- insertBatch(e) {
571
- for (const { point: t, userData: n } of e)
572
- this.insert(t, n);
347
+ get p2() {
348
+ return this.points[2];
573
349
  }
574
- /** 移除点
575
- * @param point
576
- */
577
- remove(e) {
578
- const { set: t, target: n } = e?.userData?.pointVirtualGrid ?? {};
579
- t && (t.delete(n), delete e?.userData?.pointVirtualGridMap);
350
+ get p3() {
351
+ return this.points[3];
580
352
  }
581
- /**
582
- * 获取通过坐标,获取唯一网格索引
583
- * @param point
584
- * @returns
585
- */
586
- getGridId(e) {
587
- const t = Math.ceil(e.x / this.gridSize), n = Math.ceil(e.y / this.gridSize);
588
- return `${t}.${n}`;
589
- }
590
- /**
591
- *
592
- * @param gridId
593
- * @returns
594
- */
595
- decodeGridId(e) {
596
- const [t, n] = e.split(".").map(Number);
597
- return new w(t, n);
598
- }
599
- /**
600
- * 查询与矩形相交的点
601
- * @param rectangle 矩形
602
- * @returns 相交的节点数组
603
- */
604
- queryRect(e) {
605
- 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);
606
- for (let o = n; o <= s; o++)
607
- for (let a = i; a <= r; a++) {
608
- const l = `${o}.${a}`;
609
- if (!this.map.has(l)) continue;
610
- this.map.get(l)?.forEach((h) => {
611
- e.containsPoint(h.point);
612
- });
613
- }
614
- }
615
- /**
616
- * 查询与圆形区域相交的点
617
- * @param pos 圆心
618
- * @param radius 半径
619
- * @returns 相交的节点数组
620
- */
621
- queryCircle(e, t) {
622
- const n = new _(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 = [];
623
- for (let l = s; l <= i; l++)
624
- for (let c = r; c <= o; c++) {
625
- const h = `${l}.${c}`;
626
- if (!this.map.has(h)) continue;
627
- this.map.get(h)?.forEach((u) => {
628
- e.distance(u.point) <= t && a.push(u);
629
- });
630
- }
631
- return a;
632
- }
633
- /**
634
- * 查询与包围盒相交的点
635
- * @param box2 包围盒
636
- * @returns 相交的节点数组
637
- */
638
- queryBox(e) {
639
- 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 = [];
640
- for (let o = t; o <= n; o++)
641
- for (let a = s; a <= i; a++) {
642
- const l = `${o}.${a}`;
643
- if (!this.map.has(l)) continue;
644
- this.map.get(l)?.forEach((h) => {
645
- e.containsPoint(h.point) && r.push(h);
646
- });
647
- }
648
- return r;
649
- }
650
- /**
651
- * 查找相同点
652
- * @param point
653
- */
654
- queryPoint(e) {
655
- const t = this.getGridId(e), n = [];
656
- return this.map.has(t) && this.map.get(t)?.forEach((i) => {
657
- e.equal(i.point) && n.push(i);
658
- }), n;
659
- }
660
- /**
661
- * 查找点自己
662
- * @param point
663
- */
664
- queryPointSelf(e) {
665
- return e.userData.pointVirtualGrid && e.userData.pointVirtualGrid.target ? e.userData.pointVirtualGrid.target : null;
666
- }
667
- }
668
- class te {
669
- points;
670
- get p0() {
671
- return this.points[0];
672
- }
673
- get p1() {
674
- return this.points[1];
675
- }
676
- get p2() {
677
- return this.points[2];
678
- }
679
- get p3() {
680
- return this.points[3];
681
- }
682
- get path() {
683
- return this.points.flatMap((e, t) => {
684
- const n = this.points[(t + 1) % this.points.length];
685
- return [e.x, e.y, 0, n.x, n.y, 0];
686
- });
353
+ get path() {
354
+ return this.points.flatMap((e, t) => {
355
+ const n = this.points[(t + 1) % this.points.length];
356
+ return [e.x, e.y, 0, n.x, n.y, 0];
357
+ });
687
358
  }
688
359
  path2D(e) {
689
360
  return this.points.flatMap((t, n) => {
690
361
  const s = this.points[(n + 1) % this.points.length];
691
- return e && e(new w(t.x, t.y), new w(s.x, s.y)), [t.x, t.y, s.x, s.y];
362
+ return e && e(new g(t.x, t.y), new g(s.x, s.y)), [t.x, t.y, s.x, s.y];
692
363
  });
693
364
  }
694
365
  createGeometry() {
@@ -723,8 +394,8 @@ class te {
723
394
  if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
724
395
  return !0;
725
396
  } else {
726
- const f = ((o.x - t.x) * c - (o.y - t.y) * l) / h, u = ((o.x - t.x) * i - (o.y - t.y) * s) / h;
727
- if (f >= 0 && f <= 1 && u >= 0 && u <= 1)
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;
398
+ if (d >= 0 && d <= 1 && u >= 0 && u <= 1)
728
399
  return !0;
729
400
  }
730
401
  }
@@ -806,7 +477,7 @@ class te {
806
477
  let e = 1 / 0, t = -1 / 0, n = 1 / 0, s = -1 / 0;
807
478
  return this.points.forEach((i) => {
808
479
  t = Math.max(i.x, t), e = Math.min(i.x, e), s = Math.max(i.x, s), n = Math.min(i.x, n);
809
- }), new _(e, t, n, s);
480
+ }), new j(e, t, n, s);
810
481
  }
811
482
  /**
812
483
  *
@@ -815,197 +486,21 @@ class te {
815
486
  * @returns
816
487
  */
817
488
  static fromByLineSegment(e, t = 0.1, n = !1, s = 0.5) {
818
- const i = e.points[0], r = e.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(t * s) : w.zero(), l = n ? i.direction(r).mutiplyScalar(t * s) : w.zero(), c = o.x * t * 0.5, h = o.y * t * 0.5;
819
- return new te([
820
- new w(i.x + c, i.y + h).add(l),
821
- new w(r.x + c, r.y + h).add(a),
822
- new w(r.x - c, r.y - h).add(a),
823
- new w(i.x - c, i.y - h).add(l)
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)
824
495
  ]);
825
496
  }
826
497
  }
827
- class Y {
828
- bounds;
829
- // 包围盒
830
- capacity;
831
- // 节点容量
832
- maxDepth;
833
- // 最大深度
834
- depth;
835
- // 当前深度
836
- isLeaf = !0;
837
- // 是否为叶子节点
838
- children = null;
839
- // 子节点数组
840
- nodes = [];
841
- // 存储的节点
842
- color = [Math.random(), Math.random(), Math.random()];
843
- // 颜色
844
- constructor(e, t = 8, n = 10, s = 1) {
845
- this.bounds = e, this.capacity = t, this.depth = s, this.maxDepth = n;
846
- }
847
- /**
848
- * 插入线段节点
849
- * @param node 线段节点
850
- */
851
- insert(e) {
852
- if (!this.isLeaf) {
853
- const t = this.getQuadrant(e.line);
854
- if (t !== -1) {
855
- this.children[t].insert(e);
856
- return;
857
- }
858
- }
859
- if (this.nodes.push(e), e.parent = this, this.isLeaf && this.nodes.length > this.capacity && this.depth < this.maxDepth) {
860
- this.subdivide();
861
- const t = this.nodes;
862
- this.nodes = [];
863
- for (const n of t) {
864
- const s = this.getQuadrant(n.line);
865
- s !== -1 ? this.children[s].insert(n) : (n.parent = this, this.nodes.push(n));
866
- }
867
- }
868
- }
869
- /** 移除
870
- * @param node
871
- */
872
- remove(e) {
873
- const t = e.parent?.nodes.indexOf(e);
874
- t > -1 && e.parent?.nodes.splice(t, 1);
875
- }
876
- /**
877
- * 获取线段所属的象限
878
- * @param line 线段
879
- * @returns 象限索引(0:西北,1:东北,2:西南,3:东南)或-1(跨多个象限)
880
- */
881
- getQuadrant(e) {
882
- const t = this.children[0].bounds.intersectLineSegment(e), n = this.children[1].bounds.intersectLineSegment(e), s = this.children[2].bounds.intersectLineSegment(e), i = this.children[3].bounds.intersectLineSegment(e);
883
- let r = 0, o = -1;
884
- return t && (r++, o = 0), n && (r++, o = 1), s && (r++, o = 2), i && (r++, o = 3), r === 1 ? o : -1;
885
- }
886
- /**
887
- * 细分当前节点为四个子节点
888
- */
889
- subdivide() {
890
- if (!this.isLeaf) return;
891
- this.isLeaf = !1, this.children = [];
892
- const e = (this.bounds.minX + this.bounds.maxX) / 2, t = (this.bounds.minY + this.bounds.maxY) / 2;
893
- this.children[0] = new Y(
894
- new _(this.bounds.minX, e, this.bounds.minY, t),
895
- this.capacity,
896
- this.maxDepth,
897
- this.depth + 1
898
- ), this.children[1] = new Y(
899
- new _(e, this.bounds.maxX, this.bounds.minY, t),
900
- this.capacity,
901
- this.maxDepth,
902
- this.depth + 1
903
- ), this.children[2] = new Y(
904
- new _(this.bounds.minX, e, t, this.bounds.maxY),
905
- this.capacity,
906
- this.maxDepth,
907
- this.depth + 1
908
- ), this.children[3] = new Y(
909
- new _(e, this.bounds.maxX, t, this.bounds.maxY),
910
- this.capacity,
911
- this.maxDepth,
912
- this.depth + 1
913
- );
914
- }
915
- /**
916
- * 查询与包围盒相交的线段节点
917
- * @param box2 包围盒
918
- * @returns 相交的节点数组
919
- */
920
- queryBox(e) {
921
- const t = [];
922
- if (!this.bounds.intersectBox(e))
923
- return t;
924
- for (const n of this.nodes)
925
- e.intersectLineSegment(n.line) && t.push(n);
926
- if (!this.isLeaf)
927
- for (const n of this.children)
928
- t.push(...n.queryBox(e));
929
- return t;
930
- }
931
- /**
932
- * 查询与圆形区域相交的线段节点
933
- * @param pos 圆心
934
- * @param radius 半径
935
- * @returns 相交的节点数组
936
- */
937
- queryCircle(e, t) {
938
- const n = [], s = new _(
939
- e.x - t,
940
- e.x + t,
941
- e.y - t,
942
- e.y + t
943
- );
944
- if (!this.bounds.intersectBox(s))
945
- return n;
946
- for (const i of this.nodes) {
947
- const [r, o] = i.line.points, a = o.x - r.x, l = o.y - r.y, c = a * a + l * l;
948
- let h = ((e.x - r.x) * a + (e.y - r.y) * l) / c;
949
- h = Math.max(0, Math.min(1, h));
950
- const f = r.x + h * a, u = r.y + h * l;
951
- e.distance(new w(f, u)) <= t && n.push(i);
952
- }
953
- if (!this.isLeaf)
954
- for (const i of this.children)
955
- n.push(...i.queryCircle(e, t));
956
- return n.sort((i) => i.line.length()), n;
957
- }
958
- /**
959
- * 查询与矩形相交的线段节点
960
- * @param rectangle 矩形
961
- * @returns 相交的节点数组
962
- */
963
- queryRect(e) {
964
- const t = [];
965
- if (!this.bounds.intersectRectangle(e))
966
- return t;
967
- for (const n of this.nodes)
968
- e.intersectLineSegment(n.line) && t.push(n);
969
- if (!this.isLeaf)
970
- for (const n of this.children)
971
- t.push(...n.queryRect(e));
972
- return t;
973
- }
974
- /**
975
- * 查询与线段相交的线段节点
976
- * @param lineSegment 线段
977
- * @returns 相交的节点数组
978
- */
979
- queryLineSegment(e, t = !0) {
980
- const n = [];
981
- if (!this.bounds.intersectLineSegment(e))
982
- return n;
983
- for (const s of this.nodes)
984
- e.intersectLineSegment(s.line, t) && n.push(s);
985
- if (!this.isLeaf)
986
- for (const s of this.children)
987
- n.push(...s.queryLineSegment(e));
988
- return n;
989
- }
990
- /**
991
- * 包围盒转换为数组
992
- * @param array
993
- * @param colors
994
- * @returns
995
- */
996
- boundsToArray(e = [], t, n = !0) {
997
- return !this.isLeaf && n && this.children?.forEach((s) => s.boundsToArray(e, t)), e.push(...this.bounds.points.flatMap((s, i, r) => {
998
- const o = r[(i + 1) % r.length];
999
- return t?.push(...this.color), t?.push(...this.color), [s.x, s.y, 0, o.x, o.y, 0];
1000
- })), e;
1001
- }
1002
- }
1003
- class B {
1004
- points = [new w(), new w()];
498
+ class N {
499
+ points = [new g(), new g()];
1005
500
  userData = {};
1006
501
  // line: any
1007
502
  get center() {
1008
- return new w(
503
+ return new g(
1009
504
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
1010
505
  this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
1011
506
  );
@@ -1016,7 +511,7 @@ class B {
1016
511
  get end() {
1017
512
  return this.points[1];
1018
513
  }
1019
- constructor(e = new w(), t = new w()) {
514
+ constructor(e = new g(), t = new g()) {
1020
515
  this.points = [e, t];
1021
516
  }
1022
517
  set(e, t) {
@@ -1102,15 +597,15 @@ class B {
1102
597
  * @returns {Rectangle}
1103
598
  */
1104
599
  expandToRectangle(e = 0.1, t = "all") {
1105
- 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, l = i.y * e * 0.5, c = [
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 = [
1106
601
  // 第一条线
1107
- new w(n.x + a, n.y + l).add(o),
1108
- new w(s.x + a, s.y + l).add(r),
602
+ new g(n.x + a, n.y + l).add(o),
603
+ new g(s.x + a, s.y + l).add(r),
1109
604
  // 第二条线
1110
- new w(n.x - a, n.y - l).add(o),
1111
- new w(s.x - a, s.y - l).add(r)
605
+ new g(n.x - a, n.y - l).add(o),
606
+ new g(s.x - a, s.y - l).add(r)
1112
607
  ];
1113
- return new te([0, 1, 3, 2].map((h) => c[h]));
608
+ return new ue([0, 1, 3, 2].map((h) => c[h]));
1114
609
  }
1115
610
  /**
1116
611
  * 计算线段的长度
@@ -1147,24 +642,24 @@ class B {
1147
642
  projectLineSegment(e) {
1148
643
  if (e.points.length !== 2 || this.points.length !== 2)
1149
644
  throw new Error("每条线段必须由两个点定义");
1150
- const [t, n] = e.points, [s, i] = this.points, r = new w(i.x - s.x, i.y - s.y);
645
+ const [t, n] = e.points, [s, i] = this.points, r = new g(i.x - s.x, i.y - s.y);
1151
646
  if (r.x === 0 && r.y === 0)
1152
647
  throw new Error("投影目标线段的两个点不能重合");
1153
648
  const o = (p) => {
1154
- const y = new w(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, b = (y.x * r.x + y.y * r.y) / x, C = s.x + b * r.x, m = s.y + b * r.y;
1155
- return new w(C, m);
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);
1156
651
  };
1157
652
  let a = o(t), l = o(n);
1158
653
  const c = (p) => {
1159
- const y = new w(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
654
+ const y = new g(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
1160
655
  return (y.x * r.x + y.y * r.y) / x;
1161
656
  };
1162
- let h = c(a), f = c(l);
657
+ let h = c(a), d = c(l);
1163
658
  const u = (p) => {
1164
659
  const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, S = s.y + y * r.y;
1165
- return new w(x, S);
660
+ return new g(x, S);
1166
661
  };
1167
- return (h < 0 || h > 1) && (a = u(h)), (f < 0 || f > 1) && (l = u(f)), a.x === l.x && a.y === l.y ? new B(a, a) : new B(a, l);
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);
1168
663
  }
1169
664
  /**
1170
665
  * 计算一条线段在另一条直线上的投影
@@ -1173,138 +668,727 @@ class B {
1173
668
  * @returns 投影并裁剪后的线段
1174
669
  */
1175
670
  projectPoint(e, t = !0) {
1176
- const [n, s] = this.points, i = new w(s.x - n.x, s.y - n.y);
671
+ const [n, s] = this.points, i = new g(s.x - n.x, s.y - n.y);
1177
672
  if (i.x === 0 && i.y === 0)
1178
673
  throw new Error("投影目标线段的两个点不能重合");
1179
674
  let o = ((c) => {
1180
- const h = new w(c.x - n.x, c.y - n.y), f = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / f, y = n.x + p * i.x, x = n.y + p * i.y;
1181
- return new w(y, x);
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);
1182
677
  })(e);
1183
678
  if (!t) return o;
1184
679
  let l = ((c) => {
1185
- const h = new w(c.x - n.x, c.y - n.y), f = i.x * i.x + i.y * i.y;
1186
- return (h.x * i.x + h.y * i.y) / f;
680
+ const h = new g(c.x - n.x, c.y - n.y), d = i.x * i.x + i.y * i.y;
681
+ return (h.x * i.x + h.y * i.y) / d;
1187
682
  })(o);
1188
683
  return l < 0 || l > 1 ? null : o;
1189
684
  }
1190
685
  /**
1191
- * 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
1192
- * @param line
1193
- * @param endpoint 是否包含端点相交
686
+ * 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
687
+ * @param line
688
+ * @param endpoint 是否包含端点相交
689
+ * @returns
690
+ */
691
+ intersectLineSegment(e, t = !0) {
692
+ 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);
695
+ }
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;
698
+ }
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)));
701
+ }
702
+ /**
703
+ * 判断一个点是否在线段上(含端点)
704
+ * @param pt 要判断的点
705
+ * @returns 如果点在当前线段上返回 true,否则返回 false
706
+ */
707
+ containsPoint(e) {
708
+ const t = e.distance(this.start), n = e.distance(this.end), s = this.getLength();
709
+ return Math.abs(t + n - s) < 1e-10;
710
+ }
711
+ /**
712
+ * 获取交点
713
+ * @param line
714
+ * @returns
715
+ */
716
+ getIntersection(e) {
717
+ 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
+ if (Math.abs(r) < 1e-10)
719
+ 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);
722
+ }
723
+ /**
724
+ * 获取两条线段夹角
725
+ * @param line
726
+ */
727
+ includedAngle(e) {
728
+ const t = this.direction(), n = e.direction();
729
+ return t.angleBetween(n) / (Math.PI / 180);
730
+ }
731
+ /**
732
+ * 两条线段方向是否一致
733
+ * @param line
734
+ */
735
+ directionEqual(e, t = 0.1) {
736
+ return this.includedAngle(e) < t;
737
+ }
738
+ /**
739
+ * 两条线段是否平行
740
+ * @param line
741
+ */
742
+ parallel(e, t = 1) {
743
+ const n = this.includedAngle(e);
744
+ return n < t || n > 180 - t;
745
+ }
746
+ /**
747
+ * 两条线段方向相反否一致
748
+ * @param line
749
+ */
750
+ directionOpposite(e, t = 0.1) {
751
+ return 180 - this.includedAngle(e) < t;
752
+ }
753
+ /**
754
+ * 判断两条线是否平行
755
+ * @param line
756
+ */
757
+ isParallel(e, t = 4) {
758
+ const n = this.includedAngle(e);
759
+ return n < t || n > 180 - t;
760
+ }
761
+ /** 判断点在当前线段的左边还是右边,或者线段上
762
+ * @param point
763
+ */
764
+ pointPosition(e) {
765
+ const t = this.start, n = this.end, s = (n.x - t.x) * (e.y - t.y) - (n.y - t.y) * (e.x - t.x);
766
+ return Math.abs(s) < 1e-10 ? "on" : s > 0 ? "left" : "right";
767
+ }
768
+ /**
769
+ * @returns
770
+ */
771
+ getRightDirection() {
772
+ return this.normal();
773
+ }
774
+ /**
775
+ *
776
+ * @returns
777
+ */
778
+ getLeftDirection() {
779
+ return this.normal().multiplyScalar(-1);
780
+ }
781
+ /** @param line 获取两条线段之间的最短距离
782
+ */
783
+ getMinLength(e) {
784
+ if (this.intersectLineSegment(e))
785
+ return 0;
786
+ 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)
789
+ return n.distance(i);
790
+ const c = ((n.x - i.x) * o + (n.y - i.y) * a) / l;
791
+ if (c < 0)
792
+ return n.distance(i);
793
+ if (c > 1)
794
+ return n.distance(r);
795
+ {
796
+ const h = i.x + c * o, d = i.y + c * a;
797
+ return n.distance(new g(h, d));
798
+ }
799
+ };
800
+ return Math.min(
801
+ t(this.start, e),
802
+ t(this.end, e),
803
+ t(e.start, this),
804
+ t(e.end, this)
805
+ );
806
+ }
807
+ /**
808
+ * 判断两条直线是否重合
809
+ * @param line
810
+ * @returns
811
+ */
812
+ 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;
815
+ }
816
+ /** 克隆
817
+ * @returns
818
+ */
819
+ clone() {
820
+ const e = new N(
821
+ this.points[0].clone(),
822
+ this.points[1].clone()
823
+ );
824
+ return e.userData = { ...this.userData }, e;
825
+ }
826
+ /**
827
+ * 获取最长线段
828
+ * @param lines
829
+ */
830
+ static maxLengthLineIndex(e, t) {
831
+ let n = 0, s = -1;
832
+ for (let i = 0; i < e.length; i++) {
833
+ if (t && t(e[i])) continue;
834
+ const r = e[i].length();
835
+ r > n && (n = r, s = i);
836
+ }
837
+ return s;
838
+ }
839
+ }
840
+ class g {
841
+ x;
842
+ y;
843
+ get X() {
844
+ return this.x;
845
+ }
846
+ get Y() {
847
+ return this.y;
848
+ }
849
+ userData = {};
850
+ /**
851
+ *
852
+ * @param x
853
+ * @param y
854
+ */
855
+ constructor(e = 0, t = 0) {
856
+ this.x = e, this.y = t;
857
+ }
858
+ set(e, t) {
859
+ return this.x = e, this.y = t, this;
860
+ }
861
+ setX(e) {
862
+ return this.x = e, this;
863
+ }
864
+ setY(e) {
865
+ return this.y = e, this;
866
+ }
867
+ /**
868
+ *
869
+ * @param point
870
+ * @returns
871
+ */
872
+ equal(e) {
873
+ return Math.abs(e.x - this.x) < 1e-9 && Math.abs(e.y - this.y) < 1e-9;
874
+ }
875
+ /**
876
+ *
877
+ * @param arr
878
+ */
879
+ setByArray(e) {
880
+ return this.x = e[0], this.y = e[1], this;
881
+ }
882
+ /**
883
+ *
884
+ */
885
+ toArray() {
886
+ return [this.x, this.y];
887
+ }
888
+ /**
889
+ * multiplyScalar
890
+ * @param scalar
891
+ */
892
+ mutiplyScalar(e) {
893
+ return this.x *= e, this.y *= e, this;
894
+ }
895
+ multiplyScalar(e) {
896
+ return this.x *= e, this.y *= e, this;
897
+ }
898
+ /**
899
+ *
900
+ * @param scalar
901
+ * @returns
902
+ */
903
+ divisionScalar(e) {
904
+ return this.x /= e, this.y /= e, this;
905
+ }
906
+ /**
907
+ * 减法
908
+ * @description 将当前点的坐标减去指定点的坐标
909
+ * @param point
910
+ * @returns
911
+ */
912
+ division(e) {
913
+ return this.x -= e.x, this.y -= e.y, this;
914
+ }
915
+ /**
916
+ * 加法
917
+ * @description 将当前点的坐标加上指定点的坐标
918
+ * @param point
919
+ * @returns
920
+ */
921
+ add(e) {
922
+ return this.x += e.x, this.y += e.y, this;
923
+ }
924
+ /**
925
+ * 绕point旋转angle
926
+ * @param point
927
+ * @param angle 旋转角度,单位为弧度
928
+ */
929
+ rotate(e, t) {
930
+ const n = this.x - e.x, s = this.y - e.y, i = Math.cos(t), r = Math.sin(t), o = n * i - s * r, a = n * r + s * i;
931
+ return this.x = o + e.x, this.y = a + e.y, this;
932
+ }
933
+ /**
934
+ * 保留小数位数
935
+ * @param count
936
+ */
937
+ fixed(e) {
938
+ return this.x = Number(this.x.toFixed(e)), this.y = Number(this.y.toFixed(e)), this;
939
+ }
940
+ /**
941
+ * 归一化
942
+ * @description 将当前点的坐标归一化为单位向量
943
+ * @returns
944
+ */
945
+ normalize() {
946
+ const e = Math.sqrt(this.x * this.x + this.y * this.y);
947
+ return e === 0 ? this : (this.x /= e, this.y /= e, this);
948
+ }
949
+ /**
950
+ * 获取单位法向量
951
+ * @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
952
+ * @param point
953
+ * @returns
954
+ */
955
+ normal(e) {
956
+ 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);
958
+ }
959
+ /**
960
+ * 获取由传入的点到该点的单位方向向量
961
+ * @description 计算当前点到指定点的方向向量,并返回单位方向
962
+ * @param point
963
+ * @returns
964
+ */
965
+ direction(e) {
966
+ 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);
968
+ }
969
+ /** 展开为线
970
+ * @param direction
971
+ * @param length
972
+ */
973
+ expandAsLine(e, t, n) {
974
+ const s = new N(
975
+ this.clone(),
976
+ this.clone().add(e.clone().multiplyScalar(t))
977
+ );
978
+ return s.userData = n, s;
979
+ }
980
+ /**
981
+ * 计算模长
982
+ * @returns
983
+ */
984
+ magnitude() {
985
+ return Math.sqrt(this.x * this.x + this.y * this.y);
986
+ }
987
+ /**
988
+ * 计算点点积
989
+ * @param point
990
+ * @returns
991
+ */
992
+ dot(e) {
993
+ return this.x * e.x + this.y * e.y;
994
+ }
995
+ /** 求两个点叉积
996
+ * @description 如果叉积大于 0,a 到 b 为逆时针方向。
997
+ * @description 如果叉积小于 0,a 到 b 为顺时针方向。
998
+ * @param point
999
+ * @returns
1000
+ */
1001
+ cross(e) {
1002
+ return this.x * e.y - this.y * this.x;
1003
+ }
1004
+ /** 计算两个向量夹角
1005
+ * @description 公式:a · b = |a| × |b| × cosθ
1006
+ * @description 结果为0(0度),两个向量方向一致,结果为3.1415926(180度, PI),两个向量方向相反
1007
+ * @param point
1008
+ * @returns
1009
+ */
1010
+ angleBetween(e, t = "radian", n = "180") {
1011
+ const s = this.dot(e), i = this.magnitude(), r = e.magnitude();
1012
+ if (i === 0 || r === 0) return 0;
1013
+ const o = s / (i * r), a = Math.max(-1, Math.min(1, o));
1014
+ return t === "radian" ? Math.acos(a) : t === "cos" ? a : n === "180" || this.cross(e) < 0 ? Math.acos(a) / (Math.PI / 180) : 360 - Math.acos(a) / (Math.PI / 180);
1015
+ }
1016
+ /** 获取向量长度
1017
+ */
1018
+ length() {
1019
+ const e = Math.sqrt(this.x * this.x + this.y * this.y);
1020
+ return Math.abs(e - Math.round(e)) < 1e-9 ? Math.round(e) : e;
1021
+ }
1022
+ /**
1023
+ * 获取两个点长度
1024
+ * @param point
1025
+ */
1026
+ distance(e) {
1027
+ return Math.sqrt(
1028
+ (this.x - e.x) * (this.x - e.x) + (this.y - e.y) * (this.y - e.y)
1029
+ );
1030
+ }
1031
+ /**
1032
+ * 克隆
1033
+ * @returns
1034
+ */
1035
+ clone() {
1036
+ return new g(this.x, this.y);
1037
+ }
1038
+ /**
1039
+ * 克隆
1040
+ * @returns
1041
+ */
1042
+ copy(e) {
1043
+ return this.x = e.x ?? 0, this.y = e.y ?? 0, this;
1044
+ }
1045
+ toJson(e = 0) {
1046
+ return {
1047
+ x: this.x,
1048
+ y: this.y,
1049
+ z: e
1050
+ };
1051
+ }
1052
+ 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();
1054
+ }
1055
+ static zero() {
1056
+ return new g(0, 0);
1057
+ }
1058
+ }
1059
+ async function se(f, e = !0) {
1060
+ if (typeof global < "u" && typeof require < "u")
1061
+ return require(f);
1062
+ {
1063
+ let t = await import(
1064
+ /* @vite-ignore */
1065
+ f
1066
+ );
1067
+ return e && (t = t.default), t;
1068
+ }
1069
+ }
1070
+ class Z {
1071
+ bounds;
1072
+ // 包围盒
1073
+ capacity;
1074
+ // 节点容量
1075
+ maxDepth;
1076
+ // 最大深度
1077
+ depth;
1078
+ // 当前深度
1079
+ isLeaf = !0;
1080
+ // 是否为叶子节点
1081
+ children = null;
1082
+ // 子节点数组
1083
+ nodes = [];
1084
+ // 存储的节点
1085
+ color = [Math.random(), Math.random(), Math.random()];
1086
+ // 颜色
1087
+ constructor(e, t = 8, n = 10, s = 1) {
1088
+ this.bounds = e, this.capacity = t, this.depth = s, this.maxDepth = n;
1089
+ }
1090
+ /**
1091
+ * 插入线段节点
1092
+ * @param node 线段节点
1093
+ */
1094
+ insert(e) {
1095
+ if (!this.isLeaf) {
1096
+ const t = this.getQuadrant(e.line);
1097
+ if (t !== -1) {
1098
+ this.children[t].insert(e);
1099
+ return;
1100
+ }
1101
+ }
1102
+ if (this.nodes.push(e), e.parent = this, this.isLeaf && this.nodes.length > this.capacity && this.depth < this.maxDepth) {
1103
+ this.subdivide();
1104
+ const t = this.nodes;
1105
+ this.nodes = [];
1106
+ for (const n of t) {
1107
+ const s = this.getQuadrant(n.line);
1108
+ s !== -1 ? this.children[s].insert(n) : (n.parent = this, this.nodes.push(n));
1109
+ }
1110
+ }
1111
+ }
1112
+ /** 移除
1113
+ * @param node
1114
+ */
1115
+ remove(e) {
1116
+ const t = e.parent?.nodes.indexOf(e);
1117
+ t > -1 && e.parent?.nodes.splice(t, 1);
1118
+ }
1119
+ /**
1120
+ * 获取线段所属的象限
1121
+ * @param line 线段
1122
+ * @returns 象限索引(0:西北,1:东北,2:西南,3:东南)或-1(跨多个象限)
1123
+ */
1124
+ getQuadrant(e) {
1125
+ const t = this.children[0].bounds.intersectLineSegment(e), n = this.children[1].bounds.intersectLineSegment(e), s = this.children[2].bounds.intersectLineSegment(e), i = this.children[3].bounds.intersectLineSegment(e);
1126
+ let r = 0, o = -1;
1127
+ return t && (r++, o = 0), n && (r++, o = 1), s && (r++, o = 2), i && (r++, o = 3), r === 1 ? o : -1;
1128
+ }
1129
+ /**
1130
+ * 细分当前节点为四个子节点
1131
+ */
1132
+ subdivide() {
1133
+ if (!this.isLeaf) return;
1134
+ this.isLeaf = !1, this.children = [];
1135
+ const e = (this.bounds.minX + this.bounds.maxX) / 2, t = (this.bounds.minY + this.bounds.maxY) / 2;
1136
+ this.children[0] = new Z(
1137
+ new j(this.bounds.minX, e, this.bounds.minY, t),
1138
+ this.capacity,
1139
+ this.maxDepth,
1140
+ this.depth + 1
1141
+ ), this.children[1] = new Z(
1142
+ new j(e, this.bounds.maxX, this.bounds.minY, t),
1143
+ this.capacity,
1144
+ this.maxDepth,
1145
+ this.depth + 1
1146
+ ), this.children[2] = new Z(
1147
+ new j(this.bounds.minX, e, t, this.bounds.maxY),
1148
+ this.capacity,
1149
+ this.maxDepth,
1150
+ this.depth + 1
1151
+ ), this.children[3] = new Z(
1152
+ new j(e, this.bounds.maxX, t, this.bounds.maxY),
1153
+ this.capacity,
1154
+ this.maxDepth,
1155
+ this.depth + 1
1156
+ );
1157
+ }
1158
+ /**
1159
+ * 查询与包围盒相交的线段节点
1160
+ * @param box2 包围盒
1161
+ * @returns 相交的节点数组
1162
+ */
1163
+ queryBox(e) {
1164
+ const t = [];
1165
+ if (!this.bounds.intersectBox(e))
1166
+ return t;
1167
+ for (const n of this.nodes)
1168
+ e.intersectLineSegment(n.line) && t.push(n);
1169
+ if (!this.isLeaf)
1170
+ for (const n of this.children)
1171
+ t.push(...n.queryBox(e));
1172
+ return t;
1173
+ }
1174
+ /**
1175
+ * 查询与圆形区域相交的线段节点
1176
+ * @param pos 圆心
1177
+ * @param radius 半径
1178
+ * @returns 相交的节点数组
1179
+ */
1180
+ queryCircle(e, t) {
1181
+ const n = [], s = new j(
1182
+ e.x - t,
1183
+ e.x + t,
1184
+ e.y - t,
1185
+ e.y + t
1186
+ );
1187
+ if (!this.bounds.intersectBox(s))
1188
+ return n;
1189
+ 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;
1192
+ 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);
1195
+ }
1196
+ if (!this.isLeaf)
1197
+ for (const i of this.children)
1198
+ n.push(...i.queryCircle(e, t));
1199
+ return n.sort((i) => i.line.length()), n;
1200
+ }
1201
+ /**
1202
+ * 查询与点相交的线段节点
1203
+ * @param point 圆心
1204
+ * @returns 相交的节点数组
1205
+ */
1206
+ queryPoint(e) {
1207
+ const t = [];
1208
+ if (e.x < this.bounds.minX || e.x > this.bounds.maxX || e.y < this.bounds.minY || e.y > this.bounds.maxY)
1209
+ return t;
1210
+ for (const n of this.nodes)
1211
+ n.line.isPointOnSegment(e) && t.push(n);
1212
+ if (!this.isLeaf)
1213
+ for (const n of this.children)
1214
+ t.push(...n.queryPoint(e));
1215
+ return t;
1216
+ }
1217
+ /**
1218
+ * 查询与矩形相交的线段节点
1219
+ * @param rectangle 矩形
1220
+ * @returns 相交的节点数组
1221
+ */
1222
+ queryRect(e) {
1223
+ const t = [];
1224
+ if (!this.bounds.intersectRectangle(e))
1225
+ return t;
1226
+ for (const n of this.nodes)
1227
+ e.intersectLineSegment(n.line) && t.push(n);
1228
+ if (!this.isLeaf)
1229
+ for (const n of this.children)
1230
+ t.push(...n.queryRect(e));
1231
+ return t;
1232
+ }
1233
+ /**
1234
+ * 查询与线段相交的线段节点
1235
+ * @param lineSegment 线段
1236
+ * @returns 相交的节点数组
1237
+ */
1238
+ queryLineSegment(e, t = !0) {
1239
+ const n = [];
1240
+ if (!this.bounds.intersectLineSegment(e))
1241
+ return n;
1242
+ for (const s of this.nodes)
1243
+ e.intersectLineSegment(s.line, t) && n.push(s);
1244
+ if (!this.isLeaf)
1245
+ for (const s of this.children)
1246
+ n.push(...s.queryLineSegment(e));
1247
+ return n;
1248
+ }
1249
+ /**
1250
+ * 包围盒转换为数组
1251
+ * @param array
1252
+ * @param colors
1194
1253
  * @returns
1195
1254
  */
1196
- intersectLineSegment(e, t = !0) {
1197
- const n = this.start, s = this.end, i = e.start, r = e.end;
1198
- function o(u, p, y) {
1199
- return (p.x - u.x) * (y.y - u.y) - (p.y - u.y) * (y.x - u.x);
1200
- }
1201
- function a(u, p, y) {
1202
- 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;
1203
- }
1204
- const l = o(n, s, i), c = o(n, s, r), h = o(i, r, n), f = o(i, r, s);
1205
- return !!(l * c < 0 && h * f < 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(f) < 1e-10 && a(s, i, r)));
1255
+ boundsToArray(e = [], t, n = !0) {
1256
+ return !this.isLeaf && n && this.children?.forEach((s) => s.boundsToArray(e, t)), e.push(...this.bounds.points.flatMap((s, i, r) => {
1257
+ const o = r[(i + 1) % r.length];
1258
+ return t?.push(...this.color), t?.push(...this.color), [s.x, s.y, 0, o.x, o.y, 0];
1259
+ })), e;
1260
+ }
1261
+ }
1262
+ class ge {
1263
+ map = /* @__PURE__ */ new Map();
1264
+ targetMap = /* @__PURE__ */ new Map();
1265
+ gridSize;
1266
+ constructor(e = 2) {
1267
+ this.gridSize = e;
1206
1268
  }
1207
1269
  /**
1208
- * 判断一个点是否在线段上(含端点)
1209
- * @param pt 要判断的点
1210
- * @returns 如果点在当前线段上返回 true,否则返回 false
1270
+ * 插入
1271
+ * @param point
1272
+ * @param userData
1211
1273
  */
1212
- containsPoint(e) {
1213
- const t = e.distance(this.start), n = e.distance(this.end), s = this.getLength();
1214
- return Math.abs(t + n - s) < 1e-10;
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 });
1215
1282
  }
1216
1283
  /**
1217
- * 获取交点
1218
- * @param line
1219
- * @returns
1284
+ * 批量加入
1285
+ * @param points
1220
1286
  */
1221
- getIntersection(e) {
1222
- 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);
1223
- if (Math.abs(r) < 1e-10)
1224
- return null;
1225
- 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);
1226
- return new w(a, l);
1287
+ insertBatch(e) {
1288
+ for (const { point: t, userData: n } of e)
1289
+ this.insert(t, n);
1227
1290
  }
1228
- /**
1229
- * 获取两条线段夹角
1230
- * @param line
1291
+ /** 移除点
1292
+ * @param point
1231
1293
  */
1232
- includedAngle(e) {
1233
- const t = this.direction(), n = e.direction();
1234
- return t.angleBetween(n) / (Math.PI / 180);
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
+ }
1235
1299
  }
1236
1300
  /**
1237
- * 两条线段方向是否一致
1238
- * @param line
1301
+ * 获取通过坐标,获取唯一网格索引
1302
+ * @param point
1303
+ * @returns
1239
1304
  */
1240
- directionEqual(e, t = 0.1) {
1241
- return this.includedAngle(e) < t;
1305
+ getGridId(e) {
1306
+ const t = Math.ceil(e.x / this.gridSize), n = Math.ceil(e.y / this.gridSize);
1307
+ return `${t}.${n}`;
1242
1308
  }
1243
1309
  /**
1244
- * 两条线段是否平行
1245
- * @param line
1310
+ *
1311
+ * @param gridId
1312
+ * @returns
1246
1313
  */
1247
- parallel(e, t = 1) {
1248
- const n = this.includedAngle(e);
1249
- return n < t || n > 180 - t;
1314
+ decodeGridId(e) {
1315
+ const [t, n] = e.split(".").map(Number);
1316
+ return new g(t, n);
1250
1317
  }
1251
1318
  /**
1252
- * 两条线段方向相反否一致
1253
- * @param line
1319
+ * 查询与矩形相交的点
1320
+ * @param rectangle 矩形
1321
+ * @returns 相交的节点数组
1254
1322
  */
1255
- directionOpposite(e, t = 0.1) {
1256
- return 180 - this.includedAngle(e) < t;
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
+ }
1257
1333
  }
1258
1334
  /**
1259
- * 判断两条线是否平行
1260
- * @param line
1335
+ * 查询与圆形区域相交的点
1336
+ * @param pos 圆心
1337
+ * @param radius 半径
1338
+ * @returns 相交的节点数组
1261
1339
  */
1262
- isParallel(e, t = 4) {
1263
- const n = this.includedAngle(e);
1264
- return n < t || n > 180 - t;
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;
1265
1351
  }
1266
1352
  /**
1267
- * 判断两条直线是否重合
1268
- * @param line
1269
- * @returns
1353
+ * 查询与包围盒相交的点
1354
+ * @param box2 包围盒
1355
+ * @returns 相交的节点数组
1270
1356
  */
1271
- areLinesCoincident(e) {
1272
- 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;
1273
- 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;
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;
1274
1368
  }
1275
- clone() {
1276
- const e = new B(
1277
- this.points[0].clone(),
1278
- this.points[1].clone()
1279
- );
1280
- return e.userData = { ...this.userData }, e;
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;
1281
1378
  }
1282
1379
  /**
1283
- * 获取最长线段
1284
- * @param lines
1380
+ * 查找点自己
1381
+ * @param point
1285
1382
  */
1286
- static maxLengthLineIndex(e, t) {
1287
- let n = 0, s = -1;
1288
- for (let i = 0; i < e.length; i++) {
1289
- if (t && t(e[i])) continue;
1290
- const r = e[i].length();
1291
- r > n && (n = r, s = i);
1383
+ queryPointSelf(e) {
1384
+ if (this.targetMap.has(e)) {
1385
+ const { target: t } = this.targetMap.get(e);
1386
+ return t;
1292
1387
  }
1293
- return s;
1294
- }
1295
- }
1296
- async function H(d, e = !0) {
1297
- if (typeof global < "u" && typeof require < "u")
1298
- return require(d);
1299
- {
1300
- let t = await import(
1301
- /* @vite-ignore */
1302
- d
1303
- );
1304
- return e && (t = t.default), t;
1388
+ return null;
1305
1389
  }
1306
1390
  }
1307
- const $e = {
1391
+ const at = {
1308
1392
  Unitless: 1,
1309
1393
  // 无单位,1米 = 1(无单位)
1310
1394
  Inches: 39.37007874015748,
@@ -1348,27 +1432,27 @@ const $e = {
1348
1432
  Parsecs: 3240779289666404e-32
1349
1433
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
1350
1434
  };
1351
- function fe(d) {
1435
+ function Ee(f) {
1352
1436
  const e = [];
1353
- for (let t = 0; t < d.length; t++)
1354
- e.push(new B(
1355
- d[t].clone(),
1356
- d[(t + 1) % d.length].clone()
1437
+ for (let t = 0; t < f.length; t++)
1438
+ e.push(new N(
1439
+ f[t].clone(),
1440
+ f[(t + 1) % f.length].clone()
1357
1441
  ));
1358
1442
  return e;
1359
1443
  }
1360
- function pe(d) {
1361
- return d.flatMap((e, t) => (t === d.length - 1 && [...e.points, d[0].points[0]], [e.points[0]]));
1444
+ function De(f) {
1445
+ return f.flatMap((e, t) => (t === f.length - 1 && [...e.points, f[0].points[0]], [e.points[0]]));
1362
1446
  }
1363
- class X extends W {
1447
+ class $ extends ne {
1364
1448
  static name = "Dxf";
1365
1449
  shortLine = 0.04;
1366
1450
  width = 0.04;
1367
1451
  scale = 1;
1368
1452
  originalData = [];
1369
1453
  data = [];
1370
- originalBox = new _(0, 0, 0, 0);
1371
- box = new _(0, 0, 0, 0);
1454
+ originalBox = new j(0, 0, 0, 0);
1455
+ box = new j(0, 0, 0, 0);
1372
1456
  pointsGroups = [];
1373
1457
  wallsGroup = [];
1374
1458
  doors = [];
@@ -1393,7 +1477,6 @@ class X extends W {
1393
1477
  return this.lineSegments;
1394
1478
  }
1395
1479
  /**初始化
1396
- * @param data 点云数据
1397
1480
  * @param width 墙体宽度
1398
1481
  * @param scale 缩放比例
1399
1482
  */
@@ -1404,60 +1487,62 @@ class X extends W {
1404
1487
  * 预处理数据
1405
1488
  * @param data
1406
1489
  */
1407
- preprocessing(e, t = !1) {
1408
- const n = [];
1409
- let s = -1;
1410
- e.forEach(({ start: r, end: o, ...a }, l) => {
1411
- const c = new B(
1412
- w.from(r),
1413
- w.from(o)
1490
+ preprocessing(e, t = !1, n) {
1491
+ let s = [], i = -1;
1492
+ 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)
1414
1498
  );
1415
- c.userData = a, n.push(c), a.isVerticalReferenceLine && (s = l);
1416
- }), s === -1 && (s = B.maxLengthLineIndex(n, (r) => !r.userData.insetionArr?.length));
1417
- const i = n[s];
1418
- if (i.userData.isVerticalReferenceLine = !0, e[s].isVerticalReferenceLine = !0, t) {
1419
- const r = X.axisAlignmentCorrection(n, i);
1420
- return s = B.maxLengthLineIndex(r, (o) => !o.userData.insetionArr?.length), r[s].userData.isVerticalReferenceLine = !0, {
1421
- lineSegments: r,
1422
- data: this.lineDataToOriginalData(r)
1423
- };
1424
- }
1425
- return {
1426
- lineSegments: n,
1427
- data: e
1428
- };
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));
1501
+ 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({
1503
+ type: "preprocessing",
1504
+ data: e,
1505
+ setData(a) {
1506
+ s = a.map(({ start: l, end: c, ...h }) => {
1507
+ const d = new N(g.from(l), g.from(c));
1508
+ return d.userData = h, d;
1509
+ }), e = a;
1510
+ }
1511
+ }), { lineSegments: s, data: e };
1429
1512
  }
1430
- /**
1431
- * 设置
1432
- * @param data
1433
- * @param width
1434
- * @param scale
1513
+ /** 设置
1514
+ * @param data 房屋结构数据,node环境可以为路径
1515
+ * @param width 墙体宽度
1516
+ * @param scale 缩放比例
1517
+ * @param axisAlignmentCorrection 需要执行轴对称垂直纠正
1518
+ * @param option
1519
+ * @returns
1435
1520
  */
1436
- async set(e, t = this.width, n = this.scale, s = !1) {
1521
+ async set(e, t = this.width, n = this.scale, s = !1, i) {
1437
1522
  if (typeof e == "string")
1438
1523
  if (typeof global < "u") {
1439
- const { default: a } = await import(
1524
+ const { default: l } = await import(
1440
1525
  /* @vite-ignore */
1441
1526
  "fs"
1442
- ), l = a.readFileSync(e), c = JSON.parse(l.toString("utf-8"));
1443
- return this.set(c, t, n, s);
1527
+ ), c = l.readFileSync(e), h = JSON.parse(c.toString("utf-8"));
1528
+ return this.set(h, t, n, s);
1444
1529
  } else
1445
1530
  throw new Error("非node环境不允许使用路径");
1446
1531
  this.scale = n, this.width = t;
1447
- const i = this.preprocessing(e, s);
1448
- e = i.data, this.lineSegments = i.lineSegments, this.originalData = e;
1449
- const r = [];
1450
- this.data = e.map(({ start: o, end: a, insetionArr: l, isDoor: c = !1 }, h) => {
1451
- r.push(o.z ?? 0, a.z ?? 0);
1452
- const f = this.lineSegments[h];
1532
+ const r = this.preprocessing(e, s, i);
1533
+ e = r.data, this.lineSegments = r.lineSegments, this.originalData = e;
1534
+ 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);
1537
+ const u = this.lineSegments[d];
1453
1538
  return [
1454
- f.points[0],
1455
- f.points[1],
1456
- (l ?? []).map((u) => u.index),
1457
- c,
1458
- h
1539
+ u.points[0],
1540
+ u.points[1],
1541
+ (c ?? []).map((p) => p.index),
1542
+ h,
1543
+ d
1459
1544
  ];
1460
- }), this.originalZAverage = r.reduce((o, a) => o + a, 0) / r.length, this.computedOriginalSize(e, this.originalBox), this.dispatchEvent({
1545
+ }), this.originalZAverage = o.reduce((a, l) => a + l, 0) / o.length, this.computedOriginalSize(e, this.originalBox), this.dispatchEvent({
1461
1546
  type: "setDta",
1462
1547
  originalData: this.originalData,
1463
1548
  data: this.data
@@ -1472,8 +1557,8 @@ class X extends W {
1472
1557
  */
1473
1558
  createGroups() {
1474
1559
  const e = [], t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
1475
- const [l, c, h, f] = this.data[r];
1476
- if (t.add(r), f)
1560
+ const [l, c, h, d] = this.data[r];
1561
+ if (t.add(r), d)
1477
1562
  return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
1478
1563
  o.push([l, c]), h.forEach((u) => {
1479
1564
  t.has(u) || i(u, o, r);
@@ -1568,7 +1653,7 @@ class X extends W {
1568
1653
  break;
1569
1654
  }
1570
1655
  }
1571
- const t = this.mergeSameDirectionLine(fe(e)), n = [t[0]];
1656
+ const t = this.mergeSameDirectionLine(Ee(e)), n = [t[0]];
1572
1657
  for (let s = 1; s < t.length; s++) {
1573
1658
  const i = t[s], r = t[(t.length + s - 1) % t.length];
1574
1659
  if (i.length() > this.width * 0.9) {
@@ -1583,7 +1668,7 @@ class X extends W {
1583
1668
  const a = t[s + 2];
1584
1669
  a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
1585
1670
  }
1586
- return n.length > 3 ? pe(this.mergeSameDirectionLine(n)) : [];
1671
+ return n.length > 3 ? De(this.mergeSameDirectionLine(n)) : [];
1587
1672
  }
1588
1673
  /**
1589
1674
  * 移除短线段
@@ -1591,7 +1676,7 @@ class X extends W {
1591
1676
  * @param path
1592
1677
  */
1593
1678
  removeShortLine(e, t = this.shortLine) {
1594
- const n = fe(e), s = [], i = Math.PI / 180;
1679
+ const n = Ee(e), s = [], i = Math.PI / 180;
1595
1680
  for (let r = 0; r < n.length; r++) {
1596
1681
  const o = n[r], a = o.length(), l = r;
1597
1682
  if (a > t || s.length === 0) {
@@ -1599,9 +1684,9 @@ class X extends W {
1599
1684
  continue;
1600
1685
  }
1601
1686
  let c = n[++r];
1602
- const h = s[s.length - 1], f = h.direction();
1687
+ const h = s[s.length - 1], d = h.direction();
1603
1688
  for (; r < n.length; ) {
1604
- const p = f.angleBetween(c.direction()) / i;
1689
+ const p = d.angleBetween(c.direction()) / i;
1605
1690
  if (c.length() <= t || p < 4 || p > 176)
1606
1691
  c = n[++r];
1607
1692
  else break;
@@ -1619,20 +1704,20 @@ class X extends W {
1619
1704
  } else
1620
1705
  r = l;
1621
1706
  }
1622
- return s.length > 3 ? pe(s) : [];
1707
+ return s.length > 3 ? De(s) : [];
1623
1708
  }
1624
1709
  /** 线偏移
1625
1710
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
1626
1711
  */
1627
- lineOffset(e = X.EndType.etOpenSquare, t = X.JoinType.jtMiter, n = 1e4) {
1628
- let s = new de.Paths();
1629
- const i = new de.ClipperOffset(20, 0.25);
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);
1630
1715
  return this.pointsGroups.forEach((r) => {
1631
1716
  const o = this.lineTopology(r).map((a) => a.map((l) => l.clone().mutiplyScalar(n)));
1632
1717
  i.AddPaths(o, t, e);
1633
1718
  }), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
1634
- let o = r.map((a) => w.from(a).divisionScalar(n));
1635
- return o = this.lineSegmentStraightening(o), e == X.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
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;
1636
1721
  }), this.dispatchEvent({
1637
1722
  type: "lineOffset",
1638
1723
  wallsGroup: this.wallsGroup
@@ -1667,31 +1752,13 @@ class X extends W {
1667
1752
  * 线段数据转为原始json数据
1668
1753
  */
1669
1754
  lineDataToOriginalData(e, t) {
1670
- return t || (t = new Y(_.fromByLineSegment(...e)), e.forEach((n) => t?.insert({ line: n, userData: void 0 }))), e.map((n) => {
1671
- const s = n.userData, i = s.drawWindow, r = t.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: e.indexOf(o.line) }));
1672
- return {
1673
- start: n.start.toJson(this.originalZAverage),
1674
- end: n.end.toJson(this.originalZAverage),
1675
- insetionArr: r,
1676
- isDoor: s.isDoor,
1677
- doorDirectConnection: s.isDoor,
1678
- length: n.length(),
1679
- isWindow: s.isWindow,
1680
- isVerticalReferenceLine: s.isVerticalReferenceLine,
1681
- wallWidth: n.userData.wallWidth,
1682
- drawWindow: i && i.map((o) => ({
1683
- p: { x: o.p.x, y: o.p.y, z: o.p.z },
1684
- width: o.width,
1685
- full: o.full
1686
- }))
1687
- };
1688
- });
1755
+ return $.lineDataToOriginalData(e, this.originalZAverage, t);
1689
1756
  }
1690
1757
  /**
1691
1758
  * 转为绘制数据
1692
1759
  */
1693
1760
  toDrawDataJson(e = "Millimeters") {
1694
- const t = $e[e], n = {
1761
+ const t = at[e], n = {
1695
1762
  unit: e,
1696
1763
  line: [],
1697
1764
  arc: [],
@@ -1705,13 +1772,13 @@ class X extends W {
1705
1772
  function i(l, c) {
1706
1773
  n.line.push([l.x * t, l.y * t, c.x * t, c.y * t, s]);
1707
1774
  }
1708
- function r(l, c, h, f) {
1775
+ function r(l, c, h, d) {
1709
1776
  n.arc.push([
1710
1777
  l.x * t,
1711
1778
  l.y * t,
1712
1779
  c * t,
1713
1780
  h,
1714
- f,
1781
+ d,
1715
1782
  s
1716
1783
  ]);
1717
1784
  }
@@ -1724,7 +1791,7 @@ class X extends W {
1724
1791
  }
1725
1792
  this.wallsGroup.forEach((l) => {
1726
1793
  for (let c = 0; c < l.length; c++) {
1727
- const h = l[c], f = c === l.length - 1 ? 0 : c + 1, u = l[f];
1794
+ const h = l[c], d = c === l.length - 1 ? 0 : c + 1, u = l[d];
1728
1795
  i(h, u);
1729
1796
  }
1730
1797
  });
@@ -1735,29 +1802,29 @@ class X extends W {
1735
1802
  if (s = "cyan", c.length() < 1.2) {
1736
1803
  c.expansion(-o * 0.5);
1737
1804
  const h = l.normal();
1738
- let f = new B(
1805
+ let d = new N(
1739
1806
  c.start.clone(),
1740
1807
  c.start.clone().add(h.clone().multiplyScalar(c.length()))
1741
1808
  );
1742
- const u = f.clone().directionMove(f.normal(), c.length() * -0.5).expandToRectangle(c.length(), "bothSides");
1743
- for (let m = 0; m < a.length; m++)
1744
- if (a[m].intersectRectangle(u)) {
1745
- f = new B(
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(
1746
1813
  c.start.clone(),
1747
1814
  c.start.clone().add(h.clone().multiplyScalar(-c.length()))
1748
1815
  );
1749
1816
  break;
1750
1817
  }
1751
- f.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((m, E) => i(m, E));
1752
- const p = c.length(), y = f.length(), x = (p ** 2 + y ** 2) / (2 * y), S = f.end.clone().add(f.direction().multiplyScalar(-x)), [b, C] = this.getArcAngleRange(S, c.end, f.end);
1753
- r(S, x, Math.min(b, C), Math.max(b, C)), a.push(u);
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);
1754
1821
  } else
1755
- c.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, f) => i(h, f)), 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, f) => i(h, f)), 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, f) => i(h, f));
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));
1756
1823
  }), s = "yellow", this.lineSegments.forEach((l) => {
1757
1824
  if (!l.userData.isWindow) return !1;
1758
1825
  Array.isArray(l.userData.drawWindow) && l.userData.drawWindow.forEach((c) => {
1759
- const { p: h, width: f } = c, u = w.from(h), p = u.clone().add(l.direction().multiplyScalar(f * 0.5)), y = u.clone().add(l.direction().multiplyScalar(-f * 0.5)), x = new B(p, y);
1760
- i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((S, b) => i(S, b));
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));
1761
1828
  });
1762
1829
  }), n;
1763
1830
  }
@@ -1771,7 +1838,7 @@ class X extends W {
1771
1838
  if (typeof window < "u")
1772
1839
  i = document.createElement("canvas");
1773
1840
  else if (typeof global < "u") {
1774
- const { createCanvas: l } = await H("canvas");
1841
+ const { createCanvas: l } = await se("canvas");
1775
1842
  i = l();
1776
1843
  } else
1777
1844
  throw new Error("创建画布失败");
@@ -1782,12 +1849,12 @@ class X extends W {
1782
1849
  };
1783
1850
  i.width = s.width + r * 2, i.height = s.height + r * 2;
1784
1851
  const a = i.getContext("2d");
1785
- 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, f, u]) => {
1786
- a.strokeStyle = o[u], a.beginPath(), a.moveTo(l, c), a.lineTo(h, f), a.closePath(), a.stroke();
1787
- }), s.arc.forEach(([l, c, h, f, u, p]) => {
1788
- a.strokeStyle = o[p], a.beginPath(), a.arc(l, c, h, f * (Math.PI / 180), u * (Math.PI / 180)), a.stroke();
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();
1789
1856
  }), a.beginPath(), s.dimensionLine.forEach((l) => {
1790
- let [c, h, f, u] = l;
1857
+ let [c, h, d, u] = l;
1791
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;
1792
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);
1793
1860
  }), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((l) => {
@@ -1800,8 +1867,8 @@ class X extends W {
1800
1867
  * 将点json结构转换为Dxf string
1801
1868
  */
1802
1869
  toDxfString(e = "Millimeters") {
1803
- const t = new $();
1804
- t.setUnits(e), t.addLayer("cyan", $.ACI.CYAN, "DOTTED"), t.addLayer("yellow", $.ACI.YELLOW, "DOTTED"), t.addLayer("white", $.ACI.WHITE, "DOTTED");
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");
1805
1872
  const n = this.toDrawDataJson();
1806
1873
  return n.line.forEach((s) => {
1807
1874
  let [i, r, o, a, l] = s;
@@ -1827,7 +1894,7 @@ class X extends W {
1827
1894
  if (typeof window < "u") {
1828
1895
  const n = new Blob([t], { type: "application/json" }), s = document.createElement("a");
1829
1896
  s.href = URL.createObjectURL(n), s.download = e, s.click();
1830
- } else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, t);
1897
+ } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, t);
1831
1898
  }
1832
1899
  /**
1833
1900
  * 下载
@@ -1837,7 +1904,7 @@ class X extends W {
1837
1904
  if (typeof window < "u") {
1838
1905
  const n = this.toDxfBlob(t), s = document.createElement("a");
1839
1906
  s.href = URL.createObjectURL(n), s.download = e + ".dxf", s.click();
1840
- } else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, this.toDxfString(t));
1907
+ } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, this.toDxfString(t));
1841
1908
  }
1842
1909
  /**
1843
1910
  * 下载
@@ -1849,7 +1916,7 @@ class X extends W {
1849
1916
  if (typeof window < "u") {
1850
1917
  const i = document.createElement("a");
1851
1918
  i.href = URL.createObjectURL(s), i.download = e, i.click();
1852
- } else typeof global < "u" ? (await H("fs", !1)).writeFileSync(e, s) : console.error("图片下载失败");
1919
+ } else typeof global < "u" ? (await se("fs", !1)).writeFileSync(e, s) : console.error("图片下载失败");
1853
1920
  return !0;
1854
1921
  }
1855
1922
  /**
@@ -1857,10 +1924,34 @@ class X extends W {
1857
1924
  * @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
1858
1925
  * @returns
1859
1926
  */
1860
- computedOriginalSize(e, t = new _(0, 0, 0, 0)) {
1927
+ computedOriginalSize(e, t = new j(0, 0, 0, 0)) {
1861
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);
1862
1929
  return t.set(i, r, o, a), t;
1863
1930
  }
1931
+ /**
1932
+ * 线段数据转为原始json数据
1933
+ */
1934
+ 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) => {
1936
+ 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
+ return {
1938
+ start: s.start.toJson(t),
1939
+ end: s.end.toJson(t),
1940
+ insetionArr: o,
1941
+ isDoor: i.isDoor,
1942
+ doorDirectConnection: i.isDoor,
1943
+ length: s.length(),
1944
+ isWindow: i.isWindow,
1945
+ isVerticalReferenceLine: i.isVerticalReferenceLine,
1946
+ wallWidth: s.userData.wallWidth,
1947
+ drawWindow: r && r.map((a) => ({
1948
+ p: { x: a.p.x, y: a.p.y, z: a.p.z },
1949
+ width: a.width,
1950
+ full: a.full
1951
+ }))
1952
+ };
1953
+ });
1954
+ }
1864
1955
  /**
1865
1956
  * 创建数据
1866
1957
  * @param pointsGroups
@@ -1890,218 +1981,316 @@ class X extends W {
1890
1981
  * @param targettLine 轴线段
1891
1982
  * @returns
1892
1983
  */
1893
- static axisAlignmentCorrection(e, t) {
1894
- function n(m) {
1895
- const E = new ce();
1896
- m.forEach((M) => M.userData.isDoor || M.points.forEach((g) => E.insert(g, M)));
1984
+ static axisAlignmentCorrection(e, t, n) {
1985
+ const { principalAxisThreshold: s = 0.3, crossAxistThreshold: i = 0.06, snapThreshold: r = 0.2 } = n ?? {};
1986
+ function o(D, b) {
1897
1987
  const L = [];
1898
- for (let M = 0; M < m.length; M++) {
1899
- const g = m[M], D = /* @__PURE__ */ new Map();
1900
- g.userData.isDoor || g.points.forEach((T) => {
1901
- if (E.queryPoint(T).length > 1) return;
1902
- const A = E.queryCircle(T, 0.4).filter((R) => {
1903
- const I = R.userData;
1904
- if (I === g || !g.parallel(I, 25)) return !1;
1905
- if (E.queryPoint(R.point).length > 1) return;
1906
- const N = new B(T, R.point), F = new B(g.start === T ? g.end : g.start, I.start === R.point ? I.end : I.start);
1907
- if (!N.intersectLineSegment(F)) return !1;
1908
- const O = T.distance(R.point);
1909
- return O < 1e-3 ? !1 : (D.set(R.point, O), !0);
1910
- }).sort((R, I) => {
1911
- const N = D.get(R.point), F = D.get(I.point);
1912
- return N - F;
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;
1913
2003
  });
1914
2004
  if (A.length === 0) return;
1915
- const P = A[0].userData;
1916
- L.push(new B(g.projectLineSegment(P).center, P.projectLineSegment(g).center));
2005
+ const B = A[0].userData;
2006
+ L.push(new N(m.projectLineSegment(B).center, B.projectLineSegment(m).center));
1917
2007
  });
1918
2008
  }
1919
- return [...m, ...L];
2009
+ return [...D, ...L];
1920
2010
  }
1921
- function s(m, E) {
1922
- const L = [m], M = [], g = [], D = [];
1923
- for (let T = 0; T < E.length; T++) {
1924
- const A = E[T];
1925
- if (m !== A) {
1926
- if (A.userData.isDoor) {
1927
- g.push(A);
1928
- continue;
1929
- }
1930
- if (A.userData.isWindow && D.push(A), A.parallel(m, 45)) {
1931
- const P = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x);
1932
- let I = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x) - P;
1933
- for (; I > Math.PI; ) I -= 2 * Math.PI;
1934
- for (; I < -Math.PI; ) I += 2 * Math.PI;
1935
- const N = A.center;
1936
- A.start.rotate(N, I), A.end.rotate(N, I), L.push(A);
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;
2019
+ }
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 });
2024
+ });
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));
2029
+ }
2030
+ return L;
2031
+ }
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);
1937
2044
  } else {
1938
- const P = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x), R = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x);
1939
- let I = R + Math.PI / 2 - P, N = R - Math.PI / 2 - P;
1940
- for (; I > Math.PI; ) I -= 2 * Math.PI;
1941
- for (; I < -Math.PI; ) I += 2 * Math.PI;
1942
- for (; N > Math.PI; ) N -= 2 * Math.PI;
1943
- for (; N < -Math.PI; ) N += 2 * Math.PI;
1944
- const F = Math.abs(I) < Math.abs(N) ? I : N, O = A.center;
1945
- A.start.rotate(O, F), A.end.rotate(O, F), M.push(A);
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);
1946
2053
  }
1947
- }
1948
2054
  }
1949
- return { parallelLines: L, verticalLines: M, doorLines: g, windowLines: D };
2055
+ return { parallelLines: L, verticalLines: M, doorLines: m, windowLines: w };
1950
2056
  }
1951
- function i(m, E, L, M = 0.3, g = 0.06) {
1952
- const D = [];
1953
- m.forEach((P) => {
1954
- const R = L.projectPoint(P.start, !1);
1955
- R && (R.userData = P, D.push(R));
1956
- }), D.sort((P, R) => R.distance(L.start) - P.distance(L.start));
1957
- const T = [], A = [];
1958
- for (let P = 0; P < D.length; P++) {
1959
- const R = D[P];
1960
- if (P === 0) {
1961
- A.push(R);
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);
1962
2068
  continue;
1963
2069
  }
1964
- D[P - 1].distance(R) < g || (T.push([...A]), A.length = 0), A.push(R), P === D.length - 1 && T.push(A);
2070
+ M[I - 1].distance(A) < i || (m.push([...w]), w.length = 0), w.push(A), I === M.length - 1 && m.push(w);
1965
2071
  }
1966
- return T.flatMap((P) => {
1967
- const R = P.flatMap((O) => {
1968
- const z = O.userData;
1969
- return z.points.map((j) => {
1970
- const U = E.projectPoint(j, !1);
1971
- return U.userData = z, U;
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;
1972
2078
  });
1973
2079
  });
1974
- R.sort((O, z) => O.distance(E.start) - z.distance(E.start));
1975
- const I = /* @__PURE__ */ new Map(), N = [], F = [];
1976
- return R.forEach((O, z) => {
1977
- I.size === 0 && z > 0 && R[z - 1].distance(O) > M && (N.push([...F]), F.length = 0), I.set(O.userData, (I.get(O.userData) ?? 0) + 1);
1978
- for (const j of I.values()) if (j !== 2) return;
1979
- F.push(...I.keys()), I.clear();
1980
- }), N.push([...F]), N;
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;
1981
2087
  });
1982
2088
  }
1983
- function r(m, E = 0.1) {
1984
- return m.map((L) => {
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);
2096
+ });
2097
+ }
2098
+ }), D.map((M) => M.filter((m) => !L.has(m)));
2099
+ }
2100
+ function u(D, b = 0.1) {
2101
+ return D.map((L) => {
1985
2102
  if (L.length === 0) return;
1986
2103
  if (L.length === 1) return L[0];
1987
2104
  const M = [];
1988
- L.forEach((U) => {
1989
- M.push(U.start.clone(), U.end.clone());
2105
+ L.forEach((K) => {
2106
+ M.push(K.start.clone(), K.end.clone());
1990
2107
  });
1991
- const g = L[0].direction().normalize();
1992
- let D = 1 / 0, T = -1 / 0, A = 0, P = 0;
1993
- M.forEach((U) => {
1994
- const J = U.x * g.x + U.y * g.y;
1995
- D = Math.min(D, J), T = Math.max(T, J), A += U.x, P += U.y;
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;
1996
2113
  });
1997
- const R = new w(A / M.length, P / M.length), I = R.x * g.x + R.y * g.y, N = new w(R.x + (D - I) * g.x, R.y + (D - I) * g.y), F = new w(R.x + (T - I) * g.x, R.y + (T - I) * g.y), O = new B(N, F), z = L[0].normal().normalize();
1998
- D = 1 / 0, T = -1 / 0, M.forEach((U) => {
1999
- const J = U.x * z.x + U.y * z.y;
2000
- D = Math.min(D, J), T = Math.max(T, J);
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);
2001
2118
  });
2002
- const j = T - D;
2003
- return j >= E && (O.userData.wallWidth = j), L.forEach((U) => U.userData.fittedLine = O), O;
2119
+ const ie = I - w;
2120
+ return ie >= b && (Y.userData.wallWidth = ie), L.forEach((K) => K.userData.fittedLine = Y), Y;
2004
2121
  }).filter((L) => !!L);
2005
2122
  }
2006
- function o(m, E = 0.2) {
2007
- const L = new Y(_.fromByLineSegment(...m)), M = /* @__PURE__ */ new Map();
2008
- m.forEach((D) => {
2009
- M.set(D, { line: D, userData: void 0 }), L.insert(M.get(D));
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));
2010
2127
  });
2011
- const g = new B();
2012
- for (let D = 0; D < m.length; D++) {
2013
- const T = m[D];
2014
- if (T.userData.isAdsorbed) continue;
2015
- const A = T.direction().multiplyScalar(E), [P, R] = T.points.map((I) => {
2016
- g.set(I, I), g.start.add(A), g.end.add(A.multiplyScalar(-1));
2017
- const N = /* @__PURE__ */ new Map(), F = L.queryRect(g.expandToRectangle(0.1, "bothSides")).filter((O) => O.line !== T).map((O) => {
2018
- const z = O.line.getIntersection(g);
2019
- return N.set(O.line, z), O.line;
2020
- }).sort((O, z) => {
2021
- const j = N.get(O), U = N.get(z);
2022
- return j && U ? j.distance(I) - U.distance(I) : 0;
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;
2023
2140
  });
2024
- return F.length ? N.get(F[0]) : void 0;
2141
+ return _.length ? v.get(_[0]) : void 0;
2025
2142
  });
2026
- if (P && R) {
2027
- if (P.equal(R)) {
2028
- const I = T.start.distance(P), N = T.end.distance(R);
2029
- I < N ? T.directionMove(T.start.direction(T.end), I) : T.directionMove(T.end.direction(T.start), N);
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);
2030
2147
  } else
2031
- T.start.copy(P), T.end.copy(R);
2032
- T.userData.isAdsorbed = !0;
2033
- } else P ? T.start.copy(P) : R && T.end.copy(R);
2034
- L.remove(M.get(T)), L.insert(M.get(T));
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));
2035
2152
  }
2036
- return m.filter((D) => D.length() > 1e-3);
2153
+ return D.filter((m) => m.length() > 1e-3);
2037
2154
  }
2038
- function a(m) {
2039
- for (let E = 0; E < m.length; E++) {
2040
- const L = m[E], M = L.userData.fittedLine;
2155
+ function y(D) {
2156
+ for (let b = 0; b < D.length; b++) {
2157
+ const L = D[b], M = L.userData.fittedLine;
2041
2158
  if (M) {
2042
- const g = L.direction();
2043
- M.userData.isWindow = !0, M.userData.drawWindow = M.userData.drawWindow ?? [], L.userData.drawWindow?.forEach((D) => {
2044
- const T = w.from(D.p), A = M.projectPoint(
2045
- T.clone().add(g.clone().multiplyScalar(D.width * 0.5))
2046
- ), P = M.projectPoint(
2047
- T.clone().add(g.clone().multiplyScalar(D.width * -0.5))
2048
- ), R = new B(A, P), I = R.center;
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;
2049
2166
  M.userData.drawWindow?.push({
2050
- p: new G.Vector3(I?.x ?? 0, I?.y ?? 0, D.p.z),
2051
- width: R.length(),
2052
- full: D.full
2167
+ p: new z.Vector3(v?.x ?? 0, v?.y ?? 0, w.p.z),
2168
+ width: F.length(),
2169
+ full: w.full
2053
2170
  });
2054
2171
  });
2055
2172
  }
2056
2173
  }
2057
2174
  }
2058
- function l(m) {
2059
- const E = new Y(_.fromByLineSegment(...m));
2060
- return m.forEach((L) => E.insert({ line: L, userData: void 0 })), m.flatMap((L) => {
2061
- const M = E.queryLineSegment(L, !0).map((g) => {
2062
- if (g.line === L) return;
2063
- const D = g.line.getIntersection(L);
2064
- if (!(!D || L.start.equal(D) || L.end.equal(D)))
2065
- return D;
2066
- }).filter((g) => !!g);
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);
2182
+ else {
2183
+ const w = m.projectPoint(L.start);
2184
+ w && L.start.copy(w);
2185
+ }
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);
2188
+ else {
2189
+ const w = M.projectPoint(L.end);
2190
+ w && L.end.copy(w);
2191
+ }
2192
+ }
2193
+ }
2194
+ return D;
2195
+ }
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);
2067
2205
  if (M.length) {
2068
- const g = L.clone();
2069
- M.sort((T, A) => g.start.distance(T) - g.start.distance(A));
2070
- const D = M.map((T) => {
2071
- const A = g.clone();
2072
- return A.set(g.start.clone(), T), g.start.copy(T), g.userData.isWindow && (A.userData.isWindow = !0, A.userData.drawWindow = g.userData.drawWindow?.filter((P) => A.isPointOnSegment(w.from(P.p))) ?? []), A;
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;
2073
2211
  });
2074
- return g.userData.drawWindow = g.userData.drawWindow?.filter((T) => g.isPointOnSegment(w.from(T.p))) ?? [], [...D, g];
2212
+ return m.userData.drawWindow = m.userData.drawWindow?.filter((I) => m.isPointOnSegment(g.from(I.p))) ?? [], [...w, m];
2075
2213
  }
2076
2214
  return L;
2077
- }).filter((L) => L.length() > 0.05);
2215
+ }).filter((L) => L.length() > 0.03);
2078
2216
  }
2079
- e = n(e);
2080
- const { parallelLines: c, verticalLines: h, doorLines: f, windowLines: u } = s(t, e.map((m) => m.clone())), p = t.normal(), y = t.center, x = t.direction(), S = new B(
2081
- y.clone().add(p.clone().multiplyScalar(-1e3)),
2082
- y.clone().add(p.clone().multiplyScalar(1e3))
2083
- ), b = new B(
2084
- y.clone().add(x.clone().multiplyScalar(-1e3)),
2085
- y.clone().add(x.clone().multiplyScalar(1e3))
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))
2086
2224
  );
2087
- let C = r([
2088
- ...i.call(this, c, b, S),
2089
- ...i.call(this, h, S, b)
2090
- ]);
2091
- return C = o.call(this, C), C = o.call(this, C), a(u), C = l.call(this, C), [...C, ...f];
2225
+ let J = [
2226
+ ...h.call(this, G, W, k),
2227
+ ...h.call(this, E, k, W)
2228
+ ];
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;
2232
+ }
2233
+ /**
2234
+ * @param lines
2235
+ * @param trajectoryPoints
2236
+ * @returns
2237
+ */
2238
+ static findExteriorWall(e, t, n = 0.4) {
2239
+ const s = new Z(j.fromByLineSegment(...e));
2240
+ return e.forEach((i) => s.insert({ line: i, userData: void 0 })), e = e.filter((i) => {
2241
+ const r = i.center, o = /* @__PURE__ */ new Set();
2242
+ for (const a of t) {
2243
+ 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) {
2252
+ const h = i.pointPosition(a);
2253
+ h !== "on" && o.add(h);
2254
+ }
2255
+ }
2256
+ if (i.userData.expandDirect = [...o][0], o.size < 2) return !0;
2257
+ }), e;
2258
+ }
2259
+ /** 边线外扩
2260
+ * @param lines
2261
+ * @param trajectoryPoints
2262
+ */
2263
+ 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;
2268
+ });
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);
2278
+ }
2279
+ }), $.lineDataToOriginalData(r, o);
2092
2280
  }
2281
+ boundaryExtension = $.boundaryExtension;
2093
2282
  }
2094
- function le(d) {
2095
- if (d === null || typeof d != "object") return d;
2096
- if (d instanceof Date) return new Date(d.getTime());
2097
- if (Array.isArray(d)) return d.map(le);
2283
+ function we(f) {
2284
+ if (f === null || typeof f != "object") return f;
2285
+ if (f instanceof Date) return new Date(f.getTime());
2286
+ if (Array.isArray(f)) return f.map(we);
2098
2287
  const e = {};
2099
- for (const t in d)
2100
- Object.prototype.hasOwnProperty.call(d, t) && (e[t] = le(d[t]));
2288
+ for (const t in f)
2289
+ Object.prototype.hasOwnProperty.call(f, t) && (e[t] = we(f[t]));
2101
2290
  return e;
2102
2291
  }
2103
- const V = new B();
2104
- class Ze extends X {
2292
+ const ee = new N();
2293
+ class ct extends $ {
2105
2294
  static name = "AngleCorrectionDxf";
2106
2295
  angle = 0;
2107
2296
  onAddFromParent(e) {
@@ -2112,27 +2301,27 @@ class Ze extends X {
2112
2301
  let s = 0, i = null;
2113
2302
  for (let l = 0; l < t.originalData.length; l++) {
2114
2303
  const c = t.originalData[l];
2115
- if (V.start.copy(c.start), V.end.copy(c.end), c.isVerticalReferenceLine) {
2116
- const [h, f] = c.start.y < c.end.y ? [V.start, V.end] : [V.end, V.start];
2117
- s = -new B(h, f).direction().angleBetween(new w(0, 1), "angle", "360"), i = null;
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;
2118
2307
  break;
2119
2308
  }
2120
- (!i || V.length() > i.length()) && (i = V.clone(), i.userData.index = l);
2309
+ (!i || ee.length() > i.length()) && (i = ee.clone(), i.userData.index = l);
2121
2310
  }
2122
2311
  if (i) {
2123
2312
  t.originalData[i.userData.index].isVerticalReferenceLine = !0;
2124
2313
  const [l, c] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
2125
- s = -new B(l, c).direction().angleBetween(new w(0, 1), "angle", "360");
2314
+ s = -new N(l, c).direction().angleBetween(new g(0, 1), "angle", "360");
2126
2315
  }
2127
- const r = t.originalBox.center, o = w.zero(), a = t.originalData.map((l) => {
2128
- const c = o.copy(l.start).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(l.start.z), h = o.copy(l.end).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(l.end.z), f = Object.assign(le(l), { start: c, end: h });
2129
- return f.drawWindow && f.drawWindow.forEach((u) => {
2130
- u.p = o.copy(u.p).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(u.p.z);
2131
- }), f;
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 });
2318
+ 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);
2320
+ }), d;
2132
2321
  });
2133
2322
  n.appendLineSegmentList.forEach((l) => {
2134
2323
  const c = l.clone();
2135
- c.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), a.push({
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({
2136
2325
  start: c.start.toJson(t.originalZAverage),
2137
2326
  end: c.end.toJson(t.originalZAverage),
2138
2327
  insetionArr: [],
@@ -2140,13 +2329,13 @@ class Ze extends X {
2140
2329
  });
2141
2330
  }), await this.set(a, t.width, t.scale), this.lineOffset(), this.doorLineSegment = t.doorLineSegment.map((l) => {
2142
2331
  const c = l.clone();
2143
- return c.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), c;
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;
2144
2333
  }), this.angle = s, this.dispatchEvent({
2145
2334
  type: "updateData"
2146
2335
  });
2147
2336
  }
2148
2337
  }
2149
- class Ee extends W {
2338
+ class Ce extends ne {
2150
2339
  static name = "Variable";
2151
2340
  originalLineVisible = !0;
2152
2341
  dxfVisible = !0;
@@ -2173,13 +2362,13 @@ class Ee extends W {
2173
2362
  if (e in this) return this[e];
2174
2363
  }
2175
2364
  }
2176
- class Qe {
2365
+ class lt {
2177
2366
  // 所有可查找的点位
2178
2367
  possibleDoorPoints = [];
2179
2368
  doorPoint = [];
2180
2369
  dxf;
2181
2370
  // 包含所有点的虚拟网格
2182
- pointVirtualGrid = new ce();
2371
+ pointVirtualGrid = new ge();
2183
2372
  // 只包含可查找点的虚拟网格
2184
2373
  findPointVirtualGrid;
2185
2374
  quadtree;
@@ -2192,7 +2381,7 @@ class Qe {
2192
2381
  lineAnalysis;
2193
2382
  continueFind = !0;
2194
2383
  constructor(e) {
2195
- if (this.lineAnalysis = e, this.dxf = e.Dxf, this.findPointVirtualGrid = new ce(), this.quadtree = e.quadtree, this.resultList = e.resultList, this.lineSegments = e.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
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) => {
2196
2385
  this.pointVirtualGrid.insert(n.start, n), this.pointVirtualGrid.insert(n.end, n);
2197
2386
  }), this.doorPoint = this.getDoorPoint(), !this.continueFind) return;
2198
2387
  const t = this.searchDoubleLinePoint();
@@ -2222,15 +2411,15 @@ class Qe {
2222
2411
  );
2223
2412
  const a = [];
2224
2413
  return o.forEach((l) => {
2225
- const c = new B(l?.start, l?.end), h = c.length();
2414
+ const c = new N(l?.start, l?.end), h = c.length();
2226
2415
  if (h < n) return;
2227
- const f = c.normal(), u = c.direction(), p = (h - r.width * 2) / 2;
2416
+ const d = c.normal(), u = c.direction(), p = (h - r.width * 2) / 2;
2228
2417
  for (let y = 0; y < 3; y++) {
2229
- const x = c.start.clone().add(u.clone().multiplyScalar(r.width + p * y)), S = new B(
2418
+ const x = c.start.clone().add(u.clone().multiplyScalar(r.width + p * y)), S = new N(
2230
2419
  x,
2231
- x.clone().add(f.clone().multiplyScalar(1))
2420
+ x.clone().add(d.clone().multiplyScalar(1))
2232
2421
  );
2233
- if (S.directionMove(f, -0.5), this.quadtree.queryLineSegment(S).length) return;
2422
+ if (S.directionMove(d, -0.5), this.quadtree.queryLineSegment(S).length) return;
2234
2423
  }
2235
2424
  a.push(c);
2236
2425
  }), a;
@@ -2250,7 +2439,7 @@ class Qe {
2250
2439
  return this.lineSegments.forEach((t) => {
2251
2440
  t.points.forEach((n, s) => {
2252
2441
  for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](t, n, s)) return;
2253
- this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid: ae() });
2442
+ this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid: me() });
2254
2443
  });
2255
2444
  }), e;
2256
2445
  }
@@ -2262,21 +2451,21 @@ class Qe {
2262
2451
  return t.doors.forEach((s) => {
2263
2452
  const i = t.lineSegments[s[4]], r = t.originalData[s[4]];
2264
2453
  if (r.drawDoorData) {
2265
- const o = w.from(r.drawDoorData.start), a = w.from(r.drawDoorData.n), l = n.queryPoint(o).filter((c) => {
2454
+ const o = g.from(r.drawDoorData.start), a = g.from(r.drawDoorData.n), l = n.queryPoint(o).filter((c) => {
2266
2455
  if (c.userData === i) return !1;
2267
- const h = c.userData, f = h.direction();
2268
- h.start.equal(o) && f.multiplyScalar(-1);
2269
- const u = a.angleBetween(f, "angle");
2456
+ const h = c.userData, d = h.direction();
2457
+ h.start.equal(o) && d.multiplyScalar(-1);
2458
+ const u = a.angleBetween(d, "angle");
2270
2459
  return u > 80 || u < 10;
2271
2460
  });
2272
2461
  l.length && e.push({
2273
2462
  line: l[0].userData,
2274
2463
  point: o,
2275
- uuid: ae()
2464
+ uuid: me()
2276
2465
  });
2277
2466
  } else if (r.doorDirectConnection) {
2278
2467
  this.continueFind = !1;
2279
- const o = new B(w.from(r.start), w.from(r.end));
2468
+ const o = new N(g.from(r.start), g.from(r.end));
2280
2469
  o.userData = {
2281
2470
  doorDirectConnection: !0,
2282
2471
  isDoor: !0
@@ -2306,83 +2495,83 @@ class Qe {
2306
2495
  */
2307
2496
  searchNearby(e, t = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
2308
2497
  const i = this.findPointVirtualGrid, r = this.quadtree;
2309
- function o({ point: x, line: S }, b, C) {
2310
- const m = S.direction();
2311
- S.start === x && m.multiplyScalar(-1);
2312
- const E = i.queryCircle(x, n).filter((M) => M.userData !== S).sort((M, g) => M.point.distance(x) - g.point.distance(x)), L = [];
2313
- for (let M = 0; M < E.length; M++) {
2314
- const g = t.findIndex((I) => I.point === E[M].point), D = e[b].uuid, T = t[g].uuid;
2315
- if (C.has(`${D}.${T}`)) continue;
2316
- C.add(`${D}.${T}`), C.add(`${T}.${D}`);
2317
- const A = E[M].point, P = new B(x.clone(), A.clone());
2318
- if (P.direction().angleBetween(m, "angle") < s) {
2319
- const I = e[g].line.direction();
2320
- E[M].userData.start.equal(E[M].point) && I.multiplyScalar(-1), P.direction().multiplyScalar(-1).angleBetween(I, "angle") < s && (r.queryLineSegment(P).length || L.push({
2321
- findData: E[M],
2322
- findUuid: T,
2323
- doorLine: P,
2324
- doorUuid: D
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],
2511
+ findUuid: k,
2512
+ doorLine: J,
2513
+ doorUuid: X
2325
2514
  }));
2326
2515
  }
2327
2516
  }
2328
- return L;
2517
+ return U;
2329
2518
  }
2330
- function a(x, S, b, C, m) {
2331
- C.add(x);
2332
- const E = [];
2333
- m && E.push(m);
2334
- for (let L = 0; L < b.length; L++) {
2335
- const M = b[L];
2336
- if (S.has(M.findUuid)) {
2337
- const g = S.get(M.findUuid);
2338
- a(M.findUuid, S, g, C, M) && E.push(M);
2339
- } else E.push(M);
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);
2340
2529
  }
2341
- return E.sort((L, M) => L.doorLine.length() - M.doorLine.length()), m && E[0] === m ? (b.splice(0), !0) : (b.splice(1), !1);
2530
+ return R.sort((U, P) => U.doorLine.length() - P.doorLine.length()), E && R[0] === E ? (T.splice(0), !0) : (T.splice(1), !1);
2342
2531
  }
2343
2532
  const l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
2344
2533
  e.map((x, S) => {
2345
- const b = o(x, S, l);
2346
- b.length && c.set(x.uuid, b);
2534
+ const T = o(x, S, l);
2535
+ T.length && c.set(x.uuid, T);
2347
2536
  }), l.clear();
2348
2537
  const h = /* @__PURE__ */ new Map();
2349
2538
  c.forEach((x, S) => {
2350
2539
  if (!l.has(S) && x.length && a(S, c, x, l), x.length) {
2351
- const b = x[0];
2352
- h.has(b.doorUuid) || h.set(b.doorUuid, []), h.get(b.doorUuid)?.push(b), h.has(b.findUuid) || h.set(b.findUuid, []), h.get(b.findUuid)?.push(b);
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);
2353
2542
  }
2354
2543
  });
2355
- const f = /* @__PURE__ */ new Set();
2544
+ const d = /* @__PURE__ */ new Set();
2356
2545
  h.forEach((x) => {
2357
2546
  if (x.length > 1) {
2358
- x.sort((S, b) => S.doorLine.length() - b.doorLine.length());
2359
- for (let S = 1; S < x.length; S++) f.add(x[S]);
2547
+ x.sort((S, T) => S.doorLine.length() - T.doorLine.length());
2548
+ for (let S = 1; S < x.length; S++) d.add(x[S]);
2360
2549
  }
2361
2550
  });
2362
2551
  const u = [], p = [];
2363
2552
  c.forEach((x) => {
2364
2553
  if (x.length) {
2365
2554
  const S = x[0];
2366
- f.has(S) || (u.push(S), p.push(S.doorUuid, S.findUuid));
2555
+ d.has(S) || (u.push(S), p.push(S.doorUuid, S.findUuid));
2367
2556
  }
2368
2557
  });
2369
2558
  const y = [];
2370
2559
  return u.forEach((x) => {
2371
- const S = e.findIndex((g) => g.uuid === x.doorUuid), b = t.findIndex((g) => g.uuid === x.findUuid), C = e[S].point.clone(), m = t[b].point.clone(), E = this.findLongLineSegment(e[S].line), L = this.findLongLineSegment(t[b].line), M = E.projectPoint(m);
2372
- if (M) {
2373
- C.copy(M);
2374
- const g = new B(C, m), D = L.includedAngle(g);
2375
- (D < 10 || D > 170 || Math.abs(90 - D) < 10) && y.push({
2376
- start: C,
2377
- end: m
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);
2561
+ 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
2378
2567
  });
2379
2568
  } else {
2380
- const g = L.projectPoint(C);
2381
- g && m.copy(g);
2382
- const D = new B(C, m), T = E.includedAngle(D);
2383
- (T < 10 || T > 170 || Math.abs(90 - T) < 10) && y.push({
2384
- start: C,
2385
- end: m
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
2386
2575
  });
2387
2576
  }
2388
2577
  }), t.splice(
@@ -2403,7 +2592,7 @@ class Qe {
2403
2592
  searchAlongDirection({ point: e, line: t }, n = this.doorSearchDistance) {
2404
2593
  const s = this.quadtree, i = t.direction();
2405
2594
  t.start === e && i.multiplyScalar(-1);
2406
- const r = e.clone().add(i.clone().multiplyScalar(n)), o = new B(e.clone(), r), a = s.queryLineSegment(o).map((l) => ({
2595
+ const r = e.clone().add(i.clone().multiplyScalar(n)), o = new N(e.clone(), r), a = s.queryLineSegment(o).map((l) => ({
2407
2596
  point: l.line.getIntersection(o),
2408
2597
  line: l.line
2409
2598
  })).filter((l) => l.point).sort((l, c) => e.distance(l.point) - e.distance(c.point));
@@ -2422,22 +2611,22 @@ class Qe {
2422
2611
  searchAlongNormalDirection({ point: e, line: t }, n = this.doorSearchDistance) {
2423
2612
  const s = this.pointVirtualGrid, i = this.quadtree, r = t.direction(), o = t.start.normal(t.end), a = t.start.clone();
2424
2613
  t.start === e && r.multiplyScalar(-1), t.start === e && a.copy(t.end);
2425
- const l = s.queryPoint(a).filter((f) => f.userData !== t);
2426
- for (let f = 0; f < l.length; f++) {
2427
- const u = l[f], p = u.userData, y = p.direction();
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();
2428
2617
  if (p.start === u.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
2429
2618
  o.multiplyScalar(-1);
2430
2619
  break;
2431
2620
  }
2432
2621
  }
2433
- const c = new B(e.clone(), e.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(c).map((f) => ({
2434
- point: f.line.getIntersection(c),
2435
- line: f.line
2436
- })).filter((f) => f.point).sort((f, u) => e.distance(f.point) - e.distance(u.point));
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),
2624
+ line: d.line
2625
+ })).filter((d) => d.point).sort((d, u) => e.distance(d.point) - e.distance(u.point));
2437
2626
  if (h.length) {
2438
- const f = h[0];
2439
- if (Math.abs(90 - f.line.direction().angleBetween(o, "angle")) < 5)
2440
- return f;
2627
+ const d = h[0];
2628
+ if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
2629
+ return d;
2441
2630
  }
2442
2631
  }
2443
2632
  /**
@@ -2464,12 +2653,12 @@ class Qe {
2464
2653
  return t;
2465
2654
  }
2466
2655
  }
2467
- class et extends W {
2656
+ class ht extends ne {
2468
2657
  static name = "LineAnalysis";
2469
2658
  Dxf = null;
2470
2659
  Variable = null;
2471
2660
  lineSegmentList = [];
2472
- container = new G.Group();
2661
+ container = new z.Group();
2473
2662
  // 误差角度
2474
2663
  errorAngle = 4;
2475
2664
  width = 0.4;
@@ -2478,7 +2667,7 @@ class et extends W {
2478
2667
  * @param parent
2479
2668
  */
2480
2669
  onAddFromParent(e) {
2481
- this.Dxf = e.findComponentByType(X), this.Variable = this.parent?.findComponentByType(Ee), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
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));
2482
2671
  }
2483
2672
  /**
2484
2673
  *
@@ -2492,11 +2681,11 @@ class et extends W {
2492
2681
  return {
2493
2682
  points: [
2494
2683
  // 第一条线
2495
- new w(e.x + o, e.y + a).add(r),
2496
- new w(t.x + o, t.y + a).add(i),
2684
+ new g(e.x + o, e.y + a).add(r),
2685
+ new g(t.x + o, t.y + a).add(i),
2497
2686
  // 第二条线
2498
- new w(e.x - o, e.y - a).add(r),
2499
- new w(t.x - o, t.y - a).add(i)
2687
+ new g(e.x - o, e.y - a).add(r),
2688
+ new g(t.x - o, t.y - a).add(i)
2500
2689
  ],
2501
2690
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2502
2691
  rectIndices: [0, 1, 3, 2, 0]
@@ -2510,7 +2699,7 @@ class et extends W {
2510
2699
  */
2511
2700
  addData(e, t) {
2512
2701
  const n = this.Dxf;
2513
- n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new B(e.clone(), t.clone()));
2702
+ n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new N(e.clone(), t.clone()));
2514
2703
  }
2515
2704
  /** 结果分析创建矩形
2516
2705
  * @param result
@@ -2518,14 +2707,14 @@ class et extends W {
2518
2707
  createRectangle(e) {
2519
2708
  const t = this.Dxf, n = e.project, s = e.project2;
2520
2709
  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]);
2521
- 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]), f = n.points[0].clone(), u = n.points[1].clone(), p = u.direction(f);
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);
2522
2711
  p.multiplyScalar(t.width * 0.5);
2523
- const y = f.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)), S = f.direction(u), b = y.direction(x);
2524
- if (!(S.x > 0 && b.x < 0 || S.x < 0 && b.x > 0 || S.y > 0 && b.y < 0 || S.y < 0 && b.y > 0)) {
2525
- f.set(y.x, y.y), u.set(x.x, x.y);
2526
- for (let C = 1; C < o; C++) {
2527
- const m = c.clone().multiplyScalar(a * C), E = h.clone().multiplyScalar(l * C), L = f.clone().add(m), M = u.clone().add(E);
2528
- this.addData(L, M);
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);
2529
2718
  }
2530
2719
  }
2531
2720
  }
@@ -2535,7 +2724,7 @@ class et extends W {
2535
2724
  */
2536
2725
  buildQuadtree() {
2537
2726
  const e = this.Dxf, t = [];
2538
- this.quadtree = new Y(e.originalBox, 2), e.lineSegments.forEach((n) => {
2727
+ this.quadtree = new Z(e.originalBox, 2), e.lineSegments.forEach((n) => {
2539
2728
  n.userData?.isDoor || (this.quadtree?.insert({
2540
2729
  line: n,
2541
2730
  userData: t.length
@@ -2552,7 +2741,7 @@ class et extends W {
2552
2741
  this.buildQuadtree();
2553
2742
  const e = this.quadtree, t = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
2554
2743
  t.forEach((i, r) => {
2555
- const o = t[r], a = te.fromByLineSegment(o, this.width * 2, !1, -0.01);
2744
+ const o = t[r], a = ue.fromByLineSegment(o, this.width * 2, !1, -0.01);
2556
2745
  e.queryRect(a).map((c) => c.userData).filter((c) => c !== r).forEach((c) => {
2557
2746
  try {
2558
2747
  if (n.has(`${r}-${c}`) || n.has(`${c}-${r}`)) return;
@@ -2596,12 +2785,12 @@ class et extends W {
2596
2785
  doors = [];
2597
2786
  DoorsAnalysis;
2598
2787
  doorsAnalysis() {
2599
- this.DoorsAnalysis = new Qe(this), this.dispatchEvent({
2788
+ this.DoorsAnalysis = new lt(this), this.dispatchEvent({
2600
2789
  type: "analysisCompleted"
2601
2790
  });
2602
2791
  }
2603
2792
  }
2604
- class tt extends W {
2793
+ class ut extends ne {
2605
2794
  static name = "ThreeVJia";
2606
2795
  lineSegments = [];
2607
2796
  onAddFromParent() {
@@ -2613,28 +2802,28 @@ class tt extends W {
2613
2802
  const n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
2614
2803
  let i = [...t.lineSegments], r = [], o = [];
2615
2804
  e.resultList.forEach((c) => {
2616
- const h = s.get(c.target) ?? [], f = s.get(c.source) ?? [], u = c.project.clone(), p = c.project2.clone();
2617
- u.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...u.points), f.push(...p.points), s.set(c.target, h), s.set(c.source, f);
2618
- const y = new B(u.start, p.start), x = new B(u.end, p.end), S = new B(y.center, x.center);
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);
2619
2808
  S.userData.wallWidth = Math.max(y.length(), x.length()), r.push(S);
2620
2809
  });
2621
2810
  const a = [];
2622
2811
  i = i.filter((c) => {
2623
2812
  if (o.indexOf(c) > -1) return !1;
2624
2813
  if (s.has(c)) {
2625
- const h = s.get(c), f = c.clone();
2814
+ const h = s.get(c), d = c.clone();
2626
2815
  if (h) {
2627
2816
  for (let p = 0; p < h.length; p += 2) {
2628
2817
  const y = h[p], x = h[p + 1];
2629
- y.userData.length = y.distance(f.start), x.userData.length = x.distance(f.start), y.userData.type = "start", x.userData.type = "end", f.start.distance(y) > f.start.distance(x) && (h[p] = x, h[p + 1] = y, y.userData.type = "end", x.userData.type = "start");
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");
2630
2819
  }
2631
2820
  h.sort((p, y) => p.userData.length - y.userData.length);
2632
2821
  const u = [];
2633
2822
  for (let p = 0; p < h.length; p++) {
2634
2823
  const y = h[p];
2635
- y.userData.type === "start" ? (u.length === 0 && (a.push(new B(f.start.clone(), y.clone())), f.start.copy(y)), u.push("start")) : (u.pop(), u.length === 0 && f.start.copy(y));
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));
2636
2825
  }
2637
- a.push(f);
2826
+ a.push(d);
2638
2827
  }
2639
2828
  return !1;
2640
2829
  }
@@ -2690,7 +2879,7 @@ class tt extends W {
2690
2879
  };
2691
2880
  if (s.userData.isWindow)
2692
2881
  return s.userData.drawWindow.map((i) => {
2693
- const r = w.from(i.p), o = r.clone().add(
2882
+ const r = g.from(i.p), o = r.clone().add(
2694
2883
  s.direction().multiplyScalar(i.width * 0.5)
2695
2884
  ), a = r.clone().add(
2696
2885
  s.direction().multiplyScalar(-i.width * 0.5)
@@ -2723,10 +2912,10 @@ class tt extends W {
2723
2912
  if (typeof window < "u") {
2724
2913
  const t = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
2725
2914
  n.href = URL.createObjectURL(t), n.download = e, n.click();
2726
- } else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, JSON.stringify(this.toJson()));
2915
+ } else typeof global < "u" && (await se("fs", !1)).writeFileSync(e, JSON.stringify(this.toJson()));
2727
2916
  }
2728
2917
  }
2729
- class nt extends Ke {
2918
+ class dt extends ot {
2730
2919
  Dxf;
2731
2920
  AngleCorrectionDxf;
2732
2921
  Variable;
@@ -2737,7 +2926,7 @@ class nt extends Ke {
2737
2926
  * @param scale 原始数据缩放比例
2738
2927
  */
2739
2928
  constructor(e = 0.1, t = 1) {
2740
- super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = e, this.Dxf = new X(this.wallWidth, t), this.AngleCorrectionDxf = new Ze(), this.Variable = new Ee(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new et()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new tt());
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());
2741
2930
  }
2742
2931
  usePlugin(e) {
2743
2932
  return typeof e == "function" && e.call(this, this), this;
@@ -2750,7 +2939,7 @@ class nt extends Ke {
2750
2939
  });
2751
2940
  }
2752
2941
  }
2753
- const xe = {
2942
+ const Ae = {
2754
2943
  POSITION: [
2755
2944
  "byte",
2756
2945
  "byte normalized",
@@ -2778,36 +2967,36 @@ const xe = {
2778
2967
  "unsigned short"
2779
2968
  ]
2780
2969
  };
2781
- class ee {
2970
+ class he {
2782
2971
  constructor() {
2783
2972
  this.textureUtils = null, this.pluginCallbacks = [], this.register(function(e) {
2784
- return new ft(e);
2973
+ return new Et(e);
2785
2974
  }), this.register(function(e) {
2786
- return new pt(e);
2975
+ return new Dt(e);
2787
2976
  }), this.register(function(e) {
2788
- return new gt(e);
2977
+ return new It(e);
2789
2978
  }), this.register(function(e) {
2790
- return new wt(e);
2979
+ return new Rt(e);
2791
2980
  }), this.register(function(e) {
2792
- return new Mt(e);
2981
+ return new Pt(e);
2793
2982
  }), this.register(function(e) {
2794
- return new St(e);
2983
+ return new vt(e);
2795
2984
  }), this.register(function(e) {
2796
- return new xt(e);
2985
+ return new At(e);
2797
2986
  }), this.register(function(e) {
2798
- return new yt(e);
2987
+ return new Tt(e);
2799
2988
  }), this.register(function(e) {
2800
- return new mt(e);
2989
+ return new bt(e);
2801
2990
  }), this.register(function(e) {
2802
- return new Lt(e);
2991
+ return new Nt(e);
2803
2992
  }), this.register(function(e) {
2804
- return new Et(e);
2993
+ return new Ct(e);
2805
2994
  }), this.register(function(e) {
2806
- return new Tt(e);
2995
+ return new Bt(e);
2807
2996
  }), this.register(function(e) {
2808
- return new At(e);
2997
+ return new Ot(e);
2809
2998
  }), this.register(function(e) {
2810
- return new Dt(e);
2999
+ return new Ft(e);
2811
3000
  });
2812
3001
  }
2813
3002
  register(e) {
@@ -2820,7 +3009,7 @@ class ee {
2820
3009
  return this.textureUtils = e, this;
2821
3010
  }
2822
3011
  parse(e, t, n, s) {
2823
- const i = new dt(), r = [];
3012
+ const i = new Lt(), r = [];
2824
3013
  for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
2825
3014
  r.push(this.pluginCallbacks[o](i));
2826
3015
  i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(e, t, s).catch(n);
@@ -2832,7 +3021,7 @@ class ee {
2832
3021
  });
2833
3022
  }
2834
3023
  }
2835
- const v = {
3024
+ const C = {
2836
3025
  POINTS: 0,
2837
3026
  LINES: 1,
2838
3027
  LINE_LOOP: 2,
@@ -2856,78 +3045,78 @@ const v = {
2856
3045
  CLAMP_TO_EDGE: 33071,
2857
3046
  MIRRORED_REPEAT: 33648,
2858
3047
  REPEAT: 10497
2859
- }, se = "KHR_mesh_quantization", q = {};
2860
- q[_e] = v.NEAREST;
2861
- q[ze] = v.NEAREST_MIPMAP_NEAREST;
2862
- q[qe] = v.NEAREST_MIPMAP_LINEAR;
2863
- q[je] = v.LINEAR;
2864
- q[Ye] = v.LINEAR_MIPMAP_NEAREST;
2865
- q[Ve] = v.LINEAR_MIPMAP_LINEAR;
2866
- q[ke] = v.CLAMP_TO_EDGE;
2867
- q[Xe] = v.REPEAT;
2868
- q[We] = v.MIRRORED_REPEAT;
2869
- const ye = {
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 = {
2870
3059
  scale: "scale",
2871
3060
  position: "translation",
2872
3061
  quaternion: "rotation",
2873
3062
  morphTargetInfluences: "weights"
2874
- }, st = new Re(), me = 12, it = 1179937895, rt = 2, ge = 8, ot = 1313821514, at = 5130562;
2875
- function K(d, e) {
2876
- return d.length === e.length && d.every(function(t, n) {
3063
+ }, ft = new ze(), be = 12, pt = 1179937895, xt = 2, Ie = 8, yt = 1313821514, mt = 5130562;
3064
+ function oe(f, e) {
3065
+ return f.length === e.length && f.every(function(t, n) {
2877
3066
  return t === e[n];
2878
3067
  });
2879
3068
  }
2880
- function ct(d) {
2881
- return new TextEncoder().encode(d).buffer;
3069
+ function gt(f) {
3070
+ return new TextEncoder().encode(f).buffer;
2882
3071
  }
2883
- function lt(d) {
2884
- return K(d.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
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]);
2885
3074
  }
2886
- function ht(d, e, t) {
3075
+ function Mt(f, e, t) {
2887
3076
  const n = {
2888
- min: new Array(d.itemSize).fill(Number.POSITIVE_INFINITY),
2889
- max: new Array(d.itemSize).fill(Number.NEGATIVE_INFINITY)
3077
+ min: new Array(f.itemSize).fill(Number.POSITIVE_INFINITY),
3078
+ max: new Array(f.itemSize).fill(Number.NEGATIVE_INFINITY)
2890
3079
  };
2891
3080
  for (let s = e; s < e + t; s++)
2892
- for (let i = 0; i < d.itemSize; i++) {
3081
+ for (let i = 0; i < f.itemSize; i++) {
2893
3082
  let r;
2894
- d.itemSize > 4 ? r = d.array[s * d.itemSize + i] : (i === 0 ? r = d.getX(s) : i === 1 ? r = d.getY(s) : i === 2 ? r = d.getZ(s) : i === 3 && (r = d.getW(s)), d.normalized === !0 && (r = oe.normalize(r, d.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], 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);
2895
3084
  }
2896
3085
  return n;
2897
3086
  }
2898
- function Te(d) {
2899
- return Math.ceil(d / 4) * 4;
3087
+ function Be(f) {
3088
+ return Math.ceil(f / 4) * 4;
2900
3089
  }
2901
- function ie(d, e = 0) {
2902
- const t = Te(d.byteLength);
2903
- if (t !== d.byteLength) {
3090
+ function pe(f, e = 0) {
3091
+ const t = Be(f.byteLength);
3092
+ if (t !== f.byteLength) {
2904
3093
  const n = new Uint8Array(t);
2905
- if (n.set(new Uint8Array(d)), e !== 0)
2906
- for (let s = d.byteLength; s < t; s++)
3094
+ if (n.set(new Uint8Array(f)), e !== 0)
3095
+ for (let s = f.byteLength; s < t; s++)
2907
3096
  n[s] = e;
2908
3097
  return n.buffer;
2909
3098
  }
2910
- return d;
3099
+ return f;
2911
3100
  }
2912
- function we() {
3101
+ function Re() {
2913
3102
  return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
2914
3103
  }
2915
- function ut(d, e) {
2916
- if (typeof OffscreenCanvas < "u" && d instanceof OffscreenCanvas) {
3104
+ function St(f, e) {
3105
+ if (typeof OffscreenCanvas < "u" && f instanceof OffscreenCanvas) {
2917
3106
  let t;
2918
- return e === "image/jpeg" ? t = 0.92 : e === "image/webp" && (t = 0.8), d.convertToBlob({
3107
+ return e === "image/jpeg" ? t = 0.92 : e === "image/webp" && (t = 0.8), f.convertToBlob({
2919
3108
  type: e,
2920
3109
  quality: t
2921
3110
  });
2922
3111
  } else
2923
- return new Promise((t) => d.toBlob(t, e));
3112
+ return new Promise((t) => f.toBlob(t, e));
2924
3113
  }
2925
- class dt {
3114
+ class Lt {
2926
3115
  constructor() {
2927
3116
  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 = {
2928
3117
  asset: {
2929
3118
  version: "2.0",
2930
- generator: "THREE.GLTFExporter r" + Ne
3119
+ generator: "THREE.GLTFExporter r" + qe
2931
3120
  }
2932
3121
  }, this.cache = {
2933
3122
  meshes: /* @__PURE__ */ new Map(),
@@ -2964,27 +3153,27 @@ class dt {
2964
3153
  const s = this, i = s.buffers, r = s.json;
2965
3154
  n = s.options;
2966
3155
  const o = s.extensionsUsed, a = s.extensionsRequired, l = new Blob(i, { type: "application/octet-stream" }), c = Object.keys(o), h = Object.keys(a);
2967
- 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 ? re(l).then(function(f) {
2968
- const u = ie(f), p = new DataView(new ArrayBuffer(ge));
2969
- p.setUint32(0, u.byteLength, !0), p.setUint32(4, at, !0);
2970
- const y = ie(ct(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(ge));
2971
- x.setUint32(0, y.byteLength, !0), x.setUint32(4, ot, !0);
2972
- const S = new ArrayBuffer(me), b = new DataView(S);
2973
- b.setUint32(0, it, !0), b.setUint32(4, rt, !0);
2974
- const C = me + x.byteLength + y.byteLength + p.byteLength + u.byteLength;
2975
- b.setUint32(8, C, !0);
2976
- const m = new Blob([
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([
2977
3166
  S,
2978
3167
  x,
2979
3168
  y,
2980
3169
  p,
2981
3170
  u
2982
3171
  ], { type: "application/octet-stream" });
2983
- re(m).then((E) => {
2984
- t(E);
3172
+ xe(E).then((R) => {
3173
+ t(R);
2985
3174
  });
2986
- }) : r.buffers && r.buffers.length > 0 ? bt(l).then((f) => {
2987
- r.buffers[0].uri = f, t(r);
3175
+ }) : r.buffers && r.buffers.length > 0 ? Ut(l).then((d) => {
3176
+ r.buffers[0].uri = d, t(r);
2988
3177
  }) : t(r);
2989
3178
  }
2990
3179
  /**
@@ -3031,7 +3220,7 @@ class dt {
3031
3220
  */
3032
3221
  isNormalizedNormalAttribute(e) {
3033
3222
  if (this.cache.attributesNormalized.has(e)) return !1;
3034
- const n = new Z();
3223
+ const n = new ce();
3035
3224
  for (let s = 0, i = e.count; s < i; s++)
3036
3225
  if (Math.abs(n.fromBufferAttribute(e, s).length() - 1) > 5e-4) return !1;
3037
3226
  return !0;
@@ -3046,7 +3235,7 @@ class dt {
3046
3235
  createNormalizedNormalAttribute(e) {
3047
3236
  const t = this.cache;
3048
3237
  if (t.attributesNormalized.has(e)) return t.attributesNormalized.get(e);
3049
- const n = e.clone(), s = new Z();
3238
+ const n = e.clone(), s = new ce();
3050
3239
  for (let i = 0, r = n.count; i < r; i++)
3051
3240
  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);
3052
3241
  return t.attributesNormalized.set(e, n), n;
@@ -3066,14 +3255,14 @@ class dt {
3066
3255
  async buildMetalRoughTextureAsync(e, t) {
3067
3256
  if (e === t) return e;
3068
3257
  function n(u) {
3069
- return u.colorSpace === Ue ? function(y) {
3258
+ return u.colorSpace === He ? function(y) {
3070
3259
  return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
3071
3260
  } : function(y) {
3072
3261
  return y;
3073
3262
  };
3074
3263
  }
3075
- e instanceof ne && (e = await this.decompressTextureAsync(e)), t instanceof ne && (t = await this.decompressTextureAsync(t));
3076
- 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 = we();
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();
3077
3266
  a.width = r, a.height = o;
3078
3267
  const l = a.getContext("2d", {
3079
3268
  willReadFrequently: !0
@@ -3093,8 +3282,8 @@ class dt {
3093
3282
  c.data[y] = u(p[y] / 256) * 256;
3094
3283
  }
3095
3284
  l.putImageData(c, 0, 0);
3096
- const f = (e || t).clone();
3097
- return f.source = new ve(a), f.colorSpace = Ce, f.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."), f;
3285
+ 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;
3098
3287
  }
3099
3288
  async decompressTextureAsync(e, t = 1 / 0) {
3100
3289
  if (this.textureUtils === null)
@@ -3124,34 +3313,34 @@ class dt {
3124
3313
  r.bufferViews || (r.bufferViews = []);
3125
3314
  let o;
3126
3315
  switch (t) {
3127
- case v.BYTE:
3128
- case v.UNSIGNED_BYTE:
3316
+ case C.BYTE:
3317
+ case C.UNSIGNED_BYTE:
3129
3318
  o = 1;
3130
3319
  break;
3131
- case v.SHORT:
3132
- case v.UNSIGNED_SHORT:
3320
+ case C.SHORT:
3321
+ case C.UNSIGNED_SHORT:
3133
3322
  o = 2;
3134
3323
  break;
3135
3324
  default:
3136
3325
  o = 4;
3137
3326
  }
3138
3327
  let a = e.itemSize * o;
3139
- i === v.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
3140
- const l = Te(s * a), c = new DataView(new ArrayBuffer(l));
3328
+ i === C.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
3329
+ const l = Be(s * a), c = new DataView(new ArrayBuffer(l));
3141
3330
  let h = 0;
3142
3331
  for (let p = n; p < n + s; p++) {
3143
3332
  for (let y = 0; y < e.itemSize; y++) {
3144
3333
  let x;
3145
- 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 = oe.normalize(x, e.array))), t === v.FLOAT ? c.setFloat32(h, x, !0) : t === v.INT ? c.setInt32(h, x, !0) : t === v.UNSIGNED_INT ? c.setUint32(h, x, !0) : t === v.SHORT ? c.setInt16(h, x, !0) : t === v.UNSIGNED_SHORT ? c.setUint16(h, x, !0) : t === v.BYTE ? c.setInt8(h, x) : t === v.UNSIGNED_BYTE && c.setUint8(h, x), h += o;
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;
3146
3335
  }
3147
3336
  h % a !== 0 && (h += a - h % a);
3148
3337
  }
3149
- const f = {
3338
+ const d = {
3150
3339
  buffer: this.processBuffer(c.buffer),
3151
3340
  byteOffset: this.byteOffset,
3152
3341
  byteLength: l
3153
3342
  };
3154
- return i !== void 0 && (f.target = i), i === v.ARRAY_BUFFER && (f.byteStride = a), this.byteOffset += l, r.bufferViews.push(f), {
3343
+ return i !== void 0 && (d.target = i), i === C.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += l, r.bufferViews.push(d), {
3155
3344
  id: r.bufferViews.length - 1,
3156
3345
  byteLength: 0
3157
3346
  };
@@ -3164,8 +3353,8 @@ class dt {
3164
3353
  processBufferViewImage(e) {
3165
3354
  const t = this, n = t.json;
3166
3355
  return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
3167
- re(e).then((i) => {
3168
- const r = ie(i), o = {
3356
+ xe(e).then((i) => {
3357
+ const r = pe(i), o = {
3169
3358
  buffer: t.processBuffer(r),
3170
3359
  byteOffset: t.byteOffset,
3171
3360
  byteLength: r.byteLength
@@ -3193,25 +3382,25 @@ class dt {
3193
3382
  };
3194
3383
  let o;
3195
3384
  if (e.array.constructor === Float32Array)
3196
- o = v.FLOAT;
3385
+ o = C.FLOAT;
3197
3386
  else if (e.array.constructor === Int32Array)
3198
- o = v.INT;
3387
+ o = C.INT;
3199
3388
  else if (e.array.constructor === Uint32Array)
3200
- o = v.UNSIGNED_INT;
3389
+ o = C.UNSIGNED_INT;
3201
3390
  else if (e.array.constructor === Int16Array)
3202
- o = v.SHORT;
3391
+ o = C.SHORT;
3203
3392
  else if (e.array.constructor === Uint16Array)
3204
- o = v.UNSIGNED_SHORT;
3393
+ o = C.UNSIGNED_SHORT;
3205
3394
  else if (e.array.constructor === Int8Array)
3206
- o = v.BYTE;
3395
+ o = C.BYTE;
3207
3396
  else if (e.array.constructor === Uint8Array)
3208
- o = v.UNSIGNED_BYTE;
3397
+ o = C.UNSIGNED_BYTE;
3209
3398
  else
3210
3399
  throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + e.array.constructor.name);
3211
3400
  if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = e.count), s === 0) return null;
3212
- const a = ht(e, n, s);
3401
+ const a = Mt(e, n, s);
3213
3402
  let l;
3214
- t !== void 0 && (l = e === t.index ? v.ELEMENT_ARRAY_BUFFER : v.ARRAY_BUFFER);
3403
+ t !== void 0 && (l = e === t.index ? C.ELEMENT_ARRAY_BUFFER : C.ARRAY_BUFFER);
3215
3404
  const c = this.processBufferView(e, o, n, s, l), h = {
3216
3405
  bufferView: c.id,
3217
3406
  byteOffset: c.byteOffset,
@@ -3238,13 +3427,13 @@ class dt {
3238
3427
  const c = r.images.get(e), h = s + ":flipY/" + n.toString();
3239
3428
  if (c[h] !== void 0) return c[h];
3240
3429
  o.images || (o.images = []);
3241
- const f = { mimeType: s }, u = we();
3430
+ const d = { mimeType: s }, u = Re();
3242
3431
  u.width = Math.min(e.width, a.maxTextureSize), u.height = Math.min(e.height, a.maxTextureSize);
3243
3432
  const p = u.getContext("2d", {
3244
3433
  willReadFrequently: !0
3245
3434
  });
3246
3435
  if (n === !0 && (p.translate(0, u.height), p.scale(1, -1)), e.data !== void 0) {
3247
- t !== Be && 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);
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);
3248
3437
  const x = new Uint8ClampedArray(e.height * e.width * 4);
3249
3438
  for (let S = 0; S < x.length; S += 4)
3250
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];
@@ -3254,11 +3443,11 @@ class dt {
3254
3443
  else
3255
3444
  throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
3256
3445
  a.binary === !0 ? l.push(
3257
- ut(u, s).then((x) => i.processBufferViewImage(x)).then((x) => {
3258
- f.bufferView = x;
3446
+ St(u, s).then((x) => i.processBufferViewImage(x)).then((x) => {
3447
+ d.bufferView = x;
3259
3448
  })
3260
- ) : f.uri = Oe.getDataURL(u, s);
3261
- const y = o.images.push(f) - 1;
3449
+ ) : d.uri = Xe.getDataURL(u, s);
3450
+ const y = o.images.push(d) - 1;
3262
3451
  return c[h] = y, y;
3263
3452
  } else
3264
3453
  throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
@@ -3272,10 +3461,10 @@ class dt {
3272
3461
  const t = this.json;
3273
3462
  t.samplers || (t.samplers = []);
3274
3463
  const n = {
3275
- magFilter: q[e.magFilter],
3276
- minFilter: q[e.minFilter],
3277
- wrapS: q[e.wrapS],
3278
- wrapT: q[e.wrapT]
3464
+ magFilter: H[e.magFilter],
3465
+ minFilter: H[e.minFilter],
3466
+ wrapS: H[e.wrapS],
3467
+ wrapT: H[e.wrapT]
3279
3468
  };
3280
3469
  return t.samplers.push(n) - 1;
3281
3470
  }
@@ -3287,7 +3476,7 @@ class dt {
3287
3476
  async processTextureAsync(e) {
3288
3477
  const n = this.options, s = this.cache, i = this.json;
3289
3478
  if (s.textures.has(e)) return s.textures.get(e);
3290
- i.textures || (i.textures = []), e instanceof ne && (e = await this.decompressTextureAsync(e, n.maxTextureSize));
3479
+ i.textures || (i.textures = []), e instanceof de && (e = await this.decompressTextureAsync(e, n.maxTextureSize));
3291
3480
  let r = e.userData.mimeType;
3292
3481
  r === "image/webp" && (r = "image/png");
3293
3482
  const o = {
@@ -3314,7 +3503,7 @@ class dt {
3314
3503
  const s = { pbrMetallicRoughness: {} };
3315
3504
  e.isMeshStandardMaterial !== !0 && e.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
3316
3505
  const i = e.color.toArray().concat([e.opacity]);
3317
- if (K(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) {
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) {
3318
3507
  const o = await this.buildMetalRoughTextureAsync(e.metalnessMap, e.roughnessMap), a = {
3319
3508
  index: await this.processTextureAsync(o),
3320
3509
  texCoord: o.channel
@@ -3352,7 +3541,7 @@ class dt {
3352
3541
  };
3353
3542
  e.aoMapIntensity !== 1 && (o.strength = e.aoMapIntensity), this.applyTextureTransform(o, e.aoMap), s.occlusionTexture = o;
3354
3543
  }
3355
- e.transparent ? s.alphaMode = "BLEND" : e.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = e.alphaTest), e.side === Ge && (s.doubleSided = !0), e.name !== "" && (s.name = e.name), this.serializeUserData(e, s), await this._invokeAllAsync(async function(o) {
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) {
3356
3545
  o.writeMaterialAsync && await o.writeMaterialAsync(e, s);
3357
3546
  });
3358
3547
  const r = n.materials.push(s) - 1;
@@ -3366,16 +3555,16 @@ class dt {
3366
3555
  async processMeshAsync(e) {
3367
3556
  const t = this.cache, n = this.json, s = [e.geometry.uuid];
3368
3557
  if (Array.isArray(e.material))
3369
- for (let m = 0, E = e.material.length; m < E; m++)
3370
- s.push(e.material[m].uuid);
3558
+ for (let E = 0, R = e.material.length; E < R; E++)
3559
+ s.push(e.material[E].uuid);
3371
3560
  else
3372
3561
  s.push(e.material.uuid);
3373
3562
  const i = s.join(":");
3374
3563
  if (t.meshes.has(i)) return t.meshes.get(i);
3375
3564
  const r = e.geometry;
3376
3565
  let o;
3377
- e.isLineSegments ? o = v.LINES : e.isLineLoop ? o = v.LINE_LOOP : e.isLine ? o = v.LINE_STRIP : e.isPoints ? o = v.POINTS : o = e.material.wireframe ? v.LINES : v.TRIANGLES;
3378
- const a = {}, l = {}, c = [], h = [], f = {
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 = {
3379
3568
  uv: "TEXCOORD_0",
3380
3569
  uv1: "TEXCOORD_1",
3381
3570
  uv2: "TEXCOORD_2",
@@ -3386,76 +3575,76 @@ class dt {
3386
3575
  }, u = r.getAttribute("normal");
3387
3576
  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)));
3388
3577
  let p = null;
3389
- for (let m in r.attributes) {
3390
- if (m.slice(0, 5) === "morph") continue;
3391
- const E = r.attributes[m];
3392
- if (m = f[m] || m.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(m) || (m = "_" + m), t.attributes.has(this.getUID(E))) {
3393
- l[m] = t.attributes.get(this.getUID(E));
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));
3394
3583
  continue;
3395
3584
  }
3396
3585
  p = null;
3397
- const M = E.array;
3398
- m === "JOINTS_0" && !(M instanceof Uint16Array) && !(M instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new k(new Uint16Array(M), E.itemSize, E.normalized)) : (M instanceof Uint32Array || M instanceof Int32Array) && !m.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${m}" converted to type FLOAT.`), p = ee.Utils.toFloat32BufferAttribute(E));
3399
- const g = this.processAccessor(p || E, r);
3400
- g !== null && (m.startsWith("_") || this.detectMeshQuantization(m, E), l[m] = g, t.attributes.set(this.getUID(E), g));
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));
3401
3590
  }
3402
3591
  if (u !== void 0 && r.setAttribute("normal", u), Object.keys(l).length === 0) return null;
3403
3592
  if (e.morphTargetInfluences !== void 0 && e.morphTargetInfluences.length > 0) {
3404
- const m = [], E = [], L = {};
3593
+ const E = [], R = [], U = {};
3405
3594
  if (e.morphTargetDictionary !== void 0)
3406
- for (const M in e.morphTargetDictionary)
3407
- L[e.morphTargetDictionary[M]] = M;
3408
- for (let M = 0; M < e.morphTargetInfluences.length; ++M) {
3409
- const g = {};
3410
- let D = !1;
3411
- for (const T in r.morphAttributes) {
3412
- if (T !== "position" && T !== "normal") {
3413
- D || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), D = !0);
3595
+ for (const P in e.morphTargetDictionary)
3596
+ U[e.morphTargetDictionary[P]] = P;
3597
+ for (let P = 0; P < e.morphTargetInfluences.length; ++P) {
3598
+ const O = {};
3599
+ let X = !1;
3600
+ for (const k in r.morphAttributes) {
3601
+ if (k !== "position" && k !== "normal") {
3602
+ X || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), X = !0);
3414
3603
  continue;
3415
3604
  }
3416
- const A = r.morphAttributes[T][M], P = T.toUpperCase(), R = r.attributes[T];
3417
- if (t.attributes.has(this.getUID(A, !0))) {
3418
- g[P] = t.attributes.get(this.getUID(A, !0));
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));
3419
3608
  continue;
3420
3609
  }
3421
- const I = A.clone();
3610
+ const D = W.clone();
3422
3611
  if (!r.morphTargetsRelative)
3423
- for (let N = 0, F = A.count; N < F; N++)
3424
- for (let O = 0; O < A.itemSize; O++)
3425
- O === 0 && I.setX(N, A.getX(N) - R.getX(N)), O === 1 && I.setY(N, A.getY(N) - R.getY(N)), O === 2 && I.setZ(N, A.getZ(N) - R.getZ(N)), O === 3 && I.setW(N, A.getW(N) - R.getW(N));
3426
- g[P] = this.processAccessor(I, r), t.attributes.set(this.getUID(R, !0), g[P]);
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]);
3427
3616
  }
3428
- h.push(g), m.push(e.morphTargetInfluences[M]), e.morphTargetDictionary !== void 0 && E.push(L[M]);
3617
+ h.push(O), E.push(e.morphTargetInfluences[P]), e.morphTargetDictionary !== void 0 && R.push(U[P]);
3429
3618
  }
3430
- a.weights = m, E.length > 0 && (a.extras = {}, a.extras.targetNames = E);
3619
+ a.weights = E, R.length > 0 && (a.extras = {}, a.extras.targetNames = R);
3431
3620
  }
3432
3621
  const y = Array.isArray(e.material);
3433
3622
  if (y && r.groups.length === 0) return null;
3434
3623
  let x = !1;
3435
3624
  if (y && r.index === null) {
3436
- const m = [];
3437
- for (let E = 0, L = r.attributes.position.count; E < L; E++)
3438
- m[E] = E;
3439
- r.setIndex(m), x = !0;
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;
3440
3629
  }
3441
- const S = y ? e.material : [e.material], b = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
3442
- for (let m = 0, E = b.length; m < E; m++) {
3443
- const L = {
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 = {
3444
3633
  mode: o,
3445
3634
  attributes: l
3446
3635
  };
3447
- if (this.serializeUserData(r, L), h.length > 0 && (L.targets = h), r.index !== null) {
3448
- let g = this.getUID(r.index);
3449
- (b[m].start !== void 0 || b[m].count !== void 0) && (g += ":" + b[m].start + ":" + b[m].count), t.attributes.has(g) ? L.indices = t.attributes.get(g) : (L.indices = this.processAccessor(r.index, r, b[m].start, b[m].count), t.attributes.set(g, L.indices)), L.indices === null && delete L.indices;
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;
3450
3639
  }
3451
- const M = await this.processMaterialAsync(S[b[m].materialIndex]);
3452
- M !== null && (L.material = M), c.push(L);
3640
+ const P = await this.processMaterialAsync(S[T[E].materialIndex]);
3641
+ P !== null && (U.material = P), c.push(U);
3453
3642
  }
3454
- x === !0 && r.setIndex(null), a.primitives = c, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(m) {
3455
- m.writeMesh && m.writeMesh(e, a);
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);
3456
3645
  });
3457
- const C = n.meshes.push(a) - 1;
3458
- return t.meshes.set(i, C), C;
3646
+ const G = n.meshes.push(a) - 1;
3647
+ return t.meshes.set(i, G), G;
3459
3648
  }
3460
3649
  /**
3461
3650
  * If a vertex attribute with a
@@ -3469,7 +3658,7 @@ class dt {
3469
3658
  * @param {THREE.BufferAttribute} attribute
3470
3659
  */
3471
3660
  detectMeshQuantization(e, t) {
3472
- if (this.extensionsUsed[se]) return;
3661
+ if (this.extensionsUsed[fe]) return;
3473
3662
  let n;
3474
3663
  switch (t.array.constructor) {
3475
3664
  case Int8Array:
@@ -3489,7 +3678,7 @@ class dt {
3489
3678
  }
3490
3679
  t.normalized && (n += " normalized");
3491
3680
  const s = e.split("_", 1)[0];
3492
- xe[s] && xe[s].includes(n) && (this.extensionsUsed[se] = !0, this.extensionsRequired[se] = !0);
3681
+ Ae[s] && Ae[s].includes(n) && (this.extensionsUsed[fe] = !0, this.extensionsRequired[fe] = !0);
3493
3682
  }
3494
3683
  /**
3495
3684
  * Process camera
@@ -3509,7 +3698,7 @@ class dt {
3509
3698
  znear: e.near < 0 ? 0 : e.near
3510
3699
  } : s.perspective = {
3511
3700
  aspectRatio: e.aspect,
3512
- yfov: oe.degToRad(e.fov),
3701
+ yfov: ye.degToRad(e.fov),
3513
3702
  zfar: e.far <= 0 ? 1e-3 : e.far,
3514
3703
  znear: e.near < 0 ? 0 : e.near
3515
3704
  }, e.name !== "" && (s.name = e.type), t.cameras.push(s) - 1;
@@ -3526,28 +3715,28 @@ class dt {
3526
3715
  */
3527
3716
  processAnimation(e, t) {
3528
3717
  const n = this.json, s = this.nodeMap;
3529
- n.animations || (n.animations = []), e = ee.Utils.mergeMorphTargetTracks(e.clone(), t);
3718
+ n.animations || (n.animations = []), e = he.Utils.mergeMorphTargetTracks(e.clone(), t);
3530
3719
  const i = e.tracks, r = [], o = [];
3531
3720
  for (let l = 0; l < i.length; ++l) {
3532
- const c = i[l], h = Q.parseTrackName(c.name);
3533
- let f = Q.findNode(t, h.nodeName);
3534
- const u = ye[h.propertyName];
3535
- if (h.objectName === "bones" && (f.isSkinnedMesh === !0 ? f = f.skeleton.getBoneByName(h.objectIndex) : f = void 0), !f || !u) {
3721
+ const c = i[l], h = le.parseTrackName(c.name);
3722
+ let d = le.findNode(t, h.nodeName);
3723
+ const u = Te[h.propertyName];
3724
+ if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !u) {
3536
3725
  console.warn('THREE.GLTFExporter: Could not export animation track "%s".', c.name);
3537
3726
  continue;
3538
3727
  }
3539
3728
  const p = 1;
3540
3729
  let y = c.values.length / c.times.length;
3541
- u === ye.morphTargetInfluences && (y /= f.morphTargetInfluences.length);
3730
+ u === Te.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
3542
3731
  let x;
3543
- c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() === Fe ? x = "STEP" : x = "LINEAR", o.push({
3544
- input: this.processAccessor(new k(c.times, p)),
3545
- output: this.processAccessor(new k(c.values, y)),
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)),
3546
3735
  interpolation: x
3547
3736
  }), r.push({
3548
3737
  sampler: o.length - 1,
3549
3738
  target: {
3550
- node: s.get(f),
3739
+ node: s.get(d),
3551
3740
  path: u
3552
3741
  }
3553
3742
  });
@@ -3568,11 +3757,11 @@ class dt {
3568
3757
  if (i === void 0) return null;
3569
3758
  const r = e.skeleton.bones[0];
3570
3759
  if (r === void 0) return null;
3571
- const o = [], a = new Float32Array(i.bones.length * 16), l = new Se();
3760
+ const o = [], a = new Float32Array(i.bones.length * 16), l = new ve();
3572
3761
  for (let h = 0; h < i.bones.length; ++h)
3573
3762
  o.push(n.get(i.bones[h])), l.copy(i.boneInverses[h]), l.multiply(e.bindMatrix).toArray(a, h * 16);
3574
3763
  return t.skins === void 0 && (t.skins = []), t.skins.push({
3575
- inverseBindMatrices: this.processAccessor(new k(a, 16)),
3764
+ inverseBindMatrices: this.processAccessor(new te(a, 16)),
3576
3765
  joints: o,
3577
3766
  skeleton: n.get(r)
3578
3767
  }), s.skin = t.skins.length - 1;
@@ -3588,9 +3777,9 @@ class dt {
3588
3777
  const i = {};
3589
3778
  if (n.trs) {
3590
3779
  const o = e.quaternion.toArray(), a = e.position.toArray(), l = e.scale.toArray();
3591
- K(o, [0, 0, 0, 1]) || (i.rotation = o), K(a, [0, 0, 0]) || (i.translation = a), K(l, [1, 1, 1]) || (i.scale = l);
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);
3592
3781
  } else
3593
- e.matrixAutoUpdate && e.updateMatrix(), lt(e.matrix) === !1 && (i.matrix = e.matrix.elements);
3782
+ e.matrixAutoUpdate && e.updateMatrix(), wt(e.matrix) === !1 && (i.matrix = e.matrix.elements);
3594
3783
  if (e.name !== "" && (i.name = String(e.name)), this.serializeUserData(e, i), e.isMesh || e.isLine || e.isPoints) {
3595
3784
  const o = await this.processMeshAsync(e);
3596
3785
  o !== null && (i.mesh = o);
@@ -3636,7 +3825,7 @@ class dt {
3636
3825
  * @param {Array<THREE.Object3D>} objects List of objects to process
3637
3826
  */
3638
3827
  async processObjectsAsync(e) {
3639
- const t = new ue();
3828
+ const t = new Se();
3640
3829
  t.name = "AuxScene";
3641
3830
  for (let n = 0; n < e.length; n++)
3642
3831
  t.children.push(e[n]);
@@ -3652,7 +3841,7 @@ class dt {
3652
3841
  });
3653
3842
  const n = [];
3654
3843
  for (let s = 0; s < e.length; s++)
3655
- e[s] instanceof ue ? await this.processSceneAsync(e[s]) : n.push(e[s]);
3844
+ e[s] instanceof Se ? await this.processSceneAsync(e[s]) : n.push(e[s]);
3656
3845
  n.length > 0 && await this.processObjectsAsync(n);
3657
3846
  for (let s = 0; s < this.skins.length; ++s)
3658
3847
  this.processSkin(this.skins[s]);
@@ -3667,7 +3856,7 @@ class dt {
3667
3856
  await e(this.plugins[t]);
3668
3857
  }
3669
3858
  }
3670
- class ft {
3859
+ class Et {
3671
3860
  constructor(e) {
3672
3861
  this.writer = e, this.name = "KHR_lights_punctual";
3673
3862
  }
@@ -3683,7 +3872,7 @@ class ft {
3683
3872
  o.push(r), t.extensions = t.extensions || {}, t.extensions[this.name] = { light: o.length - 1 };
3684
3873
  }
3685
3874
  }
3686
- class pt {
3875
+ class Dt {
3687
3876
  constructor(e) {
3688
3877
  this.writer = e, this.name = "KHR_materials_unlit";
3689
3878
  }
@@ -3693,7 +3882,7 @@ class pt {
3693
3882
  t.extensions = t.extensions || {}, t.extensions[this.name] = {}, s[this.name] = !0, t.pbrMetallicRoughness.metallicFactor = 0, t.pbrMetallicRoughness.roughnessFactor = 0.9;
3694
3883
  }
3695
3884
  }
3696
- class xt {
3885
+ class At {
3697
3886
  constructor(e) {
3698
3887
  this.writer = e, this.name = "KHR_materials_clearcoat";
3699
3888
  }
@@ -3724,7 +3913,7 @@ class xt {
3724
3913
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3725
3914
  }
3726
3915
  }
3727
- class yt {
3916
+ class Tt {
3728
3917
  constructor(e) {
3729
3918
  this.writer = e, this.name = "KHR_materials_dispersion";
3730
3919
  }
@@ -3734,7 +3923,7 @@ class yt {
3734
3923
  i.dispersion = e.dispersion, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3735
3924
  }
3736
3925
  }
3737
- class mt {
3926
+ class bt {
3738
3927
  constructor(e) {
3739
3928
  this.writer = e, this.name = "KHR_materials_iridescence";
3740
3929
  }
@@ -3758,7 +3947,7 @@ class mt {
3758
3947
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3759
3948
  }
3760
3949
  }
3761
- class gt {
3950
+ class It {
3762
3951
  constructor(e) {
3763
3952
  this.writer = e, this.name = "KHR_materials_transmission";
3764
3953
  }
@@ -3775,7 +3964,7 @@ class gt {
3775
3964
  t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3776
3965
  }
3777
3966
  }
3778
- class wt {
3967
+ class Rt {
3779
3968
  constructor(e) {
3780
3969
  this.writer = e, this.name = "KHR_materials_volume";
3781
3970
  }
@@ -3792,7 +3981,7 @@ class wt {
3792
3981
  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;
3793
3982
  }
3794
3983
  }
3795
- class Mt {
3984
+ class Pt {
3796
3985
  constructor(e) {
3797
3986
  this.writer = e, this.name = "KHR_materials_ior";
3798
3987
  }
@@ -3802,12 +3991,12 @@ class Mt {
3802
3991
  i.ior = e.ior, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3803
3992
  }
3804
3993
  }
3805
- class St {
3994
+ class vt {
3806
3995
  constructor(e) {
3807
3996
  this.writer = e, this.name = "KHR_materials_specular";
3808
3997
  }
3809
3998
  async writeMaterialAsync(e, t) {
3810
- if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(st) && !e.specularIntensityMap && !e.specularColorMap) return;
3999
+ if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(ft) && !e.specularIntensityMap && !e.specularColorMap) return;
3811
4000
  const n = this.writer, s = n.extensionsUsed, i = {};
3812
4001
  if (e.specularIntensityMap) {
3813
4002
  const r = {
@@ -3826,7 +4015,7 @@ class St {
3826
4015
  i.specularFactor = e.specularIntensity, i.specularColorFactor = e.specularColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3827
4016
  }
3828
4017
  }
3829
- class Lt {
4018
+ class Nt {
3830
4019
  constructor(e) {
3831
4020
  this.writer = e, this.name = "KHR_materials_sheen";
3832
4021
  }
@@ -3850,7 +4039,7 @@ class Lt {
3850
4039
  i.sheenRoughnessFactor = e.sheenRoughness, i.sheenColorFactor = e.sheenColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3851
4040
  }
3852
4041
  }
3853
- class Et {
4042
+ class Ct {
3854
4043
  constructor(e) {
3855
4044
  this.writer = e, this.name = "KHR_materials_anisotropy";
3856
4045
  }
@@ -3864,7 +4053,7 @@ class Et {
3864
4053
  i.anisotropyStrength = e.anisotropy, i.anisotropyRotation = e.anisotropyRotation, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3865
4054
  }
3866
4055
  }
3867
- class Tt {
4056
+ class Bt {
3868
4057
  constructor(e) {
3869
4058
  this.writer = e, this.name = "KHR_materials_emissive_strength";
3870
4059
  }
@@ -3874,7 +4063,7 @@ class Tt {
3874
4063
  i.emissiveStrength = e.emissiveIntensity, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3875
4064
  }
3876
4065
  }
3877
- class At {
4066
+ class Ot {
3878
4067
  constructor(e) {
3879
4068
  this.writer = e, this.name = "EXT_materials_bump";
3880
4069
  }
@@ -3891,54 +4080,54 @@ class At {
3891
4080
  i.bumpFactor = e.bumpScale, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
3892
4081
  }
3893
4082
  }
3894
- class Dt {
4083
+ class Ft {
3895
4084
  constructor(e) {
3896
4085
  this.writer = e, this.name = "EXT_mesh_gpu_instancing";
3897
4086
  }
3898
4087
  writeNode(e, t) {
3899
4088
  if (!e.isInstancedMesh) return;
3900
- 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 Se(), l = new Z(), c = new Pe(), h = new Z();
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();
3901
4090
  for (let u = 0; u < s.count; u++)
3902
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);
3903
- const f = {
3904
- TRANSLATION: n.processAccessor(new k(i, 3)),
3905
- ROTATION: n.processAccessor(new k(r, 4)),
3906
- SCALE: n.processAccessor(new k(o, 3))
4092
+ 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))
3907
4096
  };
3908
- s.instanceColor && (f._COLOR_0 = n.processAccessor(s.instanceColor)), t.extensions = t.extensions || {}, t.extensions[this.name] = { attributes: f }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
4097
+ 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;
3909
4098
  }
3910
4099
  }
3911
- ee.Utils = {
3912
- insertKeyframe: function(d, e) {
3913
- const n = d.getValueSize(), s = new d.TimeBufferType(d.times.length + 1), i = new d.ValueBufferType(d.values.length + n), r = d.createInterpolant(new d.ValueBufferType(n));
4100
+ he.Utils = {
4101
+ insertKeyframe: function(f, e) {
4102
+ 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));
3914
4103
  let o;
3915
- if (d.times.length === 0) {
4104
+ if (f.times.length === 0) {
3916
4105
  s[0] = e;
3917
4106
  for (let a = 0; a < n; a++)
3918
4107
  i[a] = 0;
3919
4108
  o = 0;
3920
- } else if (e < d.times[0]) {
3921
- if (Math.abs(d.times[0] - e) < 1e-3) return 0;
3922
- s[0] = e, s.set(d.times, 1), i.set(r.evaluate(e), 0), i.set(d.values, n), o = 0;
3923
- } else if (e > d.times[d.times.length - 1]) {
3924
- if (Math.abs(d.times[d.times.length - 1] - e) < 1e-3)
3925
- return d.times.length - 1;
3926
- s[s.length - 1] = e, s.set(d.times, 0), i.set(d.values, 0), i.set(r.evaluate(e), d.values.length), o = s.length - 1;
4109
+ } else if (e < f.times[0]) {
4110
+ if (Math.abs(f.times[0] - e) < 1e-3) return 0;
4111
+ s[0] = e, s.set(f.times, 1), i.set(r.evaluate(e), 0), i.set(f.values, n), o = 0;
4112
+ } else if (e > f.times[f.times.length - 1]) {
4113
+ if (Math.abs(f.times[f.times.length - 1] - e) < 1e-3)
4114
+ return f.times.length - 1;
4115
+ s[s.length - 1] = e, s.set(f.times, 0), i.set(f.values, 0), i.set(r.evaluate(e), f.values.length), o = s.length - 1;
3927
4116
  } else
3928
- for (let a = 0; a < d.times.length; a++) {
3929
- if (Math.abs(d.times[a] - e) < 1e-3) return a;
3930
- if (d.times[a] < e && d.times[a + 1] > e) {
3931
- s.set(d.times.slice(0, a + 1), 0), s[a + 1] = e, s.set(d.times.slice(a + 1), a + 2), i.set(d.values.slice(0, (a + 1) * n), 0), i.set(r.evaluate(e), (a + 1) * n), i.set(d.values.slice((a + 1) * n), (a + 2) * n), o = a + 1;
4117
+ for (let a = 0; a < f.times.length; a++) {
4118
+ if (Math.abs(f.times[a] - e) < 1e-3) return a;
4119
+ if (f.times[a] < e && f.times[a + 1] > e) {
4120
+ s.set(f.times.slice(0, a + 1), 0), s[a + 1] = e, s.set(f.times.slice(a + 1), a + 2), i.set(f.values.slice(0, (a + 1) * n), 0), i.set(r.evaluate(e), (a + 1) * n), i.set(f.values.slice((a + 1) * n), (a + 2) * n), o = a + 1;
3932
4121
  break;
3933
4122
  }
3934
4123
  }
3935
- return d.times = s, d.values = i, o;
4124
+ return f.times = s, f.values = i, o;
3936
4125
  },
3937
- mergeMorphTargetTracks: function(d, e) {
3938
- const t = [], n = {}, s = d.tracks;
4126
+ mergeMorphTargetTracks: function(f, e) {
4127
+ const t = [], n = {}, s = f.tracks;
3939
4128
  for (let i = 0; i < s.length; ++i) {
3940
4129
  let r = s[i];
3941
- const o = Q.parseTrackName(r.name), a = Q.findNode(e, o.nodeName);
4130
+ const o = le.parseTrackName(r.name), a = le.findNode(e, o.nodeName);
3942
4131
  if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
3943
4132
  t.push(r);
3944
4133
  continue;
@@ -3946,7 +4135,7 @@ ee.Utils = {
3946
4135
  if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
3947
4136
  if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
3948
4137
  throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
3949
- console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(He);
4138
+ console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(it);
3950
4139
  }
3951
4140
  const l = a.morphTargetInfluences.length, c = a.morphTargetDictionary[o.propertyIndex];
3952
4141
  if (c === void 0)
@@ -3960,77 +4149,77 @@ ee.Utils = {
3960
4149
  h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = u, n[a.uuid] = h, t.push(h);
3961
4150
  continue;
3962
4151
  }
3963
- const f = r.createInterpolant(new r.ValueBufferType(1));
4152
+ const d = r.createInterpolant(new r.ValueBufferType(1));
3964
4153
  h = n[a.uuid];
3965
4154
  for (let u = 0; u < h.times.length; u++)
3966
- h.values[u * l + c] = f.evaluate(h.times[u]);
4155
+ h.values[u * l + c] = d.evaluate(h.times[u]);
3967
4156
  for (let u = 0; u < r.times.length; u++) {
3968
4157
  const p = this.insertKeyframe(h, r.times[u]);
3969
4158
  h.values[p * l + c] = r.values[u];
3970
4159
  }
3971
4160
  }
3972
- return d.tracks = t, d;
4161
+ return f.tracks = t, f;
3973
4162
  },
3974
- toFloat32BufferAttribute: function(d) {
3975
- const e = new k(new Float32Array(d.count * d.itemSize), d.itemSize, !1);
3976
- if (!d.normalized && !d.isInterleavedBufferAttribute)
3977
- return e.array.set(d.array), e;
3978
- for (let t = 0, n = d.count; t < n; t++)
3979
- for (let s = 0; s < d.itemSize; s++)
3980
- e.setComponent(t, s, d.getComponent(t, s));
4163
+ toFloat32BufferAttribute: function(f) {
4164
+ const e = new te(new Float32Array(f.count * f.itemSize), f.itemSize, !1);
4165
+ if (!f.normalized && !f.isInterleavedBufferAttribute)
4166
+ return e.array.set(f.array), e;
4167
+ for (let t = 0, n = f.count; t < n; t++)
4168
+ for (let s = 0; s < f.itemSize; s++)
4169
+ e.setComponent(t, s, f.getComponent(t, s));
3981
4170
  return e;
3982
4171
  }
3983
4172
  };
3984
- async function bt(d) {
4173
+ async function Ut(f) {
3985
4174
  if (typeof FileReader > "u") {
3986
- const e = await d.arrayBuffer(), n = Buffer.from(e).toString("base64");
3987
- return `data:${d.type};base64,${n}`;
4175
+ const e = await f.arrayBuffer(), n = Buffer.from(e).toString("base64");
4176
+ return `data:${f.type};base64,${n}`;
3988
4177
  } else
3989
4178
  return new Promise((e, t) => {
3990
4179
  const n = new FileReader();
3991
- n.onload = () => e(n.result), n.onerror = () => t(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(d);
4180
+ n.onload = () => e(n.result), n.onerror = () => t(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(f);
3992
4181
  });
3993
4182
  }
3994
- async function re(d) {
3995
- if (typeof d.arrayBuffer == "function")
3996
- return await d.arrayBuffer();
4183
+ async function xe(f) {
4184
+ if (typeof f.arrayBuffer == "function")
4185
+ return await f.arrayBuffer();
3997
4186
  if (typeof FileReader < "u")
3998
4187
  return new Promise((e, t) => {
3999
4188
  const n = new FileReader();
4000
- n.onload = () => e(n.result), n.onerror = () => t(n.error), n.readAsArrayBuffer(d);
4189
+ n.onload = () => e(n.result), n.onerror = () => t(n.error), n.readAsArrayBuffer(f);
4001
4190
  });
4002
4191
  {
4003
- const e = Buffer.from(await d.text());
4192
+ const e = Buffer.from(await f.text());
4004
4193
  return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
4005
4194
  }
4006
4195
  }
4007
- const It = new Je(), Rt = new ee();
4008
- function Pt(d, e, t = 0.1) {
4009
- const n = e.normal(d), s = e.direction(d).mutiplyScalar(t * 0.5), i = d.direction(e).mutiplyScalar(t * 0.5), r = n.x * t * 0.5, o = n.y * t * 0.5;
4196
+ const Gt = new rt(), zt = new he();
4197
+ function _t(f, e, t = 0.1) {
4198
+ 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;
4010
4199
  return {
4011
4200
  points: [
4012
4201
  // 第一条线
4013
- new w(d.x + r, d.y + o).add(i),
4014
- new w(e.x + r, e.y + o).add(s),
4202
+ new g(f.x + r, f.y + o).add(i),
4203
+ new g(e.x + r, e.y + o).add(s),
4015
4204
  // 第二条线
4016
- new w(d.x - r, d.y - o).add(i),
4017
- new w(e.x - r, e.y - o).add(s)
4205
+ new g(f.x - r, f.y - o).add(i),
4206
+ new g(e.x - r, e.y - o).add(s)
4018
4207
  ],
4019
4208
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
4020
4209
  rectIndices: [0, 1, 3, 2, 0]
4021
4210
  };
4022
4211
  }
4023
- class Ae extends W {
4212
+ class Oe extends ne {
4024
4213
  static name = "WhiteModel";
4025
4214
  Dxf = null;
4026
4215
  Variable = null;
4027
4216
  // dxf数据白模
4028
- whiteModelGroup = new G.Group();
4217
+ whiteModelGroup = new z.Group();
4029
4218
  // dxf数据白模边缘线
4030
- whiteModelLineGroup = new G.Group();
4219
+ whiteModelLineGroup = new z.Group();
4031
4220
  // 原始数据白模
4032
- originalWhiteMode = new G.Group();
4033
- material = new G.MeshStandardMaterial({ color: 16777215, transparent: !0, opacity: 0.8, side: G.DoubleSide });
4221
+ originalWhiteMode = new z.Group();
4222
+ material = new z.MeshStandardMaterial({ color: 16777215, transparent: !0, opacity: 0.8, side: z.DoubleSide });
4034
4223
  onAddFromParent(e) {
4035
4224
  this.Dxf = e.findComponentByName("Dxf"), this.Variable = e.findComponentByName("Variable"), this.originalWhiteMode.visible = !1, this.Dxf?.addEventListener("lineOffset", () => {
4036
4225
  this.updateModel();
@@ -4040,17 +4229,17 @@ class Ae extends W {
4040
4229
  this.Variable?.set("whiteModelVisible", !1);
4041
4230
  const e = this.Dxf;
4042
4231
  this.originalWhiteMode.clear(), this.whiteModelGroup.clear(), this.whiteModelLineGroup.clear(), this.whiteModelGroup.add(this.whiteModelLineGroup), this.whiteModelGroup.position.z = e.originalZAverage, this.originalWhiteMode.position.z = e.originalZAverage, e.wallsGroup.forEach((n) => {
4043
- const s = new G.Shape();
4232
+ const s = new z.Shape();
4044
4233
  n.forEach((o, a) => a === 0 ? s.moveTo(o.x / e.scale, o.y / e.scale) : s.lineTo(o.x / e.scale, o.y / e.scale));
4045
- const i = new G.ExtrudeGeometry(s, {
4234
+ const i = new z.ExtrudeGeometry(s, {
4046
4235
  depth: 2.8,
4047
4236
  bevelSize: 0
4048
- }), r = new G.Mesh(i, this.material);
4237
+ }), r = new z.Mesh(i, this.material);
4049
4238
  this.whiteModelGroup.add(r), this.whiteModelLineGroup.add(
4050
- new G.LineSegments(new G.EdgesGeometry(i), new G.LineBasicMaterial({ color: 0 }))
4239
+ new z.LineSegments(new z.EdgesGeometry(i), new z.LineBasicMaterial({ color: 0 }))
4051
4240
  );
4052
4241
  }), e.originalData.map(({ start: n, end: s, insetionArr: i }) => {
4053
- const r = new w(n.x, n.y).mutiplyScalar(e.scale), o = new w(s.x, s.y).mutiplyScalar(e.scale), { points: a, indices: l, rectIndices: c } = Pt(r, o, e.width);
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);
4054
4243
  return {
4055
4244
  points: a,
4056
4245
  indices: l,
@@ -4058,17 +4247,17 @@ class Ae extends W {
4058
4247
  insetions: (i ?? []).map((h) => h.index)
4059
4248
  };
4060
4249
  }).forEach((n) => {
4061
- const s = new G.Shape();
4250
+ const s = new z.Shape();
4062
4251
  n.rectIndices.forEach((o, a) => {
4063
4252
  const l = n.points[o];
4064
4253
  a === 0 ? s.moveTo(l.x, l.y) : s.lineTo(l.x, l.y);
4065
4254
  });
4066
- const i = new G.ExtrudeGeometry(s, {
4255
+ const i = new z.ExtrudeGeometry(s, {
4067
4256
  depth: 2.8,
4068
4257
  bevelSize: 0
4069
4258
  });
4070
4259
  if (i.attributes.position.array.filter((o) => Number.isNaN(o)).length) return;
4071
- const r = new G.Mesh(i);
4260
+ const r = new z.Mesh(i);
4072
4261
  this.originalWhiteMode?.add(r);
4073
4262
  }), this.dispatchEvent({
4074
4263
  type: "updateModel",
@@ -4083,7 +4272,7 @@ class Ae extends W {
4083
4272
  toOBJ() {
4084
4273
  return new Promise((e) => {
4085
4274
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
4086
- e(It.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
4275
+ e(Gt.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
4087
4276
  }, 20);
4088
4277
  });
4089
4278
  }
@@ -4095,7 +4284,7 @@ class Ae extends W {
4095
4284
  toGltf(e = !0) {
4096
4285
  return new Promise((t) => {
4097
4286
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
4098
- Rt.parse(this.whiteModelGroup.children, (n) => {
4287
+ zt.parse(this.whiteModelGroup.children, (n) => {
4099
4288
  t(n), this.material.opacity = 0.8, this.material.transparent = !0;
4100
4289
  }, () => {
4101
4290
  t(void 0);
@@ -4136,7 +4325,7 @@ class Ae extends W {
4136
4325
  n.href = URL.createObjectURL(t), n.download = e, n.click();
4137
4326
  } else if (typeof global < "u") {
4138
4327
  const t = await this.toOBJ();
4139
- t && (await H("fs", !1)).writeFileSync(e, t);
4328
+ t && (await se("fs", !1)).writeFileSync(e, t);
4140
4329
  }
4141
4330
  }
4142
4331
  /**
@@ -4152,11 +4341,11 @@ class Ae extends W {
4152
4341
  s.href = URL.createObjectURL(n), s.download = e, s.click();
4153
4342
  } else if (typeof global < "u") {
4154
4343
  const n = await this.toGltf(t);
4155
- n && (await H("fs", !1)).writeFileSync(e, t ? Buffer.from(n) : JSON.stringify(n));
4344
+ n && (await se("fs", !1)).writeFileSync(e, t ? Buffer.from(n) : JSON.stringify(n));
4156
4345
  }
4157
4346
  }
4158
4347
  }
4159
- class De extends W {
4348
+ class Fe extends ne {
4160
4349
  static name = "DetailsPoint";
4161
4350
  Dxf = null;
4162
4351
  WhiteModel = null;
@@ -4207,17 +4396,17 @@ class De extends W {
4207
4396
  this._timer = null;
4208
4397
  const e = this.parent?.findComponentByName("WhiteModel");
4209
4398
  this.raylines.length = 0, this.desPoints.length = 0, this.data.forEach((t) => {
4210
- const n = new G.Vector3(
4399
+ const n = new z.Vector3(
4211
4400
  t.position.x,
4212
4401
  t.position.y,
4213
4402
  t.position.z
4214
- ), s = new G.Vector3(
4403
+ ), s = new z.Vector3(
4215
4404
  t.direction.x,
4216
4405
  t.direction.y,
4217
4406
  t.direction.z
4218
4407
  ), i = 100;
4219
4408
  this.racasterHelper(n, s, i), s.z = 0;
4220
- const o = new G.Raycaster(n, s, 0, i).intersectObject(e.originalWhiteMode);
4409
+ const o = new z.Raycaster(n, s, 0, i).intersectObject(e.originalWhiteMode);
4221
4410
  if (o.length) {
4222
4411
  const { point: a } = o[0];
4223
4412
  this.desPoints.push({
@@ -4233,61 +4422,61 @@ class De extends W {
4233
4422
  }, 50);
4234
4423
  }
4235
4424
  }
4236
- class be extends W {
4425
+ class Ue extends ne {
4237
4426
  static name = "DxfLineModel";
4238
- dxfLineModel = new G.LineSegments();
4239
- dxfDoorsLineModel = new G.LineSegments();
4240
- dxfModelGroup = new G.Group();
4427
+ dxfLineModel = new z.LineSegments();
4428
+ dxfDoorsLineModel = new z.LineSegments();
4429
+ dxfModelGroup = new z.Group();
4241
4430
  onAddFromParent(e) {
4242
4431
  const t = e.findComponentByName("Dxf");
4243
- this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new G.LineBasicMaterial({ color: 16776960, vertexColors: !0 }), t?.addEventListener("lineOffset", () => this.updateMode());
4432
+ this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new z.LineBasicMaterial({ color: 16776960, vertexColors: !0 }), t?.addEventListener("lineOffset", () => this.updateMode());
4244
4433
  }
4245
4434
  updateMode() {
4246
4435
  const e = this.parent?.findComponentByName("Dxf");
4247
4436
  this.dxfLineModel.clear();
4248
4437
  const t = e.to3DArray(1 / e.scale, 0);
4249
- this.dxfLineModel.geometry = new G.BufferGeometry().setAttribute("position", new G.BufferAttribute(t, 3, !0));
4438
+ this.dxfLineModel.geometry = new z.BufferGeometry().setAttribute("position", new z.BufferAttribute(t, 3, !0));
4250
4439
  const n = new Float32Array(
4251
4440
  e.doorLineSegment.flatMap(({ start: i, end: r }) => [i.x, i.y, 0, r.x, r.y, 0])
4252
4441
  ).map((i) => i / e.scale), s = new Float32Array(e.doorLineSegment.flatMap(() => [1, 0, 0, 0, 1, 0]));
4253
- this.dxfDoorsLineModel.geometry = new G.BufferGeometry().setAttribute("position", new G.BufferAttribute(n, 3, !0)).setAttribute("color", new G.BufferAttribute(s, 3)), this.dxfModelGroup.position.z = e.originalZAverage, this.dispatchEvent({
4442
+ this.dxfDoorsLineModel.geometry = new z.BufferGeometry().setAttribute("position", new z.BufferAttribute(n, 3, !0)).setAttribute("color", new z.BufferAttribute(s, 3)), this.dxfModelGroup.position.z = e.originalZAverage, this.dispatchEvent({
4254
4443
  type: "modelUpdate",
4255
4444
  model: this.dxfModelGroup
4256
4445
  });
4257
4446
  }
4258
4447
  }
4259
- const Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4448
+ const qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4260
4449
  __proto__: null,
4261
- DetailsPoint: De,
4262
- DxfLineModel: be,
4263
- WhiteModel: Ae
4450
+ DetailsPoint: Fe,
4451
+ DxfLineModel: Ue,
4452
+ WhiteModel: Oe
4264
4453
  }, Symbol.toStringTag, { value: "Module" }));
4265
- function Me(d, e = {}) {
4454
+ function Pe(f, e = {}) {
4266
4455
  const {
4267
4456
  detailsPoint: t = !0,
4268
4457
  whiteModel: n = !0,
4269
4458
  dxfLineModel: s = !0
4270
4459
  } = e;
4271
- s && d.addComponent(new be()), n && d.addComponent(new Ae()), t && d.addComponent(new De());
4460
+ s && f.addComponent(new Ue()), n && f.addComponent(new Oe()), t && f.addComponent(new Fe());
4272
4461
  }
4273
- const vt = Object.assign(Me, {
4274
- create(d = {}) {
4275
- return (e) => Me(e, d);
4462
+ const jt = Object.assign(Pe, {
4463
+ create(f = {}) {
4464
+ return (e) => Pe(e, f);
4276
4465
  }
4277
- }), Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4466
+ }), Yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4278
4467
  __proto__: null,
4279
- ModelDataPlugin: vt,
4280
- components: Nt
4468
+ ModelDataPlugin: jt,
4469
+ components: qt
4281
4470
  }, Symbol.toStringTag, { value: "Module" }));
4282
- function Bt() {
4471
+ function kt() {
4283
4472
  return import("./index2.js");
4284
4473
  }
4285
- function Ot() {
4474
+ function Xt() {
4286
4475
  return import("./index3.js");
4287
4476
  }
4288
- let he = null;
4289
- async function qt(d, e, t = !1, n) {
4290
- const s = await Promise.resolve().then(() => Ct), i = await Bt(), r = await Ot(), o = new nt().usePlugin(s.ModelDataPlugin.create({
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({
4291
4480
  detailsPoint: !1,
4292
4481
  whiteModel: !0
4293
4482
  })).usePlugin(i.RenderPlugin.create({
@@ -4297,13 +4486,13 @@ async function qt(d, e, t = !1, n) {
4297
4486
  orbitControls: t,
4298
4487
  camera: e
4299
4488
  })).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
4300
- return a && d.appendChild(a.domElement), he = o, {
4489
+ return a && f.appendChild(a.domElement), Me = o, {
4301
4490
  dxfSystem: o,
4302
- getFileAll: () => Gt(o)
4491
+ getFileAll: () => Vt(o)
4303
4492
  };
4304
4493
  }
4305
- async function Gt(d = he) {
4306
- const e = d.findComponentByName("WhiteModel"), t = new File([await d.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([d.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([d.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(d.Dxf.originalData)], "json.json", { type: "application/json" });
4494
+ async function Vt(f = Me) {
4495
+ 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" });
4307
4496
  return {
4308
4497
  dxf: n,
4309
4498
  obj: i,
@@ -4314,27 +4503,27 @@ async function Gt(d = he) {
4314
4503
  correctionDxf: s
4315
4504
  };
4316
4505
  }
4317
- function jt() {
4318
- return he;
4506
+ function Zt() {
4507
+ return Me;
4319
4508
  }
4320
4509
  export {
4321
- _ as B,
4322
- W as C,
4323
- nt as D,
4324
- Le as E,
4325
- B as L,
4326
- vt as M,
4327
- w as P,
4328
- Y as Q,
4329
- tt as T,
4330
- Ee as V,
4331
- Ae as W,
4332
- De as a,
4333
- ce as b,
4334
- X as c,
4335
- qt as d,
4336
- jt as e,
4337
- Gt as g,
4338
- Nt as i,
4339
- ae as u
4510
+ 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
4340
4529
  };