build-dxf 0.0.43 → 0.0.44
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/package.json +1 -1
- package/src/build.js +986 -907
- package/src/index3.js +337 -339
- package/src/pages/Editor.vue.d.ts +1 -1
- package/src/selectLocalFile.js +4640 -1769
- package/src/utils/DxfSystem/DxfSystem.d.ts +4 -0
- package/src/utils/DxfSystem/components/AngleCorrectionDxf.d.ts +2 -2
- package/src/utils/DxfSystem/components/DoorsAnalysis.d.ts +118 -0
- package/src/utils/DxfSystem/components/LineAnalysis.d.ts +0 -94
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/RenderManager.d.ts +3 -3
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/Renderer.d.ts +7 -1
- package/src/utils/DxfSystem/type.d.ts +1 -0
- package/src/utils/DxfSystem/utils/drawHelper.d.ts +2 -2
- package/src/utils/DxfSystem/utils/extractClosedPolygons.d.ts +11 -0
- package/src/utils/PointVirtualGrid/index.d.ts +2 -1
- package/src/utils/Quadtree/LineSegment.d.ts +1 -1
- package/src/utils/Quadtree/Point.d.ts +7 -0
package/src/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as I from "three";
|
|
2
|
-
import { EventDispatcher as
|
|
2
|
+
import { EventDispatcher as Ft, Color as Ut, Matrix4 as Tt, Vector3 as Q, Quaternion as jt, BufferAttribute as _, REVISION as Gt, CompressedTexture as rt, Source as zt, NoColorSpace as qt, MathUtils as lt, RGBAFormat as _t, ImageUtils as Yt, DoubleSide as kt, PropertyBinding as tt, InterpolateDiscrete as Xt, Scene as ft, SRGBColorSpace as Vt, NearestFilter as Wt, NearestMipmapNearestFilter as Ht, NearestMipmapLinearFilter as Jt, LinearFilter as $t, LinearMipmapNearestFilter as Kt, LinearMipmapLinearFilter as Zt, ClampToEdgeWrapping as Qt, RepeatWrapping as te, MirroredRepeatWrapping as ee, InterpolateLinear as ne } from "three";
|
|
3
3
|
import pt from "clipper-lib";
|
|
4
|
-
import
|
|
5
|
-
import { OBJExporter as
|
|
6
|
-
function
|
|
7
|
-
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(
|
|
8
|
-
var t = Math.random() * 16 | 0, e =
|
|
4
|
+
import K from "dxf-writer";
|
|
5
|
+
import { OBJExporter as se } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
+
function Z() {
|
|
7
|
+
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(u) {
|
|
8
|
+
var t = Math.random() * 16 | 0, e = u == "x" ? t : t & 3 | 8;
|
|
9
9
|
return e.toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
class
|
|
13
|
-
uuid =
|
|
12
|
+
class bt extends Ft {
|
|
13
|
+
uuid = Z();
|
|
14
14
|
addEventListener(t, e, n) {
|
|
15
15
|
const { once: s = !1 } = n ?? {}, i = (o) => {
|
|
16
16
|
e(o), s && r();
|
|
@@ -30,7 +30,7 @@ class It extends Ot {
|
|
|
30
30
|
e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class z extends bt {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...t) {
|
|
@@ -48,7 +48,7 @@ class _ extends It {
|
|
|
48
48
|
this.destroyed = !0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
class ie extends bt {
|
|
52
52
|
static EventType = {
|
|
53
53
|
ADD_COMPONENT: "addComponent"
|
|
54
54
|
};
|
|
@@ -71,7 +71,7 @@ class se extends It {
|
|
|
71
71
|
* @param component
|
|
72
72
|
*/
|
|
73
73
|
removeComponent(t) {
|
|
74
|
-
if (t instanceof
|
|
74
|
+
if (t instanceof z) {
|
|
75
75
|
const e = this.components.indexOf(t);
|
|
76
76
|
e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
|
|
77
77
|
type: "removeComponent",
|
|
@@ -116,7 +116,7 @@ class se extends It {
|
|
|
116
116
|
return e || null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class P {
|
|
120
120
|
minX = 0;
|
|
121
121
|
maxX = 0;
|
|
122
122
|
minY = 0;
|
|
@@ -202,9 +202,9 @@ class N {
|
|
|
202
202
|
const o = this.points;
|
|
203
203
|
for (let c = 0; c < 4; c++) {
|
|
204
204
|
const l = o[c], h = o[(c + 1) % 4];
|
|
205
|
-
for (let
|
|
206
|
-
const f = e[
|
|
207
|
-
if (y * x < 0 &&
|
|
205
|
+
for (let d = 0; d < 4; d++) {
|
|
206
|
+
const f = e[d], p = e[(d + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), g = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), w = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
|
|
207
|
+
if (y * x < 0 && g * w < 0 || y === 0 && Math.min(l.x, h.x) <= f.x && f.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= f.y && f.y <= Math.max(l.y, h.y) || x === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || g === 0 && Math.min(f.x, p.x) <= l.x && l.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= l.y && l.y <= Math.max(f.y, p.y) || w === 0 && Math.min(f.x, p.x) <= h.x && h.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= h.y && h.y <= Math.max(f.y, p.y))
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -216,9 +216,9 @@ class N {
|
|
|
216
216
|
const a = (c) => {
|
|
217
217
|
let l = 0;
|
|
218
218
|
for (let h = 0; h < 4; h++) {
|
|
219
|
-
const
|
|
219
|
+
const d = e[h], f = e[(h + 1) % 4], p = (f.x - d.x) * (c.y - d.y) - (f.y - d.y) * (c.x - d.x);
|
|
220
220
|
if (p === 0) {
|
|
221
|
-
const y = Math.abs(f.x -
|
|
221
|
+
const y = Math.abs(f.x - d.x) > 1e-10 ? f.x - d.x : f.y - d.y, x = y ? (c.x - d.x) / y : 0;
|
|
222
222
|
if (x >= 0 && x <= 1) return !0;
|
|
223
223
|
} else {
|
|
224
224
|
const y = p > 0 ? 1 : -1;
|
|
@@ -299,7 +299,7 @@ class N {
|
|
|
299
299
|
* @returns
|
|
300
300
|
*/
|
|
301
301
|
clone() {
|
|
302
|
-
return new
|
|
302
|
+
return new P(this.minX, this.maxX, this.minY, this.maxY);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
*
|
|
@@ -310,7 +310,7 @@ class N {
|
|
|
310
310
|
const e = [], n = [];
|
|
311
311
|
return t.forEach((s) => {
|
|
312
312
|
e.push(s.x), n.push(s.y);
|
|
313
|
-
}), new
|
|
313
|
+
}), new P(
|
|
314
314
|
Math.min(...e),
|
|
315
315
|
Math.max(...e),
|
|
316
316
|
Math.min(...n),
|
|
@@ -328,7 +328,7 @@ class N {
|
|
|
328
328
|
s?.points?.forEach((i) => {
|
|
329
329
|
e.push(i.x), n.push(i.y);
|
|
330
330
|
});
|
|
331
|
-
}), new
|
|
331
|
+
}), new P(
|
|
332
332
|
Math.min(...e),
|
|
333
333
|
Math.max(...e),
|
|
334
334
|
Math.min(...n),
|
|
@@ -336,7 +336,7 @@ class N {
|
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
class
|
|
339
|
+
class k {
|
|
340
340
|
map = /* @__PURE__ */ new Map();
|
|
341
341
|
targetMap = /* @__PURE__ */ new Map();
|
|
342
342
|
gridSize;
|
|
@@ -374,6 +374,9 @@ class X {
|
|
|
374
374
|
n && (n.delete(e), delete t?.userData?.pointVirtualGridMap, this.targetMap.delete(t));
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
+
update(t) {
|
|
378
|
+
this.remove(t), this.insert(t);
|
|
379
|
+
}
|
|
377
380
|
/**
|
|
378
381
|
* 获取通过坐标,获取唯一网格索引
|
|
379
382
|
* @param point
|
|
@@ -415,7 +418,7 @@ class X {
|
|
|
415
418
|
* @returns 相交的节点数组
|
|
416
419
|
*/
|
|
417
420
|
queryCircle(t, e) {
|
|
418
|
-
const n = new
|
|
421
|
+
const n = new P(t.x - e, t.x + e, t.y - e, t.y + e), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
|
|
419
422
|
for (let c = s; c <= i; c++)
|
|
420
423
|
for (let l = r; l <= o; l++) {
|
|
421
424
|
const h = `${c}.${l}`;
|
|
@@ -447,11 +450,14 @@ class X {
|
|
|
447
450
|
* 查找相同点
|
|
448
451
|
* @param point
|
|
449
452
|
*/
|
|
450
|
-
queryPoint(t) {
|
|
451
|
-
const
|
|
452
|
-
return this.map.has(
|
|
453
|
-
t.equal(
|
|
454
|
-
|
|
453
|
+
queryPoint(t, e = !1) {
|
|
454
|
+
const n = this.getGridId(t), s = [];
|
|
455
|
+
return this.map.has(n) && this.map.get(n)?.forEach((r) => {
|
|
456
|
+
if (t.equal(r.point)) {
|
|
457
|
+
if (e && t === r.point) return;
|
|
458
|
+
s.push(r);
|
|
459
|
+
}
|
|
460
|
+
}), s;
|
|
455
461
|
}
|
|
456
462
|
/**
|
|
457
463
|
* 查找点自己
|
|
@@ -465,7 +471,7 @@ class X {
|
|
|
465
471
|
return null;
|
|
466
472
|
}
|
|
467
473
|
}
|
|
468
|
-
class
|
|
474
|
+
class it {
|
|
469
475
|
points;
|
|
470
476
|
get p0() {
|
|
471
477
|
return this.points[0];
|
|
@@ -523,8 +529,8 @@ class nt {
|
|
|
523
529
|
if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
|
|
524
530
|
return !0;
|
|
525
531
|
} else {
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
532
|
+
const d = ((o.x - e.x) * l - (o.y - e.y) * c) / h, f = ((o.x - e.x) * i - (o.y - e.y) * s) / h;
|
|
533
|
+
if (d >= 0 && d <= 1 && f >= 0 && f <= 1)
|
|
528
534
|
return !0;
|
|
529
535
|
}
|
|
530
536
|
}
|
|
@@ -606,7 +612,7 @@ class nt {
|
|
|
606
612
|
let t = 1 / 0, e = -1 / 0, n = 1 / 0, s = -1 / 0;
|
|
607
613
|
return this.points.forEach((i) => {
|
|
608
614
|
e = Math.max(i.x, e), t = Math.min(i.x, t), s = Math.max(i.x, s), n = Math.min(i.x, n);
|
|
609
|
-
}), new
|
|
615
|
+
}), new P(t, e, n, s);
|
|
610
616
|
}
|
|
611
617
|
/**
|
|
612
618
|
*
|
|
@@ -616,7 +622,7 @@ class nt {
|
|
|
616
622
|
*/
|
|
617
623
|
static fromByLineSegment(t, e = 0.1, n = !1, s = 0.5) {
|
|
618
624
|
const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : M.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : M.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
|
|
619
|
-
return new
|
|
625
|
+
return new it([
|
|
620
626
|
new M(i.x + l, i.y + h).add(c),
|
|
621
627
|
new M(r.x + l, r.y + h).add(a),
|
|
622
628
|
new M(r.x - l, r.y - h).add(a),
|
|
@@ -624,7 +630,7 @@ class nt {
|
|
|
624
630
|
]);
|
|
625
631
|
}
|
|
626
632
|
}
|
|
627
|
-
class
|
|
633
|
+
class L {
|
|
628
634
|
points = [new M(), new M()];
|
|
629
635
|
userData = {};
|
|
630
636
|
// line: any
|
|
@@ -737,7 +743,7 @@ class A {
|
|
|
737
743
|
new M(n.x - a, n.y - c).add(o),
|
|
738
744
|
new M(s.x - a, s.y - c).add(r)
|
|
739
745
|
];
|
|
740
|
-
return new
|
|
746
|
+
return new it([0, 1, 3, 2].map((h) => l[h]));
|
|
741
747
|
}
|
|
742
748
|
/**
|
|
743
749
|
* 计算线段的长度
|
|
@@ -778,20 +784,20 @@ class A {
|
|
|
778
784
|
if (r.x === 0 && r.y === 0)
|
|
779
785
|
throw new Error("投影目标线段的两个点不能重合");
|
|
780
786
|
const o = (p) => {
|
|
781
|
-
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y,
|
|
782
|
-
return new M(
|
|
787
|
+
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, w = (y.x * r.x + y.y * r.y) / x, D = s.x + w * r.x, m = s.y + w * r.y;
|
|
788
|
+
return new M(D, m);
|
|
783
789
|
};
|
|
784
790
|
let a = o(e), c = o(n);
|
|
785
791
|
const l = (p) => {
|
|
786
792
|
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
|
|
787
793
|
return (y.x * r.x + y.y * r.y) / x;
|
|
788
794
|
};
|
|
789
|
-
let h = l(a),
|
|
795
|
+
let h = l(a), d = l(c);
|
|
790
796
|
const f = (p) => {
|
|
791
|
-
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x,
|
|
792
|
-
return new M(x,
|
|
797
|
+
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, g = s.y + y * r.y;
|
|
798
|
+
return new M(x, g);
|
|
793
799
|
};
|
|
794
|
-
return (h < 0 || h > 1) && (a = f(h)), (
|
|
800
|
+
return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new L(a, a) : new L(a, c);
|
|
795
801
|
}
|
|
796
802
|
/**
|
|
797
803
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -804,13 +810,13 @@ class A {
|
|
|
804
810
|
if (i.x === 0 && i.y === 0)
|
|
805
811
|
throw new Error("投影目标线段的两个点不能重合");
|
|
806
812
|
let o = ((l) => {
|
|
807
|
-
const h = new M(l.x - n.x, l.y - n.y),
|
|
813
|
+
const h = new M(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, y = n.x + p * i.x, x = n.y + p * i.y;
|
|
808
814
|
return new M(y, x);
|
|
809
815
|
})(t);
|
|
810
816
|
if (!e) return o;
|
|
811
817
|
let c = ((l) => {
|
|
812
|
-
const h = new M(l.x - n.x, l.y - n.y),
|
|
813
|
-
return (h.x * i.x + h.y * i.y) /
|
|
818
|
+
const h = new M(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y;
|
|
819
|
+
return (h.x * i.x + h.y * i.y) / d;
|
|
814
820
|
})(o);
|
|
815
821
|
return c < 0 || c > 1 ? null : o;
|
|
816
822
|
}
|
|
@@ -828,8 +834,8 @@ class A {
|
|
|
828
834
|
function a(f, p, y) {
|
|
829
835
|
return Math.min(p.x, y.x) - 1e-10 <= f.x && f.x <= Math.max(p.x, y.x) + 1e-10 && Math.min(p.y, y.y) - 1e-10 <= f.y && f.y <= Math.max(p.y, y.y) + 1e-10;
|
|
830
836
|
}
|
|
831
|
-
const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n),
|
|
832
|
-
return !!(c * l < 0 && h *
|
|
837
|
+
const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
|
|
838
|
+
return !!(c * l < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
|
|
833
839
|
}
|
|
834
840
|
/**
|
|
835
841
|
* 判断一个点是否在线段上(含端点)
|
|
@@ -872,7 +878,7 @@ class A {
|
|
|
872
878
|
* @param line
|
|
873
879
|
*/
|
|
874
880
|
parallel(t, e = 1) {
|
|
875
|
-
return t instanceof
|
|
881
|
+
return t instanceof L ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
|
|
876
882
|
}
|
|
877
883
|
/** 两条线段或角度是否 垂直
|
|
878
884
|
* @param line
|
|
@@ -880,7 +886,7 @@ class A {
|
|
|
880
886
|
* @returns
|
|
881
887
|
*/
|
|
882
888
|
vertical(t, e = 0.1) {
|
|
883
|
-
return t instanceof
|
|
889
|
+
return t instanceof L ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
|
|
884
890
|
}
|
|
885
891
|
/**
|
|
886
892
|
* 两条线段方向相反否一致
|
|
@@ -931,8 +937,8 @@ class A {
|
|
|
931
937
|
if (l > 1)
|
|
932
938
|
return n.distance(r);
|
|
933
939
|
{
|
|
934
|
-
const h = i.x + l * o,
|
|
935
|
-
return n.distance(new M(h,
|
|
940
|
+
const h = i.x + l * o, d = i.y + l * a;
|
|
941
|
+
return n.distance(new M(h, d));
|
|
936
942
|
}
|
|
937
943
|
};
|
|
938
944
|
return Math.min(
|
|
@@ -955,7 +961,7 @@ class A {
|
|
|
955
961
|
* @returns
|
|
956
962
|
*/
|
|
957
963
|
clone() {
|
|
958
|
-
const t = new
|
|
964
|
+
const t = new L(
|
|
959
965
|
this.points[0].clone(),
|
|
960
966
|
this.points[1].clone()
|
|
961
967
|
);
|
|
@@ -978,13 +984,13 @@ class A {
|
|
|
978
984
|
* @param selectLines
|
|
979
985
|
*/
|
|
980
986
|
static groupBySamePointAndParallel(t) {
|
|
981
|
-
const e = new
|
|
987
|
+
const e = new k();
|
|
982
988
|
t.forEach((r) => r.points.forEach((o) => e.insert(o, r)));
|
|
983
989
|
const n = /* @__PURE__ */ new Set();
|
|
984
990
|
function s(r, o, a) {
|
|
985
991
|
if (o.has(r)) return;
|
|
986
|
-
const c = e.queryPoint(r.start).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), l = e.queryPoint(r.end).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), h = c[0]?.userData,
|
|
987
|
-
return h && !a.has(h) && (a.add(h), s(h, o, a)),
|
|
992
|
+
const c = e.queryPoint(r.start).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), l = e.queryPoint(r.end).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), h = c[0]?.userData, d = l[0]?.userData;
|
|
993
|
+
return h && !a.has(h) && (a.add(h), s(h, o, a)), d && !a.has(d) && (a.add(d), s(d, o, a)), o.add(r), a;
|
|
988
994
|
}
|
|
989
995
|
const i = [];
|
|
990
996
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -1001,16 +1007,16 @@ class A {
|
|
|
1001
1007
|
*/
|
|
1002
1008
|
static mergeLinesByMaxlength(...t) {
|
|
1003
1009
|
if (t.length === 1) return t[0];
|
|
1004
|
-
const n = t.slice(0).sort((h,
|
|
1010
|
+
const n = t.slice(0).sort((h, d) => d.length() - h.length())[0], s = n.direction().normalize();
|
|
1005
1011
|
let i = n.start.clone(), r = n.end.clone();
|
|
1006
1012
|
const o = (h) => h.x * s.x + h.y * s.y;
|
|
1007
1013
|
let a = o(i), c = o(r);
|
|
1008
1014
|
for (const h of t)
|
|
1009
|
-
for (const
|
|
1010
|
-
const f = o(
|
|
1011
|
-
f < a && (a = f, i = n.projectPoint(
|
|
1015
|
+
for (const d of h.points) {
|
|
1016
|
+
const f = o(d);
|
|
1017
|
+
f < a && (a = f, i = n.projectPoint(d, !1)), f > c && (c = f, r = n.projectPoint(d, !1));
|
|
1012
1018
|
}
|
|
1013
|
-
const l = new
|
|
1019
|
+
const l = new L(i, r);
|
|
1014
1020
|
return t.forEach((h) => h.userData.fittedLine = l), l;
|
|
1015
1021
|
}
|
|
1016
1022
|
/** 合并平行线段
|
|
@@ -1029,7 +1035,7 @@ class A {
|
|
|
1029
1035
|
const y = p.x * s.x + p.y * s.y;
|
|
1030
1036
|
i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
|
|
1031
1037
|
});
|
|
1032
|
-
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y),
|
|
1038
|
+
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y), d = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new L(h, d);
|
|
1033
1039
|
return t.forEach((p) => p.userData.fittedLine = f), f;
|
|
1034
1040
|
}
|
|
1035
1041
|
/** 合并满足平行的线段
|
|
@@ -1135,6 +1141,15 @@ class M {
|
|
|
1135
1141
|
division(t) {
|
|
1136
1142
|
return this.x -= t.x, this.y -= t.y, this;
|
|
1137
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* 减法
|
|
1146
|
+
* @description 将当前点的坐标减去指定点的坐标
|
|
1147
|
+
* @param point
|
|
1148
|
+
* @returns
|
|
1149
|
+
*/
|
|
1150
|
+
subtract(t) {
|
|
1151
|
+
return this.x -= t.x, this.y -= t.y, this;
|
|
1152
|
+
}
|
|
1138
1153
|
/**
|
|
1139
1154
|
* 加法
|
|
1140
1155
|
* @description 将当前点的坐标加上指定点的坐标
|
|
@@ -1194,7 +1209,7 @@ class M {
|
|
|
1194
1209
|
* @param length
|
|
1195
1210
|
*/
|
|
1196
1211
|
expandAsLine(t, e, n) {
|
|
1197
|
-
const s = new
|
|
1212
|
+
const s = new L(
|
|
1198
1213
|
this.clone(),
|
|
1199
1214
|
this.clone().add(t.clone().multiplyScalar(e))
|
|
1200
1215
|
);
|
|
@@ -1289,18 +1304,18 @@ class M {
|
|
|
1289
1304
|
return new M(0, 0);
|
|
1290
1305
|
}
|
|
1291
1306
|
}
|
|
1292
|
-
async function
|
|
1307
|
+
async function X(u, t = !0) {
|
|
1293
1308
|
if (typeof global < "u" && typeof require < "u")
|
|
1294
|
-
return require(
|
|
1309
|
+
return require(u);
|
|
1295
1310
|
{
|
|
1296
1311
|
let e = await import(
|
|
1297
1312
|
/* @vite-ignore */
|
|
1298
|
-
|
|
1313
|
+
u
|
|
1299
1314
|
);
|
|
1300
1315
|
return t && (e = e.default), e;
|
|
1301
1316
|
}
|
|
1302
1317
|
}
|
|
1303
|
-
class
|
|
1318
|
+
class B {
|
|
1304
1319
|
bounds;
|
|
1305
1320
|
// 包围盒
|
|
1306
1321
|
capacity;
|
|
@@ -1326,7 +1341,7 @@ class F {
|
|
|
1326
1341
|
* @param node 线段节点
|
|
1327
1342
|
*/
|
|
1328
1343
|
insert(t) {
|
|
1329
|
-
if (t instanceof
|
|
1344
|
+
if (t instanceof L) {
|
|
1330
1345
|
this.insert({ line: t, userData: {} });
|
|
1331
1346
|
return;
|
|
1332
1347
|
}
|
|
@@ -1351,7 +1366,7 @@ class F {
|
|
|
1351
1366
|
* @param node
|
|
1352
1367
|
*/
|
|
1353
1368
|
remove(t) {
|
|
1354
|
-
if (t instanceof
|
|
1369
|
+
if (t instanceof L) {
|
|
1355
1370
|
t = this.targetMap.get(t), t && this.remove(t);
|
|
1356
1371
|
return;
|
|
1357
1372
|
}
|
|
@@ -1381,26 +1396,26 @@ class F {
|
|
|
1381
1396
|
if (!this.isLeaf) return;
|
|
1382
1397
|
this.isLeaf = !1, this.children = [];
|
|
1383
1398
|
const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
|
|
1384
|
-
this.children[0] = new
|
|
1385
|
-
new
|
|
1399
|
+
this.children[0] = new B(
|
|
1400
|
+
new P(this.bounds.minX, t, this.bounds.minY, e),
|
|
1386
1401
|
this.capacity,
|
|
1387
1402
|
this.maxDepth,
|
|
1388
1403
|
this.depth + 1,
|
|
1389
1404
|
this.targetMap
|
|
1390
|
-
), this.children[1] = new
|
|
1391
|
-
new
|
|
1405
|
+
), this.children[1] = new B(
|
|
1406
|
+
new P(t, this.bounds.maxX, this.bounds.minY, e),
|
|
1392
1407
|
this.capacity,
|
|
1393
1408
|
this.maxDepth,
|
|
1394
1409
|
this.depth + 1,
|
|
1395
1410
|
this.targetMap
|
|
1396
|
-
), this.children[2] = new
|
|
1397
|
-
new
|
|
1411
|
+
), this.children[2] = new B(
|
|
1412
|
+
new P(this.bounds.minX, t, e, this.bounds.maxY),
|
|
1398
1413
|
this.capacity,
|
|
1399
1414
|
this.maxDepth,
|
|
1400
1415
|
this.depth + 1,
|
|
1401
1416
|
this.targetMap
|
|
1402
|
-
), this.children[3] = new
|
|
1403
|
-
new
|
|
1417
|
+
), this.children[3] = new B(
|
|
1418
|
+
new P(t, this.bounds.maxX, e, this.bounds.maxY),
|
|
1404
1419
|
this.capacity,
|
|
1405
1420
|
this.maxDepth,
|
|
1406
1421
|
this.depth + 1,
|
|
@@ -1430,7 +1445,7 @@ class F {
|
|
|
1430
1445
|
* @returns 相交的节点数组
|
|
1431
1446
|
*/
|
|
1432
1447
|
queryCircle(t, e) {
|
|
1433
|
-
const n = [], s = new
|
|
1448
|
+
const n = [], s = new P(
|
|
1434
1449
|
t.x - e,
|
|
1435
1450
|
t.x + e,
|
|
1436
1451
|
t.y - e,
|
|
@@ -1442,8 +1457,8 @@ class F {
|
|
|
1442
1457
|
const [r, o] = i.line.points, a = o.x - r.x, c = o.y - r.y, l = a * a + c * c;
|
|
1443
1458
|
let h = ((t.x - r.x) * a + (t.y - r.y) * c) / l;
|
|
1444
1459
|
h = Math.max(0, Math.min(1, h));
|
|
1445
|
-
const
|
|
1446
|
-
t.distance(new M(
|
|
1460
|
+
const d = r.x + h * a, f = r.y + h * c;
|
|
1461
|
+
t.distance(new M(d, f)) <= e && n.push(i);
|
|
1447
1462
|
}
|
|
1448
1463
|
if (!this.isLeaf)
|
|
1449
1464
|
for (const i of this.children)
|
|
@@ -1511,9 +1526,9 @@ class F {
|
|
|
1511
1526
|
})), t;
|
|
1512
1527
|
}
|
|
1513
1528
|
}
|
|
1514
|
-
function J(
|
|
1515
|
-
return e || (e = new
|
|
1516
|
-
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index:
|
|
1529
|
+
function J(u, t = 0, e) {
|
|
1530
|
+
return e || (e = new B(P.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 }))), u.map((n) => {
|
|
1531
|
+
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: u.indexOf(o.line) }));
|
|
1517
1532
|
return {
|
|
1518
1533
|
start: n.start.toJson(t),
|
|
1519
1534
|
end: n.end.toJson(t),
|
|
@@ -1528,14 +1543,15 @@ function J(d, t = 0, e) {
|
|
|
1528
1543
|
drawWindow: i && i.map((o) => ({
|
|
1529
1544
|
p: { x: o.p.x, y: o.p.y, z: o.p.z },
|
|
1530
1545
|
width: o.width,
|
|
1531
|
-
full: o.full
|
|
1546
|
+
full: o.full,
|
|
1547
|
+
rooftopPz: o.rooftopPz
|
|
1532
1548
|
}))
|
|
1533
1549
|
};
|
|
1534
1550
|
});
|
|
1535
1551
|
}
|
|
1536
|
-
function
|
|
1537
|
-
const e = new
|
|
1538
|
-
return
|
|
1552
|
+
function et(u, t = 0.03) {
|
|
1553
|
+
const e = new B(P.fromByLineSegment(...u));
|
|
1554
|
+
return u.forEach((n) => e.insert({ line: n, userData: void 0 })), u.flatMap((n) => {
|
|
1539
1555
|
const s = e.queryLineSegment(n, !0).map((i) => {
|
|
1540
1556
|
if (i.line === n) return;
|
|
1541
1557
|
const r = i.line.getIntersection(n);
|
|
@@ -1554,8 +1570,8 @@ function lt(d, t = 0.03) {
|
|
|
1554
1570
|
return n;
|
|
1555
1571
|
}).filter((n) => n.length() >= t);
|
|
1556
1572
|
}
|
|
1557
|
-
function
|
|
1558
|
-
|
|
1573
|
+
function nt(...u) {
|
|
1574
|
+
u.forEach((t) => {
|
|
1559
1575
|
const e = t.direction();
|
|
1560
1576
|
t.userData.drawWindow?.forEach((n) => {
|
|
1561
1577
|
try {
|
|
@@ -1565,20 +1581,20 @@ function tt(...d) {
|
|
|
1565
1581
|
), r = t.projectPoint(
|
|
1566
1582
|
s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
|
|
1567
1583
|
!1
|
|
1568
|
-
), o = t.projectLineSegment(new
|
|
1584
|
+
), o = t.projectLineSegment(new L(i, r)), a = o.center;
|
|
1569
1585
|
n.p = new I.Vector3(a?.x ?? 0, a?.y ?? 0, n.p.z);
|
|
1570
1586
|
} catch {
|
|
1571
1587
|
}
|
|
1572
1588
|
});
|
|
1573
1589
|
});
|
|
1574
1590
|
}
|
|
1575
|
-
function
|
|
1576
|
-
e || (e = new
|
|
1591
|
+
function re(u, t = 0.1, e) {
|
|
1592
|
+
e || (e = new k(), u.forEach((i) => {
|
|
1577
1593
|
i.userData.isDoor || i.points.forEach((r) => e?.insert(r, i));
|
|
1578
1594
|
}));
|
|
1579
1595
|
const n = [], s = /* @__PURE__ */ new Set();
|
|
1580
|
-
for (let i = 0; i <
|
|
1581
|
-
const r =
|
|
1596
|
+
for (let i = 0; i < u.length; i++) {
|
|
1597
|
+
const r = u[i], o = /* @__PURE__ */ new Map();
|
|
1582
1598
|
r.userData.isDoor || r.points.forEach((a) => {
|
|
1583
1599
|
if (s.has(a)) return !1;
|
|
1584
1600
|
if (e.queryPoint(a).length > 1) return;
|
|
@@ -1586,40 +1602,40 @@ function ie(d, t = 0.1, e) {
|
|
|
1586
1602
|
if (s.has(y.point)) return !1;
|
|
1587
1603
|
const x = y.userData;
|
|
1588
1604
|
if (x === r || !r.parallel(x, 25) || e.queryPoint(y.point).length > 1) return !1;
|
|
1589
|
-
const
|
|
1590
|
-
if (
|
|
1591
|
-
const
|
|
1592
|
-
if (180 -
|
|
1593
|
-
return o.set(y.point,
|
|
1605
|
+
const g = a.distance(y.point);
|
|
1606
|
+
if (g < 1e-3) return !1;
|
|
1607
|
+
const w = a.direction(r.getAnotherPoint(a)), D = y.point.direction(x.getAnotherPoint(y.point));
|
|
1608
|
+
if (180 - w.angleBetween(D, "angle") < 25)
|
|
1609
|
+
return o.set(y.point, g), !0;
|
|
1594
1610
|
}).sort((y, x) => {
|
|
1595
|
-
const
|
|
1596
|
-
return
|
|
1611
|
+
const g = o.get(y.point), w = o.get(x.point);
|
|
1612
|
+
return g - w;
|
|
1597
1613
|
});
|
|
1598
1614
|
if (c.length === 0) return;
|
|
1599
1615
|
s.add(a), s.add(c[0].point);
|
|
1600
|
-
const l = c[0].userData, h = r.projectLineSegment(l),
|
|
1601
|
-
f === 0 && p === 0 ? n.push(new
|
|
1616
|
+
const l = c[0].userData, h = r.projectLineSegment(l), d = l.projectLineSegment(r), f = h.length(), p = d.length();
|
|
1617
|
+
f === 0 && p === 0 ? n.push(new L(a.clone(), c[0].point.clone())) : n.push(new L(h.center, d.center));
|
|
1602
1618
|
});
|
|
1603
1619
|
}
|
|
1604
|
-
return [...
|
|
1620
|
+
return [...u, ...n];
|
|
1605
1621
|
}
|
|
1606
|
-
function
|
|
1607
|
-
const t = new
|
|
1608
|
-
return
|
|
1622
|
+
function oe(u) {
|
|
1623
|
+
const t = new k(), e = new B(P.fromByLineSegment(...u)), n = [];
|
|
1624
|
+
return u.forEach((s) => {
|
|
1609
1625
|
s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert({ line: s, userData: void 0 }));
|
|
1610
1626
|
}), n.forEach((s) => {
|
|
1611
1627
|
const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
|
|
1612
1628
|
i.length ? s.userData.startIntersection = i[0].userData : s.userData.startIntersection = e.queryPoint(s.start)[0]?.line, r.length ? s.userData.endIntersection = r[0].userData : s.userData.endIntersection = e.queryPoint(s.end)[0]?.line;
|
|
1613
|
-
}),
|
|
1629
|
+
}), u = re(u, 0.4, t), u;
|
|
1614
1630
|
}
|
|
1615
|
-
function
|
|
1616
|
-
const t = new
|
|
1617
|
-
|
|
1631
|
+
function ae(u) {
|
|
1632
|
+
const t = new B(P.fromByLineSegment(...u));
|
|
1633
|
+
u.forEach((n) => {
|
|
1618
1634
|
n.userData.isDoor || t.insert({ line: n, userData: void 0 });
|
|
1619
1635
|
});
|
|
1620
1636
|
const e = /* @__PURE__ */ new Map();
|
|
1621
|
-
for (let n = 0; n <
|
|
1622
|
-
const s =
|
|
1637
|
+
for (let n = 0; n < u.length; n++) {
|
|
1638
|
+
const s = u[n], i = t.queryLineSegment(s).filter((r) => r.line !== s).map((r) => {
|
|
1623
1639
|
const o = s.getSameEndpoint(r.line) ?? [];
|
|
1624
1640
|
return {
|
|
1625
1641
|
line: r.line,
|
|
@@ -1632,61 +1648,61 @@ function oe(d) {
|
|
|
1632
1648
|
}
|
|
1633
1649
|
return e;
|
|
1634
1650
|
}
|
|
1635
|
-
function
|
|
1636
|
-
const s = [
|
|
1637
|
-
function a(
|
|
1638
|
-
if (
|
|
1639
|
-
const f = Math.atan2(
|
|
1640
|
-
let y = Math.atan2(
|
|
1651
|
+
function ce(u, t, e, n = 15) {
|
|
1652
|
+
const s = [u], i = [], r = [], o = [];
|
|
1653
|
+
function a(d) {
|
|
1654
|
+
if (d.userData.isDoor) return r.push(d);
|
|
1655
|
+
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x);
|
|
1656
|
+
let y = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x) - f;
|
|
1641
1657
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
1642
1658
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1643
|
-
const x =
|
|
1644
|
-
return
|
|
1659
|
+
const x = d.center;
|
|
1660
|
+
return d.start.rotate(x, y), d.end.rotate(x, y), d.userData.isDoor ? r.push(d) : s.push(d), d;
|
|
1645
1661
|
}
|
|
1646
|
-
function c(
|
|
1647
|
-
if (
|
|
1648
|
-
const f = Math.atan2(
|
|
1662
|
+
function c(d) {
|
|
1663
|
+
if (d.userData.isDoor) return r.push(d);
|
|
1664
|
+
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x), p = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
|
|
1649
1665
|
let y = p + Math.PI / 2 - f, x = p - Math.PI / 2 - f;
|
|
1650
1666
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
1651
1667
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1652
1668
|
for (; x > Math.PI; ) x -= 2 * Math.PI;
|
|
1653
1669
|
for (; x < -Math.PI; ) x += 2 * Math.PI;
|
|
1654
|
-
const
|
|
1655
|
-
return
|
|
1670
|
+
const g = Math.abs(y) < Math.abs(x) ? y : x, w = d.center;
|
|
1671
|
+
return d.start.rotate(w, g), d.end.rotate(w, g), d.userData.isDoor ? r.push(d) : i.push(d), d;
|
|
1656
1672
|
}
|
|
1657
|
-
function l(
|
|
1658
|
-
if (p) return l(
|
|
1659
|
-
|
|
1673
|
+
function l(d, f, p = !1) {
|
|
1674
|
+
if (p) return l(d === "parallel" ? "vertical" : "parallel", f);
|
|
1675
|
+
d === "parallel" ? a(f) : c(f);
|
|
1660
1676
|
}
|
|
1661
1677
|
const h = [];
|
|
1662
|
-
for (let
|
|
1663
|
-
const f = t[
|
|
1664
|
-
if (
|
|
1665
|
-
if (f.userData.isWindow && o.push(f), f.parallel(
|
|
1666
|
-
else if (f.vertical(
|
|
1678
|
+
for (let d = 0; d < t.length; d++) {
|
|
1679
|
+
const f = t[d];
|
|
1680
|
+
if (u !== f)
|
|
1681
|
+
if (f.userData.isWindow && o.push(f), f.parallel(u, n)) a(f);
|
|
1682
|
+
else if (f.vertical(u, n)) c(f);
|
|
1667
1683
|
else {
|
|
1668
|
-
const y = e.get(f)?.reduce((x,
|
|
1684
|
+
const y = e.get(f)?.reduce((x, g) => (g.sourcePoint && (x.has(g.sourcePoint) || x.set(g.sourcePoint, []), x.get(g.sourcePoint)?.push(g)), x), /* @__PURE__ */ new Map());
|
|
1669
1685
|
y && y.size > 1 ? h.push(() => {
|
|
1670
1686
|
const x = [...y.values()].map(
|
|
1671
|
-
(
|
|
1672
|
-
).map((
|
|
1673
|
-
if (
|
|
1674
|
-
if (
|
|
1675
|
-
if (
|
|
1676
|
-
if (
|
|
1677
|
-
if (
|
|
1678
|
-
return l(
|
|
1687
|
+
(D) => D.map((m) => s.includes(m.line) ? "parallel" : i.includes(m.line) ? "vertical" : null).filter((m) => !!m)
|
|
1688
|
+
).map((D) => [...new Set(D)]), g = x[0], w = x[1];
|
|
1689
|
+
if (g.length === 1 && w.length === 1) {
|
|
1690
|
+
if (g[0] === w[0]) return l(g[0], f, !0);
|
|
1691
|
+
if (g.length === 1) {
|
|
1692
|
+
if (w.includes(g[0])) return l(g[0], f, !0);
|
|
1693
|
+
if (w.length === 1 && g.includes(w[0]))
|
|
1694
|
+
return l(w[0], f, !0);
|
|
1679
1695
|
}
|
|
1680
1696
|
}
|
|
1681
1697
|
c(f);
|
|
1682
1698
|
}) : c(f);
|
|
1683
1699
|
}
|
|
1684
1700
|
}
|
|
1685
|
-
return h.forEach((
|
|
1701
|
+
return h.forEach((d) => d()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
|
|
1686
1702
|
}
|
|
1687
|
-
function yt(
|
|
1703
|
+
function yt(u, t, e, n, s) {
|
|
1688
1704
|
const i = [], r = /* @__PURE__ */ new Map();
|
|
1689
|
-
|
|
1705
|
+
u.forEach((c) => {
|
|
1690
1706
|
const l = e.projectPoint(c.start, !1);
|
|
1691
1707
|
l && (l.userData = c, i.push(l), r.set(c, l));
|
|
1692
1708
|
}), i.sort((c, l) => l.distance(e.start) - c.distance(e.start));
|
|
@@ -1703,74 +1719,74 @@ function yt(d, t, e, n, s) {
|
|
|
1703
1719
|
const l = c.flatMap((p) => {
|
|
1704
1720
|
const y = p.userData;
|
|
1705
1721
|
return y.points.map((x) => {
|
|
1706
|
-
const
|
|
1707
|
-
return
|
|
1722
|
+
const g = t.projectPoint(x, !1);
|
|
1723
|
+
return g.userData = y, g;
|
|
1708
1724
|
});
|
|
1709
1725
|
});
|
|
1710
1726
|
l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
|
|
1711
|
-
const h = /* @__PURE__ */ new Map(),
|
|
1727
|
+
const h = /* @__PURE__ */ new Map(), d = [];
|
|
1712
1728
|
let f = [];
|
|
1713
1729
|
return l.forEach((p, y) => {
|
|
1714
|
-
h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...
|
|
1730
|
+
h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...d]), d.length = 0), h.set(p.userData, (h.get(p.userData) ?? 0) + 1);
|
|
1715
1731
|
for (const x of h.values()) if (x !== 2) return;
|
|
1716
|
-
|
|
1717
|
-
}), f.push([...
|
|
1732
|
+
d.push(...h.keys()), h.clear();
|
|
1733
|
+
}), f.push([...d]), f;
|
|
1718
1734
|
});
|
|
1719
1735
|
}
|
|
1720
|
-
function xt(
|
|
1736
|
+
function xt(u, t, e, n) {
|
|
1721
1737
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
|
|
1722
|
-
|
|
1723
|
-
const f = e.projectPoint(
|
|
1724
|
-
f && (f.userData =
|
|
1738
|
+
u.forEach((d) => {
|
|
1739
|
+
const f = e.projectPoint(d.start, !1);
|
|
1740
|
+
f && (f.userData = d, s.set(d, f), o.push(f)), d.points.forEach((p, y) => {
|
|
1725
1741
|
const x = t.projectPoint(p, !1);
|
|
1726
|
-
x && (x.userData =
|
|
1742
|
+
x && (x.userData = d, y === 0 ? i.set(d, x) : r.set(d, x));
|
|
1727
1743
|
});
|
|
1728
|
-
}), o.sort((
|
|
1729
|
-
const a = o.map((
|
|
1730
|
-
const f =
|
|
1731
|
-
for (let
|
|
1732
|
-
const
|
|
1733
|
-
if (
|
|
1734
|
-
const
|
|
1735
|
-
(x.isPointOnSegment(S) || x.isPointOnSegment(
|
|
1744
|
+
}), o.sort((d, f) => f.distance(e.start) - d.distance(e.start));
|
|
1745
|
+
const a = o.map((d) => {
|
|
1746
|
+
const f = d.userData, p = i.get(f), y = r.get(f), x = new L(p, y), g = [];
|
|
1747
|
+
for (let w = 0; w < o.length; w++) {
|
|
1748
|
+
const D = o[w];
|
|
1749
|
+
if (d !== D && d.distance(D) < n) {
|
|
1750
|
+
const m = D.userData, S = i.get(m), T = r.get(m);
|
|
1751
|
+
(x.isPointOnSegment(S) || x.isPointOnSegment(T)) && g.push(w);
|
|
1736
1752
|
}
|
|
1737
1753
|
}
|
|
1738
|
-
return
|
|
1754
|
+
return g;
|
|
1739
1755
|
});
|
|
1740
|
-
function c(
|
|
1741
|
-
if (p.has(
|
|
1742
|
-
const y = f[
|
|
1743
|
-
p.add(
|
|
1756
|
+
function c(d, f, p = /* @__PURE__ */ new Set()) {
|
|
1757
|
+
if (p.has(d)) return p;
|
|
1758
|
+
const y = f[d];
|
|
1759
|
+
p.add(d);
|
|
1744
1760
|
for (let x = 0; x < y.length; x++) {
|
|
1745
|
-
const
|
|
1746
|
-
c(
|
|
1761
|
+
const g = y[x];
|
|
1762
|
+
c(g, f, p);
|
|
1747
1763
|
}
|
|
1748
1764
|
return p;
|
|
1749
1765
|
}
|
|
1750
1766
|
const l = /* @__PURE__ */ new Set(), h = [];
|
|
1751
|
-
for (let
|
|
1752
|
-
if (l.has(
|
|
1753
|
-
const f = c(
|
|
1767
|
+
for (let d = 0; d < o.length; d++) {
|
|
1768
|
+
if (l.has(d)) continue;
|
|
1769
|
+
const f = c(d, a), p = [];
|
|
1754
1770
|
if (f.forEach((y) => {
|
|
1755
1771
|
l.add(y), p.push(o[y].userData);
|
|
1756
1772
|
}), p.length > 2) {
|
|
1757
|
-
const y = p.map((
|
|
1758
|
-
y.sort((
|
|
1759
|
-
const x = y[0],
|
|
1760
|
-
if (x.distance(
|
|
1761
|
-
const
|
|
1762
|
-
if (
|
|
1763
|
-
const
|
|
1773
|
+
const y = p.map((D) => s.get(D));
|
|
1774
|
+
y.sort((D, m) => m.distance(e.start) - D.distance(e.start));
|
|
1775
|
+
const x = y[0], g = y[y.length - 1];
|
|
1776
|
+
if (x.distance(g) > n) {
|
|
1777
|
+
const D = [...p].sort((N, j) => j.length() - N.length()), m = D[0], S = D[1], T = s.get(m), E = s.get(S), A = m.length(), v = S.length(), C = m.projectLineSegment(S), F = C.length();
|
|
1778
|
+
if (T.distance(E) || v / A > 0.5 && F / v < 0.5) {
|
|
1779
|
+
const N = [m], j = [S];
|
|
1764
1780
|
for (let O = 0; O < y.length; O++) {
|
|
1765
|
-
const
|
|
1766
|
-
if (
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1781
|
+
const R = y[O], V = R.userData;
|
|
1782
|
+
if (R === T || R === E) continue;
|
|
1783
|
+
const G = S.projectLineSegment(V), W = G.length();
|
|
1784
|
+
E.distance(R) <= n && W / v > 0 ? j.push(V) : N.push(V);
|
|
1769
1785
|
}
|
|
1770
|
-
h.push(
|
|
1786
|
+
h.push(N, j);
|
|
1771
1787
|
} else {
|
|
1772
|
-
const
|
|
1773
|
-
h.push(p.slice(0,
|
|
1788
|
+
const N = Math.floor(p.length * 0.5);
|
|
1789
|
+
h.push(p.slice(0, N), p.slice(N));
|
|
1774
1790
|
}
|
|
1775
1791
|
continue;
|
|
1776
1792
|
}
|
|
@@ -1779,7 +1795,7 @@ function xt(d, t, e, n) {
|
|
|
1779
1795
|
}
|
|
1780
1796
|
return h;
|
|
1781
1797
|
}
|
|
1782
|
-
function gt(
|
|
1798
|
+
function gt(u, t) {
|
|
1783
1799
|
function e(i, r = /* @__PURE__ */ new Set()) {
|
|
1784
1800
|
if (r.has(i)) return r;
|
|
1785
1801
|
r.add(i);
|
|
@@ -1792,148 +1808,177 @@ function gt(d, t) {
|
|
|
1792
1808
|
return r;
|
|
1793
1809
|
}
|
|
1794
1810
|
const n = /* @__PURE__ */ new Set(), s = [];
|
|
1795
|
-
for (let i = 0; i <
|
|
1796
|
-
const r =
|
|
1811
|
+
for (let i = 0; i < u.length; i++) {
|
|
1812
|
+
const r = u[i];
|
|
1797
1813
|
if (n.has(r)) continue;
|
|
1798
1814
|
const o = e(r);
|
|
1799
1815
|
s.push([...o]);
|
|
1800
1816
|
}
|
|
1801
1817
|
return s;
|
|
1802
1818
|
}
|
|
1803
|
-
function
|
|
1819
|
+
function le(u, t, e, n, s, i) {
|
|
1804
1820
|
const {
|
|
1805
1821
|
principalAxisThreshold: r = 0.3,
|
|
1806
1822
|
crossAxistThreshold: o = 0.06,
|
|
1807
1823
|
groupMethod: a = "principalAndCross"
|
|
1808
1824
|
} = i ?? {}, c = {
|
|
1809
1825
|
cross: () => [
|
|
1810
|
-
...xt(
|
|
1826
|
+
...xt(u, n, e, o),
|
|
1811
1827
|
...xt(t, e, n, o)
|
|
1812
1828
|
],
|
|
1813
1829
|
principalAndCross: () => [
|
|
1814
|
-
...yt(
|
|
1830
|
+
...yt(u, n, e, r, o),
|
|
1815
1831
|
...yt(t, e, n, r, o)
|
|
1816
1832
|
],
|
|
1817
1833
|
originalInterPoint: () => [
|
|
1818
|
-
...gt(
|
|
1834
|
+
...gt(u, s),
|
|
1819
1835
|
...gt(t, s)
|
|
1820
1836
|
]
|
|
1821
1837
|
};
|
|
1822
1838
|
return c[a] ? c[a]() : c.originalInterPoint();
|
|
1823
1839
|
}
|
|
1824
|
-
function
|
|
1840
|
+
function he(u, t) {
|
|
1825
1841
|
const e = /* @__PURE__ */ new Set();
|
|
1826
|
-
return
|
|
1842
|
+
return u.forEach((n) => {
|
|
1827
1843
|
const s = /* @__PURE__ */ new Map();
|
|
1828
1844
|
n.map((i) => {
|
|
1829
1845
|
t.get(i)?.forEach((o) => {
|
|
1830
1846
|
s.has(o.line) || s.set(o.line, []), s.get(o.line)?.push({ intersect: o, targetLine: i });
|
|
1831
1847
|
});
|
|
1832
1848
|
});
|
|
1833
|
-
for (
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
(
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
}), d.map((n) => n.filter((s) => !e.has(s)));
|
|
1849
|
+
for (const [i, r] of s)
|
|
1850
|
+
if (r.length === 2) {
|
|
1851
|
+
const o = r[0].targetLine, a = r[1].targetLine;
|
|
1852
|
+
(i.sameEndpointAsStart(o) && i.sameEndpointAsEnd(a) || i.sameEndpointAsStart(a) && i.sameEndpointAsEnd(o)) && e.add(i);
|
|
1853
|
+
}
|
|
1854
|
+
}), u.map((n) => n.filter((s) => !e.has(s)));
|
|
1840
1855
|
}
|
|
1841
|
-
function
|
|
1856
|
+
function ue(u, t = 0.1, e) {
|
|
1842
1857
|
const { fittingMethod: n = "average" } = e ?? {};
|
|
1843
|
-
return
|
|
1858
|
+
return u.map((s) => {
|
|
1844
1859
|
if (s.length === 0) return;
|
|
1845
1860
|
if (s.length === 1) return s[0];
|
|
1846
1861
|
const i = [];
|
|
1847
1862
|
s.forEach((h) => i.push(h.start.clone(), h.end.clone()));
|
|
1848
|
-
const r = n === "average" ?
|
|
1863
|
+
const r = n === "average" ? L.mergeLines(...s) : L.mergeLinesByMaxlength(...s);
|
|
1849
1864
|
r.userData.rooftopPz = Math.min(
|
|
1850
1865
|
...s.map((h) => {
|
|
1851
|
-
const { drawDoorData:
|
|
1866
|
+
const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } = h.userData;
|
|
1852
1867
|
return Object.assign(r.userData, y), p ?? 1 / 0;
|
|
1853
1868
|
})
|
|
1854
1869
|
), r.userData.rooftopPz === 1 / 0 && (r.userData.rooftopPz = 0);
|
|
1855
1870
|
let o = 1 / 0, a = -1 / 0;
|
|
1856
1871
|
const c = s[0].normal().normalize();
|
|
1857
1872
|
o = 1 / 0, a = -1 / 0, i.forEach((h) => {
|
|
1858
|
-
const
|
|
1859
|
-
o = Math.min(o,
|
|
1873
|
+
const d = h.x * c.x + h.y * c.y;
|
|
1874
|
+
o = Math.min(o, d), a = Math.max(a, d);
|
|
1860
1875
|
});
|
|
1861
1876
|
const l = a - o;
|
|
1862
1877
|
return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
|
|
1863
1878
|
}).filter((s) => !!s);
|
|
1864
1879
|
}
|
|
1865
|
-
function
|
|
1866
|
-
const e = new
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1880
|
+
function de(u, t) {
|
|
1881
|
+
const e = new k(), n = new B(P.fromByLineSegment(...u));
|
|
1882
|
+
u.forEach((i) => {
|
|
1883
|
+
i.userData.isDoor || (n.insert(i), i.points.forEach((r) => e.insert(r, i)));
|
|
1884
|
+
}), u.forEach((i) => {
|
|
1885
|
+
i.userData.isDoor || (n.insert(i), i.points.forEach((r) => e.insert(r, i)));
|
|
1886
|
+
});
|
|
1887
|
+
function s(i, r, o) {
|
|
1888
|
+
if (o.length) {
|
|
1889
|
+
const a = o.map(({ line: c }) => {
|
|
1890
|
+
if (c.userData.fittedLine && (c = c.userData.fittedLine), c.vertical(i))
|
|
1891
|
+
return c.projectPoint(r, !0);
|
|
1892
|
+
}).filter((c) => !!c).sort((c, l) => c.distance(r) - l.distance(r));
|
|
1893
|
+
a.length && (r.copy(a[0]), e.update(r), n.update(i));
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
for (let i = 0; i < u.length; i++) {
|
|
1897
|
+
const r = u[i], a = (t.get(r) ?? []).reduce((c, l) => (l.sourcePoint === r.start ? c[0].push(l) : c[1].push(l), c), [[], []]);
|
|
1898
|
+
for (let c = 0; c < r.points.length; c++) {
|
|
1899
|
+
const l = r.points[c];
|
|
1900
|
+
e.queryPoint(l, !0).length || s(r, l, a[c]);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return u;
|
|
1904
|
+
}
|
|
1905
|
+
function fe(u, t = 0.4) {
|
|
1906
|
+
const e = new B(P.fromByLineSegment(...u));
|
|
1907
|
+
u.forEach((s) => {
|
|
1908
|
+
s.userData.isDoor || e.insert(s);
|
|
1909
|
+
});
|
|
1910
|
+
const n = new L();
|
|
1911
|
+
for (let s = 0; s < u.length; s++) {
|
|
1912
|
+
const i = u[s];
|
|
1871
1913
|
if (i.userData.isAdsorbed) continue;
|
|
1872
1914
|
const r = i.direction().multiplyScalar(t), [o, a] = i.points.map((c) => {
|
|
1915
|
+
if (e.queryPoint(c).length > 1) return;
|
|
1873
1916
|
n.set(c, c), n.start.add(r), n.end.add(r.multiplyScalar(-1));
|
|
1874
|
-
const l = /* @__PURE__ */ new Map(), h = e.queryLineSegment(n).filter((
|
|
1875
|
-
const f =
|
|
1876
|
-
return l.set(
|
|
1877
|
-
}).sort((
|
|
1878
|
-
const p = l.get(
|
|
1917
|
+
const l = /* @__PURE__ */ new Map(), h = e.queryLineSegment(n).filter((d) => d.line !== i).map((d) => {
|
|
1918
|
+
const f = d.line.getIntersection(n);
|
|
1919
|
+
return l.set(d.line, f), d.line;
|
|
1920
|
+
}).sort((d, f) => {
|
|
1921
|
+
const p = l.get(d), y = l.get(f);
|
|
1879
1922
|
return p && y ? p.distance(c) - y.distance(c) : 0;
|
|
1880
1923
|
});
|
|
1881
1924
|
return h.length ? l.get(h[0]) : void 0;
|
|
1882
1925
|
});
|
|
1883
|
-
if (o
|
|
1884
|
-
if (o
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1926
|
+
if (o || o) {
|
|
1927
|
+
if (o && a) {
|
|
1928
|
+
if (o.equal(a)) {
|
|
1929
|
+
const c = i.start.distance(o), l = i.end.distance(a);
|
|
1930
|
+
c < l ? i.directionMove(i.end.direction(i.start), c) : i.directionMove(i.start.direction(i.end), l);
|
|
1931
|
+
} else
|
|
1932
|
+
i.start.copy(o), i.end.copy(a);
|
|
1933
|
+
i.userData.isAdsorbed = !0;
|
|
1934
|
+
} else o ? i.start.copy(o) : a && i.end.copy(a);
|
|
1935
|
+
e.update(i);
|
|
1936
|
+
}
|
|
1892
1937
|
}
|
|
1893
|
-
return
|
|
1938
|
+
return u;
|
|
1894
1939
|
}
|
|
1895
|
-
function
|
|
1896
|
-
const e = new
|
|
1897
|
-
|
|
1940
|
+
function pe(u, t) {
|
|
1941
|
+
const e = new k(), n = new B(P.fromByLineSegment(...u));
|
|
1942
|
+
u.forEach((r) => {
|
|
1898
1943
|
r.userData.isDoor || (n.insert(r), r.points.forEach((o) => e.insert(o, r)));
|
|
1899
1944
|
});
|
|
1900
1945
|
const s = /* @__PURE__ */ new Map();
|
|
1901
1946
|
function i(r, o) {
|
|
1902
1947
|
s.has(r) || s.set(r, []), s.get(r)?.push(o);
|
|
1903
1948
|
}
|
|
1904
|
-
for (let r = 0; r <
|
|
1905
|
-
const o =
|
|
1949
|
+
for (let r = 0; r < u.length; r++) {
|
|
1950
|
+
const o = u[r];
|
|
1906
1951
|
o.points.forEach((a) => {
|
|
1907
1952
|
if (e.queryPoint(a).filter((f) => f.userData !== o).length !== 0 || n.queryCircle(a, 1e-3).filter((f) => f.line !== o).length > 0) return;
|
|
1908
1953
|
const l = e.queryCircle(a, t).filter((f) => f.userData !== o && f.userData?.vertical(o)).sort((f, p) => f.point.distance(a) - p.point.distance(a));
|
|
1909
1954
|
if (!l.length) return;
|
|
1910
|
-
const h = l[0],
|
|
1911
|
-
if (
|
|
1955
|
+
const h = l[0], d = h.userData?.projectPoint(a, !1);
|
|
1956
|
+
if (d) {
|
|
1912
1957
|
const f = h.userData;
|
|
1913
|
-
i(o, new
|
|
1958
|
+
i(o, new L(a.clone(), d.clone())), i(f, new L(h.point.clone(), d.clone()));
|
|
1914
1959
|
}
|
|
1915
1960
|
});
|
|
1916
1961
|
}
|
|
1917
1962
|
return s.forEach((r, o) => {
|
|
1918
|
-
const a =
|
|
1963
|
+
const a = L.mergeLines(o, ...r);
|
|
1919
1964
|
o.set(a.start, a.end);
|
|
1920
|
-
}),
|
|
1965
|
+
}), u;
|
|
1921
1966
|
}
|
|
1922
|
-
function
|
|
1923
|
-
const { snapThreshold:
|
|
1924
|
-
return
|
|
1967
|
+
function ye(u, t, e) {
|
|
1968
|
+
const { snapThreshold: n = 0.2 } = e ?? {};
|
|
1969
|
+
return u = de(u, t), u = fe(u, n), u = pe(u, n), u;
|
|
1925
1970
|
}
|
|
1926
|
-
function
|
|
1971
|
+
function xe(u) {
|
|
1927
1972
|
const t = /* @__PURE__ */ new Set();
|
|
1928
|
-
for (let e = 0; e <
|
|
1929
|
-
const n =
|
|
1930
|
-
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) :
|
|
1973
|
+
for (let e = 0; e < u.length; e++) {
|
|
1974
|
+
const n = u[e], s = n.userData.fittedLine;
|
|
1975
|
+
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : nt(n);
|
|
1931
1976
|
}
|
|
1932
|
-
t.forEach((e) =>
|
|
1977
|
+
t.forEach((e) => nt(e));
|
|
1933
1978
|
}
|
|
1934
|
-
function
|
|
1935
|
-
for (let t = 0; t <
|
|
1936
|
-
const e =
|
|
1979
|
+
function ge(u) {
|
|
1980
|
+
for (let t = 0; t < u.length; t++) {
|
|
1981
|
+
const e = u[t];
|
|
1937
1982
|
let { endIntersection: n, startIntersection: s } = e.userData;
|
|
1938
1983
|
if (!(!n || !s)) {
|
|
1939
1984
|
if (s.userData.fittedLine && (s = s.userData.fittedLine), n.userData.fittedLine && (n = n.userData.fittedLine), e.parallel(s))
|
|
@@ -1950,11 +1995,11 @@ function pe(d) {
|
|
|
1950
1995
|
}
|
|
1951
1996
|
}
|
|
1952
1997
|
}
|
|
1953
|
-
return
|
|
1998
|
+
return u;
|
|
1954
1999
|
}
|
|
1955
|
-
function
|
|
1956
|
-
const e = new
|
|
1957
|
-
return
|
|
2000
|
+
function me(u, t = 0.01) {
|
|
2001
|
+
const e = new k();
|
|
2002
|
+
return u.forEach((n) => n.points.forEach((s) => e.insert(s, n))), u.filter((n) => {
|
|
1958
2003
|
if (n.length() <= t) {
|
|
1959
2004
|
const s = e.queryPoint(n.start).filter((r) => r.userData !== n).length === 0, i = e.queryPoint(n.end).filter((r) => r.userData !== n).length === 0;
|
|
1960
2005
|
if (s || i) return !1;
|
|
@@ -1962,7 +2007,7 @@ function ye(d, t = 0.01) {
|
|
|
1962
2007
|
return !0;
|
|
1963
2008
|
});
|
|
1964
2009
|
}
|
|
1965
|
-
class
|
|
2010
|
+
class It {
|
|
1966
2011
|
/**
|
|
1967
2012
|
* 轴对齐垂直修正
|
|
1968
2013
|
* @param lines 待调整线段组
|
|
@@ -1970,39 +2015,39 @@ class Pt {
|
|
|
1970
2015
|
* @returns
|
|
1971
2016
|
*/
|
|
1972
2017
|
static correction(t, e, n) {
|
|
1973
|
-
t =
|
|
1974
|
-
const s =
|
|
2018
|
+
t = oe(t.map((x) => x.clone()));
|
|
2019
|
+
const s = ae(t), { parallelLines: i, verticalLines: r, doorLines: o, windowLines: a } = ce(e, t, s, 25), c = e.normal(), l = e.center, h = e.direction(), d = new L(
|
|
1975
2020
|
l.clone().add(c.clone().multiplyScalar(-1e3)),
|
|
1976
2021
|
l.clone().add(c.clone().multiplyScalar(1e3))
|
|
1977
|
-
), f = new
|
|
2022
|
+
), f = new L(
|
|
1978
2023
|
l.clone().add(h.clone().multiplyScalar(-1e3)),
|
|
1979
2024
|
l.clone().add(h.clone().multiplyScalar(1e3))
|
|
1980
2025
|
);
|
|
1981
|
-
let p =
|
|
1982
|
-
p =
|
|
1983
|
-
let y =
|
|
1984
|
-
return y =
|
|
2026
|
+
let p = le(i, r, d, f, s, n);
|
|
2027
|
+
p = he(p, s);
|
|
2028
|
+
let y = ue(p, 0.1, n);
|
|
2029
|
+
return y = ye(y, s, n), xe(a), ge(o), y = et(y, 1e-9), y.push(...o), y = me(y, 0.15), y = y, y = L.autoMergeLines(y).lines, y = et(y, 1e-9), y;
|
|
1985
2030
|
}
|
|
1986
2031
|
}
|
|
1987
|
-
const
|
|
2032
|
+
const we = new L(
|
|
1988
2033
|
new M(0, 0),
|
|
1989
2034
|
new M(0, 1)
|
|
1990
2035
|
);
|
|
1991
|
-
function
|
|
1992
|
-
const t = [...
|
|
1993
|
-
let r = parseInt(
|
|
2036
|
+
function Me(u) {
|
|
2037
|
+
const t = [...u].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
|
|
2038
|
+
let r = parseInt(we.includedAngle(i) + "");
|
|
1994
2039
|
return r > 90 && (r = 180 - r), r;
|
|
1995
2040
|
}), n = /* @__PURE__ */ new Map();
|
|
1996
2041
|
return e.forEach((i, r) => {
|
|
1997
2042
|
n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
|
|
1998
2043
|
}), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
|
|
1999
2044
|
}
|
|
2000
|
-
function
|
|
2045
|
+
function Se(u) {
|
|
2001
2046
|
let t = [], e = -1;
|
|
2002
2047
|
const n = [];
|
|
2003
|
-
return
|
|
2048
|
+
return u.forEach(({ start: i, end: r, ...o }, a) => {
|
|
2004
2049
|
n.push(i.z ?? 0, r.z ?? 0);
|
|
2005
|
-
const c = new
|
|
2050
|
+
const c = new L(
|
|
2006
2051
|
M.from(i),
|
|
2007
2052
|
M.from(r)
|
|
2008
2053
|
);
|
|
@@ -2013,7 +2058,7 @@ function me(d) {
|
|
|
2013
2058
|
verticalReferenceIndex: e
|
|
2014
2059
|
};
|
|
2015
2060
|
}
|
|
2016
|
-
const
|
|
2061
|
+
const De = {
|
|
2017
2062
|
Unitless: 1,
|
|
2018
2063
|
// 无单位,1米 = 1(无单位)
|
|
2019
2064
|
Inches: 39.37007874015748,
|
|
@@ -2057,27 +2102,27 @@ const we = {
|
|
|
2057
2102
|
Parsecs: 3240779289666404e-32
|
|
2058
2103
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
2059
2104
|
};
|
|
2060
|
-
function
|
|
2105
|
+
function mt(u) {
|
|
2061
2106
|
const t = [];
|
|
2062
|
-
for (let e = 0; e <
|
|
2063
|
-
t.push(new
|
|
2064
|
-
|
|
2065
|
-
|
|
2107
|
+
for (let e = 0; e < u.length; e++)
|
|
2108
|
+
t.push(new L(
|
|
2109
|
+
u[e].clone(),
|
|
2110
|
+
u[(e + 1) % u.length].clone()
|
|
2066
2111
|
));
|
|
2067
2112
|
return t;
|
|
2068
2113
|
}
|
|
2069
|
-
function
|
|
2070
|
-
return
|
|
2114
|
+
function wt(u) {
|
|
2115
|
+
return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
|
|
2071
2116
|
}
|
|
2072
|
-
class
|
|
2117
|
+
class Y extends z {
|
|
2073
2118
|
static name = "Dxf";
|
|
2074
2119
|
shortLine = 0.04;
|
|
2075
2120
|
width = 0.04;
|
|
2076
2121
|
scale = 1;
|
|
2077
2122
|
originalData = [];
|
|
2078
2123
|
data = [];
|
|
2079
|
-
originalBox = new
|
|
2080
|
-
box = new
|
|
2124
|
+
originalBox = new P(0, 0, 0, 0);
|
|
2125
|
+
box = new P(0, 0, 0, 0);
|
|
2081
2126
|
pointsGroups = [];
|
|
2082
2127
|
wallsGroup = [];
|
|
2083
2128
|
doors = [];
|
|
@@ -2114,9 +2159,9 @@ class k extends _ {
|
|
|
2114
2159
|
* @param data
|
|
2115
2160
|
*/
|
|
2116
2161
|
preprocessing(t) {
|
|
2117
|
-
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } =
|
|
2162
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = Se(t);
|
|
2118
2163
|
if (this.originalZAverage = s, n === -1) {
|
|
2119
|
-
const r =
|
|
2164
|
+
const r = Me(e);
|
|
2120
2165
|
n = e.indexOf(r);
|
|
2121
2166
|
}
|
|
2122
2167
|
const i = e[n];
|
|
@@ -2125,7 +2170,7 @@ class k extends _ {
|
|
|
2125
2170
|
data: t,
|
|
2126
2171
|
setData(r) {
|
|
2127
2172
|
e = r.map(({ start: o, end: a, ...c }) => {
|
|
2128
|
-
const l = new
|
|
2173
|
+
const l = new L(M.from(o), M.from(a));
|
|
2129
2174
|
return l.userData = c, l;
|
|
2130
2175
|
}), t = r;
|
|
2131
2176
|
}
|
|
@@ -2182,8 +2227,8 @@ class k extends _ {
|
|
|
2182
2227
|
createGroups() {
|
|
2183
2228
|
const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
|
|
2184
2229
|
if (!this.data[r]) return;
|
|
2185
|
-
const [c, l, h,
|
|
2186
|
-
if (e.add(r),
|
|
2230
|
+
const [c, l, h, d] = this.data[r];
|
|
2231
|
+
if (e.add(r), d)
|
|
2187
2232
|
return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
|
|
2188
2233
|
o.push([c, l]), h.forEach((f) => {
|
|
2189
2234
|
e.has(f) || i(f, o, r);
|
|
@@ -2278,7 +2323,7 @@ class k extends _ {
|
|
|
2278
2323
|
break;
|
|
2279
2324
|
}
|
|
2280
2325
|
}
|
|
2281
|
-
const e = this.mergeSameDirectionLine(
|
|
2326
|
+
const e = this.mergeSameDirectionLine(mt(t)), n = [e[0]];
|
|
2282
2327
|
for (let s = 1; s < e.length; s++) {
|
|
2283
2328
|
const i = e[s], r = e[(e.length + s - 1) % e.length];
|
|
2284
2329
|
if (i.length() > this.width * 0.9) {
|
|
@@ -2293,7 +2338,7 @@ class k extends _ {
|
|
|
2293
2338
|
const a = e[s + 2];
|
|
2294
2339
|
a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
|
|
2295
2340
|
}
|
|
2296
|
-
return n.length > 3 ?
|
|
2341
|
+
return n.length > 3 ? wt(this.mergeSameDirectionLine(n)) : [];
|
|
2297
2342
|
}
|
|
2298
2343
|
/**
|
|
2299
2344
|
* 移除短线段
|
|
@@ -2301,7 +2346,7 @@ class k extends _ {
|
|
|
2301
2346
|
* @param path
|
|
2302
2347
|
*/
|
|
2303
2348
|
removeShortLine(t, e = this.shortLine) {
|
|
2304
|
-
const n =
|
|
2349
|
+
const n = mt(t), s = [], i = Math.PI / 180;
|
|
2305
2350
|
for (let r = 0; r < n.length; r++) {
|
|
2306
2351
|
const o = n[r], a = o.length(), c = r;
|
|
2307
2352
|
if (a > e || s.length === 0) {
|
|
@@ -2309,9 +2354,9 @@ class k extends _ {
|
|
|
2309
2354
|
continue;
|
|
2310
2355
|
}
|
|
2311
2356
|
let l = n[++r];
|
|
2312
|
-
const h = s[s.length - 1],
|
|
2357
|
+
const h = s[s.length - 1], d = h.direction();
|
|
2313
2358
|
for (; r < n.length; ) {
|
|
2314
|
-
const p =
|
|
2359
|
+
const p = d.angleBetween(l.direction()) / i;
|
|
2315
2360
|
if (l.length() <= e || p < 4 || p > 176)
|
|
2316
2361
|
l = n[++r];
|
|
2317
2362
|
else break;
|
|
@@ -2329,12 +2374,12 @@ class k extends _ {
|
|
|
2329
2374
|
} else
|
|
2330
2375
|
r = c;
|
|
2331
2376
|
}
|
|
2332
|
-
return s.length > 3 ?
|
|
2377
|
+
return s.length > 3 ? wt(s) : [];
|
|
2333
2378
|
}
|
|
2334
2379
|
/** 线偏移
|
|
2335
2380
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
2336
2381
|
*/
|
|
2337
|
-
lineOffset(t =
|
|
2382
|
+
lineOffset(t = Y.EndType.etOpenSquare, e = Y.JoinType.jtMiter, n = 1e4) {
|
|
2338
2383
|
let s = new pt.Paths();
|
|
2339
2384
|
const i = new pt.ClipperOffset(20, 0.25);
|
|
2340
2385
|
return this.pointsGroups.forEach((r) => {
|
|
@@ -2342,7 +2387,7 @@ class k extends _ {
|
|
|
2342
2387
|
i.AddPaths(o, e, t);
|
|
2343
2388
|
}), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
|
|
2344
2389
|
let o = r.map((a) => M.from(a).divisionScalar(n));
|
|
2345
|
-
return o = this.lineSegmentStraightening(o), t ==
|
|
2390
|
+
return o = this.lineSegmentStraightening(o), t == Y.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
|
|
2346
2391
|
}), this.dispatchEvent({
|
|
2347
2392
|
type: "lineOffset",
|
|
2348
2393
|
wallsGroup: this.wallsGroup
|
|
@@ -2354,7 +2399,7 @@ class k extends _ {
|
|
|
2354
2399
|
axisAlignCorr(t) {
|
|
2355
2400
|
if (this.verticalReferenceLine) {
|
|
2356
2401
|
this.doorLineSegment;
|
|
2357
|
-
const e =
|
|
2402
|
+
const e = It.correction(this.getLineSegments(), this.verticalReferenceLine, t), n = J(e);
|
|
2358
2403
|
this.set(n);
|
|
2359
2404
|
} else
|
|
2360
2405
|
throw new Error("未找到一条垂直纠正基准轴线");
|
|
@@ -2404,7 +2449,7 @@ class k extends _ {
|
|
|
2404
2449
|
* 转为绘制数据
|
|
2405
2450
|
*/
|
|
2406
2451
|
toDrawDataJson(t = "Millimeters") {
|
|
2407
|
-
const e =
|
|
2452
|
+
const e = De[t], n = {
|
|
2408
2453
|
unit: t,
|
|
2409
2454
|
line: [],
|
|
2410
2455
|
arc: [],
|
|
@@ -2418,13 +2463,13 @@ class k extends _ {
|
|
|
2418
2463
|
function i(c, l) {
|
|
2419
2464
|
n.line.push([c.x * e, c.y * e, l.x * e, l.y * e, s]);
|
|
2420
2465
|
}
|
|
2421
|
-
function r(c, l, h,
|
|
2466
|
+
function r(c, l, h, d) {
|
|
2422
2467
|
n.arc.push([
|
|
2423
2468
|
c.x * e,
|
|
2424
2469
|
c.y * e,
|
|
2425
2470
|
l * e,
|
|
2426
2471
|
h,
|
|
2427
|
-
|
|
2472
|
+
d,
|
|
2428
2473
|
s
|
|
2429
2474
|
]);
|
|
2430
2475
|
}
|
|
@@ -2437,7 +2482,7 @@ class k extends _ {
|
|
|
2437
2482
|
}
|
|
2438
2483
|
this.wallsGroup.forEach((c) => {
|
|
2439
2484
|
for (let l = 0; l < c.length; l++) {
|
|
2440
|
-
const h = c[l],
|
|
2485
|
+
const h = c[l], d = l === c.length - 1 ? 0 : l + 1, f = c[d];
|
|
2441
2486
|
i(h, f);
|
|
2442
2487
|
}
|
|
2443
2488
|
});
|
|
@@ -2448,29 +2493,29 @@ class k extends _ {
|
|
|
2448
2493
|
if (s = "cyan", l.length() < 1.2) {
|
|
2449
2494
|
l.expansion(-o * 0.5);
|
|
2450
2495
|
const h = c.normal();
|
|
2451
|
-
let
|
|
2496
|
+
let d = new L(
|
|
2452
2497
|
l.start.clone(),
|
|
2453
2498
|
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2454
2499
|
);
|
|
2455
|
-
const f =
|
|
2456
|
-
for (let
|
|
2457
|
-
if (a[
|
|
2458
|
-
|
|
2500
|
+
const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
2501
|
+
for (let m = 0; m < a.length; m++)
|
|
2502
|
+
if (a[m].intersectRectangle(f)) {
|
|
2503
|
+
d = new L(
|
|
2459
2504
|
l.start.clone(),
|
|
2460
2505
|
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2461
2506
|
);
|
|
2462
2507
|
break;
|
|
2463
2508
|
}
|
|
2464
|
-
|
|
2465
|
-
const p = l.length(), y =
|
|
2466
|
-
r(
|
|
2509
|
+
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((m, S) => i(m, S));
|
|
2510
|
+
const p = l.length(), y = d.length(), x = (p ** 2 + y ** 2) / (2 * y), g = d.end.clone().add(d.direction().multiplyScalar(-x)), [w, D] = this.getArcAngleRange(g, l.end, d.end);
|
|
2511
|
+
r(g, x, Math.min(w, D), Math.max(w, D)), a.push(f);
|
|
2467
2512
|
} else
|
|
2468
|
-
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h,
|
|
2513
|
+
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
|
|
2469
2514
|
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
2470
2515
|
if (!c.userData.isWindow) return !1;
|
|
2471
2516
|
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
2472
|
-
const { p: h, width:
|
|
2473
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((
|
|
2517
|
+
const { p: h, width: d } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), x = new L(p, y);
|
|
2518
|
+
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((g, w) => i(g, w));
|
|
2474
2519
|
});
|
|
2475
2520
|
}), n;
|
|
2476
2521
|
}
|
|
@@ -2484,7 +2529,7 @@ class k extends _ {
|
|
|
2484
2529
|
if (typeof window < "u")
|
|
2485
2530
|
i = document.createElement("canvas");
|
|
2486
2531
|
else if (typeof global < "u") {
|
|
2487
|
-
const { createCanvas: c } = await
|
|
2532
|
+
const { createCanvas: c } = await X("canvas");
|
|
2488
2533
|
i = c();
|
|
2489
2534
|
} else
|
|
2490
2535
|
throw new Error("创建画布失败");
|
|
@@ -2495,14 +2540,14 @@ class k extends _ {
|
|
|
2495
2540
|
};
|
|
2496
2541
|
i.width = s.width + r * 2, i.height = s.height + r * 2;
|
|
2497
2542
|
const a = i.getContext("2d");
|
|
2498
|
-
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h,
|
|
2499
|
-
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h,
|
|
2500
|
-
}), s.arc.forEach(([c, l, h,
|
|
2501
|
-
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h,
|
|
2543
|
+
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, d, f]) => {
|
|
2544
|
+
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h, d), a.closePath(), a.stroke();
|
|
2545
|
+
}), s.arc.forEach(([c, l, h, d, f, p]) => {
|
|
2546
|
+
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
|
|
2502
2547
|
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
2503
|
-
let [l, h,
|
|
2504
|
-
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1),
|
|
2505
|
-
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,
|
|
2548
|
+
let [l, h, d, f] = c;
|
|
2549
|
+
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), g = (y - p) * 0.45;
|
|
2550
|
+
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, g + p), a.moveTo(x, y), a.lineTo(x, y - g), a.moveTo(x - 0.1 * s.scale, y), a.lineTo(x + 0.1 * s.scale, y);
|
|
2506
2551
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
2507
2552
|
i.toBlob((l) => {
|
|
2508
2553
|
c(l);
|
|
@@ -2513,8 +2558,8 @@ class k extends _ {
|
|
|
2513
2558
|
* 将点json结构转换为Dxf string
|
|
2514
2559
|
*/
|
|
2515
2560
|
toDxfString(t = "Millimeters") {
|
|
2516
|
-
const e = new
|
|
2517
|
-
e.setUnits(t), e.addLayer("cyan",
|
|
2561
|
+
const e = new K();
|
|
2562
|
+
e.setUnits(t), e.addLayer("cyan", K.ACI.CYAN, "DOTTED"), e.addLayer("yellow", K.ACI.YELLOW, "DOTTED"), e.addLayer("white", K.ACI.WHITE, "DOTTED");
|
|
2518
2563
|
const n = this.toDrawDataJson();
|
|
2519
2564
|
return n.line.forEach((s) => {
|
|
2520
2565
|
let [i, r, o, a, c] = s;
|
|
@@ -2540,7 +2585,7 @@ class k extends _ {
|
|
|
2540
2585
|
if (typeof window < "u") {
|
|
2541
2586
|
const n = new Blob([e], { type: "application/json" }), s = document.createElement("a");
|
|
2542
2587
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
2543
|
-
} else typeof global < "u" && (await
|
|
2588
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, e);
|
|
2544
2589
|
}
|
|
2545
2590
|
/**
|
|
2546
2591
|
* 下载
|
|
@@ -2550,7 +2595,7 @@ class k extends _ {
|
|
|
2550
2595
|
if (typeof window < "u") {
|
|
2551
2596
|
const n = this.toDxfBlob(e), s = document.createElement("a");
|
|
2552
2597
|
s.href = URL.createObjectURL(n), s.download = t + ".dxf", s.click();
|
|
2553
|
-
} else typeof global < "u" && (await
|
|
2598
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, this.toDxfString(e));
|
|
2554
2599
|
}
|
|
2555
2600
|
/**
|
|
2556
2601
|
* 下载
|
|
@@ -2562,7 +2607,7 @@ class k extends _ {
|
|
|
2562
2607
|
if (typeof window < "u") {
|
|
2563
2608
|
const i = document.createElement("a");
|
|
2564
2609
|
i.href = URL.createObjectURL(s), i.download = t, i.click();
|
|
2565
|
-
} else typeof global < "u" ? (await
|
|
2610
|
+
} else typeof global < "u" ? (await X("fs", !1)).writeFileSync(t, s) : console.error("图片下载失败");
|
|
2566
2611
|
return !0;
|
|
2567
2612
|
}
|
|
2568
2613
|
/**
|
|
@@ -2570,7 +2615,7 @@ class k extends _ {
|
|
|
2570
2615
|
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
2571
2616
|
* @returns
|
|
2572
2617
|
*/
|
|
2573
|
-
computedOriginalSize(t, e = new
|
|
2618
|
+
computedOriginalSize(t, e = new P(0, 0, 0, 0)) {
|
|
2574
2619
|
const n = t.flatMap((c) => [c.start.x, c.end.x]), s = t.flatMap((c) => [c.start.y, c.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
|
|
2575
2620
|
return e.set(i, r, o, a), e;
|
|
2576
2621
|
}
|
|
@@ -2598,44 +2643,44 @@ class k extends _ {
|
|
|
2598
2643
|
});
|
|
2599
2644
|
}
|
|
2600
2645
|
}
|
|
2601
|
-
function
|
|
2602
|
-
if (
|
|
2603
|
-
if (
|
|
2604
|
-
if (Array.isArray(
|
|
2646
|
+
function ht(u) {
|
|
2647
|
+
if (u === null || typeof u != "object") return u;
|
|
2648
|
+
if (u instanceof Date) return new Date(u.getTime());
|
|
2649
|
+
if (Array.isArray(u)) return u.map(ht);
|
|
2605
2650
|
const t = {};
|
|
2606
|
-
for (const e in
|
|
2607
|
-
Object.prototype.hasOwnProperty.call(
|
|
2651
|
+
for (const e in u)
|
|
2652
|
+
Object.prototype.hasOwnProperty.call(u, e) && (t[e] = ht(u[e]));
|
|
2608
2653
|
return t;
|
|
2609
2654
|
}
|
|
2610
|
-
const
|
|
2611
|
-
class
|
|
2655
|
+
const q = new L();
|
|
2656
|
+
class Le extends Y {
|
|
2612
2657
|
static name = "AngleCorrectionDxf";
|
|
2613
2658
|
angle = 0;
|
|
2614
2659
|
onAddFromParent(t) {
|
|
2615
|
-
t.
|
|
2660
|
+
t.DoorsAnalysis.addEventListener("analysisCompleted", async () => this.update());
|
|
2616
2661
|
}
|
|
2617
2662
|
async update() {
|
|
2618
2663
|
const t = this.parent, e = t.findComponentByName("Dxf"), n = t.findComponentByName("LineAnalysis");
|
|
2619
2664
|
let s = 0, i = null;
|
|
2620
2665
|
for (let c = 0; c < e.originalData.length; c++) {
|
|
2621
2666
|
const l = e.originalData[c];
|
|
2622
|
-
if (
|
|
2623
|
-
const [h,
|
|
2624
|
-
s = -new
|
|
2667
|
+
if (q.start.copy(l.start), q.end.copy(l.end), l.isVerticalReferenceLine) {
|
|
2668
|
+
const [h, d] = l.start.y < l.end.y ? [q.start, q.end] : [q.end, q.start];
|
|
2669
|
+
s = -new L(h, d).direction().angleBetween(new M(0, 1), "angle", "360"), i = null;
|
|
2625
2670
|
break;
|
|
2626
2671
|
}
|
|
2627
|
-
(!i ||
|
|
2672
|
+
(!i || q.length() > i.length()) && (i = q.clone(), i.userData.index = c);
|
|
2628
2673
|
}
|
|
2629
2674
|
if (i) {
|
|
2630
2675
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
2631
2676
|
const [c, l] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
|
|
2632
|
-
s = -new
|
|
2677
|
+
s = -new L(c, l).direction().angleBetween(new M(0, 1), "angle", "360");
|
|
2633
2678
|
}
|
|
2634
2679
|
const r = e.originalBox.center, o = M.zero(), a = e.originalData.map((c) => {
|
|
2635
|
-
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z),
|
|
2636
|
-
return
|
|
2680
|
+
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(ht(c), { start: l, end: h });
|
|
2681
|
+
return d.drawWindow && d.drawWindow.forEach((f) => {
|
|
2637
2682
|
f.p = o.copy(f.p).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(f.p.z);
|
|
2638
|
-
}),
|
|
2683
|
+
}), d;
|
|
2639
2684
|
});
|
|
2640
2685
|
n.appendLineSegmentList.forEach((c) => {
|
|
2641
2686
|
const l = c.clone();
|
|
@@ -2653,7 +2698,7 @@ class Me extends k {
|
|
|
2653
2698
|
});
|
|
2654
2699
|
}
|
|
2655
2700
|
}
|
|
2656
|
-
class
|
|
2701
|
+
class Pt extends z {
|
|
2657
2702
|
static name = "Variable";
|
|
2658
2703
|
originalLineVisible = !0;
|
|
2659
2704
|
dxfVisible = !0;
|
|
@@ -2680,14 +2725,166 @@ class Rt extends _ {
|
|
|
2680
2725
|
if (t in this) return this[t];
|
|
2681
2726
|
}
|
|
2682
2727
|
}
|
|
2683
|
-
class
|
|
2728
|
+
class Rt extends z {
|
|
2729
|
+
static name = "LineAnalysis";
|
|
2730
|
+
Dxf = null;
|
|
2731
|
+
Variable = null;
|
|
2732
|
+
lineSegmentList = [];
|
|
2733
|
+
container = new I.Group();
|
|
2734
|
+
// 误差角度
|
|
2735
|
+
errorAngle = 4;
|
|
2736
|
+
width = 0.4;
|
|
2737
|
+
/**
|
|
2738
|
+
*
|
|
2739
|
+
* @param parent
|
|
2740
|
+
*/
|
|
2741
|
+
onAddFromParent(t) {
|
|
2742
|
+
this.Dxf = t.findComponentByType(Y), this.Variable = this.parent?.findComponentByType(Pt), this.Dxf.addEventListener("setDta", () => {
|
|
2743
|
+
this.lineAnalysis(), this.dispatchEvent({ type: "analysisCompleted" });
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
*
|
|
2748
|
+
* @param p1
|
|
2749
|
+
* @param p2
|
|
2750
|
+
* @param width
|
|
2751
|
+
* @returns
|
|
2752
|
+
*/
|
|
2753
|
+
expandLineSegment(t, e, n = 0.1) {
|
|
2754
|
+
const s = e.normal(t), i = e.direction(t).mutiplyScalar(n * 0.5), r = t.direction(e).mutiplyScalar(n * 0.5), o = s.x * n * 0.5, a = s.y * n * 0.5;
|
|
2755
|
+
return {
|
|
2756
|
+
points: [
|
|
2757
|
+
// 第一条线
|
|
2758
|
+
new M(t.x + o, t.y + a).add(r),
|
|
2759
|
+
new M(e.x + o, e.y + a).add(i),
|
|
2760
|
+
// 第二条线
|
|
2761
|
+
new M(t.x - o, t.y - a).add(r),
|
|
2762
|
+
new M(e.x - o, e.y - a).add(i)
|
|
2763
|
+
],
|
|
2764
|
+
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
2765
|
+
rectIndices: [0, 1, 3, 2, 0]
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
appendLineSegmentList = [];
|
|
2769
|
+
/**
|
|
2770
|
+
* 追加数据
|
|
2771
|
+
* @param p1
|
|
2772
|
+
* @param p2
|
|
2773
|
+
*/
|
|
2774
|
+
addData(t, e) {
|
|
2775
|
+
const n = this.Dxf;
|
|
2776
|
+
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new L(t.clone(), e.clone()));
|
|
2777
|
+
}
|
|
2778
|
+
/** 结果分析创建矩形
|
|
2779
|
+
* @param result
|
|
2780
|
+
*/
|
|
2781
|
+
createRectangle(t) {
|
|
2782
|
+
const e = this.Dxf, n = t.project, s = t.project2;
|
|
2783
|
+
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]);
|
|
2784
|
+
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(d);
|
|
2785
|
+
p.multiplyScalar(e.width * 0.5);
|
|
2786
|
+
const y = d.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), g = d.direction(f), w = y.direction(x);
|
|
2787
|
+
if (!(g.x > 0 && w.x < 0 || g.x < 0 && w.x > 0 || g.y > 0 && w.y < 0 || g.y < 0 && w.y > 0)) {
|
|
2788
|
+
d.set(y.x, y.y), f.set(x.x, x.y);
|
|
2789
|
+
for (let D = 1; D < o; D++) {
|
|
2790
|
+
const m = l.clone().multiplyScalar(a * D), S = h.clone().multiplyScalar(c * D), T = d.clone().add(m), E = f.clone().add(S);
|
|
2791
|
+
this.addData(T, E);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
quadtree;
|
|
2796
|
+
/**
|
|
2797
|
+
* 构建线段四叉树,快速查找,
|
|
2798
|
+
*/
|
|
2799
|
+
buildQuadtree() {
|
|
2800
|
+
const t = this.Dxf, e = [];
|
|
2801
|
+
this.quadtree = new B(t.originalBox, 2), t.lineSegments.forEach((n) => {
|
|
2802
|
+
n.userData?.isDoor || (this.quadtree?.insert({
|
|
2803
|
+
line: n,
|
|
2804
|
+
userData: e.length
|
|
2805
|
+
}), e.push(n));
|
|
2806
|
+
}), this.lineSegmentList = e;
|
|
2807
|
+
}
|
|
2808
|
+
resultList = [];
|
|
2809
|
+
mergeWallLines = [];
|
|
2810
|
+
/** 线段分析
|
|
2811
|
+
* @description 判断两条线段距离是否较短且趋近平行,然后查找两条线段的重合部分的投影线,以此判断两根线是否需要合并
|
|
2812
|
+
* @param data
|
|
2813
|
+
*/
|
|
2814
|
+
lineAnalysis() {
|
|
2815
|
+
this.buildQuadtree();
|
|
2816
|
+
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
2817
|
+
e.forEach((i, r) => {
|
|
2818
|
+
const o = e[r], a = it.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
2819
|
+
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
2820
|
+
try {
|
|
2821
|
+
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
2822
|
+
const h = this.projectionAnalysis(l, r, o, e);
|
|
2823
|
+
h && s.push(h), n.add(`${r}-${l}`);
|
|
2824
|
+
} catch {
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
}), this.appendLineSegmentList.length = 0, s.forEach(this.createRectangle.bind(this)), this.resultList = s;
|
|
2828
|
+
}
|
|
2829
|
+
/** 线段投影分析
|
|
2830
|
+
* @param index
|
|
2831
|
+
* @param sourceLineSegment
|
|
2832
|
+
* @param lineSegmentList
|
|
2833
|
+
* @returns
|
|
2834
|
+
*/
|
|
2835
|
+
projectionAnalysis(t, e, n, s) {
|
|
2836
|
+
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
2837
|
+
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
2838
|
+
let c;
|
|
2839
|
+
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
2840
|
+
return l.getLength() > h.getLength() ? c = {
|
|
2841
|
+
target: i,
|
|
2842
|
+
targetIndex: t,
|
|
2843
|
+
source: n,
|
|
2844
|
+
sourceIndex: e,
|
|
2845
|
+
project: l,
|
|
2846
|
+
project2: h
|
|
2847
|
+
} : c = {
|
|
2848
|
+
target: n,
|
|
2849
|
+
targetIndex: e,
|
|
2850
|
+
source: i,
|
|
2851
|
+
sourceIndex: t,
|
|
2852
|
+
project: h,
|
|
2853
|
+
project2: l
|
|
2854
|
+
}, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
function vt(u, t, e = 1e-3) {
|
|
2859
|
+
if (Array.isArray(u) && u[0] instanceof M) {
|
|
2860
|
+
const s = u;
|
|
2861
|
+
u = s.map((i, r) => {
|
|
2862
|
+
const o = s[(r + 1) % s.length];
|
|
2863
|
+
return new L(i, o);
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2866
|
+
if (u instanceof L) return vt([u], t, e);
|
|
2867
|
+
const n = $.finalInstance;
|
|
2868
|
+
if (n) {
|
|
2869
|
+
const s = n.findComponentByName("Renderer"), i = n.findComponentByName("Editor"), r = s.createLineSegments(u, 0, t, i?.container);
|
|
2870
|
+
return r.position.z = e, r;
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
function Ee(u, t, e = 1e-3) {
|
|
2874
|
+
const n = $.finalInstance;
|
|
2875
|
+
if (n) {
|
|
2876
|
+
const s = n.findComponentByName("Renderer"), i = n.findComponentByName("Editor"), r = s.createCircle(u, t, i?.container);
|
|
2877
|
+
return r.position.z = e, r;
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
class Ae {
|
|
2684
2881
|
// 所有可查找的点位
|
|
2685
2882
|
possibleDoorPoints = [];
|
|
2686
2883
|
doorPoint = [];
|
|
2687
2884
|
calculatedDoorPoint = [];
|
|
2688
2885
|
dxf;
|
|
2689
2886
|
// 包含所有点的虚拟网格
|
|
2690
|
-
pointVirtualGrid = new
|
|
2887
|
+
pointVirtualGrid = new k();
|
|
2691
2888
|
// 只包含可查找点的虚拟网格
|
|
2692
2889
|
findPointVirtualGrid;
|
|
2693
2890
|
quadtree;
|
|
@@ -2700,7 +2897,7 @@ class Se {
|
|
|
2700
2897
|
lineAnalysis;
|
|
2701
2898
|
continueFind = !0;
|
|
2702
2899
|
constructor(t) {
|
|
2703
|
-
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new
|
|
2900
|
+
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new k(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((i) => {
|
|
2704
2901
|
this.pointVirtualGrid.insert(i.start, i), this.pointVirtualGrid.insert(i.end, i);
|
|
2705
2902
|
});
|
|
2706
2903
|
const { doorPoints: e, calculatedDoorPoint: n } = this.getDoorPoint();
|
|
@@ -2740,15 +2937,15 @@ class Se {
|
|
|
2740
2937
|
);
|
|
2741
2938
|
const a = [];
|
|
2742
2939
|
return o.forEach((c) => {
|
|
2743
|
-
const l = new
|
|
2940
|
+
const l = new L(c?.start, c?.end), h = l.length();
|
|
2744
2941
|
if (h < n) return;
|
|
2745
|
-
const
|
|
2942
|
+
const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
2746
2943
|
for (let y = 0; y < 3; y++) {
|
|
2747
|
-
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)),
|
|
2944
|
+
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), g = new L(
|
|
2748
2945
|
x,
|
|
2749
|
-
x.clone().add(
|
|
2946
|
+
x.clone().add(d.clone().multiplyScalar(1))
|
|
2750
2947
|
);
|
|
2751
|
-
if (
|
|
2948
|
+
if (g.directionMove(d, -0.5), this.quadtree.queryLineSegment(g).length) return;
|
|
2752
2949
|
}
|
|
2753
2950
|
a.push(l);
|
|
2754
2951
|
}), a;
|
|
@@ -2768,7 +2965,7 @@ class Se {
|
|
|
2768
2965
|
return this.lineSegments.forEach((e) => {
|
|
2769
2966
|
e.points.forEach((n, s) => {
|
|
2770
2967
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
|
|
2771
|
-
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid:
|
|
2968
|
+
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: Z() });
|
|
2772
2969
|
});
|
|
2773
2970
|
}), t;
|
|
2774
2971
|
}
|
|
@@ -2781,7 +2978,7 @@ class Se {
|
|
|
2781
2978
|
const r = n.lineSegments[i[4]], o = n.originalData[i[4]];
|
|
2782
2979
|
if (o.doorDirectConnection) {
|
|
2783
2980
|
this.continueFind = !1;
|
|
2784
|
-
const a = new
|
|
2981
|
+
const a = new L(M.from(o.start), M.from(o.end));
|
|
2785
2982
|
a.userData = {
|
|
2786
2983
|
doorDirectConnection: !0,
|
|
2787
2984
|
isDoor: !0
|
|
@@ -2790,21 +2987,21 @@ class Se {
|
|
|
2790
2987
|
l.length && e.push({
|
|
2791
2988
|
line: l[0].userData,
|
|
2792
2989
|
point: l[0].point,
|
|
2793
|
-
uuid:
|
|
2990
|
+
uuid: Z()
|
|
2794
2991
|
});
|
|
2795
2992
|
});
|
|
2796
2993
|
} else if (o.drawDoorData) {
|
|
2797
2994
|
const a = M.from(o.drawDoorData.start), c = M.from(o.drawDoorData.n), l = s.queryPoint(a).filter((h) => {
|
|
2798
2995
|
if (h.userData === r) return !1;
|
|
2799
|
-
const
|
|
2800
|
-
|
|
2996
|
+
const d = h.userData, f = d.direction();
|
|
2997
|
+
d.start.equal(a) && f.multiplyScalar(-1);
|
|
2801
2998
|
const p = c.angleBetween(f, "angle");
|
|
2802
2999
|
return p > 170 || p < 10;
|
|
2803
3000
|
});
|
|
2804
3001
|
l.length && t.push({
|
|
2805
3002
|
line: l[0].userData,
|
|
2806
3003
|
point: a,
|
|
2807
|
-
uuid:
|
|
3004
|
+
uuid: Z()
|
|
2808
3005
|
});
|
|
2809
3006
|
} else
|
|
2810
3007
|
console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
|
|
@@ -2831,85 +3028,85 @@ class Se {
|
|
|
2831
3028
|
*/
|
|
2832
3029
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2833
3030
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2834
|
-
function o({ point: x, line:
|
|
2835
|
-
const
|
|
2836
|
-
|
|
2837
|
-
const S = i.queryCircle(x, n).filter((
|
|
2838
|
-
for (let
|
|
2839
|
-
const
|
|
2840
|
-
if (
|
|
2841
|
-
const
|
|
2842
|
-
if (
|
|
2843
|
-
|
|
2844
|
-
const
|
|
2845
|
-
if (
|
|
2846
|
-
const O = t[
|
|
2847
|
-
|
|
2848
|
-
findData: S[
|
|
2849
|
-
findUuid:
|
|
2850
|
-
doorLine:
|
|
2851
|
-
doorUuid:
|
|
3031
|
+
function o({ point: x, line: g }, w, D) {
|
|
3032
|
+
const m = g.direction();
|
|
3033
|
+
g.start === x && m.multiplyScalar(-1);
|
|
3034
|
+
const S = i.queryCircle(x, n).filter((E) => E.userData !== g).sort((E, A) => E.point.distance(x) - A.point.distance(x)), T = [];
|
|
3035
|
+
for (let E = 0; E < S.length; E++) {
|
|
3036
|
+
const A = e.findIndex((O) => O.point === S[E].point);
|
|
3037
|
+
if (A === -1) continue;
|
|
3038
|
+
const v = t[w].uuid, C = e[A].uuid;
|
|
3039
|
+
if (D.has(`${v}.${C}`)) continue;
|
|
3040
|
+
D.add(`${v}.${C}`), D.add(`${C}.${v}`);
|
|
3041
|
+
const F = S[E].point, N = new L(x.clone(), F.clone());
|
|
3042
|
+
if (N.direction().angleBetween(m, "angle") < s) {
|
|
3043
|
+
const O = t[w].line.direction(), R = S[E].userData;
|
|
3044
|
+
R.start.equal(S[E].point) && O.multiplyScalar(-1), N.direction().multiplyScalar(-1).angleBetween(O, "angle") < s && (r.queryLineSegment(N).filter((W) => !(W.line.start.equal(x) || W.line.end.equal(x) || W.line === R)).length || T.push({
|
|
3045
|
+
findData: S[E],
|
|
3046
|
+
findUuid: C,
|
|
3047
|
+
doorLine: N,
|
|
3048
|
+
doorUuid: v
|
|
2852
3049
|
}));
|
|
2853
3050
|
}
|
|
2854
3051
|
}
|
|
2855
|
-
return
|
|
3052
|
+
return T;
|
|
2856
3053
|
}
|
|
2857
|
-
function a(x,
|
|
2858
|
-
|
|
3054
|
+
function a(x, g, w, D, m) {
|
|
3055
|
+
D.add(x);
|
|
2859
3056
|
const S = [];
|
|
2860
|
-
|
|
2861
|
-
for (let
|
|
2862
|
-
const
|
|
2863
|
-
if (
|
|
2864
|
-
const
|
|
2865
|
-
a(
|
|
2866
|
-
} else S.push(
|
|
3057
|
+
m && S.push(m);
|
|
3058
|
+
for (let T = 0; T < w.length; T++) {
|
|
3059
|
+
const E = w[T];
|
|
3060
|
+
if (g.has(E.findUuid)) {
|
|
3061
|
+
const A = g.get(E.findUuid);
|
|
3062
|
+
a(E.findUuid, g, A, D, E) && S.push(E);
|
|
3063
|
+
} else S.push(E);
|
|
2867
3064
|
}
|
|
2868
|
-
return S.sort((
|
|
3065
|
+
return S.sort((T, E) => T.doorLine.length() - E.doorLine.length()), m && S[0] === m ? (w.splice(0), !0) : (w.splice(1), !1);
|
|
2869
3066
|
}
|
|
2870
3067
|
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
2871
|
-
t.map((x,
|
|
2872
|
-
const
|
|
2873
|
-
|
|
3068
|
+
t.map((x, g) => {
|
|
3069
|
+
const w = o(x, g, c);
|
|
3070
|
+
w.length && l.set(x.uuid, w);
|
|
2874
3071
|
}), c.clear();
|
|
2875
3072
|
const h = /* @__PURE__ */ new Map();
|
|
2876
|
-
l.forEach((x,
|
|
2877
|
-
if (!c.has(
|
|
2878
|
-
const
|
|
2879
|
-
h.has(
|
|
3073
|
+
l.forEach((x, g) => {
|
|
3074
|
+
if (!c.has(g) && x.length && a(g, l, x, c), x.length) {
|
|
3075
|
+
const w = x[0];
|
|
3076
|
+
h.has(w.doorUuid) || h.set(w.doorUuid, []), h.get(w.doorUuid)?.push(w), h.has(w.findUuid) || h.set(w.findUuid, []), h.get(w.findUuid)?.push(w);
|
|
2880
3077
|
}
|
|
2881
3078
|
});
|
|
2882
|
-
const
|
|
3079
|
+
const d = /* @__PURE__ */ new Set();
|
|
2883
3080
|
h.forEach((x) => {
|
|
2884
3081
|
if (x.length > 1) {
|
|
2885
|
-
x.sort((
|
|
2886
|
-
for (let
|
|
3082
|
+
x.sort((g, w) => g.doorLine.length() - w.doorLine.length());
|
|
3083
|
+
for (let g = 1; g < x.length; g++) d.add(x[g]);
|
|
2887
3084
|
}
|
|
2888
3085
|
});
|
|
2889
3086
|
const f = [], p = [];
|
|
2890
3087
|
l.forEach((x) => {
|
|
2891
3088
|
if (x.length) {
|
|
2892
|
-
const
|
|
2893
|
-
|
|
3089
|
+
const g = x[0];
|
|
3090
|
+
d.has(g) || (f.push(g), p.push(g.doorUuid, g.findUuid));
|
|
2894
3091
|
}
|
|
2895
3092
|
});
|
|
2896
3093
|
const y = [];
|
|
2897
3094
|
return f.forEach((x) => {
|
|
2898
|
-
const
|
|
2899
|
-
if (
|
|
2900
|
-
|
|
2901
|
-
const
|
|
2902
|
-
(
|
|
2903
|
-
start:
|
|
2904
|
-
end:
|
|
3095
|
+
const g = t.findIndex((A) => A.uuid === x.doorUuid), w = e.findIndex((A) => A.uuid === x.findUuid), D = t[g].point.clone(), m = e[w].point.clone(), S = this.findLongLineSegment(t[g].line), T = this.findLongLineSegment(e[w].line), E = S.projectPoint(m);
|
|
3096
|
+
if (E) {
|
|
3097
|
+
D.copy(E);
|
|
3098
|
+
const A = new L(D, m), v = T.includedAngle(A);
|
|
3099
|
+
(v < 10 || v > 170 || Math.abs(90 - v) < 10) && y.push({
|
|
3100
|
+
start: D,
|
|
3101
|
+
end: m
|
|
2905
3102
|
});
|
|
2906
3103
|
} else {
|
|
2907
|
-
const
|
|
2908
|
-
|
|
2909
|
-
const
|
|
2910
|
-
(
|
|
2911
|
-
start:
|
|
2912
|
-
end:
|
|
3104
|
+
const A = T.projectPoint(D);
|
|
3105
|
+
A && m.copy(A);
|
|
3106
|
+
const v = new L(D, m), C = S.includedAngle(v);
|
|
3107
|
+
(C < 10 || C > 170 || Math.abs(90 - C) < 10) && y.push({
|
|
3108
|
+
start: D,
|
|
3109
|
+
end: m
|
|
2913
3110
|
});
|
|
2914
3111
|
}
|
|
2915
3112
|
}), e.splice(
|
|
@@ -2930,7 +3127,7 @@ class Se {
|
|
|
2930
3127
|
searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2931
3128
|
const s = this.quadtree, i = e.direction();
|
|
2932
3129
|
e.start === t && i.multiplyScalar(-1);
|
|
2933
|
-
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new
|
|
3130
|
+
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new L(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
|
|
2934
3131
|
point: c.line.getIntersection(o),
|
|
2935
3132
|
line: c.line
|
|
2936
3133
|
})).filter((c) => c.point).sort((c, l) => t.distance(c.point) - t.distance(l.point));
|
|
@@ -2949,22 +3146,22 @@ class Se {
|
|
|
2949
3146
|
searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2950
3147
|
const s = this.pointVirtualGrid, i = this.quadtree, r = e.direction(), o = e.start.normal(e.end), a = e.start.clone();
|
|
2951
3148
|
e.start === t && r.multiplyScalar(-1), e.start === t && a.copy(e.end);
|
|
2952
|
-
const c = s.queryPoint(a).filter((
|
|
2953
|
-
for (let
|
|
2954
|
-
const f = c[
|
|
3149
|
+
const c = s.queryPoint(a).filter((d) => d.userData !== e);
|
|
3150
|
+
for (let d = 0; d < c.length; d++) {
|
|
3151
|
+
const f = c[d], p = f.userData, y = p.direction();
|
|
2955
3152
|
if (p.start === f.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
|
|
2956
3153
|
o.multiplyScalar(-1);
|
|
2957
3154
|
break;
|
|
2958
3155
|
}
|
|
2959
3156
|
}
|
|
2960
|
-
const l = new
|
|
2961
|
-
point:
|
|
2962
|
-
line:
|
|
2963
|
-
})).filter((
|
|
3157
|
+
const l = new L(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
|
|
3158
|
+
point: d.line.getIntersection(l),
|
|
3159
|
+
line: d.line
|
|
3160
|
+
})).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
|
|
2964
3161
|
if (h.length) {
|
|
2965
|
-
const
|
|
2966
|
-
if (Math.abs(90 -
|
|
2967
|
-
return
|
|
3162
|
+
const d = h[0];
|
|
3163
|
+
if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
|
|
3164
|
+
return d;
|
|
2968
3165
|
}
|
|
2969
3166
|
}
|
|
2970
3167
|
/**
|
|
@@ -2991,143 +3188,25 @@ class Se {
|
|
|
2991
3188
|
return e;
|
|
2992
3189
|
}
|
|
2993
3190
|
}
|
|
2994
|
-
class
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
errorAngle = 4;
|
|
3002
|
-
width = 0.4;
|
|
3191
|
+
class Te extends z {
|
|
3192
|
+
doorSearchNearAngle = 110;
|
|
3193
|
+
doorSearchDistance = 2;
|
|
3194
|
+
DoorsAnalysis;
|
|
3195
|
+
skipFindDoor = !1;
|
|
3196
|
+
needsSaveDoor = !1;
|
|
3197
|
+
doors = [];
|
|
3003
3198
|
/**
|
|
3004
3199
|
*
|
|
3005
3200
|
* @param parent
|
|
3006
3201
|
*/
|
|
3007
3202
|
onAddFromParent(t) {
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
* @param p1
|
|
3013
|
-
* @param p2
|
|
3014
|
-
* @param width
|
|
3015
|
-
* @returns
|
|
3016
|
-
*/
|
|
3017
|
-
expandLineSegment(t, e, n = 0.1) {
|
|
3018
|
-
const s = e.normal(t), i = e.direction(t).mutiplyScalar(n * 0.5), r = t.direction(e).mutiplyScalar(n * 0.5), o = s.x * n * 0.5, a = s.y * n * 0.5;
|
|
3019
|
-
return {
|
|
3020
|
-
points: [
|
|
3021
|
-
// 第一条线
|
|
3022
|
-
new M(t.x + o, t.y + a).add(r),
|
|
3023
|
-
new M(e.x + o, e.y + a).add(i),
|
|
3024
|
-
// 第二条线
|
|
3025
|
-
new M(t.x - o, t.y - a).add(r),
|
|
3026
|
-
new M(e.x - o, e.y - a).add(i)
|
|
3027
|
-
],
|
|
3028
|
-
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
3029
|
-
rectIndices: [0, 1, 3, 2, 0]
|
|
3030
|
-
};
|
|
3031
|
-
}
|
|
3032
|
-
appendLineSegmentList = [];
|
|
3033
|
-
/**
|
|
3034
|
-
* 追加数据
|
|
3035
|
-
* @param p1
|
|
3036
|
-
* @param p2
|
|
3037
|
-
*/
|
|
3038
|
-
addData(t, e) {
|
|
3039
|
-
const n = this.Dxf;
|
|
3040
|
-
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new A(t.clone(), e.clone()));
|
|
3041
|
-
}
|
|
3042
|
-
/** 结果分析创建矩形
|
|
3043
|
-
* @param result
|
|
3044
|
-
*/
|
|
3045
|
-
createRectangle(t) {
|
|
3046
|
-
const e = this.Dxf, n = t.project, s = t.project2;
|
|
3047
|
-
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]);
|
|
3048
|
-
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), u = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(u);
|
|
3049
|
-
p.multiplyScalar(e.width * 0.5);
|
|
3050
|
-
const y = u.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), m = u.direction(f), D = y.direction(x);
|
|
3051
|
-
if (!(m.x > 0 && D.x < 0 || m.x < 0 && D.x > 0 || m.y > 0 && D.y < 0 || m.y < 0 && D.y > 0)) {
|
|
3052
|
-
u.set(y.x, y.y), f.set(x.x, x.y);
|
|
3053
|
-
for (let w = 1; w < o; w++) {
|
|
3054
|
-
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w), E = u.clone().add(g), L = f.clone().add(S);
|
|
3055
|
-
this.addData(E, L);
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
quadtree;
|
|
3060
|
-
/**
|
|
3061
|
-
* 构建线段四叉树,快速查找,
|
|
3062
|
-
*/
|
|
3063
|
-
buildQuadtree() {
|
|
3064
|
-
const t = this.Dxf, e = [];
|
|
3065
|
-
this.quadtree = new F(t.originalBox, 2), t.lineSegments.forEach((n) => {
|
|
3066
|
-
n.userData?.isDoor || (this.quadtree?.insert({
|
|
3067
|
-
line: n,
|
|
3068
|
-
userData: e.length
|
|
3069
|
-
}), e.push(n));
|
|
3070
|
-
}), this.lineSegmentList = e;
|
|
3071
|
-
}
|
|
3072
|
-
resultList = [];
|
|
3073
|
-
mergeWallLines = [];
|
|
3074
|
-
/** 线段分析
|
|
3075
|
-
* @description 判断两条线段距离是否较短且趋近平行,然后查找两条线段的重合部分的投影线,以此判断两根线是否需要合并
|
|
3076
|
-
* @param data
|
|
3077
|
-
*/
|
|
3078
|
-
lineAnalysis() {
|
|
3079
|
-
this.buildQuadtree();
|
|
3080
|
-
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
3081
|
-
e.forEach((i, r) => {
|
|
3082
|
-
const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
3083
|
-
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
3084
|
-
try {
|
|
3085
|
-
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
3086
|
-
const h = this.projectionAnalysis(l, r, o, e);
|
|
3087
|
-
h && s.push(h), n.add(`${r}-${l}`);
|
|
3088
|
-
} catch {
|
|
3089
|
-
}
|
|
3090
|
-
});
|
|
3091
|
-
}), this.appendLineSegmentList.length = 0, s.forEach(this.createRectangle.bind(this)), this.resultList = s;
|
|
3092
|
-
}
|
|
3093
|
-
/** 线段投影分析
|
|
3094
|
-
* @param index
|
|
3095
|
-
* @param sourceLineSegment
|
|
3096
|
-
* @param lineSegmentList
|
|
3097
|
-
* @returns
|
|
3098
|
-
*/
|
|
3099
|
-
projectionAnalysis(t, e, n, s) {
|
|
3100
|
-
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
3101
|
-
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
3102
|
-
let c;
|
|
3103
|
-
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
3104
|
-
return l.getLength() > h.getLength() ? c = {
|
|
3105
|
-
target: i,
|
|
3106
|
-
targetIndex: t,
|
|
3107
|
-
source: n,
|
|
3108
|
-
sourceIndex: e,
|
|
3109
|
-
project: l,
|
|
3110
|
-
project2: h
|
|
3111
|
-
} : c = {
|
|
3112
|
-
target: n,
|
|
3113
|
-
targetIndex: e,
|
|
3114
|
-
source: i,
|
|
3115
|
-
sourceIndex: t,
|
|
3116
|
-
project: h,
|
|
3117
|
-
project2: l
|
|
3118
|
-
}, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
|
|
3119
|
-
}
|
|
3120
|
-
}
|
|
3121
|
-
doorSearchNearAngle = 110;
|
|
3122
|
-
doorSearchDistance = 2;
|
|
3123
|
-
doors = [];
|
|
3124
|
-
DoorsAnalysis;
|
|
3125
|
-
skipFindDoor = !1;
|
|
3126
|
-
doorsAnalysis() {
|
|
3127
|
-
this.skipFindDoor || (this.DoorsAnalysis = new Se(this), this.skipFindDoor = !1), this.dispatchEvent({ type: "analysisCompleted" });
|
|
3203
|
+
const e = t.findComponentByType(Y), n = this.parent?.findComponentByType(Rt);
|
|
3204
|
+
e.addEventListener("createGroup", () => {
|
|
3205
|
+
this.skipFindDoor ? this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])) : this.DoorsAnalysis = new Ae(n), this.skipFindDoor = !1, this.dispatchEvent({ type: "analysisCompleted" });
|
|
3206
|
+
});
|
|
3128
3207
|
}
|
|
3129
3208
|
}
|
|
3130
|
-
class
|
|
3209
|
+
class be extends z {
|
|
3131
3210
|
static name = "ThreeVJia";
|
|
3132
3211
|
lineSegments = [];
|
|
3133
3212
|
onAddFromParent() {
|
|
@@ -3137,28 +3216,28 @@ class Le extends _ {
|
|
|
3137
3216
|
const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf"), n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
|
|
3138
3217
|
let i = [...e.lineSegments], r = [], o = [];
|
|
3139
3218
|
t.resultList.forEach((l) => {
|
|
3140
|
-
const h = s.get(l.target) ?? [],
|
|
3141
|
-
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points),
|
|
3142
|
-
const y = new
|
|
3143
|
-
|
|
3219
|
+
const h = s.get(l.target) ?? [], d = s.get(l.source) ?? [], f = l.project.clone(), p = l.project2.clone();
|
|
3220
|
+
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points), d.push(...p.points), s.set(l.target, h), s.set(l.source, d);
|
|
3221
|
+
const y = new L(f.start, p.start), x = new L(f.end, p.end), g = new L(y.center, x.center);
|
|
3222
|
+
g.userData.wallWidth = Math.max(y.length(), x.length()), r.push(g);
|
|
3144
3223
|
});
|
|
3145
3224
|
const a = [];
|
|
3146
3225
|
i = i.filter((l) => {
|
|
3147
3226
|
if (o.indexOf(l) > -1) return !1;
|
|
3148
3227
|
if (s.has(l)) {
|
|
3149
|
-
const h = s.get(l),
|
|
3228
|
+
const h = s.get(l), d = l.clone();
|
|
3150
3229
|
if (h) {
|
|
3151
3230
|
for (let p = 0; p < h.length; p += 2) {
|
|
3152
3231
|
const y = h[p], x = h[p + 1];
|
|
3153
|
-
y.userData.length = y.distance(
|
|
3232
|
+
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");
|
|
3154
3233
|
}
|
|
3155
3234
|
h.sort((p, y) => p.userData.length - y.userData.length);
|
|
3156
3235
|
const f = [];
|
|
3157
3236
|
for (let p = 0; p < h.length; p++) {
|
|
3158
3237
|
const y = h[p];
|
|
3159
|
-
y.userData.type === "start" ? (f.length === 0 && (a.push(new
|
|
3238
|
+
y.userData.type === "start" ? (f.length === 0 && (a.push(new L(d.start.clone(), y.clone())), d.start.copy(y)), f.push("start")) : (f.pop(), f.length === 0 && d.start.copy(y));
|
|
3160
3239
|
}
|
|
3161
|
-
a.push(
|
|
3240
|
+
a.push(d);
|
|
3162
3241
|
}
|
|
3163
3242
|
return !1;
|
|
3164
3243
|
}
|
|
@@ -3247,13 +3326,15 @@ class Le extends _ {
|
|
|
3247
3326
|
if (typeof window < "u") {
|
|
3248
3327
|
const e = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
|
|
3249
3328
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
3250
|
-
} else typeof global < "u" && (await
|
|
3329
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
|
|
3251
3330
|
}
|
|
3252
3331
|
}
|
|
3253
|
-
class
|
|
3332
|
+
class $ extends ie {
|
|
3254
3333
|
Dxf;
|
|
3255
3334
|
AngleCorrectionDxf;
|
|
3256
3335
|
Variable;
|
|
3336
|
+
LineAnalysis;
|
|
3337
|
+
DoorsAnalysis;
|
|
3257
3338
|
wallWidth;
|
|
3258
3339
|
environment;
|
|
3259
3340
|
static finalInstance;
|
|
@@ -3262,7 +3343,7 @@ class ht extends se {
|
|
|
3262
3343
|
* @param scale 原始数据缩放比例
|
|
3263
3344
|
*/
|
|
3264
3345
|
constructor(t = 0.1, e = 1) {
|
|
3265
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new
|
|
3346
|
+
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new Y(this.wallWidth, e), this.AngleCorrectionDxf = new Le(), this.Variable = new Pt(), this.LineAnalysis = new Rt(), this.DoorsAnalysis = new Te(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(this.LineAnalysis), this.addComponent(this.DoorsAnalysis), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new be()), $.finalInstance = this;
|
|
3266
3347
|
}
|
|
3267
3348
|
usePlugin(t) {
|
|
3268
3349
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3282,12 +3363,12 @@ class ut {
|
|
|
3282
3363
|
* @returns
|
|
3283
3364
|
*/
|
|
3284
3365
|
static findExtWallByTraj(t, e, n = 0.4) {
|
|
3285
|
-
const s = new
|
|
3366
|
+
const s = new B(P.fromByLineSegment(...t));
|
|
3286
3367
|
return t.forEach((i) => s.insert({ line: i, userData: void 0 })), t = t.filter((i) => {
|
|
3287
3368
|
const r = i.center, o = /* @__PURE__ */ new Set();
|
|
3288
3369
|
for (const a of e) {
|
|
3289
3370
|
if (o.size === 2) break;
|
|
3290
|
-
const c = new
|
|
3371
|
+
const c = new L(r, a);
|
|
3291
3372
|
if (!s.queryLineSegment(c).filter((h) => !(h.line === i || h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
|
|
3292
3373
|
const h = i.pointPosition(a);
|
|
3293
3374
|
h !== "on" && o.add(h);
|
|
@@ -3301,89 +3382,87 @@ class ut {
|
|
|
3301
3382
|
* @param trajectoryPoints
|
|
3302
3383
|
*/
|
|
3303
3384
|
static boundExtbyTraj(t, e, n = 0.12) {
|
|
3304
|
-
function s(
|
|
3305
|
-
return
|
|
3306
|
-
const
|
|
3307
|
-
|
|
3308
|
-
const
|
|
3309
|
-
if (
|
|
3385
|
+
function s(g, w) {
|
|
3386
|
+
return w.queryLineSegment(g).filter((D) => D.line !== g).map(({ line: D }) => {
|
|
3387
|
+
const m = { resultLine: D, type: "intersect", direction: "vertical", point: null, newLine: null };
|
|
3388
|
+
g.sameEndpoint(D) && (m.type = "endpoint"), g.parallel(D) && (m.direction = "parallel");
|
|
3389
|
+
const S = g.getSameEndpoint(D);
|
|
3390
|
+
if (S) m.point = S[1];
|
|
3310
3391
|
else {
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3392
|
+
const T = D.getIntersection(g);
|
|
3393
|
+
T && (m.point = D.start.equal(T) ? D.start : D.end);
|
|
3313
3394
|
}
|
|
3314
|
-
return
|
|
3395
|
+
return m;
|
|
3315
3396
|
});
|
|
3316
3397
|
}
|
|
3317
|
-
function i(
|
|
3318
|
-
const
|
|
3319
|
-
if (
|
|
3320
|
-
const
|
|
3321
|
-
|
|
3322
|
-
} else if (
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3398
|
+
function i(g) {
|
|
3399
|
+
const w = g.userData.expandDirect;
|
|
3400
|
+
if (w === "left") {
|
|
3401
|
+
const D = g.getLeftDirection();
|
|
3402
|
+
g.directionMove(D, n * 0.5);
|
|
3403
|
+
} else if (w === "right") {
|
|
3404
|
+
const D = g.getRightDirection();
|
|
3405
|
+
g.directionMove(D, n * 0.5);
|
|
3325
3406
|
}
|
|
3326
3407
|
}
|
|
3327
|
-
function r({ resultLine:
|
|
3328
|
-
if (
|
|
3329
|
-
|
|
3330
|
-
else if (
|
|
3331
|
-
if (
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3408
|
+
function r({ resultLine: g, type: w, direction: D, point: m }, S, T, E) {
|
|
3409
|
+
if (w === "intersect")
|
|
3410
|
+
m && m.copy(S.projectPoint(m) ?? m);
|
|
3411
|
+
else if (D === "vertical") {
|
|
3412
|
+
if (m) {
|
|
3413
|
+
const A = S.projectPoint(m, !1);
|
|
3414
|
+
m.copy(A), S.isPointOnSegment(A) || (S.start.distance(A) < S.end.distance(A) ? E.push(new L(A.clone(), S.start.clone())) : E.push(new L(A.clone(), S.end.clone())));
|
|
3334
3415
|
}
|
|
3335
|
-
} else if (!
|
|
3336
|
-
let
|
|
3337
|
-
if (
|
|
3338
|
-
|
|
3339
|
-
const C = new A
|
|
3340
|
-
C.length() &&
|
|
3416
|
+
} else if (!d.includes(g) && m) {
|
|
3417
|
+
let A = S.projectPoint(m, !1), v;
|
|
3418
|
+
if (S.start.distance(m) < S.end.distance(m) ? v = S.start : v = S.end, A) {
|
|
3419
|
+
E.push(new L(m.clone(), A.clone()));
|
|
3420
|
+
const C = new L(A.clone(), v.clone());
|
|
3421
|
+
C.length() && E.push(C);
|
|
3341
3422
|
}
|
|
3342
3423
|
}
|
|
3343
|
-
|
|
3424
|
+
T.update(g);
|
|
3344
3425
|
}
|
|
3345
|
-
const o = Object.keys(e).map((
|
|
3346
|
-
let c = t.map(({ start:
|
|
3347
|
-
const
|
|
3348
|
-
return
|
|
3426
|
+
const o = Object.keys(e).map((g) => M.from(e[g])), a = [];
|
|
3427
|
+
let c = t.map(({ start: g, end: w, ...D }) => {
|
|
3428
|
+
const m = new L(M.from(g), M.from(w));
|
|
3429
|
+
return m.userData = D, a.push(g.z ?? 0, w.z ?? 0), m;
|
|
3349
3430
|
});
|
|
3350
|
-
const l = a.reduce((
|
|
3351
|
-
let
|
|
3352
|
-
c = c.filter((
|
|
3353
|
-
const p =
|
|
3354
|
-
|
|
3355
|
-
const y =
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
let L;
|
|
3361
|
-
return Object.defineProperty(E, "newLine", {
|
|
3431
|
+
const l = a.reduce((g, w) => g + w, 0) / a.length;
|
|
3432
|
+
let d = ut.findExtWallByTraj(c, o).filter((g) => g.userData.expandDirect);
|
|
3433
|
+
c = c.filter((g) => !d.includes(g)), c.push(...d), vt(d, { color: 65280 }), Ee(o, { size: 6 });
|
|
3434
|
+
const f = L.groupBySamePointAndParallel(d), p = new B(P.fromByLineSegment(...c));
|
|
3435
|
+
c.forEach((g) => g.userData.isDoor || p.insert(g));
|
|
3436
|
+
const y = f.map((g) => g.flatMap((w) => s(w, p))), x = [];
|
|
3437
|
+
return f.flatMap((g, w) => (g.forEach((m) => (i(m), p.update(m))), y[w].filter((m) => {
|
|
3438
|
+
if (!d.includes(m.resultLine)) {
|
|
3439
|
+
let S;
|
|
3440
|
+
return Object.defineProperty(m, "newLine", {
|
|
3362
3441
|
get() {
|
|
3363
|
-
return
|
|
3442
|
+
return S || (S = L.mergeLines(...g)), S;
|
|
3364
3443
|
}
|
|
3365
3444
|
}), !0;
|
|
3366
3445
|
}
|
|
3367
|
-
r(
|
|
3368
|
-
}))).reduce((
|
|
3369
|
-
|
|
3370
|
-
const
|
|
3371
|
-
for (let
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3446
|
+
r(m, L.mergeLines(...g), p, x);
|
|
3447
|
+
}))).reduce((g, w) => (g.has(w.resultLine) || g.set(w.resultLine, []), g.get(w.resultLine)?.push(w), g), /* @__PURE__ */ new Map()).forEach((g) => {
|
|
3448
|
+
g.reduce((w, D) => (w.has(D.point) || w.set(D.point, []), w.get(D.point)?.push(D), w), /* @__PURE__ */ new Map()).forEach((w) => {
|
|
3449
|
+
const D = /* @__PURE__ */ new Set();
|
|
3450
|
+
for (let m = 0; m < w.length; m++) {
|
|
3451
|
+
const S = w[m];
|
|
3452
|
+
D.has(S.point) || (r(S, S.newLine, p, x), D.add(S.point));
|
|
3374
3453
|
}
|
|
3375
3454
|
});
|
|
3376
|
-
}), c.push(...
|
|
3455
|
+
}), c.push(...L.deduplication(x)), c.forEach((g) => g.userData.isWindow && nt(g)), c = et(c), c = L.deduplication(c), J(c, l);
|
|
3377
3456
|
}
|
|
3378
3457
|
}
|
|
3379
|
-
const
|
|
3458
|
+
const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3380
3459
|
__proto__: null,
|
|
3381
|
-
AxisAlignCorr:
|
|
3460
|
+
AxisAlignCorr: It,
|
|
3382
3461
|
BoundExt: ut,
|
|
3383
3462
|
lineDataToOriginalData: J,
|
|
3384
|
-
lineSegmentClipping:
|
|
3385
|
-
recomputedWindow:
|
|
3386
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3463
|
+
lineSegmentClipping: et,
|
|
3464
|
+
recomputedWindow: nt
|
|
3465
|
+
}, Symbol.toStringTag, { value: "Module" })), Mt = {
|
|
3387
3466
|
POSITION: [
|
|
3388
3467
|
"byte",
|
|
3389
3468
|
"byte normalized",
|
|
@@ -3411,24 +3490,10 @@ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3411
3490
|
"unsigned short"
|
|
3412
3491
|
]
|
|
3413
3492
|
};
|
|
3414
|
-
class
|
|
3493
|
+
class st {
|
|
3415
3494
|
constructor() {
|
|
3416
3495
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
3417
|
-
return new Be(t);
|
|
3418
|
-
}), this.register(function(t) {
|
|
3419
|
-
return new Oe(t);
|
|
3420
|
-
}), this.register(function(t) {
|
|
3421
3496
|
return new je(t);
|
|
3422
|
-
}), this.register(function(t) {
|
|
3423
|
-
return new ze(t);
|
|
3424
|
-
}), this.register(function(t) {
|
|
3425
|
-
return new qe(t);
|
|
3426
|
-
}), this.register(function(t) {
|
|
3427
|
-
return new _e(t);
|
|
3428
|
-
}), this.register(function(t) {
|
|
3429
|
-
return new Fe(t);
|
|
3430
|
-
}), this.register(function(t) {
|
|
3431
|
-
return new Ue(t);
|
|
3432
3497
|
}), this.register(function(t) {
|
|
3433
3498
|
return new Ge(t);
|
|
3434
3499
|
}), this.register(function(t) {
|
|
@@ -3439,8 +3504,22 @@ class et {
|
|
|
3439
3504
|
return new Xe(t);
|
|
3440
3505
|
}), this.register(function(t) {
|
|
3441
3506
|
return new Ve(t);
|
|
3507
|
+
}), this.register(function(t) {
|
|
3508
|
+
return new ze(t);
|
|
3509
|
+
}), this.register(function(t) {
|
|
3510
|
+
return new qe(t);
|
|
3511
|
+
}), this.register(function(t) {
|
|
3512
|
+
return new _e(t);
|
|
3442
3513
|
}), this.register(function(t) {
|
|
3443
3514
|
return new We(t);
|
|
3515
|
+
}), this.register(function(t) {
|
|
3516
|
+
return new He(t);
|
|
3517
|
+
}), this.register(function(t) {
|
|
3518
|
+
return new Je(t);
|
|
3519
|
+
}), this.register(function(t) {
|
|
3520
|
+
return new $e(t);
|
|
3521
|
+
}), this.register(function(t) {
|
|
3522
|
+
return new Ke(t);
|
|
3444
3523
|
});
|
|
3445
3524
|
}
|
|
3446
3525
|
register(t) {
|
|
@@ -3453,7 +3532,7 @@ class et {
|
|
|
3453
3532
|
return this.textureUtils = t, this;
|
|
3454
3533
|
}
|
|
3455
3534
|
parse(t, e, n, s) {
|
|
3456
|
-
const i = new
|
|
3535
|
+
const i = new Ue(), r = [];
|
|
3457
3536
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
3458
3537
|
r.push(this.pluginCallbacks[o](i));
|
|
3459
3538
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
|
|
@@ -3465,7 +3544,7 @@ class et {
|
|
|
3465
3544
|
});
|
|
3466
3545
|
}
|
|
3467
3546
|
}
|
|
3468
|
-
const
|
|
3547
|
+
const b = {
|
|
3469
3548
|
POINTS: 0,
|
|
3470
3549
|
LINES: 1,
|
|
3471
3550
|
LINE_LOOP: 2,
|
|
@@ -3489,73 +3568,73 @@ const T = {
|
|
|
3489
3568
|
CLAMP_TO_EDGE: 33071,
|
|
3490
3569
|
MIRRORED_REPEAT: 33648,
|
|
3491
3570
|
REPEAT: 10497
|
|
3492
|
-
},
|
|
3493
|
-
U[
|
|
3494
|
-
U[
|
|
3495
|
-
U[
|
|
3496
|
-
U[
|
|
3497
|
-
U[
|
|
3498
|
-
U[
|
|
3499
|
-
U[
|
|
3500
|
-
U[
|
|
3501
|
-
U[
|
|
3502
|
-
const
|
|
3571
|
+
}, ot = "KHR_mesh_quantization", U = {};
|
|
3572
|
+
U[Wt] = b.NEAREST;
|
|
3573
|
+
U[Ht] = b.NEAREST_MIPMAP_NEAREST;
|
|
3574
|
+
U[Jt] = b.NEAREST_MIPMAP_LINEAR;
|
|
3575
|
+
U[$t] = b.LINEAR;
|
|
3576
|
+
U[Kt] = b.LINEAR_MIPMAP_NEAREST;
|
|
3577
|
+
U[Zt] = b.LINEAR_MIPMAP_LINEAR;
|
|
3578
|
+
U[Qt] = b.CLAMP_TO_EDGE;
|
|
3579
|
+
U[te] = b.REPEAT;
|
|
3580
|
+
U[ee] = b.MIRRORED_REPEAT;
|
|
3581
|
+
const St = {
|
|
3503
3582
|
scale: "scale",
|
|
3504
3583
|
position: "translation",
|
|
3505
3584
|
quaternion: "rotation",
|
|
3506
3585
|
morphTargetInfluences: "weights"
|
|
3507
|
-
},
|
|
3508
|
-
function H(
|
|
3509
|
-
return
|
|
3586
|
+
}, Ie = new Ut(), Dt = 12, Pe = 1179937895, Re = 2, Lt = 8, ve = 1313821514, Ce = 5130562;
|
|
3587
|
+
function H(u, t) {
|
|
3588
|
+
return u.length === t.length && u.every(function(e, n) {
|
|
3510
3589
|
return e === t[n];
|
|
3511
3590
|
});
|
|
3512
3591
|
}
|
|
3513
|
-
function
|
|
3514
|
-
return new TextEncoder().encode(
|
|
3592
|
+
function Ne(u) {
|
|
3593
|
+
return new TextEncoder().encode(u).buffer;
|
|
3515
3594
|
}
|
|
3516
|
-
function
|
|
3517
|
-
return H(
|
|
3595
|
+
function Be(u) {
|
|
3596
|
+
return H(u.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
3518
3597
|
}
|
|
3519
|
-
function
|
|
3598
|
+
function Oe(u, t, e) {
|
|
3520
3599
|
const n = {
|
|
3521
|
-
min: new Array(
|
|
3522
|
-
max: new Array(
|
|
3600
|
+
min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
3601
|
+
max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
3523
3602
|
};
|
|
3524
3603
|
for (let s = t; s < t + e; s++)
|
|
3525
|
-
for (let i = 0; i <
|
|
3604
|
+
for (let i = 0; i < u.itemSize; i++) {
|
|
3526
3605
|
let r;
|
|
3527
|
-
|
|
3606
|
+
u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r = lt.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
3528
3607
|
}
|
|
3529
3608
|
return n;
|
|
3530
3609
|
}
|
|
3531
|
-
function
|
|
3532
|
-
return Math.ceil(
|
|
3610
|
+
function Ct(u) {
|
|
3611
|
+
return Math.ceil(u / 4) * 4;
|
|
3533
3612
|
}
|
|
3534
|
-
function
|
|
3535
|
-
const e =
|
|
3536
|
-
if (e !==
|
|
3613
|
+
function at(u, t = 0) {
|
|
3614
|
+
const e = Ct(u.byteLength);
|
|
3615
|
+
if (e !== u.byteLength) {
|
|
3537
3616
|
const n = new Uint8Array(e);
|
|
3538
|
-
if (n.set(new Uint8Array(
|
|
3539
|
-
for (let s =
|
|
3617
|
+
if (n.set(new Uint8Array(u)), t !== 0)
|
|
3618
|
+
for (let s = u.byteLength; s < e; s++)
|
|
3540
3619
|
n[s] = t;
|
|
3541
3620
|
return n.buffer;
|
|
3542
3621
|
}
|
|
3543
|
-
return
|
|
3622
|
+
return u;
|
|
3544
3623
|
}
|
|
3545
|
-
function
|
|
3624
|
+
function Et() {
|
|
3546
3625
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
3547
3626
|
}
|
|
3548
|
-
function
|
|
3549
|
-
if (typeof OffscreenCanvas < "u" &&
|
|
3627
|
+
function Fe(u, t) {
|
|
3628
|
+
if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
|
|
3550
3629
|
let e;
|
|
3551
|
-
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8),
|
|
3630
|
+
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8), u.convertToBlob({
|
|
3552
3631
|
type: t,
|
|
3553
3632
|
quality: e
|
|
3554
3633
|
});
|
|
3555
3634
|
} else
|
|
3556
|
-
return new Promise((e) =>
|
|
3635
|
+
return new Promise((e) => u.toBlob(e, t));
|
|
3557
3636
|
}
|
|
3558
|
-
class
|
|
3637
|
+
class Ue {
|
|
3559
3638
|
constructor() {
|
|
3560
3639
|
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 = {
|
|
3561
3640
|
asset: {
|
|
@@ -3597,27 +3676,27 @@ class Ce {
|
|
|
3597
3676
|
const s = this, i = s.buffers, r = s.json;
|
|
3598
3677
|
n = s.options;
|
|
3599
3678
|
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
3600
|
-
l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ?
|
|
3601
|
-
const f =
|
|
3602
|
-
p.setUint32(0, f.byteLength, !0), p.setUint32(4,
|
|
3603
|
-
const y =
|
|
3604
|
-
x.setUint32(0, y.byteLength, !0), x.setUint32(4,
|
|
3605
|
-
const
|
|
3606
|
-
|
|
3607
|
-
const
|
|
3608
|
-
|
|
3609
|
-
const
|
|
3610
|
-
|
|
3679
|
+
l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ? ct(c).then(function(d) {
|
|
3680
|
+
const f = at(d), p = new DataView(new ArrayBuffer(Lt));
|
|
3681
|
+
p.setUint32(0, f.byteLength, !0), p.setUint32(4, Ce, !0);
|
|
3682
|
+
const y = at(Ne(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(Lt));
|
|
3683
|
+
x.setUint32(0, y.byteLength, !0), x.setUint32(4, ve, !0);
|
|
3684
|
+
const g = new ArrayBuffer(Dt), w = new DataView(g);
|
|
3685
|
+
w.setUint32(0, Pe, !0), w.setUint32(4, Re, !0);
|
|
3686
|
+
const D = Dt + x.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
3687
|
+
w.setUint32(8, D, !0);
|
|
3688
|
+
const m = new Blob([
|
|
3689
|
+
g,
|
|
3611
3690
|
x,
|
|
3612
3691
|
y,
|
|
3613
3692
|
p,
|
|
3614
3693
|
f
|
|
3615
3694
|
], { type: "application/octet-stream" });
|
|
3616
|
-
|
|
3695
|
+
ct(m).then((S) => {
|
|
3617
3696
|
e(S);
|
|
3618
3697
|
});
|
|
3619
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
3620
|
-
r.buffers[0].uri =
|
|
3698
|
+
}) : r.buffers && r.buffers.length > 0 ? Ze(c).then((d) => {
|
|
3699
|
+
r.buffers[0].uri = d, e(r);
|
|
3621
3700
|
}) : e(r);
|
|
3622
3701
|
}
|
|
3623
3702
|
/**
|
|
@@ -3664,7 +3743,7 @@ class Ce {
|
|
|
3664
3743
|
*/
|
|
3665
3744
|
isNormalizedNormalAttribute(t) {
|
|
3666
3745
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
3667
|
-
const n = new
|
|
3746
|
+
const n = new Q();
|
|
3668
3747
|
for (let s = 0, i = t.count; s < i; s++)
|
|
3669
3748
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
3670
3749
|
return !0;
|
|
@@ -3679,7 +3758,7 @@ class Ce {
|
|
|
3679
3758
|
createNormalizedNormalAttribute(t) {
|
|
3680
3759
|
const e = this.cache;
|
|
3681
3760
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
3682
|
-
const n = t.clone(), s = new
|
|
3761
|
+
const n = t.clone(), s = new Q();
|
|
3683
3762
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3684
3763
|
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);
|
|
3685
3764
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -3699,14 +3778,14 @@ class Ce {
|
|
|
3699
3778
|
async buildMetalRoughTextureAsync(t, e) {
|
|
3700
3779
|
if (t === e) return t;
|
|
3701
3780
|
function n(f) {
|
|
3702
|
-
return f.colorSpace ===
|
|
3781
|
+
return f.colorSpace === Vt ? function(y) {
|
|
3703
3782
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3704
3783
|
} : function(y) {
|
|
3705
3784
|
return y;
|
|
3706
3785
|
};
|
|
3707
3786
|
}
|
|
3708
|
-
t instanceof
|
|
3709
|
-
const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a =
|
|
3787
|
+
t instanceof rt && (t = await this.decompressTextureAsync(t)), e instanceof rt && (e = await this.decompressTextureAsync(e));
|
|
3788
|
+
const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = Et();
|
|
3710
3789
|
a.width = r, a.height = o;
|
|
3711
3790
|
const c = a.getContext("2d", {
|
|
3712
3791
|
willReadFrequently: !0
|
|
@@ -3726,8 +3805,8 @@ class Ce {
|
|
|
3726
3805
|
l.data[y] = f(p[y] / 256) * 256;
|
|
3727
3806
|
}
|
|
3728
3807
|
c.putImageData(l, 0, 0);
|
|
3729
|
-
const
|
|
3730
|
-
return
|
|
3808
|
+
const d = (t || e).clone();
|
|
3809
|
+
return d.source = new zt(a), d.colorSpace = qt, d.channel = (t || e).channel, t && e && t.channel !== e.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
|
|
3731
3810
|
}
|
|
3732
3811
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
3733
3812
|
if (this.textureUtils === null)
|
|
@@ -3757,34 +3836,34 @@ class Ce {
|
|
|
3757
3836
|
r.bufferViews || (r.bufferViews = []);
|
|
3758
3837
|
let o;
|
|
3759
3838
|
switch (e) {
|
|
3760
|
-
case
|
|
3761
|
-
case
|
|
3839
|
+
case b.BYTE:
|
|
3840
|
+
case b.UNSIGNED_BYTE:
|
|
3762
3841
|
o = 1;
|
|
3763
3842
|
break;
|
|
3764
|
-
case
|
|
3765
|
-
case
|
|
3843
|
+
case b.SHORT:
|
|
3844
|
+
case b.UNSIGNED_SHORT:
|
|
3766
3845
|
o = 2;
|
|
3767
3846
|
break;
|
|
3768
3847
|
default:
|
|
3769
3848
|
o = 4;
|
|
3770
3849
|
}
|
|
3771
3850
|
let a = t.itemSize * o;
|
|
3772
|
-
i ===
|
|
3773
|
-
const c =
|
|
3851
|
+
i === b.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
|
|
3852
|
+
const c = Ct(s * a), l = new DataView(new ArrayBuffer(c));
|
|
3774
3853
|
let h = 0;
|
|
3775
3854
|
for (let p = n; p < n + s; p++) {
|
|
3776
3855
|
for (let y = 0; y < t.itemSize; y++) {
|
|
3777
3856
|
let x;
|
|
3778
|
-
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x =
|
|
3857
|
+
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x = lt.normalize(x, t.array))), e === b.FLOAT ? l.setFloat32(h, x, !0) : e === b.INT ? l.setInt32(h, x, !0) : e === b.UNSIGNED_INT ? l.setUint32(h, x, !0) : e === b.SHORT ? l.setInt16(h, x, !0) : e === b.UNSIGNED_SHORT ? l.setUint16(h, x, !0) : e === b.BYTE ? l.setInt8(h, x) : e === b.UNSIGNED_BYTE && l.setUint8(h, x), h += o;
|
|
3779
3858
|
}
|
|
3780
3859
|
h % a !== 0 && (h += a - h % a);
|
|
3781
3860
|
}
|
|
3782
|
-
const
|
|
3861
|
+
const d = {
|
|
3783
3862
|
buffer: this.processBuffer(l.buffer),
|
|
3784
3863
|
byteOffset: this.byteOffset,
|
|
3785
3864
|
byteLength: c
|
|
3786
3865
|
};
|
|
3787
|
-
return i !== void 0 && (
|
|
3866
|
+
return i !== void 0 && (d.target = i), i === b.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
|
|
3788
3867
|
id: r.bufferViews.length - 1,
|
|
3789
3868
|
byteLength: 0
|
|
3790
3869
|
};
|
|
@@ -3797,8 +3876,8 @@ class Ce {
|
|
|
3797
3876
|
processBufferViewImage(t) {
|
|
3798
3877
|
const e = this, n = e.json;
|
|
3799
3878
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3800
|
-
|
|
3801
|
-
const r =
|
|
3879
|
+
ct(t).then((i) => {
|
|
3880
|
+
const r = at(i), o = {
|
|
3802
3881
|
buffer: e.processBuffer(r),
|
|
3803
3882
|
byteOffset: e.byteOffset,
|
|
3804
3883
|
byteLength: r.byteLength
|
|
@@ -3826,25 +3905,25 @@ class Ce {
|
|
|
3826
3905
|
};
|
|
3827
3906
|
let o;
|
|
3828
3907
|
if (t.array.constructor === Float32Array)
|
|
3829
|
-
o =
|
|
3908
|
+
o = b.FLOAT;
|
|
3830
3909
|
else if (t.array.constructor === Int32Array)
|
|
3831
|
-
o =
|
|
3910
|
+
o = b.INT;
|
|
3832
3911
|
else if (t.array.constructor === Uint32Array)
|
|
3833
|
-
o =
|
|
3912
|
+
o = b.UNSIGNED_INT;
|
|
3834
3913
|
else if (t.array.constructor === Int16Array)
|
|
3835
|
-
o =
|
|
3914
|
+
o = b.SHORT;
|
|
3836
3915
|
else if (t.array.constructor === Uint16Array)
|
|
3837
|
-
o =
|
|
3916
|
+
o = b.UNSIGNED_SHORT;
|
|
3838
3917
|
else if (t.array.constructor === Int8Array)
|
|
3839
|
-
o =
|
|
3918
|
+
o = b.BYTE;
|
|
3840
3919
|
else if (t.array.constructor === Uint8Array)
|
|
3841
|
-
o =
|
|
3920
|
+
o = b.UNSIGNED_BYTE;
|
|
3842
3921
|
else
|
|
3843
3922
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
3844
3923
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
3845
|
-
const a =
|
|
3924
|
+
const a = Oe(t, n, s);
|
|
3846
3925
|
let c;
|
|
3847
|
-
e !== void 0 && (c = t === e.index ?
|
|
3926
|
+
e !== void 0 && (c = t === e.index ? b.ELEMENT_ARRAY_BUFFER : b.ARRAY_BUFFER);
|
|
3848
3927
|
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
3849
3928
|
bufferView: l.id,
|
|
3850
3929
|
byteOffset: l.byteOffset,
|
|
@@ -3871,27 +3950,27 @@ class Ce {
|
|
|
3871
3950
|
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
3872
3951
|
if (l[h] !== void 0) return l[h];
|
|
3873
3952
|
o.images || (o.images = []);
|
|
3874
|
-
const
|
|
3953
|
+
const d = { mimeType: s }, f = Et();
|
|
3875
3954
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
3876
3955
|
const p = f.getContext("2d", {
|
|
3877
3956
|
willReadFrequently: !0
|
|
3878
3957
|
});
|
|
3879
3958
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
3880
|
-
e !==
|
|
3959
|
+
e !== _t && console.error("GLTFExporter: Only RGBAFormat is supported.", e), (t.width > a.maxTextureSize || t.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", t);
|
|
3881
3960
|
const x = new Uint8ClampedArray(t.height * t.width * 4);
|
|
3882
|
-
for (let
|
|
3883
|
-
x[
|
|
3961
|
+
for (let g = 0; g < x.length; g += 4)
|
|
3962
|
+
x[g + 0] = t.data[g + 0], x[g + 1] = t.data[g + 1], x[g + 2] = t.data[g + 2], x[g + 3] = t.data[g + 3];
|
|
3884
3963
|
p.putImageData(new ImageData(x, t.width, t.height), 0, 0);
|
|
3885
3964
|
} else if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas)
|
|
3886
3965
|
p.drawImage(t, 0, 0, f.width, f.height);
|
|
3887
3966
|
else
|
|
3888
3967
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
3889
3968
|
a.binary === !0 ? c.push(
|
|
3890
|
-
|
|
3891
|
-
|
|
3969
|
+
Fe(f, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3970
|
+
d.bufferView = x;
|
|
3892
3971
|
})
|
|
3893
|
-
) :
|
|
3894
|
-
const y = o.images.push(
|
|
3972
|
+
) : d.uri = Yt.getDataURL(f, s);
|
|
3973
|
+
const y = o.images.push(d) - 1;
|
|
3895
3974
|
return l[h] = y, y;
|
|
3896
3975
|
} else
|
|
3897
3976
|
throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
|
|
@@ -3920,7 +3999,7 @@ class Ce {
|
|
|
3920
3999
|
async processTextureAsync(t) {
|
|
3921
4000
|
const n = this.options, s = this.cache, i = this.json;
|
|
3922
4001
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
3923
|
-
i.textures || (i.textures = []), t instanceof
|
|
4002
|
+
i.textures || (i.textures = []), t instanceof rt && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
3924
4003
|
let r = t.userData.mimeType;
|
|
3925
4004
|
r === "image/webp" && (r = "image/png");
|
|
3926
4005
|
const o = {
|
|
@@ -3985,7 +4064,7 @@ class Ce {
|
|
|
3985
4064
|
};
|
|
3986
4065
|
t.aoMapIntensity !== 1 && (o.strength = t.aoMapIntensity), this.applyTextureTransform(o, t.aoMap), s.occlusionTexture = o;
|
|
3987
4066
|
}
|
|
3988
|
-
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side ===
|
|
4067
|
+
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === kt && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
|
|
3989
4068
|
o.writeMaterialAsync && await o.writeMaterialAsync(t, s);
|
|
3990
4069
|
});
|
|
3991
4070
|
const r = n.materials.push(s) - 1;
|
|
@@ -3999,16 +4078,16 @@ class Ce {
|
|
|
3999
4078
|
async processMeshAsync(t) {
|
|
4000
4079
|
const e = this.cache, n = this.json, s = [t.geometry.uuid];
|
|
4001
4080
|
if (Array.isArray(t.material))
|
|
4002
|
-
for (let
|
|
4003
|
-
s.push(t.material[
|
|
4081
|
+
for (let m = 0, S = t.material.length; m < S; m++)
|
|
4082
|
+
s.push(t.material[m].uuid);
|
|
4004
4083
|
else
|
|
4005
4084
|
s.push(t.material.uuid);
|
|
4006
4085
|
const i = s.join(":");
|
|
4007
4086
|
if (e.meshes.has(i)) return e.meshes.get(i);
|
|
4008
4087
|
const r = t.geometry;
|
|
4009
4088
|
let o;
|
|
4010
|
-
t.isLineSegments ? o =
|
|
4011
|
-
const a = {}, c = {}, l = [], h = [],
|
|
4089
|
+
t.isLineSegments ? o = b.LINES : t.isLineLoop ? o = b.LINE_LOOP : t.isLine ? o = b.LINE_STRIP : t.isPoints ? o = b.POINTS : o = t.material.wireframe ? b.LINES : b.TRIANGLES;
|
|
4090
|
+
const a = {}, c = {}, l = [], h = [], d = {
|
|
4012
4091
|
uv: "TEXCOORD_0",
|
|
4013
4092
|
uv1: "TEXCOORD_1",
|
|
4014
4093
|
uv2: "TEXCOORD_2",
|
|
@@ -4019,76 +4098,76 @@ class Ce {
|
|
|
4019
4098
|
}, f = r.getAttribute("normal");
|
|
4020
4099
|
f !== void 0 && !this.isNormalizedNormalAttribute(f) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(f)));
|
|
4021
4100
|
let p = null;
|
|
4022
|
-
for (let
|
|
4023
|
-
if (
|
|
4024
|
-
const S = r.attributes[
|
|
4025
|
-
if (
|
|
4026
|
-
c[
|
|
4101
|
+
for (let m in r.attributes) {
|
|
4102
|
+
if (m.slice(0, 5) === "morph") continue;
|
|
4103
|
+
const S = r.attributes[m];
|
|
4104
|
+
if (m = d[m] || m.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(m) || (m = "_" + m), e.attributes.has(this.getUID(S))) {
|
|
4105
|
+
c[m] = e.attributes.get(this.getUID(S));
|
|
4027
4106
|
continue;
|
|
4028
4107
|
}
|
|
4029
4108
|
p = null;
|
|
4030
|
-
const
|
|
4031
|
-
|
|
4032
|
-
const
|
|
4033
|
-
|
|
4109
|
+
const E = S.array;
|
|
4110
|
+
m === "JOINTS_0" && !(E instanceof Uint16Array) && !(E instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new _(new Uint16Array(E), S.itemSize, S.normalized)) : (E instanceof Uint32Array || E instanceof Int32Array) && !m.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${m}" converted to type FLOAT.`), p = st.Utils.toFloat32BufferAttribute(S));
|
|
4111
|
+
const A = this.processAccessor(p || S, r);
|
|
4112
|
+
A !== null && (m.startsWith("_") || this.detectMeshQuantization(m, S), c[m] = A, e.attributes.set(this.getUID(S), A));
|
|
4034
4113
|
}
|
|
4035
4114
|
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
4036
4115
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
4037
|
-
const
|
|
4116
|
+
const m = [], S = [], T = {};
|
|
4038
4117
|
if (t.morphTargetDictionary !== void 0)
|
|
4039
|
-
for (const
|
|
4040
|
-
|
|
4041
|
-
for (let
|
|
4042
|
-
const
|
|
4043
|
-
let
|
|
4044
|
-
for (const
|
|
4045
|
-
if (
|
|
4046
|
-
|
|
4118
|
+
for (const E in t.morphTargetDictionary)
|
|
4119
|
+
T[t.morphTargetDictionary[E]] = E;
|
|
4120
|
+
for (let E = 0; E < t.morphTargetInfluences.length; ++E) {
|
|
4121
|
+
const A = {};
|
|
4122
|
+
let v = !1;
|
|
4123
|
+
for (const C in r.morphAttributes) {
|
|
4124
|
+
if (C !== "position" && C !== "normal") {
|
|
4125
|
+
v || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), v = !0);
|
|
4047
4126
|
continue;
|
|
4048
4127
|
}
|
|
4049
|
-
const
|
|
4050
|
-
if (e.attributes.has(this.getUID(
|
|
4051
|
-
|
|
4128
|
+
const F = r.morphAttributes[C][E], N = C.toUpperCase(), j = r.attributes[C];
|
|
4129
|
+
if (e.attributes.has(this.getUID(F, !0))) {
|
|
4130
|
+
A[N] = e.attributes.get(this.getUID(F, !0));
|
|
4052
4131
|
continue;
|
|
4053
4132
|
}
|
|
4054
|
-
const O =
|
|
4133
|
+
const O = F.clone();
|
|
4055
4134
|
if (!r.morphTargetsRelative)
|
|
4056
|
-
for (let
|
|
4057
|
-
for (let
|
|
4058
|
-
|
|
4059
|
-
|
|
4135
|
+
for (let R = 0, V = F.count; R < V; R++)
|
|
4136
|
+
for (let G = 0; G < F.itemSize; G++)
|
|
4137
|
+
G === 0 && O.setX(R, F.getX(R) - j.getX(R)), G === 1 && O.setY(R, F.getY(R) - j.getY(R)), G === 2 && O.setZ(R, F.getZ(R) - j.getZ(R)), G === 3 && O.setW(R, F.getW(R) - j.getW(R));
|
|
4138
|
+
A[N] = this.processAccessor(O, r), e.attributes.set(this.getUID(j, !0), A[N]);
|
|
4060
4139
|
}
|
|
4061
|
-
h.push(
|
|
4140
|
+
h.push(A), m.push(t.morphTargetInfluences[E]), t.morphTargetDictionary !== void 0 && S.push(T[E]);
|
|
4062
4141
|
}
|
|
4063
|
-
a.weights =
|
|
4142
|
+
a.weights = m, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
4064
4143
|
}
|
|
4065
4144
|
const y = Array.isArray(t.material);
|
|
4066
4145
|
if (y && r.groups.length === 0) return null;
|
|
4067
4146
|
let x = !1;
|
|
4068
4147
|
if (y && r.index === null) {
|
|
4069
|
-
const
|
|
4070
|
-
for (let S = 0,
|
|
4071
|
-
|
|
4072
|
-
r.setIndex(
|
|
4148
|
+
const m = [];
|
|
4149
|
+
for (let S = 0, T = r.attributes.position.count; S < T; S++)
|
|
4150
|
+
m[S] = S;
|
|
4151
|
+
r.setIndex(m), x = !0;
|
|
4073
4152
|
}
|
|
4074
|
-
const
|
|
4075
|
-
for (let
|
|
4076
|
-
const
|
|
4153
|
+
const g = y ? t.material : [t.material], w = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
4154
|
+
for (let m = 0, S = w.length; m < S; m++) {
|
|
4155
|
+
const T = {
|
|
4077
4156
|
mode: o,
|
|
4078
4157
|
attributes: c
|
|
4079
4158
|
};
|
|
4080
|
-
if (this.serializeUserData(r,
|
|
4081
|
-
let
|
|
4082
|
-
(
|
|
4159
|
+
if (this.serializeUserData(r, T), h.length > 0 && (T.targets = h), r.index !== null) {
|
|
4160
|
+
let A = this.getUID(r.index);
|
|
4161
|
+
(w[m].start !== void 0 || w[m].count !== void 0) && (A += ":" + w[m].start + ":" + w[m].count), e.attributes.has(A) ? T.indices = e.attributes.get(A) : (T.indices = this.processAccessor(r.index, r, w[m].start, w[m].count), e.attributes.set(A, T.indices)), T.indices === null && delete T.indices;
|
|
4083
4162
|
}
|
|
4084
|
-
const
|
|
4085
|
-
|
|
4163
|
+
const E = await this.processMaterialAsync(g[w[m].materialIndex]);
|
|
4164
|
+
E !== null && (T.material = E), l.push(T);
|
|
4086
4165
|
}
|
|
4087
|
-
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(
|
|
4088
|
-
|
|
4166
|
+
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(m) {
|
|
4167
|
+
m.writeMesh && m.writeMesh(t, a);
|
|
4089
4168
|
});
|
|
4090
|
-
const
|
|
4091
|
-
return e.meshes.set(i,
|
|
4169
|
+
const D = n.meshes.push(a) - 1;
|
|
4170
|
+
return e.meshes.set(i, D), D;
|
|
4092
4171
|
}
|
|
4093
4172
|
/**
|
|
4094
4173
|
* If a vertex attribute with a
|
|
@@ -4102,7 +4181,7 @@ class Ce {
|
|
|
4102
4181
|
* @param {THREE.BufferAttribute} attribute
|
|
4103
4182
|
*/
|
|
4104
4183
|
detectMeshQuantization(t, e) {
|
|
4105
|
-
if (this.extensionsUsed[
|
|
4184
|
+
if (this.extensionsUsed[ot]) return;
|
|
4106
4185
|
let n;
|
|
4107
4186
|
switch (e.array.constructor) {
|
|
4108
4187
|
case Int8Array:
|
|
@@ -4122,7 +4201,7 @@ class Ce {
|
|
|
4122
4201
|
}
|
|
4123
4202
|
e.normalized && (n += " normalized");
|
|
4124
4203
|
const s = t.split("_", 1)[0];
|
|
4125
|
-
|
|
4204
|
+
Mt[s] && Mt[s].includes(n) && (this.extensionsUsed[ot] = !0, this.extensionsRequired[ot] = !0);
|
|
4126
4205
|
}
|
|
4127
4206
|
/**
|
|
4128
4207
|
* Process camera
|
|
@@ -4142,7 +4221,7 @@ class Ce {
|
|
|
4142
4221
|
znear: t.near < 0 ? 0 : t.near
|
|
4143
4222
|
} : s.perspective = {
|
|
4144
4223
|
aspectRatio: t.aspect,
|
|
4145
|
-
yfov:
|
|
4224
|
+
yfov: lt.degToRad(t.fov),
|
|
4146
4225
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4147
4226
|
znear: t.near < 0 ? 0 : t.near
|
|
4148
4227
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4159,28 +4238,28 @@ class Ce {
|
|
|
4159
4238
|
*/
|
|
4160
4239
|
processAnimation(t, e) {
|
|
4161
4240
|
const n = this.json, s = this.nodeMap;
|
|
4162
|
-
n.animations || (n.animations = []), t =
|
|
4241
|
+
n.animations || (n.animations = []), t = st.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4163
4242
|
const i = t.tracks, r = [], o = [];
|
|
4164
4243
|
for (let c = 0; c < i.length; ++c) {
|
|
4165
|
-
const l = i[c], h =
|
|
4166
|
-
let
|
|
4167
|
-
const f =
|
|
4168
|
-
if (h.objectName === "bones" && (
|
|
4244
|
+
const l = i[c], h = tt.parseTrackName(l.name);
|
|
4245
|
+
let d = tt.findNode(e, h.nodeName);
|
|
4246
|
+
const f = St[h.propertyName];
|
|
4247
|
+
if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !f) {
|
|
4169
4248
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4170
4249
|
continue;
|
|
4171
4250
|
}
|
|
4172
4251
|
const p = 1;
|
|
4173
4252
|
let y = l.values.length / l.times.length;
|
|
4174
|
-
f ===
|
|
4253
|
+
f === St.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
|
|
4175
4254
|
let x;
|
|
4176
|
-
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() ===
|
|
4177
|
-
input: this.processAccessor(new
|
|
4178
|
-
output: this.processAccessor(new
|
|
4255
|
+
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() === Xt ? x = "STEP" : x = "LINEAR", o.push({
|
|
4256
|
+
input: this.processAccessor(new _(l.times, p)),
|
|
4257
|
+
output: this.processAccessor(new _(l.values, y)),
|
|
4179
4258
|
interpolation: x
|
|
4180
4259
|
}), r.push({
|
|
4181
4260
|
sampler: o.length - 1,
|
|
4182
4261
|
target: {
|
|
4183
|
-
node: s.get(
|
|
4262
|
+
node: s.get(d),
|
|
4184
4263
|
path: f
|
|
4185
4264
|
}
|
|
4186
4265
|
});
|
|
@@ -4201,11 +4280,11 @@ class Ce {
|
|
|
4201
4280
|
if (i === void 0) return null;
|
|
4202
4281
|
const r = t.skeleton.bones[0];
|
|
4203
4282
|
if (r === void 0) return null;
|
|
4204
|
-
const o = [], a = new Float32Array(i.bones.length * 16), c = new
|
|
4283
|
+
const o = [], a = new Float32Array(i.bones.length * 16), c = new Tt();
|
|
4205
4284
|
for (let h = 0; h < i.bones.length; ++h)
|
|
4206
4285
|
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4207
4286
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
4208
|
-
inverseBindMatrices: this.processAccessor(new
|
|
4287
|
+
inverseBindMatrices: this.processAccessor(new _(a, 16)),
|
|
4209
4288
|
joints: o,
|
|
4210
4289
|
skeleton: n.get(r)
|
|
4211
4290
|
}), s.skin = e.skins.length - 1;
|
|
@@ -4223,7 +4302,7 @@ class Ce {
|
|
|
4223
4302
|
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4224
4303
|
H(o, [0, 0, 0, 1]) || (i.rotation = o), H(a, [0, 0, 0]) || (i.translation = a), H(c, [1, 1, 1]) || (i.scale = c);
|
|
4225
4304
|
} else
|
|
4226
|
-
t.matrixAutoUpdate && t.updateMatrix(),
|
|
4305
|
+
t.matrixAutoUpdate && t.updateMatrix(), Be(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4227
4306
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
4228
4307
|
const o = await this.processMeshAsync(t);
|
|
4229
4308
|
o !== null && (i.mesh = o);
|
|
@@ -4300,7 +4379,7 @@ class Ce {
|
|
|
4300
4379
|
await t(this.plugins[e]);
|
|
4301
4380
|
}
|
|
4302
4381
|
}
|
|
4303
|
-
class
|
|
4382
|
+
class je {
|
|
4304
4383
|
constructor(t) {
|
|
4305
4384
|
this.writer = t, this.name = "KHR_lights_punctual";
|
|
4306
4385
|
}
|
|
@@ -4316,7 +4395,7 @@ class Be {
|
|
|
4316
4395
|
o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
|
|
4317
4396
|
}
|
|
4318
4397
|
}
|
|
4319
|
-
class
|
|
4398
|
+
class Ge {
|
|
4320
4399
|
constructor(t) {
|
|
4321
4400
|
this.writer = t, this.name = "KHR_materials_unlit";
|
|
4322
4401
|
}
|
|
@@ -4326,7 +4405,7 @@ class Oe {
|
|
|
4326
4405
|
e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
4327
4406
|
}
|
|
4328
4407
|
}
|
|
4329
|
-
class
|
|
4408
|
+
class ze {
|
|
4330
4409
|
constructor(t) {
|
|
4331
4410
|
this.writer = t, this.name = "KHR_materials_clearcoat";
|
|
4332
4411
|
}
|
|
@@ -4357,7 +4436,7 @@ class Fe {
|
|
|
4357
4436
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4358
4437
|
}
|
|
4359
4438
|
}
|
|
4360
|
-
class
|
|
4439
|
+
class qe {
|
|
4361
4440
|
constructor(t) {
|
|
4362
4441
|
this.writer = t, this.name = "KHR_materials_dispersion";
|
|
4363
4442
|
}
|
|
@@ -4367,7 +4446,7 @@ class Ue {
|
|
|
4367
4446
|
i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4368
4447
|
}
|
|
4369
4448
|
}
|
|
4370
|
-
class
|
|
4449
|
+
class _e {
|
|
4371
4450
|
constructor(t) {
|
|
4372
4451
|
this.writer = t, this.name = "KHR_materials_iridescence";
|
|
4373
4452
|
}
|
|
@@ -4391,7 +4470,7 @@ class Ge {
|
|
|
4391
4470
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4392
4471
|
}
|
|
4393
4472
|
}
|
|
4394
|
-
class
|
|
4473
|
+
class Ye {
|
|
4395
4474
|
constructor(t) {
|
|
4396
4475
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4397
4476
|
}
|
|
@@ -4408,7 +4487,7 @@ class je {
|
|
|
4408
4487
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4409
4488
|
}
|
|
4410
4489
|
}
|
|
4411
|
-
class
|
|
4490
|
+
class ke {
|
|
4412
4491
|
constructor(t) {
|
|
4413
4492
|
this.writer = t, this.name = "KHR_materials_volume";
|
|
4414
4493
|
}
|
|
@@ -4425,7 +4504,7 @@ class ze {
|
|
|
4425
4504
|
t.attenuationDistance !== 1 / 0 && (i.attenuationDistance = t.attenuationDistance), i.attenuationColor = t.attenuationColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4426
4505
|
}
|
|
4427
4506
|
}
|
|
4428
|
-
class
|
|
4507
|
+
class Xe {
|
|
4429
4508
|
constructor(t) {
|
|
4430
4509
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
4431
4510
|
}
|
|
@@ -4435,12 +4514,12 @@ class qe {
|
|
|
4435
4514
|
i.ior = t.ior, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4436
4515
|
}
|
|
4437
4516
|
}
|
|
4438
|
-
class
|
|
4517
|
+
class Ve {
|
|
4439
4518
|
constructor(t) {
|
|
4440
4519
|
this.writer = t, this.name = "KHR_materials_specular";
|
|
4441
4520
|
}
|
|
4442
4521
|
async writeMaterialAsync(t, e) {
|
|
4443
|
-
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(
|
|
4522
|
+
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(Ie) && !t.specularIntensityMap && !t.specularColorMap) return;
|
|
4444
4523
|
const n = this.writer, s = n.extensionsUsed, i = {};
|
|
4445
4524
|
if (t.specularIntensityMap) {
|
|
4446
4525
|
const r = {
|
|
@@ -4459,7 +4538,7 @@ class _e {
|
|
|
4459
4538
|
i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4460
4539
|
}
|
|
4461
4540
|
}
|
|
4462
|
-
class
|
|
4541
|
+
class We {
|
|
4463
4542
|
constructor(t) {
|
|
4464
4543
|
this.writer = t, this.name = "KHR_materials_sheen";
|
|
4465
4544
|
}
|
|
@@ -4483,7 +4562,7 @@ class Ye {
|
|
|
4483
4562
|
i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4484
4563
|
}
|
|
4485
4564
|
}
|
|
4486
|
-
class
|
|
4565
|
+
class He {
|
|
4487
4566
|
constructor(t) {
|
|
4488
4567
|
this.writer = t, this.name = "KHR_materials_anisotropy";
|
|
4489
4568
|
}
|
|
@@ -4497,7 +4576,7 @@ class ke {
|
|
|
4497
4576
|
i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4498
4577
|
}
|
|
4499
4578
|
}
|
|
4500
|
-
class
|
|
4579
|
+
class Je {
|
|
4501
4580
|
constructor(t) {
|
|
4502
4581
|
this.writer = t, this.name = "KHR_materials_emissive_strength";
|
|
4503
4582
|
}
|
|
@@ -4507,7 +4586,7 @@ class Xe {
|
|
|
4507
4586
|
i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4508
4587
|
}
|
|
4509
4588
|
}
|
|
4510
|
-
class
|
|
4589
|
+
class $e {
|
|
4511
4590
|
constructor(t) {
|
|
4512
4591
|
this.writer = t, this.name = "EXT_materials_bump";
|
|
4513
4592
|
}
|
|
@@ -4524,54 +4603,54 @@ class Ve {
|
|
|
4524
4603
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4525
4604
|
}
|
|
4526
4605
|
}
|
|
4527
|
-
class
|
|
4606
|
+
class Ke {
|
|
4528
4607
|
constructor(t) {
|
|
4529
4608
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
4530
4609
|
}
|
|
4531
4610
|
writeNode(t, e) {
|
|
4532
4611
|
if (!t.isInstancedMesh) return;
|
|
4533
|
-
const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new
|
|
4612
|
+
const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Tt(), c = new Q(), l = new jt(), h = new Q();
|
|
4534
4613
|
for (let f = 0; f < s.count; f++)
|
|
4535
4614
|
s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
|
|
4536
|
-
const
|
|
4537
|
-
TRANSLATION: n.processAccessor(new
|
|
4538
|
-
ROTATION: n.processAccessor(new
|
|
4539
|
-
SCALE: n.processAccessor(new
|
|
4615
|
+
const d = {
|
|
4616
|
+
TRANSLATION: n.processAccessor(new _(i, 3)),
|
|
4617
|
+
ROTATION: n.processAccessor(new _(r, 4)),
|
|
4618
|
+
SCALE: n.processAccessor(new _(o, 3))
|
|
4540
4619
|
};
|
|
4541
|
-
s.instanceColor && (
|
|
4620
|
+
s.instanceColor && (d._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: d }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
|
|
4542
4621
|
}
|
|
4543
4622
|
}
|
|
4544
|
-
|
|
4545
|
-
insertKeyframe: function(
|
|
4546
|
-
const n =
|
|
4623
|
+
st.Utils = {
|
|
4624
|
+
insertKeyframe: function(u, t) {
|
|
4625
|
+
const n = u.getValueSize(), s = new u.TimeBufferType(u.times.length + 1), i = new u.ValueBufferType(u.values.length + n), r = u.createInterpolant(new u.ValueBufferType(n));
|
|
4547
4626
|
let o;
|
|
4548
|
-
if (
|
|
4627
|
+
if (u.times.length === 0) {
|
|
4549
4628
|
s[0] = t;
|
|
4550
4629
|
for (let a = 0; a < n; a++)
|
|
4551
4630
|
i[a] = 0;
|
|
4552
4631
|
o = 0;
|
|
4553
|
-
} else if (t <
|
|
4554
|
-
if (Math.abs(
|
|
4555
|
-
s[0] = t, s.set(
|
|
4556
|
-
} else if (t >
|
|
4557
|
-
if (Math.abs(
|
|
4558
|
-
return
|
|
4559
|
-
s[s.length - 1] = t, s.set(
|
|
4632
|
+
} else if (t < u.times[0]) {
|
|
4633
|
+
if (Math.abs(u.times[0] - t) < 1e-3) return 0;
|
|
4634
|
+
s[0] = t, s.set(u.times, 1), i.set(r.evaluate(t), 0), i.set(u.values, n), o = 0;
|
|
4635
|
+
} else if (t > u.times[u.times.length - 1]) {
|
|
4636
|
+
if (Math.abs(u.times[u.times.length - 1] - t) < 1e-3)
|
|
4637
|
+
return u.times.length - 1;
|
|
4638
|
+
s[s.length - 1] = t, s.set(u.times, 0), i.set(u.values, 0), i.set(r.evaluate(t), u.values.length), o = s.length - 1;
|
|
4560
4639
|
} else
|
|
4561
|
-
for (let a = 0; a <
|
|
4562
|
-
if (Math.abs(
|
|
4563
|
-
if (
|
|
4564
|
-
s.set(
|
|
4640
|
+
for (let a = 0; a < u.times.length; a++) {
|
|
4641
|
+
if (Math.abs(u.times[a] - t) < 1e-3) return a;
|
|
4642
|
+
if (u.times[a] < t && u.times[a + 1] > t) {
|
|
4643
|
+
s.set(u.times.slice(0, a + 1), 0), s[a + 1] = t, s.set(u.times.slice(a + 1), a + 2), i.set(u.values.slice(0, (a + 1) * n), 0), i.set(r.evaluate(t), (a + 1) * n), i.set(u.values.slice((a + 1) * n), (a + 2) * n), o = a + 1;
|
|
4565
4644
|
break;
|
|
4566
4645
|
}
|
|
4567
4646
|
}
|
|
4568
|
-
return
|
|
4647
|
+
return u.times = s, u.values = i, o;
|
|
4569
4648
|
},
|
|
4570
|
-
mergeMorphTargetTracks: function(
|
|
4571
|
-
const e = [], n = {}, s =
|
|
4649
|
+
mergeMorphTargetTracks: function(u, t) {
|
|
4650
|
+
const e = [], n = {}, s = u.tracks;
|
|
4572
4651
|
for (let i = 0; i < s.length; ++i) {
|
|
4573
4652
|
let r = s[i];
|
|
4574
|
-
const o =
|
|
4653
|
+
const o = tt.parseTrackName(r.name), a = tt.findNode(t, o.nodeName);
|
|
4575
4654
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
4576
4655
|
e.push(r);
|
|
4577
4656
|
continue;
|
|
@@ -4579,7 +4658,7 @@ et.Utils = {
|
|
|
4579
4658
|
if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
|
|
4580
4659
|
if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
4581
4660
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
4582
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(
|
|
4661
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(ne);
|
|
4583
4662
|
}
|
|
4584
4663
|
const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
|
|
4585
4664
|
if (l === void 0)
|
|
@@ -4593,67 +4672,67 @@ et.Utils = {
|
|
|
4593
4672
|
h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = f, n[a.uuid] = h, e.push(h);
|
|
4594
4673
|
continue;
|
|
4595
4674
|
}
|
|
4596
|
-
const
|
|
4675
|
+
const d = r.createInterpolant(new r.ValueBufferType(1));
|
|
4597
4676
|
h = n[a.uuid];
|
|
4598
4677
|
for (let f = 0; f < h.times.length; f++)
|
|
4599
|
-
h.values[f * c + l] =
|
|
4678
|
+
h.values[f * c + l] = d.evaluate(h.times[f]);
|
|
4600
4679
|
for (let f = 0; f < r.times.length; f++) {
|
|
4601
4680
|
const p = this.insertKeyframe(h, r.times[f]);
|
|
4602
4681
|
h.values[p * c + l] = r.values[f];
|
|
4603
4682
|
}
|
|
4604
4683
|
}
|
|
4605
|
-
return
|
|
4684
|
+
return u.tracks = e, u;
|
|
4606
4685
|
},
|
|
4607
|
-
toFloat32BufferAttribute: function(
|
|
4608
|
-
const t = new
|
|
4609
|
-
if (!
|
|
4610
|
-
return t.array.set(
|
|
4611
|
-
for (let e = 0, n =
|
|
4612
|
-
for (let s = 0; s <
|
|
4613
|
-
t.setComponent(e, s,
|
|
4686
|
+
toFloat32BufferAttribute: function(u) {
|
|
4687
|
+
const t = new _(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
|
|
4688
|
+
if (!u.normalized && !u.isInterleavedBufferAttribute)
|
|
4689
|
+
return t.array.set(u.array), t;
|
|
4690
|
+
for (let e = 0, n = u.count; e < n; e++)
|
|
4691
|
+
for (let s = 0; s < u.itemSize; s++)
|
|
4692
|
+
t.setComponent(e, s, u.getComponent(e, s));
|
|
4614
4693
|
return t;
|
|
4615
4694
|
}
|
|
4616
4695
|
};
|
|
4617
|
-
async function
|
|
4696
|
+
async function Ze(u) {
|
|
4618
4697
|
if (typeof FileReader > "u") {
|
|
4619
|
-
const t = await
|
|
4620
|
-
return `data:${
|
|
4698
|
+
const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
|
|
4699
|
+
return `data:${u.type};base64,${n}`;
|
|
4621
4700
|
} else
|
|
4622
4701
|
return new Promise((t, e) => {
|
|
4623
4702
|
const n = new FileReader();
|
|
4624
|
-
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(
|
|
4703
|
+
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(u);
|
|
4625
4704
|
});
|
|
4626
4705
|
}
|
|
4627
|
-
async function
|
|
4628
|
-
if (typeof
|
|
4629
|
-
return await
|
|
4706
|
+
async function ct(u) {
|
|
4707
|
+
if (typeof u.arrayBuffer == "function")
|
|
4708
|
+
return await u.arrayBuffer();
|
|
4630
4709
|
if (typeof FileReader < "u")
|
|
4631
4710
|
return new Promise((t, e) => {
|
|
4632
4711
|
const n = new FileReader();
|
|
4633
|
-
n.onload = () => t(n.result), n.onerror = () => e(n.error), n.readAsArrayBuffer(
|
|
4712
|
+
n.onload = () => t(n.result), n.onerror = () => e(n.error), n.readAsArrayBuffer(u);
|
|
4634
4713
|
});
|
|
4635
4714
|
{
|
|
4636
|
-
const t = Buffer.from(await
|
|
4715
|
+
const t = Buffer.from(await u.text());
|
|
4637
4716
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4638
4717
|
}
|
|
4639
4718
|
}
|
|
4640
|
-
const
|
|
4641
|
-
function
|
|
4642
|
-
const n = t.normal(
|
|
4719
|
+
const Qe = new se(), tn = new st();
|
|
4720
|
+
function en(u, t, e = 0.1) {
|
|
4721
|
+
const n = t.normal(u), s = t.direction(u).mutiplyScalar(e * 0.5), i = u.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
|
|
4643
4722
|
return {
|
|
4644
4723
|
points: [
|
|
4645
4724
|
// 第一条线
|
|
4646
|
-
new M(
|
|
4725
|
+
new M(u.x + r, u.y + o).add(i),
|
|
4647
4726
|
new M(t.x + r, t.y + o).add(s),
|
|
4648
4727
|
// 第二条线
|
|
4649
|
-
new M(
|
|
4728
|
+
new M(u.x - r, u.y - o).add(i),
|
|
4650
4729
|
new M(t.x - r, t.y - o).add(s)
|
|
4651
4730
|
],
|
|
4652
4731
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
4653
4732
|
rectIndices: [0, 1, 3, 2, 0]
|
|
4654
4733
|
};
|
|
4655
4734
|
}
|
|
4656
|
-
class Nt extends
|
|
4735
|
+
class Nt extends z {
|
|
4657
4736
|
static name = "WhiteModel";
|
|
4658
4737
|
Dxf = null;
|
|
4659
4738
|
Variable = null;
|
|
@@ -4683,7 +4762,7 @@ class Nt extends _ {
|
|
|
4683
4762
|
new I.LineSegments(new I.EdgesGeometry(i), new I.LineBasicMaterial({ color: 0 }))
|
|
4684
4763
|
);
|
|
4685
4764
|
}), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
4686
|
-
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } =
|
|
4765
|
+
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = en(r, o, t.width);
|
|
4687
4766
|
return {
|
|
4688
4767
|
points: a,
|
|
4689
4768
|
indices: c,
|
|
@@ -4716,7 +4795,7 @@ class Nt extends _ {
|
|
|
4716
4795
|
toOBJ() {
|
|
4717
4796
|
return new Promise((t) => {
|
|
4718
4797
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
4719
|
-
t(
|
|
4798
|
+
t(Qe.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4720
4799
|
}, 20);
|
|
4721
4800
|
});
|
|
4722
4801
|
}
|
|
@@ -4728,7 +4807,7 @@ class Nt extends _ {
|
|
|
4728
4807
|
toGltf(t = !0) {
|
|
4729
4808
|
return new Promise((e) => {
|
|
4730
4809
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
4731
|
-
|
|
4810
|
+
tn.parse(this.whiteModelGroup.children, (n) => {
|
|
4732
4811
|
e(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4733
4812
|
}, () => {
|
|
4734
4813
|
e(void 0);
|
|
@@ -4769,7 +4848,7 @@ class Nt extends _ {
|
|
|
4769
4848
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
4770
4849
|
} else if (typeof global < "u") {
|
|
4771
4850
|
const e = await this.toOBJ();
|
|
4772
|
-
e && (await
|
|
4851
|
+
e && (await X("fs", !1)).writeFileSync(t, e);
|
|
4773
4852
|
}
|
|
4774
4853
|
}
|
|
4775
4854
|
/**
|
|
@@ -4785,11 +4864,11 @@ class Nt extends _ {
|
|
|
4785
4864
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
4786
4865
|
} else if (typeof global < "u") {
|
|
4787
4866
|
const n = await this.toGltf(e);
|
|
4788
|
-
n && (await
|
|
4867
|
+
n && (await X("fs", !1)).writeFileSync(t, e ? Buffer.from(n) : JSON.stringify(n));
|
|
4789
4868
|
}
|
|
4790
4869
|
}
|
|
4791
4870
|
}
|
|
4792
|
-
class
|
|
4871
|
+
class Bt extends z {
|
|
4793
4872
|
static name = "DetailsPoint";
|
|
4794
4873
|
Dxf = null;
|
|
4795
4874
|
WhiteModel = null;
|
|
@@ -4866,7 +4945,7 @@ class Ct extends _ {
|
|
|
4866
4945
|
}, 50);
|
|
4867
4946
|
}
|
|
4868
4947
|
}
|
|
4869
|
-
class
|
|
4948
|
+
class Ot extends z {
|
|
4870
4949
|
static name = "DxfLineModel";
|
|
4871
4950
|
dxfLineModel = new I.LineSegments();
|
|
4872
4951
|
dxfDoorsLineModel = new I.LineSegments();
|
|
@@ -4889,38 +4968,38 @@ class Bt extends _ {
|
|
|
4889
4968
|
});
|
|
4890
4969
|
}
|
|
4891
4970
|
}
|
|
4892
|
-
const
|
|
4971
|
+
const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4893
4972
|
__proto__: null,
|
|
4894
|
-
DetailsPoint:
|
|
4895
|
-
DxfLineModel:
|
|
4973
|
+
DetailsPoint: Bt,
|
|
4974
|
+
DxfLineModel: Ot,
|
|
4896
4975
|
WhiteModel: Nt
|
|
4897
4976
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4898
|
-
function
|
|
4977
|
+
function At(u, t = {}) {
|
|
4899
4978
|
const {
|
|
4900
4979
|
detailsPoint: e = !0,
|
|
4901
4980
|
whiteModel: n = !0,
|
|
4902
4981
|
dxfLineModel: s = !0
|
|
4903
4982
|
} = t;
|
|
4904
|
-
s &&
|
|
4983
|
+
s && u.addComponent(new Ot()), n && u.addComponent(new Nt()), e && u.addComponent(new Bt());
|
|
4905
4984
|
}
|
|
4906
|
-
const
|
|
4907
|
-
create(
|
|
4908
|
-
return (t) =>
|
|
4985
|
+
const sn = Object.assign(At, {
|
|
4986
|
+
create(u = {}) {
|
|
4987
|
+
return (t) => At(t, u);
|
|
4909
4988
|
}
|
|
4910
|
-
}),
|
|
4989
|
+
}), rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4911
4990
|
__proto__: null,
|
|
4912
|
-
ModelDataPlugin:
|
|
4913
|
-
components:
|
|
4991
|
+
ModelDataPlugin: sn,
|
|
4992
|
+
components: nn
|
|
4914
4993
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4915
|
-
function
|
|
4994
|
+
function on() {
|
|
4916
4995
|
return import("./index2.js");
|
|
4917
4996
|
}
|
|
4918
|
-
function
|
|
4997
|
+
function an() {
|
|
4919
4998
|
return import("./index3.js");
|
|
4920
4999
|
}
|
|
4921
5000
|
let dt = null;
|
|
4922
|
-
async function
|
|
4923
|
-
const s = await Promise.resolve().then(() =>
|
|
5001
|
+
async function pn(u, t, e = !1, n) {
|
|
5002
|
+
const s = await Promise.resolve().then(() => rn), i = await on(), r = await an(), o = new $().usePlugin(s.ModelDataPlugin.create({
|
|
4924
5003
|
detailsPoint: !1,
|
|
4925
5004
|
whiteModel: !0
|
|
4926
5005
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4930,13 +5009,13 @@ async function hn(d, t, e = !1, n) {
|
|
|
4930
5009
|
orbitControls: e,
|
|
4931
5010
|
camera: t
|
|
4932
5011
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4933
|
-
return a &&
|
|
5012
|
+
return a && u.appendChild(a.domElement), dt = o, {
|
|
4934
5013
|
dxfSystem: o,
|
|
4935
|
-
getFileAll: () =>
|
|
5014
|
+
getFileAll: () => cn(o)
|
|
4936
5015
|
};
|
|
4937
5016
|
}
|
|
4938
|
-
async function
|
|
4939
|
-
const t =
|
|
5017
|
+
async function cn(u = dt) {
|
|
5018
|
+
const t = u.findComponentByName("WhiteModel"), e = new File([await u.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([u.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([u.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(u.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
4940
5019
|
return {
|
|
4941
5020
|
dxf: n,
|
|
4942
5021
|
obj: i,
|
|
@@ -4947,31 +5026,31 @@ async function sn(d = dt) {
|
|
|
4947
5026
|
correctionDxf: s
|
|
4948
5027
|
};
|
|
4949
5028
|
}
|
|
4950
|
-
function
|
|
5029
|
+
function yn() {
|
|
4951
5030
|
return dt;
|
|
4952
5031
|
}
|
|
4953
5032
|
export {
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5033
|
+
It as A,
|
|
5034
|
+
P as B,
|
|
5035
|
+
z as C,
|
|
5036
|
+
$ as D,
|
|
5037
|
+
bt as E,
|
|
5038
|
+
L,
|
|
5039
|
+
sn as M,
|
|
4961
5040
|
M as P,
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
5041
|
+
B as Q,
|
|
5042
|
+
be as T,
|
|
5043
|
+
Pt as V,
|
|
4965
5044
|
Nt as W,
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
5045
|
+
Bt as a,
|
|
5046
|
+
k as b,
|
|
5047
|
+
Te as c,
|
|
5048
|
+
pn as d,
|
|
5049
|
+
yn as e,
|
|
5050
|
+
Y as f,
|
|
5051
|
+
cn as g,
|
|
5052
|
+
fn as h,
|
|
5053
|
+
nn as i,
|
|
5054
|
+
nt as r,
|
|
5055
|
+
Z as u
|
|
4977
5056
|
};
|