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