build-dxf 0.0.41 → 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 +1 -1
- package/package.json +1 -1
- package/src/build.js +617 -558
- package/src/index.js +1 -1
- package/src/index3.js +293 -286
- package/src/utils/DxfSystem/components/LineAnalysis.d.ts +14 -1
- 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
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 J(
|
|
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 J(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
|
-
|
|
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,37 +1960,37 @@ 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
|
-
function
|
|
1990
|
+
function me(u) {
|
|
1950
1991
|
let t = [], e = -1;
|
|
1951
1992
|
const n = [];
|
|
1952
|
-
return
|
|
1993
|
+
return u.forEach(({ start: i, end: r, ...o }, a) => {
|
|
1953
1994
|
n.push(i.z ?? 0, r.z ?? 0);
|
|
1954
1995
|
const c = new A(
|
|
1955
1996
|
M.from(i),
|
|
@@ -1962,7 +2003,7 @@ function ge(d) {
|
|
|
1962
2003
|
verticalReferenceIndex: e
|
|
1963
2004
|
};
|
|
1964
2005
|
}
|
|
1965
|
-
const
|
|
2006
|
+
const we = {
|
|
1966
2007
|
Unitless: 1,
|
|
1967
2008
|
// 无单位,1米 = 1(无单位)
|
|
1968
2009
|
Inches: 39.37007874015748,
|
|
@@ -2006,19 +2047,19 @@ const me = {
|
|
|
2006
2047
|
Parsecs: 3240779289666404e-32
|
|
2007
2048
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
2008
2049
|
};
|
|
2009
|
-
function wt(
|
|
2050
|
+
function wt(u) {
|
|
2010
2051
|
const t = [];
|
|
2011
|
-
for (let e = 0; e <
|
|
2052
|
+
for (let e = 0; e < u.length; e++)
|
|
2012
2053
|
t.push(new A(
|
|
2013
|
-
|
|
2014
|
-
|
|
2054
|
+
u[e].clone(),
|
|
2055
|
+
u[(e + 1) % u.length].clone()
|
|
2015
2056
|
));
|
|
2016
2057
|
return t;
|
|
2017
2058
|
}
|
|
2018
|
-
function Mt(
|
|
2019
|
-
return
|
|
2059
|
+
function Mt(u) {
|
|
2060
|
+
return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
|
|
2020
2061
|
}
|
|
2021
|
-
class k extends
|
|
2062
|
+
class k extends _ {
|
|
2022
2063
|
static name = "Dxf";
|
|
2023
2064
|
shortLine = 0.04;
|
|
2024
2065
|
width = 0.04;
|
|
@@ -2063,9 +2104,9 @@ class k extends q {
|
|
|
2063
2104
|
* @param data
|
|
2064
2105
|
*/
|
|
2065
2106
|
preprocessing(t) {
|
|
2066
|
-
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } =
|
|
2107
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = me(t);
|
|
2067
2108
|
if (this.originalZAverage = s, n === -1) {
|
|
2068
|
-
const r =
|
|
2109
|
+
const r = ge(e);
|
|
2069
2110
|
n = e.indexOf(r);
|
|
2070
2111
|
}
|
|
2071
2112
|
const i = e[n];
|
|
@@ -2098,7 +2139,7 @@ class k extends q {
|
|
|
2098
2139
|
return this.set(a, e, n);
|
|
2099
2140
|
} else
|
|
2100
2141
|
throw new Error("非node环境不允许使用路径");
|
|
2101
|
-
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)
|
|
2102
2143
|
this.lineSegments = [], this.originalData = t;
|
|
2103
2144
|
else {
|
|
2104
2145
|
const i = this.preprocessing(t);
|
|
@@ -2131,8 +2172,8 @@ class k extends q {
|
|
|
2131
2172
|
createGroups() {
|
|
2132
2173
|
const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
|
|
2133
2174
|
if (!this.data[r]) return;
|
|
2134
|
-
const [c, l, h,
|
|
2135
|
-
if (e.add(r),
|
|
2175
|
+
const [c, l, h, d] = this.data[r];
|
|
2176
|
+
if (e.add(r), d)
|
|
2136
2177
|
return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
|
|
2137
2178
|
o.push([c, l]), h.forEach((f) => {
|
|
2138
2179
|
e.has(f) || i(f, o, r);
|
|
@@ -2258,9 +2299,9 @@ class k extends q {
|
|
|
2258
2299
|
continue;
|
|
2259
2300
|
}
|
|
2260
2301
|
let l = n[++r];
|
|
2261
|
-
const h = s[s.length - 1],
|
|
2302
|
+
const h = s[s.length - 1], d = h.direction();
|
|
2262
2303
|
for (; r < n.length; ) {
|
|
2263
|
-
const p =
|
|
2304
|
+
const p = d.angleBetween(l.direction()) / i;
|
|
2264
2305
|
if (l.length() <= e || p < 4 || p > 176)
|
|
2265
2306
|
l = n[++r];
|
|
2266
2307
|
else break;
|
|
@@ -2353,7 +2394,7 @@ class k extends q {
|
|
|
2353
2394
|
* 转为绘制数据
|
|
2354
2395
|
*/
|
|
2355
2396
|
toDrawDataJson(t = "Millimeters") {
|
|
2356
|
-
const e =
|
|
2397
|
+
const e = we[t], n = {
|
|
2357
2398
|
unit: t,
|
|
2358
2399
|
line: [],
|
|
2359
2400
|
arc: [],
|
|
@@ -2367,13 +2408,13 @@ class k extends q {
|
|
|
2367
2408
|
function i(c, l) {
|
|
2368
2409
|
n.line.push([c.x * e, c.y * e, l.x * e, l.y * e, s]);
|
|
2369
2410
|
}
|
|
2370
|
-
function r(c, l, h,
|
|
2411
|
+
function r(c, l, h, d) {
|
|
2371
2412
|
n.arc.push([
|
|
2372
2413
|
c.x * e,
|
|
2373
2414
|
c.y * e,
|
|
2374
2415
|
l * e,
|
|
2375
2416
|
h,
|
|
2376
|
-
|
|
2417
|
+
d,
|
|
2377
2418
|
s
|
|
2378
2419
|
]);
|
|
2379
2420
|
}
|
|
@@ -2386,7 +2427,7 @@ class k extends q {
|
|
|
2386
2427
|
}
|
|
2387
2428
|
this.wallsGroup.forEach((c) => {
|
|
2388
2429
|
for (let l = 0; l < c.length; l++) {
|
|
2389
|
-
const h = c[l],
|
|
2430
|
+
const h = c[l], d = l === c.length - 1 ? 0 : l + 1, f = c[d];
|
|
2390
2431
|
i(h, f);
|
|
2391
2432
|
}
|
|
2392
2433
|
});
|
|
@@ -2397,29 +2438,29 @@ class k extends q {
|
|
|
2397
2438
|
if (s = "cyan", l.length() < 1.2) {
|
|
2398
2439
|
l.expansion(-o * 0.5);
|
|
2399
2440
|
const h = c.normal();
|
|
2400
|
-
let
|
|
2441
|
+
let d = new A(
|
|
2401
2442
|
l.start.clone(),
|
|
2402
2443
|
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2403
2444
|
);
|
|
2404
|
-
const f =
|
|
2445
|
+
const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
2405
2446
|
for (let g = 0; g < a.length; g++)
|
|
2406
2447
|
if (a[g].intersectRectangle(f)) {
|
|
2407
|
-
|
|
2448
|
+
d = new A(
|
|
2408
2449
|
l.start.clone(),
|
|
2409
2450
|
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2410
2451
|
);
|
|
2411
2452
|
break;
|
|
2412
2453
|
}
|
|
2413
|
-
|
|
2414
|
-
const p = l.length(), y =
|
|
2415
|
-
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);
|
|
2416
2457
|
} else
|
|
2417
|
-
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));
|
|
2418
2459
|
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
2419
2460
|
if (!c.userData.isWindow) return !1;
|
|
2420
2461
|
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
2421
|
-
const { p: h, width:
|
|
2422
|
-
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));
|
|
2423
2464
|
});
|
|
2424
2465
|
}), n;
|
|
2425
2466
|
}
|
|
@@ -2444,12 +2485,12 @@ class k extends q {
|
|
|
2444
2485
|
};
|
|
2445
2486
|
i.width = s.width + r * 2, i.height = s.height + r * 2;
|
|
2446
2487
|
const a = i.getContext("2d");
|
|
2447
|
-
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,
|
|
2448
|
-
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h,
|
|
2449
|
-
}), s.arc.forEach(([c, l, h,
|
|
2450
|
-
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();
|
|
2451
2492
|
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
2452
|
-
let [l, h,
|
|
2493
|
+
let [l, h, d, f] = c;
|
|
2453
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;
|
|
2454
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);
|
|
2455
2496
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
@@ -2547,17 +2588,17 @@ class k extends q {
|
|
|
2547
2588
|
});
|
|
2548
2589
|
}
|
|
2549
2590
|
}
|
|
2550
|
-
function ct(
|
|
2551
|
-
if (
|
|
2552
|
-
if (
|
|
2553
|
-
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);
|
|
2554
2595
|
const t = {};
|
|
2555
|
-
for (const e in
|
|
2556
|
-
Object.prototype.hasOwnProperty.call(
|
|
2596
|
+
for (const e in u)
|
|
2597
|
+
Object.prototype.hasOwnProperty.call(u, e) && (t[e] = ct(u[e]));
|
|
2557
2598
|
return t;
|
|
2558
2599
|
}
|
|
2559
|
-
const
|
|
2560
|
-
class
|
|
2600
|
+
const z = new A();
|
|
2601
|
+
class Me extends k {
|
|
2561
2602
|
static name = "AngleCorrectionDxf";
|
|
2562
2603
|
angle = 0;
|
|
2563
2604
|
onAddFromParent(t) {
|
|
@@ -2568,12 +2609,12 @@ class we extends k {
|
|
|
2568
2609
|
let s = 0, i = null;
|
|
2569
2610
|
for (let c = 0; c < e.originalData.length; c++) {
|
|
2570
2611
|
const l = e.originalData[c];
|
|
2571
|
-
if (
|
|
2572
|
-
const [h,
|
|
2573
|
-
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;
|
|
2574
2615
|
break;
|
|
2575
2616
|
}
|
|
2576
|
-
(!i ||
|
|
2617
|
+
(!i || z.length() > i.length()) && (i = z.clone(), i.userData.index = c);
|
|
2577
2618
|
}
|
|
2578
2619
|
if (i) {
|
|
2579
2620
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
@@ -2581,10 +2622,10 @@ class we extends k {
|
|
|
2581
2622
|
s = -new A(c, l).direction().angleBetween(new M(0, 1), "angle", "360");
|
|
2582
2623
|
}
|
|
2583
2624
|
const r = e.originalBox.center, o = M.zero(), a = e.originalData.map((c) => {
|
|
2584
|
-
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z),
|
|
2585
|
-
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) => {
|
|
2586
2627
|
f.p = o.copy(f.p).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(f.p.z);
|
|
2587
|
-
}),
|
|
2628
|
+
}), d;
|
|
2588
2629
|
});
|
|
2589
2630
|
n.appendLineSegmentList.forEach((c) => {
|
|
2590
2631
|
const l = c.clone();
|
|
@@ -2602,7 +2643,7 @@ class we extends k {
|
|
|
2602
2643
|
});
|
|
2603
2644
|
}
|
|
2604
2645
|
}
|
|
2605
|
-
class Rt extends
|
|
2646
|
+
class Rt extends _ {
|
|
2606
2647
|
static name = "Variable";
|
|
2607
2648
|
originalLineVisible = !0;
|
|
2608
2649
|
dxfVisible = !0;
|
|
@@ -2629,10 +2670,11 @@ class Rt extends q {
|
|
|
2629
2670
|
if (t in this) return this[t];
|
|
2630
2671
|
}
|
|
2631
2672
|
}
|
|
2632
|
-
class
|
|
2673
|
+
class Se {
|
|
2633
2674
|
// 所有可查找的点位
|
|
2634
2675
|
possibleDoorPoints = [];
|
|
2635
2676
|
doorPoint = [];
|
|
2677
|
+
calculatedDoorPoint = [];
|
|
2636
2678
|
dxf;
|
|
2637
2679
|
// 包含所有点的虚拟网格
|
|
2638
2680
|
pointVirtualGrid = new X();
|
|
@@ -2648,18 +2690,28 @@ class Me {
|
|
|
2648
2690
|
lineAnalysis;
|
|
2649
2691
|
continueFind = !0;
|
|
2650
2692
|
constructor(t) {
|
|
2651
|
-
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new X(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((
|
|
2652
|
-
this.pointVirtualGrid.insert(
|
|
2653
|
-
})
|
|
2654
|
-
const e = this.
|
|
2655
|
-
this.
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
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();
|
|
2659
2703
|
}
|
|
2660
2704
|
handle() {
|
|
2661
|
-
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));
|
|
2662
2706
|
}
|
|
2707
|
+
/** 查找
|
|
2708
|
+
* @param doorPoints
|
|
2709
|
+
* @param possibleDoorPoints
|
|
2710
|
+
* @param minDoorWidth
|
|
2711
|
+
* @param doorSearchDistance
|
|
2712
|
+
* @param doorSearchNearAngle
|
|
2713
|
+
* @returns
|
|
2714
|
+
*/
|
|
2663
2715
|
search(t, e = [], n = 0.6, s = this.doorSearchDistance, i = this.doorSearchNearAngle) {
|
|
2664
2716
|
const r = this.dxf, o = this.searchNearby(t, e, s, i);
|
|
2665
2717
|
o.push(
|
|
@@ -2680,13 +2732,13 @@ class Me {
|
|
|
2680
2732
|
return o.forEach((c) => {
|
|
2681
2733
|
const l = new A(c?.start, c?.end), h = l.length();
|
|
2682
2734
|
if (h < n) return;
|
|
2683
|
-
const
|
|
2735
|
+
const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
2684
2736
|
for (let y = 0; y < 3; y++) {
|
|
2685
2737
|
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), m = new A(
|
|
2686
2738
|
x,
|
|
2687
|
-
x.clone().add(
|
|
2739
|
+
x.clone().add(d.clone().multiplyScalar(1))
|
|
2688
2740
|
);
|
|
2689
|
-
if (m.directionMove(
|
|
2741
|
+
if (m.directionMove(d, -0.5), this.quadtree.queryLineSegment(m).length) return;
|
|
2690
2742
|
}
|
|
2691
2743
|
a.push(l);
|
|
2692
2744
|
}), a;
|
|
@@ -2706,7 +2758,7 @@ class Me {
|
|
|
2706
2758
|
return this.lineSegments.forEach((e) => {
|
|
2707
2759
|
e.points.forEach((n, s) => {
|
|
2708
2760
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
|
|
2709
|
-
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() });
|
|
2710
2762
|
});
|
|
2711
2763
|
}), t;
|
|
2712
2764
|
}
|
|
@@ -2714,32 +2766,39 @@ class Me {
|
|
|
2714
2766
|
* 查找已知为门的点位
|
|
2715
2767
|
*/
|
|
2716
2768
|
getDoorPoint() {
|
|
2717
|
-
const t = [], e = this.dxf,
|
|
2718
|
-
return
|
|
2719
|
-
const
|
|
2720
|
-
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) {
|
|
2721
2773
|
this.continueFind = !1;
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2774
|
+
const a = new A(M.from(o.start), M.from(o.end));
|
|
2775
|
+
a.userData = {
|
|
2724
2776
|
doorDirectConnection: !0,
|
|
2725
2777
|
isDoor: !0
|
|
2726
|
-
}, this.dxf.doorLineSegment.push(
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
return f > 80 || f < 10;
|
|
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
|
+
});
|
|
2734
2785
|
});
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
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;
|
|
2793
|
+
});
|
|
2794
|
+
l.length && t.push({
|
|
2795
|
+
line: l[0].userData,
|
|
2796
|
+
point: a,
|
|
2797
|
+
uuid: K()
|
|
2739
2798
|
});
|
|
2740
2799
|
} else
|
|
2741
|
-
console.warn(`门的线段顺序${
|
|
2742
|
-
}), t;
|
|
2800
|
+
console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
|
|
2801
|
+
}), { doorPoints: t, calculatedDoorPoint: e };
|
|
2743
2802
|
}
|
|
2744
2803
|
/**
|
|
2745
2804
|
* 查找双线墙的点位
|
|
@@ -2762,78 +2821,78 @@ class Me {
|
|
|
2762
2821
|
*/
|
|
2763
2822
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2764
2823
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2765
|
-
function o({ point: x, line: m },
|
|
2824
|
+
function o({ point: x, line: m }, D, w) {
|
|
2766
2825
|
const g = m.direction();
|
|
2767
2826
|
m.start === x && g.multiplyScalar(-1);
|
|
2768
|
-
const S = i.queryCircle(x, n).filter((
|
|
2769
|
-
for (let
|
|
2770
|
-
const b = e.findIndex((O) => O.point === S[
|
|
2827
|
+
const S = i.queryCircle(x, n).filter((L) => L.userData !== m).sort((L, b) => L.point.distance(x) - b.point.distance(x)), E = [];
|
|
2828
|
+
for (let L = 0; L < S.length; L++) {
|
|
2829
|
+
const b = e.findIndex((O) => O.point === S[L].point), R = t[D].uuid, P = e[b].uuid;
|
|
2771
2830
|
if (w.has(`${R}.${P}`)) continue;
|
|
2772
2831
|
w.add(`${R}.${P}`), w.add(`${P}.${R}`);
|
|
2773
|
-
const B = S[
|
|
2832
|
+
const B = S[L].point, C = new A(x.clone(), B.clone());
|
|
2774
2833
|
if (C.direction().angleBetween(g, "angle") < s) {
|
|
2775
|
-
const O = t[
|
|
2776
|
-
v.start.equal(S[
|
|
2777
|
-
findData: S[
|
|
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({
|
|
2836
|
+
findData: S[L],
|
|
2778
2837
|
findUuid: P,
|
|
2779
2838
|
doorLine: C,
|
|
2780
2839
|
doorUuid: R
|
|
2781
2840
|
}));
|
|
2782
2841
|
}
|
|
2783
2842
|
}
|
|
2784
|
-
return
|
|
2843
|
+
return E;
|
|
2785
2844
|
}
|
|
2786
|
-
function a(x, m,
|
|
2845
|
+
function a(x, m, D, w, g) {
|
|
2787
2846
|
w.add(x);
|
|
2788
2847
|
const S = [];
|
|
2789
2848
|
g && S.push(g);
|
|
2790
|
-
for (let
|
|
2791
|
-
const
|
|
2792
|
-
if (m.has(
|
|
2793
|
-
const b = m.get(
|
|
2794
|
-
a(
|
|
2795
|
-
} else S.push(
|
|
2849
|
+
for (let E = 0; E < D.length; E++) {
|
|
2850
|
+
const L = D[E];
|
|
2851
|
+
if (m.has(L.findUuid)) {
|
|
2852
|
+
const b = m.get(L.findUuid);
|
|
2853
|
+
a(L.findUuid, m, b, w, L) && S.push(L);
|
|
2854
|
+
} else S.push(L);
|
|
2796
2855
|
}
|
|
2797
|
-
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);
|
|
2798
2857
|
}
|
|
2799
2858
|
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
2800
2859
|
t.map((x, m) => {
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2860
|
+
const D = o(x, m, c);
|
|
2861
|
+
D.length && l.set(x.uuid, D);
|
|
2803
2862
|
}), c.clear();
|
|
2804
2863
|
const h = /* @__PURE__ */ new Map();
|
|
2805
2864
|
l.forEach((x, m) => {
|
|
2806
2865
|
if (!c.has(m) && x.length && a(m, l, x, c), x.length) {
|
|
2807
|
-
const
|
|
2808
|
-
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);
|
|
2809
2868
|
}
|
|
2810
2869
|
});
|
|
2811
|
-
const
|
|
2870
|
+
const d = /* @__PURE__ */ new Set();
|
|
2812
2871
|
h.forEach((x) => {
|
|
2813
2872
|
if (x.length > 1) {
|
|
2814
|
-
x.sort((m,
|
|
2815
|
-
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]);
|
|
2816
2875
|
}
|
|
2817
2876
|
});
|
|
2818
2877
|
const f = [], p = [];
|
|
2819
2878
|
l.forEach((x) => {
|
|
2820
2879
|
if (x.length) {
|
|
2821
2880
|
const m = x[0];
|
|
2822
|
-
|
|
2881
|
+
d.has(m) || (f.push(m), p.push(m.doorUuid, m.findUuid));
|
|
2823
2882
|
}
|
|
2824
2883
|
});
|
|
2825
2884
|
const y = [];
|
|
2826
2885
|
return f.forEach((x) => {
|
|
2827
|
-
const m = t.findIndex((b) => b.uuid === x.doorUuid),
|
|
2828
|
-
if (
|
|
2829
|
-
w.copy(
|
|
2830
|
-
const b = new A(w, g), R =
|
|
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);
|
|
2887
|
+
if (L) {
|
|
2888
|
+
w.copy(L);
|
|
2889
|
+
const b = new A(w, g), R = E.includedAngle(b);
|
|
2831
2890
|
(R < 10 || R > 170 || Math.abs(90 - R) < 10) && y.push({
|
|
2832
2891
|
start: w,
|
|
2833
2892
|
end: g
|
|
2834
2893
|
});
|
|
2835
2894
|
} else {
|
|
2836
|
-
const b =
|
|
2895
|
+
const b = E.projectPoint(w);
|
|
2837
2896
|
b && g.copy(b);
|
|
2838
2897
|
const R = new A(w, g), P = S.includedAngle(R);
|
|
2839
2898
|
(P < 10 || P > 170 || Math.abs(90 - P) < 10) && y.push({
|
|
@@ -2878,22 +2937,22 @@ class Me {
|
|
|
2878
2937
|
searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2879
2938
|
const s = this.pointVirtualGrid, i = this.quadtree, r = e.direction(), o = e.start.normal(e.end), a = e.start.clone();
|
|
2880
2939
|
e.start === t && r.multiplyScalar(-1), e.start === t && a.copy(e.end);
|
|
2881
|
-
const c = s.queryPoint(a).filter((
|
|
2882
|
-
for (let
|
|
2883
|
-
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();
|
|
2884
2943
|
if (p.start === f.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
|
|
2885
2944
|
o.multiplyScalar(-1);
|
|
2886
2945
|
break;
|
|
2887
2946
|
}
|
|
2888
2947
|
}
|
|
2889
|
-
const l = new A(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((
|
|
2890
|
-
point:
|
|
2891
|
-
line:
|
|
2892
|
-
})).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));
|
|
2893
2952
|
if (h.length) {
|
|
2894
|
-
const
|
|
2895
|
-
if (Math.abs(90 -
|
|
2896
|
-
return
|
|
2953
|
+
const d = h[0];
|
|
2954
|
+
if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
|
|
2955
|
+
return d;
|
|
2897
2956
|
}
|
|
2898
2957
|
}
|
|
2899
2958
|
/**
|
|
@@ -2920,7 +2979,7 @@ class Me {
|
|
|
2920
2979
|
return e;
|
|
2921
2980
|
}
|
|
2922
2981
|
}
|
|
2923
|
-
class
|
|
2982
|
+
class De extends _ {
|
|
2924
2983
|
static name = "LineAnalysis";
|
|
2925
2984
|
Dxf = null;
|
|
2926
2985
|
Variable = null;
|
|
@@ -2974,14 +3033,14 @@ class Se extends q {
|
|
|
2974
3033
|
createRectangle(t) {
|
|
2975
3034
|
const e = this.Dxf, n = t.project, s = t.project2;
|
|
2976
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]);
|
|
2977
|
-
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]),
|
|
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);
|
|
2978
3037
|
p.multiplyScalar(e.width * 0.5);
|
|
2979
|
-
const y =
|
|
2980
|
-
if (!(m.x > 0 &&
|
|
2981
|
-
|
|
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);
|
|
2982
3041
|
for (let w = 1; w < o; w++) {
|
|
2983
|
-
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w),
|
|
2984
|
-
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);
|
|
2985
3044
|
}
|
|
2986
3045
|
}
|
|
2987
3046
|
}
|
|
@@ -3008,7 +3067,7 @@ class Se extends q {
|
|
|
3008
3067
|
this.buildQuadtree();
|
|
3009
3068
|
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
3010
3069
|
e.forEach((i, r) => {
|
|
3011
|
-
const o = e[r], a =
|
|
3070
|
+
const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
3012
3071
|
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
3013
3072
|
try {
|
|
3014
3073
|
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
@@ -3051,13 +3110,12 @@ class Se extends q {
|
|
|
3051
3110
|
doorSearchDistance = 2;
|
|
3052
3111
|
doors = [];
|
|
3053
3112
|
DoorsAnalysis;
|
|
3113
|
+
skipFindDoor = !1;
|
|
3054
3114
|
doorsAnalysis() {
|
|
3055
|
-
this.DoorsAnalysis = new
|
|
3056
|
-
type: "analysisCompleted"
|
|
3057
|
-
});
|
|
3115
|
+
this.skipFindDoor || (this.DoorsAnalysis = new Se(this), this.skipFindDoor = !1), this.dispatchEvent({ type: "analysisCompleted" });
|
|
3058
3116
|
}
|
|
3059
3117
|
}
|
|
3060
|
-
class Le extends
|
|
3118
|
+
class Le extends _ {
|
|
3061
3119
|
static name = "ThreeVJia";
|
|
3062
3120
|
lineSegments = [];
|
|
3063
3121
|
onAddFromParent() {
|
|
@@ -3067,8 +3125,8 @@ class Le extends q {
|
|
|
3067
3125
|
const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf"), n = this.parent?.findComponentByName("AngleCorrectionDxf"), s = /* @__PURE__ */ new Map();
|
|
3068
3126
|
let i = [...e.lineSegments], r = [], o = [];
|
|
3069
3127
|
t.resultList.forEach((l) => {
|
|
3070
|
-
const h = s.get(l.target) ?? [],
|
|
3071
|
-
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);
|
|
3072
3130
|
const y = new A(f.start, p.start), x = new A(f.end, p.end), m = new A(y.center, x.center);
|
|
3073
3131
|
m.userData.wallWidth = Math.max(y.length(), x.length()), r.push(m);
|
|
3074
3132
|
});
|
|
@@ -3076,19 +3134,19 @@ class Le extends q {
|
|
|
3076
3134
|
i = i.filter((l) => {
|
|
3077
3135
|
if (o.indexOf(l) > -1) return !1;
|
|
3078
3136
|
if (s.has(l)) {
|
|
3079
|
-
const h = s.get(l),
|
|
3137
|
+
const h = s.get(l), d = l.clone();
|
|
3080
3138
|
if (h) {
|
|
3081
3139
|
for (let p = 0; p < h.length; p += 2) {
|
|
3082
3140
|
const y = h[p], x = h[p + 1];
|
|
3083
|
-
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");
|
|
3084
3142
|
}
|
|
3085
3143
|
h.sort((p, y) => p.userData.length - y.userData.length);
|
|
3086
3144
|
const f = [];
|
|
3087
3145
|
for (let p = 0; p < h.length; p++) {
|
|
3088
3146
|
const y = h[p];
|
|
3089
|
-
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));
|
|
3090
3148
|
}
|
|
3091
|
-
a.push(
|
|
3149
|
+
a.push(d);
|
|
3092
3150
|
}
|
|
3093
3151
|
return !1;
|
|
3094
3152
|
}
|
|
@@ -3192,7 +3250,7 @@ class ht extends se {
|
|
|
3192
3250
|
* @param scale 原始数据缩放比例
|
|
3193
3251
|
*/
|
|
3194
3252
|
constructor(t = 0.1, e = 1) {
|
|
3195
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new
|
|
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;
|
|
3196
3254
|
}
|
|
3197
3255
|
usePlugin(t) {
|
|
3198
3256
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3233,15 +3291,15 @@ class ut {
|
|
|
3233
3291
|
static boundExtbyTraj(t, e, n = 0.12) {
|
|
3234
3292
|
function s(w, g) {
|
|
3235
3293
|
return g.queryLineSegment(w).filter((S) => S.line !== w).map(({ line: S }) => {
|
|
3236
|
-
const
|
|
3237
|
-
w.sameEndpoint(S) && (
|
|
3238
|
-
const
|
|
3239
|
-
if (
|
|
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");
|
|
3296
|
+
const L = w.getSameEndpoint(S);
|
|
3297
|
+
if (L) E.point = L[1];
|
|
3240
3298
|
else {
|
|
3241
3299
|
const b = S.getIntersection(w);
|
|
3242
|
-
b && (
|
|
3300
|
+
b && (E.point = S.start.equal(b) ? S.start : S.end);
|
|
3243
3301
|
}
|
|
3244
|
-
return
|
|
3302
|
+
return E;
|
|
3245
3303
|
});
|
|
3246
3304
|
}
|
|
3247
3305
|
function i(w) {
|
|
@@ -3254,18 +3312,18 @@ class ut {
|
|
|
3254
3312
|
w.directionMove(S, n * 0.5);
|
|
3255
3313
|
}
|
|
3256
3314
|
}
|
|
3257
|
-
function r({ resultLine: w, type: g, direction: S, point:
|
|
3315
|
+
function r({ resultLine: w, type: g, direction: S, point: E }, L, b, R) {
|
|
3258
3316
|
if (g === "intersect")
|
|
3259
|
-
|
|
3317
|
+
E && E.copy(L.projectPoint(E) ?? E);
|
|
3260
3318
|
else if (S === "vertical") {
|
|
3261
|
-
if (
|
|
3262
|
-
const P =
|
|
3263
|
-
|
|
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())));
|
|
3264
3322
|
}
|
|
3265
|
-
} else if (!
|
|
3266
|
-
let P =
|
|
3267
|
-
if (
|
|
3268
|
-
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()));
|
|
3269
3327
|
const C = new A(P.clone(), B.clone());
|
|
3270
3328
|
C.length() && R.push(C);
|
|
3271
3329
|
}
|
|
@@ -3274,45 +3332,45 @@ class ut {
|
|
|
3274
3332
|
}
|
|
3275
3333
|
const o = Object.keys(e).map((w) => M.from(e[w])), a = [];
|
|
3276
3334
|
let c = t.map(({ start: w, end: g, ...S }) => {
|
|
3277
|
-
const
|
|
3278
|
-
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;
|
|
3279
3337
|
});
|
|
3280
3338
|
const l = a.reduce((w, g) => w + g, 0) / a.length;
|
|
3281
|
-
let
|
|
3282
|
-
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);
|
|
3283
3341
|
const p = this.parent?.findComponentByName("Renderer");
|
|
3284
|
-
o.forEach((w) => p.createPointMesh(w, 0.05, {}).position.z = l), p.createLineSegments(
|
|
3285
|
-
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));
|
|
3286
3344
|
c.forEach((w) => w.userData.isDoor || x.insert(w));
|
|
3287
|
-
const m = y.map((w) => w.flatMap((g) => s(g, x))),
|
|
3288
|
-
return y.flatMap((w, g) => (w.forEach((
|
|
3289
|
-
if (!
|
|
3290
|
-
let
|
|
3291
|
-
return Object.defineProperty(
|
|
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)) {
|
|
3348
|
+
let L;
|
|
3349
|
+
return Object.defineProperty(E, "newLine", {
|
|
3292
3350
|
get() {
|
|
3293
|
-
return
|
|
3351
|
+
return L || (L = A.mergeLines(...w)), L;
|
|
3294
3352
|
}
|
|
3295
3353
|
}), !0;
|
|
3296
3354
|
}
|
|
3297
|
-
r(
|
|
3355
|
+
r(E, A.mergeLines(...w), x, D);
|
|
3298
3356
|
}))).reduce((w, g) => (w.has(g.resultLine) || w.set(g.resultLine, []), w.get(g.resultLine)?.push(g), w), /* @__PURE__ */ new Map()).forEach((w) => {
|
|
3299
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) => {
|
|
3300
3358
|
const S = /* @__PURE__ */ new Set();
|
|
3301
|
-
for (let
|
|
3302
|
-
const
|
|
3303
|
-
S.has(
|
|
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));
|
|
3304
3362
|
}
|
|
3305
3363
|
});
|
|
3306
|
-
}), 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);
|
|
3307
3365
|
}
|
|
3308
3366
|
}
|
|
3309
|
-
const
|
|
3367
|
+
const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3310
3368
|
__proto__: null,
|
|
3311
3369
|
AxisAlignCorr: Pt,
|
|
3312
3370
|
BoundExt: ut,
|
|
3313
3371
|
lineDataToOriginalData: J,
|
|
3314
3372
|
lineSegmentClipping: lt,
|
|
3315
|
-
recomputedWindow:
|
|
3373
|
+
recomputedWindow: tt
|
|
3316
3374
|
}, Symbol.toStringTag, { value: "Module" })), St = {
|
|
3317
3375
|
POSITION: [
|
|
3318
3376
|
"byte",
|
|
@@ -3341,36 +3399,36 @@ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3341
3399
|
"unsigned short"
|
|
3342
3400
|
]
|
|
3343
3401
|
};
|
|
3344
|
-
class
|
|
3402
|
+
class et {
|
|
3345
3403
|
constructor() {
|
|
3346
3404
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
3347
|
-
return new Ce(t);
|
|
3348
|
-
}), this.register(function(t) {
|
|
3349
3405
|
return new Be(t);
|
|
3350
3406
|
}), this.register(function(t) {
|
|
3351
|
-
return new
|
|
3407
|
+
return new Oe(t);
|
|
3408
|
+
}), this.register(function(t) {
|
|
3409
|
+
return new je(t);
|
|
3352
3410
|
}), this.register(function(t) {
|
|
3353
3411
|
return new ze(t);
|
|
3354
3412
|
}), this.register(function(t) {
|
|
3355
|
-
return new
|
|
3413
|
+
return new qe(t);
|
|
3356
3414
|
}), this.register(function(t) {
|
|
3357
3415
|
return new _e(t);
|
|
3358
|
-
}), this.register(function(t) {
|
|
3359
|
-
return new Oe(t);
|
|
3360
3416
|
}), this.register(function(t) {
|
|
3361
3417
|
return new Fe(t);
|
|
3362
3418
|
}), this.register(function(t) {
|
|
3363
|
-
return new
|
|
3419
|
+
return new Ue(t);
|
|
3364
3420
|
}), this.register(function(t) {
|
|
3365
|
-
return new
|
|
3421
|
+
return new Ge(t);
|
|
3366
3422
|
}), this.register(function(t) {
|
|
3367
3423
|
return new Ye(t);
|
|
3368
3424
|
}), this.register(function(t) {
|
|
3369
3425
|
return new ke(t);
|
|
3426
|
+
}), this.register(function(t) {
|
|
3427
|
+
return new Xe(t);
|
|
3370
3428
|
}), this.register(function(t) {
|
|
3371
3429
|
return new Ve(t);
|
|
3372
3430
|
}), this.register(function(t) {
|
|
3373
|
-
return new
|
|
3431
|
+
return new We(t);
|
|
3374
3432
|
});
|
|
3375
3433
|
}
|
|
3376
3434
|
register(t) {
|
|
@@ -3383,7 +3441,7 @@ class tt {
|
|
|
3383
3441
|
return this.textureUtils = t, this;
|
|
3384
3442
|
}
|
|
3385
3443
|
parse(t, e, n, s) {
|
|
3386
|
-
const i = new
|
|
3444
|
+
const i = new Ce(), r = [];
|
|
3387
3445
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
3388
3446
|
r.push(this.pluginCallbacks[o](i));
|
|
3389
3447
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
|
|
@@ -3419,78 +3477,78 @@ const T = {
|
|
|
3419
3477
|
CLAMP_TO_EDGE: 33071,
|
|
3420
3478
|
MIRRORED_REPEAT: 33648,
|
|
3421
3479
|
REPEAT: 10497
|
|
3422
|
-
},
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
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 = {
|
|
3433
3491
|
scale: "scale",
|
|
3434
3492
|
position: "translation",
|
|
3435
3493
|
quaternion: "rotation",
|
|
3436
3494
|
morphTargetInfluences: "weights"
|
|
3437
|
-
}, Ee = new Ft(),
|
|
3438
|
-
function H(
|
|
3439
|
-
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) {
|
|
3440
3498
|
return e === t[n];
|
|
3441
3499
|
});
|
|
3442
3500
|
}
|
|
3443
|
-
function
|
|
3444
|
-
return new TextEncoder().encode(
|
|
3501
|
+
function Pe(u) {
|
|
3502
|
+
return new TextEncoder().encode(u).buffer;
|
|
3445
3503
|
}
|
|
3446
|
-
function
|
|
3447
|
-
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]);
|
|
3448
3506
|
}
|
|
3449
|
-
function
|
|
3507
|
+
function ve(u, t, e) {
|
|
3450
3508
|
const n = {
|
|
3451
|
-
min: new Array(
|
|
3452
|
-
max: new Array(
|
|
3509
|
+
min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
3510
|
+
max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
3453
3511
|
};
|
|
3454
3512
|
for (let s = t; s < t + e; s++)
|
|
3455
|
-
for (let i = 0; i <
|
|
3513
|
+
for (let i = 0; i < u.itemSize; i++) {
|
|
3456
3514
|
let r;
|
|
3457
|
-
|
|
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);
|
|
3458
3516
|
}
|
|
3459
3517
|
return n;
|
|
3460
3518
|
}
|
|
3461
|
-
function vt(
|
|
3462
|
-
return Math.ceil(
|
|
3519
|
+
function vt(u) {
|
|
3520
|
+
return Math.ceil(u / 4) * 4;
|
|
3463
3521
|
}
|
|
3464
|
-
function
|
|
3465
|
-
const e = vt(
|
|
3466
|
-
if (e !==
|
|
3522
|
+
function rt(u, t = 0) {
|
|
3523
|
+
const e = vt(u.byteLength);
|
|
3524
|
+
if (e !== u.byteLength) {
|
|
3467
3525
|
const n = new Uint8Array(e);
|
|
3468
|
-
if (n.set(new Uint8Array(
|
|
3469
|
-
for (let s =
|
|
3526
|
+
if (n.set(new Uint8Array(u)), t !== 0)
|
|
3527
|
+
for (let s = u.byteLength; s < e; s++)
|
|
3470
3528
|
n[s] = t;
|
|
3471
3529
|
return n.buffer;
|
|
3472
3530
|
}
|
|
3473
|
-
return
|
|
3531
|
+
return u;
|
|
3474
3532
|
}
|
|
3475
3533
|
function At() {
|
|
3476
3534
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
3477
3535
|
}
|
|
3478
|
-
function
|
|
3479
|
-
if (typeof OffscreenCanvas < "u" &&
|
|
3536
|
+
function Ne(u, t) {
|
|
3537
|
+
if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
|
|
3480
3538
|
let e;
|
|
3481
|
-
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({
|
|
3482
3540
|
type: t,
|
|
3483
3541
|
quality: e
|
|
3484
3542
|
});
|
|
3485
3543
|
} else
|
|
3486
|
-
return new Promise((e) =>
|
|
3544
|
+
return new Promise((e) => u.toBlob(e, t));
|
|
3487
3545
|
}
|
|
3488
|
-
class
|
|
3546
|
+
class Ce {
|
|
3489
3547
|
constructor() {
|
|
3490
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 = {
|
|
3491
3549
|
asset: {
|
|
3492
3550
|
version: "2.0",
|
|
3493
|
-
generator: "THREE.GLTFExporter r" +
|
|
3551
|
+
generator: "THREE.GLTFExporter r" + Gt
|
|
3494
3552
|
}
|
|
3495
3553
|
}, this.cache = {
|
|
3496
3554
|
meshes: /* @__PURE__ */ new Map(),
|
|
@@ -3527,15 +3585,15 @@ class Ne {
|
|
|
3527
3585
|
const s = this, i = s.buffers, r = s.json;
|
|
3528
3586
|
n = s.options;
|
|
3529
3587
|
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
3530
|
-
l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ?
|
|
3531
|
-
const f =
|
|
3532
|
-
p.setUint32(0, f.byteLength, !0), p.setUint32(4,
|
|
3533
|
-
const y =
|
|
3534
|
-
x.setUint32(0, y.byteLength, !0), x.setUint32(4,
|
|
3535
|
-
const m = new ArrayBuffer(
|
|
3536
|
-
|
|
3537
|
-
const w =
|
|
3538
|
-
|
|
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);
|
|
3595
|
+
const w = Lt + x.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
3596
|
+
D.setUint32(8, w, !0);
|
|
3539
3597
|
const g = new Blob([
|
|
3540
3598
|
m,
|
|
3541
3599
|
x,
|
|
@@ -3543,11 +3601,11 @@ class Ne {
|
|
|
3543
3601
|
p,
|
|
3544
3602
|
f
|
|
3545
3603
|
], { type: "application/octet-stream" });
|
|
3546
|
-
|
|
3604
|
+
ot(g).then((S) => {
|
|
3547
3605
|
e(S);
|
|
3548
3606
|
});
|
|
3549
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
3550
|
-
r.buffers[0].uri =
|
|
3607
|
+
}) : r.buffers && r.buffers.length > 0 ? He(c).then((d) => {
|
|
3608
|
+
r.buffers[0].uri = d, e(r);
|
|
3551
3609
|
}) : e(r);
|
|
3552
3610
|
}
|
|
3553
3611
|
/**
|
|
@@ -3594,7 +3652,7 @@ class Ne {
|
|
|
3594
3652
|
*/
|
|
3595
3653
|
isNormalizedNormalAttribute(t) {
|
|
3596
3654
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
3597
|
-
const n = new
|
|
3655
|
+
const n = new Z();
|
|
3598
3656
|
for (let s = 0, i = t.count; s < i; s++)
|
|
3599
3657
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
3600
3658
|
return !0;
|
|
@@ -3609,7 +3667,7 @@ class Ne {
|
|
|
3609
3667
|
createNormalizedNormalAttribute(t) {
|
|
3610
3668
|
const e = this.cache;
|
|
3611
3669
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
3612
|
-
const n = t.clone(), s = new
|
|
3670
|
+
const n = t.clone(), s = new Z();
|
|
3613
3671
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3614
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);
|
|
3615
3673
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -3629,13 +3687,13 @@ class Ne {
|
|
|
3629
3687
|
async buildMetalRoughTextureAsync(t, e) {
|
|
3630
3688
|
if (t === e) return t;
|
|
3631
3689
|
function n(f) {
|
|
3632
|
-
return f.colorSpace ===
|
|
3690
|
+
return f.colorSpace === Xt ? function(y) {
|
|
3633
3691
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3634
3692
|
} : function(y) {
|
|
3635
3693
|
return y;
|
|
3636
3694
|
};
|
|
3637
3695
|
}
|
|
3638
|
-
t instanceof
|
|
3696
|
+
t instanceof st && (t = await this.decompressTextureAsync(t)), e instanceof st && (e = await this.decompressTextureAsync(e));
|
|
3639
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();
|
|
3640
3698
|
a.width = r, a.height = o;
|
|
3641
3699
|
const c = a.getContext("2d", {
|
|
@@ -3656,8 +3714,8 @@ class Ne {
|
|
|
3656
3714
|
l.data[y] = f(p[y] / 256) * 256;
|
|
3657
3715
|
}
|
|
3658
3716
|
c.putImageData(l, 0, 0);
|
|
3659
|
-
const
|
|
3660
|
-
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;
|
|
3661
3719
|
}
|
|
3662
3720
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
3663
3721
|
if (this.textureUtils === null)
|
|
@@ -3705,16 +3763,16 @@ class Ne {
|
|
|
3705
3763
|
for (let p = n; p < n + s; p++) {
|
|
3706
3764
|
for (let y = 0; y < t.itemSize; y++) {
|
|
3707
3765
|
let x;
|
|
3708
|
-
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x =
|
|
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;
|
|
3709
3767
|
}
|
|
3710
3768
|
h % a !== 0 && (h += a - h % a);
|
|
3711
3769
|
}
|
|
3712
|
-
const
|
|
3770
|
+
const d = {
|
|
3713
3771
|
buffer: this.processBuffer(l.buffer),
|
|
3714
3772
|
byteOffset: this.byteOffset,
|
|
3715
3773
|
byteLength: c
|
|
3716
3774
|
};
|
|
3717
|
-
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), {
|
|
3718
3776
|
id: r.bufferViews.length - 1,
|
|
3719
3777
|
byteLength: 0
|
|
3720
3778
|
};
|
|
@@ -3727,8 +3785,8 @@ class Ne {
|
|
|
3727
3785
|
processBufferViewImage(t) {
|
|
3728
3786
|
const e = this, n = e.json;
|
|
3729
3787
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3730
|
-
|
|
3731
|
-
const r =
|
|
3788
|
+
ot(t).then((i) => {
|
|
3789
|
+
const r = rt(i), o = {
|
|
3732
3790
|
buffer: e.processBuffer(r),
|
|
3733
3791
|
byteOffset: e.byteOffset,
|
|
3734
3792
|
byteLength: r.byteLength
|
|
@@ -3772,7 +3830,7 @@ class Ne {
|
|
|
3772
3830
|
else
|
|
3773
3831
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
3774
3832
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
3775
|
-
const a =
|
|
3833
|
+
const a = ve(t, n, s);
|
|
3776
3834
|
let c;
|
|
3777
3835
|
e !== void 0 && (c = t === e.index ? T.ELEMENT_ARRAY_BUFFER : T.ARRAY_BUFFER);
|
|
3778
3836
|
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
@@ -3801,13 +3859,13 @@ class Ne {
|
|
|
3801
3859
|
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
3802
3860
|
if (l[h] !== void 0) return l[h];
|
|
3803
3861
|
o.images || (o.images = []);
|
|
3804
|
-
const
|
|
3862
|
+
const d = { mimeType: s }, f = At();
|
|
3805
3863
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
3806
3864
|
const p = f.getContext("2d", {
|
|
3807
3865
|
willReadFrequently: !0
|
|
3808
3866
|
});
|
|
3809
3867
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
3810
|
-
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);
|
|
3811
3869
|
const x = new Uint8ClampedArray(t.height * t.width * 4);
|
|
3812
3870
|
for (let m = 0; m < x.length; m += 4)
|
|
3813
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];
|
|
@@ -3817,11 +3875,11 @@ class Ne {
|
|
|
3817
3875
|
else
|
|
3818
3876
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
3819
3877
|
a.binary === !0 ? c.push(
|
|
3820
|
-
|
|
3821
|
-
|
|
3878
|
+
Ne(f, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3879
|
+
d.bufferView = x;
|
|
3822
3880
|
})
|
|
3823
|
-
) :
|
|
3824
|
-
const y = o.images.push(
|
|
3881
|
+
) : d.uri = _t.getDataURL(f, s);
|
|
3882
|
+
const y = o.images.push(d) - 1;
|
|
3825
3883
|
return l[h] = y, y;
|
|
3826
3884
|
} else
|
|
3827
3885
|
throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
|
|
@@ -3835,10 +3893,10 @@ class Ne {
|
|
|
3835
3893
|
const e = this.json;
|
|
3836
3894
|
e.samplers || (e.samplers = []);
|
|
3837
3895
|
const n = {
|
|
3838
|
-
magFilter:
|
|
3839
|
-
minFilter:
|
|
3840
|
-
wrapS:
|
|
3841
|
-
wrapT:
|
|
3896
|
+
magFilter: U[t.magFilter],
|
|
3897
|
+
minFilter: U[t.minFilter],
|
|
3898
|
+
wrapS: U[t.wrapS],
|
|
3899
|
+
wrapT: U[t.wrapT]
|
|
3842
3900
|
};
|
|
3843
3901
|
return e.samplers.push(n) - 1;
|
|
3844
3902
|
}
|
|
@@ -3850,7 +3908,7 @@ class Ne {
|
|
|
3850
3908
|
async processTextureAsync(t) {
|
|
3851
3909
|
const n = this.options, s = this.cache, i = this.json;
|
|
3852
3910
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
3853
|
-
i.textures || (i.textures = []), t instanceof
|
|
3911
|
+
i.textures || (i.textures = []), t instanceof st && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
3854
3912
|
let r = t.userData.mimeType;
|
|
3855
3913
|
r === "image/webp" && (r = "image/png");
|
|
3856
3914
|
const o = {
|
|
@@ -3938,7 +3996,7 @@ class Ne {
|
|
|
3938
3996
|
const r = t.geometry;
|
|
3939
3997
|
let o;
|
|
3940
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;
|
|
3941
|
-
const a = {}, c = {}, l = [], h = [],
|
|
3999
|
+
const a = {}, c = {}, l = [], h = [], d = {
|
|
3942
4000
|
uv: "TEXCOORD_0",
|
|
3943
4001
|
uv1: "TEXCOORD_1",
|
|
3944
4002
|
uv2: "TEXCOORD_2",
|
|
@@ -3952,23 +4010,23 @@ class Ne {
|
|
|
3952
4010
|
for (let g in r.attributes) {
|
|
3953
4011
|
if (g.slice(0, 5) === "morph") continue;
|
|
3954
4012
|
const S = r.attributes[g];
|
|
3955
|
-
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))) {
|
|
3956
4014
|
c[g] = e.attributes.get(this.getUID(S));
|
|
3957
4015
|
continue;
|
|
3958
4016
|
}
|
|
3959
4017
|
p = null;
|
|
3960
|
-
const
|
|
3961
|
-
g === "JOINTS_0" && !(
|
|
4018
|
+
const L = S.array;
|
|
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));
|
|
3962
4020
|
const b = this.processAccessor(p || S, r);
|
|
3963
4021
|
b !== null && (g.startsWith("_") || this.detectMeshQuantization(g, S), c[g] = b, e.attributes.set(this.getUID(S), b));
|
|
3964
4022
|
}
|
|
3965
4023
|
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
3966
4024
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
3967
|
-
const g = [], S = [],
|
|
4025
|
+
const g = [], S = [], E = {};
|
|
3968
4026
|
if (t.morphTargetDictionary !== void 0)
|
|
3969
|
-
for (const
|
|
3970
|
-
|
|
3971
|
-
for (let
|
|
4027
|
+
for (const L in t.morphTargetDictionary)
|
|
4028
|
+
E[t.morphTargetDictionary[L]] = L;
|
|
4029
|
+
for (let L = 0; L < t.morphTargetInfluences.length; ++L) {
|
|
3972
4030
|
const b = {};
|
|
3973
4031
|
let R = !1;
|
|
3974
4032
|
for (const P in r.morphAttributes) {
|
|
@@ -3976,7 +4034,7 @@ class Ne {
|
|
|
3976
4034
|
R || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), R = !0);
|
|
3977
4035
|
continue;
|
|
3978
4036
|
}
|
|
3979
|
-
const B = r.morphAttributes[P][
|
|
4037
|
+
const B = r.morphAttributes[P][L], C = P.toUpperCase(), G = r.attributes[P];
|
|
3980
4038
|
if (e.attributes.has(this.getUID(B, !0))) {
|
|
3981
4039
|
b[C] = e.attributes.get(this.getUID(B, !0));
|
|
3982
4040
|
continue;
|
|
@@ -3984,11 +4042,11 @@ class Ne {
|
|
|
3984
4042
|
const O = B.clone();
|
|
3985
4043
|
if (!r.morphTargetsRelative)
|
|
3986
4044
|
for (let v = 0, V = B.count; v < V; v++)
|
|
3987
|
-
for (let
|
|
3988
|
-
|
|
3989
|
-
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]);
|
|
3990
4048
|
}
|
|
3991
|
-
h.push(b), g.push(t.morphTargetInfluences[
|
|
4049
|
+
h.push(b), g.push(t.morphTargetInfluences[L]), t.morphTargetDictionary !== void 0 && S.push(E[L]);
|
|
3992
4050
|
}
|
|
3993
4051
|
a.weights = g, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
3994
4052
|
}
|
|
@@ -3997,22 +4055,22 @@ class Ne {
|
|
|
3997
4055
|
let x = !1;
|
|
3998
4056
|
if (y && r.index === null) {
|
|
3999
4057
|
const g = [];
|
|
4000
|
-
for (let S = 0,
|
|
4058
|
+
for (let S = 0, E = r.attributes.position.count; S < E; S++)
|
|
4001
4059
|
g[S] = S;
|
|
4002
4060
|
r.setIndex(g), x = !0;
|
|
4003
4061
|
}
|
|
4004
|
-
const m = y ? t.material : [t.material],
|
|
4005
|
-
for (let g = 0, S =
|
|
4006
|
-
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 = {
|
|
4007
4065
|
mode: o,
|
|
4008
4066
|
attributes: c
|
|
4009
4067
|
};
|
|
4010
|
-
if (this.serializeUserData(r,
|
|
4068
|
+
if (this.serializeUserData(r, E), h.length > 0 && (E.targets = h), r.index !== null) {
|
|
4011
4069
|
let b = this.getUID(r.index);
|
|
4012
|
-
(
|
|
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;
|
|
4013
4071
|
}
|
|
4014
|
-
const
|
|
4015
|
-
|
|
4072
|
+
const L = await this.processMaterialAsync(m[D[g].materialIndex]);
|
|
4073
|
+
L !== null && (E.material = L), l.push(E);
|
|
4016
4074
|
}
|
|
4017
4075
|
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(g) {
|
|
4018
4076
|
g.writeMesh && g.writeMesh(t, a);
|
|
@@ -4032,7 +4090,7 @@ class Ne {
|
|
|
4032
4090
|
* @param {THREE.BufferAttribute} attribute
|
|
4033
4091
|
*/
|
|
4034
4092
|
detectMeshQuantization(t, e) {
|
|
4035
|
-
if (this.extensionsUsed[
|
|
4093
|
+
if (this.extensionsUsed[it]) return;
|
|
4036
4094
|
let n;
|
|
4037
4095
|
switch (e.array.constructor) {
|
|
4038
4096
|
case Int8Array:
|
|
@@ -4052,7 +4110,7 @@ class Ne {
|
|
|
4052
4110
|
}
|
|
4053
4111
|
e.normalized && (n += " normalized");
|
|
4054
4112
|
const s = t.split("_", 1)[0];
|
|
4055
|
-
St[s] && St[s].includes(n) && (this.extensionsUsed[
|
|
4113
|
+
St[s] && St[s].includes(n) && (this.extensionsUsed[it] = !0, this.extensionsRequired[it] = !0);
|
|
4056
4114
|
}
|
|
4057
4115
|
/**
|
|
4058
4116
|
* Process camera
|
|
@@ -4072,7 +4130,7 @@ class Ne {
|
|
|
4072
4130
|
znear: t.near < 0 ? 0 : t.near
|
|
4073
4131
|
} : s.perspective = {
|
|
4074
4132
|
aspectRatio: t.aspect,
|
|
4075
|
-
yfov:
|
|
4133
|
+
yfov: at.degToRad(t.fov),
|
|
4076
4134
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4077
4135
|
znear: t.near < 0 ? 0 : t.near
|
|
4078
4136
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4089,28 +4147,28 @@ class Ne {
|
|
|
4089
4147
|
*/
|
|
4090
4148
|
processAnimation(t, e) {
|
|
4091
4149
|
const n = this.json, s = this.nodeMap;
|
|
4092
|
-
n.animations || (n.animations = []), t =
|
|
4150
|
+
n.animations || (n.animations = []), t = et.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4093
4151
|
const i = t.tracks, r = [], o = [];
|
|
4094
4152
|
for (let c = 0; c < i.length; ++c) {
|
|
4095
|
-
const l = i[c], h =
|
|
4096
|
-
let
|
|
4097
|
-
const f =
|
|
4098
|
-
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) {
|
|
4099
4157
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4100
4158
|
continue;
|
|
4101
4159
|
}
|
|
4102
4160
|
const p = 1;
|
|
4103
4161
|
let y = l.values.length / l.times.length;
|
|
4104
|
-
f ===
|
|
4162
|
+
f === Dt.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
|
|
4105
4163
|
let x;
|
|
4106
4164
|
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() === kt ? x = "STEP" : x = "LINEAR", o.push({
|
|
4107
|
-
input: this.processAccessor(new
|
|
4108
|
-
output: this.processAccessor(new
|
|
4165
|
+
input: this.processAccessor(new q(l.times, p)),
|
|
4166
|
+
output: this.processAccessor(new q(l.values, y)),
|
|
4109
4167
|
interpolation: x
|
|
4110
4168
|
}), r.push({
|
|
4111
4169
|
sampler: o.length - 1,
|
|
4112
4170
|
target: {
|
|
4113
|
-
node: s.get(
|
|
4171
|
+
node: s.get(d),
|
|
4114
4172
|
path: f
|
|
4115
4173
|
}
|
|
4116
4174
|
});
|
|
@@ -4135,7 +4193,7 @@ class Ne {
|
|
|
4135
4193
|
for (let h = 0; h < i.bones.length; ++h)
|
|
4136
4194
|
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4137
4195
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
4138
|
-
inverseBindMatrices: this.processAccessor(new
|
|
4196
|
+
inverseBindMatrices: this.processAccessor(new q(a, 16)),
|
|
4139
4197
|
joints: o,
|
|
4140
4198
|
skeleton: n.get(r)
|
|
4141
4199
|
}), s.skin = e.skins.length - 1;
|
|
@@ -4153,7 +4211,7 @@ class Ne {
|
|
|
4153
4211
|
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4154
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);
|
|
4155
4213
|
} else
|
|
4156
|
-
t.matrixAutoUpdate && t.updateMatrix(),
|
|
4214
|
+
t.matrixAutoUpdate && t.updateMatrix(), Re(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4157
4215
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
4158
4216
|
const o = await this.processMeshAsync(t);
|
|
4159
4217
|
o !== null && (i.mesh = o);
|
|
@@ -4230,7 +4288,7 @@ class Ne {
|
|
|
4230
4288
|
await t(this.plugins[e]);
|
|
4231
4289
|
}
|
|
4232
4290
|
}
|
|
4233
|
-
class
|
|
4291
|
+
class Be {
|
|
4234
4292
|
constructor(t) {
|
|
4235
4293
|
this.writer = t, this.name = "KHR_lights_punctual";
|
|
4236
4294
|
}
|
|
@@ -4246,7 +4304,7 @@ class Ce {
|
|
|
4246
4304
|
o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
|
|
4247
4305
|
}
|
|
4248
4306
|
}
|
|
4249
|
-
class
|
|
4307
|
+
class Oe {
|
|
4250
4308
|
constructor(t) {
|
|
4251
4309
|
this.writer = t, this.name = "KHR_materials_unlit";
|
|
4252
4310
|
}
|
|
@@ -4256,7 +4314,7 @@ class Be {
|
|
|
4256
4314
|
e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
4257
4315
|
}
|
|
4258
4316
|
}
|
|
4259
|
-
class
|
|
4317
|
+
class Fe {
|
|
4260
4318
|
constructor(t) {
|
|
4261
4319
|
this.writer = t, this.name = "KHR_materials_clearcoat";
|
|
4262
4320
|
}
|
|
@@ -4287,7 +4345,7 @@ class Oe {
|
|
|
4287
4345
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4288
4346
|
}
|
|
4289
4347
|
}
|
|
4290
|
-
class
|
|
4348
|
+
class Ue {
|
|
4291
4349
|
constructor(t) {
|
|
4292
4350
|
this.writer = t, this.name = "KHR_materials_dispersion";
|
|
4293
4351
|
}
|
|
@@ -4321,7 +4379,7 @@ class Ge {
|
|
|
4321
4379
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4322
4380
|
}
|
|
4323
4381
|
}
|
|
4324
|
-
class
|
|
4382
|
+
class je {
|
|
4325
4383
|
constructor(t) {
|
|
4326
4384
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4327
4385
|
}
|
|
@@ -4355,7 +4413,7 @@ class ze {
|
|
|
4355
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;
|
|
4356
4414
|
}
|
|
4357
4415
|
}
|
|
4358
|
-
class
|
|
4416
|
+
class qe {
|
|
4359
4417
|
constructor(t) {
|
|
4360
4418
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
4361
4419
|
}
|
|
@@ -4389,7 +4447,7 @@ class _e {
|
|
|
4389
4447
|
i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4390
4448
|
}
|
|
4391
4449
|
}
|
|
4392
|
-
class
|
|
4450
|
+
class Ye {
|
|
4393
4451
|
constructor(t) {
|
|
4394
4452
|
this.writer = t, this.name = "KHR_materials_sheen";
|
|
4395
4453
|
}
|
|
@@ -4413,7 +4471,7 @@ class qe {
|
|
|
4413
4471
|
i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4414
4472
|
}
|
|
4415
4473
|
}
|
|
4416
|
-
class
|
|
4474
|
+
class ke {
|
|
4417
4475
|
constructor(t) {
|
|
4418
4476
|
this.writer = t, this.name = "KHR_materials_anisotropy";
|
|
4419
4477
|
}
|
|
@@ -4427,7 +4485,7 @@ class Ye {
|
|
|
4427
4485
|
i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4428
4486
|
}
|
|
4429
4487
|
}
|
|
4430
|
-
class
|
|
4488
|
+
class Xe {
|
|
4431
4489
|
constructor(t) {
|
|
4432
4490
|
this.writer = t, this.name = "KHR_materials_emissive_strength";
|
|
4433
4491
|
}
|
|
@@ -4454,54 +4512,54 @@ class Ve {
|
|
|
4454
4512
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4455
4513
|
}
|
|
4456
4514
|
}
|
|
4457
|
-
class
|
|
4515
|
+
class We {
|
|
4458
4516
|
constructor(t) {
|
|
4459
4517
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
4460
4518
|
}
|
|
4461
4519
|
writeNode(t, e) {
|
|
4462
4520
|
if (!t.isInstancedMesh) return;
|
|
4463
|
-
const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new bt(), c = new
|
|
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();
|
|
4464
4522
|
for (let f = 0; f < s.count; f++)
|
|
4465
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);
|
|
4466
|
-
const
|
|
4467
|
-
TRANSLATION: n.processAccessor(new
|
|
4468
|
-
ROTATION: n.processAccessor(new
|
|
4469
|
-
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))
|
|
4470
4528
|
};
|
|
4471
|
-
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;
|
|
4472
4530
|
}
|
|
4473
4531
|
}
|
|
4474
|
-
|
|
4475
|
-
insertKeyframe: function(
|
|
4476
|
-
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));
|
|
4477
4535
|
let o;
|
|
4478
|
-
if (
|
|
4536
|
+
if (u.times.length === 0) {
|
|
4479
4537
|
s[0] = t;
|
|
4480
4538
|
for (let a = 0; a < n; a++)
|
|
4481
4539
|
i[a] = 0;
|
|
4482
4540
|
o = 0;
|
|
4483
|
-
} else if (t <
|
|
4484
|
-
if (Math.abs(
|
|
4485
|
-
s[0] = t, s.set(
|
|
4486
|
-
} else if (t >
|
|
4487
|
-
if (Math.abs(
|
|
4488
|
-
return
|
|
4489
|
-
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;
|
|
4490
4548
|
} else
|
|
4491
|
-
for (let a = 0; a <
|
|
4492
|
-
if (Math.abs(
|
|
4493
|
-
if (
|
|
4494
|
-
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;
|
|
4495
4553
|
break;
|
|
4496
4554
|
}
|
|
4497
4555
|
}
|
|
4498
|
-
return
|
|
4556
|
+
return u.times = s, u.values = i, o;
|
|
4499
4557
|
},
|
|
4500
|
-
mergeMorphTargetTracks: function(
|
|
4501
|
-
const e = [], n = {}, s =
|
|
4558
|
+
mergeMorphTargetTracks: function(u, t) {
|
|
4559
|
+
const e = [], n = {}, s = u.tracks;
|
|
4502
4560
|
for (let i = 0; i < s.length; ++i) {
|
|
4503
4561
|
let r = s[i];
|
|
4504
|
-
const o =
|
|
4562
|
+
const o = Q.parseTrackName(r.name), a = Q.findNode(t, o.nodeName);
|
|
4505
4563
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
4506
4564
|
e.push(r);
|
|
4507
4565
|
continue;
|
|
@@ -4523,67 +4581,67 @@ tt.Utils = {
|
|
|
4523
4581
|
h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = f, n[a.uuid] = h, e.push(h);
|
|
4524
4582
|
continue;
|
|
4525
4583
|
}
|
|
4526
|
-
const
|
|
4584
|
+
const d = r.createInterpolant(new r.ValueBufferType(1));
|
|
4527
4585
|
h = n[a.uuid];
|
|
4528
4586
|
for (let f = 0; f < h.times.length; f++)
|
|
4529
|
-
h.values[f * c + l] =
|
|
4587
|
+
h.values[f * c + l] = d.evaluate(h.times[f]);
|
|
4530
4588
|
for (let f = 0; f < r.times.length; f++) {
|
|
4531
4589
|
const p = this.insertKeyframe(h, r.times[f]);
|
|
4532
4590
|
h.values[p * c + l] = r.values[f];
|
|
4533
4591
|
}
|
|
4534
4592
|
}
|
|
4535
|
-
return
|
|
4593
|
+
return u.tracks = e, u;
|
|
4536
4594
|
},
|
|
4537
|
-
toFloat32BufferAttribute: function(
|
|
4538
|
-
const t = new
|
|
4539
|
-
if (!
|
|
4540
|
-
return t.array.set(
|
|
4541
|
-
for (let e = 0, n =
|
|
4542
|
-
for (let s = 0; s <
|
|
4543
|
-
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));
|
|
4544
4602
|
return t;
|
|
4545
4603
|
}
|
|
4546
4604
|
};
|
|
4547
|
-
async function
|
|
4605
|
+
async function He(u) {
|
|
4548
4606
|
if (typeof FileReader > "u") {
|
|
4549
|
-
const t = await
|
|
4550
|
-
return `data:${
|
|
4607
|
+
const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
|
|
4608
|
+
return `data:${u.type};base64,${n}`;
|
|
4551
4609
|
} else
|
|
4552
4610
|
return new Promise((t, e) => {
|
|
4553
4611
|
const n = new FileReader();
|
|
4554
|
-
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);
|
|
4555
4613
|
});
|
|
4556
4614
|
}
|
|
4557
|
-
async function
|
|
4558
|
-
if (typeof
|
|
4559
|
-
return await
|
|
4615
|
+
async function ot(u) {
|
|
4616
|
+
if (typeof u.arrayBuffer == "function")
|
|
4617
|
+
return await u.arrayBuffer();
|
|
4560
4618
|
if (typeof FileReader < "u")
|
|
4561
4619
|
return new Promise((t, e) => {
|
|
4562
4620
|
const n = new FileReader();
|
|
4563
|
-
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);
|
|
4564
4622
|
});
|
|
4565
4623
|
{
|
|
4566
|
-
const t = Buffer.from(await
|
|
4624
|
+
const t = Buffer.from(await u.text());
|
|
4567
4625
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4568
4626
|
}
|
|
4569
4627
|
}
|
|
4570
|
-
const
|
|
4571
|
-
function
|
|
4572
|
-
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;
|
|
4573
4631
|
return {
|
|
4574
4632
|
points: [
|
|
4575
4633
|
// 第一条线
|
|
4576
|
-
new M(
|
|
4634
|
+
new M(u.x + r, u.y + o).add(i),
|
|
4577
4635
|
new M(t.x + r, t.y + o).add(s),
|
|
4578
4636
|
// 第二条线
|
|
4579
|
-
new M(
|
|
4637
|
+
new M(u.x - r, u.y - o).add(i),
|
|
4580
4638
|
new M(t.x - r, t.y - o).add(s)
|
|
4581
4639
|
],
|
|
4582
4640
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
4583
4641
|
rectIndices: [0, 1, 3, 2, 0]
|
|
4584
4642
|
};
|
|
4585
4643
|
}
|
|
4586
|
-
class Nt extends
|
|
4644
|
+
class Nt extends _ {
|
|
4587
4645
|
static name = "WhiteModel";
|
|
4588
4646
|
Dxf = null;
|
|
4589
4647
|
Variable = null;
|
|
@@ -4613,7 +4671,7 @@ class Nt extends q {
|
|
|
4613
4671
|
new I.LineSegments(new I.EdgesGeometry(i), new I.LineBasicMaterial({ color: 0 }))
|
|
4614
4672
|
);
|
|
4615
4673
|
}), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
4616
|
-
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);
|
|
4617
4675
|
return {
|
|
4618
4676
|
points: a,
|
|
4619
4677
|
indices: c,
|
|
@@ -4646,7 +4704,7 @@ class Nt extends q {
|
|
|
4646
4704
|
toOBJ() {
|
|
4647
4705
|
return new Promise((t) => {
|
|
4648
4706
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
4649
|
-
t(
|
|
4707
|
+
t(Je.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4650
4708
|
}, 20);
|
|
4651
4709
|
});
|
|
4652
4710
|
}
|
|
@@ -4658,7 +4716,7 @@ class Nt extends q {
|
|
|
4658
4716
|
toGltf(t = !0) {
|
|
4659
4717
|
return new Promise((e) => {
|
|
4660
4718
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
4661
|
-
|
|
4719
|
+
$e.parse(this.whiteModelGroup.children, (n) => {
|
|
4662
4720
|
e(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4663
4721
|
}, () => {
|
|
4664
4722
|
e(void 0);
|
|
@@ -4719,7 +4777,7 @@ class Nt extends q {
|
|
|
4719
4777
|
}
|
|
4720
4778
|
}
|
|
4721
4779
|
}
|
|
4722
|
-
class Ct extends
|
|
4780
|
+
class Ct extends _ {
|
|
4723
4781
|
static name = "DetailsPoint";
|
|
4724
4782
|
Dxf = null;
|
|
4725
4783
|
WhiteModel = null;
|
|
@@ -4796,7 +4854,7 @@ class Ct extends q {
|
|
|
4796
4854
|
}, 50);
|
|
4797
4855
|
}
|
|
4798
4856
|
}
|
|
4799
|
-
class Bt extends
|
|
4857
|
+
class Bt extends _ {
|
|
4800
4858
|
static name = "DxfLineModel";
|
|
4801
4859
|
dxfLineModel = new I.LineSegments();
|
|
4802
4860
|
dxfDoorsLineModel = new I.LineSegments();
|
|
@@ -4819,38 +4877,38 @@ class Bt extends q {
|
|
|
4819
4877
|
});
|
|
4820
4878
|
}
|
|
4821
4879
|
}
|
|
4822
|
-
const
|
|
4880
|
+
const Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4823
4881
|
__proto__: null,
|
|
4824
4882
|
DetailsPoint: Ct,
|
|
4825
4883
|
DxfLineModel: Bt,
|
|
4826
4884
|
WhiteModel: Nt
|
|
4827
4885
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4828
|
-
function Tt(
|
|
4886
|
+
function Tt(u, t = {}) {
|
|
4829
4887
|
const {
|
|
4830
4888
|
detailsPoint: e = !0,
|
|
4831
4889
|
whiteModel: n = !0,
|
|
4832
4890
|
dxfLineModel: s = !0
|
|
4833
4891
|
} = t;
|
|
4834
|
-
s &&
|
|
4892
|
+
s && u.addComponent(new Bt()), n && u.addComponent(new Nt()), e && u.addComponent(new Ct());
|
|
4835
4893
|
}
|
|
4836
|
-
const
|
|
4837
|
-
create(
|
|
4838
|
-
return (t) => Tt(t,
|
|
4894
|
+
const Qe = Object.assign(Tt, {
|
|
4895
|
+
create(u = {}) {
|
|
4896
|
+
return (t) => Tt(t, u);
|
|
4839
4897
|
}
|
|
4840
|
-
}),
|
|
4898
|
+
}), tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4841
4899
|
__proto__: null,
|
|
4842
|
-
ModelDataPlugin:
|
|
4843
|
-
components:
|
|
4900
|
+
ModelDataPlugin: Qe,
|
|
4901
|
+
components: Ze
|
|
4844
4902
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4845
|
-
function
|
|
4903
|
+
function en() {
|
|
4846
4904
|
return import("./index2.js");
|
|
4847
4905
|
}
|
|
4848
|
-
function
|
|
4906
|
+
function nn() {
|
|
4849
4907
|
return import("./index3.js");
|
|
4850
4908
|
}
|
|
4851
4909
|
let dt = null;
|
|
4852
|
-
async function
|
|
4853
|
-
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({
|
|
4854
4912
|
detailsPoint: !1,
|
|
4855
4913
|
whiteModel: !0
|
|
4856
4914
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4860,13 +4918,13 @@ async function ln(d, t, e = !1, n) {
|
|
|
4860
4918
|
orbitControls: e,
|
|
4861
4919
|
camera: t
|
|
4862
4920
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4863
|
-
return a &&
|
|
4921
|
+
return a && u.appendChild(a.domElement), dt = o, {
|
|
4864
4922
|
dxfSystem: o,
|
|
4865
|
-
getFileAll: () =>
|
|
4923
|
+
getFileAll: () => sn(o)
|
|
4866
4924
|
};
|
|
4867
4925
|
}
|
|
4868
|
-
async function
|
|
4869
|
-
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" });
|
|
4870
4928
|
return {
|
|
4871
4929
|
dxf: n,
|
|
4872
4930
|
obj: i,
|
|
@@ -4877,17 +4935,17 @@ async function nn(d = dt) {
|
|
|
4877
4935
|
correctionDxf: s
|
|
4878
4936
|
};
|
|
4879
4937
|
}
|
|
4880
|
-
function
|
|
4938
|
+
function un() {
|
|
4881
4939
|
return dt;
|
|
4882
4940
|
}
|
|
4883
4941
|
export {
|
|
4884
4942
|
Pt as A,
|
|
4885
4943
|
N as B,
|
|
4886
|
-
|
|
4944
|
+
_ as C,
|
|
4887
4945
|
ht as D,
|
|
4888
4946
|
It as E,
|
|
4889
4947
|
A as L,
|
|
4890
|
-
|
|
4948
|
+
Qe as M,
|
|
4891
4949
|
M as P,
|
|
4892
4950
|
F as Q,
|
|
4893
4951
|
Le as T,
|
|
@@ -4895,12 +4953,13 @@ export {
|
|
|
4895
4953
|
Nt as W,
|
|
4896
4954
|
Ct as a,
|
|
4897
4955
|
X as b,
|
|
4898
|
-
|
|
4956
|
+
De as c,
|
|
4899
4957
|
hn as d,
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
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
|
|
4906
4965
|
};
|