build-dxf 0.0.31 → 0.0.32
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 +116 -110
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as G from "three";
|
|
2
|
-
import { EventDispatcher as Ie, Color as Re, Matrix4 as Se, Vector3 as Z, Quaternion as Pe, BufferAttribute as k, REVISION as Ne, CompressedTexture as ne, Source as ve, NoColorSpace as Ce, MathUtils as oe, RGBAFormat as Be, ImageUtils as Oe, DoubleSide as Ge, PropertyBinding as Q, InterpolateDiscrete as
|
|
2
|
+
import { EventDispatcher as Ie, Color as Re, Matrix4 as Se, Vector3 as Z, Quaternion as Pe, BufferAttribute as k, REVISION as Ne, CompressedTexture as ne, Source as ve, NoColorSpace as Ce, MathUtils as oe, RGBAFormat as Be, ImageUtils as Oe, DoubleSide as Ge, PropertyBinding as Q, InterpolateDiscrete as Fe, Scene as ue, SRGBColorSpace as Ue, NearestFilter as _e, NearestMipmapNearestFilter as ze, NearestMipmapLinearFilter as qe, LinearFilter as je, LinearMipmapNearestFilter as Ye, LinearMipmapLinearFilter as Ve, ClampToEdgeWrapping as ke, RepeatWrapping as Xe, MirroredRepeatWrapping as We, InterpolateLinear as He } from "three";
|
|
3
3
|
import de from "clipper-lib";
|
|
4
4
|
import $ from "dxf-writer";
|
|
5
5
|
import { OBJExporter as Je } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
@@ -411,8 +411,8 @@ class _ {
|
|
|
411
411
|
for (let l = 0; l < 4; l++) {
|
|
412
412
|
const c = o[l], h = o[(l + 1) % 4];
|
|
413
413
|
for (let f = 0; f < 4; f++) {
|
|
414
|
-
const u = t[f], p = t[(f + 1) % 4], y = (h.x - c.x) * (u.y - c.y) - (h.y - c.y) * (u.x - c.x), x = (h.x - c.x) * (p.y - c.y) - (h.y - c.y) * (p.x - c.x), S = (p.x - u.x) * (c.y - u.y) - (p.y - u.y) * (c.x - u.x),
|
|
415
|
-
if (y * x < 0 && S *
|
|
414
|
+
const u = t[f], p = t[(f + 1) % 4], y = (h.x - c.x) * (u.y - c.y) - (h.y - c.y) * (u.x - c.x), x = (h.x - c.x) * (p.y - c.y) - (h.y - c.y) * (p.x - c.x), S = (p.x - u.x) * (c.y - u.y) - (p.y - u.y) * (c.x - u.x), b = (p.x - u.x) * (h.y - u.y) - (p.y - u.y) * (h.x - u.x);
|
|
415
|
+
if (y * x < 0 && S * b < 0 || y === 0 && Math.min(c.x, h.x) <= u.x && u.x <= Math.max(c.x, h.x) && Math.min(c.y, h.y) <= u.y && u.y <= Math.max(c.y, h.y) || x === 0 && Math.min(c.x, h.x) <= p.x && p.x <= Math.max(c.x, h.x) && Math.min(c.y, h.y) <= p.y && p.y <= Math.max(c.y, h.y) || S === 0 && Math.min(u.x, p.x) <= c.x && c.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= c.y && c.y <= Math.max(u.y, p.y) || b === 0 && Math.min(u.x, p.x) <= h.x && h.x <= Math.max(u.x, p.x) && Math.min(u.y, p.y) <= h.y && h.y <= Math.max(u.y, p.y))
|
|
416
416
|
return !0;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
@@ -1151,7 +1151,7 @@ class B {
|
|
|
1151
1151
|
if (r.x === 0 && r.y === 0)
|
|
1152
1152
|
throw new Error("投影目标线段的两个点不能重合");
|
|
1153
1153
|
const o = (p) => {
|
|
1154
|
-
const y = new w(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y,
|
|
1154
|
+
const y = new w(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, b = (y.x * r.x + y.y * r.y) / x, C = s.x + b * r.x, m = s.y + b * r.y;
|
|
1155
1155
|
return new w(C, m);
|
|
1156
1156
|
};
|
|
1157
1157
|
let a = o(t), l = o(n);
|
|
@@ -1749,15 +1749,15 @@ class X extends W {
|
|
|
1749
1749
|
break;
|
|
1750
1750
|
}
|
|
1751
1751
|
f.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((m, E) => i(m, E));
|
|
1752
|
-
const p = c.length(), y = f.length(), x = (p ** 2 + y ** 2) / (2 * y), S = f.end.clone().add(f.direction().multiplyScalar(-x)), [
|
|
1753
|
-
r(S, x, Math.min(
|
|
1752
|
+
const p = c.length(), y = f.length(), x = (p ** 2 + y ** 2) / (2 * y), S = f.end.clone().add(f.direction().multiplyScalar(-x)), [b, C] = this.getArcAngleRange(S, c.end, f.end);
|
|
1753
|
+
r(S, x, Math.min(b, C), Math.max(b, C)), a.push(u);
|
|
1754
1754
|
} else
|
|
1755
1755
|
c.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, f) => i(h, f)), c.clone().directionMove(c.normal(), o * 0.5).directionMove(c.direction(), o * 0.5).expansion(-c.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, f) => i(h, f)), c.clone().directionMove(c.normal(), -o * 0.5).directionMove(c.direction(), -o * 0.5).expansion(-c.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, f) => i(h, f));
|
|
1756
1756
|
}), s = "yellow", this.lineSegments.forEach((l) => {
|
|
1757
1757
|
if (!l.userData.isWindow) return !1;
|
|
1758
1758
|
Array.isArray(l.userData.drawWindow) && l.userData.drawWindow.forEach((c) => {
|
|
1759
1759
|
const { p: h, width: f } = c, u = w.from(h), p = u.clone().add(l.direction().multiplyScalar(f * 0.5)), y = u.clone().add(l.direction().multiplyScalar(-f * 0.5)), x = new B(p, y);
|
|
1760
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((S,
|
|
1760
|
+
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((S, b) => i(S, b));
|
|
1761
1761
|
});
|
|
1762
1762
|
}), n;
|
|
1763
1763
|
}
|
|
@@ -1896,20 +1896,20 @@ class X extends W {
|
|
|
1896
1896
|
m.forEach((M) => M.userData.isDoor || M.points.forEach((g) => E.insert(g, M)));
|
|
1897
1897
|
const L = [];
|
|
1898
1898
|
for (let M = 0; M < m.length; M++) {
|
|
1899
|
-
const g = m[M],
|
|
1899
|
+
const g = m[M], D = /* @__PURE__ */ new Map();
|
|
1900
1900
|
g.userData.isDoor || g.points.forEach((T) => {
|
|
1901
1901
|
if (E.queryPoint(T).length > 1) return;
|
|
1902
1902
|
const A = E.queryCircle(T, 0.4).filter((R) => {
|
|
1903
1903
|
const I = R.userData;
|
|
1904
1904
|
if (I === g || !g.parallel(I, 25)) return !1;
|
|
1905
1905
|
if (E.queryPoint(R.point).length > 1) return;
|
|
1906
|
-
const N = new B(T, R.point),
|
|
1907
|
-
if (!N.intersectLineSegment(
|
|
1906
|
+
const N = new B(T, R.point), F = new B(g.start === T ? g.end : g.start, I.start === R.point ? I.end : I.start);
|
|
1907
|
+
if (!N.intersectLineSegment(F)) return !1;
|
|
1908
1908
|
const O = T.distance(R.point);
|
|
1909
|
-
return O < 1e-3 ? !1 : (
|
|
1909
|
+
return O < 1e-3 ? !1 : (D.set(R.point, O), !0);
|
|
1910
1910
|
}).sort((R, I) => {
|
|
1911
|
-
const N =
|
|
1912
|
-
return N -
|
|
1911
|
+
const N = D.get(R.point), F = D.get(I.point);
|
|
1912
|
+
return N - F;
|
|
1913
1913
|
});
|
|
1914
1914
|
if (A.length === 0) return;
|
|
1915
1915
|
const P = A[0].userData;
|
|
@@ -1919,7 +1919,7 @@ class X extends W {
|
|
|
1919
1919
|
return [...m, ...L];
|
|
1920
1920
|
}
|
|
1921
1921
|
function s(m, E) {
|
|
1922
|
-
const L = [m], M = [], g = [],
|
|
1922
|
+
const L = [m], M = [], g = [], D = [];
|
|
1923
1923
|
for (let T = 0; T < E.length; T++) {
|
|
1924
1924
|
const A = E[T];
|
|
1925
1925
|
if (m !== A) {
|
|
@@ -1927,7 +1927,7 @@ class X extends W {
|
|
|
1927
1927
|
g.push(A);
|
|
1928
1928
|
continue;
|
|
1929
1929
|
}
|
|
1930
|
-
if (A.userData.isWindow &&
|
|
1930
|
+
if (A.userData.isWindow && D.push(A), A.parallel(m, 45)) {
|
|
1931
1931
|
const P = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x);
|
|
1932
1932
|
let I = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x) - P;
|
|
1933
1933
|
for (; I > Math.PI; ) I -= 2 * Math.PI;
|
|
@@ -1941,43 +1941,43 @@ class X extends W {
|
|
|
1941
1941
|
for (; I < -Math.PI; ) I += 2 * Math.PI;
|
|
1942
1942
|
for (; N > Math.PI; ) N -= 2 * Math.PI;
|
|
1943
1943
|
for (; N < -Math.PI; ) N += 2 * Math.PI;
|
|
1944
|
-
const
|
|
1945
|
-
A.start.rotate(O,
|
|
1944
|
+
const F = Math.abs(I) < Math.abs(N) ? I : N, O = A.center;
|
|
1945
|
+
A.start.rotate(O, F), A.end.rotate(O, F), M.push(A);
|
|
1946
1946
|
}
|
|
1947
1947
|
}
|
|
1948
1948
|
}
|
|
1949
|
-
return { parallelLines: L, verticalLines: M, doorLines: g, windowLines:
|
|
1949
|
+
return { parallelLines: L, verticalLines: M, doorLines: g, windowLines: D };
|
|
1950
1950
|
}
|
|
1951
1951
|
function i(m, E, L, M = 0.3, g = 0.06) {
|
|
1952
|
-
const
|
|
1952
|
+
const D = [];
|
|
1953
1953
|
m.forEach((P) => {
|
|
1954
1954
|
const R = L.projectPoint(P.start, !1);
|
|
1955
|
-
R && (R.userData = P,
|
|
1956
|
-
}),
|
|
1955
|
+
R && (R.userData = P, D.push(R));
|
|
1956
|
+
}), D.sort((P, R) => R.distance(L.start) - P.distance(L.start));
|
|
1957
1957
|
const T = [], A = [];
|
|
1958
|
-
for (let P = 0; P <
|
|
1959
|
-
const R =
|
|
1958
|
+
for (let P = 0; P < D.length; P++) {
|
|
1959
|
+
const R = D[P];
|
|
1960
1960
|
if (P === 0) {
|
|
1961
1961
|
A.push(R);
|
|
1962
1962
|
continue;
|
|
1963
1963
|
}
|
|
1964
|
-
|
|
1964
|
+
D[P - 1].distance(R) < g || (T.push([...A]), A.length = 0), A.push(R), P === D.length - 1 && T.push(A);
|
|
1965
1965
|
}
|
|
1966
1966
|
return T.flatMap((P) => {
|
|
1967
1967
|
const R = P.flatMap((O) => {
|
|
1968
1968
|
const z = O.userData;
|
|
1969
1969
|
return z.points.map((j) => {
|
|
1970
|
-
const
|
|
1971
|
-
return
|
|
1970
|
+
const U = E.projectPoint(j, !1);
|
|
1971
|
+
return U.userData = z, U;
|
|
1972
1972
|
});
|
|
1973
1973
|
});
|
|
1974
1974
|
R.sort((O, z) => O.distance(E.start) - z.distance(E.start));
|
|
1975
|
-
const I = /* @__PURE__ */ new Map(), N = [],
|
|
1975
|
+
const I = /* @__PURE__ */ new Map(), N = [], F = [];
|
|
1976
1976
|
return R.forEach((O, z) => {
|
|
1977
|
-
I.size === 0 && z > 0 && R[z - 1].distance(O) > M && (N.push([...
|
|
1977
|
+
I.size === 0 && z > 0 && R[z - 1].distance(O) > M && (N.push([...F]), F.length = 0), I.set(O.userData, (I.get(O.userData) ?? 0) + 1);
|
|
1978
1978
|
for (const j of I.values()) if (j !== 2) return;
|
|
1979
|
-
|
|
1980
|
-
}), N.push([...
|
|
1979
|
+
F.push(...I.keys()), I.clear();
|
|
1980
|
+
}), N.push([...F]), N;
|
|
1981
1981
|
});
|
|
1982
1982
|
}
|
|
1983
1983
|
function r(m, E = 0.1) {
|
|
@@ -1985,43 +1985,43 @@ class X extends W {
|
|
|
1985
1985
|
if (L.length === 0) return;
|
|
1986
1986
|
if (L.length === 1) return L[0];
|
|
1987
1987
|
const M = [];
|
|
1988
|
-
L.forEach((
|
|
1989
|
-
M.push(
|
|
1988
|
+
L.forEach((U) => {
|
|
1989
|
+
M.push(U.start.clone(), U.end.clone());
|
|
1990
1990
|
});
|
|
1991
1991
|
const g = L[0].direction().normalize();
|
|
1992
|
-
let
|
|
1993
|
-
M.forEach((
|
|
1994
|
-
const J =
|
|
1995
|
-
|
|
1992
|
+
let D = 1 / 0, T = -1 / 0, A = 0, P = 0;
|
|
1993
|
+
M.forEach((U) => {
|
|
1994
|
+
const J = U.x * g.x + U.y * g.y;
|
|
1995
|
+
D = Math.min(D, J), T = Math.max(T, J), A += U.x, P += U.y;
|
|
1996
1996
|
});
|
|
1997
|
-
const R = new w(A / M.length, P / M.length), I = R.x * g.x + R.y * g.y, N = new w(R.x + (
|
|
1998
|
-
|
|
1999
|
-
const J =
|
|
2000
|
-
|
|
1997
|
+
const R = new w(A / M.length, P / M.length), I = R.x * g.x + R.y * g.y, N = new w(R.x + (D - I) * g.x, R.y + (D - I) * g.y), F = new w(R.x + (T - I) * g.x, R.y + (T - I) * g.y), O = new B(N, F), z = L[0].normal().normalize();
|
|
1998
|
+
D = 1 / 0, T = -1 / 0, M.forEach((U) => {
|
|
1999
|
+
const J = U.x * z.x + U.y * z.y;
|
|
2000
|
+
D = Math.min(D, J), T = Math.max(T, J);
|
|
2001
2001
|
});
|
|
2002
|
-
const j = T -
|
|
2003
|
-
return j >= E && (O.userData.wallWidth = j), L.forEach((
|
|
2002
|
+
const j = T - D;
|
|
2003
|
+
return j >= E && (O.userData.wallWidth = j), L.forEach((U) => U.userData.fittedLine = O), O;
|
|
2004
2004
|
}).filter((L) => !!L);
|
|
2005
2005
|
}
|
|
2006
2006
|
function o(m, E = 0.2) {
|
|
2007
2007
|
const L = new Y(_.fromByLineSegment(...m)), M = /* @__PURE__ */ new Map();
|
|
2008
|
-
m.forEach((
|
|
2009
|
-
M.set(
|
|
2008
|
+
m.forEach((D) => {
|
|
2009
|
+
M.set(D, { line: D, userData: void 0 }), L.insert(M.get(D));
|
|
2010
2010
|
});
|
|
2011
2011
|
const g = new B();
|
|
2012
|
-
for (let
|
|
2013
|
-
const T = m[
|
|
2012
|
+
for (let D = 0; D < m.length; D++) {
|
|
2013
|
+
const T = m[D];
|
|
2014
2014
|
if (T.userData.isAdsorbed) continue;
|
|
2015
2015
|
const A = T.direction().multiplyScalar(E), [P, R] = T.points.map((I) => {
|
|
2016
2016
|
g.set(I, I), g.start.add(A), g.end.add(A.multiplyScalar(-1));
|
|
2017
|
-
const N = /* @__PURE__ */ new Map(),
|
|
2017
|
+
const N = /* @__PURE__ */ new Map(), F = L.queryRect(g.expandToRectangle(0.1, "bothSides")).filter((O) => O.line !== T).map((O) => {
|
|
2018
2018
|
const z = O.line.getIntersection(g);
|
|
2019
2019
|
return N.set(O.line, z), O.line;
|
|
2020
2020
|
}).sort((O, z) => {
|
|
2021
|
-
const j = N.get(O),
|
|
2022
|
-
return j &&
|
|
2021
|
+
const j = N.get(O), U = N.get(z);
|
|
2022
|
+
return j && U ? j.distance(I) - U.distance(I) : 0;
|
|
2023
2023
|
});
|
|
2024
|
-
return
|
|
2024
|
+
return F.length ? N.get(F[0]) : void 0;
|
|
2025
2025
|
});
|
|
2026
2026
|
if (P && R) {
|
|
2027
2027
|
if (P.equal(R)) {
|
|
@@ -2033,23 +2033,23 @@ class X extends W {
|
|
|
2033
2033
|
} else P ? T.start.copy(P) : R && T.end.copy(R);
|
|
2034
2034
|
L.remove(M.get(T)), L.insert(M.get(T));
|
|
2035
2035
|
}
|
|
2036
|
-
return m.filter((
|
|
2036
|
+
return m.filter((D) => D.length() > 1e-3);
|
|
2037
2037
|
}
|
|
2038
2038
|
function a(m) {
|
|
2039
2039
|
for (let E = 0; E < m.length; E++) {
|
|
2040
2040
|
const L = m[E], M = L.userData.fittedLine;
|
|
2041
2041
|
if (M) {
|
|
2042
2042
|
const g = L.direction();
|
|
2043
|
-
M.userData.isWindow = !0, M.userData.drawWindow = M.userData.drawWindow ?? [], L.userData.drawWindow?.forEach((
|
|
2044
|
-
const T = w.from(
|
|
2045
|
-
T.clone().add(g.clone().multiplyScalar(
|
|
2043
|
+
M.userData.isWindow = !0, M.userData.drawWindow = M.userData.drawWindow ?? [], L.userData.drawWindow?.forEach((D) => {
|
|
2044
|
+
const T = w.from(D.p), A = M.projectPoint(
|
|
2045
|
+
T.clone().add(g.clone().multiplyScalar(D.width * 0.5))
|
|
2046
2046
|
), P = M.projectPoint(
|
|
2047
|
-
T.clone().add(g.clone().multiplyScalar(
|
|
2047
|
+
T.clone().add(g.clone().multiplyScalar(D.width * -0.5))
|
|
2048
2048
|
), R = new B(A, P), I = R.center;
|
|
2049
2049
|
M.userData.drawWindow?.push({
|
|
2050
|
-
p: new G.Vector3(I?.x ?? 0, I?.y ?? 0,
|
|
2050
|
+
p: new G.Vector3(I?.x ?? 0, I?.y ?? 0, D.p.z),
|
|
2051
2051
|
width: R.length(),
|
|
2052
|
-
full:
|
|
2052
|
+
full: D.full
|
|
2053
2053
|
});
|
|
2054
2054
|
});
|
|
2055
2055
|
}
|
|
@@ -2060,18 +2060,18 @@ class X extends W {
|
|
|
2060
2060
|
return m.forEach((L) => E.insert({ line: L, userData: void 0 })), m.flatMap((L) => {
|
|
2061
2061
|
const M = E.queryLineSegment(L, !0).map((g) => {
|
|
2062
2062
|
if (g.line === L) return;
|
|
2063
|
-
const
|
|
2064
|
-
if (!(!
|
|
2065
|
-
return
|
|
2063
|
+
const D = g.line.getIntersection(L);
|
|
2064
|
+
if (!(!D || L.start.equal(D) || L.end.equal(D)))
|
|
2065
|
+
return D;
|
|
2066
2066
|
}).filter((g) => !!g);
|
|
2067
2067
|
if (M.length) {
|
|
2068
2068
|
const g = L.clone();
|
|
2069
2069
|
M.sort((T, A) => g.start.distance(T) - g.start.distance(A));
|
|
2070
|
-
const
|
|
2070
|
+
const D = M.map((T) => {
|
|
2071
2071
|
const A = g.clone();
|
|
2072
2072
|
return A.set(g.start.clone(), T), g.start.copy(T), g.userData.isWindow && (A.userData.isWindow = !0, A.userData.drawWindow = g.userData.drawWindow?.filter((P) => A.isPointOnSegment(w.from(P.p))) ?? []), A;
|
|
2073
2073
|
});
|
|
2074
|
-
return g.userData.drawWindow = g.userData.drawWindow?.filter((T) => g.isPointOnSegment(w.from(T.p))) ?? [], [...
|
|
2074
|
+
return g.userData.drawWindow = g.userData.drawWindow?.filter((T) => g.isPointOnSegment(w.from(T.p))) ?? [], [...D, g];
|
|
2075
2075
|
}
|
|
2076
2076
|
return L;
|
|
2077
2077
|
}).filter((L) => L.length() > 0.05);
|
|
@@ -2080,13 +2080,13 @@ class X extends W {
|
|
|
2080
2080
|
const { parallelLines: c, verticalLines: h, doorLines: f, windowLines: u } = s(t, e.map((m) => m.clone())), p = t.normal(), y = t.center, x = t.direction(), S = new B(
|
|
2081
2081
|
y.clone().add(p.clone().multiplyScalar(-1e3)),
|
|
2082
2082
|
y.clone().add(p.clone().multiplyScalar(1e3))
|
|
2083
|
-
),
|
|
2083
|
+
), b = new B(
|
|
2084
2084
|
y.clone().add(x.clone().multiplyScalar(-1e3)),
|
|
2085
2085
|
y.clone().add(x.clone().multiplyScalar(1e3))
|
|
2086
2086
|
);
|
|
2087
2087
|
let C = r([
|
|
2088
|
-
...i.call(this, c,
|
|
2089
|
-
...i.call(this, h, S,
|
|
2088
|
+
...i.call(this, c, b, S),
|
|
2089
|
+
...i.call(this, h, S, b)
|
|
2090
2090
|
]);
|
|
2091
2091
|
return C = o.call(this, C), C = o.call(this, C), a(u), C = l.call(this, C), [...C, ...f];
|
|
2092
2092
|
}
|
|
@@ -2306,14 +2306,14 @@ class Qe {
|
|
|
2306
2306
|
*/
|
|
2307
2307
|
searchNearby(e, t = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2308
2308
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2309
|
-
function o({ point: x, line: S },
|
|
2309
|
+
function o({ point: x, line: S }, b, C) {
|
|
2310
2310
|
const m = S.direction();
|
|
2311
2311
|
S.start === x && m.multiplyScalar(-1);
|
|
2312
2312
|
const E = i.queryCircle(x, n).filter((M) => M.userData !== S).sort((M, g) => M.point.distance(x) - g.point.distance(x)), L = [];
|
|
2313
2313
|
for (let M = 0; M < E.length; M++) {
|
|
2314
|
-
const g = t.findIndex((I) => I.point === E[M].point),
|
|
2315
|
-
if (C.has(`${
|
|
2316
|
-
C.add(`${
|
|
2314
|
+
const g = t.findIndex((I) => I.point === E[M].point), D = e[b].uuid, T = t[g].uuid;
|
|
2315
|
+
if (C.has(`${D}.${T}`)) continue;
|
|
2316
|
+
C.add(`${D}.${T}`), C.add(`${T}.${D}`);
|
|
2317
2317
|
const A = E[M].point, P = new B(x.clone(), A.clone());
|
|
2318
2318
|
if (P.direction().angleBetween(m, "angle") < s) {
|
|
2319
2319
|
const I = e[g].line.direction();
|
|
@@ -2321,41 +2321,41 @@ class Qe {
|
|
|
2321
2321
|
findData: E[M],
|
|
2322
2322
|
findUuid: T,
|
|
2323
2323
|
doorLine: P,
|
|
2324
|
-
doorUuid:
|
|
2324
|
+
doorUuid: D
|
|
2325
2325
|
}));
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
2328
|
return L;
|
|
2329
2329
|
}
|
|
2330
|
-
function a(x, S,
|
|
2330
|
+
function a(x, S, b, C, m) {
|
|
2331
2331
|
C.add(x);
|
|
2332
2332
|
const E = [];
|
|
2333
2333
|
m && E.push(m);
|
|
2334
|
-
for (let L = 0; L <
|
|
2335
|
-
const M =
|
|
2334
|
+
for (let L = 0; L < b.length; L++) {
|
|
2335
|
+
const M = b[L];
|
|
2336
2336
|
if (S.has(M.findUuid)) {
|
|
2337
2337
|
const g = S.get(M.findUuid);
|
|
2338
2338
|
a(M.findUuid, S, g, C, M) && E.push(M);
|
|
2339
2339
|
} else E.push(M);
|
|
2340
2340
|
}
|
|
2341
|
-
return E.sort((L, M) => L.doorLine.length() - M.doorLine.length()), m && E[0] === m ? (
|
|
2341
|
+
return E.sort((L, M) => L.doorLine.length() - M.doorLine.length()), m && E[0] === m ? (b.splice(0), !0) : (b.splice(1), !1);
|
|
2342
2342
|
}
|
|
2343
2343
|
const l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
2344
2344
|
e.map((x, S) => {
|
|
2345
|
-
const
|
|
2346
|
-
|
|
2345
|
+
const b = o(x, S, l);
|
|
2346
|
+
b.length && c.set(x.uuid, b);
|
|
2347
2347
|
}), l.clear();
|
|
2348
2348
|
const h = /* @__PURE__ */ new Map();
|
|
2349
2349
|
c.forEach((x, S) => {
|
|
2350
2350
|
if (!l.has(S) && x.length && a(S, c, x, l), x.length) {
|
|
2351
|
-
const
|
|
2352
|
-
h.has(
|
|
2351
|
+
const b = x[0];
|
|
2352
|
+
h.has(b.doorUuid) || h.set(b.doorUuid, []), h.get(b.doorUuid)?.push(b), h.has(b.findUuid) || h.set(b.findUuid, []), h.get(b.findUuid)?.push(b);
|
|
2353
2353
|
}
|
|
2354
2354
|
});
|
|
2355
2355
|
const f = /* @__PURE__ */ new Set();
|
|
2356
2356
|
h.forEach((x) => {
|
|
2357
2357
|
if (x.length > 1) {
|
|
2358
|
-
x.sort((S,
|
|
2358
|
+
x.sort((S, b) => S.doorLine.length() - b.doorLine.length());
|
|
2359
2359
|
for (let S = 1; S < x.length; S++) f.add(x[S]);
|
|
2360
2360
|
}
|
|
2361
2361
|
});
|
|
@@ -2368,18 +2368,18 @@ class Qe {
|
|
|
2368
2368
|
});
|
|
2369
2369
|
const y = [];
|
|
2370
2370
|
return u.forEach((x) => {
|
|
2371
|
-
const S = e.findIndex((g) => g.uuid === x.doorUuid),
|
|
2371
|
+
const S = e.findIndex((g) => g.uuid === x.doorUuid), b = t.findIndex((g) => g.uuid === x.findUuid), C = e[S].point.clone(), m = t[b].point.clone(), E = this.findLongLineSegment(e[S].line), L = this.findLongLineSegment(t[b].line), M = E.projectPoint(m);
|
|
2372
2372
|
if (M) {
|
|
2373
2373
|
C.copy(M);
|
|
2374
|
-
const g = new B(C, m),
|
|
2375
|
-
(
|
|
2374
|
+
const g = new B(C, m), D = L.includedAngle(g);
|
|
2375
|
+
(D < 10 || D > 170 || Math.abs(90 - D) < 10) && y.push({
|
|
2376
2376
|
start: C,
|
|
2377
2377
|
end: m
|
|
2378
2378
|
});
|
|
2379
2379
|
} else {
|
|
2380
2380
|
const g = L.projectPoint(C);
|
|
2381
2381
|
g && m.copy(g);
|
|
2382
|
-
const
|
|
2382
|
+
const D = new B(C, m), T = E.includedAngle(D);
|
|
2383
2383
|
(T < 10 || T > 170 || Math.abs(90 - T) < 10) && y.push({
|
|
2384
2384
|
start: C,
|
|
2385
2385
|
end: m
|
|
@@ -2520,8 +2520,8 @@ class et extends W {
|
|
|
2520
2520
|
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]);
|
|
2521
2521
|
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / t.width), a = i / o, l = r / o, c = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), f = n.points[0].clone(), u = n.points[1].clone(), p = u.direction(f);
|
|
2522
2522
|
p.multiplyScalar(t.width * 0.5);
|
|
2523
|
-
const y = f.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)), S = f.direction(u),
|
|
2524
|
-
if (!(S.x > 0 &&
|
|
2523
|
+
const y = f.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)), S = f.direction(u), b = y.direction(x);
|
|
2524
|
+
if (!(S.x > 0 && b.x < 0 || S.x < 0 && b.x > 0 || S.y > 0 && b.y < 0 || S.y < 0 && b.y > 0)) {
|
|
2525
2525
|
f.set(y.x, y.y), u.set(x.x, x.y);
|
|
2526
2526
|
for (let C = 1; C < o; C++) {
|
|
2527
2527
|
const m = c.clone().multiplyScalar(a * C), E = h.clone().multiplyScalar(l * C), L = f.clone().add(m), M = u.clone().add(E);
|
|
@@ -2807,7 +2807,7 @@ class ee {
|
|
|
2807
2807
|
}), this.register(function(e) {
|
|
2808
2808
|
return new At(e);
|
|
2809
2809
|
}), this.register(function(e) {
|
|
2810
|
-
return new
|
|
2810
|
+
return new Dt(e);
|
|
2811
2811
|
});
|
|
2812
2812
|
}
|
|
2813
2813
|
register(e) {
|
|
@@ -2969,10 +2969,10 @@ class dt {
|
|
|
2969
2969
|
p.setUint32(0, u.byteLength, !0), p.setUint32(4, at, !0);
|
|
2970
2970
|
const y = ie(ct(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(ge));
|
|
2971
2971
|
x.setUint32(0, y.byteLength, !0), x.setUint32(4, ot, !0);
|
|
2972
|
-
const S = new ArrayBuffer(me),
|
|
2973
|
-
|
|
2972
|
+
const S = new ArrayBuffer(me), b = new DataView(S);
|
|
2973
|
+
b.setUint32(0, it, !0), b.setUint32(4, rt, !0);
|
|
2974
2974
|
const C = me + x.byteLength + y.byteLength + p.byteLength + u.byteLength;
|
|
2975
|
-
|
|
2975
|
+
b.setUint32(8, C, !0);
|
|
2976
2976
|
const m = new Blob([
|
|
2977
2977
|
S,
|
|
2978
2978
|
x,
|
|
@@ -2983,7 +2983,7 @@ class dt {
|
|
|
2983
2983
|
re(m).then((E) => {
|
|
2984
2984
|
t(E);
|
|
2985
2985
|
});
|
|
2986
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
2986
|
+
}) : r.buffers && r.buffers.length > 0 ? bt(l).then((f) => {
|
|
2987
2987
|
r.buffers[0].uri = f, t(r);
|
|
2988
2988
|
}) : t(r);
|
|
2989
2989
|
}
|
|
@@ -3066,7 +3066,7 @@ class dt {
|
|
|
3066
3066
|
async buildMetalRoughTextureAsync(e, t) {
|
|
3067
3067
|
if (e === t) return e;
|
|
3068
3068
|
function n(u) {
|
|
3069
|
-
return u.colorSpace ===
|
|
3069
|
+
return u.colorSpace === Ue ? function(y) {
|
|
3070
3070
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3071
3071
|
} : function(y) {
|
|
3072
3072
|
return y;
|
|
@@ -3407,10 +3407,10 @@ class dt {
|
|
|
3407
3407
|
L[e.morphTargetDictionary[M]] = M;
|
|
3408
3408
|
for (let M = 0; M < e.morphTargetInfluences.length; ++M) {
|
|
3409
3409
|
const g = {};
|
|
3410
|
-
let
|
|
3410
|
+
let D = !1;
|
|
3411
3411
|
for (const T in r.morphAttributes) {
|
|
3412
3412
|
if (T !== "position" && T !== "normal") {
|
|
3413
|
-
|
|
3413
|
+
D || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), D = !0);
|
|
3414
3414
|
continue;
|
|
3415
3415
|
}
|
|
3416
3416
|
const A = r.morphAttributes[T][M], P = T.toUpperCase(), R = r.attributes[T];
|
|
@@ -3420,7 +3420,7 @@ class dt {
|
|
|
3420
3420
|
}
|
|
3421
3421
|
const I = A.clone();
|
|
3422
3422
|
if (!r.morphTargetsRelative)
|
|
3423
|
-
for (let N = 0,
|
|
3423
|
+
for (let N = 0, F = A.count; N < F; N++)
|
|
3424
3424
|
for (let O = 0; O < A.itemSize; O++)
|
|
3425
3425
|
O === 0 && I.setX(N, A.getX(N) - R.getX(N)), O === 1 && I.setY(N, A.getY(N) - R.getY(N)), O === 2 && I.setZ(N, A.getZ(N) - R.getZ(N)), O === 3 && I.setW(N, A.getW(N) - R.getW(N));
|
|
3426
3426
|
g[P] = this.processAccessor(I, r), t.attributes.set(this.getUID(R, !0), g[P]);
|
|
@@ -3438,17 +3438,17 @@ class dt {
|
|
|
3438
3438
|
m[E] = E;
|
|
3439
3439
|
r.setIndex(m), x = !0;
|
|
3440
3440
|
}
|
|
3441
|
-
const S = y ? e.material : [e.material],
|
|
3442
|
-
for (let m = 0, E =
|
|
3441
|
+
const S = y ? e.material : [e.material], b = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
3442
|
+
for (let m = 0, E = b.length; m < E; m++) {
|
|
3443
3443
|
const L = {
|
|
3444
3444
|
mode: o,
|
|
3445
3445
|
attributes: l
|
|
3446
3446
|
};
|
|
3447
3447
|
if (this.serializeUserData(r, L), h.length > 0 && (L.targets = h), r.index !== null) {
|
|
3448
3448
|
let g = this.getUID(r.index);
|
|
3449
|
-
(
|
|
3449
|
+
(b[m].start !== void 0 || b[m].count !== void 0) && (g += ":" + b[m].start + ":" + b[m].count), t.attributes.has(g) ? L.indices = t.attributes.get(g) : (L.indices = this.processAccessor(r.index, r, b[m].start, b[m].count), t.attributes.set(g, L.indices)), L.indices === null && delete L.indices;
|
|
3450
3450
|
}
|
|
3451
|
-
const M = await this.processMaterialAsync(S[
|
|
3451
|
+
const M = await this.processMaterialAsync(S[b[m].materialIndex]);
|
|
3452
3452
|
M !== null && (L.material = M), c.push(L);
|
|
3453
3453
|
}
|
|
3454
3454
|
x === !0 && r.setIndex(null), a.primitives = c, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(m) {
|
|
@@ -3540,7 +3540,7 @@ class dt {
|
|
|
3540
3540
|
let y = c.values.length / c.times.length;
|
|
3541
3541
|
u === ye.morphTargetInfluences && (y /= f.morphTargetInfluences.length);
|
|
3542
3542
|
let x;
|
|
3543
|
-
c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() ===
|
|
3543
|
+
c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() === Fe ? x = "STEP" : x = "LINEAR", o.push({
|
|
3544
3544
|
input: this.processAccessor(new k(c.times, p)),
|
|
3545
3545
|
output: this.processAccessor(new k(c.values, y)),
|
|
3546
3546
|
interpolation: x
|
|
@@ -3891,7 +3891,7 @@ class At {
|
|
|
3891
3891
|
i.bumpFactor = e.bumpScale, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3892
3892
|
}
|
|
3893
3893
|
}
|
|
3894
|
-
class
|
|
3894
|
+
class Dt {
|
|
3895
3895
|
constructor(e) {
|
|
3896
3896
|
this.writer = e, this.name = "EXT_mesh_gpu_instancing";
|
|
3897
3897
|
}
|
|
@@ -3981,9 +3981,15 @@ ee.Utils = {
|
|
|
3981
3981
|
return e;
|
|
3982
3982
|
}
|
|
3983
3983
|
};
|
|
3984
|
-
async function
|
|
3985
|
-
|
|
3986
|
-
|
|
3984
|
+
async function bt(d) {
|
|
3985
|
+
if (typeof FileReader > "u") {
|
|
3986
|
+
const e = await d.arrayBuffer(), n = Buffer.from(e).toString("base64");
|
|
3987
|
+
return `data:${d.type};base64,${n}`;
|
|
3988
|
+
} else
|
|
3989
|
+
return new Promise((e, t) => {
|
|
3990
|
+
const n = new FileReader();
|
|
3991
|
+
n.onload = () => e(n.result), n.onerror = () => t(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(d);
|
|
3992
|
+
});
|
|
3987
3993
|
}
|
|
3988
3994
|
async function re(d) {
|
|
3989
3995
|
if (typeof d.arrayBuffer == "function")
|
|
@@ -4115,7 +4121,7 @@ class Ae extends W {
|
|
|
4115
4121
|
async toGltfBlob(e = !0) {
|
|
4116
4122
|
const t = await this.toGltf(e);
|
|
4117
4123
|
if (t)
|
|
4118
|
-
return new Blob([t], { type: "application/octet-stream" });
|
|
4124
|
+
return e ? new Blob([t], { type: "application/octet-stream" }) : new Blob([JSON.stringify(t)], { type: "application/json" });
|
|
4119
4125
|
}
|
|
4120
4126
|
/**
|
|
4121
4127
|
* 下载 OBJ
|
|
@@ -4150,7 +4156,7 @@ class Ae extends W {
|
|
|
4150
4156
|
}
|
|
4151
4157
|
}
|
|
4152
4158
|
}
|
|
4153
|
-
class
|
|
4159
|
+
class De extends W {
|
|
4154
4160
|
static name = "DetailsPoint";
|
|
4155
4161
|
Dxf = null;
|
|
4156
4162
|
WhiteModel = null;
|
|
@@ -4227,7 +4233,7 @@ class be extends W {
|
|
|
4227
4233
|
}, 50);
|
|
4228
4234
|
}
|
|
4229
4235
|
}
|
|
4230
|
-
class
|
|
4236
|
+
class be extends W {
|
|
4231
4237
|
static name = "DxfLineModel";
|
|
4232
4238
|
dxfLineModel = new G.LineSegments();
|
|
4233
4239
|
dxfDoorsLineModel = new G.LineSegments();
|
|
@@ -4252,8 +4258,8 @@ class De extends W {
|
|
|
4252
4258
|
}
|
|
4253
4259
|
const Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4254
4260
|
__proto__: null,
|
|
4255
|
-
DetailsPoint:
|
|
4256
|
-
DxfLineModel:
|
|
4261
|
+
DetailsPoint: De,
|
|
4262
|
+
DxfLineModel: be,
|
|
4257
4263
|
WhiteModel: Ae
|
|
4258
4264
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4259
4265
|
function Me(d, e = {}) {
|
|
@@ -4262,7 +4268,7 @@ function Me(d, e = {}) {
|
|
|
4262
4268
|
whiteModel: n = !0,
|
|
4263
4269
|
dxfLineModel: s = !0
|
|
4264
4270
|
} = e;
|
|
4265
|
-
s && d.addComponent(new
|
|
4271
|
+
s && d.addComponent(new be()), n && d.addComponent(new Ae()), t && d.addComponent(new De());
|
|
4266
4272
|
}
|
|
4267
4273
|
const vt = Object.assign(Me, {
|
|
4268
4274
|
create(d = {}) {
|
|
@@ -4323,7 +4329,7 @@ export {
|
|
|
4323
4329
|
tt as T,
|
|
4324
4330
|
Ee as V,
|
|
4325
4331
|
Ae as W,
|
|
4326
|
-
|
|
4332
|
+
De as a,
|
|
4327
4333
|
ce as b,
|
|
4328
4334
|
X as c,
|
|
4329
4335
|
qt as d,
|