build-dxf 0.0.20-20 → 0.0.20-22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/src/build.d.ts +2 -0
- package/src/build.js +46 -49
- package/src/index.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "build-dxf",
|
|
3
|
-
"version": "0.0.20-
|
|
3
|
+
"version": "0.0.20-22",
|
|
4
4
|
"description": "线段构建双线墙壁的dxf版本",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"style": "src/index.css",
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@tweenjs/tween.js": ">=25.0.0",
|
|
37
|
+
"build-dxf": "^0.0.20-21",
|
|
36
38
|
"clipper-lib": ">=6.4.2",
|
|
37
39
|
"dxf-writer": ">=1.18.4",
|
|
38
|
-
"
|
|
39
|
-
"vue": ">=3.0.0"
|
|
40
|
-
"obj2gltf": ">=3.1.6"
|
|
40
|
+
"obj2gltf": ">=3.1.6",
|
|
41
|
+
"vue": ">=3.0.0"
|
|
41
42
|
},
|
|
42
43
|
"author": "夏过初秋",
|
|
43
44
|
"license": "ISC"
|
|
44
|
-
}
|
|
45
|
+
}
|
package/src/build.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare function createEditor(dom: HTMLDivElement, camera?: THREE.Camera,
|
|
|
15
15
|
glb: File;
|
|
16
16
|
gltf: File;
|
|
17
17
|
json: File;
|
|
18
|
+
image: File;
|
|
18
19
|
}>;
|
|
19
20
|
}>;
|
|
20
21
|
/**
|
|
@@ -27,6 +28,7 @@ export declare function getFileAll(dxfSystem?: DxfSystem): Promise<{
|
|
|
27
28
|
glb: File;
|
|
28
29
|
gltf: File;
|
|
29
30
|
json: File;
|
|
31
|
+
image: File;
|
|
30
32
|
}>;
|
|
31
33
|
/** 获取全局DxfSystem
|
|
32
34
|
* @returns
|
package/src/build.js
CHANGED
|
@@ -685,7 +685,7 @@ class N {
|
|
|
685
685
|
]);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
|
-
class
|
|
688
|
+
class L {
|
|
689
689
|
points = [new p(), new p()];
|
|
690
690
|
userData = {};
|
|
691
691
|
line;
|
|
@@ -819,8 +819,8 @@ class b {
|
|
|
819
819
|
if (s.x === 0 && s.y === 0)
|
|
820
820
|
throw new Error("投影目标线段的两个点不能重合");
|
|
821
821
|
const r = (m) => {
|
|
822
|
-
const g = new p(m.x - i.x, m.y - i.y), u = s.x * s.x + s.y * s.y, w = (g.x * s.x + g.y * s.y) / u, S = i.x + w * s.x,
|
|
823
|
-
return new p(S,
|
|
822
|
+
const g = new p(m.x - i.x, m.y - i.y), u = s.x * s.x + s.y * s.y, w = (g.x * s.x + g.y * s.y) / u, S = i.x + w * s.x, b = i.y + w * s.y;
|
|
823
|
+
return new p(S, b);
|
|
824
824
|
};
|
|
825
825
|
let c = r(e), a = r(n);
|
|
826
826
|
const h = (m) => {
|
|
@@ -832,7 +832,7 @@ class b {
|
|
|
832
832
|
const g = Math.max(0, Math.min(1, m)), u = i.x + g * s.x, x = i.y + g * s.y;
|
|
833
833
|
return new p(u, x);
|
|
834
834
|
};
|
|
835
|
-
return (l < 0 || l > 1) && (c = f(l)), (d < 0 || d > 1) && (a = f(d)), c.x === a.x && c.y === a.y ? new
|
|
835
|
+
return (l < 0 || l > 1) && (c = f(l)), (d < 0 || d > 1) && (a = f(d)), c.x === a.x && c.y === a.y ? new L(c, c) : new L(c, a);
|
|
836
836
|
}
|
|
837
837
|
/**
|
|
838
838
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -922,7 +922,7 @@ class b {
|
|
|
922
922
|
return !isFinite(s) && !isFinite(c) ? e.x === i.x && n.x === i.x : Math.abs(s - c) < 1e-3 && Math.abs(r - a) < 1e-3;
|
|
923
923
|
}
|
|
924
924
|
clone() {
|
|
925
|
-
const t = new
|
|
925
|
+
const t = new L(
|
|
926
926
|
this.points[0].clone(),
|
|
927
927
|
this.points[1].clone()
|
|
928
928
|
);
|
|
@@ -987,7 +987,7 @@ const st = {
|
|
|
987
987
|
function k(y) {
|
|
988
988
|
const t = [];
|
|
989
989
|
for (let e = 0; e < y.length; e++)
|
|
990
|
-
t.push(new
|
|
990
|
+
t.push(new L(
|
|
991
991
|
y[e].clone(),
|
|
992
992
|
y[(e + 1) % y.length].clone()
|
|
993
993
|
));
|
|
@@ -1056,7 +1056,7 @@ class X extends j {
|
|
|
1056
1056
|
const i = [];
|
|
1057
1057
|
this.data = t.map(({ start: o, end: s, insetionArr: r, isDoor: c = !1, ...a }, h) => {
|
|
1058
1058
|
i.push(o.z ?? 0, s.z ?? 0);
|
|
1059
|
-
const l = new
|
|
1059
|
+
const l = new L(
|
|
1060
1060
|
p.from(o).mutiplyScalar(n),
|
|
1061
1061
|
p.from(s).mutiplyScalar(n)
|
|
1062
1062
|
);
|
|
@@ -1321,20 +1321,20 @@ class X extends j {
|
|
|
1321
1321
|
if (i = "cyan", h.length() < 1.2) {
|
|
1322
1322
|
h.expansion(-r * 0.5);
|
|
1323
1323
|
const l = a.normal();
|
|
1324
|
-
let d = new
|
|
1324
|
+
let d = new L(
|
|
1325
1325
|
h.start.clone(),
|
|
1326
1326
|
h.start.clone().add(l.clone().multiplyScalar(h.length()))
|
|
1327
1327
|
);
|
|
1328
1328
|
const f = d.clone().directionMove(d.normal(), h.length() * -0.5).expandToRectangle(h.length(), "bothSides");
|
|
1329
|
-
for (let
|
|
1330
|
-
if (c[
|
|
1331
|
-
d = new
|
|
1329
|
+
for (let b = 0; b < c.length; b++)
|
|
1330
|
+
if (c[b].intersectRectangle(f)) {
|
|
1331
|
+
d = new L(
|
|
1332
1332
|
h.start.clone(),
|
|
1333
1333
|
h.start.clone().add(l.clone().multiplyScalar(-h.length()))
|
|
1334
1334
|
);
|
|
1335
1335
|
break;
|
|
1336
1336
|
}
|
|
1337
|
-
d.expansion(-r * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((
|
|
1337
|
+
d.expansion(-r * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((b, P) => o(b, P));
|
|
1338
1338
|
const m = h.length(), g = d.length(), u = (m ** 2 + g ** 2) / (2 * g), x = d.end.clone().add(d.direction().multiplyScalar(-u)), [w, S] = this.getArcAngleRange(x, h.end, d.end);
|
|
1339
1339
|
s(x, u, Math.min(w, S), Math.max(w, S)), c.push(f);
|
|
1340
1340
|
} else
|
|
@@ -1342,7 +1342,7 @@ class X extends j {
|
|
|
1342
1342
|
}), i = "yellow", this.lineSegments.forEach((a) => {
|
|
1343
1343
|
if (!a.userData.isWindow) return !1;
|
|
1344
1344
|
Array.isArray(a.userData.drawWindow) && a.userData.drawWindow.forEach((h) => {
|
|
1345
|
-
const { p: l, width: d } = h, f = p.from(l), m = f.clone().add(a.direction().multiplyScalar(d * 0.5)), g = f.clone().add(a.direction().multiplyScalar(-d * 0.5)), u = new
|
|
1345
|
+
const { p: l, width: d } = h, f = p.from(l), m = f.clone().add(a.direction().multiplyScalar(d * 0.5)), g = f.clone().add(a.direction().multiplyScalar(-d * 0.5)), u = new L(m, g);
|
|
1346
1346
|
o(u.start, u.end), u.expandToRectangle(this.width, "bothSides").path2D((x, w) => o(x, w));
|
|
1347
1347
|
});
|
|
1348
1348
|
}), n;
|
|
@@ -1380,11 +1380,7 @@ class X extends j {
|
|
|
1380
1380
|
i.toBlob((a) => {
|
|
1381
1381
|
c(a);
|
|
1382
1382
|
}, e, 1);
|
|
1383
|
-
}) :
|
|
1384
|
-
i.toBuffer((a, h) => {
|
|
1385
|
-
console.error(a), c(h);
|
|
1386
|
-
}, e);
|
|
1387
|
-
});
|
|
1383
|
+
}) : i.toBuffer(e, { quality: 1 });
|
|
1388
1384
|
}
|
|
1389
1385
|
/**
|
|
1390
1386
|
* 将点json结构转换为Dxf string
|
|
@@ -1422,7 +1418,7 @@ class X extends j {
|
|
|
1422
1418
|
* 下载
|
|
1423
1419
|
* @param filename
|
|
1424
1420
|
*/
|
|
1425
|
-
async downloadImage(t, e = "Centimeters", n = "image/
|
|
1421
|
+
async downloadImage(t, e = "Centimeters", n = "image/jpeg") {
|
|
1426
1422
|
const i = await this.toDxfImageBlob(e, n);
|
|
1427
1423
|
if (!i) return !1;
|
|
1428
1424
|
if (typeof window < "u") {
|
|
@@ -1464,7 +1460,7 @@ class X extends j {
|
|
|
1464
1460
|
});
|
|
1465
1461
|
}
|
|
1466
1462
|
}
|
|
1467
|
-
const I = new
|
|
1463
|
+
const I = new L();
|
|
1468
1464
|
class ot extends X {
|
|
1469
1465
|
static name = "AngleCorrectionDxf";
|
|
1470
1466
|
onAddFromParent(t) {
|
|
@@ -1475,7 +1471,7 @@ class ot extends X {
|
|
|
1475
1471
|
const h = e.originalData[a];
|
|
1476
1472
|
if (I.start.copy(h.start), I.end.copy(h.end), h.isVerticalReferenceLine) {
|
|
1477
1473
|
const [l, d] = h.start.y < h.end.y ? [I.start, I.end] : [I.end, I.start];
|
|
1478
|
-
i = -new
|
|
1474
|
+
i = -new L(l, d).direction().angleBetween(new p(0, 1), "angle", "360"), o = null;
|
|
1479
1475
|
break;
|
|
1480
1476
|
}
|
|
1481
1477
|
(!o || I.length() > o.length()) && (o = I.clone(), o.userData.index = a);
|
|
@@ -1483,7 +1479,7 @@ class ot extends X {
|
|
|
1483
1479
|
if (o) {
|
|
1484
1480
|
e.originalData[o.userData.index].isVerticalReferenceLine = !0;
|
|
1485
1481
|
const [a, h] = o.start.y < o.end.y ? [o.start, o.end] : [o.end, o.start];
|
|
1486
|
-
i = -new
|
|
1482
|
+
i = -new L(a, h).direction().angleBetween(new p(0, 1), "angle", "360");
|
|
1487
1483
|
}
|
|
1488
1484
|
const s = e.originalBox.center, r = p.zero(), c = e.originalData.map((a) => {
|
|
1489
1485
|
const h = r.copy(a.start).division(s).rotate(p.zero(), i * (Math.PI / 180)).toJson(a.start.z), l = r.copy(a.end).division(s).rotate(p.zero(), i * (Math.PI / 180)).toJson(a.end.z), d = Object.assign(O(a), { start: h, end: l });
|
|
@@ -1874,11 +1870,11 @@ class rt {
|
|
|
1874
1870
|
);
|
|
1875
1871
|
const c = [];
|
|
1876
1872
|
return r.forEach((a) => {
|
|
1877
|
-
const h = new
|
|
1873
|
+
const h = new L(a?.start, a?.end), l = h.length();
|
|
1878
1874
|
if (l < n) return;
|
|
1879
1875
|
const d = h.normal(), f = h.direction(), m = (l - s.width * 2) / 2;
|
|
1880
1876
|
for (let g = 0; g < 3; g++) {
|
|
1881
|
-
const u = h.start.clone().add(f.clone().multiplyScalar(s.width + m * g)), x = new
|
|
1877
|
+
const u = h.start.clone().add(f.clone().multiplyScalar(s.width + m * g)), x = new L(
|
|
1882
1878
|
u,
|
|
1883
1879
|
u.clone().add(d.clone().multiplyScalar(1))
|
|
1884
1880
|
);
|
|
@@ -1928,7 +1924,7 @@ class rt {
|
|
|
1928
1924
|
});
|
|
1929
1925
|
} else if (s.doorDirectConnection) {
|
|
1930
1926
|
this.continueFind = !1;
|
|
1931
|
-
const r = new
|
|
1927
|
+
const r = new L(p.from(s.start), p.from(s.end));
|
|
1932
1928
|
r.userData = {
|
|
1933
1929
|
doorDirectConnection: !0,
|
|
1934
1930
|
isDoor: !0
|
|
@@ -1959,15 +1955,15 @@ class rt {
|
|
|
1959
1955
|
searchNearby(t, e = [], n = this.doorSearchDistance, i = this.doorSearchNearAngle) {
|
|
1960
1956
|
const o = this.findPointVirtualGrid, s = this.quadtree;
|
|
1961
1957
|
function r({ point: u, line: x }, w, S) {
|
|
1962
|
-
const
|
|
1963
|
-
x.start === u &&
|
|
1958
|
+
const b = x.direction();
|
|
1959
|
+
x.start === u && b.multiplyScalar(-1);
|
|
1964
1960
|
const P = o.queryCircle(u, n).filter((D) => D.userData !== x).sort((D, E) => D.point.distance(u) - E.point.distance(u)), A = [];
|
|
1965
1961
|
for (let D = 0; D < P.length; D++) {
|
|
1966
1962
|
const E = e.findIndex((T) => T.point === P[D].point), B = t[w].uuid, Y = e[E].uuid;
|
|
1967
1963
|
if (S.has(`${B}.${Y}`)) continue;
|
|
1968
1964
|
S.add(`${B}.${Y}`), S.add(`${Y}.${B}`);
|
|
1969
|
-
const Q = P[D].point, C = new
|
|
1970
|
-
if (C.direction().angleBetween(
|
|
1965
|
+
const Q = P[D].point, C = new L(u.clone(), Q.clone());
|
|
1966
|
+
if (C.direction().angleBetween(b, "angle") < i) {
|
|
1971
1967
|
const T = t[E].line.direction();
|
|
1972
1968
|
P[D].userData.start.equal(P[D].point) && T.multiplyScalar(-1), C.direction().multiplyScalar(-1).angleBetween(T, "angle") < i && (s.queryLineSegment(C).length || A.push({
|
|
1973
1969
|
findData: P[D],
|
|
@@ -1979,10 +1975,10 @@ class rt {
|
|
|
1979
1975
|
}
|
|
1980
1976
|
return A;
|
|
1981
1977
|
}
|
|
1982
|
-
function c(u, x, w, S,
|
|
1978
|
+
function c(u, x, w, S, b) {
|
|
1983
1979
|
S.add(u);
|
|
1984
1980
|
const P = [];
|
|
1985
|
-
|
|
1981
|
+
b && P.push(b);
|
|
1986
1982
|
for (let A = 0; A < w.length; A++) {
|
|
1987
1983
|
const D = w[A];
|
|
1988
1984
|
if (x.has(D.findUuid)) {
|
|
@@ -1990,7 +1986,7 @@ class rt {
|
|
|
1990
1986
|
c(D.findUuid, x, E, S, D) && P.push(D);
|
|
1991
1987
|
} else P.push(D);
|
|
1992
1988
|
}
|
|
1993
|
-
return P.sort((A, D) => A.doorLine.length() - D.doorLine.length()),
|
|
1989
|
+
return P.sort((A, D) => A.doorLine.length() - D.doorLine.length()), b && P[0] === b ? (w.splice(0), !0) : (w.splice(1), !1);
|
|
1994
1990
|
}
|
|
1995
1991
|
const a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
|
|
1996
1992
|
t.map((u, x) => {
|
|
@@ -2020,21 +2016,21 @@ class rt {
|
|
|
2020
2016
|
});
|
|
2021
2017
|
const g = [];
|
|
2022
2018
|
return f.forEach((u) => {
|
|
2023
|
-
const x = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), S = t[x].point.clone(),
|
|
2019
|
+
const x = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), S = t[x].point.clone(), b = e[w].point.clone(), P = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[w].line), D = P.projectPoint(b);
|
|
2024
2020
|
if (D) {
|
|
2025
2021
|
S.copy(D);
|
|
2026
|
-
const E = new
|
|
2022
|
+
const E = new L(S, b), B = A.includedAngle(E);
|
|
2027
2023
|
(B < 10 || B > 170 || Math.abs(90 - B) < 10) && g.push({
|
|
2028
2024
|
start: S,
|
|
2029
|
-
end:
|
|
2025
|
+
end: b
|
|
2030
2026
|
});
|
|
2031
2027
|
} else {
|
|
2032
2028
|
const E = A.projectPoint(S);
|
|
2033
|
-
E &&
|
|
2034
|
-
const B = new
|
|
2029
|
+
E && b.copy(E);
|
|
2030
|
+
const B = new L(S, b), Y = P.includedAngle(B);
|
|
2035
2031
|
(Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && g.push({
|
|
2036
2032
|
start: S,
|
|
2037
|
-
end:
|
|
2033
|
+
end: b
|
|
2038
2034
|
});
|
|
2039
2035
|
}
|
|
2040
2036
|
}), e.splice(
|
|
@@ -2055,7 +2051,7 @@ class rt {
|
|
|
2055
2051
|
searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2056
2052
|
const i = this.quadtree, o = e.direction();
|
|
2057
2053
|
e.start === t && o.multiplyScalar(-1);
|
|
2058
|
-
const s = t.clone().add(o.clone().multiplyScalar(n)), r = new
|
|
2054
|
+
const s = t.clone().add(o.clone().multiplyScalar(n)), r = new L(t.clone(), s), c = i.queryLineSegment(r).map((a) => ({
|
|
2059
2055
|
point: a.line.getIntersection(r),
|
|
2060
2056
|
line: a.line
|
|
2061
2057
|
})).filter((a) => a.point).sort((a, h) => t.distance(a.point) - t.distance(h.point));
|
|
@@ -2082,7 +2078,7 @@ class rt {
|
|
|
2082
2078
|
break;
|
|
2083
2079
|
}
|
|
2084
2080
|
}
|
|
2085
|
-
const h = new
|
|
2081
|
+
const h = new L(t.clone(), t.clone().add(r.multiplyScalar(n))), l = o.queryLineSegment(h).map((d) => ({
|
|
2086
2082
|
point: d.line.getIntersection(h),
|
|
2087
2083
|
line: d.line
|
|
2088
2084
|
})).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
|
|
@@ -2162,7 +2158,7 @@ class at extends j {
|
|
|
2162
2158
|
*/
|
|
2163
2159
|
addData(t, e) {
|
|
2164
2160
|
const n = this.Dxf;
|
|
2165
|
-
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new
|
|
2161
|
+
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new L(t.clone(), e.clone()));
|
|
2166
2162
|
}
|
|
2167
2163
|
/** 结果分析创建矩形
|
|
2168
2164
|
* @param result
|
|
@@ -2176,7 +2172,7 @@ class at extends j {
|
|
|
2176
2172
|
if (!(x.x > 0 && w.x < 0 || x.x < 0 && w.x > 0 || x.y > 0 && w.y < 0 || x.y < 0 && w.y > 0)) {
|
|
2177
2173
|
d.set(g.x, g.y), f.set(u.x, u.y);
|
|
2178
2174
|
for (let S = 1; S < r; S++) {
|
|
2179
|
-
const
|
|
2175
|
+
const b = h.clone().multiplyScalar(c * S), P = l.clone().multiplyScalar(a * S), A = d.clone().add(b), D = f.clone().add(P);
|
|
2180
2176
|
this.addData(A, D);
|
|
2181
2177
|
}
|
|
2182
2178
|
}
|
|
@@ -2587,13 +2583,14 @@ async function Et(y, t, e = !1, n) {
|
|
|
2587
2583
|
};
|
|
2588
2584
|
}
|
|
2589
2585
|
async function yt(y = V) {
|
|
2590
|
-
const t = y.findComponentByName("WhiteModel"), e = new File([y.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }),
|
|
2586
|
+
const t = y.findComponentByName("WhiteModel"), e = new File([await y.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([y.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), s = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), r = new File([JSON.stringify(y.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
2591
2587
|
return {
|
|
2592
|
-
dxf:
|
|
2593
|
-
obj:
|
|
2594
|
-
glb:
|
|
2595
|
-
gltf:
|
|
2596
|
-
json:
|
|
2588
|
+
dxf: n,
|
|
2589
|
+
obj: i,
|
|
2590
|
+
glb: o,
|
|
2591
|
+
gltf: s,
|
|
2592
|
+
json: r,
|
|
2593
|
+
image: e
|
|
2597
2594
|
};
|
|
2598
2595
|
}
|
|
2599
2596
|
function At() {
|
|
@@ -2604,7 +2601,7 @@ export {
|
|
|
2604
2601
|
j as C,
|
|
2605
2602
|
ct as D,
|
|
2606
2603
|
$ as E,
|
|
2607
|
-
|
|
2604
|
+
L,
|
|
2608
2605
|
ft as M,
|
|
2609
2606
|
p as P,
|
|
2610
2607
|
q as Q,
|