build-dxf 0.0.39 → 0.0.41
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/README.md +26 -24
- package/package.json +1 -1
- package/src/build.js +561 -566
- package/src/index.css +1 -1
- package/src/index3.js +377 -378
- package/src/utils/CommandManager/CommandManager.d.ts +1 -0
- package/src/utils/DxfSystem/components/Dxf.d.ts +11 -2
- package/src/utils/DxfSystem/utils/originalDataToLineData.d.ts +7 -0
- package/src/utils/Quadtree/LineSegment.d.ts +1 -0
package/src/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as I from "three";
|
|
2
|
-
import { EventDispatcher as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { OBJExporter as
|
|
6
|
-
function
|
|
2
|
+
import { EventDispatcher as Ot, Color as Ft, Matrix4 as bt, Vector3 as K, Quaternion as Gt, BufferAttribute as _, REVISION as Ut, CompressedTexture as nt, Source as zt, NoColorSpace as jt, MathUtils as ot, RGBAFormat as _t, ImageUtils as qt, DoubleSide as Yt, PropertyBinding as Z, InterpolateDiscrete as kt, Scene as ft, SRGBColorSpace as Vt, NearestFilter as Xt, NearestMipmapNearestFilter as Wt, NearestMipmapLinearFilter as Ht, LinearFilter as Jt, LinearMipmapNearestFilter as $t, LinearMipmapLinearFilter as Kt, ClampToEdgeWrapping as Zt, RepeatWrapping as Qt, MirroredRepeatWrapping as te, InterpolateLinear as ee } from "three";
|
|
3
|
+
import pt from "clipper-lib";
|
|
4
|
+
import $ from "dxf-writer";
|
|
5
|
+
import { OBJExporter as ne } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
+
function at() {
|
|
7
7
|
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(d) {
|
|
8
8
|
var t = Math.random() * 16 | 0, e = d == "x" ? t : t & 3 | 8;
|
|
9
9
|
return e.toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
class
|
|
13
|
-
uuid =
|
|
12
|
+
class It extends Ot {
|
|
13
|
+
uuid = at();
|
|
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 At extends Bt {
|
|
|
30
30
|
e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class q extends
|
|
33
|
+
class q extends It {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...t) {
|
|
@@ -48,7 +48,7 @@ class q extends At {
|
|
|
48
48
|
this.destroyed = !0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
class se extends It {
|
|
52
52
|
static EventType = {
|
|
53
53
|
ADD_COMPONENT: "addComponent"
|
|
54
54
|
};
|
|
@@ -116,7 +116,7 @@ class ne extends At {
|
|
|
116
116
|
return e || null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class N {
|
|
120
120
|
minX = 0;
|
|
121
121
|
maxX = 0;
|
|
122
122
|
minY = 0;
|
|
@@ -203,8 +203,8 @@ class R {
|
|
|
203
203
|
for (let c = 0; c < 4; c++) {
|
|
204
204
|
const l = o[c], h = o[(c + 1) % 4];
|
|
205
205
|
for (let u = 0; u < 4; u++) {
|
|
206
|
-
const f = e[u], p = e[(u + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x),
|
|
207
|
-
if (y * x < 0 &&
|
|
206
|
+
const f = e[u], p = e[(u + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), m = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), L = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
|
|
207
|
+
if (y * x < 0 && m * L < 0 || y === 0 && Math.min(l.x, h.x) <= f.x && f.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= f.y && f.y <= Math.max(l.y, h.y) || x === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || m === 0 && Math.min(f.x, p.x) <= l.x && l.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= l.y && l.y <= Math.max(f.y, p.y) || L === 0 && Math.min(f.x, p.x) <= h.x && h.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= h.y && h.y <= Math.max(f.y, p.y))
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -299,7 +299,7 @@ class R {
|
|
|
299
299
|
* @returns
|
|
300
300
|
*/
|
|
301
301
|
clone() {
|
|
302
|
-
return new
|
|
302
|
+
return new N(this.minX, this.maxX, this.minY, this.maxY);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
*
|
|
@@ -310,7 +310,7 @@ class R {
|
|
|
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 N(
|
|
314
314
|
Math.min(...e),
|
|
315
315
|
Math.max(...e),
|
|
316
316
|
Math.min(...n),
|
|
@@ -328,7 +328,7 @@ class R {
|
|
|
328
328
|
s?.points?.forEach((i) => {
|
|
329
329
|
e.push(i.x), n.push(i.y);
|
|
330
330
|
});
|
|
331
|
-
}), new
|
|
331
|
+
}), new N(
|
|
332
332
|
Math.min(...e),
|
|
333
333
|
Math.max(...e),
|
|
334
334
|
Math.min(...n),
|
|
@@ -415,7 +415,7 @@ class X {
|
|
|
415
415
|
* @returns 相交的节点数组
|
|
416
416
|
*/
|
|
417
417
|
queryCircle(t, e) {
|
|
418
|
-
const n = new
|
|
418
|
+
const n = new N(t.x - e, t.x + e, t.y - e, t.y + e), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
|
|
419
419
|
for (let c = s; c <= i; c++)
|
|
420
420
|
for (let l = r; l <= o; l++) {
|
|
421
421
|
const h = `${c}.${l}`;
|
|
@@ -465,7 +465,7 @@ class X {
|
|
|
465
465
|
return null;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
class
|
|
468
|
+
class et {
|
|
469
469
|
points;
|
|
470
470
|
get p0() {
|
|
471
471
|
return this.points[0];
|
|
@@ -606,7 +606,7 @@ class Q {
|
|
|
606
606
|
let t = 1 / 0, e = -1 / 0, n = 1 / 0, s = -1 / 0;
|
|
607
607
|
return this.points.forEach((i) => {
|
|
608
608
|
e = Math.max(i.x, e), t = Math.min(i.x, t), s = Math.max(i.x, s), n = Math.min(i.x, n);
|
|
609
|
-
}), new
|
|
609
|
+
}), new N(t, e, n, s);
|
|
610
610
|
}
|
|
611
611
|
/**
|
|
612
612
|
*
|
|
@@ -616,7 +616,7 @@ class Q {
|
|
|
616
616
|
*/
|
|
617
617
|
static fromByLineSegment(t, e = 0.1, n = !1, s = 0.5) {
|
|
618
618
|
const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : M.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : M.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
|
|
619
|
-
return new
|
|
619
|
+
return new et([
|
|
620
620
|
new M(i.x + l, i.y + h).add(c),
|
|
621
621
|
new M(r.x + l, r.y + h).add(a),
|
|
622
622
|
new M(r.x - l, r.y - h).add(a),
|
|
@@ -624,7 +624,7 @@ class Q {
|
|
|
624
624
|
]);
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
-
class
|
|
627
|
+
class A {
|
|
628
628
|
points = [new M(), new M()];
|
|
629
629
|
userData = {};
|
|
630
630
|
// line: any
|
|
@@ -646,6 +646,9 @@ class D {
|
|
|
646
646
|
set(t, e) {
|
|
647
647
|
return this.start.copy(t), this.end.copy(e), this;
|
|
648
648
|
}
|
|
649
|
+
getAnotherPoint(t) {
|
|
650
|
+
return t === this.start ? this.end : this.start;
|
|
651
|
+
}
|
|
649
652
|
/**
|
|
650
653
|
* 是否有相同端点
|
|
651
654
|
* @param line
|
|
@@ -734,7 +737,7 @@ class D {
|
|
|
734
737
|
new M(n.x - a, n.y - c).add(o),
|
|
735
738
|
new M(s.x - a, s.y - c).add(r)
|
|
736
739
|
];
|
|
737
|
-
return new
|
|
740
|
+
return new et([0, 1, 3, 2].map((h) => l[h]));
|
|
738
741
|
}
|
|
739
742
|
/**
|
|
740
743
|
* 计算线段的长度
|
|
@@ -775,8 +778,8 @@ class D {
|
|
|
775
778
|
if (r.x === 0 && r.y === 0)
|
|
776
779
|
throw new Error("投影目标线段的两个点不能重合");
|
|
777
780
|
const o = (p) => {
|
|
778
|
-
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y,
|
|
779
|
-
return new M(
|
|
781
|
+
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, L = (y.x * r.x + y.y * r.y) / x, w = s.x + L * r.x, g = s.y + L * r.y;
|
|
782
|
+
return new M(w, g);
|
|
780
783
|
};
|
|
781
784
|
let a = o(e), c = o(n);
|
|
782
785
|
const l = (p) => {
|
|
@@ -785,10 +788,10 @@ class D {
|
|
|
785
788
|
};
|
|
786
789
|
let h = l(a), u = l(c);
|
|
787
790
|
const f = (p) => {
|
|
788
|
-
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x,
|
|
789
|
-
return new M(x,
|
|
791
|
+
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, m = s.y + y * r.y;
|
|
792
|
+
return new M(x, m);
|
|
790
793
|
};
|
|
791
|
-
return (h < 0 || h > 1) && (a = f(h)), (u < 0 || u > 1) && (c = f(u)), a.x === c.x && a.y === c.y ? new
|
|
794
|
+
return (h < 0 || h > 1) && (a = f(h)), (u < 0 || u > 1) && (c = f(u)), a.x === c.x && a.y === c.y ? new A(a, a) : new A(a, c);
|
|
792
795
|
}
|
|
793
796
|
/**
|
|
794
797
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -869,7 +872,7 @@ class D {
|
|
|
869
872
|
* @param line
|
|
870
873
|
*/
|
|
871
874
|
parallel(t, e = 1) {
|
|
872
|
-
return t instanceof
|
|
875
|
+
return t instanceof A ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
|
|
873
876
|
}
|
|
874
877
|
/** 两条线段或角度是否 垂直
|
|
875
878
|
* @param line
|
|
@@ -877,7 +880,7 @@ class D {
|
|
|
877
880
|
* @returns
|
|
878
881
|
*/
|
|
879
882
|
vertical(t, e = 0.1) {
|
|
880
|
-
return t instanceof
|
|
883
|
+
return t instanceof A ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
|
|
881
884
|
}
|
|
882
885
|
/**
|
|
883
886
|
* 两条线段方向相反否一致
|
|
@@ -952,7 +955,7 @@ class D {
|
|
|
952
955
|
* @returns
|
|
953
956
|
*/
|
|
954
957
|
clone() {
|
|
955
|
-
const t = new
|
|
958
|
+
const t = new A(
|
|
956
959
|
this.points[0].clone(),
|
|
957
960
|
this.points[1].clone()
|
|
958
961
|
);
|
|
@@ -1007,7 +1010,7 @@ class D {
|
|
|
1007
1010
|
const f = o(u);
|
|
1008
1011
|
f < a && (a = f, i = n.projectPoint(u, !1)), f > c && (c = f, r = n.projectPoint(u, !1));
|
|
1009
1012
|
}
|
|
1010
|
-
const l = new
|
|
1013
|
+
const l = new A(i, r);
|
|
1011
1014
|
return t.forEach((h) => h.userData.fittedLine = l), l;
|
|
1012
1015
|
}
|
|
1013
1016
|
/** 合并平行线段
|
|
@@ -1026,7 +1029,7 @@ class D {
|
|
|
1026
1029
|
const y = p.x * s.x + p.y * s.y;
|
|
1027
1030
|
i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
|
|
1028
1031
|
});
|
|
1029
|
-
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y), u = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new
|
|
1032
|
+
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y), u = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new A(h, u);
|
|
1030
1033
|
return t.forEach((p) => p.userData.fittedLine = f), f;
|
|
1031
1034
|
}
|
|
1032
1035
|
/** 合并满足平行的线段
|
|
@@ -1191,7 +1194,7 @@ class M {
|
|
|
1191
1194
|
* @param length
|
|
1192
1195
|
*/
|
|
1193
1196
|
expandAsLine(t, e, n) {
|
|
1194
|
-
const s = new
|
|
1197
|
+
const s = new A(
|
|
1195
1198
|
this.clone(),
|
|
1196
1199
|
this.clone().add(t.clone().multiplyScalar(e))
|
|
1197
1200
|
);
|
|
@@ -1313,7 +1316,7 @@ class F {
|
|
|
1313
1316
|
* @param node 线段节点
|
|
1314
1317
|
*/
|
|
1315
1318
|
insert(t) {
|
|
1316
|
-
if (t instanceof
|
|
1319
|
+
if (t instanceof A) {
|
|
1317
1320
|
this.insert({ line: t, userData: {} });
|
|
1318
1321
|
return;
|
|
1319
1322
|
}
|
|
@@ -1338,7 +1341,7 @@ class F {
|
|
|
1338
1341
|
* @param node
|
|
1339
1342
|
*/
|
|
1340
1343
|
remove(t) {
|
|
1341
|
-
if (t instanceof
|
|
1344
|
+
if (t instanceof A) {
|
|
1342
1345
|
t = this.targetMap.get(t), t && this.remove(t);
|
|
1343
1346
|
return;
|
|
1344
1347
|
}
|
|
@@ -1369,25 +1372,25 @@ class F {
|
|
|
1369
1372
|
this.isLeaf = !1, this.children = [];
|
|
1370
1373
|
const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
|
|
1371
1374
|
this.children[0] = new F(
|
|
1372
|
-
new
|
|
1375
|
+
new N(this.bounds.minX, t, this.bounds.minY, e),
|
|
1373
1376
|
this.capacity,
|
|
1374
1377
|
this.maxDepth,
|
|
1375
1378
|
this.depth + 1,
|
|
1376
1379
|
this.targetMap
|
|
1377
1380
|
), this.children[1] = new F(
|
|
1378
|
-
new
|
|
1381
|
+
new N(t, this.bounds.maxX, this.bounds.minY, e),
|
|
1379
1382
|
this.capacity,
|
|
1380
1383
|
this.maxDepth,
|
|
1381
1384
|
this.depth + 1,
|
|
1382
1385
|
this.targetMap
|
|
1383
1386
|
), this.children[2] = new F(
|
|
1384
|
-
new
|
|
1387
|
+
new N(this.bounds.minX, t, e, this.bounds.maxY),
|
|
1385
1388
|
this.capacity,
|
|
1386
1389
|
this.maxDepth,
|
|
1387
1390
|
this.depth + 1,
|
|
1388
1391
|
this.targetMap
|
|
1389
1392
|
), this.children[3] = new F(
|
|
1390
|
-
new
|
|
1393
|
+
new N(t, this.bounds.maxX, e, this.bounds.maxY),
|
|
1391
1394
|
this.capacity,
|
|
1392
1395
|
this.maxDepth,
|
|
1393
1396
|
this.depth + 1,
|
|
@@ -1417,7 +1420,7 @@ class F {
|
|
|
1417
1420
|
* @returns 相交的节点数组
|
|
1418
1421
|
*/
|
|
1419
1422
|
queryCircle(t, e) {
|
|
1420
|
-
const n = [], s = new
|
|
1423
|
+
const n = [], s = new N(
|
|
1421
1424
|
t.x - e,
|
|
1422
1425
|
t.x + e,
|
|
1423
1426
|
t.y - e,
|
|
@@ -1498,8 +1501,8 @@ class F {
|
|
|
1498
1501
|
})), t;
|
|
1499
1502
|
}
|
|
1500
1503
|
}
|
|
1501
|
-
function
|
|
1502
|
-
return e || (e = new F(
|
|
1504
|
+
function J(d, t = 0, e) {
|
|
1505
|
+
return e || (e = new F(N.fromByLineSegment(...d)), d.forEach((n) => e?.insert({ line: n, userData: void 0 }))), d.map((n) => {
|
|
1503
1506
|
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: d.indexOf(o.line) }));
|
|
1504
1507
|
return {
|
|
1505
1508
|
start: n.start.toJson(t),
|
|
@@ -1520,8 +1523,8 @@ function K(d, t = 0, e) {
|
|
|
1520
1523
|
};
|
|
1521
1524
|
});
|
|
1522
1525
|
}
|
|
1523
|
-
function
|
|
1524
|
-
const e = new F(
|
|
1526
|
+
function lt(d, t = 0.03) {
|
|
1527
|
+
const e = new F(N.fromByLineSegment(...d));
|
|
1525
1528
|
return d.forEach((n) => e.insert({ line: n, userData: void 0 })), d.flatMap((n) => {
|
|
1526
1529
|
const s = e.queryLineSegment(n, !0).map((i) => {
|
|
1527
1530
|
if (i.line === n) return;
|
|
@@ -1541,45 +1544,35 @@ function at(d, t = 0.03) {
|
|
|
1541
1544
|
return n;
|
|
1542
1545
|
}).filter((n) => n.length() >= t);
|
|
1543
1546
|
}
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
const f = r.distance(c.point);
|
|
1560
|
-
return f < 1e-3 ? !1 : (i.set(c.point, f), !0);
|
|
1561
|
-
}).sort((c, l) => {
|
|
1562
|
-
const h = i.get(c.point), u = i.get(l.point);
|
|
1563
|
-
return h - u;
|
|
1564
|
-
});
|
|
1565
|
-
if (o.length === 0) return;
|
|
1566
|
-
const a = o[0].userData;
|
|
1567
|
-
e.push(new D(s.projectLineSegment(a).center, a.projectLineSegment(s).center));
|
|
1547
|
+
function Q(...d) {
|
|
1548
|
+
d.forEach((t) => {
|
|
1549
|
+
const e = t.direction();
|
|
1550
|
+
t.userData.drawWindow?.forEach((n) => {
|
|
1551
|
+
try {
|
|
1552
|
+
const s = M.from(n.p), i = t.projectPoint(
|
|
1553
|
+
s.clone().add(e.clone().multiplyScalar(n.width * 0.5)),
|
|
1554
|
+
!1
|
|
1555
|
+
), r = t.projectPoint(
|
|
1556
|
+
s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
|
|
1557
|
+
!1
|
|
1558
|
+
), o = t.projectLineSegment(new A(i, r)), a = o.center;
|
|
1559
|
+
n.p = new I.Vector3(a?.x ?? 0, a?.y ?? 0, n.p.z);
|
|
1560
|
+
} catch {
|
|
1561
|
+
}
|
|
1568
1562
|
});
|
|
1569
|
-
}
|
|
1570
|
-
return [...d, ...e];
|
|
1563
|
+
});
|
|
1571
1564
|
}
|
|
1572
1565
|
function ie(d) {
|
|
1573
|
-
const t = new X(), e = new F(
|
|
1566
|
+
const t = new X(), e = new F(N.fromByLineSegment(...d)), n = [];
|
|
1574
1567
|
return d.forEach((s) => {
|
|
1575
1568
|
s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert({ line: s, userData: void 0 }));
|
|
1576
1569
|
}), n.forEach((s) => {
|
|
1577
1570
|
const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
|
|
1578
1571
|
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;
|
|
1579
|
-
}), d
|
|
1572
|
+
}), d;
|
|
1580
1573
|
}
|
|
1581
1574
|
function re(d) {
|
|
1582
|
-
const t = new F(
|
|
1575
|
+
const t = new F(N.fromByLineSegment(...d));
|
|
1583
1576
|
d.forEach((n) => {
|
|
1584
1577
|
n.userData.isDoor || t.insert({ line: n, userData: void 0 });
|
|
1585
1578
|
});
|
|
@@ -1598,7 +1591,7 @@ function re(d) {
|
|
|
1598
1591
|
}
|
|
1599
1592
|
return e;
|
|
1600
1593
|
}
|
|
1601
|
-
function oe(d, t, e, n =
|
|
1594
|
+
function oe(d, t, e, n = 15) {
|
|
1602
1595
|
const s = [d], i = [], r = [], o = [];
|
|
1603
1596
|
function a(u) {
|
|
1604
1597
|
const f = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
|
|
@@ -1615,8 +1608,8 @@ function oe(d, t, e, n = 25) {
|
|
|
1615
1608
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1616
1609
|
for (; x > Math.PI; ) x -= 2 * Math.PI;
|
|
1617
1610
|
for (; x < -Math.PI; ) x += 2 * Math.PI;
|
|
1618
|
-
const
|
|
1619
|
-
return u.start.rotate(
|
|
1611
|
+
const m = Math.abs(y) < Math.abs(x) ? y : x, L = u.center;
|
|
1612
|
+
return u.start.rotate(L, m), u.end.rotate(L, m), u.userData.isDoor ? r.push(u) : i.push(u), u;
|
|
1620
1613
|
}
|
|
1621
1614
|
function l(u, f, p = !1) {
|
|
1622
1615
|
if (p) return l(u === "parallel" ? "vertical" : "parallel", f);
|
|
@@ -1629,17 +1622,17 @@ function oe(d, t, e, n = 25) {
|
|
|
1629
1622
|
if (f.userData.isWindow && o.push(f), f.parallel(d, n)) a(f);
|
|
1630
1623
|
else if (f.vertical(d, n)) c(f);
|
|
1631
1624
|
else {
|
|
1632
|
-
const y = e.get(f)?.reduce((x,
|
|
1625
|
+
const y = e.get(f)?.reduce((x, m) => (m.sourcePoint && (x.has(m.sourcePoint) || x.set(m.sourcePoint, []), x.get(m.sourcePoint)?.push(m)), x), /* @__PURE__ */ new Map());
|
|
1633
1626
|
y && y.size > 1 ? h.push(() => {
|
|
1634
1627
|
const x = [...y.values()].map(
|
|
1635
|
-
(
|
|
1636
|
-
).map((
|
|
1637
|
-
if (
|
|
1638
|
-
if (
|
|
1639
|
-
if (
|
|
1640
|
-
if (
|
|
1641
|
-
if (
|
|
1642
|
-
return l(
|
|
1628
|
+
(w) => w.map((g) => s.includes(g.line) ? "parallel" : i.includes(g.line) ? "vertical" : null).filter((g) => !!g)
|
|
1629
|
+
).map((w) => [...new Set(w)]), m = x[0], L = x[1];
|
|
1630
|
+
if (m.length === 1 && L.length === 1) {
|
|
1631
|
+
if (m[0] === L[0]) return l(m[0], f, !0);
|
|
1632
|
+
if (m.length === 1) {
|
|
1633
|
+
if (L.includes(m[0])) return l(m[0], f, !0);
|
|
1634
|
+
if (L.length === 1 && m.includes(L[0]))
|
|
1635
|
+
return l(L[0], f, !0);
|
|
1643
1636
|
}
|
|
1644
1637
|
}
|
|
1645
1638
|
c(f);
|
|
@@ -1648,7 +1641,7 @@ function oe(d, t, e, n = 25) {
|
|
|
1648
1641
|
}
|
|
1649
1642
|
return h.forEach((u) => u()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
|
|
1650
1643
|
}
|
|
1651
|
-
function
|
|
1644
|
+
function yt(d, t, e, n, s) {
|
|
1652
1645
|
const i = [], r = /* @__PURE__ */ new Map();
|
|
1653
1646
|
d.forEach((c) => {
|
|
1654
1647
|
const l = e.projectPoint(c.start, !1);
|
|
@@ -1667,8 +1660,8 @@ function ft(d, t, e, n, s) {
|
|
|
1667
1660
|
const l = c.flatMap((p) => {
|
|
1668
1661
|
const y = p.userData;
|
|
1669
1662
|
return y.points.map((x) => {
|
|
1670
|
-
const
|
|
1671
|
-
return
|
|
1663
|
+
const m = t.projectPoint(x, !1);
|
|
1664
|
+
return m.userData = y, m;
|
|
1672
1665
|
});
|
|
1673
1666
|
});
|
|
1674
1667
|
l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
|
|
@@ -1681,7 +1674,7 @@ function ft(d, t, e, n, s) {
|
|
|
1681
1674
|
}), f.push([...u]), f;
|
|
1682
1675
|
});
|
|
1683
1676
|
}
|
|
1684
|
-
function
|
|
1677
|
+
function xt(d, t, e, n) {
|
|
1685
1678
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
|
|
1686
1679
|
d.forEach((u) => {
|
|
1687
1680
|
const f = e.projectPoint(u.start, !1);
|
|
@@ -1691,23 +1684,23 @@ function pt(d, t, e, n) {
|
|
|
1691
1684
|
});
|
|
1692
1685
|
}), o.sort((u, f) => f.distance(e.start) - u.distance(e.start));
|
|
1693
1686
|
const a = o.map((u) => {
|
|
1694
|
-
const f = u.userData, p = i.get(f), y = r.get(f), x = new
|
|
1695
|
-
for (let
|
|
1696
|
-
const
|
|
1697
|
-
if (u !==
|
|
1698
|
-
const
|
|
1699
|
-
(x.isPointOnSegment(S) || x.isPointOnSegment(
|
|
1687
|
+
const f = u.userData, p = i.get(f), y = r.get(f), x = new A(p, y), m = [];
|
|
1688
|
+
for (let L = 0; L < o.length; L++) {
|
|
1689
|
+
const w = o[L];
|
|
1690
|
+
if (u !== w && u.distance(w) < n) {
|
|
1691
|
+
const g = w.userData, S = i.get(g), D = r.get(g);
|
|
1692
|
+
(x.isPointOnSegment(S) || x.isPointOnSegment(D)) && m.push(L);
|
|
1700
1693
|
}
|
|
1701
1694
|
}
|
|
1702
|
-
return
|
|
1695
|
+
return m;
|
|
1703
1696
|
});
|
|
1704
1697
|
function c(u, f, p = /* @__PURE__ */ new Set()) {
|
|
1705
1698
|
if (p.has(u)) return p;
|
|
1706
1699
|
const y = f[u];
|
|
1707
1700
|
p.add(u);
|
|
1708
1701
|
for (let x = 0; x < y.length; x++) {
|
|
1709
|
-
const
|
|
1710
|
-
c(
|
|
1702
|
+
const m = y[x];
|
|
1703
|
+
c(m, f, p);
|
|
1711
1704
|
}
|
|
1712
1705
|
return p;
|
|
1713
1706
|
}
|
|
@@ -1718,20 +1711,20 @@ function pt(d, t, e, n) {
|
|
|
1718
1711
|
if (f.forEach((y) => {
|
|
1719
1712
|
l.add(y), p.push(o[y].userData);
|
|
1720
1713
|
}), p.length > 2) {
|
|
1721
|
-
const y = p.map((
|
|
1722
|
-
y.sort((
|
|
1723
|
-
const x = y[0],
|
|
1724
|
-
if (x.distance(
|
|
1725
|
-
const
|
|
1726
|
-
if (
|
|
1727
|
-
const C = [
|
|
1728
|
-
for (let
|
|
1729
|
-
const v = y[
|
|
1730
|
-
if (v ===
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1714
|
+
const y = p.map((w) => s.get(w));
|
|
1715
|
+
y.sort((w, g) => g.distance(e.start) - w.distance(e.start));
|
|
1716
|
+
const x = y[0], m = y[y.length - 1];
|
|
1717
|
+
if (x.distance(m) > n) {
|
|
1718
|
+
const w = [...p].sort((C, U) => U.length() - C.length()), g = w[0], S = w[1], D = s.get(g), E = s.get(S), b = g.length(), R = S.length(), P = g.projectLineSegment(S), B = P.length();
|
|
1719
|
+
if (D.distance(E) || R / b > 0.5 && B / R < 0.5) {
|
|
1720
|
+
const C = [g], U = [S];
|
|
1721
|
+
for (let O = 0; O < y.length; O++) {
|
|
1722
|
+
const v = y[O], V = v.userData;
|
|
1723
|
+
if (v === D || v === E) continue;
|
|
1724
|
+
const z = S.projectLineSegment(V), W = z.length();
|
|
1725
|
+
E.distance(v) <= n && W / R > 0 ? U.push(V) : C.push(V);
|
|
1733
1726
|
}
|
|
1734
|
-
h.push(C,
|
|
1727
|
+
h.push(C, U);
|
|
1735
1728
|
} else {
|
|
1736
1729
|
const C = Math.floor(p.length * 0.5);
|
|
1737
1730
|
h.push(p.slice(0, C), p.slice(C));
|
|
@@ -1743,7 +1736,7 @@ function pt(d, t, e, n) {
|
|
|
1743
1736
|
}
|
|
1744
1737
|
return h;
|
|
1745
1738
|
}
|
|
1746
|
-
function
|
|
1739
|
+
function gt(d, t) {
|
|
1747
1740
|
function e(i, r = /* @__PURE__ */ new Set()) {
|
|
1748
1741
|
if (r.has(i)) return r;
|
|
1749
1742
|
r.add(i);
|
|
@@ -1771,16 +1764,16 @@ function ae(d, t, e, n, s, i) {
|
|
|
1771
1764
|
groupMethod: a = "principalAndCross"
|
|
1772
1765
|
} = i ?? {}, c = {
|
|
1773
1766
|
cross: () => [
|
|
1774
|
-
...
|
|
1775
|
-
...
|
|
1767
|
+
...xt(d, n, e, o),
|
|
1768
|
+
...xt(t, e, n, o)
|
|
1776
1769
|
],
|
|
1777
1770
|
principalAndCross: () => [
|
|
1778
|
-
...
|
|
1779
|
-
...
|
|
1771
|
+
...yt(d, n, e, r, o),
|
|
1772
|
+
...yt(t, e, n, r, o)
|
|
1780
1773
|
],
|
|
1781
1774
|
originalInterPoint: () => [
|
|
1782
|
-
...
|
|
1783
|
-
...
|
|
1775
|
+
...gt(d, s),
|
|
1776
|
+
...gt(t, s)
|
|
1784
1777
|
]
|
|
1785
1778
|
};
|
|
1786
1779
|
return c[a] ? c[a]() : c.originalInterPoint();
|
|
@@ -1803,7 +1796,7 @@ function le(d, t = 0.1, e) {
|
|
|
1803
1796
|
if (s.length === 1) return s[0];
|
|
1804
1797
|
const i = [];
|
|
1805
1798
|
s.forEach((h) => i.push(h.start.clone(), h.end.clone()));
|
|
1806
|
-
const r = n === "average" ?
|
|
1799
|
+
const r = n === "average" ? A.mergeLines(...s) : A.mergeLinesByMaxlength(...s);
|
|
1807
1800
|
r.userData.rooftopPz = Math.min(
|
|
1808
1801
|
...s.map((h) => {
|
|
1809
1802
|
const { drawDoorData: u, drawWindow: f, rooftopPz: p, ...y } = h.userData;
|
|
@@ -1820,10 +1813,10 @@ function le(d, t = 0.1, e) {
|
|
|
1820
1813
|
return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
|
|
1821
1814
|
}).filter((s) => !!s);
|
|
1822
1815
|
}
|
|
1823
|
-
function
|
|
1824
|
-
const e = new F(
|
|
1816
|
+
function mt(d, t = 0.4) {
|
|
1817
|
+
const e = new F(N.fromByLineSegment(...d));
|
|
1825
1818
|
d.forEach((s) => e.insert(s));
|
|
1826
|
-
const n = new
|
|
1819
|
+
const n = new A();
|
|
1827
1820
|
for (let s = 0; s < d.length; s++) {
|
|
1828
1821
|
const i = d[s];
|
|
1829
1822
|
if (i.userData.isAdsorbed) continue;
|
|
@@ -1845,12 +1838,12 @@ function he(d, t = 0.4) {
|
|
|
1845
1838
|
} else
|
|
1846
1839
|
i.start.copy(o), i.end.copy(a);
|
|
1847
1840
|
i.userData.isAdsorbed = !0;
|
|
1848
|
-
} else o ? i.start.
|
|
1841
|
+
} else o ? i.directionMove(o.direction(i.start), i.start.distance(o)) : a && i.directionMove(a.direction(i.end), i.end.distance(a));
|
|
1849
1842
|
e.update(i);
|
|
1850
1843
|
}
|
|
1851
1844
|
return d.filter((s) => s.length() > 1e-3);
|
|
1852
1845
|
}
|
|
1853
|
-
function
|
|
1846
|
+
function he(d, t) {
|
|
1854
1847
|
const e = new X();
|
|
1855
1848
|
d.forEach((i) => i.points.forEach((r) => e.insert(r, i)));
|
|
1856
1849
|
const n = /* @__PURE__ */ new Map();
|
|
@@ -1866,51 +1859,39 @@ function ue(d, t) {
|
|
|
1866
1859
|
const c = a.sort((h, u) => h.userData.length() - u.userData.length())[0], l = c.userData?.projectPoint(o, !1);
|
|
1867
1860
|
if (l) {
|
|
1868
1861
|
const h = c.userData;
|
|
1869
|
-
s(r, new
|
|
1862
|
+
s(r, new A(o.clone(), l.clone())), s(h, new A(c.point.clone(), l.clone()));
|
|
1870
1863
|
}
|
|
1871
1864
|
});
|
|
1872
1865
|
}
|
|
1873
1866
|
return n.forEach((i, r) => {
|
|
1874
|
-
const o =
|
|
1867
|
+
const o = A.mergeLines(r, ...i);
|
|
1875
1868
|
r.set(o.start, o.end);
|
|
1876
1869
|
}), d;
|
|
1877
1870
|
}
|
|
1878
|
-
function
|
|
1871
|
+
function ue(d, t) {
|
|
1879
1872
|
const { snapThreshold: e = 0.2 } = t ?? {};
|
|
1880
|
-
return d =
|
|
1873
|
+
return d = mt(d, e), d = mt(d, e), d = he(d, e), d;
|
|
1881
1874
|
}
|
|
1882
|
-
function
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
n.userData.isWindow = !0, n.userData.drawWindow = n.userData.drawWindow ?? [], e.userData.drawWindow?.forEach((i) => {
|
|
1888
|
-
const r = M.from(i.p), o = n.projectPoint(
|
|
1889
|
-
r.clone().add(s.clone().multiplyScalar(i.width * 0.5))
|
|
1890
|
-
), a = n.projectPoint(
|
|
1891
|
-
r.clone().add(s.clone().multiplyScalar(i.width * -0.5))
|
|
1892
|
-
), c = new D(o, a), l = c.center;
|
|
1893
|
-
n.userData.drawWindow?.push({
|
|
1894
|
-
p: new I.Vector3(l?.x ?? 0, l?.y ?? 0, i.p.z),
|
|
1895
|
-
width: c.length(),
|
|
1896
|
-
full: i.full
|
|
1897
|
-
});
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1875
|
+
function de(d) {
|
|
1876
|
+
const t = /* @__PURE__ */ new Set();
|
|
1877
|
+
for (let e = 0; e < d.length; e++) {
|
|
1878
|
+
const n = d[e], s = n.userData.fittedLine;
|
|
1879
|
+
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : Q(n);
|
|
1900
1880
|
}
|
|
1881
|
+
t.forEach((e) => Q(e));
|
|
1901
1882
|
}
|
|
1902
|
-
function
|
|
1883
|
+
function fe(d) {
|
|
1903
1884
|
for (let t = 0; t < d.length; t++) {
|
|
1904
1885
|
const e = d[t];
|
|
1905
1886
|
let { endIntersection: n, startIntersection: s } = e.userData;
|
|
1906
1887
|
if (!(!n || !s)) {
|
|
1907
|
-
if (s.userData.fittedLine && (s = s.userData.fittedLine), n.userData.fittedLine && (n = n.userData.fittedLine), e.
|
|
1888
|
+
if (s.userData.fittedLine && (s = s.userData.fittedLine), n.userData.fittedLine && (n = n.userData.fittedLine), e.parallel(s))
|
|
1908
1889
|
e.start.distance(s.start) < e.start.distance(s.end) ? e.start.copy(s.start) : e.start.copy(s.end);
|
|
1909
1890
|
else {
|
|
1910
1891
|
const i = s.projectPoint(e.start);
|
|
1911
1892
|
i && e.start.copy(i);
|
|
1912
1893
|
}
|
|
1913
|
-
if (e.
|
|
1894
|
+
if (e.parallel(n))
|
|
1914
1895
|
e.end.distance(n.start) < e.end.distance(n.end) ? e.end.copy(n.start) : e.end.copy(n.end);
|
|
1915
1896
|
else {
|
|
1916
1897
|
const i = n.projectPoint(e.end);
|
|
@@ -1920,7 +1901,7 @@ function pe(d) {
|
|
|
1920
1901
|
}
|
|
1921
1902
|
return d;
|
|
1922
1903
|
}
|
|
1923
|
-
function
|
|
1904
|
+
function pe(d, t = 0.01) {
|
|
1924
1905
|
const e = new X();
|
|
1925
1906
|
return d.forEach((n) => n.points.forEach((s) => e.insert(s, n))), d.filter((n) => {
|
|
1926
1907
|
if (n.length() <= t) {
|
|
@@ -1930,7 +1911,7 @@ function ye(d, t = 0.01) {
|
|
|
1930
1911
|
return !0;
|
|
1931
1912
|
});
|
|
1932
1913
|
}
|
|
1933
|
-
class
|
|
1914
|
+
class Pt {
|
|
1934
1915
|
/**
|
|
1935
1916
|
* 轴对齐垂直修正
|
|
1936
1917
|
* @param lines 待调整线段组
|
|
@@ -1939,32 +1920,48 @@ class Tt {
|
|
|
1939
1920
|
*/
|
|
1940
1921
|
static correction(t, e, n) {
|
|
1941
1922
|
t = ie(t.map((x) => x.clone()));
|
|
1942
|
-
const s = re(t), { parallelLines: i, verticalLines: r, doorLines: o, windowLines: a } = oe(e, t, s, 25), c = e.normal(), l = e.center, h = e.direction(), u = new
|
|
1923
|
+
const s = re(t), { parallelLines: i, verticalLines: r, doorLines: o, windowLines: a } = oe(e, t, s, 25), c = e.normal(), l = e.center, h = e.direction(), u = new A(
|
|
1943
1924
|
l.clone().add(c.clone().multiplyScalar(-1e3)),
|
|
1944
1925
|
l.clone().add(c.clone().multiplyScalar(1e3))
|
|
1945
|
-
), f = new
|
|
1926
|
+
), f = new A(
|
|
1946
1927
|
l.clone().add(h.clone().multiplyScalar(-1e3)),
|
|
1947
1928
|
l.clone().add(h.clone().multiplyScalar(1e3))
|
|
1948
1929
|
);
|
|
1949
1930
|
let p = ae(i, r, u, f, s, n);
|
|
1950
1931
|
p = ce(p, s);
|
|
1951
1932
|
let y = le(p, 0.1, n);
|
|
1952
|
-
return y =
|
|
1933
|
+
return y = ue(y, n), de(a), fe(o), y = lt(y, 1e-9), y.push(...o), y = pe(y, 0.08), y = y, y;
|
|
1953
1934
|
}
|
|
1954
1935
|
}
|
|
1955
|
-
const
|
|
1936
|
+
const ye = new A(
|
|
1956
1937
|
new M(0, 0),
|
|
1957
1938
|
new M(0, 1)
|
|
1958
1939
|
);
|
|
1959
|
-
function
|
|
1940
|
+
function xe(d) {
|
|
1960
1941
|
const t = [...d].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
|
|
1961
|
-
let r = parseInt(
|
|
1942
|
+
let r = parseInt(ye.includedAngle(i) + "");
|
|
1962
1943
|
return r > 90 && (r = 180 - r), r;
|
|
1963
1944
|
}), n = /* @__PURE__ */ new Map();
|
|
1964
1945
|
return e.forEach((i, r) => {
|
|
1965
1946
|
n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
|
|
1966
1947
|
}), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
|
|
1967
1948
|
}
|
|
1949
|
+
function ge(d) {
|
|
1950
|
+
let t = [], e = -1;
|
|
1951
|
+
const n = [];
|
|
1952
|
+
return d.forEach(({ start: i, end: r, ...o }, a) => {
|
|
1953
|
+
n.push(i.z ?? 0, r.z ?? 0);
|
|
1954
|
+
const c = new A(
|
|
1955
|
+
M.from(i),
|
|
1956
|
+
M.from(r)
|
|
1957
|
+
);
|
|
1958
|
+
c.userData = o, t.push(c), o.isVerticalReferenceLine && (e = a);
|
|
1959
|
+
}), {
|
|
1960
|
+
originalZAverage: n.reduce((i, r) => i + r, 0) / n.length,
|
|
1961
|
+
lineSegments: t,
|
|
1962
|
+
verticalReferenceIndex: e
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1968
1965
|
const me = {
|
|
1969
1966
|
Unitless: 1,
|
|
1970
1967
|
// 无单位,1米 = 1(无单位)
|
|
@@ -2009,16 +2006,16 @@ const me = {
|
|
|
2009
2006
|
Parsecs: 3240779289666404e-32
|
|
2010
2007
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
2011
2008
|
};
|
|
2012
|
-
function
|
|
2009
|
+
function wt(d) {
|
|
2013
2010
|
const t = [];
|
|
2014
2011
|
for (let e = 0; e < d.length; e++)
|
|
2015
|
-
t.push(new
|
|
2012
|
+
t.push(new A(
|
|
2016
2013
|
d[e].clone(),
|
|
2017
2014
|
d[(e + 1) % d.length].clone()
|
|
2018
2015
|
));
|
|
2019
2016
|
return t;
|
|
2020
2017
|
}
|
|
2021
|
-
function
|
|
2018
|
+
function Mt(d) {
|
|
2022
2019
|
return d.flatMap((t, e) => (e === d.length - 1 && [...t.points, d[0].points[0]], [t.points[0]]));
|
|
2023
2020
|
}
|
|
2024
2021
|
class k extends q {
|
|
@@ -2028,12 +2025,13 @@ class k extends q {
|
|
|
2028
2025
|
scale = 1;
|
|
2029
2026
|
originalData = [];
|
|
2030
2027
|
data = [];
|
|
2031
|
-
originalBox = new
|
|
2032
|
-
box = new
|
|
2028
|
+
originalBox = new N(0, 0, 0, 0);
|
|
2029
|
+
box = new N(0, 0, 0, 0);
|
|
2033
2030
|
pointsGroups = [];
|
|
2034
2031
|
wallsGroup = [];
|
|
2035
2032
|
doors = [];
|
|
2036
2033
|
doorLineSegment = [];
|
|
2034
|
+
verticalReferenceLine;
|
|
2037
2035
|
lineSegments = [];
|
|
2038
2036
|
originalZAverage = 0;
|
|
2039
2037
|
static EndType = {
|
|
@@ -2064,31 +2062,23 @@ class k extends q {
|
|
|
2064
2062
|
* 预处理数据
|
|
2065
2063
|
* @param data
|
|
2066
2064
|
*/
|
|
2067
|
-
preprocessing(t
|
|
2068
|
-
let
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const u = new D(
|
|
2073
|
-
M.from(a),
|
|
2074
|
-
M.from(c)
|
|
2075
|
-
);
|
|
2076
|
-
u.userData = l, s.push(u), l.isVerticalReferenceLine && (i = h);
|
|
2077
|
-
}), this.originalZAverage = r.reduce((a, c) => a + c, 0) / r.length, i === -1) {
|
|
2078
|
-
const a = ge(s);
|
|
2079
|
-
i = s.indexOf(a);
|
|
2065
|
+
preprocessing(t) {
|
|
2066
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = ge(t);
|
|
2067
|
+
if (this.originalZAverage = s, n === -1) {
|
|
2068
|
+
const r = xe(e);
|
|
2069
|
+
n = e.indexOf(r);
|
|
2080
2070
|
}
|
|
2081
|
-
const
|
|
2082
|
-
return
|
|
2071
|
+
const i = e[n];
|
|
2072
|
+
return i.userData.isVerticalReferenceLine = !0, t[n].isVerticalReferenceLine = !0, this.verticalReferenceLine = i, this.dispatchEvent({
|
|
2083
2073
|
type: "preprocessing",
|
|
2084
2074
|
data: t,
|
|
2085
|
-
setData(
|
|
2086
|
-
|
|
2087
|
-
const
|
|
2088
|
-
return
|
|
2089
|
-
}), t =
|
|
2075
|
+
setData(r) {
|
|
2076
|
+
e = r.map(({ start: o, end: a, ...c }) => {
|
|
2077
|
+
const l = new A(M.from(o), M.from(a));
|
|
2078
|
+
return l.userData = c, l;
|
|
2079
|
+
}), t = r;
|
|
2090
2080
|
}
|
|
2091
|
-
}), { lineSegments:
|
|
2081
|
+
}), { lineSegments: e, data: t };
|
|
2092
2082
|
}
|
|
2093
2083
|
/** 设置
|
|
2094
2084
|
* @param data 房屋结构数据,node环境可以为路径
|
|
@@ -2098,34 +2088,34 @@ class k extends q {
|
|
|
2098
2088
|
* @param option
|
|
2099
2089
|
* @returns
|
|
2100
2090
|
*/
|
|
2101
|
-
async set(t, e = this.width, n = this.scale
|
|
2091
|
+
async set(t, e = this.width, n = this.scale) {
|
|
2102
2092
|
if (typeof t == "string")
|
|
2103
2093
|
if (typeof global < "u") {
|
|
2104
|
-
const { default:
|
|
2094
|
+
const { default: r } = await import(
|
|
2105
2095
|
/* @vite-ignore */
|
|
2106
2096
|
"fs"
|
|
2107
|
-
),
|
|
2108
|
-
return this.set(
|
|
2097
|
+
), o = r.readFileSync(t), a = JSON.parse(o.toString("utf-8"));
|
|
2098
|
+
return this.set(a, e, n);
|
|
2109
2099
|
} else
|
|
2110
2100
|
throw new Error("非node环境不允许使用路径");
|
|
2111
2101
|
if (this.scale = n, this.width = e, t.length === 0)
|
|
2112
2102
|
this.lineSegments = [], this.originalData = t;
|
|
2113
2103
|
else {
|
|
2114
|
-
const
|
|
2115
|
-
t =
|
|
2104
|
+
const i = this.preprocessing(t);
|
|
2105
|
+
t = i.data, this.lineSegments = i.lineSegments, this.originalData = t;
|
|
2116
2106
|
}
|
|
2117
|
-
const
|
|
2118
|
-
this.data = t.map(({ start:
|
|
2119
|
-
|
|
2120
|
-
const
|
|
2107
|
+
const s = [];
|
|
2108
|
+
this.data = t.map(({ start: i, end: r, insetionArr: o, isDoor: a = !1 }, c) => {
|
|
2109
|
+
s.push(i.z ?? 0, r.z ?? 0);
|
|
2110
|
+
const l = this.lineSegments[c];
|
|
2121
2111
|
return [
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
(
|
|
2125
|
-
|
|
2126
|
-
|
|
2112
|
+
l.points[0],
|
|
2113
|
+
l.points[1],
|
|
2114
|
+
(o ?? []).map((h) => h.index),
|
|
2115
|
+
a,
|
|
2116
|
+
c
|
|
2127
2117
|
];
|
|
2128
|
-
}), this.originalZAverage =
|
|
2118
|
+
}), this.originalZAverage = s.reduce((i, r) => i + r, 0) / s.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
|
|
2129
2119
|
type: "setDta",
|
|
2130
2120
|
originalData: this.originalData,
|
|
2131
2121
|
data: this.data
|
|
@@ -2237,7 +2227,7 @@ class k extends q {
|
|
|
2237
2227
|
break;
|
|
2238
2228
|
}
|
|
2239
2229
|
}
|
|
2240
|
-
const e = this.mergeSameDirectionLine(
|
|
2230
|
+
const e = this.mergeSameDirectionLine(wt(t)), n = [e[0]];
|
|
2241
2231
|
for (let s = 1; s < e.length; s++) {
|
|
2242
2232
|
const i = e[s], r = e[(e.length + s - 1) % e.length];
|
|
2243
2233
|
if (i.length() > this.width * 0.9) {
|
|
@@ -2252,7 +2242,7 @@ class k extends q {
|
|
|
2252
2242
|
const a = e[s + 2];
|
|
2253
2243
|
a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
|
|
2254
2244
|
}
|
|
2255
|
-
return n.length > 3 ?
|
|
2245
|
+
return n.length > 3 ? Mt(this.mergeSameDirectionLine(n)) : [];
|
|
2256
2246
|
}
|
|
2257
2247
|
/**
|
|
2258
2248
|
* 移除短线段
|
|
@@ -2260,7 +2250,7 @@ class k extends q {
|
|
|
2260
2250
|
* @param path
|
|
2261
2251
|
*/
|
|
2262
2252
|
removeShortLine(t, e = this.shortLine) {
|
|
2263
|
-
const n =
|
|
2253
|
+
const n = wt(t), s = [], i = Math.PI / 180;
|
|
2264
2254
|
for (let r = 0; r < n.length; r++) {
|
|
2265
2255
|
const o = n[r], a = o.length(), c = r;
|
|
2266
2256
|
if (a > e || s.length === 0) {
|
|
@@ -2288,14 +2278,14 @@ class k extends q {
|
|
|
2288
2278
|
} else
|
|
2289
2279
|
r = c;
|
|
2290
2280
|
}
|
|
2291
|
-
return s.length > 3 ?
|
|
2281
|
+
return s.length > 3 ? Mt(s) : [];
|
|
2292
2282
|
}
|
|
2293
2283
|
/** 线偏移
|
|
2294
2284
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
2295
2285
|
*/
|
|
2296
2286
|
lineOffset(t = k.EndType.etOpenSquare, e = k.JoinType.jtMiter, n = 1e4) {
|
|
2297
|
-
let s = new
|
|
2298
|
-
const i = new
|
|
2287
|
+
let s = new pt.Paths();
|
|
2288
|
+
const i = new pt.ClipperOffset(20, 0.25);
|
|
2299
2289
|
return this.pointsGroups.forEach((r) => {
|
|
2300
2290
|
const o = this.lineTopology(r).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
|
|
2301
2291
|
i.AddPaths(o, e, t);
|
|
@@ -2307,6 +2297,27 @@ class k extends q {
|
|
|
2307
2297
|
wallsGroup: this.wallsGroup
|
|
2308
2298
|
}), this.wallsGroup;
|
|
2309
2299
|
}
|
|
2300
|
+
/** 垂直纠正
|
|
2301
|
+
* @param option
|
|
2302
|
+
*/
|
|
2303
|
+
axisAlignCorr(t) {
|
|
2304
|
+
if (this.verticalReferenceLine) {
|
|
2305
|
+
this.doorLineSegment;
|
|
2306
|
+
const e = Pt.correction(this.getLineSegments(), this.verticalReferenceLine, t), n = J(e);
|
|
2307
|
+
this.set(n);
|
|
2308
|
+
} else
|
|
2309
|
+
throw new Error("未找到一条垂直纠正基准轴线");
|
|
2310
|
+
}
|
|
2311
|
+
/** 完整线段数据
|
|
2312
|
+
* @returns
|
|
2313
|
+
*/
|
|
2314
|
+
getLineSegments(t = !1) {
|
|
2315
|
+
let e = this.lineSegments.filter((s) => !s.userData.isDoor), n = [...this.doorLineSegment];
|
|
2316
|
+
return t && (e = e.map((s) => s.clone()), n = n.map((s) => s.clone())), n.forEach((s) => Object.assign(s.userData, {
|
|
2317
|
+
isDoor: !0,
|
|
2318
|
+
doorDirectConnection: !0
|
|
2319
|
+
})), e.push(...n), e;
|
|
2320
|
+
}
|
|
2310
2321
|
/**
|
|
2311
2322
|
* 将点云结构转换为Float32Array
|
|
2312
2323
|
*/
|
|
@@ -2336,7 +2347,7 @@ class k extends q {
|
|
|
2336
2347
|
* 线段数据转为原始json数据
|
|
2337
2348
|
*/
|
|
2338
2349
|
lineDataToOriginalData(t, e) {
|
|
2339
|
-
return
|
|
2350
|
+
return J(t, this.originalZAverage, e);
|
|
2340
2351
|
}
|
|
2341
2352
|
/**
|
|
2342
2353
|
* 转为绘制数据
|
|
@@ -2386,29 +2397,29 @@ class k extends q {
|
|
|
2386
2397
|
if (s = "cyan", l.length() < 1.2) {
|
|
2387
2398
|
l.expansion(-o * 0.5);
|
|
2388
2399
|
const h = c.normal();
|
|
2389
|
-
let u = new
|
|
2400
|
+
let u = new A(
|
|
2390
2401
|
l.start.clone(),
|
|
2391
2402
|
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2392
2403
|
);
|
|
2393
2404
|
const f = u.clone().directionMove(u.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
2394
|
-
for (let
|
|
2395
|
-
if (a[
|
|
2396
|
-
u = new
|
|
2405
|
+
for (let g = 0; g < a.length; g++)
|
|
2406
|
+
if (a[g].intersectRectangle(f)) {
|
|
2407
|
+
u = new A(
|
|
2397
2408
|
l.start.clone(),
|
|
2398
2409
|
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2399
2410
|
);
|
|
2400
2411
|
break;
|
|
2401
2412
|
}
|
|
2402
|
-
u.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((
|
|
2403
|
-
const p = l.length(), y = u.length(), x = (p ** 2 + y ** 2) / (2 * y),
|
|
2404
|
-
r(
|
|
2413
|
+
u.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((g, S) => i(g, S));
|
|
2414
|
+
const p = l.length(), y = u.length(), x = (p ** 2 + y ** 2) / (2 * y), m = u.end.clone().add(u.direction().multiplyScalar(-x)), [L, w] = this.getArcAngleRange(m, l.end, u.end);
|
|
2415
|
+
r(m, x, Math.min(L, w), Math.max(L, w)), a.push(f);
|
|
2405
2416
|
} else
|
|
2406
2417
|
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, u) => i(h, u)), 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, u) => i(h, u)), 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, u) => i(h, u));
|
|
2407
2418
|
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
2408
2419
|
if (!c.userData.isWindow) return !1;
|
|
2409
2420
|
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
2410
|
-
const { p: h, width: u } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(u * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-u * 0.5)), x = new
|
|
2411
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((
|
|
2421
|
+
const { p: h, width: u } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(u * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-u * 0.5)), x = new A(p, y);
|
|
2422
|
+
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((m, L) => i(m, L));
|
|
2412
2423
|
});
|
|
2413
2424
|
}), n;
|
|
2414
2425
|
}
|
|
@@ -2439,8 +2450,8 @@ class k extends q {
|
|
|
2439
2450
|
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, u * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
|
|
2440
2451
|
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
2441
2452
|
let [l, h, u, f] = c;
|
|
2442
|
-
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1),
|
|
2443
|
-
a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(x, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(x - 0.1 * s.scale, p), a.lineTo(x + 0.1 * s.scale, p), a.moveTo(x, p), a.lineTo(x,
|
|
2453
|
+
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), m = (y - p) * 0.45;
|
|
2454
|
+
a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(x, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(x - 0.1 * s.scale, p), a.lineTo(x + 0.1 * s.scale, p), a.moveTo(x, p), a.lineTo(x, m + p), a.moveTo(x, y), a.lineTo(x, y - m), a.moveTo(x - 0.1 * s.scale, y), a.lineTo(x + 0.1 * s.scale, y);
|
|
2444
2455
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
2445
2456
|
i.toBlob((l) => {
|
|
2446
2457
|
c(l);
|
|
@@ -2451,8 +2462,8 @@ class k extends q {
|
|
|
2451
2462
|
* 将点json结构转换为Dxf string
|
|
2452
2463
|
*/
|
|
2453
2464
|
toDxfString(t = "Millimeters") {
|
|
2454
|
-
const e = new
|
|
2455
|
-
e.setUnits(t), e.addLayer("cyan",
|
|
2465
|
+
const e = new $();
|
|
2466
|
+
e.setUnits(t), e.addLayer("cyan", $.ACI.CYAN, "DOTTED"), e.addLayer("yellow", $.ACI.YELLOW, "DOTTED"), e.addLayer("white", $.ACI.WHITE, "DOTTED");
|
|
2456
2467
|
const n = this.toDrawDataJson();
|
|
2457
2468
|
return n.line.forEach((s) => {
|
|
2458
2469
|
let [i, r, o, a, c] = s;
|
|
@@ -2474,7 +2485,7 @@ class k extends q {
|
|
|
2474
2485
|
* @param filename
|
|
2475
2486
|
*/
|
|
2476
2487
|
async downloadOriginalData(t) {
|
|
2477
|
-
const e = JSON.stringify(this.
|
|
2488
|
+
const e = JSON.stringify(J(this.getLineSegments()), null, 2);
|
|
2478
2489
|
if (typeof window < "u") {
|
|
2479
2490
|
const n = new Blob([e], { type: "application/json" }), s = document.createElement("a");
|
|
2480
2491
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
@@ -2508,7 +2519,7 @@ class k extends q {
|
|
|
2508
2519
|
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
2509
2520
|
* @returns
|
|
2510
2521
|
*/
|
|
2511
|
-
computedOriginalSize(t, e = new
|
|
2522
|
+
computedOriginalSize(t, e = new N(0, 0, 0, 0)) {
|
|
2512
2523
|
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);
|
|
2513
2524
|
return e.set(i, r, o, a), e;
|
|
2514
2525
|
}
|
|
@@ -2536,16 +2547,16 @@ class k extends q {
|
|
|
2536
2547
|
});
|
|
2537
2548
|
}
|
|
2538
2549
|
}
|
|
2539
|
-
function
|
|
2550
|
+
function ct(d) {
|
|
2540
2551
|
if (d === null || typeof d != "object") return d;
|
|
2541
2552
|
if (d instanceof Date) return new Date(d.getTime());
|
|
2542
|
-
if (Array.isArray(d)) return d.map(
|
|
2553
|
+
if (Array.isArray(d)) return d.map(ct);
|
|
2543
2554
|
const t = {};
|
|
2544
2555
|
for (const e in d)
|
|
2545
|
-
Object.prototype.hasOwnProperty.call(d, e) && (t[e] =
|
|
2556
|
+
Object.prototype.hasOwnProperty.call(d, e) && (t[e] = ct(d[e]));
|
|
2546
2557
|
return t;
|
|
2547
2558
|
}
|
|
2548
|
-
const
|
|
2559
|
+
const j = new A();
|
|
2549
2560
|
class we extends k {
|
|
2550
2561
|
static name = "AngleCorrectionDxf";
|
|
2551
2562
|
angle = 0;
|
|
@@ -2557,20 +2568,20 @@ class we extends k {
|
|
|
2557
2568
|
let s = 0, i = null;
|
|
2558
2569
|
for (let c = 0; c < e.originalData.length; c++) {
|
|
2559
2570
|
const l = e.originalData[c];
|
|
2560
|
-
if (
|
|
2561
|
-
const [h, u] = l.start.y < l.end.y ? [
|
|
2562
|
-
s = -new
|
|
2571
|
+
if (j.start.copy(l.start), j.end.copy(l.end), l.isVerticalReferenceLine) {
|
|
2572
|
+
const [h, u] = l.start.y < l.end.y ? [j.start, j.end] : [j.end, j.start];
|
|
2573
|
+
s = -new A(h, u).direction().angleBetween(new M(0, 1), "angle", "360"), i = null;
|
|
2563
2574
|
break;
|
|
2564
2575
|
}
|
|
2565
|
-
(!i ||
|
|
2576
|
+
(!i || j.length() > i.length()) && (i = j.clone(), i.userData.index = c);
|
|
2566
2577
|
}
|
|
2567
2578
|
if (i) {
|
|
2568
2579
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
2569
2580
|
const [c, l] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
|
|
2570
|
-
s = -new
|
|
2581
|
+
s = -new A(c, l).direction().angleBetween(new M(0, 1), "angle", "360");
|
|
2571
2582
|
}
|
|
2572
2583
|
const r = e.originalBox.center, o = M.zero(), a = e.originalData.map((c) => {
|
|
2573
|
-
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), u = Object.assign(
|
|
2584
|
+
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), u = Object.assign(ct(c), { start: l, end: h });
|
|
2574
2585
|
return u.drawWindow && u.drawWindow.forEach((f) => {
|
|
2575
2586
|
f.p = o.copy(f.p).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(f.p.z);
|
|
2576
2587
|
}), u;
|
|
@@ -2591,7 +2602,7 @@ class we extends k {
|
|
|
2591
2602
|
});
|
|
2592
2603
|
}
|
|
2593
2604
|
}
|
|
2594
|
-
class
|
|
2605
|
+
class Rt extends q {
|
|
2595
2606
|
static name = "Variable";
|
|
2596
2607
|
originalLineVisible = !0;
|
|
2597
2608
|
dxfVisible = !0;
|
|
@@ -2637,9 +2648,9 @@ class Me {
|
|
|
2637
2648
|
lineAnalysis;
|
|
2638
2649
|
continueFind = !0;
|
|
2639
2650
|
constructor(t) {
|
|
2640
|
-
|
|
2651
|
+
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new X(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
|
|
2641
2652
|
this.pointVirtualGrid.insert(n.start, n), this.pointVirtualGrid.insert(n.end, n);
|
|
2642
|
-
}), this.doorPoint = this.getDoorPoint()
|
|
2653
|
+
}), this.doorPoint = this.getDoorPoint();
|
|
2643
2654
|
const e = this.searchDoubleLinePoint();
|
|
2644
2655
|
this.addPointsExcludeRule((n, s, i) => {
|
|
2645
2656
|
const r = this.lineSegments.indexOf(n), o = e.get(r);
|
|
@@ -2647,7 +2658,7 @@ class Me {
|
|
|
2647
2658
|
}), this.addPointsExcludeRule((n, s) => !!this.doorPoint.find((i) => i.point.equal(s))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((n) => this.findPointVirtualGrid.insert(n.point, n.line)), this.handle();
|
|
2648
2659
|
}
|
|
2649
2660
|
handle() {
|
|
2650
|
-
this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.
|
|
2661
|
+
this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.dxf.doorLineSegment.length < 2 && this.dxf.doorLineSegment.push(...this.search(this.possibleDoorPoints, this.possibleDoorPoints, 0.6));
|
|
2651
2662
|
}
|
|
2652
2663
|
search(t, e = [], n = 0.6, s = this.doorSearchDistance, i = this.doorSearchNearAngle) {
|
|
2653
2664
|
const r = this.dxf, o = this.searchNearby(t, e, s, i);
|
|
@@ -2667,15 +2678,15 @@ class Me {
|
|
|
2667
2678
|
);
|
|
2668
2679
|
const a = [];
|
|
2669
2680
|
return o.forEach((c) => {
|
|
2670
|
-
const l = new
|
|
2681
|
+
const l = new A(c?.start, c?.end), h = l.length();
|
|
2671
2682
|
if (h < n) return;
|
|
2672
2683
|
const u = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
2673
2684
|
for (let y = 0; y < 3; y++) {
|
|
2674
|
-
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)),
|
|
2685
|
+
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), m = new A(
|
|
2675
2686
|
x,
|
|
2676
2687
|
x.clone().add(u.clone().multiplyScalar(1))
|
|
2677
2688
|
);
|
|
2678
|
-
if (
|
|
2689
|
+
if (m.directionMove(u, -0.5), this.quadtree.queryLineSegment(m).length) return;
|
|
2679
2690
|
}
|
|
2680
2691
|
a.push(l);
|
|
2681
2692
|
}), a;
|
|
@@ -2695,7 +2706,7 @@ class Me {
|
|
|
2695
2706
|
return this.lineSegments.forEach((e) => {
|
|
2696
2707
|
e.points.forEach((n, s) => {
|
|
2697
2708
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
|
|
2698
|
-
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid:
|
|
2709
|
+
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: at() });
|
|
2699
2710
|
});
|
|
2700
2711
|
}), t;
|
|
2701
2712
|
}
|
|
@@ -2706,7 +2717,14 @@ class Me {
|
|
|
2706
2717
|
const t = [], e = this.dxf, n = this.pointVirtualGrid;
|
|
2707
2718
|
return e.doors.forEach((s) => {
|
|
2708
2719
|
const i = e.lineSegments[s[4]], r = e.originalData[s[4]];
|
|
2709
|
-
if (r.
|
|
2720
|
+
if (r.doorDirectConnection) {
|
|
2721
|
+
this.continueFind = !1;
|
|
2722
|
+
const o = new A(M.from(r.start), M.from(r.end));
|
|
2723
|
+
o.userData = {
|
|
2724
|
+
doorDirectConnection: !0,
|
|
2725
|
+
isDoor: !0
|
|
2726
|
+
}, this.dxf.doorLineSegment.push(o);
|
|
2727
|
+
} else if (r.drawDoorData) {
|
|
2710
2728
|
const o = M.from(r.drawDoorData.start), a = M.from(r.drawDoorData.n), c = n.queryPoint(o).filter((l) => {
|
|
2711
2729
|
if (l.userData === i) return !1;
|
|
2712
2730
|
const h = l.userData, u = h.direction();
|
|
@@ -2717,15 +2735,8 @@ class Me {
|
|
|
2717
2735
|
c.length && t.push({
|
|
2718
2736
|
line: c[0].userData,
|
|
2719
2737
|
point: o,
|
|
2720
|
-
uuid:
|
|
2738
|
+
uuid: at()
|
|
2721
2739
|
});
|
|
2722
|
-
} else if (r.doorDirectConnection) {
|
|
2723
|
-
this.continueFind = !1;
|
|
2724
|
-
const o = new D(M.from(r.start), M.from(r.end));
|
|
2725
|
-
o.userData = {
|
|
2726
|
-
doorDirectConnection: !0,
|
|
2727
|
-
isDoor: !0
|
|
2728
|
-
}, this.dxf.doorLineSegment.push(o);
|
|
2729
2740
|
} else
|
|
2730
2741
|
console.warn(`门的线段顺序${s[4]} 没有drawDoorData属性`);
|
|
2731
2742
|
}), t;
|
|
@@ -2751,83 +2762,83 @@ class Me {
|
|
|
2751
2762
|
*/
|
|
2752
2763
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2753
2764
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2754
|
-
function o({ point: x, line:
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
const S = i.queryCircle(x, n).filter((
|
|
2758
|
-
for (let
|
|
2759
|
-
const
|
|
2760
|
-
if (
|
|
2761
|
-
|
|
2762
|
-
const
|
|
2763
|
-
if (C.direction().angleBetween(
|
|
2764
|
-
const
|
|
2765
|
-
|
|
2766
|
-
findData: S[
|
|
2767
|
-
findUuid:
|
|
2765
|
+
function o({ point: x, line: m }, L, w) {
|
|
2766
|
+
const g = m.direction();
|
|
2767
|
+
m.start === x && g.multiplyScalar(-1);
|
|
2768
|
+
const S = i.queryCircle(x, n).filter((E) => E.userData !== m).sort((E, b) => E.point.distance(x) - b.point.distance(x)), D = [];
|
|
2769
|
+
for (let E = 0; E < S.length; E++) {
|
|
2770
|
+
const b = e.findIndex((O) => O.point === S[E].point), R = t[L].uuid, P = e[b].uuid;
|
|
2771
|
+
if (w.has(`${R}.${P}`)) continue;
|
|
2772
|
+
w.add(`${R}.${P}`), w.add(`${P}.${R}`);
|
|
2773
|
+
const B = S[E].point, C = new A(x.clone(), B.clone());
|
|
2774
|
+
if (C.direction().angleBetween(g, "angle") < s) {
|
|
2775
|
+
const O = t[L].line.direction(), v = S[E].userData;
|
|
2776
|
+
v.start.equal(S[E].point) && O.multiplyScalar(-1), C.direction().multiplyScalar(-1).angleBetween(O, "angle") < s && (r.queryLineSegment(C).filter((W) => !(W.line.start.equal(x) || W.line.end.equal(x) || W.line === v)).length || D.push({
|
|
2777
|
+
findData: S[E],
|
|
2778
|
+
findUuid: P,
|
|
2768
2779
|
doorLine: C,
|
|
2769
|
-
doorUuid:
|
|
2780
|
+
doorUuid: R
|
|
2770
2781
|
}));
|
|
2771
2782
|
}
|
|
2772
2783
|
}
|
|
2773
|
-
return
|
|
2784
|
+
return D;
|
|
2774
2785
|
}
|
|
2775
|
-
function a(x,
|
|
2776
|
-
|
|
2786
|
+
function a(x, m, L, w, g) {
|
|
2787
|
+
w.add(x);
|
|
2777
2788
|
const S = [];
|
|
2778
|
-
|
|
2779
|
-
for (let
|
|
2780
|
-
const
|
|
2781
|
-
if (
|
|
2782
|
-
const
|
|
2783
|
-
a(
|
|
2784
|
-
} else S.push(
|
|
2789
|
+
g && S.push(g);
|
|
2790
|
+
for (let D = 0; D < L.length; D++) {
|
|
2791
|
+
const E = L[D];
|
|
2792
|
+
if (m.has(E.findUuid)) {
|
|
2793
|
+
const b = m.get(E.findUuid);
|
|
2794
|
+
a(E.findUuid, m, b, w, E) && S.push(E);
|
|
2795
|
+
} else S.push(E);
|
|
2785
2796
|
}
|
|
2786
|
-
return S.sort((
|
|
2797
|
+
return S.sort((D, E) => D.doorLine.length() - E.doorLine.length()), g && S[0] === g ? (L.splice(0), !0) : (L.splice(1), !1);
|
|
2787
2798
|
}
|
|
2788
2799
|
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
2789
|
-
t.map((x,
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2800
|
+
t.map((x, m) => {
|
|
2801
|
+
const L = o(x, m, c);
|
|
2802
|
+
L.length && l.set(x.uuid, L);
|
|
2792
2803
|
}), c.clear();
|
|
2793
2804
|
const h = /* @__PURE__ */ new Map();
|
|
2794
|
-
l.forEach((x,
|
|
2795
|
-
if (!c.has(
|
|
2796
|
-
const
|
|
2797
|
-
h.has(
|
|
2805
|
+
l.forEach((x, m) => {
|
|
2806
|
+
if (!c.has(m) && x.length && a(m, l, x, c), x.length) {
|
|
2807
|
+
const L = x[0];
|
|
2808
|
+
h.has(L.doorUuid) || h.set(L.doorUuid, []), h.get(L.doorUuid)?.push(L), h.has(L.findUuid) || h.set(L.findUuid, []), h.get(L.findUuid)?.push(L);
|
|
2798
2809
|
}
|
|
2799
2810
|
});
|
|
2800
2811
|
const u = /* @__PURE__ */ new Set();
|
|
2801
2812
|
h.forEach((x) => {
|
|
2802
2813
|
if (x.length > 1) {
|
|
2803
|
-
x.sort((
|
|
2804
|
-
for (let
|
|
2814
|
+
x.sort((m, L) => m.doorLine.length() - L.doorLine.length());
|
|
2815
|
+
for (let m = 1; m < x.length; m++) u.add(x[m]);
|
|
2805
2816
|
}
|
|
2806
2817
|
});
|
|
2807
2818
|
const f = [], p = [];
|
|
2808
2819
|
l.forEach((x) => {
|
|
2809
2820
|
if (x.length) {
|
|
2810
|
-
const
|
|
2811
|
-
u.has(
|
|
2821
|
+
const m = x[0];
|
|
2822
|
+
u.has(m) || (f.push(m), p.push(m.doorUuid, m.findUuid));
|
|
2812
2823
|
}
|
|
2813
2824
|
});
|
|
2814
2825
|
const y = [];
|
|
2815
2826
|
return f.forEach((x) => {
|
|
2816
|
-
const
|
|
2817
|
-
if (
|
|
2818
|
-
|
|
2819
|
-
const
|
|
2820
|
-
(
|
|
2821
|
-
start:
|
|
2822
|
-
end:
|
|
2827
|
+
const m = t.findIndex((b) => b.uuid === x.doorUuid), L = e.findIndex((b) => b.uuid === x.findUuid), w = t[m].point.clone(), g = e[L].point.clone(), S = this.findLongLineSegment(t[m].line), D = this.findLongLineSegment(e[L].line), E = S.projectPoint(g);
|
|
2828
|
+
if (E) {
|
|
2829
|
+
w.copy(E);
|
|
2830
|
+
const b = new A(w, g), R = D.includedAngle(b);
|
|
2831
|
+
(R < 10 || R > 170 || Math.abs(90 - R) < 10) && y.push({
|
|
2832
|
+
start: w,
|
|
2833
|
+
end: g
|
|
2823
2834
|
});
|
|
2824
2835
|
} else {
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
const
|
|
2828
|
-
(
|
|
2829
|
-
start:
|
|
2830
|
-
end:
|
|
2836
|
+
const b = D.projectPoint(w);
|
|
2837
|
+
b && g.copy(b);
|
|
2838
|
+
const R = new A(w, g), P = S.includedAngle(R);
|
|
2839
|
+
(P < 10 || P > 170 || Math.abs(90 - P) < 10) && y.push({
|
|
2840
|
+
start: w,
|
|
2841
|
+
end: g
|
|
2831
2842
|
});
|
|
2832
2843
|
}
|
|
2833
2844
|
}), e.splice(
|
|
@@ -2848,7 +2859,7 @@ class Me {
|
|
|
2848
2859
|
searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2849
2860
|
const s = this.quadtree, i = e.direction();
|
|
2850
2861
|
e.start === t && i.multiplyScalar(-1);
|
|
2851
|
-
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new
|
|
2862
|
+
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new A(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
|
|
2852
2863
|
point: c.line.getIntersection(o),
|
|
2853
2864
|
line: c.line
|
|
2854
2865
|
})).filter((c) => c.point).sort((c, l) => t.distance(c.point) - t.distance(l.point));
|
|
@@ -2875,7 +2886,7 @@ class Me {
|
|
|
2875
2886
|
break;
|
|
2876
2887
|
}
|
|
2877
2888
|
}
|
|
2878
|
-
const l = new
|
|
2889
|
+
const l = new A(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((u) => ({
|
|
2879
2890
|
point: u.line.getIntersection(l),
|
|
2880
2891
|
line: u.line
|
|
2881
2892
|
})).filter((u) => u.point).sort((u, f) => t.distance(u.point) - t.distance(f.point));
|
|
@@ -2923,7 +2934,7 @@ class Se extends q {
|
|
|
2923
2934
|
* @param parent
|
|
2924
2935
|
*/
|
|
2925
2936
|
onAddFromParent(t) {
|
|
2926
|
-
this.Dxf = t.findComponentByType(k), this.Variable = this.parent?.findComponentByType(
|
|
2937
|
+
this.Dxf = t.findComponentByType(k), this.Variable = this.parent?.findComponentByType(Rt), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
|
|
2927
2938
|
}
|
|
2928
2939
|
/**
|
|
2929
2940
|
*
|
|
@@ -2955,7 +2966,7 @@ class Se extends q {
|
|
|
2955
2966
|
*/
|
|
2956
2967
|
addData(t, e) {
|
|
2957
2968
|
const n = this.Dxf;
|
|
2958
|
-
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new
|
|
2969
|
+
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new A(t.clone(), e.clone()));
|
|
2959
2970
|
}
|
|
2960
2971
|
/** 结果分析创建矩形
|
|
2961
2972
|
* @param result
|
|
@@ -2965,12 +2976,12 @@ class Se extends q {
|
|
|
2965
2976
|
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]);
|
|
2966
2977
|
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), u = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(u);
|
|
2967
2978
|
p.multiplyScalar(e.width * 0.5);
|
|
2968
|
-
const y = u.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)),
|
|
2969
|
-
if (!(
|
|
2979
|
+
const y = u.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), m = u.direction(f), L = y.direction(x);
|
|
2980
|
+
if (!(m.x > 0 && L.x < 0 || m.x < 0 && L.x > 0 || m.y > 0 && L.y < 0 || m.y < 0 && L.y > 0)) {
|
|
2970
2981
|
u.set(y.x, y.y), f.set(x.x, x.y);
|
|
2971
|
-
for (let
|
|
2972
|
-
const
|
|
2973
|
-
this.addData(
|
|
2982
|
+
for (let w = 1; w < o; w++) {
|
|
2983
|
+
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w), D = u.clone().add(g), E = f.clone().add(S);
|
|
2984
|
+
this.addData(D, E);
|
|
2974
2985
|
}
|
|
2975
2986
|
}
|
|
2976
2987
|
}
|
|
@@ -2997,7 +3008,7 @@ class Se extends q {
|
|
|
2997
3008
|
this.buildQuadtree();
|
|
2998
3009
|
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
2999
3010
|
e.forEach((i, r) => {
|
|
3000
|
-
const o = e[r], a =
|
|
3011
|
+
const o = e[r], a = et.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
3001
3012
|
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
3002
3013
|
try {
|
|
3003
3014
|
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
@@ -3046,7 +3057,7 @@ class Se extends q {
|
|
|
3046
3057
|
});
|
|
3047
3058
|
}
|
|
3048
3059
|
}
|
|
3049
|
-
class
|
|
3060
|
+
class Le extends q {
|
|
3050
3061
|
static name = "ThreeVJia";
|
|
3051
3062
|
lineSegments = [];
|
|
3052
3063
|
onAddFromParent() {
|
|
@@ -3058,8 +3069,8 @@ class Ee extends q {
|
|
|
3058
3069
|
t.resultList.forEach((l) => {
|
|
3059
3070
|
const h = s.get(l.target) ?? [], u = s.get(l.source) ?? [], f = l.project.clone(), p = l.project2.clone();
|
|
3060
3071
|
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points), u.push(...p.points), s.set(l.target, h), s.set(l.source, u);
|
|
3061
|
-
const y = new
|
|
3062
|
-
|
|
3072
|
+
const y = new A(f.start, p.start), x = new A(f.end, p.end), m = new A(y.center, x.center);
|
|
3073
|
+
m.userData.wallWidth = Math.max(y.length(), x.length()), r.push(m);
|
|
3063
3074
|
});
|
|
3064
3075
|
const a = [];
|
|
3065
3076
|
i = i.filter((l) => {
|
|
@@ -3075,7 +3086,7 @@ class Ee extends q {
|
|
|
3075
3086
|
const f = [];
|
|
3076
3087
|
for (let p = 0; p < h.length; p++) {
|
|
3077
3088
|
const y = h[p];
|
|
3078
|
-
y.userData.type === "start" ? (f.length === 0 && (a.push(new
|
|
3089
|
+
y.userData.type === "start" ? (f.length === 0 && (a.push(new A(u.start.clone(), y.clone())), u.start.copy(y)), f.push("start")) : (f.pop(), f.length === 0 && u.start.copy(y));
|
|
3079
3090
|
}
|
|
3080
3091
|
a.push(u);
|
|
3081
3092
|
}
|
|
@@ -3169,7 +3180,7 @@ class Ee extends q {
|
|
|
3169
3180
|
} else typeof global < "u" && (await Y("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
|
|
3170
3181
|
}
|
|
3171
3182
|
}
|
|
3172
|
-
class
|
|
3183
|
+
class ht extends se {
|
|
3173
3184
|
Dxf;
|
|
3174
3185
|
AngleCorrectionDxf;
|
|
3175
3186
|
Variable;
|
|
@@ -3181,7 +3192,7 @@ class ct extends ne {
|
|
|
3181
3192
|
* @param scale 原始数据缩放比例
|
|
3182
3193
|
*/
|
|
3183
3194
|
constructor(t = 0.1, e = 1) {
|
|
3184
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new we(), this.Variable = new
|
|
3195
|
+
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new we(), this.Variable = new Rt(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new Se()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new Le()), ht.finalInstance = this;
|
|
3185
3196
|
}
|
|
3186
3197
|
usePlugin(t) {
|
|
3187
3198
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3194,37 +3205,19 @@ class ct extends ne {
|
|
|
3194
3205
|
});
|
|
3195
3206
|
}
|
|
3196
3207
|
}
|
|
3197
|
-
|
|
3198
|
-
d.forEach((t) => {
|
|
3199
|
-
const e = t.direction();
|
|
3200
|
-
t.userData.drawWindow?.forEach((n) => {
|
|
3201
|
-
try {
|
|
3202
|
-
const s = M.from(n.p), i = t.projectPoint(
|
|
3203
|
-
s.clone().add(e.clone().multiplyScalar(n.width * 0.5)),
|
|
3204
|
-
!1
|
|
3205
|
-
), r = t.projectPoint(
|
|
3206
|
-
s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
|
|
3207
|
-
!1
|
|
3208
|
-
), o = t.projectLineSegment(new D(i, r)), a = o.center;
|
|
3209
|
-
n.p = new I.Vector3(a?.x ?? 0, a?.y ?? 0, n.p.z);
|
|
3210
|
-
} catch {
|
|
3211
|
-
}
|
|
3212
|
-
});
|
|
3213
|
-
});
|
|
3214
|
-
}
|
|
3215
|
-
class lt {
|
|
3208
|
+
class ut {
|
|
3216
3209
|
/** 通过轨迹点查找外墙
|
|
3217
3210
|
* @param lines
|
|
3218
3211
|
* @param trajectoryPoints
|
|
3219
3212
|
* @returns
|
|
3220
3213
|
*/
|
|
3221
3214
|
static findExtWallByTraj(t, e, n = 0.4) {
|
|
3222
|
-
const s = new F(
|
|
3215
|
+
const s = new F(N.fromByLineSegment(...t));
|
|
3223
3216
|
return t.forEach((i) => s.insert({ line: i, userData: void 0 })), t = t.filter((i) => {
|
|
3224
3217
|
const r = i.center, o = /* @__PURE__ */ new Set();
|
|
3225
3218
|
for (const a of e) {
|
|
3226
3219
|
if (o.size === 2) break;
|
|
3227
|
-
const c = new
|
|
3220
|
+
const c = new A(r, a);
|
|
3228
3221
|
if (!s.queryLineSegment(c).filter((h) => !(h.line === i || h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
|
|
3229
3222
|
const h = i.pointPosition(a);
|
|
3230
3223
|
h !== "on" && o.add(h);
|
|
@@ -3238,87 +3231,89 @@ class lt {
|
|
|
3238
3231
|
* @param trajectoryPoints
|
|
3239
3232
|
*/
|
|
3240
3233
|
static boundExtbyTraj(t, e, n = 0.12) {
|
|
3241
|
-
function s(
|
|
3242
|
-
return
|
|
3243
|
-
const
|
|
3244
|
-
|
|
3245
|
-
const
|
|
3246
|
-
if (
|
|
3234
|
+
function s(w, g) {
|
|
3235
|
+
return g.queryLineSegment(w).filter((S) => S.line !== w).map(({ line: S }) => {
|
|
3236
|
+
const D = { resultLine: S, type: "intersect", direction: "vertical", point: null, newLine: null };
|
|
3237
|
+
w.sameEndpoint(S) && (D.type = "endpoint"), w.parallel(S) && (D.direction = "parallel");
|
|
3238
|
+
const E = w.getSameEndpoint(S);
|
|
3239
|
+
if (E) D.point = E[1];
|
|
3247
3240
|
else {
|
|
3248
|
-
const
|
|
3249
|
-
|
|
3241
|
+
const b = S.getIntersection(w);
|
|
3242
|
+
b && (D.point = S.start.equal(b) ? S.start : S.end);
|
|
3250
3243
|
}
|
|
3251
|
-
return
|
|
3244
|
+
return D;
|
|
3252
3245
|
});
|
|
3253
3246
|
}
|
|
3254
|
-
function i(
|
|
3255
|
-
const
|
|
3256
|
-
if (
|
|
3257
|
-
const
|
|
3258
|
-
|
|
3259
|
-
} else if (
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3247
|
+
function i(w) {
|
|
3248
|
+
const g = w.userData.expandDirect;
|
|
3249
|
+
if (g === "left") {
|
|
3250
|
+
const S = w.getLeftDirection();
|
|
3251
|
+
w.directionMove(S, n * 0.5);
|
|
3252
|
+
} else if (g === "right") {
|
|
3253
|
+
const S = w.getRightDirection();
|
|
3254
|
+
w.directionMove(S, n * 0.5);
|
|
3262
3255
|
}
|
|
3263
3256
|
}
|
|
3264
|
-
function r({ resultLine:
|
|
3265
|
-
if (
|
|
3266
|
-
|
|
3267
|
-
else if (
|
|
3268
|
-
if (
|
|
3269
|
-
const
|
|
3270
|
-
|
|
3257
|
+
function r({ resultLine: w, type: g, direction: S, point: D }, E, b, R) {
|
|
3258
|
+
if (g === "intersect")
|
|
3259
|
+
D && D.copy(E.projectPoint(D) ?? D);
|
|
3260
|
+
else if (S === "vertical") {
|
|
3261
|
+
if (D) {
|
|
3262
|
+
const P = E.projectPoint(D, !1);
|
|
3263
|
+
D.copy(P), E.isPointOnSegment(P) || (E.start.distance(P) < E.end.distance(P) ? R.push(new A(P.clone(), E.start.clone())) : R.push(new A(P.clone(), E.end.clone())));
|
|
3271
3264
|
}
|
|
3272
|
-
} else if (!u.includes(
|
|
3273
|
-
let
|
|
3274
|
-
if (
|
|
3275
|
-
|
|
3276
|
-
const
|
|
3277
|
-
|
|
3265
|
+
} else if (!u.includes(w) && D) {
|
|
3266
|
+
let P = E.projectPoint(D, !1), B;
|
|
3267
|
+
if (E.start.distance(D) < E.end.distance(D) ? B = E.start : B = E.end, P) {
|
|
3268
|
+
R.push(new A(D.clone(), P.clone()));
|
|
3269
|
+
const C = new A(P.clone(), B.clone());
|
|
3270
|
+
C.length() && R.push(C);
|
|
3278
3271
|
}
|
|
3279
3272
|
}
|
|
3280
|
-
|
|
3273
|
+
b.update(w);
|
|
3281
3274
|
}
|
|
3282
|
-
const o = Object.keys(e).map((
|
|
3283
|
-
let c = t.map(({ start:
|
|
3284
|
-
const
|
|
3285
|
-
return
|
|
3275
|
+
const o = Object.keys(e).map((w) => M.from(e[w])), a = [];
|
|
3276
|
+
let c = t.map(({ start: w, end: g, ...S }) => {
|
|
3277
|
+
const D = new A(M.from(w), M.from(g));
|
|
3278
|
+
return D.userData = S, a.push(w.z ?? 0, g.z ?? 0), D;
|
|
3286
3279
|
});
|
|
3287
|
-
const l = a.reduce((
|
|
3288
|
-
let u =
|
|
3289
|
-
c = c.filter((
|
|
3290
|
-
const
|
|
3291
|
-
|
|
3292
|
-
const y =
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3280
|
+
const l = a.reduce((w, g) => w + g, 0) / a.length;
|
|
3281
|
+
let u = ut.findExtWallByTraj(c, o).filter((w) => w.userData.expandDirect);
|
|
3282
|
+
c = c.filter((w) => !u.includes(w)), c.push(...u);
|
|
3283
|
+
const p = this.parent?.findComponentByName("Renderer");
|
|
3284
|
+
o.forEach((w) => p.createPointMesh(w, 0.05, {}).position.z = l), p.createLineSegments(u, 0, { color: 65280 }).position.z = l + 1e-3;
|
|
3285
|
+
const y = A.groupBySamePointAndParallel(u), x = new F(N.fromByLineSegment(...c));
|
|
3286
|
+
c.forEach((w) => w.userData.isDoor || x.insert(w));
|
|
3287
|
+
const m = y.map((w) => w.flatMap((g) => s(g, x))), L = [];
|
|
3288
|
+
return y.flatMap((w, g) => (w.forEach((D) => (i(D), x.update(D))), m[g].filter((D) => {
|
|
3289
|
+
if (!u.includes(D.resultLine)) {
|
|
3290
|
+
let E;
|
|
3291
|
+
return Object.defineProperty(D, "newLine", {
|
|
3297
3292
|
get() {
|
|
3298
|
-
return
|
|
3293
|
+
return E || (E = A.mergeLines(...w)), E;
|
|
3299
3294
|
}
|
|
3300
3295
|
}), !0;
|
|
3301
3296
|
}
|
|
3302
|
-
r(
|
|
3303
|
-
}))).reduce((
|
|
3304
|
-
|
|
3305
|
-
const
|
|
3306
|
-
for (let
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3297
|
+
r(D, A.mergeLines(...w), x, L);
|
|
3298
|
+
}))).reduce((w, g) => (w.has(g.resultLine) || w.set(g.resultLine, []), w.get(g.resultLine)?.push(g), w), /* @__PURE__ */ new Map()).forEach((w) => {
|
|
3299
|
+
w.reduce((g, S) => (g.has(S.point) || g.set(S.point, []), g.get(S.point)?.push(S), g), /* @__PURE__ */ new Map()).forEach((g) => {
|
|
3300
|
+
const S = /* @__PURE__ */ new Set();
|
|
3301
|
+
for (let D = 0; D < g.length; D++) {
|
|
3302
|
+
const E = g[D];
|
|
3303
|
+
S.has(E.point) || (r(E, E.newLine, x, L), S.add(E.point));
|
|
3309
3304
|
}
|
|
3310
3305
|
});
|
|
3311
|
-
}), c.push(...
|
|
3306
|
+
}), c.push(...A.deduplication(L)), c.forEach((w) => w.userData.isWindow && Q(w)), c = lt(c), c = A.deduplication(c), J(c, l);
|
|
3312
3307
|
}
|
|
3313
3308
|
}
|
|
3314
3309
|
const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3315
3310
|
__proto__: null,
|
|
3316
|
-
AxisAlignCorr:
|
|
3317
|
-
BoundExt:
|
|
3318
|
-
lineDataToOriginalData:
|
|
3319
|
-
lineSegmentClipping:
|
|
3320
|
-
recomputedWindow:
|
|
3321
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3311
|
+
AxisAlignCorr: Pt,
|
|
3312
|
+
BoundExt: ut,
|
|
3313
|
+
lineDataToOriginalData: J,
|
|
3314
|
+
lineSegmentClipping: lt,
|
|
3315
|
+
recomputedWindow: Q
|
|
3316
|
+
}, Symbol.toStringTag, { value: "Module" })), St = {
|
|
3322
3317
|
POSITION: [
|
|
3323
3318
|
"byte",
|
|
3324
3319
|
"byte normalized",
|
|
@@ -3346,18 +3341,18 @@ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3346
3341
|
"unsigned short"
|
|
3347
3342
|
]
|
|
3348
3343
|
};
|
|
3349
|
-
class
|
|
3344
|
+
class tt {
|
|
3350
3345
|
constructor() {
|
|
3351
3346
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
3352
3347
|
return new Ce(t);
|
|
3353
3348
|
}), this.register(function(t) {
|
|
3354
3349
|
return new Be(t);
|
|
3355
3350
|
}), this.register(function(t) {
|
|
3356
|
-
return new
|
|
3357
|
-
}), this.register(function(t) {
|
|
3358
|
-
return new je(t);
|
|
3351
|
+
return new Ue(t);
|
|
3359
3352
|
}), this.register(function(t) {
|
|
3360
3353
|
return new ze(t);
|
|
3354
|
+
}), this.register(function(t) {
|
|
3355
|
+
return new je(t);
|
|
3361
3356
|
}), this.register(function(t) {
|
|
3362
3357
|
return new _e(t);
|
|
3363
3358
|
}), this.register(function(t) {
|
|
@@ -3365,17 +3360,17 @@ class Z {
|
|
|
3365
3360
|
}), this.register(function(t) {
|
|
3366
3361
|
return new Fe(t);
|
|
3367
3362
|
}), this.register(function(t) {
|
|
3368
|
-
return new
|
|
3363
|
+
return new Ge(t);
|
|
3369
3364
|
}), this.register(function(t) {
|
|
3370
3365
|
return new qe(t);
|
|
3371
3366
|
}), this.register(function(t) {
|
|
3372
3367
|
return new Ye(t);
|
|
3373
3368
|
}), this.register(function(t) {
|
|
3374
3369
|
return new ke(t);
|
|
3375
|
-
}), this.register(function(t) {
|
|
3376
|
-
return new Xe(t);
|
|
3377
3370
|
}), this.register(function(t) {
|
|
3378
3371
|
return new Ve(t);
|
|
3372
|
+
}), this.register(function(t) {
|
|
3373
|
+
return new Xe(t);
|
|
3379
3374
|
});
|
|
3380
3375
|
}
|
|
3381
3376
|
register(t) {
|
|
@@ -3400,7 +3395,7 @@ class Z {
|
|
|
3400
3395
|
});
|
|
3401
3396
|
}
|
|
3402
3397
|
}
|
|
3403
|
-
const
|
|
3398
|
+
const T = {
|
|
3404
3399
|
POINTS: 0,
|
|
3405
3400
|
LINES: 1,
|
|
3406
3401
|
LINE_LOOP: 2,
|
|
@@ -3424,23 +3419,23 @@ const b = {
|
|
|
3424
3419
|
CLAMP_TO_EDGE: 33071,
|
|
3425
3420
|
MIRRORED_REPEAT: 33648,
|
|
3426
3421
|
REPEAT: 10497
|
|
3427
|
-
},
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
const
|
|
3422
|
+
}, st = "KHR_mesh_quantization", G = {};
|
|
3423
|
+
G[Xt] = T.NEAREST;
|
|
3424
|
+
G[Wt] = T.NEAREST_MIPMAP_NEAREST;
|
|
3425
|
+
G[Ht] = T.NEAREST_MIPMAP_LINEAR;
|
|
3426
|
+
G[Jt] = T.LINEAR;
|
|
3427
|
+
G[$t] = T.LINEAR_MIPMAP_NEAREST;
|
|
3428
|
+
G[Kt] = T.LINEAR_MIPMAP_LINEAR;
|
|
3429
|
+
G[Zt] = T.CLAMP_TO_EDGE;
|
|
3430
|
+
G[Qt] = T.REPEAT;
|
|
3431
|
+
G[te] = T.MIRRORED_REPEAT;
|
|
3432
|
+
const Lt = {
|
|
3438
3433
|
scale: "scale",
|
|
3439
3434
|
position: "translation",
|
|
3440
3435
|
quaternion: "rotation",
|
|
3441
3436
|
morphTargetInfluences: "weights"
|
|
3442
|
-
},
|
|
3443
|
-
function
|
|
3437
|
+
}, Ee = new Ft(), Et = 12, De = 1179937895, Ae = 2, Dt = 8, Te = 1313821514, be = 5130562;
|
|
3438
|
+
function H(d, t) {
|
|
3444
3439
|
return d.length === t.length && d.every(function(e, n) {
|
|
3445
3440
|
return e === t[n];
|
|
3446
3441
|
});
|
|
@@ -3449,7 +3444,7 @@ function Ie(d) {
|
|
|
3449
3444
|
return new TextEncoder().encode(d).buffer;
|
|
3450
3445
|
}
|
|
3451
3446
|
function Pe(d) {
|
|
3452
|
-
return
|
|
3447
|
+
return H(d.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
3453
3448
|
}
|
|
3454
3449
|
function Re(d, t, e) {
|
|
3455
3450
|
const n = {
|
|
@@ -3459,15 +3454,15 @@ function Re(d, t, e) {
|
|
|
3459
3454
|
for (let s = t; s < t + e; s++)
|
|
3460
3455
|
for (let i = 0; i < d.itemSize; i++) {
|
|
3461
3456
|
let r;
|
|
3462
|
-
d.itemSize > 4 ? r = d.array[s * d.itemSize + i] : (i === 0 ? r = d.getX(s) : i === 1 ? r = d.getY(s) : i === 2 ? r = d.getZ(s) : i === 3 && (r = d.getW(s)), d.normalized === !0 && (r =
|
|
3457
|
+
d.itemSize > 4 ? r = d.array[s * d.itemSize + i] : (i === 0 ? r = d.getX(s) : i === 1 ? r = d.getY(s) : i === 2 ? r = d.getZ(s) : i === 3 && (r = d.getW(s)), d.normalized === !0 && (r = ot.normalize(r, d.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
3463
3458
|
}
|
|
3464
3459
|
return n;
|
|
3465
3460
|
}
|
|
3466
|
-
function
|
|
3461
|
+
function vt(d) {
|
|
3467
3462
|
return Math.ceil(d / 4) * 4;
|
|
3468
3463
|
}
|
|
3469
|
-
function
|
|
3470
|
-
const e =
|
|
3464
|
+
function it(d, t = 0) {
|
|
3465
|
+
const e = vt(d.byteLength);
|
|
3471
3466
|
if (e !== d.byteLength) {
|
|
3472
3467
|
const n = new Uint8Array(e);
|
|
3473
3468
|
if (n.set(new Uint8Array(d)), t !== 0)
|
|
@@ -3477,7 +3472,7 @@ function nt(d, t = 0) {
|
|
|
3477
3472
|
}
|
|
3478
3473
|
return d;
|
|
3479
3474
|
}
|
|
3480
|
-
function
|
|
3475
|
+
function At() {
|
|
3481
3476
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
3482
3477
|
}
|
|
3483
3478
|
function ve(d, t) {
|
|
@@ -3532,23 +3527,23 @@ class Ne {
|
|
|
3532
3527
|
const s = this, i = s.buffers, r = s.json;
|
|
3533
3528
|
n = s.options;
|
|
3534
3529
|
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
3535
|
-
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 ?
|
|
3536
|
-
const f =
|
|
3530
|
+
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 ? rt(c).then(function(u) {
|
|
3531
|
+
const f = it(u), p = new DataView(new ArrayBuffer(Dt));
|
|
3537
3532
|
p.setUint32(0, f.byteLength, !0), p.setUint32(4, be, !0);
|
|
3538
|
-
const y =
|
|
3533
|
+
const y = it(Ie(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(Dt));
|
|
3539
3534
|
x.setUint32(0, y.byteLength, !0), x.setUint32(4, Te, !0);
|
|
3540
|
-
const
|
|
3541
|
-
|
|
3542
|
-
const
|
|
3543
|
-
|
|
3544
|
-
const
|
|
3545
|
-
|
|
3535
|
+
const m = new ArrayBuffer(Et), L = new DataView(m);
|
|
3536
|
+
L.setUint32(0, De, !0), L.setUint32(4, Ae, !0);
|
|
3537
|
+
const w = Et + x.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
3538
|
+
L.setUint32(8, w, !0);
|
|
3539
|
+
const g = new Blob([
|
|
3540
|
+
m,
|
|
3546
3541
|
x,
|
|
3547
3542
|
y,
|
|
3548
3543
|
p,
|
|
3549
3544
|
f
|
|
3550
3545
|
], { type: "application/octet-stream" });
|
|
3551
|
-
|
|
3546
|
+
rt(g).then((S) => {
|
|
3552
3547
|
e(S);
|
|
3553
3548
|
});
|
|
3554
3549
|
}) : r.buffers && r.buffers.length > 0 ? We(c).then((u) => {
|
|
@@ -3599,7 +3594,7 @@ class Ne {
|
|
|
3599
3594
|
*/
|
|
3600
3595
|
isNormalizedNormalAttribute(t) {
|
|
3601
3596
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
3602
|
-
const n = new
|
|
3597
|
+
const n = new K();
|
|
3603
3598
|
for (let s = 0, i = t.count; s < i; s++)
|
|
3604
3599
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
3605
3600
|
return !0;
|
|
@@ -3614,7 +3609,7 @@ class Ne {
|
|
|
3614
3609
|
createNormalizedNormalAttribute(t) {
|
|
3615
3610
|
const e = this.cache;
|
|
3616
3611
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
3617
|
-
const n = t.clone(), s = new
|
|
3612
|
+
const n = t.clone(), s = new K();
|
|
3618
3613
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3619
3614
|
s.fromBufferAttribute(n, i), s.x === 0 && s.y === 0 && s.z === 0 ? s.setX(1) : s.normalize(), n.setXYZ(i, s.x, s.y, s.z);
|
|
3620
3615
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -3634,14 +3629,14 @@ class Ne {
|
|
|
3634
3629
|
async buildMetalRoughTextureAsync(t, e) {
|
|
3635
3630
|
if (t === e) return t;
|
|
3636
3631
|
function n(f) {
|
|
3637
|
-
return f.colorSpace ===
|
|
3632
|
+
return f.colorSpace === Vt ? function(y) {
|
|
3638
3633
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3639
3634
|
} : function(y) {
|
|
3640
3635
|
return y;
|
|
3641
3636
|
};
|
|
3642
3637
|
}
|
|
3643
|
-
t instanceof
|
|
3644
|
-
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 =
|
|
3638
|
+
t instanceof nt && (t = await this.decompressTextureAsync(t)), e instanceof nt && (e = await this.decompressTextureAsync(e));
|
|
3639
|
+
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 = At();
|
|
3645
3640
|
a.width = r, a.height = o;
|
|
3646
3641
|
const c = a.getContext("2d", {
|
|
3647
3642
|
willReadFrequently: !0
|
|
@@ -3662,7 +3657,7 @@ class Ne {
|
|
|
3662
3657
|
}
|
|
3663
3658
|
c.putImageData(l, 0, 0);
|
|
3664
3659
|
const u = (t || e).clone();
|
|
3665
|
-
return u.source = new
|
|
3660
|
+
return u.source = new zt(a), u.colorSpace = jt, u.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."), u;
|
|
3666
3661
|
}
|
|
3667
3662
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
3668
3663
|
if (this.textureUtils === null)
|
|
@@ -3692,25 +3687,25 @@ class Ne {
|
|
|
3692
3687
|
r.bufferViews || (r.bufferViews = []);
|
|
3693
3688
|
let o;
|
|
3694
3689
|
switch (e) {
|
|
3695
|
-
case
|
|
3696
|
-
case
|
|
3690
|
+
case T.BYTE:
|
|
3691
|
+
case T.UNSIGNED_BYTE:
|
|
3697
3692
|
o = 1;
|
|
3698
3693
|
break;
|
|
3699
|
-
case
|
|
3700
|
-
case
|
|
3694
|
+
case T.SHORT:
|
|
3695
|
+
case T.UNSIGNED_SHORT:
|
|
3701
3696
|
o = 2;
|
|
3702
3697
|
break;
|
|
3703
3698
|
default:
|
|
3704
3699
|
o = 4;
|
|
3705
3700
|
}
|
|
3706
3701
|
let a = t.itemSize * o;
|
|
3707
|
-
i ===
|
|
3708
|
-
const c =
|
|
3702
|
+
i === T.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
|
|
3703
|
+
const c = vt(s * a), l = new DataView(new ArrayBuffer(c));
|
|
3709
3704
|
let h = 0;
|
|
3710
3705
|
for (let p = n; p < n + s; p++) {
|
|
3711
3706
|
for (let y = 0; y < t.itemSize; y++) {
|
|
3712
3707
|
let x;
|
|
3713
|
-
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x =
|
|
3708
|
+
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x = ot.normalize(x, t.array))), e === T.FLOAT ? l.setFloat32(h, x, !0) : e === T.INT ? l.setInt32(h, x, !0) : e === T.UNSIGNED_INT ? l.setUint32(h, x, !0) : e === T.SHORT ? l.setInt16(h, x, !0) : e === T.UNSIGNED_SHORT ? l.setUint16(h, x, !0) : e === T.BYTE ? l.setInt8(h, x) : e === T.UNSIGNED_BYTE && l.setUint8(h, x), h += o;
|
|
3714
3709
|
}
|
|
3715
3710
|
h % a !== 0 && (h += a - h % a);
|
|
3716
3711
|
}
|
|
@@ -3719,7 +3714,7 @@ class Ne {
|
|
|
3719
3714
|
byteOffset: this.byteOffset,
|
|
3720
3715
|
byteLength: c
|
|
3721
3716
|
};
|
|
3722
|
-
return i !== void 0 && (u.target = i), i ===
|
|
3717
|
+
return i !== void 0 && (u.target = i), i === T.ARRAY_BUFFER && (u.byteStride = a), this.byteOffset += c, r.bufferViews.push(u), {
|
|
3723
3718
|
id: r.bufferViews.length - 1,
|
|
3724
3719
|
byteLength: 0
|
|
3725
3720
|
};
|
|
@@ -3732,8 +3727,8 @@ class Ne {
|
|
|
3732
3727
|
processBufferViewImage(t) {
|
|
3733
3728
|
const e = this, n = e.json;
|
|
3734
3729
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3735
|
-
|
|
3736
|
-
const r =
|
|
3730
|
+
rt(t).then((i) => {
|
|
3731
|
+
const r = it(i), o = {
|
|
3737
3732
|
buffer: e.processBuffer(r),
|
|
3738
3733
|
byteOffset: e.byteOffset,
|
|
3739
3734
|
byteLength: r.byteLength
|
|
@@ -3761,25 +3756,25 @@ class Ne {
|
|
|
3761
3756
|
};
|
|
3762
3757
|
let o;
|
|
3763
3758
|
if (t.array.constructor === Float32Array)
|
|
3764
|
-
o =
|
|
3759
|
+
o = T.FLOAT;
|
|
3765
3760
|
else if (t.array.constructor === Int32Array)
|
|
3766
|
-
o =
|
|
3761
|
+
o = T.INT;
|
|
3767
3762
|
else if (t.array.constructor === Uint32Array)
|
|
3768
|
-
o =
|
|
3763
|
+
o = T.UNSIGNED_INT;
|
|
3769
3764
|
else if (t.array.constructor === Int16Array)
|
|
3770
|
-
o =
|
|
3765
|
+
o = T.SHORT;
|
|
3771
3766
|
else if (t.array.constructor === Uint16Array)
|
|
3772
|
-
o =
|
|
3767
|
+
o = T.UNSIGNED_SHORT;
|
|
3773
3768
|
else if (t.array.constructor === Int8Array)
|
|
3774
|
-
o =
|
|
3769
|
+
o = T.BYTE;
|
|
3775
3770
|
else if (t.array.constructor === Uint8Array)
|
|
3776
|
-
o =
|
|
3771
|
+
o = T.UNSIGNED_BYTE;
|
|
3777
3772
|
else
|
|
3778
3773
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
3779
3774
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
3780
3775
|
const a = Re(t, n, s);
|
|
3781
3776
|
let c;
|
|
3782
|
-
e !== void 0 && (c = t === e.index ?
|
|
3777
|
+
e !== void 0 && (c = t === e.index ? T.ELEMENT_ARRAY_BUFFER : T.ARRAY_BUFFER);
|
|
3783
3778
|
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
3784
3779
|
bufferView: l.id,
|
|
3785
3780
|
byteOffset: l.byteOffset,
|
|
@@ -3806,16 +3801,16 @@ class Ne {
|
|
|
3806
3801
|
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
3807
3802
|
if (l[h] !== void 0) return l[h];
|
|
3808
3803
|
o.images || (o.images = []);
|
|
3809
|
-
const u = { mimeType: s }, f =
|
|
3804
|
+
const u = { mimeType: s }, f = At();
|
|
3810
3805
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
3811
3806
|
const p = f.getContext("2d", {
|
|
3812
3807
|
willReadFrequently: !0
|
|
3813
3808
|
});
|
|
3814
3809
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
3815
|
-
e !==
|
|
3810
|
+
e !== _t && console.error("GLTFExporter: Only RGBAFormat is supported.", e), (t.width > a.maxTextureSize || t.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", t);
|
|
3816
3811
|
const x = new Uint8ClampedArray(t.height * t.width * 4);
|
|
3817
|
-
for (let
|
|
3818
|
-
x[
|
|
3812
|
+
for (let m = 0; m < x.length; m += 4)
|
|
3813
|
+
x[m + 0] = t.data[m + 0], x[m + 1] = t.data[m + 1], x[m + 2] = t.data[m + 2], x[m + 3] = t.data[m + 3];
|
|
3819
3814
|
p.putImageData(new ImageData(x, t.width, t.height), 0, 0);
|
|
3820
3815
|
} 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)
|
|
3821
3816
|
p.drawImage(t, 0, 0, f.width, f.height);
|
|
@@ -3825,7 +3820,7 @@ class Ne {
|
|
|
3825
3820
|
ve(f, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3826
3821
|
u.bufferView = x;
|
|
3827
3822
|
})
|
|
3828
|
-
) : u.uri =
|
|
3823
|
+
) : u.uri = qt.getDataURL(f, s);
|
|
3829
3824
|
const y = o.images.push(u) - 1;
|
|
3830
3825
|
return l[h] = y, y;
|
|
3831
3826
|
} else
|
|
@@ -3840,10 +3835,10 @@ class Ne {
|
|
|
3840
3835
|
const e = this.json;
|
|
3841
3836
|
e.samplers || (e.samplers = []);
|
|
3842
3837
|
const n = {
|
|
3843
|
-
magFilter:
|
|
3844
|
-
minFilter:
|
|
3845
|
-
wrapS:
|
|
3846
|
-
wrapT:
|
|
3838
|
+
magFilter: G[t.magFilter],
|
|
3839
|
+
minFilter: G[t.minFilter],
|
|
3840
|
+
wrapS: G[t.wrapS],
|
|
3841
|
+
wrapT: G[t.wrapT]
|
|
3847
3842
|
};
|
|
3848
3843
|
return e.samplers.push(n) - 1;
|
|
3849
3844
|
}
|
|
@@ -3855,7 +3850,7 @@ class Ne {
|
|
|
3855
3850
|
async processTextureAsync(t) {
|
|
3856
3851
|
const n = this.options, s = this.cache, i = this.json;
|
|
3857
3852
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
3858
|
-
i.textures || (i.textures = []), t instanceof
|
|
3853
|
+
i.textures || (i.textures = []), t instanceof nt && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
3859
3854
|
let r = t.userData.mimeType;
|
|
3860
3855
|
r === "image/webp" && (r = "image/png");
|
|
3861
3856
|
const o = {
|
|
@@ -3882,7 +3877,7 @@ class Ne {
|
|
|
3882
3877
|
const s = { pbrMetallicRoughness: {} };
|
|
3883
3878
|
t.isMeshStandardMaterial !== !0 && t.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
|
|
3884
3879
|
const i = t.color.toArray().concat([t.opacity]);
|
|
3885
|
-
if (
|
|
3880
|
+
if (H(i, [1, 1, 1, 1]) || (s.pbrMetallicRoughness.baseColorFactor = i), t.isMeshStandardMaterial ? (s.pbrMetallicRoughness.metallicFactor = t.metalness, s.pbrMetallicRoughness.roughnessFactor = t.roughness) : (s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 1), t.metalnessMap || t.roughnessMap) {
|
|
3886
3881
|
const o = await this.buildMetalRoughTextureAsync(t.metalnessMap, t.roughnessMap), a = {
|
|
3887
3882
|
index: await this.processTextureAsync(o),
|
|
3888
3883
|
texCoord: o.channel
|
|
@@ -3920,7 +3915,7 @@ class Ne {
|
|
|
3920
3915
|
};
|
|
3921
3916
|
t.aoMapIntensity !== 1 && (o.strength = t.aoMapIntensity), this.applyTextureTransform(o, t.aoMap), s.occlusionTexture = o;
|
|
3922
3917
|
}
|
|
3923
|
-
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side ===
|
|
3918
|
+
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === Yt && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
|
|
3924
3919
|
o.writeMaterialAsync && await o.writeMaterialAsync(t, s);
|
|
3925
3920
|
});
|
|
3926
3921
|
const r = n.materials.push(s) - 1;
|
|
@@ -3934,15 +3929,15 @@ class Ne {
|
|
|
3934
3929
|
async processMeshAsync(t) {
|
|
3935
3930
|
const e = this.cache, n = this.json, s = [t.geometry.uuid];
|
|
3936
3931
|
if (Array.isArray(t.material))
|
|
3937
|
-
for (let
|
|
3938
|
-
s.push(t.material[
|
|
3932
|
+
for (let g = 0, S = t.material.length; g < S; g++)
|
|
3933
|
+
s.push(t.material[g].uuid);
|
|
3939
3934
|
else
|
|
3940
3935
|
s.push(t.material.uuid);
|
|
3941
3936
|
const i = s.join(":");
|
|
3942
3937
|
if (e.meshes.has(i)) return e.meshes.get(i);
|
|
3943
3938
|
const r = t.geometry;
|
|
3944
3939
|
let o;
|
|
3945
|
-
t.isLineSegments ? o =
|
|
3940
|
+
t.isLineSegments ? o = T.LINES : t.isLineLoop ? o = T.LINE_LOOP : t.isLine ? o = T.LINE_STRIP : t.isPoints ? o = T.POINTS : o = t.material.wireframe ? T.LINES : T.TRIANGLES;
|
|
3946
3941
|
const a = {}, c = {}, l = [], h = [], u = {
|
|
3947
3942
|
uv: "TEXCOORD_0",
|
|
3948
3943
|
uv1: "TEXCOORD_1",
|
|
@@ -3954,76 +3949,76 @@ class Ne {
|
|
|
3954
3949
|
}, f = r.getAttribute("normal");
|
|
3955
3950
|
f !== void 0 && !this.isNormalizedNormalAttribute(f) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(f)));
|
|
3956
3951
|
let p = null;
|
|
3957
|
-
for (let
|
|
3958
|
-
if (
|
|
3959
|
-
const S = r.attributes[
|
|
3960
|
-
if (
|
|
3961
|
-
c[
|
|
3952
|
+
for (let g in r.attributes) {
|
|
3953
|
+
if (g.slice(0, 5) === "morph") continue;
|
|
3954
|
+
const S = r.attributes[g];
|
|
3955
|
+
if (g = u[g] || g.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g) || (g = "_" + g), e.attributes.has(this.getUID(S))) {
|
|
3956
|
+
c[g] = e.attributes.get(this.getUID(S));
|
|
3962
3957
|
continue;
|
|
3963
3958
|
}
|
|
3964
3959
|
p = null;
|
|
3965
|
-
const
|
|
3966
|
-
|
|
3967
|
-
const
|
|
3968
|
-
|
|
3960
|
+
const E = S.array;
|
|
3961
|
+
g === "JOINTS_0" && !(E instanceof Uint16Array) && !(E instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new _(new Uint16Array(E), S.itemSize, S.normalized)) : (E instanceof Uint32Array || E instanceof Int32Array) && !g.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${g}" converted to type FLOAT.`), p = tt.Utils.toFloat32BufferAttribute(S));
|
|
3962
|
+
const b = this.processAccessor(p || S, r);
|
|
3963
|
+
b !== null && (g.startsWith("_") || this.detectMeshQuantization(g, S), c[g] = b, e.attributes.set(this.getUID(S), b));
|
|
3969
3964
|
}
|
|
3970
3965
|
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
3971
3966
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
3972
|
-
const
|
|
3967
|
+
const g = [], S = [], D = {};
|
|
3973
3968
|
if (t.morphTargetDictionary !== void 0)
|
|
3974
|
-
for (const
|
|
3975
|
-
|
|
3976
|
-
for (let
|
|
3977
|
-
const
|
|
3978
|
-
let
|
|
3979
|
-
for (const
|
|
3980
|
-
if (
|
|
3981
|
-
|
|
3969
|
+
for (const E in t.morphTargetDictionary)
|
|
3970
|
+
D[t.morphTargetDictionary[E]] = E;
|
|
3971
|
+
for (let E = 0; E < t.morphTargetInfluences.length; ++E) {
|
|
3972
|
+
const b = {};
|
|
3973
|
+
let R = !1;
|
|
3974
|
+
for (const P in r.morphAttributes) {
|
|
3975
|
+
if (P !== "position" && P !== "normal") {
|
|
3976
|
+
R || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), R = !0);
|
|
3982
3977
|
continue;
|
|
3983
3978
|
}
|
|
3984
|
-
const
|
|
3985
|
-
if (e.attributes.has(this.getUID(
|
|
3986
|
-
|
|
3979
|
+
const B = r.morphAttributes[P][E], C = P.toUpperCase(), U = r.attributes[P];
|
|
3980
|
+
if (e.attributes.has(this.getUID(B, !0))) {
|
|
3981
|
+
b[C] = e.attributes.get(this.getUID(B, !0));
|
|
3987
3982
|
continue;
|
|
3988
3983
|
}
|
|
3989
|
-
const
|
|
3984
|
+
const O = B.clone();
|
|
3990
3985
|
if (!r.morphTargetsRelative)
|
|
3991
|
-
for (let v = 0, V =
|
|
3992
|
-
for (let
|
|
3993
|
-
|
|
3994
|
-
|
|
3986
|
+
for (let v = 0, V = B.count; v < V; v++)
|
|
3987
|
+
for (let z = 0; z < B.itemSize; z++)
|
|
3988
|
+
z === 0 && O.setX(v, B.getX(v) - U.getX(v)), z === 1 && O.setY(v, B.getY(v) - U.getY(v)), z === 2 && O.setZ(v, B.getZ(v) - U.getZ(v)), z === 3 && O.setW(v, B.getW(v) - U.getW(v));
|
|
3989
|
+
b[C] = this.processAccessor(O, r), e.attributes.set(this.getUID(U, !0), b[C]);
|
|
3995
3990
|
}
|
|
3996
|
-
h.push(
|
|
3991
|
+
h.push(b), g.push(t.morphTargetInfluences[E]), t.morphTargetDictionary !== void 0 && S.push(D[E]);
|
|
3997
3992
|
}
|
|
3998
|
-
a.weights =
|
|
3993
|
+
a.weights = g, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
3999
3994
|
}
|
|
4000
3995
|
const y = Array.isArray(t.material);
|
|
4001
3996
|
if (y && r.groups.length === 0) return null;
|
|
4002
3997
|
let x = !1;
|
|
4003
3998
|
if (y && r.index === null) {
|
|
4004
|
-
const
|
|
4005
|
-
for (let S = 0,
|
|
4006
|
-
|
|
4007
|
-
r.setIndex(
|
|
3999
|
+
const g = [];
|
|
4000
|
+
for (let S = 0, D = r.attributes.position.count; S < D; S++)
|
|
4001
|
+
g[S] = S;
|
|
4002
|
+
r.setIndex(g), x = !0;
|
|
4008
4003
|
}
|
|
4009
|
-
const
|
|
4010
|
-
for (let
|
|
4011
|
-
const
|
|
4004
|
+
const m = y ? t.material : [t.material], L = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
4005
|
+
for (let g = 0, S = L.length; g < S; g++) {
|
|
4006
|
+
const D = {
|
|
4012
4007
|
mode: o,
|
|
4013
4008
|
attributes: c
|
|
4014
4009
|
};
|
|
4015
|
-
if (this.serializeUserData(r,
|
|
4016
|
-
let
|
|
4017
|
-
(
|
|
4010
|
+
if (this.serializeUserData(r, D), h.length > 0 && (D.targets = h), r.index !== null) {
|
|
4011
|
+
let b = this.getUID(r.index);
|
|
4012
|
+
(L[g].start !== void 0 || L[g].count !== void 0) && (b += ":" + L[g].start + ":" + L[g].count), e.attributes.has(b) ? D.indices = e.attributes.get(b) : (D.indices = this.processAccessor(r.index, r, L[g].start, L[g].count), e.attributes.set(b, D.indices)), D.indices === null && delete D.indices;
|
|
4018
4013
|
}
|
|
4019
|
-
const
|
|
4020
|
-
|
|
4014
|
+
const E = await this.processMaterialAsync(m[L[g].materialIndex]);
|
|
4015
|
+
E !== null && (D.material = E), l.push(D);
|
|
4021
4016
|
}
|
|
4022
|
-
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(
|
|
4023
|
-
|
|
4017
|
+
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(g) {
|
|
4018
|
+
g.writeMesh && g.writeMesh(t, a);
|
|
4024
4019
|
});
|
|
4025
|
-
const
|
|
4026
|
-
return e.meshes.set(i,
|
|
4020
|
+
const w = n.meshes.push(a) - 1;
|
|
4021
|
+
return e.meshes.set(i, w), w;
|
|
4027
4022
|
}
|
|
4028
4023
|
/**
|
|
4029
4024
|
* If a vertex attribute with a
|
|
@@ -4037,7 +4032,7 @@ class Ne {
|
|
|
4037
4032
|
* @param {THREE.BufferAttribute} attribute
|
|
4038
4033
|
*/
|
|
4039
4034
|
detectMeshQuantization(t, e) {
|
|
4040
|
-
if (this.extensionsUsed[
|
|
4035
|
+
if (this.extensionsUsed[st]) return;
|
|
4041
4036
|
let n;
|
|
4042
4037
|
switch (e.array.constructor) {
|
|
4043
4038
|
case Int8Array:
|
|
@@ -4057,7 +4052,7 @@ class Ne {
|
|
|
4057
4052
|
}
|
|
4058
4053
|
e.normalized && (n += " normalized");
|
|
4059
4054
|
const s = t.split("_", 1)[0];
|
|
4060
|
-
|
|
4055
|
+
St[s] && St[s].includes(n) && (this.extensionsUsed[st] = !0, this.extensionsRequired[st] = !0);
|
|
4061
4056
|
}
|
|
4062
4057
|
/**
|
|
4063
4058
|
* Process camera
|
|
@@ -4077,7 +4072,7 @@ class Ne {
|
|
|
4077
4072
|
znear: t.near < 0 ? 0 : t.near
|
|
4078
4073
|
} : s.perspective = {
|
|
4079
4074
|
aspectRatio: t.aspect,
|
|
4080
|
-
yfov:
|
|
4075
|
+
yfov: ot.degToRad(t.fov),
|
|
4081
4076
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4082
4077
|
znear: t.near < 0 ? 0 : t.near
|
|
4083
4078
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4094,21 +4089,21 @@ class Ne {
|
|
|
4094
4089
|
*/
|
|
4095
4090
|
processAnimation(t, e) {
|
|
4096
4091
|
const n = this.json, s = this.nodeMap;
|
|
4097
|
-
n.animations || (n.animations = []), t =
|
|
4092
|
+
n.animations || (n.animations = []), t = tt.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4098
4093
|
const i = t.tracks, r = [], o = [];
|
|
4099
4094
|
for (let c = 0; c < i.length; ++c) {
|
|
4100
|
-
const l = i[c], h =
|
|
4101
|
-
let u =
|
|
4102
|
-
const f =
|
|
4095
|
+
const l = i[c], h = Z.parseTrackName(l.name);
|
|
4096
|
+
let u = Z.findNode(e, h.nodeName);
|
|
4097
|
+
const f = Lt[h.propertyName];
|
|
4103
4098
|
if (h.objectName === "bones" && (u.isSkinnedMesh === !0 ? u = u.skeleton.getBoneByName(h.objectIndex) : u = void 0), !u || !f) {
|
|
4104
4099
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4105
4100
|
continue;
|
|
4106
4101
|
}
|
|
4107
4102
|
const p = 1;
|
|
4108
4103
|
let y = l.values.length / l.times.length;
|
|
4109
|
-
f ===
|
|
4104
|
+
f === Lt.morphTargetInfluences && (y /= u.morphTargetInfluences.length);
|
|
4110
4105
|
let x;
|
|
4111
|
-
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() ===
|
|
4106
|
+
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() === kt ? x = "STEP" : x = "LINEAR", o.push({
|
|
4112
4107
|
input: this.processAccessor(new _(l.times, p)),
|
|
4113
4108
|
output: this.processAccessor(new _(l.values, y)),
|
|
4114
4109
|
interpolation: x
|
|
@@ -4136,7 +4131,7 @@ class Ne {
|
|
|
4136
4131
|
if (i === void 0) return null;
|
|
4137
4132
|
const r = t.skeleton.bones[0];
|
|
4138
4133
|
if (r === void 0) return null;
|
|
4139
|
-
const o = [], a = new Float32Array(i.bones.length * 16), c = new
|
|
4134
|
+
const o = [], a = new Float32Array(i.bones.length * 16), c = new bt();
|
|
4140
4135
|
for (let h = 0; h < i.bones.length; ++h)
|
|
4141
4136
|
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4142
4137
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
@@ -4156,7 +4151,7 @@ class Ne {
|
|
|
4156
4151
|
const i = {};
|
|
4157
4152
|
if (n.trs) {
|
|
4158
4153
|
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4159
|
-
|
|
4154
|
+
H(o, [0, 0, 0, 1]) || (i.rotation = o), H(a, [0, 0, 0]) || (i.translation = a), H(c, [1, 1, 1]) || (i.scale = c);
|
|
4160
4155
|
} else
|
|
4161
4156
|
t.matrixAutoUpdate && t.updateMatrix(), Pe(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4162
4157
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
@@ -4204,7 +4199,7 @@ class Ne {
|
|
|
4204
4199
|
* @param {Array<THREE.Object3D>} objects List of objects to process
|
|
4205
4200
|
*/
|
|
4206
4201
|
async processObjectsAsync(t) {
|
|
4207
|
-
const e = new
|
|
4202
|
+
const e = new ft();
|
|
4208
4203
|
e.name = "AuxScene";
|
|
4209
4204
|
for (let n = 0; n < t.length; n++)
|
|
4210
4205
|
e.children.push(t[n]);
|
|
@@ -4220,7 +4215,7 @@ class Ne {
|
|
|
4220
4215
|
});
|
|
4221
4216
|
const n = [];
|
|
4222
4217
|
for (let s = 0; s < t.length; s++)
|
|
4223
|
-
t[s] instanceof
|
|
4218
|
+
t[s] instanceof ft ? await this.processSceneAsync(t[s]) : n.push(t[s]);
|
|
4224
4219
|
n.length > 0 && await this.processObjectsAsync(n);
|
|
4225
4220
|
for (let s = 0; s < this.skins.length; ++s)
|
|
4226
4221
|
this.processSkin(this.skins[s]);
|
|
@@ -4302,7 +4297,7 @@ class Fe {
|
|
|
4302
4297
|
i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4303
4298
|
}
|
|
4304
4299
|
}
|
|
4305
|
-
class
|
|
4300
|
+
class Ge {
|
|
4306
4301
|
constructor(t) {
|
|
4307
4302
|
this.writer = t, this.name = "KHR_materials_iridescence";
|
|
4308
4303
|
}
|
|
@@ -4326,7 +4321,7 @@ class Ue {
|
|
|
4326
4321
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4327
4322
|
}
|
|
4328
4323
|
}
|
|
4329
|
-
class
|
|
4324
|
+
class Ue {
|
|
4330
4325
|
constructor(t) {
|
|
4331
4326
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4332
4327
|
}
|
|
@@ -4343,7 +4338,7 @@ class Ge {
|
|
|
4343
4338
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4344
4339
|
}
|
|
4345
4340
|
}
|
|
4346
|
-
class
|
|
4341
|
+
class ze {
|
|
4347
4342
|
constructor(t) {
|
|
4348
4343
|
this.writer = t, this.name = "KHR_materials_volume";
|
|
4349
4344
|
}
|
|
@@ -4360,7 +4355,7 @@ class je {
|
|
|
4360
4355
|
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;
|
|
4361
4356
|
}
|
|
4362
4357
|
}
|
|
4363
|
-
class
|
|
4358
|
+
class je {
|
|
4364
4359
|
constructor(t) {
|
|
4365
4360
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
4366
4361
|
}
|
|
@@ -4375,7 +4370,7 @@ class _e {
|
|
|
4375
4370
|
this.writer = t, this.name = "KHR_materials_specular";
|
|
4376
4371
|
}
|
|
4377
4372
|
async writeMaterialAsync(t, e) {
|
|
4378
|
-
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(
|
|
4373
|
+
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(Ee) && !t.specularIntensityMap && !t.specularColorMap) return;
|
|
4379
4374
|
const n = this.writer, s = n.extensionsUsed, i = {};
|
|
4380
4375
|
if (t.specularIntensityMap) {
|
|
4381
4376
|
const r = {
|
|
@@ -4442,7 +4437,7 @@ class ke {
|
|
|
4442
4437
|
i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4443
4438
|
}
|
|
4444
4439
|
}
|
|
4445
|
-
class
|
|
4440
|
+
class Ve {
|
|
4446
4441
|
constructor(t) {
|
|
4447
4442
|
this.writer = t, this.name = "EXT_materials_bump";
|
|
4448
4443
|
}
|
|
@@ -4459,13 +4454,13 @@ class Xe {
|
|
|
4459
4454
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4460
4455
|
}
|
|
4461
4456
|
}
|
|
4462
|
-
class
|
|
4457
|
+
class Xe {
|
|
4463
4458
|
constructor(t) {
|
|
4464
4459
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
4465
4460
|
}
|
|
4466
4461
|
writeNode(t, e) {
|
|
4467
4462
|
if (!t.isInstancedMesh) return;
|
|
4468
|
-
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
|
|
4463
|
+
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 bt(), c = new K(), l = new Gt(), h = new K();
|
|
4469
4464
|
for (let f = 0; f < s.count; f++)
|
|
4470
4465
|
s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
|
|
4471
4466
|
const u = {
|
|
@@ -4476,7 +4471,7 @@ class Ve {
|
|
|
4476
4471
|
s.instanceColor && (u._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: u }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
|
|
4477
4472
|
}
|
|
4478
4473
|
}
|
|
4479
|
-
|
|
4474
|
+
tt.Utils = {
|
|
4480
4475
|
insertKeyframe: function(d, t) {
|
|
4481
4476
|
const n = d.getValueSize(), s = new d.TimeBufferType(d.times.length + 1), i = new d.ValueBufferType(d.values.length + n), r = d.createInterpolant(new d.ValueBufferType(n));
|
|
4482
4477
|
let o;
|
|
@@ -4506,7 +4501,7 @@ Z.Utils = {
|
|
|
4506
4501
|
const e = [], n = {}, s = d.tracks;
|
|
4507
4502
|
for (let i = 0; i < s.length; ++i) {
|
|
4508
4503
|
let r = s[i];
|
|
4509
|
-
const o =
|
|
4504
|
+
const o = Z.parseTrackName(r.name), a = Z.findNode(t, o.nodeName);
|
|
4510
4505
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
4511
4506
|
e.push(r);
|
|
4512
4507
|
continue;
|
|
@@ -4514,7 +4509,7 @@ Z.Utils = {
|
|
|
4514
4509
|
if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
|
|
4515
4510
|
if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
4516
4511
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
4517
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(
|
|
4512
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(ee);
|
|
4518
4513
|
}
|
|
4519
4514
|
const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
|
|
4520
4515
|
if (l === void 0)
|
|
@@ -4559,7 +4554,7 @@ async function We(d) {
|
|
|
4559
4554
|
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(d);
|
|
4560
4555
|
});
|
|
4561
4556
|
}
|
|
4562
|
-
async function
|
|
4557
|
+
async function rt(d) {
|
|
4563
4558
|
if (typeof d.arrayBuffer == "function")
|
|
4564
4559
|
return await d.arrayBuffer();
|
|
4565
4560
|
if (typeof FileReader < "u")
|
|
@@ -4572,7 +4567,7 @@ async function st(d) {
|
|
|
4572
4567
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4573
4568
|
}
|
|
4574
4569
|
}
|
|
4575
|
-
const He = new
|
|
4570
|
+
const He = new ne(), Je = new tt();
|
|
4576
4571
|
function $e(d, t, e = 0.1) {
|
|
4577
4572
|
const n = t.normal(d), s = t.direction(d).mutiplyScalar(e * 0.5), i = d.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
|
|
4578
4573
|
return {
|
|
@@ -4588,7 +4583,7 @@ function $e(d, t, e = 0.1) {
|
|
|
4588
4583
|
rectIndices: [0, 1, 3, 2, 0]
|
|
4589
4584
|
};
|
|
4590
4585
|
}
|
|
4591
|
-
class
|
|
4586
|
+
class Nt extends q {
|
|
4592
4587
|
static name = "WhiteModel";
|
|
4593
4588
|
Dxf = null;
|
|
4594
4589
|
Variable = null;
|
|
@@ -4724,7 +4719,7 @@ class Rt extends q {
|
|
|
4724
4719
|
}
|
|
4725
4720
|
}
|
|
4726
4721
|
}
|
|
4727
|
-
class
|
|
4722
|
+
class Ct extends q {
|
|
4728
4723
|
static name = "DetailsPoint";
|
|
4729
4724
|
Dxf = null;
|
|
4730
4725
|
WhiteModel = null;
|
|
@@ -4801,7 +4796,7 @@ class vt extends q {
|
|
|
4801
4796
|
}, 50);
|
|
4802
4797
|
}
|
|
4803
4798
|
}
|
|
4804
|
-
class
|
|
4799
|
+
class Bt extends q {
|
|
4805
4800
|
static name = "DxfLineModel";
|
|
4806
4801
|
dxfLineModel = new I.LineSegments();
|
|
4807
4802
|
dxfDoorsLineModel = new I.LineSegments();
|
|
@@ -4826,21 +4821,21 @@ class Nt extends q {
|
|
|
4826
4821
|
}
|
|
4827
4822
|
const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4828
4823
|
__proto__: null,
|
|
4829
|
-
DetailsPoint:
|
|
4830
|
-
DxfLineModel:
|
|
4831
|
-
WhiteModel:
|
|
4824
|
+
DetailsPoint: Ct,
|
|
4825
|
+
DxfLineModel: Bt,
|
|
4826
|
+
WhiteModel: Nt
|
|
4832
4827
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4833
|
-
function
|
|
4828
|
+
function Tt(d, t = {}) {
|
|
4834
4829
|
const {
|
|
4835
4830
|
detailsPoint: e = !0,
|
|
4836
4831
|
whiteModel: n = !0,
|
|
4837
4832
|
dxfLineModel: s = !0
|
|
4838
4833
|
} = t;
|
|
4839
|
-
s && d.addComponent(new
|
|
4834
|
+
s && d.addComponent(new Bt()), n && d.addComponent(new Nt()), e && d.addComponent(new Ct());
|
|
4840
4835
|
}
|
|
4841
|
-
const Ze = Object.assign(
|
|
4836
|
+
const Ze = Object.assign(Tt, {
|
|
4842
4837
|
create(d = {}) {
|
|
4843
|
-
return (t) =>
|
|
4838
|
+
return (t) => Tt(t, d);
|
|
4844
4839
|
}
|
|
4845
4840
|
}), Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4846
4841
|
__proto__: null,
|
|
@@ -4853,9 +4848,9 @@ function tn() {
|
|
|
4853
4848
|
function en() {
|
|
4854
4849
|
return import("./index3.js");
|
|
4855
4850
|
}
|
|
4856
|
-
let
|
|
4851
|
+
let dt = null;
|
|
4857
4852
|
async function ln(d, t, e = !1, n) {
|
|
4858
|
-
const s = await Promise.resolve().then(() => Qe), i = await tn(), r = await en(), o = new
|
|
4853
|
+
const s = await Promise.resolve().then(() => Qe), i = await tn(), r = await en(), o = new ht().usePlugin(s.ModelDataPlugin.create({
|
|
4859
4854
|
detailsPoint: !1,
|
|
4860
4855
|
whiteModel: !0
|
|
4861
4856
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4865,12 +4860,12 @@ async function ln(d, t, e = !1, n) {
|
|
|
4865
4860
|
orbitControls: e,
|
|
4866
4861
|
camera: t
|
|
4867
4862
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4868
|
-
return a && d.appendChild(a.domElement),
|
|
4863
|
+
return a && d.appendChild(a.domElement), dt = o, {
|
|
4869
4864
|
dxfSystem: o,
|
|
4870
4865
|
getFileAll: () => nn(o)
|
|
4871
4866
|
};
|
|
4872
4867
|
}
|
|
4873
|
-
async function nn(d =
|
|
4868
|
+
async function nn(d = dt) {
|
|
4874
4869
|
const t = d.findComponentByName("WhiteModel"), e = new File([await d.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([d.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([d.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await 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(d.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
4875
4870
|
return {
|
|
4876
4871
|
dxf: n,
|
|
@@ -4883,22 +4878,22 @@ async function nn(d = ht) {
|
|
|
4883
4878
|
};
|
|
4884
4879
|
}
|
|
4885
4880
|
function hn() {
|
|
4886
|
-
return
|
|
4881
|
+
return dt;
|
|
4887
4882
|
}
|
|
4888
4883
|
export {
|
|
4889
|
-
|
|
4890
|
-
|
|
4884
|
+
Pt as A,
|
|
4885
|
+
N as B,
|
|
4891
4886
|
q as C,
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4887
|
+
ht as D,
|
|
4888
|
+
It as E,
|
|
4889
|
+
A as L,
|
|
4895
4890
|
Ze as M,
|
|
4896
4891
|
M as P,
|
|
4897
4892
|
F as Q,
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4893
|
+
Le as T,
|
|
4894
|
+
Rt as V,
|
|
4895
|
+
Nt as W,
|
|
4896
|
+
Ct as a,
|
|
4902
4897
|
X as b,
|
|
4903
4898
|
ln as c,
|
|
4904
4899
|
hn as d,
|
|
@@ -4906,6 +4901,6 @@ export {
|
|
|
4906
4901
|
cn as f,
|
|
4907
4902
|
nn as g,
|
|
4908
4903
|
Ke as i,
|
|
4909
|
-
|
|
4910
|
-
|
|
4904
|
+
Q as r,
|
|
4905
|
+
at as u
|
|
4911
4906
|
};
|