build-dxf 0.0.20-16 → 0.0.20-18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/build.js +16 -12
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -1376,11 +1376,15 @@ class X extends j {
|
|
|
1376
1376
|
let [a, h, l, d] = c;
|
|
1377
1377
|
const f = Math.min(h, d), m = Math.max(h, d), g = (i.width * 0.5 - 0.4 * n.scale) * (a < 0 ? -1 : 1), u = (m - f) * 0.45;
|
|
1378
1378
|
r.fillStyle = "#fff", r.font = `${0.15 * n.scale}px Arial`, r.textAlign = "center", r.textBaseline = "middle", r.fillText((m - f).toFixed(2) + "cm", g, f + (m - f) * 0.5), r.moveTo(g - 0.1 * n.scale, f), r.lineTo(g + 0.1 * n.scale, f), r.moveTo(g, f), r.lineTo(g, u + f), r.moveTo(g, m), r.lineTo(g, m - u), r.moveTo(g - 0.1 * n.scale, m), r.lineTo(g + 0.1 * n.scale, m);
|
|
1379
|
-
}), r.closePath(), r.strokeStyle = "#fff", r.stroke(),
|
|
1379
|
+
}), r.closePath(), r.strokeStyle = "#fff", r.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
1380
1380
|
i.toBlob((a) => {
|
|
1381
1381
|
c(a);
|
|
1382
1382
|
}, e, 1);
|
|
1383
|
-
}) :
|
|
1383
|
+
}) : new Promise((c) => {
|
|
1384
|
+
i.toBuffer((a, h) => {
|
|
1385
|
+
console.error(a), c(h);
|
|
1386
|
+
}, e);
|
|
1387
|
+
});
|
|
1384
1388
|
}
|
|
1385
1389
|
/**
|
|
1386
1390
|
* 将点json结构转换为Dxf string
|
|
@@ -1424,7 +1428,7 @@ class X extends j {
|
|
|
1424
1428
|
if (typeof window < "u") {
|
|
1425
1429
|
const o = document.createElement("a");
|
|
1426
1430
|
o.href = URL.createObjectURL(i), o.download = t, o.click();
|
|
1427
|
-
} else typeof global < "u"
|
|
1431
|
+
} else typeof global < "u" ? (await G("fs", !1)).writeFileSync(t, i) : console.error("图片下载失败");
|
|
1428
1432
|
return !0;
|
|
1429
1433
|
}
|
|
1430
1434
|
/**
|
|
@@ -1959,17 +1963,17 @@ class rt {
|
|
|
1959
1963
|
x.start === u && L.multiplyScalar(-1);
|
|
1960
1964
|
const P = o.queryCircle(u, n).filter((D) => D.userData !== x).sort((D, E) => D.point.distance(u) - E.point.distance(u)), A = [];
|
|
1961
1965
|
for (let D = 0; D < P.length; D++) {
|
|
1962
|
-
const E = e.findIndex((T) => T.point === P[D].point),
|
|
1963
|
-
if (S.has(`${
|
|
1964
|
-
S.add(`${
|
|
1966
|
+
const E = e.findIndex((T) => T.point === P[D].point), B = t[w].uuid, Y = e[E].uuid;
|
|
1967
|
+
if (S.has(`${B}.${Y}`)) continue;
|
|
1968
|
+
S.add(`${B}.${Y}`), S.add(`${Y}.${B}`);
|
|
1965
1969
|
const Q = P[D].point, C = new b(u.clone(), Q.clone());
|
|
1966
1970
|
if (C.direction().angleBetween(L, "angle") < i) {
|
|
1967
1971
|
const T = t[E].line.direction();
|
|
1968
1972
|
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({
|
|
1969
1973
|
findData: P[D],
|
|
1970
|
-
findUuid:
|
|
1974
|
+
findUuid: Y,
|
|
1971
1975
|
doorLine: C,
|
|
1972
|
-
doorUuid:
|
|
1976
|
+
doorUuid: B
|
|
1973
1977
|
}));
|
|
1974
1978
|
}
|
|
1975
1979
|
}
|
|
@@ -2019,16 +2023,16 @@ class rt {
|
|
|
2019
2023
|
const x = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), S = t[x].point.clone(), L = e[w].point.clone(), P = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[w].line), D = P.projectPoint(L);
|
|
2020
2024
|
if (D) {
|
|
2021
2025
|
S.copy(D);
|
|
2022
|
-
const E = new b(S, L),
|
|
2023
|
-
(
|
|
2026
|
+
const E = new b(S, L), B = A.includedAngle(E);
|
|
2027
|
+
(B < 10 || B > 170 || Math.abs(90 - B) < 10) && g.push({
|
|
2024
2028
|
start: S,
|
|
2025
2029
|
end: L
|
|
2026
2030
|
});
|
|
2027
2031
|
} else {
|
|
2028
2032
|
const E = A.projectPoint(S);
|
|
2029
2033
|
E && L.copy(E);
|
|
2030
|
-
const
|
|
2031
|
-
(
|
|
2034
|
+
const B = new b(S, L), Y = P.includedAngle(B);
|
|
2035
|
+
(Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && g.push({
|
|
2032
2036
|
start: S,
|
|
2033
2037
|
end: L
|
|
2034
2038
|
});
|