build-dxf 0.0.40 → 0.0.42
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 +678 -589
- package/src/index.js +1 -1
- package/src/index3.js +503 -499
- package/src/utils/CommandManager/CommandManager.d.ts +1 -0
- package/src/utils/DxfSystem/components/Dxf.d.ts +11 -2
- package/src/utils/DxfSystem/components/LineAnalysis.d.ts +14 -1
- package/src/utils/DxfSystem/utils/originalDataToLineData.d.ts +7 -0
- package/src/utils/Quadtree/Point.d.ts +5 -0
package/src/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as I from "three";
|
|
2
|
-
import { EventDispatcher as Ot, Color as Ft, Matrix4 as bt, Vector3 as
|
|
2
|
+
import { EventDispatcher as Ot, Color as Ft, Matrix4 as bt, Vector3 as Z, Quaternion as Ut, BufferAttribute as q, REVISION as Gt, CompressedTexture as st, Source as jt, NoColorSpace as zt, MathUtils as at, RGBAFormat as qt, ImageUtils as _t, DoubleSide as Yt, PropertyBinding as Q, InterpolateDiscrete as kt, Scene as ft, SRGBColorSpace as Xt, NearestFilter as Vt, 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
3
|
import pt from "clipper-lib";
|
|
4
|
-
import
|
|
4
|
+
import $ from "dxf-writer";
|
|
5
5
|
import { OBJExporter as ne } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
-
function
|
|
7
|
-
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(
|
|
8
|
-
var t = Math.random() * 16 | 0, e =
|
|
6
|
+
function K() {
|
|
7
|
+
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(u) {
|
|
8
|
+
var t = Math.random() * 16 | 0, e = u == "x" ? t : t & 3 | 8;
|
|
9
9
|
return e.toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
class It extends Ot {
|
|
13
|
-
uuid =
|
|
13
|
+
uuid = K();
|
|
14
14
|
addEventListener(t, e, n) {
|
|
15
15
|
const { once: s = !1 } = n ?? {}, i = (o) => {
|
|
16
16
|
e(o), s && r();
|
|
@@ -30,7 +30,7 @@ class It extends Ot {
|
|
|
30
30
|
e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class _ extends It {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...t) {
|
|
@@ -71,7 +71,7 @@ class se extends It {
|
|
|
71
71
|
* @param component
|
|
72
72
|
*/
|
|
73
73
|
removeComponent(t) {
|
|
74
|
-
if (t instanceof
|
|
74
|
+
if (t instanceof _) {
|
|
75
75
|
const e = this.components.indexOf(t);
|
|
76
76
|
e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
|
|
77
77
|
type: "removeComponent",
|
|
@@ -202,9 +202,9 @@ class N {
|
|
|
202
202
|
const o = this.points;
|
|
203
203
|
for (let c = 0; c < 4; c++) {
|
|
204
204
|
const l = o[c], h = o[(c + 1) % 4];
|
|
205
|
-
for (let
|
|
206
|
-
const f = e[
|
|
207
|
-
if (y * x < 0 && m *
|
|
205
|
+
for (let d = 0; d < 4; d++) {
|
|
206
|
+
const f = e[d], p = e[(d + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), m = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), D = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
|
|
207
|
+
if (y * x < 0 && m * D < 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) || D === 0 && Math.min(f.x, p.x) <= h.x && h.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= h.y && h.y <= Math.max(f.y, p.y))
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -216,9 +216,9 @@ class N {
|
|
|
216
216
|
const a = (c) => {
|
|
217
217
|
let l = 0;
|
|
218
218
|
for (let h = 0; h < 4; h++) {
|
|
219
|
-
const
|
|
219
|
+
const d = e[h], f = e[(h + 1) % 4], p = (f.x - d.x) * (c.y - d.y) - (f.y - d.y) * (c.x - d.x);
|
|
220
220
|
if (p === 0) {
|
|
221
|
-
const y = Math.abs(f.x -
|
|
221
|
+
const y = Math.abs(f.x - d.x) > 1e-10 ? f.x - d.x : f.y - d.y, x = y ? (c.x - d.x) / y : 0;
|
|
222
222
|
if (x >= 0 && x <= 1) return !0;
|
|
223
223
|
} else {
|
|
224
224
|
const y = p > 0 ? 1 : -1;
|
|
@@ -465,7 +465,7 @@ class X {
|
|
|
465
465
|
return null;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
class
|
|
468
|
+
class nt {
|
|
469
469
|
points;
|
|
470
470
|
get p0() {
|
|
471
471
|
return this.points[0];
|
|
@@ -523,8 +523,8 @@ class et {
|
|
|
523
523
|
if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
|
|
524
524
|
return !0;
|
|
525
525
|
} else {
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
526
|
+
const d = ((o.x - e.x) * l - (o.y - e.y) * c) / h, f = ((o.x - e.x) * i - (o.y - e.y) * s) / h;
|
|
527
|
+
if (d >= 0 && d <= 1 && f >= 0 && f <= 1)
|
|
528
528
|
return !0;
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -616,7 +616,7 @@ class et {
|
|
|
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 nt([
|
|
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),
|
|
@@ -737,7 +737,7 @@ class A {
|
|
|
737
737
|
new M(n.x - a, n.y - c).add(o),
|
|
738
738
|
new M(s.x - a, s.y - c).add(r)
|
|
739
739
|
];
|
|
740
|
-
return new
|
|
740
|
+
return new nt([0, 1, 3, 2].map((h) => l[h]));
|
|
741
741
|
}
|
|
742
742
|
/**
|
|
743
743
|
* 计算线段的长度
|
|
@@ -778,7 +778,7 @@ class A {
|
|
|
778
778
|
if (r.x === 0 && r.y === 0)
|
|
779
779
|
throw new Error("投影目标线段的两个点不能重合");
|
|
780
780
|
const o = (p) => {
|
|
781
|
-
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y,
|
|
781
|
+
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, D = (y.x * r.x + y.y * r.y) / x, w = s.x + D * r.x, g = s.y + D * r.y;
|
|
782
782
|
return new M(w, g);
|
|
783
783
|
};
|
|
784
784
|
let a = o(e), c = o(n);
|
|
@@ -786,12 +786,12 @@ class A {
|
|
|
786
786
|
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
|
|
787
787
|
return (y.x * r.x + y.y * r.y) / x;
|
|
788
788
|
};
|
|
789
|
-
let h = l(a),
|
|
789
|
+
let h = l(a), d = l(c);
|
|
790
790
|
const f = (p) => {
|
|
791
791
|
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, m = s.y + y * r.y;
|
|
792
792
|
return new M(x, m);
|
|
793
793
|
};
|
|
794
|
-
return (h < 0 || h > 1) && (a = f(h)), (
|
|
794
|
+
return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new A(a, a) : new A(a, c);
|
|
795
795
|
}
|
|
796
796
|
/**
|
|
797
797
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -804,13 +804,13 @@ class A {
|
|
|
804
804
|
if (i.x === 0 && i.y === 0)
|
|
805
805
|
throw new Error("投影目标线段的两个点不能重合");
|
|
806
806
|
let o = ((l) => {
|
|
807
|
-
const h = new M(l.x - n.x, l.y - n.y),
|
|
807
|
+
const h = new M(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, y = n.x + p * i.x, x = n.y + p * i.y;
|
|
808
808
|
return new M(y, x);
|
|
809
809
|
})(t);
|
|
810
810
|
if (!e) return o;
|
|
811
811
|
let c = ((l) => {
|
|
812
|
-
const h = new M(l.x - n.x, l.y - n.y),
|
|
813
|
-
return (h.x * i.x + h.y * i.y) /
|
|
812
|
+
const h = new M(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y;
|
|
813
|
+
return (h.x * i.x + h.y * i.y) / d;
|
|
814
814
|
})(o);
|
|
815
815
|
return c < 0 || c > 1 ? null : o;
|
|
816
816
|
}
|
|
@@ -828,8 +828,8 @@ class A {
|
|
|
828
828
|
function a(f, p, y) {
|
|
829
829
|
return Math.min(p.x, y.x) - 1e-10 <= f.x && f.x <= Math.max(p.x, y.x) + 1e-10 && Math.min(p.y, y.y) - 1e-10 <= f.y && f.y <= Math.max(p.y, y.y) + 1e-10;
|
|
830
830
|
}
|
|
831
|
-
const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n),
|
|
832
|
-
return !!(c * l < 0 && h *
|
|
831
|
+
const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
|
|
832
|
+
return !!(c * l < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
|
|
833
833
|
}
|
|
834
834
|
/**
|
|
835
835
|
* 判断一个点是否在线段上(含端点)
|
|
@@ -931,8 +931,8 @@ class A {
|
|
|
931
931
|
if (l > 1)
|
|
932
932
|
return n.distance(r);
|
|
933
933
|
{
|
|
934
|
-
const h = i.x + l * o,
|
|
935
|
-
return n.distance(new M(h,
|
|
934
|
+
const h = i.x + l * o, d = i.y + l * a;
|
|
935
|
+
return n.distance(new M(h, d));
|
|
936
936
|
}
|
|
937
937
|
};
|
|
938
938
|
return Math.min(
|
|
@@ -983,8 +983,8 @@ class A {
|
|
|
983
983
|
const n = /* @__PURE__ */ new Set();
|
|
984
984
|
function s(r, o, a) {
|
|
985
985
|
if (o.has(r)) return;
|
|
986
|
-
const c = e.queryPoint(r.start).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), l = e.queryPoint(r.end).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), h = c[0]?.userData,
|
|
987
|
-
return h && !a.has(h) && (a.add(h), s(h, o, a)),
|
|
986
|
+
const c = e.queryPoint(r.start).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), l = e.queryPoint(r.end).filter((f) => f.userData !== r && r.parallel(f.userData, 0.1)), h = c[0]?.userData, d = l[0]?.userData;
|
|
987
|
+
return h && !a.has(h) && (a.add(h), s(h, o, a)), d && !a.has(d) && (a.add(d), s(d, o, a)), o.add(r), a;
|
|
988
988
|
}
|
|
989
989
|
const i = [];
|
|
990
990
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -1001,14 +1001,14 @@ class A {
|
|
|
1001
1001
|
*/
|
|
1002
1002
|
static mergeLinesByMaxlength(...t) {
|
|
1003
1003
|
if (t.length === 1) return t[0];
|
|
1004
|
-
const n = t.slice(0).sort((h,
|
|
1004
|
+
const n = t.slice(0).sort((h, d) => d.length() - h.length())[0], s = n.direction().normalize();
|
|
1005
1005
|
let i = n.start.clone(), r = n.end.clone();
|
|
1006
1006
|
const o = (h) => h.x * s.x + h.y * s.y;
|
|
1007
1007
|
let a = o(i), c = o(r);
|
|
1008
1008
|
for (const h of t)
|
|
1009
|
-
for (const
|
|
1010
|
-
const f = o(
|
|
1011
|
-
f < a && (a = f, i = n.projectPoint(
|
|
1009
|
+
for (const d of h.points) {
|
|
1010
|
+
const f = o(d);
|
|
1011
|
+
f < a && (a = f, i = n.projectPoint(d, !1)), f > c && (c = f, r = n.projectPoint(d, !1));
|
|
1012
1012
|
}
|
|
1013
1013
|
const l = new A(i, r);
|
|
1014
1014
|
return t.forEach((h) => h.userData.fittedLine = l), l;
|
|
@@ -1029,7 +1029,7 @@ class A {
|
|
|
1029
1029
|
const y = p.x * s.x + p.y * s.y;
|
|
1030
1030
|
i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
|
|
1031
1031
|
});
|
|
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),
|
|
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), d = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new A(h, d);
|
|
1033
1033
|
return t.forEach((p) => p.userData.fittedLine = f), f;
|
|
1034
1034
|
}
|
|
1035
1035
|
/** 合并满足平行的线段
|
|
@@ -1236,6 +1236,16 @@ class M {
|
|
|
1236
1236
|
const o = s / (i * r), a = Math.max(-1, Math.min(1, o));
|
|
1237
1237
|
return e === "radian" ? Math.acos(a) : e === "cos" ? a : n === "180" || this.cross(t) < 0 ? Math.acos(a) / (Math.PI / 180) : 360 - Math.acos(a) / (Math.PI / 180);
|
|
1238
1238
|
}
|
|
1239
|
+
/**
|
|
1240
|
+
* @param point
|
|
1241
|
+
* @returns
|
|
1242
|
+
*/
|
|
1243
|
+
angleBetween2(t) {
|
|
1244
|
+
const e = Math.hypot(this.x, this.y), n = Math.hypot(t.x, t.y);
|
|
1245
|
+
if (e === 0 || n === 0) return 0;
|
|
1246
|
+
const s = this.x * t.x + this.y * t.y, i = this.x * t.y - this.y * t.x;
|
|
1247
|
+
return Math.atan2(i, s);
|
|
1248
|
+
}
|
|
1239
1249
|
/** 获取向量长度
|
|
1240
1250
|
*/
|
|
1241
1251
|
length() {
|
|
@@ -1279,13 +1289,13 @@ class M {
|
|
|
1279
1289
|
return new M(0, 0);
|
|
1280
1290
|
}
|
|
1281
1291
|
}
|
|
1282
|
-
async function Y(
|
|
1292
|
+
async function Y(u, t = !0) {
|
|
1283
1293
|
if (typeof global < "u" && typeof require < "u")
|
|
1284
|
-
return require(
|
|
1294
|
+
return require(u);
|
|
1285
1295
|
{
|
|
1286
1296
|
let e = await import(
|
|
1287
1297
|
/* @vite-ignore */
|
|
1288
|
-
|
|
1298
|
+
u
|
|
1289
1299
|
);
|
|
1290
1300
|
return t && (e = e.default), e;
|
|
1291
1301
|
}
|
|
@@ -1432,8 +1442,8 @@ class F {
|
|
|
1432
1442
|
const [r, o] = i.line.points, a = o.x - r.x, c = o.y - r.y, l = a * a + c * c;
|
|
1433
1443
|
let h = ((t.x - r.x) * a + (t.y - r.y) * c) / l;
|
|
1434
1444
|
h = Math.max(0, Math.min(1, h));
|
|
1435
|
-
const
|
|
1436
|
-
t.distance(new M(
|
|
1445
|
+
const d = r.x + h * a, f = r.y + h * c;
|
|
1446
|
+
t.distance(new M(d, f)) <= e && n.push(i);
|
|
1437
1447
|
}
|
|
1438
1448
|
if (!this.isLeaf)
|
|
1439
1449
|
for (const i of this.children)
|
|
@@ -1501,9 +1511,9 @@ class F {
|
|
|
1501
1511
|
})), t;
|
|
1502
1512
|
}
|
|
1503
1513
|
}
|
|
1504
|
-
function
|
|
1505
|
-
return e || (e = new F(N.fromByLineSegment(...
|
|
1506
|
-
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index:
|
|
1514
|
+
function J(u, t = 0, e) {
|
|
1515
|
+
return e || (e = new F(N.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 }))), u.map((n) => {
|
|
1516
|
+
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: u.indexOf(o.line) }));
|
|
1507
1517
|
return {
|
|
1508
1518
|
start: n.start.toJson(t),
|
|
1509
1519
|
end: n.end.toJson(t),
|
|
@@ -1523,9 +1533,9 @@ function Z(d, t = 0, e) {
|
|
|
1523
1533
|
};
|
|
1524
1534
|
});
|
|
1525
1535
|
}
|
|
1526
|
-
function lt(
|
|
1527
|
-
const e = new F(N.fromByLineSegment(...
|
|
1528
|
-
return
|
|
1536
|
+
function lt(u, t = 0.03) {
|
|
1537
|
+
const e = new F(N.fromByLineSegment(...u));
|
|
1538
|
+
return u.forEach((n) => e.insert({ line: n, userData: void 0 })), u.flatMap((n) => {
|
|
1529
1539
|
const s = e.queryLineSegment(n, !0).map((i) => {
|
|
1530
1540
|
if (i.line === n) return;
|
|
1531
1541
|
const r = i.line.getIntersection(n);
|
|
@@ -1544,8 +1554,8 @@ function lt(d, t = 0.03) {
|
|
|
1544
1554
|
return n;
|
|
1545
1555
|
}).filter((n) => n.length() >= t);
|
|
1546
1556
|
}
|
|
1547
|
-
function
|
|
1548
|
-
|
|
1557
|
+
function tt(...u) {
|
|
1558
|
+
u.forEach((t) => {
|
|
1549
1559
|
const e = t.direction();
|
|
1550
1560
|
t.userData.drawWindow?.forEach((n) => {
|
|
1551
1561
|
try {
|
|
@@ -1562,23 +1572,54 @@ function Q(...d) {
|
|
|
1562
1572
|
});
|
|
1563
1573
|
});
|
|
1564
1574
|
}
|
|
1565
|
-
function ie(
|
|
1566
|
-
|
|
1567
|
-
|
|
1575
|
+
function ie(u, t = 0.1, e) {
|
|
1576
|
+
e || (e = new X(), u.forEach((i) => {
|
|
1577
|
+
i.userData.isDoor || i.points.forEach((r) => e?.insert(r, i));
|
|
1578
|
+
}));
|
|
1579
|
+
const n = [], s = /* @__PURE__ */ new Set();
|
|
1580
|
+
for (let i = 0; i < u.length; i++) {
|
|
1581
|
+
const r = u[i], o = /* @__PURE__ */ new Map();
|
|
1582
|
+
r.userData.isDoor || r.points.forEach((a) => {
|
|
1583
|
+
if (s.has(a)) return !1;
|
|
1584
|
+
if (e.queryPoint(a).length > 1) return;
|
|
1585
|
+
const c = e.queryCircle(a, t).filter((y) => {
|
|
1586
|
+
if (s.has(y.point)) return !1;
|
|
1587
|
+
const x = y.userData;
|
|
1588
|
+
if (x === r || !r.parallel(x, 25) || e.queryPoint(y.point).length > 1) return !1;
|
|
1589
|
+
const m = a.distance(y.point);
|
|
1590
|
+
if (m < 1e-3) return !1;
|
|
1591
|
+
const D = a.direction(r.getAnotherPoint(a)), w = y.point.direction(x.getAnotherPoint(y.point));
|
|
1592
|
+
if (180 - D.angleBetween(w, "angle") < 25)
|
|
1593
|
+
return o.set(y.point, m), !0;
|
|
1594
|
+
}).sort((y, x) => {
|
|
1595
|
+
const m = o.get(y.point), D = o.get(x.point);
|
|
1596
|
+
return m - D;
|
|
1597
|
+
});
|
|
1598
|
+
if (c.length === 0) return;
|
|
1599
|
+
s.add(a), s.add(c[0].point);
|
|
1600
|
+
const l = c[0].userData, h = r.projectLineSegment(l), d = l.projectLineSegment(r), f = h.length(), p = d.length();
|
|
1601
|
+
f === 0 && p === 0 ? n.push(new A(a.clone(), c[0].point.clone())) : n.push(new A(h.center, d.center));
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
return [...u, ...n];
|
|
1605
|
+
}
|
|
1606
|
+
function re(u) {
|
|
1607
|
+
const t = new X(), e = new F(N.fromByLineSegment(...u)), n = [];
|
|
1608
|
+
return u.forEach((s) => {
|
|
1568
1609
|
s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert({ line: s, userData: void 0 }));
|
|
1569
1610
|
}), n.forEach((s) => {
|
|
1570
1611
|
const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
|
|
1571
1612
|
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;
|
|
1572
|
-
}),
|
|
1613
|
+
}), u = ie(u, 0.3, t), u;
|
|
1573
1614
|
}
|
|
1574
|
-
function
|
|
1575
|
-
const t = new F(N.fromByLineSegment(...
|
|
1576
|
-
|
|
1615
|
+
function oe(u) {
|
|
1616
|
+
const t = new F(N.fromByLineSegment(...u));
|
|
1617
|
+
u.forEach((n) => {
|
|
1577
1618
|
n.userData.isDoor || t.insert({ line: n, userData: void 0 });
|
|
1578
1619
|
});
|
|
1579
1620
|
const e = /* @__PURE__ */ new Map();
|
|
1580
|
-
for (let n = 0; n <
|
|
1581
|
-
const s =
|
|
1621
|
+
for (let n = 0; n < u.length; n++) {
|
|
1622
|
+
const s = u[n], i = t.queryLineSegment(s).filter((r) => r.line !== s).map((r) => {
|
|
1582
1623
|
const o = s.getSameEndpoint(r.line) ?? [];
|
|
1583
1624
|
return {
|
|
1584
1625
|
line: r.line,
|
|
@@ -1591,59 +1632,59 @@ function re(d) {
|
|
|
1591
1632
|
}
|
|
1592
1633
|
return e;
|
|
1593
1634
|
}
|
|
1594
|
-
function
|
|
1595
|
-
const s = [
|
|
1596
|
-
function a(
|
|
1597
|
-
const f = Math.atan2(
|
|
1598
|
-
let y = Math.atan2(
|
|
1635
|
+
function ae(u, t, e, n = 15) {
|
|
1636
|
+
const s = [u], i = [], r = [], o = [];
|
|
1637
|
+
function a(d) {
|
|
1638
|
+
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x);
|
|
1639
|
+
let y = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x) - f;
|
|
1599
1640
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
1600
1641
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1601
|
-
const x =
|
|
1602
|
-
return
|
|
1642
|
+
const x = d.center;
|
|
1643
|
+
return d.start.rotate(x, y), d.end.rotate(x, y), d.userData.isDoor ? r.push(d) : s.push(d), d;
|
|
1603
1644
|
}
|
|
1604
|
-
function c(
|
|
1605
|
-
const f = Math.atan2(
|
|
1645
|
+
function c(d) {
|
|
1646
|
+
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x), p = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
|
|
1606
1647
|
let y = p + Math.PI / 2 - f, x = p - Math.PI / 2 - f;
|
|
1607
1648
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
1608
1649
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1609
1650
|
for (; x > Math.PI; ) x -= 2 * Math.PI;
|
|
1610
1651
|
for (; x < -Math.PI; ) x += 2 * Math.PI;
|
|
1611
|
-
const m = Math.abs(y) < Math.abs(x) ? y : x,
|
|
1612
|
-
return
|
|
1652
|
+
const m = Math.abs(y) < Math.abs(x) ? y : x, D = d.center;
|
|
1653
|
+
return d.start.rotate(D, m), d.end.rotate(D, m), d.userData.isDoor ? r.push(d) : i.push(d), d;
|
|
1613
1654
|
}
|
|
1614
|
-
function l(
|
|
1615
|
-
if (p) return l(
|
|
1616
|
-
|
|
1655
|
+
function l(d, f, p = !1) {
|
|
1656
|
+
if (p) return l(d === "parallel" ? "vertical" : "parallel", f);
|
|
1657
|
+
d === "parallel" ? a(f) : c(f);
|
|
1617
1658
|
}
|
|
1618
1659
|
const h = [];
|
|
1619
|
-
for (let
|
|
1620
|
-
const f = t[
|
|
1621
|
-
if (
|
|
1622
|
-
if (f.userData.isWindow && o.push(f), f.parallel(
|
|
1623
|
-
else if (f.vertical(
|
|
1660
|
+
for (let d = 0; d < t.length; d++) {
|
|
1661
|
+
const f = t[d];
|
|
1662
|
+
if (u !== f)
|
|
1663
|
+
if (f.userData.isWindow && o.push(f), f.parallel(u, n)) a(f);
|
|
1664
|
+
else if (f.vertical(u, n)) c(f);
|
|
1624
1665
|
else {
|
|
1625
1666
|
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());
|
|
1626
1667
|
y && y.size > 1 ? h.push(() => {
|
|
1627
1668
|
const x = [...y.values()].map(
|
|
1628
1669
|
(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],
|
|
1630
|
-
if (m.length === 1 &&
|
|
1631
|
-
if (m[0] ===
|
|
1670
|
+
).map((w) => [...new Set(w)]), m = x[0], D = x[1];
|
|
1671
|
+
if (m.length === 1 && D.length === 1) {
|
|
1672
|
+
if (m[0] === D[0]) return l(m[0], f, !0);
|
|
1632
1673
|
if (m.length === 1) {
|
|
1633
|
-
if (
|
|
1634
|
-
if (
|
|
1635
|
-
return l(
|
|
1674
|
+
if (D.includes(m[0])) return l(m[0], f, !0);
|
|
1675
|
+
if (D.length === 1 && m.includes(D[0]))
|
|
1676
|
+
return l(D[0], f, !0);
|
|
1636
1677
|
}
|
|
1637
1678
|
}
|
|
1638
1679
|
c(f);
|
|
1639
1680
|
}) : c(f);
|
|
1640
1681
|
}
|
|
1641
1682
|
}
|
|
1642
|
-
return h.forEach((
|
|
1683
|
+
return h.forEach((d) => d()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
|
|
1643
1684
|
}
|
|
1644
|
-
function yt(
|
|
1685
|
+
function yt(u, t, e, n, s) {
|
|
1645
1686
|
const i = [], r = /* @__PURE__ */ new Map();
|
|
1646
|
-
|
|
1687
|
+
u.forEach((c) => {
|
|
1647
1688
|
const l = e.projectPoint(c.start, !1);
|
|
1648
1689
|
l && (l.userData = c, i.push(l), r.set(c, l));
|
|
1649
1690
|
}), i.sort((c, l) => l.distance(e.start) - c.distance(e.start));
|
|
@@ -1665,39 +1706,39 @@ function yt(d, t, e, n, s) {
|
|
|
1665
1706
|
});
|
|
1666
1707
|
});
|
|
1667
1708
|
l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
|
|
1668
|
-
const h = /* @__PURE__ */ new Map(),
|
|
1709
|
+
const h = /* @__PURE__ */ new Map(), d = [];
|
|
1669
1710
|
let f = [];
|
|
1670
1711
|
return l.forEach((p, y) => {
|
|
1671
|
-
h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...
|
|
1712
|
+
h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...d]), d.length = 0), h.set(p.userData, (h.get(p.userData) ?? 0) + 1);
|
|
1672
1713
|
for (const x of h.values()) if (x !== 2) return;
|
|
1673
|
-
|
|
1674
|
-
}), f.push([...
|
|
1714
|
+
d.push(...h.keys()), h.clear();
|
|
1715
|
+
}), f.push([...d]), f;
|
|
1675
1716
|
});
|
|
1676
1717
|
}
|
|
1677
|
-
function xt(
|
|
1718
|
+
function xt(u, t, e, n) {
|
|
1678
1719
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
|
|
1679
|
-
|
|
1680
|
-
const f = e.projectPoint(
|
|
1681
|
-
f && (f.userData =
|
|
1720
|
+
u.forEach((d) => {
|
|
1721
|
+
const f = e.projectPoint(d.start, !1);
|
|
1722
|
+
f && (f.userData = d, s.set(d, f), o.push(f)), d.points.forEach((p, y) => {
|
|
1682
1723
|
const x = t.projectPoint(p, !1);
|
|
1683
|
-
x && (x.userData =
|
|
1724
|
+
x && (x.userData = d, y === 0 ? i.set(d, x) : r.set(d, x));
|
|
1684
1725
|
});
|
|
1685
|
-
}), o.sort((
|
|
1686
|
-
const a = o.map((
|
|
1687
|
-
const f =
|
|
1688
|
-
for (let
|
|
1689
|
-
const w = o[
|
|
1690
|
-
if (
|
|
1691
|
-
const g = w.userData, S = i.get(g),
|
|
1692
|
-
(x.isPointOnSegment(S) || x.isPointOnSegment(
|
|
1726
|
+
}), o.sort((d, f) => f.distance(e.start) - d.distance(e.start));
|
|
1727
|
+
const a = o.map((d) => {
|
|
1728
|
+
const f = d.userData, p = i.get(f), y = r.get(f), x = new A(p, y), m = [];
|
|
1729
|
+
for (let D = 0; D < o.length; D++) {
|
|
1730
|
+
const w = o[D];
|
|
1731
|
+
if (d !== w && d.distance(w) < n) {
|
|
1732
|
+
const g = w.userData, S = i.get(g), E = r.get(g);
|
|
1733
|
+
(x.isPointOnSegment(S) || x.isPointOnSegment(E)) && m.push(D);
|
|
1693
1734
|
}
|
|
1694
1735
|
}
|
|
1695
1736
|
return m;
|
|
1696
1737
|
});
|
|
1697
|
-
function c(
|
|
1698
|
-
if (p.has(
|
|
1699
|
-
const y = f[
|
|
1700
|
-
p.add(
|
|
1738
|
+
function c(d, f, p = /* @__PURE__ */ new Set()) {
|
|
1739
|
+
if (p.has(d)) return p;
|
|
1740
|
+
const y = f[d];
|
|
1741
|
+
p.add(d);
|
|
1701
1742
|
for (let x = 0; x < y.length; x++) {
|
|
1702
1743
|
const m = y[x];
|
|
1703
1744
|
c(m, f, p);
|
|
@@ -1705,9 +1746,9 @@ function xt(d, t, e, n) {
|
|
|
1705
1746
|
return p;
|
|
1706
1747
|
}
|
|
1707
1748
|
const l = /* @__PURE__ */ new Set(), h = [];
|
|
1708
|
-
for (let
|
|
1709
|
-
if (l.has(
|
|
1710
|
-
const f = c(
|
|
1749
|
+
for (let d = 0; d < o.length; d++) {
|
|
1750
|
+
if (l.has(d)) continue;
|
|
1751
|
+
const f = c(d, a), p = [];
|
|
1711
1752
|
if (f.forEach((y) => {
|
|
1712
1753
|
l.add(y), p.push(o[y].userData);
|
|
1713
1754
|
}), p.length > 2) {
|
|
@@ -1715,16 +1756,16 @@ function xt(d, t, e, n) {
|
|
|
1715
1756
|
y.sort((w, g) => g.distance(e.start) - w.distance(e.start));
|
|
1716
1757
|
const x = y[0], m = y[y.length - 1];
|
|
1717
1758
|
if (x.distance(m) > n) {
|
|
1718
|
-
const w = [...p].sort((C,
|
|
1719
|
-
if (
|
|
1720
|
-
const C = [g],
|
|
1759
|
+
const w = [...p].sort((C, G) => G.length() - C.length()), g = w[0], S = w[1], E = s.get(g), L = s.get(S), b = g.length(), R = S.length(), P = g.projectLineSegment(S), B = P.length();
|
|
1760
|
+
if (E.distance(L) || R / b > 0.5 && B / R < 0.5) {
|
|
1761
|
+
const C = [g], G = [S];
|
|
1721
1762
|
for (let O = 0; O < y.length; O++) {
|
|
1722
1763
|
const v = y[O], V = v.userData;
|
|
1723
|
-
if (v ===
|
|
1724
|
-
const
|
|
1725
|
-
L.distance(v) <= n && W / R > 0 ?
|
|
1764
|
+
if (v === E || v === L) continue;
|
|
1765
|
+
const j = S.projectLineSegment(V), W = j.length();
|
|
1766
|
+
L.distance(v) <= n && W / R > 0 ? G.push(V) : C.push(V);
|
|
1726
1767
|
}
|
|
1727
|
-
h.push(C,
|
|
1768
|
+
h.push(C, G);
|
|
1728
1769
|
} else {
|
|
1729
1770
|
const C = Math.floor(p.length * 0.5);
|
|
1730
1771
|
h.push(p.slice(0, C), p.slice(C));
|
|
@@ -1736,7 +1777,7 @@ function xt(d, t, e, n) {
|
|
|
1736
1777
|
}
|
|
1737
1778
|
return h;
|
|
1738
1779
|
}
|
|
1739
|
-
function gt(
|
|
1780
|
+
function gt(u, t) {
|
|
1740
1781
|
function e(i, r = /* @__PURE__ */ new Set()) {
|
|
1741
1782
|
if (r.has(i)) return r;
|
|
1742
1783
|
r.add(i);
|
|
@@ -1749,49 +1790,49 @@ function gt(d, t) {
|
|
|
1749
1790
|
return r;
|
|
1750
1791
|
}
|
|
1751
1792
|
const n = /* @__PURE__ */ new Set(), s = [];
|
|
1752
|
-
for (let i = 0; i <
|
|
1753
|
-
const r =
|
|
1793
|
+
for (let i = 0; i < u.length; i++) {
|
|
1794
|
+
const r = u[i];
|
|
1754
1795
|
if (n.has(r)) continue;
|
|
1755
1796
|
const o = e(r);
|
|
1756
1797
|
s.push([...o]);
|
|
1757
1798
|
}
|
|
1758
1799
|
return s;
|
|
1759
1800
|
}
|
|
1760
|
-
function
|
|
1801
|
+
function ce(u, t, e, n, s, i) {
|
|
1761
1802
|
const {
|
|
1762
1803
|
principalAxisThreshold: r = 0.3,
|
|
1763
1804
|
crossAxistThreshold: o = 0.06,
|
|
1764
1805
|
groupMethod: a = "principalAndCross"
|
|
1765
1806
|
} = i ?? {}, c = {
|
|
1766
1807
|
cross: () => [
|
|
1767
|
-
...xt(
|
|
1808
|
+
...xt(u, n, e, o),
|
|
1768
1809
|
...xt(t, e, n, o)
|
|
1769
1810
|
],
|
|
1770
1811
|
principalAndCross: () => [
|
|
1771
|
-
...yt(
|
|
1812
|
+
...yt(u, n, e, r, o),
|
|
1772
1813
|
...yt(t, e, n, r, o)
|
|
1773
1814
|
],
|
|
1774
1815
|
originalInterPoint: () => [
|
|
1775
|
-
...gt(
|
|
1816
|
+
...gt(u, s),
|
|
1776
1817
|
...gt(t, s)
|
|
1777
1818
|
]
|
|
1778
1819
|
};
|
|
1779
1820
|
return c[a] ? c[a]() : c.originalInterPoint();
|
|
1780
1821
|
}
|
|
1781
|
-
function
|
|
1822
|
+
function le(u, t) {
|
|
1782
1823
|
const e = /* @__PURE__ */ new Set();
|
|
1783
|
-
return
|
|
1824
|
+
return u.forEach((n) => {
|
|
1784
1825
|
for (let s = 1; s < n.length; s++) {
|
|
1785
1826
|
const i = n[s], r = n[s - 1];
|
|
1786
1827
|
[...t.get(i) ?? [], ...t.get(r) ?? []].forEach((a) => {
|
|
1787
1828
|
(a.line.sameEndpointAsStart(i) && a.line.sameEndpointAsEnd(r) || a.line.sameEndpointAsStart(r) && a.line.sameEndpointAsEnd(i)) && e.add(a);
|
|
1788
1829
|
});
|
|
1789
1830
|
}
|
|
1790
|
-
}),
|
|
1831
|
+
}), u.map((n) => n.filter((s) => !e.has(s)));
|
|
1791
1832
|
}
|
|
1792
|
-
function
|
|
1833
|
+
function he(u, t = 0.1, e) {
|
|
1793
1834
|
const { fittingMethod: n = "average" } = e ?? {};
|
|
1794
|
-
return
|
|
1835
|
+
return u.map((s) => {
|
|
1795
1836
|
if (s.length === 0) return;
|
|
1796
1837
|
if (s.length === 1) return s[0];
|
|
1797
1838
|
const i = [];
|
|
@@ -1799,34 +1840,34 @@ function le(d, t = 0.1, e) {
|
|
|
1799
1840
|
const r = n === "average" ? A.mergeLines(...s) : A.mergeLinesByMaxlength(...s);
|
|
1800
1841
|
r.userData.rooftopPz = Math.min(
|
|
1801
1842
|
...s.map((h) => {
|
|
1802
|
-
const { drawDoorData:
|
|
1843
|
+
const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } = h.userData;
|
|
1803
1844
|
return Object.assign(r.userData, y), p ?? 1 / 0;
|
|
1804
1845
|
})
|
|
1805
1846
|
), r.userData.rooftopPz === 1 / 0 && (r.userData.rooftopPz = 0);
|
|
1806
1847
|
let o = 1 / 0, a = -1 / 0;
|
|
1807
1848
|
const c = s[0].normal().normalize();
|
|
1808
1849
|
o = 1 / 0, a = -1 / 0, i.forEach((h) => {
|
|
1809
|
-
const
|
|
1810
|
-
o = Math.min(o,
|
|
1850
|
+
const d = h.x * c.x + h.y * c.y;
|
|
1851
|
+
o = Math.min(o, d), a = Math.max(a, d);
|
|
1811
1852
|
});
|
|
1812
1853
|
const l = a - o;
|
|
1813
1854
|
return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
|
|
1814
1855
|
}).filter((s) => !!s);
|
|
1815
1856
|
}
|
|
1816
|
-
function mt(
|
|
1817
|
-
const e = new F(N.fromByLineSegment(...
|
|
1818
|
-
|
|
1857
|
+
function mt(u, t = 0.4) {
|
|
1858
|
+
const e = new F(N.fromByLineSegment(...u));
|
|
1859
|
+
u.forEach((s) => e.insert(s));
|
|
1819
1860
|
const n = new A();
|
|
1820
|
-
for (let s = 0; s <
|
|
1821
|
-
const i =
|
|
1861
|
+
for (let s = 0; s < u.length; s++) {
|
|
1862
|
+
const i = u[s];
|
|
1822
1863
|
if (i.userData.isAdsorbed) continue;
|
|
1823
1864
|
const r = i.direction().multiplyScalar(t), [o, a] = i.points.map((c) => {
|
|
1824
1865
|
n.set(c, c), n.start.add(r), n.end.add(r.multiplyScalar(-1));
|
|
1825
|
-
const l = /* @__PURE__ */ new Map(), h = e.queryLineSegment(n).filter((
|
|
1826
|
-
const f =
|
|
1827
|
-
return l.set(
|
|
1828
|
-
}).sort((
|
|
1829
|
-
const p = l.get(
|
|
1866
|
+
const l = /* @__PURE__ */ new Map(), h = e.queryLineSegment(n).filter((d) => d.line !== i).map((d) => {
|
|
1867
|
+
const f = d.line.getIntersection(n);
|
|
1868
|
+
return l.set(d.line, f), d.line;
|
|
1869
|
+
}).sort((d, f) => {
|
|
1870
|
+
const p = l.get(d), y = l.get(f);
|
|
1830
1871
|
return p && y ? p.distance(c) - y.distance(c) : 0;
|
|
1831
1872
|
});
|
|
1832
1873
|
return h.length ? l.get(h[0]) : void 0;
|
|
@@ -1841,22 +1882,22 @@ function mt(d, t = 0.4) {
|
|
|
1841
1882
|
} else o ? i.directionMove(o.direction(i.start), i.start.distance(o)) : a && i.directionMove(a.direction(i.end), i.end.distance(a));
|
|
1842
1883
|
e.update(i);
|
|
1843
1884
|
}
|
|
1844
|
-
return
|
|
1885
|
+
return u.filter((s) => s.length() > 1e-3);
|
|
1845
1886
|
}
|
|
1846
|
-
function
|
|
1887
|
+
function ue(u, t) {
|
|
1847
1888
|
const e = new X();
|
|
1848
|
-
|
|
1889
|
+
u.forEach((i) => i.points.forEach((r) => e.insert(r, i)));
|
|
1849
1890
|
const n = /* @__PURE__ */ new Map();
|
|
1850
1891
|
function s(i, r) {
|
|
1851
1892
|
n.has(i) || n.set(i, []), n.get(i)?.push(r);
|
|
1852
1893
|
}
|
|
1853
|
-
for (let i = 0; i <
|
|
1854
|
-
const r =
|
|
1894
|
+
for (let i = 0; i < u.length; i++) {
|
|
1895
|
+
const r = u[i];
|
|
1855
1896
|
r.points.forEach((o) => {
|
|
1856
1897
|
if (e.queryPoint(o).filter((h) => h.userData !== r).length !== 0) return;
|
|
1857
1898
|
const a = e.queryCircle(o, t).filter((h) => h.userData !== r && h.userData?.vertical(r));
|
|
1858
1899
|
if (!a.length) return;
|
|
1859
|
-
const c = a.sort((h,
|
|
1900
|
+
const c = a.sort((h, d) => h.userData.length() - d.userData.length())[0], l = c.userData?.projectPoint(o, !1);
|
|
1860
1901
|
if (l) {
|
|
1861
1902
|
const h = c.userData;
|
|
1862
1903
|
s(r, new A(o.clone(), l.clone())), s(h, new A(c.point.clone(), l.clone()));
|
|
@@ -1866,23 +1907,23 @@ function he(d, t) {
|
|
|
1866
1907
|
return n.forEach((i, r) => {
|
|
1867
1908
|
const o = A.mergeLines(r, ...i);
|
|
1868
1909
|
r.set(o.start, o.end);
|
|
1869
|
-
}),
|
|
1910
|
+
}), u;
|
|
1870
1911
|
}
|
|
1871
|
-
function
|
|
1912
|
+
function de(u, t) {
|
|
1872
1913
|
const { snapThreshold: e = 0.2 } = t ?? {};
|
|
1873
|
-
return
|
|
1914
|
+
return u = mt(u, e), u = mt(u, e), u = ue(u, e), u;
|
|
1874
1915
|
}
|
|
1875
|
-
function
|
|
1916
|
+
function fe(u) {
|
|
1876
1917
|
const t = /* @__PURE__ */ new Set();
|
|
1877
|
-
for (let e = 0; e <
|
|
1878
|
-
const n =
|
|
1879
|
-
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) :
|
|
1918
|
+
for (let e = 0; e < u.length; e++) {
|
|
1919
|
+
const n = u[e], s = n.userData.fittedLine;
|
|
1920
|
+
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : tt(n);
|
|
1880
1921
|
}
|
|
1881
|
-
t.forEach((e) =>
|
|
1922
|
+
t.forEach((e) => tt(e));
|
|
1882
1923
|
}
|
|
1883
|
-
function
|
|
1884
|
-
for (let t = 0; t <
|
|
1885
|
-
const e =
|
|
1924
|
+
function pe(u) {
|
|
1925
|
+
for (let t = 0; t < u.length; t++) {
|
|
1926
|
+
const e = u[t];
|
|
1886
1927
|
let { endIntersection: n, startIntersection: s } = e.userData;
|
|
1887
1928
|
if (!(!n || !s)) {
|
|
1888
1929
|
if (s.userData.fittedLine && (s = s.userData.fittedLine), n.userData.fittedLine && (n = n.userData.fittedLine), e.parallel(s))
|
|
@@ -1899,11 +1940,11 @@ function fe(d) {
|
|
|
1899
1940
|
}
|
|
1900
1941
|
}
|
|
1901
1942
|
}
|
|
1902
|
-
return
|
|
1943
|
+
return u;
|
|
1903
1944
|
}
|
|
1904
|
-
function
|
|
1945
|
+
function ye(u, t = 0.01) {
|
|
1905
1946
|
const e = new X();
|
|
1906
|
-
return
|
|
1947
|
+
return u.forEach((n) => n.points.forEach((s) => e.insert(s, n))), u.filter((n) => {
|
|
1907
1948
|
if (n.length() <= t) {
|
|
1908
1949
|
const s = e.queryPoint(n.start).filter((r) => r.userData !== n).length === 0, i = e.queryPoint(n.end).filter((r) => r.userData !== n).length === 0;
|
|
1909
1950
|
if (s || i) return !1;
|
|
@@ -1919,34 +1960,50 @@ class Pt {
|
|
|
1919
1960
|
* @returns
|
|
1920
1961
|
*/
|
|
1921
1962
|
static correction(t, e, n) {
|
|
1922
|
-
t =
|
|
1923
|
-
const s =
|
|
1963
|
+
t = re(t.map((x) => x.clone()));
|
|
1964
|
+
const s = oe(t), { parallelLines: i, verticalLines: r, doorLines: o, windowLines: a } = ae(e, t, s, 25), c = e.normal(), l = e.center, h = e.direction(), d = new A(
|
|
1924
1965
|
l.clone().add(c.clone().multiplyScalar(-1e3)),
|
|
1925
1966
|
l.clone().add(c.clone().multiplyScalar(1e3))
|
|
1926
1967
|
), f = new A(
|
|
1927
1968
|
l.clone().add(h.clone().multiplyScalar(-1e3)),
|
|
1928
1969
|
l.clone().add(h.clone().multiplyScalar(1e3))
|
|
1929
1970
|
);
|
|
1930
|
-
let p =
|
|
1931
|
-
p =
|
|
1932
|
-
let y =
|
|
1933
|
-
return y =
|
|
1971
|
+
let p = ce(i, r, d, f, s, n);
|
|
1972
|
+
p = le(p, s);
|
|
1973
|
+
let y = he(p, 0.1, n);
|
|
1974
|
+
return y = de(y, n), fe(a), pe(o), y = lt(y, 1e-9), y.push(...o), y = ye(y, 0.08), y = y, y;
|
|
1934
1975
|
}
|
|
1935
1976
|
}
|
|
1936
|
-
const
|
|
1977
|
+
const xe = new A(
|
|
1937
1978
|
new M(0, 0),
|
|
1938
1979
|
new M(0, 1)
|
|
1939
1980
|
);
|
|
1940
|
-
function
|
|
1941
|
-
const t = [...
|
|
1942
|
-
let r = parseInt(
|
|
1981
|
+
function ge(u) {
|
|
1982
|
+
const t = [...u].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
|
|
1983
|
+
let r = parseInt(xe.includedAngle(i) + "");
|
|
1943
1984
|
return r > 90 && (r = 180 - r), r;
|
|
1944
1985
|
}), n = /* @__PURE__ */ new Map();
|
|
1945
1986
|
return e.forEach((i, r) => {
|
|
1946
1987
|
n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
|
|
1947
1988
|
}), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
|
|
1948
1989
|
}
|
|
1949
|
-
|
|
1990
|
+
function me(u) {
|
|
1991
|
+
let t = [], e = -1;
|
|
1992
|
+
const n = [];
|
|
1993
|
+
return u.forEach(({ start: i, end: r, ...o }, a) => {
|
|
1994
|
+
n.push(i.z ?? 0, r.z ?? 0);
|
|
1995
|
+
const c = new A(
|
|
1996
|
+
M.from(i),
|
|
1997
|
+
M.from(r)
|
|
1998
|
+
);
|
|
1999
|
+
c.userData = o, t.push(c), o.isVerticalReferenceLine && (e = a);
|
|
2000
|
+
}), {
|
|
2001
|
+
originalZAverage: n.reduce((i, r) => i + r, 0) / n.length,
|
|
2002
|
+
lineSegments: t,
|
|
2003
|
+
verticalReferenceIndex: e
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
const we = {
|
|
1950
2007
|
Unitless: 1,
|
|
1951
2008
|
// 无单位,1米 = 1(无单位)
|
|
1952
2009
|
Inches: 39.37007874015748,
|
|
@@ -1990,19 +2047,19 @@ const ge = {
|
|
|
1990
2047
|
Parsecs: 3240779289666404e-32
|
|
1991
2048
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
1992
2049
|
};
|
|
1993
|
-
function wt(
|
|
2050
|
+
function wt(u) {
|
|
1994
2051
|
const t = [];
|
|
1995
|
-
for (let e = 0; e <
|
|
2052
|
+
for (let e = 0; e < u.length; e++)
|
|
1996
2053
|
t.push(new A(
|
|
1997
|
-
|
|
1998
|
-
|
|
2054
|
+
u[e].clone(),
|
|
2055
|
+
u[(e + 1) % u.length].clone()
|
|
1999
2056
|
));
|
|
2000
2057
|
return t;
|
|
2001
2058
|
}
|
|
2002
|
-
function Mt(
|
|
2003
|
-
return
|
|
2059
|
+
function Mt(u) {
|
|
2060
|
+
return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
|
|
2004
2061
|
}
|
|
2005
|
-
class k extends
|
|
2062
|
+
class k extends _ {
|
|
2006
2063
|
static name = "Dxf";
|
|
2007
2064
|
shortLine = 0.04;
|
|
2008
2065
|
width = 0.04;
|
|
@@ -2015,6 +2072,7 @@ class k extends q {
|
|
|
2015
2072
|
wallsGroup = [];
|
|
2016
2073
|
doors = [];
|
|
2017
2074
|
doorLineSegment = [];
|
|
2075
|
+
verticalReferenceLine;
|
|
2018
2076
|
lineSegments = [];
|
|
2019
2077
|
originalZAverage = 0;
|
|
2020
2078
|
static EndType = {
|
|
@@ -2045,31 +2103,23 @@ class k extends q {
|
|
|
2045
2103
|
* 预处理数据
|
|
2046
2104
|
* @param data
|
|
2047
2105
|
*/
|
|
2048
|
-
preprocessing(t
|
|
2049
|
-
let
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
const u = new A(
|
|
2054
|
-
M.from(a),
|
|
2055
|
-
M.from(c)
|
|
2056
|
-
);
|
|
2057
|
-
u.userData = l, s.push(u), l.isVerticalReferenceLine && (i = h);
|
|
2058
|
-
}), this.originalZAverage = r.reduce((a, c) => a + c, 0) / r.length, i === -1) {
|
|
2059
|
-
const a = xe(s);
|
|
2060
|
-
i = s.indexOf(a);
|
|
2106
|
+
preprocessing(t) {
|
|
2107
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = me(t);
|
|
2108
|
+
if (this.originalZAverage = s, n === -1) {
|
|
2109
|
+
const r = ge(e);
|
|
2110
|
+
n = e.indexOf(r);
|
|
2061
2111
|
}
|
|
2062
|
-
const
|
|
2063
|
-
return
|
|
2112
|
+
const i = e[n];
|
|
2113
|
+
return i.userData.isVerticalReferenceLine = !0, t[n].isVerticalReferenceLine = !0, this.verticalReferenceLine = i, this.dispatchEvent({
|
|
2064
2114
|
type: "preprocessing",
|
|
2065
2115
|
data: t,
|
|
2066
|
-
setData(
|
|
2067
|
-
|
|
2068
|
-
const
|
|
2069
|
-
return
|
|
2070
|
-
}), t =
|
|
2116
|
+
setData(r) {
|
|
2117
|
+
e = r.map(({ start: o, end: a, ...c }) => {
|
|
2118
|
+
const l = new A(M.from(o), M.from(a));
|
|
2119
|
+
return l.userData = c, l;
|
|
2120
|
+
}), t = r;
|
|
2071
2121
|
}
|
|
2072
|
-
}), { lineSegments:
|
|
2122
|
+
}), { lineSegments: e, data: t };
|
|
2073
2123
|
}
|
|
2074
2124
|
/** 设置
|
|
2075
2125
|
* @param data 房屋结构数据,node环境可以为路径
|
|
@@ -2079,34 +2129,34 @@ class k extends q {
|
|
|
2079
2129
|
* @param option
|
|
2080
2130
|
* @returns
|
|
2081
2131
|
*/
|
|
2082
|
-
async set(t, e = this.width, n = this.scale
|
|
2132
|
+
async set(t, e = this.width, n = this.scale) {
|
|
2083
2133
|
if (typeof t == "string")
|
|
2084
2134
|
if (typeof global < "u") {
|
|
2085
|
-
const { default:
|
|
2135
|
+
const { default: r } = await import(
|
|
2086
2136
|
/* @vite-ignore */
|
|
2087
2137
|
"fs"
|
|
2088
|
-
),
|
|
2089
|
-
return this.set(
|
|
2138
|
+
), o = r.readFileSync(t), a = JSON.parse(o.toString("utf-8"));
|
|
2139
|
+
return this.set(a, e, n);
|
|
2090
2140
|
} else
|
|
2091
2141
|
throw new Error("非node环境不允许使用路径");
|
|
2092
|
-
if (this.scale = n, this.width = e, t.length === 0)
|
|
2142
|
+
if (this.scale = n, this.width = e, this.doorLineSegment.length = 0, t.length === 0)
|
|
2093
2143
|
this.lineSegments = [], this.originalData = t;
|
|
2094
2144
|
else {
|
|
2095
|
-
const
|
|
2096
|
-
t =
|
|
2145
|
+
const i = this.preprocessing(t);
|
|
2146
|
+
t = i.data, this.lineSegments = i.lineSegments, this.originalData = t;
|
|
2097
2147
|
}
|
|
2098
|
-
const
|
|
2099
|
-
this.data = t.map(({ start:
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2148
|
+
const s = [];
|
|
2149
|
+
this.data = t.map(({ start: i, end: r, insetionArr: o, isDoor: a = !1 }, c) => {
|
|
2150
|
+
s.push(i.z ?? 0, r.z ?? 0);
|
|
2151
|
+
const l = this.lineSegments[c];
|
|
2102
2152
|
return [
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
(
|
|
2106
|
-
|
|
2107
|
-
|
|
2153
|
+
l.points[0],
|
|
2154
|
+
l.points[1],
|
|
2155
|
+
(o ?? []).map((h) => h.index),
|
|
2156
|
+
a,
|
|
2157
|
+
c
|
|
2108
2158
|
];
|
|
2109
|
-
}), this.originalZAverage =
|
|
2159
|
+
}), this.originalZAverage = s.reduce((i, r) => i + r, 0) / s.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
|
|
2110
2160
|
type: "setDta",
|
|
2111
2161
|
originalData: this.originalData,
|
|
2112
2162
|
data: this.data
|
|
@@ -2122,8 +2172,8 @@ class k extends q {
|
|
|
2122
2172
|
createGroups() {
|
|
2123
2173
|
const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
|
|
2124
2174
|
if (!this.data[r]) return;
|
|
2125
|
-
const [c, l, h,
|
|
2126
|
-
if (e.add(r),
|
|
2175
|
+
const [c, l, h, d] = this.data[r];
|
|
2176
|
+
if (e.add(r), d)
|
|
2127
2177
|
return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
|
|
2128
2178
|
o.push([c, l]), h.forEach((f) => {
|
|
2129
2179
|
e.has(f) || i(f, o, r);
|
|
@@ -2249,9 +2299,9 @@ class k extends q {
|
|
|
2249
2299
|
continue;
|
|
2250
2300
|
}
|
|
2251
2301
|
let l = n[++r];
|
|
2252
|
-
const h = s[s.length - 1],
|
|
2302
|
+
const h = s[s.length - 1], d = h.direction();
|
|
2253
2303
|
for (; r < n.length; ) {
|
|
2254
|
-
const p =
|
|
2304
|
+
const p = d.angleBetween(l.direction()) / i;
|
|
2255
2305
|
if (l.length() <= e || p < 4 || p > 176)
|
|
2256
2306
|
l = n[++r];
|
|
2257
2307
|
else break;
|
|
@@ -2288,6 +2338,27 @@ class k extends q {
|
|
|
2288
2338
|
wallsGroup: this.wallsGroup
|
|
2289
2339
|
}), this.wallsGroup;
|
|
2290
2340
|
}
|
|
2341
|
+
/** 垂直纠正
|
|
2342
|
+
* @param option
|
|
2343
|
+
*/
|
|
2344
|
+
axisAlignCorr(t) {
|
|
2345
|
+
if (this.verticalReferenceLine) {
|
|
2346
|
+
this.doorLineSegment;
|
|
2347
|
+
const e = Pt.correction(this.getLineSegments(), this.verticalReferenceLine, t), n = J(e);
|
|
2348
|
+
this.set(n);
|
|
2349
|
+
} else
|
|
2350
|
+
throw new Error("未找到一条垂直纠正基准轴线");
|
|
2351
|
+
}
|
|
2352
|
+
/** 完整线段数据
|
|
2353
|
+
* @returns
|
|
2354
|
+
*/
|
|
2355
|
+
getLineSegments(t = !1) {
|
|
2356
|
+
let e = this.lineSegments.filter((s) => !s.userData.isDoor), n = [...this.doorLineSegment];
|
|
2357
|
+
return t && (e = e.map((s) => s.clone()), n = n.map((s) => s.clone())), n.forEach((s) => Object.assign(s.userData, {
|
|
2358
|
+
isDoor: !0,
|
|
2359
|
+
doorDirectConnection: !0
|
|
2360
|
+
})), e.push(...n), e;
|
|
2361
|
+
}
|
|
2291
2362
|
/**
|
|
2292
2363
|
* 将点云结构转换为Float32Array
|
|
2293
2364
|
*/
|
|
@@ -2317,13 +2388,13 @@ class k extends q {
|
|
|
2317
2388
|
* 线段数据转为原始json数据
|
|
2318
2389
|
*/
|
|
2319
2390
|
lineDataToOriginalData(t, e) {
|
|
2320
|
-
return
|
|
2391
|
+
return J(t, this.originalZAverage, e);
|
|
2321
2392
|
}
|
|
2322
2393
|
/**
|
|
2323
2394
|
* 转为绘制数据
|
|
2324
2395
|
*/
|
|
2325
2396
|
toDrawDataJson(t = "Millimeters") {
|
|
2326
|
-
const e =
|
|
2397
|
+
const e = we[t], n = {
|
|
2327
2398
|
unit: t,
|
|
2328
2399
|
line: [],
|
|
2329
2400
|
arc: [],
|
|
@@ -2337,13 +2408,13 @@ class k extends q {
|
|
|
2337
2408
|
function i(c, l) {
|
|
2338
2409
|
n.line.push([c.x * e, c.y * e, l.x * e, l.y * e, s]);
|
|
2339
2410
|
}
|
|
2340
|
-
function r(c, l, h,
|
|
2411
|
+
function r(c, l, h, d) {
|
|
2341
2412
|
n.arc.push([
|
|
2342
2413
|
c.x * e,
|
|
2343
2414
|
c.y * e,
|
|
2344
2415
|
l * e,
|
|
2345
2416
|
h,
|
|
2346
|
-
|
|
2417
|
+
d,
|
|
2347
2418
|
s
|
|
2348
2419
|
]);
|
|
2349
2420
|
}
|
|
@@ -2356,7 +2427,7 @@ class k extends q {
|
|
|
2356
2427
|
}
|
|
2357
2428
|
this.wallsGroup.forEach((c) => {
|
|
2358
2429
|
for (let l = 0; l < c.length; l++) {
|
|
2359
|
-
const h = c[l],
|
|
2430
|
+
const h = c[l], d = l === c.length - 1 ? 0 : l + 1, f = c[d];
|
|
2360
2431
|
i(h, f);
|
|
2361
2432
|
}
|
|
2362
2433
|
});
|
|
@@ -2367,29 +2438,29 @@ class k extends q {
|
|
|
2367
2438
|
if (s = "cyan", l.length() < 1.2) {
|
|
2368
2439
|
l.expansion(-o * 0.5);
|
|
2369
2440
|
const h = c.normal();
|
|
2370
|
-
let
|
|
2441
|
+
let d = new A(
|
|
2371
2442
|
l.start.clone(),
|
|
2372
2443
|
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2373
2444
|
);
|
|
2374
|
-
const f =
|
|
2445
|
+
const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
2375
2446
|
for (let g = 0; g < a.length; g++)
|
|
2376
2447
|
if (a[g].intersectRectangle(f)) {
|
|
2377
|
-
|
|
2448
|
+
d = new A(
|
|
2378
2449
|
l.start.clone(),
|
|
2379
2450
|
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2380
2451
|
);
|
|
2381
2452
|
break;
|
|
2382
2453
|
}
|
|
2383
|
-
|
|
2384
|
-
const p = l.length(), y =
|
|
2385
|
-
r(m, x, Math.min(
|
|
2454
|
+
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((g, S) => i(g, S));
|
|
2455
|
+
const p = l.length(), y = d.length(), x = (p ** 2 + y ** 2) / (2 * y), m = d.end.clone().add(d.direction().multiplyScalar(-x)), [D, w] = this.getArcAngleRange(m, l.end, d.end);
|
|
2456
|
+
r(m, x, Math.min(D, w), Math.max(D, w)), a.push(f);
|
|
2386
2457
|
} else
|
|
2387
|
-
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h,
|
|
2458
|
+
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
|
|
2388
2459
|
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
2389
2460
|
if (!c.userData.isWindow) return !1;
|
|
2390
2461
|
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
2391
|
-
const { p: h, width:
|
|
2392
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((m,
|
|
2462
|
+
const { p: h, width: d } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), x = new A(p, y);
|
|
2463
|
+
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((m, D) => i(m, D));
|
|
2393
2464
|
});
|
|
2394
2465
|
}), n;
|
|
2395
2466
|
}
|
|
@@ -2414,12 +2485,12 @@ class k extends q {
|
|
|
2414
2485
|
};
|
|
2415
2486
|
i.width = s.width + r * 2, i.height = s.height + r * 2;
|
|
2416
2487
|
const a = i.getContext("2d");
|
|
2417
|
-
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h,
|
|
2418
|
-
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h,
|
|
2419
|
-
}), s.arc.forEach(([c, l, h,
|
|
2420
|
-
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h,
|
|
2488
|
+
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, d, f]) => {
|
|
2489
|
+
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h, d), a.closePath(), a.stroke();
|
|
2490
|
+
}), s.arc.forEach(([c, l, h, d, f, p]) => {
|
|
2491
|
+
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
|
|
2421
2492
|
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
2422
|
-
let [l, h,
|
|
2493
|
+
let [l, h, d, f] = c;
|
|
2423
2494
|
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;
|
|
2424
2495
|
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);
|
|
2425
2496
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
@@ -2432,8 +2503,8 @@ class k extends q {
|
|
|
2432
2503
|
* 将点json结构转换为Dxf string
|
|
2433
2504
|
*/
|
|
2434
2505
|
toDxfString(t = "Millimeters") {
|
|
2435
|
-
const e = new
|
|
2436
|
-
e.setUnits(t), e.addLayer("cyan",
|
|
2506
|
+
const e = new $();
|
|
2507
|
+
e.setUnits(t), e.addLayer("cyan", $.ACI.CYAN, "DOTTED"), e.addLayer("yellow", $.ACI.YELLOW, "DOTTED"), e.addLayer("white", $.ACI.WHITE, "DOTTED");
|
|
2437
2508
|
const n = this.toDrawDataJson();
|
|
2438
2509
|
return n.line.forEach((s) => {
|
|
2439
2510
|
let [i, r, o, a, c] = s;
|
|
@@ -2455,7 +2526,7 @@ class k extends q {
|
|
|
2455
2526
|
* @param filename
|
|
2456
2527
|
*/
|
|
2457
2528
|
async downloadOriginalData(t) {
|
|
2458
|
-
const e = JSON.stringify(this.
|
|
2529
|
+
const e = JSON.stringify(J(this.getLineSegments()), null, 2);
|
|
2459
2530
|
if (typeof window < "u") {
|
|
2460
2531
|
const n = new Blob([e], { type: "application/json" }), s = document.createElement("a");
|
|
2461
2532
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
@@ -2517,17 +2588,17 @@ class k extends q {
|
|
|
2517
2588
|
});
|
|
2518
2589
|
}
|
|
2519
2590
|
}
|
|
2520
|
-
function ct(
|
|
2521
|
-
if (
|
|
2522
|
-
if (
|
|
2523
|
-
if (Array.isArray(
|
|
2591
|
+
function ct(u) {
|
|
2592
|
+
if (u === null || typeof u != "object") return u;
|
|
2593
|
+
if (u instanceof Date) return new Date(u.getTime());
|
|
2594
|
+
if (Array.isArray(u)) return u.map(ct);
|
|
2524
2595
|
const t = {};
|
|
2525
|
-
for (const e in
|
|
2526
|
-
Object.prototype.hasOwnProperty.call(
|
|
2596
|
+
for (const e in u)
|
|
2597
|
+
Object.prototype.hasOwnProperty.call(u, e) && (t[e] = ct(u[e]));
|
|
2527
2598
|
return t;
|
|
2528
2599
|
}
|
|
2529
|
-
const
|
|
2530
|
-
class
|
|
2600
|
+
const z = new A();
|
|
2601
|
+
class Me extends k {
|
|
2531
2602
|
static name = "AngleCorrectionDxf";
|
|
2532
2603
|
angle = 0;
|
|
2533
2604
|
onAddFromParent(t) {
|
|
@@ -2538,12 +2609,12 @@ class me extends k {
|
|
|
2538
2609
|
let s = 0, i = null;
|
|
2539
2610
|
for (let c = 0; c < e.originalData.length; c++) {
|
|
2540
2611
|
const l = e.originalData[c];
|
|
2541
|
-
if (
|
|
2542
|
-
const [h,
|
|
2543
|
-
s = -new A(h,
|
|
2612
|
+
if (z.start.copy(l.start), z.end.copy(l.end), l.isVerticalReferenceLine) {
|
|
2613
|
+
const [h, d] = l.start.y < l.end.y ? [z.start, z.end] : [z.end, z.start];
|
|
2614
|
+
s = -new A(h, d).direction().angleBetween(new M(0, 1), "angle", "360"), i = null;
|
|
2544
2615
|
break;
|
|
2545
2616
|
}
|
|
2546
|
-
(!i ||
|
|
2617
|
+
(!i || z.length() > i.length()) && (i = z.clone(), i.userData.index = c);
|
|
2547
2618
|
}
|
|
2548
2619
|
if (i) {
|
|
2549
2620
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
@@ -2551,10 +2622,10 @@ class me extends k {
|
|
|
2551
2622
|
s = -new A(c, l).direction().angleBetween(new M(0, 1), "angle", "360");
|
|
2552
2623
|
}
|
|
2553
2624
|
const r = e.originalBox.center, o = M.zero(), a = e.originalData.map((c) => {
|
|
2554
|
-
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),
|
|
2555
|
-
return
|
|
2625
|
+
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(ct(c), { start: l, end: h });
|
|
2626
|
+
return d.drawWindow && d.drawWindow.forEach((f) => {
|
|
2556
2627
|
f.p = o.copy(f.p).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(f.p.z);
|
|
2557
|
-
}),
|
|
2628
|
+
}), d;
|
|
2558
2629
|
});
|
|
2559
2630
|
n.appendLineSegmentList.forEach((c) => {
|
|
2560
2631
|
const l = c.clone();
|
|
@@ -2572,7 +2643,7 @@ class me extends k {
|
|
|
2572
2643
|
});
|
|
2573
2644
|
}
|
|
2574
2645
|
}
|
|
2575
|
-
class Rt extends
|
|
2646
|
+
class Rt extends _ {
|
|
2576
2647
|
static name = "Variable";
|
|
2577
2648
|
originalLineVisible = !0;
|
|
2578
2649
|
dxfVisible = !0;
|
|
@@ -2599,10 +2670,11 @@ class Rt extends q {
|
|
|
2599
2670
|
if (t in this) return this[t];
|
|
2600
2671
|
}
|
|
2601
2672
|
}
|
|
2602
|
-
class
|
|
2673
|
+
class Se {
|
|
2603
2674
|
// 所有可查找的点位
|
|
2604
2675
|
possibleDoorPoints = [];
|
|
2605
2676
|
doorPoint = [];
|
|
2677
|
+
calculatedDoorPoint = [];
|
|
2606
2678
|
dxf;
|
|
2607
2679
|
// 包含所有点的虚拟网格
|
|
2608
2680
|
pointVirtualGrid = new X();
|
|
@@ -2618,18 +2690,28 @@ class we {
|
|
|
2618
2690
|
lineAnalysis;
|
|
2619
2691
|
continueFind = !0;
|
|
2620
2692
|
constructor(t) {
|
|
2621
|
-
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((
|
|
2622
|
-
this.pointVirtualGrid.insert(
|
|
2623
|
-
})
|
|
2624
|
-
const e = this.
|
|
2625
|
-
this.
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2693
|
+
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((i) => {
|
|
2694
|
+
this.pointVirtualGrid.insert(i.start, i), this.pointVirtualGrid.insert(i.end, i);
|
|
2695
|
+
});
|
|
2696
|
+
const { doorPoints: e, calculatedDoorPoint: n } = this.getDoorPoint();
|
|
2697
|
+
this.doorPoint = e, this.calculatedDoorPoint = n;
|
|
2698
|
+
const s = this.searchDoubleLinePoint();
|
|
2699
|
+
this.addPointsExcludeRule((i, r, o) => {
|
|
2700
|
+
const a = this.lineSegments.indexOf(i), c = s.get(a);
|
|
2701
|
+
return typeof c == "number" ? c === -1 || c === o : !1;
|
|
2702
|
+
}), this.addPointsExcludeRule((i, r) => !!this.doorPoint.find((o) => o.point.equal(r))), this.addPointsExcludeRule((i, r) => !!this.calculatedDoorPoint.find((o) => o.point.equal(r))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((i) => this.findPointVirtualGrid.insert(i.point, i.line)), this.handle();
|
|
2629
2703
|
}
|
|
2630
2704
|
handle() {
|
|
2631
|
-
this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.dxf.
|
|
2705
|
+
this.dxf.doorLineSegment.push(...this.search(this.doorPoint, this.possibleDoorPoints, 0.5)), this.dxf.doors.length < 2 && this.dxf.doorLineSegment.push(...this.search(this.possibleDoorPoints, this.possibleDoorPoints, 0.6));
|
|
2632
2706
|
}
|
|
2707
|
+
/** 查找
|
|
2708
|
+
* @param doorPoints
|
|
2709
|
+
* @param possibleDoorPoints
|
|
2710
|
+
* @param minDoorWidth
|
|
2711
|
+
* @param doorSearchDistance
|
|
2712
|
+
* @param doorSearchNearAngle
|
|
2713
|
+
* @returns
|
|
2714
|
+
*/
|
|
2633
2715
|
search(t, e = [], n = 0.6, s = this.doorSearchDistance, i = this.doorSearchNearAngle) {
|
|
2634
2716
|
const r = this.dxf, o = this.searchNearby(t, e, s, i);
|
|
2635
2717
|
o.push(
|
|
@@ -2650,13 +2732,13 @@ class we {
|
|
|
2650
2732
|
return o.forEach((c) => {
|
|
2651
2733
|
const l = new A(c?.start, c?.end), h = l.length();
|
|
2652
2734
|
if (h < n) return;
|
|
2653
|
-
const
|
|
2735
|
+
const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
2654
2736
|
for (let y = 0; y < 3; y++) {
|
|
2655
2737
|
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), m = new A(
|
|
2656
2738
|
x,
|
|
2657
|
-
x.clone().add(
|
|
2739
|
+
x.clone().add(d.clone().multiplyScalar(1))
|
|
2658
2740
|
);
|
|
2659
|
-
if (m.directionMove(
|
|
2741
|
+
if (m.directionMove(d, -0.5), this.quadtree.queryLineSegment(m).length) return;
|
|
2660
2742
|
}
|
|
2661
2743
|
a.push(l);
|
|
2662
2744
|
}), a;
|
|
@@ -2676,7 +2758,7 @@ class we {
|
|
|
2676
2758
|
return this.lineSegments.forEach((e) => {
|
|
2677
2759
|
e.points.forEach((n, s) => {
|
|
2678
2760
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
|
|
2679
|
-
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid:
|
|
2761
|
+
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: K() });
|
|
2680
2762
|
});
|
|
2681
2763
|
}), t;
|
|
2682
2764
|
}
|
|
@@ -2684,32 +2766,39 @@ class we {
|
|
|
2684
2766
|
* 查找已知为门的点位
|
|
2685
2767
|
*/
|
|
2686
2768
|
getDoorPoint() {
|
|
2687
|
-
const t = [], e = this.dxf,
|
|
2688
|
-
return
|
|
2689
|
-
const
|
|
2690
|
-
if (
|
|
2769
|
+
const t = [], e = [], n = this.dxf, s = this.pointVirtualGrid;
|
|
2770
|
+
return n.doors.forEach((i) => {
|
|
2771
|
+
const r = n.lineSegments[i[4]], o = n.originalData[i[4]];
|
|
2772
|
+
if (o.doorDirectConnection) {
|
|
2691
2773
|
this.continueFind = !1;
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2774
|
+
const a = new A(M.from(o.start), M.from(o.end));
|
|
2775
|
+
a.userData = {
|
|
2694
2776
|
doorDirectConnection: !0,
|
|
2695
2777
|
isDoor: !0
|
|
2696
|
-
}, this.dxf.doorLineSegment.push(
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2778
|
+
}, this.dxf.doorLineSegment.push(a), a.points.forEach((c) => {
|
|
2779
|
+
const l = s.queryPoint(c);
|
|
2780
|
+
l.length && e.push({
|
|
2781
|
+
line: l[0].userData,
|
|
2782
|
+
point: l[0].point,
|
|
2783
|
+
uuid: K()
|
|
2784
|
+
});
|
|
2785
|
+
});
|
|
2786
|
+
} else if (o.drawDoorData) {
|
|
2787
|
+
const a = M.from(o.drawDoorData.start), c = M.from(o.drawDoorData.n), l = s.queryPoint(a).filter((h) => {
|
|
2788
|
+
if (h.userData === r) return !1;
|
|
2789
|
+
const d = h.userData, f = d.direction();
|
|
2790
|
+
d.start.equal(a) && f.multiplyScalar(-1);
|
|
2791
|
+
const p = c.angleBetween(f, "angle");
|
|
2792
|
+
return p > 170 || p < 10;
|
|
2704
2793
|
});
|
|
2705
|
-
|
|
2706
|
-
line:
|
|
2707
|
-
point:
|
|
2708
|
-
uuid:
|
|
2794
|
+
l.length && t.push({
|
|
2795
|
+
line: l[0].userData,
|
|
2796
|
+
point: a,
|
|
2797
|
+
uuid: K()
|
|
2709
2798
|
});
|
|
2710
2799
|
} else
|
|
2711
|
-
console.warn(`门的线段顺序${
|
|
2712
|
-
}), t;
|
|
2800
|
+
console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
|
|
2801
|
+
}), { doorPoints: t, calculatedDoorPoint: e };
|
|
2713
2802
|
}
|
|
2714
2803
|
/**
|
|
2715
2804
|
* 查找双线墙的点位
|
|
@@ -2732,18 +2821,18 @@ class we {
|
|
|
2732
2821
|
*/
|
|
2733
2822
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2734
2823
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2735
|
-
function o({ point: x, line: m },
|
|
2824
|
+
function o({ point: x, line: m }, D, w) {
|
|
2736
2825
|
const g = m.direction();
|
|
2737
2826
|
m.start === x && g.multiplyScalar(-1);
|
|
2738
|
-
const S = i.queryCircle(x, n).filter((L) => L.userData !== m).sort((L, b) => L.point.distance(x) - b.point.distance(x)),
|
|
2827
|
+
const S = i.queryCircle(x, n).filter((L) => L.userData !== m).sort((L, b) => L.point.distance(x) - b.point.distance(x)), E = [];
|
|
2739
2828
|
for (let L = 0; L < S.length; L++) {
|
|
2740
|
-
const b = e.findIndex((O) => O.point === S[L].point), R = t[
|
|
2829
|
+
const b = e.findIndex((O) => O.point === S[L].point), R = t[D].uuid, P = e[b].uuid;
|
|
2741
2830
|
if (w.has(`${R}.${P}`)) continue;
|
|
2742
2831
|
w.add(`${R}.${P}`), w.add(`${P}.${R}`);
|
|
2743
2832
|
const B = S[L].point, C = new A(x.clone(), B.clone());
|
|
2744
2833
|
if (C.direction().angleBetween(g, "angle") < s) {
|
|
2745
|
-
const O = t[
|
|
2746
|
-
v.start.equal(S[L].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 ||
|
|
2834
|
+
const O = t[D].line.direction(), v = S[L].userData;
|
|
2835
|
+
v.start.equal(S[L].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 || E.push({
|
|
2747
2836
|
findData: S[L],
|
|
2748
2837
|
findUuid: P,
|
|
2749
2838
|
doorLine: C,
|
|
@@ -2751,59 +2840,59 @@ class we {
|
|
|
2751
2840
|
}));
|
|
2752
2841
|
}
|
|
2753
2842
|
}
|
|
2754
|
-
return
|
|
2843
|
+
return E;
|
|
2755
2844
|
}
|
|
2756
|
-
function a(x, m,
|
|
2845
|
+
function a(x, m, D, w, g) {
|
|
2757
2846
|
w.add(x);
|
|
2758
2847
|
const S = [];
|
|
2759
2848
|
g && S.push(g);
|
|
2760
|
-
for (let
|
|
2761
|
-
const L = E
|
|
2849
|
+
for (let E = 0; E < D.length; E++) {
|
|
2850
|
+
const L = D[E];
|
|
2762
2851
|
if (m.has(L.findUuid)) {
|
|
2763
2852
|
const b = m.get(L.findUuid);
|
|
2764
2853
|
a(L.findUuid, m, b, w, L) && S.push(L);
|
|
2765
2854
|
} else S.push(L);
|
|
2766
2855
|
}
|
|
2767
|
-
return S.sort((
|
|
2856
|
+
return S.sort((E, L) => E.doorLine.length() - L.doorLine.length()), g && S[0] === g ? (D.splice(0), !0) : (D.splice(1), !1);
|
|
2768
2857
|
}
|
|
2769
2858
|
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
2770
2859
|
t.map((x, m) => {
|
|
2771
|
-
const
|
|
2772
|
-
|
|
2860
|
+
const D = o(x, m, c);
|
|
2861
|
+
D.length && l.set(x.uuid, D);
|
|
2773
2862
|
}), c.clear();
|
|
2774
2863
|
const h = /* @__PURE__ */ new Map();
|
|
2775
2864
|
l.forEach((x, m) => {
|
|
2776
2865
|
if (!c.has(m) && x.length && a(m, l, x, c), x.length) {
|
|
2777
|
-
const
|
|
2778
|
-
h.has(
|
|
2866
|
+
const D = x[0];
|
|
2867
|
+
h.has(D.doorUuid) || h.set(D.doorUuid, []), h.get(D.doorUuid)?.push(D), h.has(D.findUuid) || h.set(D.findUuid, []), h.get(D.findUuid)?.push(D);
|
|
2779
2868
|
}
|
|
2780
2869
|
});
|
|
2781
|
-
const
|
|
2870
|
+
const d = /* @__PURE__ */ new Set();
|
|
2782
2871
|
h.forEach((x) => {
|
|
2783
2872
|
if (x.length > 1) {
|
|
2784
|
-
x.sort((m,
|
|
2785
|
-
for (let m = 1; m < x.length; m++)
|
|
2873
|
+
x.sort((m, D) => m.doorLine.length() - D.doorLine.length());
|
|
2874
|
+
for (let m = 1; m < x.length; m++) d.add(x[m]);
|
|
2786
2875
|
}
|
|
2787
2876
|
});
|
|
2788
2877
|
const f = [], p = [];
|
|
2789
2878
|
l.forEach((x) => {
|
|
2790
2879
|
if (x.length) {
|
|
2791
2880
|
const m = x[0];
|
|
2792
|
-
|
|
2881
|
+
d.has(m) || (f.push(m), p.push(m.doorUuid, m.findUuid));
|
|
2793
2882
|
}
|
|
2794
2883
|
});
|
|
2795
2884
|
const y = [];
|
|
2796
2885
|
return f.forEach((x) => {
|
|
2797
|
-
const m = t.findIndex((b) => b.uuid === x.doorUuid),
|
|
2886
|
+
const m = t.findIndex((b) => b.uuid === x.doorUuid), D = e.findIndex((b) => b.uuid === x.findUuid), w = t[m].point.clone(), g = e[D].point.clone(), S = this.findLongLineSegment(t[m].line), E = this.findLongLineSegment(e[D].line), L = S.projectPoint(g);
|
|
2798
2887
|
if (L) {
|
|
2799
2888
|
w.copy(L);
|
|
2800
|
-
const b = new A(w, g), R =
|
|
2889
|
+
const b = new A(w, g), R = E.includedAngle(b);
|
|
2801
2890
|
(R < 10 || R > 170 || Math.abs(90 - R) < 10) && y.push({
|
|
2802
2891
|
start: w,
|
|
2803
2892
|
end: g
|
|
2804
2893
|
});
|
|
2805
2894
|
} else {
|
|
2806
|
-
const b =
|
|
2895
|
+
const b = E.projectPoint(w);
|
|
2807
2896
|
b && g.copy(b);
|
|
2808
2897
|
const R = new A(w, g), P = S.includedAngle(R);
|
|
2809
2898
|
(P < 10 || P > 170 || Math.abs(90 - P) < 10) && y.push({
|
|
@@ -2848,22 +2937,22 @@ class we {
|
|
|
2848
2937
|
searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2849
2938
|
const s = this.pointVirtualGrid, i = this.quadtree, r = e.direction(), o = e.start.normal(e.end), a = e.start.clone();
|
|
2850
2939
|
e.start === t && r.multiplyScalar(-1), e.start === t && a.copy(e.end);
|
|
2851
|
-
const c = s.queryPoint(a).filter((
|
|
2852
|
-
for (let
|
|
2853
|
-
const f = c[
|
|
2940
|
+
const c = s.queryPoint(a).filter((d) => d.userData !== e);
|
|
2941
|
+
for (let d = 0; d < c.length; d++) {
|
|
2942
|
+
const f = c[d], p = f.userData, y = p.direction();
|
|
2854
2943
|
if (p.start === f.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
|
|
2855
2944
|
o.multiplyScalar(-1);
|
|
2856
2945
|
break;
|
|
2857
2946
|
}
|
|
2858
2947
|
}
|
|
2859
|
-
const l = new A(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((
|
|
2860
|
-
point:
|
|
2861
|
-
line:
|
|
2862
|
-
})).filter((
|
|
2948
|
+
const l = new A(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
|
|
2949
|
+
point: d.line.getIntersection(l),
|
|
2950
|
+
line: d.line
|
|
2951
|
+
})).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
|
|
2863
2952
|
if (h.length) {
|
|
2864
|
-
const
|
|
2865
|
-
if (Math.abs(90 -
|
|
2866
|
-
return
|
|
2953
|
+
const d = h[0];
|
|
2954
|
+
if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
|
|
2955
|
+
return d;
|
|
2867
2956
|
}
|
|
2868
2957
|
}
|
|
2869
2958
|
/**
|
|
@@ -2890,7 +2979,7 @@ class we {
|
|
|
2890
2979
|
return e;
|
|
2891
2980
|
}
|
|
2892
2981
|
}
|
|
2893
|
-
class
|
|
2982
|
+
class De extends _ {
|
|
2894
2983
|
static name = "LineAnalysis";
|
|
2895
2984
|
Dxf = null;
|
|
2896
2985
|
Variable = null;
|
|
@@ -2944,14 +3033,14 @@ class Me extends q {
|
|
|
2944
3033
|
createRectangle(t) {
|
|
2945
3034
|
const e = this.Dxf, n = t.project, s = t.project2;
|
|
2946
3035
|
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]);
|
|
2947
|
-
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]),
|
|
3036
|
+
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(d);
|
|
2948
3037
|
p.multiplyScalar(e.width * 0.5);
|
|
2949
|
-
const y =
|
|
2950
|
-
if (!(m.x > 0 &&
|
|
2951
|
-
|
|
3038
|
+
const y = d.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), m = d.direction(f), D = y.direction(x);
|
|
3039
|
+
if (!(m.x > 0 && D.x < 0 || m.x < 0 && D.x > 0 || m.y > 0 && D.y < 0 || m.y < 0 && D.y > 0)) {
|
|
3040
|
+
d.set(y.x, y.y), f.set(x.x, x.y);
|
|
2952
3041
|
for (let w = 1; w < o; w++) {
|
|
2953
|
-
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w),
|
|
2954
|
-
this.addData(
|
|
3042
|
+
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w), E = d.clone().add(g), L = f.clone().add(S);
|
|
3043
|
+
this.addData(E, L);
|
|
2955
3044
|
}
|
|
2956
3045
|
}
|
|
2957
3046
|
}
|
|
@@ -2978,7 +3067,7 @@ class Me extends q {
|
|
|
2978
3067
|
this.buildQuadtree();
|
|
2979
3068
|
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
2980
3069
|
e.forEach((i, r) => {
|
|
2981
|
-
const o = e[r], a =
|
|
3070
|
+
const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
2982
3071
|
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
2983
3072
|
try {
|
|
2984
3073
|
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
@@ -3021,13 +3110,12 @@ class Me extends q {
|
|
|
3021
3110
|
doorSearchDistance = 2;
|
|
3022
3111
|
doors = [];
|
|
3023
3112
|
DoorsAnalysis;
|
|
3113
|
+
skipFindDoor = !1;
|
|
3024
3114
|
doorsAnalysis() {
|
|
3025
|
-
this.DoorsAnalysis = new
|
|
3026
|
-
type: "analysisCompleted"
|
|
3027
|
-
});
|
|
3115
|
+
this.skipFindDoor || (this.DoorsAnalysis = new Se(this), this.skipFindDoor = !1), this.dispatchEvent({ type: "analysisCompleted" });
|
|
3028
3116
|
}
|
|
3029
3117
|
}
|
|
3030
|
-
class
|
|
3118
|
+
class Le extends _ {
|
|
3031
3119
|
static name = "ThreeVJia";
|
|
3032
3120
|
lineSegments = [];
|
|
3033
3121
|
onAddFromParent() {
|
|
@@ -3037,8 +3125,8 @@ class Se extends q {
|
|
|
3037
3125
|
const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf"), n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
|
|
3038
3126
|
let i = [...e.lineSegments], r = [], o = [];
|
|
3039
3127
|
t.resultList.forEach((l) => {
|
|
3040
|
-
const h = s.get(l.target) ?? [],
|
|
3041
|
-
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points),
|
|
3128
|
+
const h = s.get(l.target) ?? [], d = s.get(l.source) ?? [], f = l.project.clone(), p = l.project2.clone();
|
|
3129
|
+
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points), d.push(...p.points), s.set(l.target, h), s.set(l.source, d);
|
|
3042
3130
|
const y = new A(f.start, p.start), x = new A(f.end, p.end), m = new A(y.center, x.center);
|
|
3043
3131
|
m.userData.wallWidth = Math.max(y.length(), x.length()), r.push(m);
|
|
3044
3132
|
});
|
|
@@ -3046,19 +3134,19 @@ class Se extends q {
|
|
|
3046
3134
|
i = i.filter((l) => {
|
|
3047
3135
|
if (o.indexOf(l) > -1) return !1;
|
|
3048
3136
|
if (s.has(l)) {
|
|
3049
|
-
const h = s.get(l),
|
|
3137
|
+
const h = s.get(l), d = l.clone();
|
|
3050
3138
|
if (h) {
|
|
3051
3139
|
for (let p = 0; p < h.length; p += 2) {
|
|
3052
3140
|
const y = h[p], x = h[p + 1];
|
|
3053
|
-
y.userData.length = y.distance(
|
|
3141
|
+
y.userData.length = y.distance(d.start), x.userData.length = x.distance(d.start), y.userData.type = "start", x.userData.type = "end", d.start.distance(y) > d.start.distance(x) && (h[p] = x, h[p + 1] = y, y.userData.type = "end", x.userData.type = "start");
|
|
3054
3142
|
}
|
|
3055
3143
|
h.sort((p, y) => p.userData.length - y.userData.length);
|
|
3056
3144
|
const f = [];
|
|
3057
3145
|
for (let p = 0; p < h.length; p++) {
|
|
3058
3146
|
const y = h[p];
|
|
3059
|
-
y.userData.type === "start" ? (f.length === 0 && (a.push(new A(
|
|
3147
|
+
y.userData.type === "start" ? (f.length === 0 && (a.push(new A(d.start.clone(), y.clone())), d.start.copy(y)), f.push("start")) : (f.pop(), f.length === 0 && d.start.copy(y));
|
|
3060
3148
|
}
|
|
3061
|
-
a.push(
|
|
3149
|
+
a.push(d);
|
|
3062
3150
|
}
|
|
3063
3151
|
return !1;
|
|
3064
3152
|
}
|
|
@@ -3162,7 +3250,7 @@ class ht extends se {
|
|
|
3162
3250
|
* @param scale 原始数据缩放比例
|
|
3163
3251
|
*/
|
|
3164
3252
|
constructor(t = 0.1, e = 1) {
|
|
3165
|
-
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
|
|
3253
|
+
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 Me(), this.Variable = new Rt(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new De()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new Le()), ht.finalInstance = this;
|
|
3166
3254
|
}
|
|
3167
3255
|
usePlugin(t) {
|
|
3168
3256
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3203,15 +3291,15 @@ class ut {
|
|
|
3203
3291
|
static boundExtbyTraj(t, e, n = 0.12) {
|
|
3204
3292
|
function s(w, g) {
|
|
3205
3293
|
return g.queryLineSegment(w).filter((S) => S.line !== w).map(({ line: S }) => {
|
|
3206
|
-
const
|
|
3207
|
-
w.sameEndpoint(S) && (
|
|
3294
|
+
const E = { resultLine: S, type: "intersect", direction: "vertical", point: null, newLine: null };
|
|
3295
|
+
w.sameEndpoint(S) && (E.type = "endpoint"), w.parallel(S) && (E.direction = "parallel");
|
|
3208
3296
|
const L = w.getSameEndpoint(S);
|
|
3209
|
-
if (L)
|
|
3297
|
+
if (L) E.point = L[1];
|
|
3210
3298
|
else {
|
|
3211
3299
|
const b = S.getIntersection(w);
|
|
3212
|
-
b && (
|
|
3300
|
+
b && (E.point = S.start.equal(b) ? S.start : S.end);
|
|
3213
3301
|
}
|
|
3214
|
-
return
|
|
3302
|
+
return E;
|
|
3215
3303
|
});
|
|
3216
3304
|
}
|
|
3217
3305
|
function i(w) {
|
|
@@ -3224,18 +3312,18 @@ class ut {
|
|
|
3224
3312
|
w.directionMove(S, n * 0.5);
|
|
3225
3313
|
}
|
|
3226
3314
|
}
|
|
3227
|
-
function r({ resultLine: w, type: g, direction: S, point:
|
|
3315
|
+
function r({ resultLine: w, type: g, direction: S, point: E }, L, b, R) {
|
|
3228
3316
|
if (g === "intersect")
|
|
3229
|
-
|
|
3317
|
+
E && E.copy(L.projectPoint(E) ?? E);
|
|
3230
3318
|
else if (S === "vertical") {
|
|
3231
|
-
if (
|
|
3232
|
-
const P = L.projectPoint(
|
|
3233
|
-
|
|
3319
|
+
if (E) {
|
|
3320
|
+
const P = L.projectPoint(E, !1);
|
|
3321
|
+
E.copy(P), L.isPointOnSegment(P) || (L.start.distance(P) < L.end.distance(P) ? R.push(new A(P.clone(), L.start.clone())) : R.push(new A(P.clone(), L.end.clone())));
|
|
3234
3322
|
}
|
|
3235
|
-
} else if (!
|
|
3236
|
-
let P = L.projectPoint(
|
|
3237
|
-
if (L.start.distance(
|
|
3238
|
-
R.push(new A(
|
|
3323
|
+
} else if (!d.includes(w) && E) {
|
|
3324
|
+
let P = L.projectPoint(E, !1), B;
|
|
3325
|
+
if (L.start.distance(E) < L.end.distance(E) ? B = L.start : B = L.end, P) {
|
|
3326
|
+
R.push(new A(E.clone(), P.clone()));
|
|
3239
3327
|
const C = new A(P.clone(), B.clone());
|
|
3240
3328
|
C.length() && R.push(C);
|
|
3241
3329
|
}
|
|
@@ -3244,45 +3332,45 @@ class ut {
|
|
|
3244
3332
|
}
|
|
3245
3333
|
const o = Object.keys(e).map((w) => M.from(e[w])), a = [];
|
|
3246
3334
|
let c = t.map(({ start: w, end: g, ...S }) => {
|
|
3247
|
-
const
|
|
3248
|
-
return
|
|
3335
|
+
const E = new A(M.from(w), M.from(g));
|
|
3336
|
+
return E.userData = S, a.push(w.z ?? 0, g.z ?? 0), E;
|
|
3249
3337
|
});
|
|
3250
3338
|
const l = a.reduce((w, g) => w + g, 0) / a.length;
|
|
3251
|
-
let
|
|
3252
|
-
c = c.filter((w) => !
|
|
3339
|
+
let d = ut.findExtWallByTraj(c, o).filter((w) => w.userData.expandDirect);
|
|
3340
|
+
c = c.filter((w) => !d.includes(w)), c.push(...d);
|
|
3253
3341
|
const p = this.parent?.findComponentByName("Renderer");
|
|
3254
|
-
o.forEach((w) => p.createPointMesh(w, 0.05, {}).position.z = l), p.createLineSegments(
|
|
3255
|
-
const y = A.groupBySamePointAndParallel(
|
|
3342
|
+
o.forEach((w) => p.createPointMesh(w, 0.05, {}).position.z = l), p.createLineSegments(d, 0, { color: 65280 }).position.z = l + 1e-3;
|
|
3343
|
+
const y = A.groupBySamePointAndParallel(d), x = new F(N.fromByLineSegment(...c));
|
|
3256
3344
|
c.forEach((w) => w.userData.isDoor || x.insert(w));
|
|
3257
|
-
const m = y.map((w) => w.flatMap((g) => s(g, x))),
|
|
3258
|
-
return y.flatMap((w, g) => (w.forEach((
|
|
3259
|
-
if (!
|
|
3345
|
+
const m = y.map((w) => w.flatMap((g) => s(g, x))), D = [];
|
|
3346
|
+
return y.flatMap((w, g) => (w.forEach((E) => (i(E), x.update(E))), m[g].filter((E) => {
|
|
3347
|
+
if (!d.includes(E.resultLine)) {
|
|
3260
3348
|
let L;
|
|
3261
|
-
return Object.defineProperty(
|
|
3349
|
+
return Object.defineProperty(E, "newLine", {
|
|
3262
3350
|
get() {
|
|
3263
3351
|
return L || (L = A.mergeLines(...w)), L;
|
|
3264
3352
|
}
|
|
3265
3353
|
}), !0;
|
|
3266
3354
|
}
|
|
3267
|
-
r(
|
|
3355
|
+
r(E, A.mergeLines(...w), x, D);
|
|
3268
3356
|
}))).reduce((w, g) => (w.has(g.resultLine) || w.set(g.resultLine, []), w.get(g.resultLine)?.push(g), w), /* @__PURE__ */ new Map()).forEach((w) => {
|
|
3269
3357
|
w.reduce((g, S) => (g.has(S.point) || g.set(S.point, []), g.get(S.point)?.push(S), g), /* @__PURE__ */ new Map()).forEach((g) => {
|
|
3270
3358
|
const S = /* @__PURE__ */ new Set();
|
|
3271
|
-
for (let
|
|
3272
|
-
const L = g[
|
|
3273
|
-
S.has(L.point) || (r(L, L.newLine, x,
|
|
3359
|
+
for (let E = 0; E < g.length; E++) {
|
|
3360
|
+
const L = g[E];
|
|
3361
|
+
S.has(L.point) || (r(L, L.newLine, x, D), S.add(L.point));
|
|
3274
3362
|
}
|
|
3275
3363
|
});
|
|
3276
|
-
}), c.push(...A.deduplication(
|
|
3364
|
+
}), c.push(...A.deduplication(D)), c.forEach((w) => w.userData.isWindow && tt(w)), c = lt(c), c = A.deduplication(c), J(c, l);
|
|
3277
3365
|
}
|
|
3278
3366
|
}
|
|
3279
|
-
const
|
|
3367
|
+
const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3280
3368
|
__proto__: null,
|
|
3281
3369
|
AxisAlignCorr: Pt,
|
|
3282
3370
|
BoundExt: ut,
|
|
3283
|
-
lineDataToOriginalData:
|
|
3371
|
+
lineDataToOriginalData: J,
|
|
3284
3372
|
lineSegmentClipping: lt,
|
|
3285
|
-
recomputedWindow:
|
|
3373
|
+
recomputedWindow: tt
|
|
3286
3374
|
}, Symbol.toStringTag, { value: "Module" })), St = {
|
|
3287
3375
|
POSITION: [
|
|
3288
3376
|
"byte",
|
|
@@ -3311,36 +3399,36 @@ const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3311
3399
|
"unsigned short"
|
|
3312
3400
|
]
|
|
3313
3401
|
};
|
|
3314
|
-
class
|
|
3402
|
+
class et {
|
|
3315
3403
|
constructor() {
|
|
3316
3404
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
3317
|
-
return new
|
|
3318
|
-
}), this.register(function(t) {
|
|
3319
|
-
return new Ce(t);
|
|
3405
|
+
return new Be(t);
|
|
3320
3406
|
}), this.register(function(t) {
|
|
3321
|
-
return new
|
|
3407
|
+
return new Oe(t);
|
|
3322
3408
|
}), this.register(function(t) {
|
|
3323
|
-
return new
|
|
3409
|
+
return new je(t);
|
|
3324
3410
|
}), this.register(function(t) {
|
|
3325
3411
|
return new ze(t);
|
|
3326
3412
|
}), this.register(function(t) {
|
|
3327
|
-
return new
|
|
3328
|
-
}), this.register(function(t) {
|
|
3329
|
-
return new Be(t);
|
|
3413
|
+
return new qe(t);
|
|
3330
3414
|
}), this.register(function(t) {
|
|
3331
|
-
return new
|
|
3415
|
+
return new _e(t);
|
|
3332
3416
|
}), this.register(function(t) {
|
|
3333
3417
|
return new Fe(t);
|
|
3334
3418
|
}), this.register(function(t) {
|
|
3335
|
-
return new
|
|
3419
|
+
return new Ue(t);
|
|
3336
3420
|
}), this.register(function(t) {
|
|
3337
|
-
return new
|
|
3421
|
+
return new Ge(t);
|
|
3338
3422
|
}), this.register(function(t) {
|
|
3339
3423
|
return new Ye(t);
|
|
3340
3424
|
}), this.register(function(t) {
|
|
3341
3425
|
return new ke(t);
|
|
3426
|
+
}), this.register(function(t) {
|
|
3427
|
+
return new Xe(t);
|
|
3342
3428
|
}), this.register(function(t) {
|
|
3343
3429
|
return new Ve(t);
|
|
3430
|
+
}), this.register(function(t) {
|
|
3431
|
+
return new We(t);
|
|
3344
3432
|
});
|
|
3345
3433
|
}
|
|
3346
3434
|
register(t) {
|
|
@@ -3353,7 +3441,7 @@ class tt {
|
|
|
3353
3441
|
return this.textureUtils = t, this;
|
|
3354
3442
|
}
|
|
3355
3443
|
parse(t, e, n, s) {
|
|
3356
|
-
const i = new
|
|
3444
|
+
const i = new Ce(), r = [];
|
|
3357
3445
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
3358
3446
|
r.push(this.pluginCallbacks[o](i));
|
|
3359
3447
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
|
|
@@ -3389,78 +3477,78 @@ const T = {
|
|
|
3389
3477
|
CLAMP_TO_EDGE: 33071,
|
|
3390
3478
|
MIRRORED_REPEAT: 33648,
|
|
3391
3479
|
REPEAT: 10497
|
|
3392
|
-
},
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
const
|
|
3480
|
+
}, it = "KHR_mesh_quantization", U = {};
|
|
3481
|
+
U[Vt] = T.NEAREST;
|
|
3482
|
+
U[Wt] = T.NEAREST_MIPMAP_NEAREST;
|
|
3483
|
+
U[Ht] = T.NEAREST_MIPMAP_LINEAR;
|
|
3484
|
+
U[Jt] = T.LINEAR;
|
|
3485
|
+
U[$t] = T.LINEAR_MIPMAP_NEAREST;
|
|
3486
|
+
U[Kt] = T.LINEAR_MIPMAP_LINEAR;
|
|
3487
|
+
U[Zt] = T.CLAMP_TO_EDGE;
|
|
3488
|
+
U[Qt] = T.REPEAT;
|
|
3489
|
+
U[te] = T.MIRRORED_REPEAT;
|
|
3490
|
+
const Dt = {
|
|
3403
3491
|
scale: "scale",
|
|
3404
3492
|
position: "translation",
|
|
3405
3493
|
quaternion: "rotation",
|
|
3406
3494
|
morphTargetInfluences: "weights"
|
|
3407
|
-
}, Ee = new Ft(), Lt = 12,
|
|
3408
|
-
function H(
|
|
3409
|
-
return
|
|
3495
|
+
}, Ee = new Ft(), Lt = 12, Ae = 1179937895, Te = 2, Et = 8, be = 1313821514, Ie = 5130562;
|
|
3496
|
+
function H(u, t) {
|
|
3497
|
+
return u.length === t.length && u.every(function(e, n) {
|
|
3410
3498
|
return e === t[n];
|
|
3411
3499
|
});
|
|
3412
3500
|
}
|
|
3413
|
-
function
|
|
3414
|
-
return new TextEncoder().encode(
|
|
3501
|
+
function Pe(u) {
|
|
3502
|
+
return new TextEncoder().encode(u).buffer;
|
|
3415
3503
|
}
|
|
3416
|
-
function
|
|
3417
|
-
return H(
|
|
3504
|
+
function Re(u) {
|
|
3505
|
+
return H(u.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
3418
3506
|
}
|
|
3419
|
-
function
|
|
3507
|
+
function ve(u, t, e) {
|
|
3420
3508
|
const n = {
|
|
3421
|
-
min: new Array(
|
|
3422
|
-
max: new Array(
|
|
3509
|
+
min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
3510
|
+
max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
3423
3511
|
};
|
|
3424
3512
|
for (let s = t; s < t + e; s++)
|
|
3425
|
-
for (let i = 0; i <
|
|
3513
|
+
for (let i = 0; i < u.itemSize; i++) {
|
|
3426
3514
|
let r;
|
|
3427
|
-
|
|
3515
|
+
u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r = at.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
3428
3516
|
}
|
|
3429
3517
|
return n;
|
|
3430
3518
|
}
|
|
3431
|
-
function vt(
|
|
3432
|
-
return Math.ceil(
|
|
3519
|
+
function vt(u) {
|
|
3520
|
+
return Math.ceil(u / 4) * 4;
|
|
3433
3521
|
}
|
|
3434
|
-
function
|
|
3435
|
-
const e = vt(
|
|
3436
|
-
if (e !==
|
|
3522
|
+
function rt(u, t = 0) {
|
|
3523
|
+
const e = vt(u.byteLength);
|
|
3524
|
+
if (e !== u.byteLength) {
|
|
3437
3525
|
const n = new Uint8Array(e);
|
|
3438
|
-
if (n.set(new Uint8Array(
|
|
3439
|
-
for (let s =
|
|
3526
|
+
if (n.set(new Uint8Array(u)), t !== 0)
|
|
3527
|
+
for (let s = u.byteLength; s < e; s++)
|
|
3440
3528
|
n[s] = t;
|
|
3441
3529
|
return n.buffer;
|
|
3442
3530
|
}
|
|
3443
|
-
return
|
|
3531
|
+
return u;
|
|
3444
3532
|
}
|
|
3445
3533
|
function At() {
|
|
3446
3534
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
3447
3535
|
}
|
|
3448
|
-
function
|
|
3449
|
-
if (typeof OffscreenCanvas < "u" &&
|
|
3536
|
+
function Ne(u, t) {
|
|
3537
|
+
if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
|
|
3450
3538
|
let e;
|
|
3451
|
-
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8),
|
|
3539
|
+
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8), u.convertToBlob({
|
|
3452
3540
|
type: t,
|
|
3453
3541
|
quality: e
|
|
3454
3542
|
});
|
|
3455
3543
|
} else
|
|
3456
|
-
return new Promise((e) =>
|
|
3544
|
+
return new Promise((e) => u.toBlob(e, t));
|
|
3457
3545
|
}
|
|
3458
|
-
class
|
|
3546
|
+
class Ce {
|
|
3459
3547
|
constructor() {
|
|
3460
3548
|
this.plugins = [], this.options = {}, this.pending = [], this.buffers = [], this.byteOffset = 0, this.buffers = [], this.nodeMap = /* @__PURE__ */ new Map(), this.skins = [], this.extensionsUsed = {}, this.extensionsRequired = {}, this.uids = /* @__PURE__ */ new Map(), this.uid = 0, this.json = {
|
|
3461
3549
|
asset: {
|
|
3462
3550
|
version: "2.0",
|
|
3463
|
-
generator: "THREE.GLTFExporter r" +
|
|
3551
|
+
generator: "THREE.GLTFExporter r" + Gt
|
|
3464
3552
|
}
|
|
3465
3553
|
}, this.cache = {
|
|
3466
3554
|
meshes: /* @__PURE__ */ new Map(),
|
|
@@ -3497,15 +3585,15 @@ class ve {
|
|
|
3497
3585
|
const s = this, i = s.buffers, r = s.json;
|
|
3498
3586
|
n = s.options;
|
|
3499
3587
|
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
3500
|
-
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 ?
|
|
3501
|
-
const f =
|
|
3502
|
-
p.setUint32(0, f.byteLength, !0), p.setUint32(4,
|
|
3503
|
-
const y =
|
|
3504
|
-
x.setUint32(0, y.byteLength, !0), x.setUint32(4,
|
|
3505
|
-
const m = new ArrayBuffer(Lt),
|
|
3506
|
-
|
|
3588
|
+
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 ? ot(c).then(function(d) {
|
|
3589
|
+
const f = rt(d), p = new DataView(new ArrayBuffer(Et));
|
|
3590
|
+
p.setUint32(0, f.byteLength, !0), p.setUint32(4, Ie, !0);
|
|
3591
|
+
const y = rt(Pe(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(Et));
|
|
3592
|
+
x.setUint32(0, y.byteLength, !0), x.setUint32(4, be, !0);
|
|
3593
|
+
const m = new ArrayBuffer(Lt), D = new DataView(m);
|
|
3594
|
+
D.setUint32(0, Ae, !0), D.setUint32(4, Te, !0);
|
|
3507
3595
|
const w = Lt + x.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
3508
|
-
|
|
3596
|
+
D.setUint32(8, w, !0);
|
|
3509
3597
|
const g = new Blob([
|
|
3510
3598
|
m,
|
|
3511
3599
|
x,
|
|
@@ -3513,11 +3601,11 @@ class ve {
|
|
|
3513
3601
|
p,
|
|
3514
3602
|
f
|
|
3515
3603
|
], { type: "application/octet-stream" });
|
|
3516
|
-
|
|
3604
|
+
ot(g).then((S) => {
|
|
3517
3605
|
e(S);
|
|
3518
3606
|
});
|
|
3519
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
3520
|
-
r.buffers[0].uri =
|
|
3607
|
+
}) : r.buffers && r.buffers.length > 0 ? He(c).then((d) => {
|
|
3608
|
+
r.buffers[0].uri = d, e(r);
|
|
3521
3609
|
}) : e(r);
|
|
3522
3610
|
}
|
|
3523
3611
|
/**
|
|
@@ -3564,7 +3652,7 @@ class ve {
|
|
|
3564
3652
|
*/
|
|
3565
3653
|
isNormalizedNormalAttribute(t) {
|
|
3566
3654
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
3567
|
-
const n = new
|
|
3655
|
+
const n = new Z();
|
|
3568
3656
|
for (let s = 0, i = t.count; s < i; s++)
|
|
3569
3657
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
3570
3658
|
return !0;
|
|
@@ -3579,7 +3667,7 @@ class ve {
|
|
|
3579
3667
|
createNormalizedNormalAttribute(t) {
|
|
3580
3668
|
const e = this.cache;
|
|
3581
3669
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
3582
|
-
const n = t.clone(), s = new
|
|
3670
|
+
const n = t.clone(), s = new Z();
|
|
3583
3671
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3584
3672
|
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);
|
|
3585
3673
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -3599,13 +3687,13 @@ class ve {
|
|
|
3599
3687
|
async buildMetalRoughTextureAsync(t, e) {
|
|
3600
3688
|
if (t === e) return t;
|
|
3601
3689
|
function n(f) {
|
|
3602
|
-
return f.colorSpace ===
|
|
3690
|
+
return f.colorSpace === Xt ? function(y) {
|
|
3603
3691
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3604
3692
|
} : function(y) {
|
|
3605
3693
|
return y;
|
|
3606
3694
|
};
|
|
3607
3695
|
}
|
|
3608
|
-
t instanceof
|
|
3696
|
+
t instanceof st && (t = await this.decompressTextureAsync(t)), e instanceof st && (e = await this.decompressTextureAsync(e));
|
|
3609
3697
|
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();
|
|
3610
3698
|
a.width = r, a.height = o;
|
|
3611
3699
|
const c = a.getContext("2d", {
|
|
@@ -3626,8 +3714,8 @@ class ve {
|
|
|
3626
3714
|
l.data[y] = f(p[y] / 256) * 256;
|
|
3627
3715
|
}
|
|
3628
3716
|
c.putImageData(l, 0, 0);
|
|
3629
|
-
const
|
|
3630
|
-
return
|
|
3717
|
+
const d = (t || e).clone();
|
|
3718
|
+
return d.source = new jt(a), d.colorSpace = zt, d.channel = (t || e).channel, t && e && t.channel !== e.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
|
|
3631
3719
|
}
|
|
3632
3720
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
3633
3721
|
if (this.textureUtils === null)
|
|
@@ -3675,16 +3763,16 @@ class ve {
|
|
|
3675
3763
|
for (let p = n; p < n + s; p++) {
|
|
3676
3764
|
for (let y = 0; y < t.itemSize; y++) {
|
|
3677
3765
|
let x;
|
|
3678
|
-
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 =
|
|
3766
|
+
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 = at.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;
|
|
3679
3767
|
}
|
|
3680
3768
|
h % a !== 0 && (h += a - h % a);
|
|
3681
3769
|
}
|
|
3682
|
-
const
|
|
3770
|
+
const d = {
|
|
3683
3771
|
buffer: this.processBuffer(l.buffer),
|
|
3684
3772
|
byteOffset: this.byteOffset,
|
|
3685
3773
|
byteLength: c
|
|
3686
3774
|
};
|
|
3687
|
-
return i !== void 0 && (
|
|
3775
|
+
return i !== void 0 && (d.target = i), i === T.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
|
|
3688
3776
|
id: r.bufferViews.length - 1,
|
|
3689
3777
|
byteLength: 0
|
|
3690
3778
|
};
|
|
@@ -3697,8 +3785,8 @@ class ve {
|
|
|
3697
3785
|
processBufferViewImage(t) {
|
|
3698
3786
|
const e = this, n = e.json;
|
|
3699
3787
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3700
|
-
|
|
3701
|
-
const r =
|
|
3788
|
+
ot(t).then((i) => {
|
|
3789
|
+
const r = rt(i), o = {
|
|
3702
3790
|
buffer: e.processBuffer(r),
|
|
3703
3791
|
byteOffset: e.byteOffset,
|
|
3704
3792
|
byteLength: r.byteLength
|
|
@@ -3742,7 +3830,7 @@ class ve {
|
|
|
3742
3830
|
else
|
|
3743
3831
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
3744
3832
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
3745
|
-
const a =
|
|
3833
|
+
const a = ve(t, n, s);
|
|
3746
3834
|
let c;
|
|
3747
3835
|
e !== void 0 && (c = t === e.index ? T.ELEMENT_ARRAY_BUFFER : T.ARRAY_BUFFER);
|
|
3748
3836
|
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
@@ -3771,13 +3859,13 @@ class ve {
|
|
|
3771
3859
|
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
3772
3860
|
if (l[h] !== void 0) return l[h];
|
|
3773
3861
|
o.images || (o.images = []);
|
|
3774
|
-
const
|
|
3862
|
+
const d = { mimeType: s }, f = At();
|
|
3775
3863
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
3776
3864
|
const p = f.getContext("2d", {
|
|
3777
3865
|
willReadFrequently: !0
|
|
3778
3866
|
});
|
|
3779
3867
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
3780
|
-
e !==
|
|
3868
|
+
e !== qt && 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);
|
|
3781
3869
|
const x = new Uint8ClampedArray(t.height * t.width * 4);
|
|
3782
3870
|
for (let m = 0; m < x.length; m += 4)
|
|
3783
3871
|
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];
|
|
@@ -3787,11 +3875,11 @@ class ve {
|
|
|
3787
3875
|
else
|
|
3788
3876
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
3789
3877
|
a.binary === !0 ? c.push(
|
|
3790
|
-
|
|
3791
|
-
|
|
3878
|
+
Ne(f, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3879
|
+
d.bufferView = x;
|
|
3792
3880
|
})
|
|
3793
|
-
) :
|
|
3794
|
-
const y = o.images.push(
|
|
3881
|
+
) : d.uri = _t.getDataURL(f, s);
|
|
3882
|
+
const y = o.images.push(d) - 1;
|
|
3795
3883
|
return l[h] = y, y;
|
|
3796
3884
|
} else
|
|
3797
3885
|
throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
|
|
@@ -3805,10 +3893,10 @@ class ve {
|
|
|
3805
3893
|
const e = this.json;
|
|
3806
3894
|
e.samplers || (e.samplers = []);
|
|
3807
3895
|
const n = {
|
|
3808
|
-
magFilter:
|
|
3809
|
-
minFilter:
|
|
3810
|
-
wrapS:
|
|
3811
|
-
wrapT:
|
|
3896
|
+
magFilter: U[t.magFilter],
|
|
3897
|
+
minFilter: U[t.minFilter],
|
|
3898
|
+
wrapS: U[t.wrapS],
|
|
3899
|
+
wrapT: U[t.wrapT]
|
|
3812
3900
|
};
|
|
3813
3901
|
return e.samplers.push(n) - 1;
|
|
3814
3902
|
}
|
|
@@ -3820,7 +3908,7 @@ class ve {
|
|
|
3820
3908
|
async processTextureAsync(t) {
|
|
3821
3909
|
const n = this.options, s = this.cache, i = this.json;
|
|
3822
3910
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
3823
|
-
i.textures || (i.textures = []), t instanceof
|
|
3911
|
+
i.textures || (i.textures = []), t instanceof st && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
3824
3912
|
let r = t.userData.mimeType;
|
|
3825
3913
|
r === "image/webp" && (r = "image/png");
|
|
3826
3914
|
const o = {
|
|
@@ -3908,7 +3996,7 @@ class ve {
|
|
|
3908
3996
|
const r = t.geometry;
|
|
3909
3997
|
let o;
|
|
3910
3998
|
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;
|
|
3911
|
-
const a = {}, c = {}, l = [], h = [],
|
|
3999
|
+
const a = {}, c = {}, l = [], h = [], d = {
|
|
3912
4000
|
uv: "TEXCOORD_0",
|
|
3913
4001
|
uv1: "TEXCOORD_1",
|
|
3914
4002
|
uv2: "TEXCOORD_2",
|
|
@@ -3922,22 +4010,22 @@ class ve {
|
|
|
3922
4010
|
for (let g in r.attributes) {
|
|
3923
4011
|
if (g.slice(0, 5) === "morph") continue;
|
|
3924
4012
|
const S = r.attributes[g];
|
|
3925
|
-
if (g =
|
|
4013
|
+
if (g = d[g] || g.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g) || (g = "_" + g), e.attributes.has(this.getUID(S))) {
|
|
3926
4014
|
c[g] = e.attributes.get(this.getUID(S));
|
|
3927
4015
|
continue;
|
|
3928
4016
|
}
|
|
3929
4017
|
p = null;
|
|
3930
4018
|
const L = S.array;
|
|
3931
|
-
g === "JOINTS_0" && !(L instanceof Uint16Array) && !(L instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new
|
|
4019
|
+
g === "JOINTS_0" && !(L instanceof Uint16Array) && !(L instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new q(new Uint16Array(L), S.itemSize, S.normalized)) : (L instanceof Uint32Array || L instanceof Int32Array) && !g.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${g}" converted to type FLOAT.`), p = et.Utils.toFloat32BufferAttribute(S));
|
|
3932
4020
|
const b = this.processAccessor(p || S, r);
|
|
3933
4021
|
b !== null && (g.startsWith("_") || this.detectMeshQuantization(g, S), c[g] = b, e.attributes.set(this.getUID(S), b));
|
|
3934
4022
|
}
|
|
3935
4023
|
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
3936
4024
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
3937
|
-
const g = [], S = [],
|
|
4025
|
+
const g = [], S = [], E = {};
|
|
3938
4026
|
if (t.morphTargetDictionary !== void 0)
|
|
3939
4027
|
for (const L in t.morphTargetDictionary)
|
|
3940
|
-
|
|
4028
|
+
E[t.morphTargetDictionary[L]] = L;
|
|
3941
4029
|
for (let L = 0; L < t.morphTargetInfluences.length; ++L) {
|
|
3942
4030
|
const b = {};
|
|
3943
4031
|
let R = !1;
|
|
@@ -3946,7 +4034,7 @@ class ve {
|
|
|
3946
4034
|
R || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), R = !0);
|
|
3947
4035
|
continue;
|
|
3948
4036
|
}
|
|
3949
|
-
const B = r.morphAttributes[P][L], C = P.toUpperCase(),
|
|
4037
|
+
const B = r.morphAttributes[P][L], C = P.toUpperCase(), G = r.attributes[P];
|
|
3950
4038
|
if (e.attributes.has(this.getUID(B, !0))) {
|
|
3951
4039
|
b[C] = e.attributes.get(this.getUID(B, !0));
|
|
3952
4040
|
continue;
|
|
@@ -3954,11 +4042,11 @@ class ve {
|
|
|
3954
4042
|
const O = B.clone();
|
|
3955
4043
|
if (!r.morphTargetsRelative)
|
|
3956
4044
|
for (let v = 0, V = B.count; v < V; v++)
|
|
3957
|
-
for (let
|
|
3958
|
-
|
|
3959
|
-
b[C] = this.processAccessor(O, r), e.attributes.set(this.getUID(
|
|
4045
|
+
for (let j = 0; j < B.itemSize; j++)
|
|
4046
|
+
j === 0 && O.setX(v, B.getX(v) - G.getX(v)), j === 1 && O.setY(v, B.getY(v) - G.getY(v)), j === 2 && O.setZ(v, B.getZ(v) - G.getZ(v)), j === 3 && O.setW(v, B.getW(v) - G.getW(v));
|
|
4047
|
+
b[C] = this.processAccessor(O, r), e.attributes.set(this.getUID(G, !0), b[C]);
|
|
3960
4048
|
}
|
|
3961
|
-
h.push(b), g.push(t.morphTargetInfluences[L]), t.morphTargetDictionary !== void 0 && S.push(
|
|
4049
|
+
h.push(b), g.push(t.morphTargetInfluences[L]), t.morphTargetDictionary !== void 0 && S.push(E[L]);
|
|
3962
4050
|
}
|
|
3963
4051
|
a.weights = g, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
3964
4052
|
}
|
|
@@ -3967,22 +4055,22 @@ class ve {
|
|
|
3967
4055
|
let x = !1;
|
|
3968
4056
|
if (y && r.index === null) {
|
|
3969
4057
|
const g = [];
|
|
3970
|
-
for (let S = 0,
|
|
4058
|
+
for (let S = 0, E = r.attributes.position.count; S < E; S++)
|
|
3971
4059
|
g[S] = S;
|
|
3972
4060
|
r.setIndex(g), x = !0;
|
|
3973
4061
|
}
|
|
3974
|
-
const m = y ? t.material : [t.material],
|
|
3975
|
-
for (let g = 0, S =
|
|
3976
|
-
const
|
|
4062
|
+
const m = y ? t.material : [t.material], D = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
4063
|
+
for (let g = 0, S = D.length; g < S; g++) {
|
|
4064
|
+
const E = {
|
|
3977
4065
|
mode: o,
|
|
3978
4066
|
attributes: c
|
|
3979
4067
|
};
|
|
3980
|
-
if (this.serializeUserData(r,
|
|
4068
|
+
if (this.serializeUserData(r, E), h.length > 0 && (E.targets = h), r.index !== null) {
|
|
3981
4069
|
let b = this.getUID(r.index);
|
|
3982
|
-
(
|
|
4070
|
+
(D[g].start !== void 0 || D[g].count !== void 0) && (b += ":" + D[g].start + ":" + D[g].count), e.attributes.has(b) ? E.indices = e.attributes.get(b) : (E.indices = this.processAccessor(r.index, r, D[g].start, D[g].count), e.attributes.set(b, E.indices)), E.indices === null && delete E.indices;
|
|
3983
4071
|
}
|
|
3984
|
-
const L = await this.processMaterialAsync(m[
|
|
3985
|
-
L !== null && (
|
|
4072
|
+
const L = await this.processMaterialAsync(m[D[g].materialIndex]);
|
|
4073
|
+
L !== null && (E.material = L), l.push(E);
|
|
3986
4074
|
}
|
|
3987
4075
|
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(g) {
|
|
3988
4076
|
g.writeMesh && g.writeMesh(t, a);
|
|
@@ -4002,7 +4090,7 @@ class ve {
|
|
|
4002
4090
|
* @param {THREE.BufferAttribute} attribute
|
|
4003
4091
|
*/
|
|
4004
4092
|
detectMeshQuantization(t, e) {
|
|
4005
|
-
if (this.extensionsUsed[
|
|
4093
|
+
if (this.extensionsUsed[it]) return;
|
|
4006
4094
|
let n;
|
|
4007
4095
|
switch (e.array.constructor) {
|
|
4008
4096
|
case Int8Array:
|
|
@@ -4022,7 +4110,7 @@ class ve {
|
|
|
4022
4110
|
}
|
|
4023
4111
|
e.normalized && (n += " normalized");
|
|
4024
4112
|
const s = t.split("_", 1)[0];
|
|
4025
|
-
St[s] && St[s].includes(n) && (this.extensionsUsed[
|
|
4113
|
+
St[s] && St[s].includes(n) && (this.extensionsUsed[it] = !0, this.extensionsRequired[it] = !0);
|
|
4026
4114
|
}
|
|
4027
4115
|
/**
|
|
4028
4116
|
* Process camera
|
|
@@ -4042,7 +4130,7 @@ class ve {
|
|
|
4042
4130
|
znear: t.near < 0 ? 0 : t.near
|
|
4043
4131
|
} : s.perspective = {
|
|
4044
4132
|
aspectRatio: t.aspect,
|
|
4045
|
-
yfov:
|
|
4133
|
+
yfov: at.degToRad(t.fov),
|
|
4046
4134
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4047
4135
|
znear: t.near < 0 ? 0 : t.near
|
|
4048
4136
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4059,28 +4147,28 @@ class ve {
|
|
|
4059
4147
|
*/
|
|
4060
4148
|
processAnimation(t, e) {
|
|
4061
4149
|
const n = this.json, s = this.nodeMap;
|
|
4062
|
-
n.animations || (n.animations = []), t =
|
|
4150
|
+
n.animations || (n.animations = []), t = et.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4063
4151
|
const i = t.tracks, r = [], o = [];
|
|
4064
4152
|
for (let c = 0; c < i.length; ++c) {
|
|
4065
|
-
const l = i[c], h =
|
|
4066
|
-
let
|
|
4067
|
-
const f =
|
|
4068
|
-
if (h.objectName === "bones" && (
|
|
4153
|
+
const l = i[c], h = Q.parseTrackName(l.name);
|
|
4154
|
+
let d = Q.findNode(e, h.nodeName);
|
|
4155
|
+
const f = Dt[h.propertyName];
|
|
4156
|
+
if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !f) {
|
|
4069
4157
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4070
4158
|
continue;
|
|
4071
4159
|
}
|
|
4072
4160
|
const p = 1;
|
|
4073
4161
|
let y = l.values.length / l.times.length;
|
|
4074
|
-
f ===
|
|
4162
|
+
f === Dt.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
|
|
4075
4163
|
let x;
|
|
4076
4164
|
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() === kt ? x = "STEP" : x = "LINEAR", o.push({
|
|
4077
|
-
input: this.processAccessor(new
|
|
4078
|
-
output: this.processAccessor(new
|
|
4165
|
+
input: this.processAccessor(new q(l.times, p)),
|
|
4166
|
+
output: this.processAccessor(new q(l.values, y)),
|
|
4079
4167
|
interpolation: x
|
|
4080
4168
|
}), r.push({
|
|
4081
4169
|
sampler: o.length - 1,
|
|
4082
4170
|
target: {
|
|
4083
|
-
node: s.get(
|
|
4171
|
+
node: s.get(d),
|
|
4084
4172
|
path: f
|
|
4085
4173
|
}
|
|
4086
4174
|
});
|
|
@@ -4105,7 +4193,7 @@ class ve {
|
|
|
4105
4193
|
for (let h = 0; h < i.bones.length; ++h)
|
|
4106
4194
|
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4107
4195
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
4108
|
-
inverseBindMatrices: this.processAccessor(new
|
|
4196
|
+
inverseBindMatrices: this.processAccessor(new q(a, 16)),
|
|
4109
4197
|
joints: o,
|
|
4110
4198
|
skeleton: n.get(r)
|
|
4111
4199
|
}), s.skin = e.skins.length - 1;
|
|
@@ -4123,7 +4211,7 @@ class ve {
|
|
|
4123
4211
|
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4124
4212
|
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);
|
|
4125
4213
|
} else
|
|
4126
|
-
t.matrixAutoUpdate && t.updateMatrix(),
|
|
4214
|
+
t.matrixAutoUpdate && t.updateMatrix(), Re(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4127
4215
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
4128
4216
|
const o = await this.processMeshAsync(t);
|
|
4129
4217
|
o !== null && (i.mesh = o);
|
|
@@ -4200,7 +4288,7 @@ class ve {
|
|
|
4200
4288
|
await t(this.plugins[e]);
|
|
4201
4289
|
}
|
|
4202
4290
|
}
|
|
4203
|
-
class
|
|
4291
|
+
class Be {
|
|
4204
4292
|
constructor(t) {
|
|
4205
4293
|
this.writer = t, this.name = "KHR_lights_punctual";
|
|
4206
4294
|
}
|
|
@@ -4216,7 +4304,7 @@ class Ne {
|
|
|
4216
4304
|
o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
|
|
4217
4305
|
}
|
|
4218
4306
|
}
|
|
4219
|
-
class
|
|
4307
|
+
class Oe {
|
|
4220
4308
|
constructor(t) {
|
|
4221
4309
|
this.writer = t, this.name = "KHR_materials_unlit";
|
|
4222
4310
|
}
|
|
@@ -4226,7 +4314,7 @@ class Ce {
|
|
|
4226
4314
|
e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
4227
4315
|
}
|
|
4228
4316
|
}
|
|
4229
|
-
class
|
|
4317
|
+
class Fe {
|
|
4230
4318
|
constructor(t) {
|
|
4231
4319
|
this.writer = t, this.name = "KHR_materials_clearcoat";
|
|
4232
4320
|
}
|
|
@@ -4257,7 +4345,7 @@ class Be {
|
|
|
4257
4345
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4258
4346
|
}
|
|
4259
4347
|
}
|
|
4260
|
-
class
|
|
4348
|
+
class Ue {
|
|
4261
4349
|
constructor(t) {
|
|
4262
4350
|
this.writer = t, this.name = "KHR_materials_dispersion";
|
|
4263
4351
|
}
|
|
@@ -4267,7 +4355,7 @@ class Oe {
|
|
|
4267
4355
|
i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4268
4356
|
}
|
|
4269
4357
|
}
|
|
4270
|
-
class
|
|
4358
|
+
class Ge {
|
|
4271
4359
|
constructor(t) {
|
|
4272
4360
|
this.writer = t, this.name = "KHR_materials_iridescence";
|
|
4273
4361
|
}
|
|
@@ -4291,7 +4379,7 @@ class Fe {
|
|
|
4291
4379
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4292
4380
|
}
|
|
4293
4381
|
}
|
|
4294
|
-
class
|
|
4382
|
+
class je {
|
|
4295
4383
|
constructor(t) {
|
|
4296
4384
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4297
4385
|
}
|
|
@@ -4308,7 +4396,7 @@ class Ge {
|
|
|
4308
4396
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4309
4397
|
}
|
|
4310
4398
|
}
|
|
4311
|
-
class
|
|
4399
|
+
class ze {
|
|
4312
4400
|
constructor(t) {
|
|
4313
4401
|
this.writer = t, this.name = "KHR_materials_volume";
|
|
4314
4402
|
}
|
|
@@ -4325,7 +4413,7 @@ class Ue {
|
|
|
4325
4413
|
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;
|
|
4326
4414
|
}
|
|
4327
4415
|
}
|
|
4328
|
-
class
|
|
4416
|
+
class qe {
|
|
4329
4417
|
constructor(t) {
|
|
4330
4418
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
4331
4419
|
}
|
|
@@ -4335,7 +4423,7 @@ class ze {
|
|
|
4335
4423
|
i.ior = t.ior, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4336
4424
|
}
|
|
4337
4425
|
}
|
|
4338
|
-
class
|
|
4426
|
+
class _e {
|
|
4339
4427
|
constructor(t) {
|
|
4340
4428
|
this.writer = t, this.name = "KHR_materials_specular";
|
|
4341
4429
|
}
|
|
@@ -4359,7 +4447,7 @@ class je {
|
|
|
4359
4447
|
i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4360
4448
|
}
|
|
4361
4449
|
}
|
|
4362
|
-
class
|
|
4450
|
+
class Ye {
|
|
4363
4451
|
constructor(t) {
|
|
4364
4452
|
this.writer = t, this.name = "KHR_materials_sheen";
|
|
4365
4453
|
}
|
|
@@ -4383,7 +4471,7 @@ class _e {
|
|
|
4383
4471
|
i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4384
4472
|
}
|
|
4385
4473
|
}
|
|
4386
|
-
class
|
|
4474
|
+
class ke {
|
|
4387
4475
|
constructor(t) {
|
|
4388
4476
|
this.writer = t, this.name = "KHR_materials_anisotropy";
|
|
4389
4477
|
}
|
|
@@ -4397,7 +4485,7 @@ class qe {
|
|
|
4397
4485
|
i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4398
4486
|
}
|
|
4399
4487
|
}
|
|
4400
|
-
class
|
|
4488
|
+
class Xe {
|
|
4401
4489
|
constructor(t) {
|
|
4402
4490
|
this.writer = t, this.name = "KHR_materials_emissive_strength";
|
|
4403
4491
|
}
|
|
@@ -4407,7 +4495,7 @@ class Ye {
|
|
|
4407
4495
|
i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4408
4496
|
}
|
|
4409
4497
|
}
|
|
4410
|
-
class
|
|
4498
|
+
class Ve {
|
|
4411
4499
|
constructor(t) {
|
|
4412
4500
|
this.writer = t, this.name = "EXT_materials_bump";
|
|
4413
4501
|
}
|
|
@@ -4424,54 +4512,54 @@ class ke {
|
|
|
4424
4512
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4425
4513
|
}
|
|
4426
4514
|
}
|
|
4427
|
-
class
|
|
4515
|
+
class We {
|
|
4428
4516
|
constructor(t) {
|
|
4429
4517
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
4430
4518
|
}
|
|
4431
4519
|
writeNode(t, e) {
|
|
4432
4520
|
if (!t.isInstancedMesh) return;
|
|
4433
|
-
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
|
|
4521
|
+
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 Z(), l = new Ut(), h = new Z();
|
|
4434
4522
|
for (let f = 0; f < s.count; f++)
|
|
4435
4523
|
s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
|
|
4436
|
-
const
|
|
4437
|
-
TRANSLATION: n.processAccessor(new
|
|
4438
|
-
ROTATION: n.processAccessor(new
|
|
4439
|
-
SCALE: n.processAccessor(new
|
|
4524
|
+
const d = {
|
|
4525
|
+
TRANSLATION: n.processAccessor(new q(i, 3)),
|
|
4526
|
+
ROTATION: n.processAccessor(new q(r, 4)),
|
|
4527
|
+
SCALE: n.processAccessor(new q(o, 3))
|
|
4440
4528
|
};
|
|
4441
|
-
s.instanceColor && (
|
|
4529
|
+
s.instanceColor && (d._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: d }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
|
|
4442
4530
|
}
|
|
4443
4531
|
}
|
|
4444
|
-
|
|
4445
|
-
insertKeyframe: function(
|
|
4446
|
-
const n =
|
|
4532
|
+
et.Utils = {
|
|
4533
|
+
insertKeyframe: function(u, t) {
|
|
4534
|
+
const n = u.getValueSize(), s = new u.TimeBufferType(u.times.length + 1), i = new u.ValueBufferType(u.values.length + n), r = u.createInterpolant(new u.ValueBufferType(n));
|
|
4447
4535
|
let o;
|
|
4448
|
-
if (
|
|
4536
|
+
if (u.times.length === 0) {
|
|
4449
4537
|
s[0] = t;
|
|
4450
4538
|
for (let a = 0; a < n; a++)
|
|
4451
4539
|
i[a] = 0;
|
|
4452
4540
|
o = 0;
|
|
4453
|
-
} else if (t <
|
|
4454
|
-
if (Math.abs(
|
|
4455
|
-
s[0] = t, s.set(
|
|
4456
|
-
} else if (t >
|
|
4457
|
-
if (Math.abs(
|
|
4458
|
-
return
|
|
4459
|
-
s[s.length - 1] = t, s.set(
|
|
4541
|
+
} else if (t < u.times[0]) {
|
|
4542
|
+
if (Math.abs(u.times[0] - t) < 1e-3) return 0;
|
|
4543
|
+
s[0] = t, s.set(u.times, 1), i.set(r.evaluate(t), 0), i.set(u.values, n), o = 0;
|
|
4544
|
+
} else if (t > u.times[u.times.length - 1]) {
|
|
4545
|
+
if (Math.abs(u.times[u.times.length - 1] - t) < 1e-3)
|
|
4546
|
+
return u.times.length - 1;
|
|
4547
|
+
s[s.length - 1] = t, s.set(u.times, 0), i.set(u.values, 0), i.set(r.evaluate(t), u.values.length), o = s.length - 1;
|
|
4460
4548
|
} else
|
|
4461
|
-
for (let a = 0; a <
|
|
4462
|
-
if (Math.abs(
|
|
4463
|
-
if (
|
|
4464
|
-
s.set(
|
|
4549
|
+
for (let a = 0; a < u.times.length; a++) {
|
|
4550
|
+
if (Math.abs(u.times[a] - t) < 1e-3) return a;
|
|
4551
|
+
if (u.times[a] < t && u.times[a + 1] > t) {
|
|
4552
|
+
s.set(u.times.slice(0, a + 1), 0), s[a + 1] = t, s.set(u.times.slice(a + 1), a + 2), i.set(u.values.slice(0, (a + 1) * n), 0), i.set(r.evaluate(t), (a + 1) * n), i.set(u.values.slice((a + 1) * n), (a + 2) * n), o = a + 1;
|
|
4465
4553
|
break;
|
|
4466
4554
|
}
|
|
4467
4555
|
}
|
|
4468
|
-
return
|
|
4556
|
+
return u.times = s, u.values = i, o;
|
|
4469
4557
|
},
|
|
4470
|
-
mergeMorphTargetTracks: function(
|
|
4471
|
-
const e = [], n = {}, s =
|
|
4558
|
+
mergeMorphTargetTracks: function(u, t) {
|
|
4559
|
+
const e = [], n = {}, s = u.tracks;
|
|
4472
4560
|
for (let i = 0; i < s.length; ++i) {
|
|
4473
4561
|
let r = s[i];
|
|
4474
|
-
const o =
|
|
4562
|
+
const o = Q.parseTrackName(r.name), a = Q.findNode(t, o.nodeName);
|
|
4475
4563
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
4476
4564
|
e.push(r);
|
|
4477
4565
|
continue;
|
|
@@ -4493,67 +4581,67 @@ tt.Utils = {
|
|
|
4493
4581
|
h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = f, n[a.uuid] = h, e.push(h);
|
|
4494
4582
|
continue;
|
|
4495
4583
|
}
|
|
4496
|
-
const
|
|
4584
|
+
const d = r.createInterpolant(new r.ValueBufferType(1));
|
|
4497
4585
|
h = n[a.uuid];
|
|
4498
4586
|
for (let f = 0; f < h.times.length; f++)
|
|
4499
|
-
h.values[f * c + l] =
|
|
4587
|
+
h.values[f * c + l] = d.evaluate(h.times[f]);
|
|
4500
4588
|
for (let f = 0; f < r.times.length; f++) {
|
|
4501
4589
|
const p = this.insertKeyframe(h, r.times[f]);
|
|
4502
4590
|
h.values[p * c + l] = r.values[f];
|
|
4503
4591
|
}
|
|
4504
4592
|
}
|
|
4505
|
-
return
|
|
4593
|
+
return u.tracks = e, u;
|
|
4506
4594
|
},
|
|
4507
|
-
toFloat32BufferAttribute: function(
|
|
4508
|
-
const t = new
|
|
4509
|
-
if (!
|
|
4510
|
-
return t.array.set(
|
|
4511
|
-
for (let e = 0, n =
|
|
4512
|
-
for (let s = 0; s <
|
|
4513
|
-
t.setComponent(e, s,
|
|
4595
|
+
toFloat32BufferAttribute: function(u) {
|
|
4596
|
+
const t = new q(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
|
|
4597
|
+
if (!u.normalized && !u.isInterleavedBufferAttribute)
|
|
4598
|
+
return t.array.set(u.array), t;
|
|
4599
|
+
for (let e = 0, n = u.count; e < n; e++)
|
|
4600
|
+
for (let s = 0; s < u.itemSize; s++)
|
|
4601
|
+
t.setComponent(e, s, u.getComponent(e, s));
|
|
4514
4602
|
return t;
|
|
4515
4603
|
}
|
|
4516
4604
|
};
|
|
4517
|
-
async function
|
|
4605
|
+
async function He(u) {
|
|
4518
4606
|
if (typeof FileReader > "u") {
|
|
4519
|
-
const t = await
|
|
4520
|
-
return `data:${
|
|
4607
|
+
const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
|
|
4608
|
+
return `data:${u.type};base64,${n}`;
|
|
4521
4609
|
} else
|
|
4522
4610
|
return new Promise((t, e) => {
|
|
4523
4611
|
const n = new FileReader();
|
|
4524
|
-
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(
|
|
4612
|
+
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(u);
|
|
4525
4613
|
});
|
|
4526
4614
|
}
|
|
4527
|
-
async function
|
|
4528
|
-
if (typeof
|
|
4529
|
-
return await
|
|
4615
|
+
async function ot(u) {
|
|
4616
|
+
if (typeof u.arrayBuffer == "function")
|
|
4617
|
+
return await u.arrayBuffer();
|
|
4530
4618
|
if (typeof FileReader < "u")
|
|
4531
4619
|
return new Promise((t, e) => {
|
|
4532
4620
|
const n = new FileReader();
|
|
4533
|
-
n.onload = () => t(n.result), n.onerror = () => e(n.error), n.readAsArrayBuffer(
|
|
4621
|
+
n.onload = () => t(n.result), n.onerror = () => e(n.error), n.readAsArrayBuffer(u);
|
|
4534
4622
|
});
|
|
4535
4623
|
{
|
|
4536
|
-
const t = Buffer.from(await
|
|
4624
|
+
const t = Buffer.from(await u.text());
|
|
4537
4625
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4538
4626
|
}
|
|
4539
4627
|
}
|
|
4540
|
-
const
|
|
4541
|
-
function
|
|
4542
|
-
const n = t.normal(
|
|
4628
|
+
const Je = new ne(), $e = new et();
|
|
4629
|
+
function Ke(u, t, e = 0.1) {
|
|
4630
|
+
const n = t.normal(u), s = t.direction(u).mutiplyScalar(e * 0.5), i = u.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
|
|
4543
4631
|
return {
|
|
4544
4632
|
points: [
|
|
4545
4633
|
// 第一条线
|
|
4546
|
-
new M(
|
|
4634
|
+
new M(u.x + r, u.y + o).add(i),
|
|
4547
4635
|
new M(t.x + r, t.y + o).add(s),
|
|
4548
4636
|
// 第二条线
|
|
4549
|
-
new M(
|
|
4637
|
+
new M(u.x - r, u.y - o).add(i),
|
|
4550
4638
|
new M(t.x - r, t.y - o).add(s)
|
|
4551
4639
|
],
|
|
4552
4640
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
4553
4641
|
rectIndices: [0, 1, 3, 2, 0]
|
|
4554
4642
|
};
|
|
4555
4643
|
}
|
|
4556
|
-
class Nt extends
|
|
4644
|
+
class Nt extends _ {
|
|
4557
4645
|
static name = "WhiteModel";
|
|
4558
4646
|
Dxf = null;
|
|
4559
4647
|
Variable = null;
|
|
@@ -4583,7 +4671,7 @@ class Nt extends q {
|
|
|
4583
4671
|
new I.LineSegments(new I.EdgesGeometry(i), new I.LineBasicMaterial({ color: 0 }))
|
|
4584
4672
|
);
|
|
4585
4673
|
}), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
4586
|
-
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } =
|
|
4674
|
+
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = Ke(r, o, t.width);
|
|
4587
4675
|
return {
|
|
4588
4676
|
points: a,
|
|
4589
4677
|
indices: c,
|
|
@@ -4616,7 +4704,7 @@ class Nt extends q {
|
|
|
4616
4704
|
toOBJ() {
|
|
4617
4705
|
return new Promise((t) => {
|
|
4618
4706
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
4619
|
-
t(
|
|
4707
|
+
t(Je.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4620
4708
|
}, 20);
|
|
4621
4709
|
});
|
|
4622
4710
|
}
|
|
@@ -4628,7 +4716,7 @@ class Nt extends q {
|
|
|
4628
4716
|
toGltf(t = !0) {
|
|
4629
4717
|
return new Promise((e) => {
|
|
4630
4718
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
4631
|
-
|
|
4719
|
+
$e.parse(this.whiteModelGroup.children, (n) => {
|
|
4632
4720
|
e(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4633
4721
|
}, () => {
|
|
4634
4722
|
e(void 0);
|
|
@@ -4689,7 +4777,7 @@ class Nt extends q {
|
|
|
4689
4777
|
}
|
|
4690
4778
|
}
|
|
4691
4779
|
}
|
|
4692
|
-
class Ct extends
|
|
4780
|
+
class Ct extends _ {
|
|
4693
4781
|
static name = "DetailsPoint";
|
|
4694
4782
|
Dxf = null;
|
|
4695
4783
|
WhiteModel = null;
|
|
@@ -4766,7 +4854,7 @@ class Ct extends q {
|
|
|
4766
4854
|
}, 50);
|
|
4767
4855
|
}
|
|
4768
4856
|
}
|
|
4769
|
-
class Bt extends
|
|
4857
|
+
class Bt extends _ {
|
|
4770
4858
|
static name = "DxfLineModel";
|
|
4771
4859
|
dxfLineModel = new I.LineSegments();
|
|
4772
4860
|
dxfDoorsLineModel = new I.LineSegments();
|
|
@@ -4789,38 +4877,38 @@ class Bt extends q {
|
|
|
4789
4877
|
});
|
|
4790
4878
|
}
|
|
4791
4879
|
}
|
|
4792
|
-
const
|
|
4880
|
+
const Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4793
4881
|
__proto__: null,
|
|
4794
4882
|
DetailsPoint: Ct,
|
|
4795
4883
|
DxfLineModel: Bt,
|
|
4796
4884
|
WhiteModel: Nt
|
|
4797
4885
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4798
|
-
function Tt(
|
|
4886
|
+
function Tt(u, t = {}) {
|
|
4799
4887
|
const {
|
|
4800
4888
|
detailsPoint: e = !0,
|
|
4801
4889
|
whiteModel: n = !0,
|
|
4802
4890
|
dxfLineModel: s = !0
|
|
4803
4891
|
} = t;
|
|
4804
|
-
s &&
|
|
4892
|
+
s && u.addComponent(new Bt()), n && u.addComponent(new Nt()), e && u.addComponent(new Ct());
|
|
4805
4893
|
}
|
|
4806
|
-
const
|
|
4807
|
-
create(
|
|
4808
|
-
return (t) => Tt(t,
|
|
4894
|
+
const Qe = Object.assign(Tt, {
|
|
4895
|
+
create(u = {}) {
|
|
4896
|
+
return (t) => Tt(t, u);
|
|
4809
4897
|
}
|
|
4810
|
-
}),
|
|
4898
|
+
}), tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4811
4899
|
__proto__: null,
|
|
4812
|
-
ModelDataPlugin:
|
|
4813
|
-
components:
|
|
4900
|
+
ModelDataPlugin: Qe,
|
|
4901
|
+
components: Ze
|
|
4814
4902
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4815
|
-
function
|
|
4903
|
+
function en() {
|
|
4816
4904
|
return import("./index2.js");
|
|
4817
4905
|
}
|
|
4818
|
-
function
|
|
4906
|
+
function nn() {
|
|
4819
4907
|
return import("./index3.js");
|
|
4820
4908
|
}
|
|
4821
4909
|
let dt = null;
|
|
4822
|
-
async function
|
|
4823
|
-
const s = await Promise.resolve().then(() =>
|
|
4910
|
+
async function hn(u, t, e = !1, n) {
|
|
4911
|
+
const s = await Promise.resolve().then(() => tn), i = await en(), r = await nn(), o = new ht().usePlugin(s.ModelDataPlugin.create({
|
|
4824
4912
|
detailsPoint: !1,
|
|
4825
4913
|
whiteModel: !0
|
|
4826
4914
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4830,13 +4918,13 @@ async function cn(d, t, e = !1, n) {
|
|
|
4830
4918
|
orbitControls: e,
|
|
4831
4919
|
camera: t
|
|
4832
4920
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4833
|
-
return a &&
|
|
4921
|
+
return a && u.appendChild(a.domElement), dt = o, {
|
|
4834
4922
|
dxfSystem: o,
|
|
4835
|
-
getFileAll: () =>
|
|
4923
|
+
getFileAll: () => sn(o)
|
|
4836
4924
|
};
|
|
4837
4925
|
}
|
|
4838
|
-
async function
|
|
4839
|
-
const t =
|
|
4926
|
+
async function sn(u = dt) {
|
|
4927
|
+
const t = u.findComponentByName("WhiteModel"), e = new File([await u.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([u.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([u.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(u.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
4840
4928
|
return {
|
|
4841
4929
|
dxf: n,
|
|
4842
4930
|
obj: i,
|
|
@@ -4847,30 +4935,31 @@ async function en(d = dt) {
|
|
|
4847
4935
|
correctionDxf: s
|
|
4848
4936
|
};
|
|
4849
4937
|
}
|
|
4850
|
-
function
|
|
4938
|
+
function un() {
|
|
4851
4939
|
return dt;
|
|
4852
4940
|
}
|
|
4853
4941
|
export {
|
|
4854
4942
|
Pt as A,
|
|
4855
4943
|
N as B,
|
|
4856
|
-
|
|
4944
|
+
_ as C,
|
|
4857
4945
|
ht as D,
|
|
4858
4946
|
It as E,
|
|
4859
4947
|
A as L,
|
|
4860
|
-
|
|
4948
|
+
Qe as M,
|
|
4861
4949
|
M as P,
|
|
4862
4950
|
F as Q,
|
|
4863
|
-
|
|
4951
|
+
Le as T,
|
|
4864
4952
|
Rt as V,
|
|
4865
4953
|
Nt as W,
|
|
4866
4954
|
Ct as a,
|
|
4867
4955
|
X as b,
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4956
|
+
De as c,
|
|
4957
|
+
hn as d,
|
|
4958
|
+
un as e,
|
|
4959
|
+
k as f,
|
|
4960
|
+
sn as g,
|
|
4961
|
+
ln as h,
|
|
4962
|
+
Ze as i,
|
|
4963
|
+
tt as r,
|
|
4964
|
+
K as u
|
|
4876
4965
|
};
|