build-dxf 0.0.30 → 0.0.31
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 +701 -662
- package/src/index.js +1 -1
- package/src/index3.js +509 -503
- package/src/utils/DxfSystem/components/Dxf.d.ts +8 -4
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorrection.d.ts +3 -3
- package/src/utils/DxfSystem/plugin/Editor/components/RenderManager.d.ts +6 -1
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/components/WhiteModel.d.ts +1 -1
- package/src/utils/Quadtree/LineSegment.d.ts +7 -8
package/src/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { EventDispatcher as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { OBJExporter as
|
|
6
|
-
function
|
|
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 Ue, Scene as ue, SRGBColorSpace as Fe, 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
|
+
import de from "clipper-lib";
|
|
4
|
+
import $ from "dxf-writer";
|
|
5
|
+
import { OBJExporter as Je } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
+
function ae() {
|
|
7
7
|
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(d) {
|
|
8
8
|
var e = Math.random() * 16 | 0, t = d == "x" ? e : e & 3 | 8;
|
|
9
9
|
return t.toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
class
|
|
13
|
-
uuid =
|
|
12
|
+
class Le extends Ie {
|
|
13
|
+
uuid = ae();
|
|
14
14
|
addEventListener(e, t, n) {
|
|
15
15
|
const { once: s = !1 } = n ?? {}, i = (o) => {
|
|
16
16
|
t(o), s && r();
|
|
@@ -30,7 +30,7 @@ class we extends Le {
|
|
|
30
30
|
t && (t.forEach((n) => n()), this.eventRecordStack.delete(e));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class W extends Le {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...e) {
|
|
@@ -48,7 +48,7 @@ class j extends we {
|
|
|
48
48
|
this.destroyed = !0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
class Ke extends Le {
|
|
52
52
|
static EventType = {
|
|
53
53
|
ADD_COMPONENT: "addComponent"
|
|
54
54
|
};
|
|
@@ -71,7 +71,7 @@ class He extends we {
|
|
|
71
71
|
* @param component
|
|
72
72
|
*/
|
|
73
73
|
removeComponent(e) {
|
|
74
|
-
if (e instanceof
|
|
74
|
+
if (e instanceof W) {
|
|
75
75
|
const t = this.components.indexOf(e);
|
|
76
76
|
t > -1 && (this.components.splice(t, 1), this.dispatchEvent({
|
|
77
77
|
type: "removeComponent",
|
|
@@ -116,7 +116,7 @@ class He extends we {
|
|
|
116
116
|
return t || null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class w {
|
|
120
120
|
x;
|
|
121
121
|
y;
|
|
122
122
|
get X() {
|
|
@@ -233,7 +233,7 @@ class S {
|
|
|
233
233
|
*/
|
|
234
234
|
normal(e) {
|
|
235
235
|
const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n), i = -n / s, r = t / s;
|
|
236
|
-
return new
|
|
236
|
+
return new w(i, r);
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
239
|
* 获取由传入的点到该点的单位方向向量
|
|
@@ -243,7 +243,7 @@ class S {
|
|
|
243
243
|
*/
|
|
244
244
|
direction(e) {
|
|
245
245
|
const t = this.x - e.x, n = this.y - e.y, s = Math.sqrt(t * t + n * n);
|
|
246
|
-
return s === 0 ? new
|
|
246
|
+
return s === 0 ? new w(0, 0) : new w(t / s, n / s);
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
249
|
* 计算模长
|
|
@@ -301,7 +301,7 @@ class S {
|
|
|
301
301
|
* @returns
|
|
302
302
|
*/
|
|
303
303
|
clone() {
|
|
304
|
-
return new
|
|
304
|
+
return new w(this.x, this.y);
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* 克隆
|
|
@@ -318,23 +318,23 @@ class S {
|
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
static from(e) {
|
|
321
|
-
return Array.isArray(e) ? new
|
|
321
|
+
return Array.isArray(e) ? new w(e[0], e[1]) : "x" in e && "y" in e ? new w(e.x, e.y) : "X" in e && "Y" in e ? new w(e.X, e.Y) : this.zero();
|
|
322
322
|
}
|
|
323
323
|
static zero() {
|
|
324
|
-
return new
|
|
324
|
+
return new w(0, 0);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
class
|
|
327
|
+
class _ {
|
|
328
328
|
minX = 0;
|
|
329
329
|
maxX = 0;
|
|
330
330
|
minY = 0;
|
|
331
331
|
maxY = 0;
|
|
332
332
|
get points() {
|
|
333
333
|
return [
|
|
334
|
-
new
|
|
335
|
-
new
|
|
336
|
-
new
|
|
337
|
-
new
|
|
334
|
+
new w(this.minX, this.minY),
|
|
335
|
+
new w(this.maxX, this.minY),
|
|
336
|
+
new w(this.maxX, this.maxY),
|
|
337
|
+
new w(this.minX, this.maxY)
|
|
338
338
|
];
|
|
339
339
|
}
|
|
340
340
|
get width() {
|
|
@@ -344,7 +344,7 @@ class U {
|
|
|
344
344
|
return this.maxY - this.minY;
|
|
345
345
|
}
|
|
346
346
|
get center() {
|
|
347
|
-
return new
|
|
347
|
+
return new w(
|
|
348
348
|
this.minX + (this.maxX - this.minX) * 0.5,
|
|
349
349
|
this.minY + (this.maxY - this.minY) * 0.5
|
|
350
350
|
);
|
|
@@ -411,8 +411,8 @@ class U {
|
|
|
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),
|
|
415
|
-
if (y * x < 0 &&
|
|
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), D = (p.x - u.x) * (h.y - u.y) - (p.y - u.y) * (h.x - u.x);
|
|
415
|
+
if (y * x < 0 && S * D < 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) || D === 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
|
}
|
|
@@ -507,7 +507,7 @@ class U {
|
|
|
507
507
|
* @returns
|
|
508
508
|
*/
|
|
509
509
|
clone() {
|
|
510
|
-
return new
|
|
510
|
+
return new _(this.minX, this.maxX, this.minY, this.maxY);
|
|
511
511
|
}
|
|
512
512
|
/**
|
|
513
513
|
*
|
|
@@ -518,7 +518,7 @@ class U {
|
|
|
518
518
|
const t = [], n = [];
|
|
519
519
|
return e.forEach((s) => {
|
|
520
520
|
t.push(s.x), n.push(s.y);
|
|
521
|
-
}), new
|
|
521
|
+
}), new _(
|
|
522
522
|
Math.min(...t),
|
|
523
523
|
Math.max(...t),
|
|
524
524
|
Math.min(...n),
|
|
@@ -536,7 +536,7 @@ class U {
|
|
|
536
536
|
s?.points?.forEach((i) => {
|
|
537
537
|
t.push(i.x), n.push(i.y);
|
|
538
538
|
});
|
|
539
|
-
}), new
|
|
539
|
+
}), new _(
|
|
540
540
|
Math.min(...t),
|
|
541
541
|
Math.max(...t),
|
|
542
542
|
Math.min(...n),
|
|
@@ -544,7 +544,7 @@ class U {
|
|
|
544
544
|
);
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
class
|
|
547
|
+
class ce {
|
|
548
548
|
map = /* @__PURE__ */ new Map();
|
|
549
549
|
gridSize;
|
|
550
550
|
constructor(e = 2) {
|
|
@@ -594,7 +594,7 @@ class re {
|
|
|
594
594
|
*/
|
|
595
595
|
decodeGridId(e) {
|
|
596
596
|
const [t, n] = e.split(".").map(Number);
|
|
597
|
-
return new
|
|
597
|
+
return new w(t, n);
|
|
598
598
|
}
|
|
599
599
|
/**
|
|
600
600
|
* 查询与矩形相交的点
|
|
@@ -619,7 +619,7 @@ class re {
|
|
|
619
619
|
* @returns 相交的节点数组
|
|
620
620
|
*/
|
|
621
621
|
queryCircle(e, t) {
|
|
622
|
-
const n = new
|
|
622
|
+
const n = new _(e.x - t, e.x + t, e.y - t, e.y + t), s = Math.ceil(n.minX / this.gridSize), i = Math.ceil(n.maxX / this.gridSize), r = Math.ceil(n.minY / this.gridSize), o = Math.ceil(n.maxY / this.gridSize), a = [];
|
|
623
623
|
for (let l = s; l <= i; l++)
|
|
624
624
|
for (let c = r; c <= o; c++) {
|
|
625
625
|
const h = `${l}.${c}`;
|
|
@@ -665,7 +665,7 @@ class re {
|
|
|
665
665
|
return e.userData.pointVirtualGrid && e.userData.pointVirtualGrid.target ? e.userData.pointVirtualGrid.target : null;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
class
|
|
668
|
+
class te {
|
|
669
669
|
points;
|
|
670
670
|
get p0() {
|
|
671
671
|
return this.points[0];
|
|
@@ -688,7 +688,7 @@ class Z {
|
|
|
688
688
|
path2D(e) {
|
|
689
689
|
return this.points.flatMap((t, n) => {
|
|
690
690
|
const s = this.points[(n + 1) % this.points.length];
|
|
691
|
-
return e && e(new
|
|
691
|
+
return e && e(new w(t.x, t.y), new w(s.x, s.y)), [t.x, t.y, s.x, s.y];
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
createGeometry() {
|
|
@@ -806,7 +806,7 @@ class Z {
|
|
|
806
806
|
let e = 1 / 0, t = -1 / 0, n = 1 / 0, s = -1 / 0;
|
|
807
807
|
return this.points.forEach((i) => {
|
|
808
808
|
t = Math.max(i.x, t), e = Math.min(i.x, e), s = Math.max(i.x, s), n = Math.min(i.x, n);
|
|
809
|
-
}), new
|
|
809
|
+
}), new _(e, t, n, s);
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
*
|
|
@@ -815,16 +815,16 @@ class Z {
|
|
|
815
815
|
* @returns
|
|
816
816
|
*/
|
|
817
817
|
static fromByLineSegment(e, t = 0.1, n = !1, s = 0.5) {
|
|
818
|
-
const i = e.points[0], r = e.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(t * s) :
|
|
819
|
-
return new
|
|
820
|
-
new
|
|
821
|
-
new
|
|
822
|
-
new
|
|
823
|
-
new
|
|
818
|
+
const i = e.points[0], r = e.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(t * s) : w.zero(), l = n ? i.direction(r).mutiplyScalar(t * s) : w.zero(), c = o.x * t * 0.5, h = o.y * t * 0.5;
|
|
819
|
+
return new te([
|
|
820
|
+
new w(i.x + c, i.y + h).add(l),
|
|
821
|
+
new w(r.x + c, r.y + h).add(a),
|
|
822
|
+
new w(r.x - c, r.y - h).add(a),
|
|
823
|
+
new w(i.x - c, i.y - h).add(l)
|
|
824
824
|
]);
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
|
-
class
|
|
827
|
+
class Y {
|
|
828
828
|
bounds;
|
|
829
829
|
// 包围盒
|
|
830
830
|
capacity;
|
|
@@ -890,23 +890,23 @@ class z {
|
|
|
890
890
|
if (!this.isLeaf) return;
|
|
891
891
|
this.isLeaf = !1, this.children = [];
|
|
892
892
|
const e = (this.bounds.minX + this.bounds.maxX) / 2, t = (this.bounds.minY + this.bounds.maxY) / 2;
|
|
893
|
-
this.children[0] = new
|
|
894
|
-
new
|
|
893
|
+
this.children[0] = new Y(
|
|
894
|
+
new _(this.bounds.minX, e, this.bounds.minY, t),
|
|
895
895
|
this.capacity,
|
|
896
896
|
this.maxDepth,
|
|
897
897
|
this.depth + 1
|
|
898
|
-
), this.children[1] = new
|
|
899
|
-
new
|
|
898
|
+
), this.children[1] = new Y(
|
|
899
|
+
new _(e, this.bounds.maxX, this.bounds.minY, t),
|
|
900
900
|
this.capacity,
|
|
901
901
|
this.maxDepth,
|
|
902
902
|
this.depth + 1
|
|
903
|
-
), this.children[2] = new
|
|
904
|
-
new
|
|
903
|
+
), this.children[2] = new Y(
|
|
904
|
+
new _(this.bounds.minX, e, t, this.bounds.maxY),
|
|
905
905
|
this.capacity,
|
|
906
906
|
this.maxDepth,
|
|
907
907
|
this.depth + 1
|
|
908
|
-
), this.children[3] = new
|
|
909
|
-
new
|
|
908
|
+
), this.children[3] = new Y(
|
|
909
|
+
new _(e, this.bounds.maxX, t, this.bounds.maxY),
|
|
910
910
|
this.capacity,
|
|
911
911
|
this.maxDepth,
|
|
912
912
|
this.depth + 1
|
|
@@ -935,7 +935,7 @@ class z {
|
|
|
935
935
|
* @returns 相交的节点数组
|
|
936
936
|
*/
|
|
937
937
|
queryCircle(e, t) {
|
|
938
|
-
const n = [], s = new
|
|
938
|
+
const n = [], s = new _(
|
|
939
939
|
e.x - t,
|
|
940
940
|
e.x + t,
|
|
941
941
|
e.y - t,
|
|
@@ -948,7 +948,7 @@ class z {
|
|
|
948
948
|
let h = ((e.x - r.x) * a + (e.y - r.y) * l) / c;
|
|
949
949
|
h = Math.max(0, Math.min(1, h));
|
|
950
950
|
const f = r.x + h * a, u = r.y + h * l;
|
|
951
|
-
e.distance(new
|
|
951
|
+
e.distance(new w(f, u)) <= t && n.push(i);
|
|
952
952
|
}
|
|
953
953
|
if (!this.isLeaf)
|
|
954
954
|
for (const i of this.children)
|
|
@@ -1000,12 +1000,12 @@ class z {
|
|
|
1000
1000
|
})), e;
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
class
|
|
1004
|
-
points = [new
|
|
1003
|
+
class B {
|
|
1004
|
+
points = [new w(), new w()];
|
|
1005
1005
|
userData = {};
|
|
1006
1006
|
// line: any
|
|
1007
1007
|
get center() {
|
|
1008
|
-
return new
|
|
1008
|
+
return new w(
|
|
1009
1009
|
this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
|
|
1010
1010
|
this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
|
|
1011
1011
|
);
|
|
@@ -1016,7 +1016,7 @@ class P {
|
|
|
1016
1016
|
get end() {
|
|
1017
1017
|
return this.points[1];
|
|
1018
1018
|
}
|
|
1019
|
-
constructor(e = new
|
|
1019
|
+
constructor(e = new w(), t = new w()) {
|
|
1020
1020
|
this.points = [e, t];
|
|
1021
1021
|
}
|
|
1022
1022
|
set(e, t) {
|
|
@@ -1046,6 +1046,15 @@ class P {
|
|
|
1046
1046
|
getSameEndpoint(e) {
|
|
1047
1047
|
return this.start.equal(e.start) ? [this.start, e.start] : this.start.equal(e.end) ? [this.start, e.end] : this.end.equal(e.start) ? [this.end, e.start] : this.end.equal(e.end) ? [this.end, e.end] : null;
|
|
1048
1048
|
}
|
|
1049
|
+
/**
|
|
1050
|
+
* 判断一个点是否在当前线段上(包含端点)
|
|
1051
|
+
* @param point 要判断的点
|
|
1052
|
+
* @returns 如果点在当前线段上则返回 true,否则返回 false
|
|
1053
|
+
*/
|
|
1054
|
+
isPointOnSegment(e) {
|
|
1055
|
+
const { start: t, end: n } = this, s = (e.y - t.y) * (n.x - t.x) - (e.x - t.x) * (n.y - t.y);
|
|
1056
|
+
return Math.abs(s) > 1e-10 ? !1 : (e.x - t.x) * (e.x - n.x) + (e.y - t.y) * (e.y - n.y) <= 1e-10;
|
|
1057
|
+
}
|
|
1049
1058
|
/**
|
|
1050
1059
|
* 相同端点是否为结束
|
|
1051
1060
|
* @param line
|
|
@@ -1093,15 +1102,15 @@ class P {
|
|
|
1093
1102
|
* @returns {Rectangle}
|
|
1094
1103
|
*/
|
|
1095
1104
|
expandToRectangle(e = 0.1, t = "all") {
|
|
1096
|
-
const n = this.start, s = this.end, i = s.normal(n), r = t === "bothSides" ?
|
|
1105
|
+
const n = this.start, s = this.end, i = s.normal(n), r = t === "bothSides" ? w.zero() : s.direction(n).mutiplyScalar(e * 0.5), o = t === "bothSides" ? w.zero() : n.direction(s).mutiplyScalar(e * 0.5), a = i.x * e * 0.5, l = i.y * e * 0.5, c = [
|
|
1097
1106
|
// 第一条线
|
|
1098
|
-
new
|
|
1099
|
-
new
|
|
1107
|
+
new w(n.x + a, n.y + l).add(o),
|
|
1108
|
+
new w(s.x + a, s.y + l).add(r),
|
|
1100
1109
|
// 第二条线
|
|
1101
|
-
new
|
|
1102
|
-
new
|
|
1110
|
+
new w(n.x - a, n.y - l).add(o),
|
|
1111
|
+
new w(s.x - a, s.y - l).add(r)
|
|
1103
1112
|
];
|
|
1104
|
-
return new
|
|
1113
|
+
return new te([0, 1, 3, 2].map((h) => c[h]));
|
|
1105
1114
|
}
|
|
1106
1115
|
/**
|
|
1107
1116
|
* 计算线段的长度
|
|
@@ -1138,24 +1147,24 @@ class P {
|
|
|
1138
1147
|
projectLineSegment(e) {
|
|
1139
1148
|
if (e.points.length !== 2 || this.points.length !== 2)
|
|
1140
1149
|
throw new Error("每条线段必须由两个点定义");
|
|
1141
|
-
const [t, n] = e.points, [s, i] = this.points, r = new
|
|
1150
|
+
const [t, n] = e.points, [s, i] = this.points, r = new w(i.x - s.x, i.y - s.y);
|
|
1142
1151
|
if (r.x === 0 && r.y === 0)
|
|
1143
1152
|
throw new Error("投影目标线段的两个点不能重合");
|
|
1144
1153
|
const o = (p) => {
|
|
1145
|
-
const y = new
|
|
1146
|
-
return new
|
|
1154
|
+
const y = new w(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, C = s.x + D * r.x, m = s.y + D * r.y;
|
|
1155
|
+
return new w(C, m);
|
|
1147
1156
|
};
|
|
1148
1157
|
let a = o(t), l = o(n);
|
|
1149
1158
|
const c = (p) => {
|
|
1150
|
-
const y = new
|
|
1159
|
+
const y = new w(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y;
|
|
1151
1160
|
return (y.x * r.x + y.y * r.y) / x;
|
|
1152
1161
|
};
|
|
1153
1162
|
let h = c(a), f = c(l);
|
|
1154
1163
|
const u = (p) => {
|
|
1155
|
-
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x,
|
|
1156
|
-
return new
|
|
1164
|
+
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, S = s.y + y * r.y;
|
|
1165
|
+
return new w(x, S);
|
|
1157
1166
|
};
|
|
1158
|
-
return (h < 0 || h > 1) && (a = u(h)), (f < 0 || f > 1) && (l = u(f)), a.x === l.x && a.y === l.y ? new
|
|
1167
|
+
return (h < 0 || h > 1) && (a = u(h)), (f < 0 || f > 1) && (l = u(f)), a.x === l.x && a.y === l.y ? new B(a, a) : new B(a, l);
|
|
1159
1168
|
}
|
|
1160
1169
|
/**
|
|
1161
1170
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -1164,16 +1173,16 @@ class P {
|
|
|
1164
1173
|
* @returns 投影并裁剪后的线段
|
|
1165
1174
|
*/
|
|
1166
1175
|
projectPoint(e, t = !0) {
|
|
1167
|
-
const [n, s] = this.points, i = new
|
|
1176
|
+
const [n, s] = this.points, i = new w(s.x - n.x, s.y - n.y);
|
|
1168
1177
|
if (i.x === 0 && i.y === 0)
|
|
1169
1178
|
throw new Error("投影目标线段的两个点不能重合");
|
|
1170
1179
|
let o = ((c) => {
|
|
1171
|
-
const h = new
|
|
1172
|
-
return new
|
|
1180
|
+
const h = new w(c.x - n.x, c.y - n.y), f = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / f, y = n.x + p * i.x, x = n.y + p * i.y;
|
|
1181
|
+
return new w(y, x);
|
|
1173
1182
|
})(e);
|
|
1174
1183
|
if (!t) return o;
|
|
1175
1184
|
let l = ((c) => {
|
|
1176
|
-
const h = new
|
|
1185
|
+
const h = new w(c.x - n.x, c.y - n.y), f = i.x * i.x + i.y * i.y;
|
|
1177
1186
|
return (h.x * i.x + h.y * i.y) / f;
|
|
1178
1187
|
})(o);
|
|
1179
1188
|
return l < 0 || l > 1 ? null : o;
|
|
@@ -1214,7 +1223,7 @@ class P {
|
|
|
1214
1223
|
if (Math.abs(r) < 1e-10)
|
|
1215
1224
|
return null;
|
|
1216
1225
|
const o = ((t.x - s.x) * (s.y - i.y) - (t.y - s.y) * (s.x - i.x)) / r, a = t.x + o * (n.x - t.x), l = t.y + o * (n.y - t.y);
|
|
1217
|
-
return new
|
|
1226
|
+
return new w(a, l);
|
|
1218
1227
|
}
|
|
1219
1228
|
/**
|
|
1220
1229
|
* 获取两条线段夹角
|
|
@@ -1264,204 +1273,27 @@ class P {
|
|
|
1264
1273
|
return !isFinite(r) && !isFinite(a) ? t.x === s.x && n.x === s.x : Math.abs(r - a) < 1e-3 && Math.abs(o - l) < 1e-3;
|
|
1265
1274
|
}
|
|
1266
1275
|
clone() {
|
|
1267
|
-
const e = new
|
|
1276
|
+
const e = new B(
|
|
1268
1277
|
this.points[0].clone(),
|
|
1269
1278
|
this.points[1].clone()
|
|
1270
1279
|
);
|
|
1271
1280
|
return e.userData = { ...this.userData }, e;
|
|
1272
1281
|
}
|
|
1273
|
-
/**
|
|
1274
|
-
* 轴对齐垂直修正
|
|
1275
|
-
* @param lines 待调整线段组
|
|
1276
|
-
* @param targettLine 轴线段
|
|
1277
|
-
* @returns
|
|
1278
|
-
*/
|
|
1279
|
-
static axisAlignmentCorrection(e, t) {
|
|
1280
|
-
function n(g) {
|
|
1281
|
-
const E = new re();
|
|
1282
|
-
g.forEach((w) => w.userData.isDoor || w.points.forEach((M) => E.insert(M, w)));
|
|
1283
|
-
const A = [];
|
|
1284
|
-
for (let w = 0; w < g.length; w++) {
|
|
1285
|
-
const M = g[w], T = /* @__PURE__ */ new Map();
|
|
1286
|
-
M.userData.isDoor || M.points.forEach((m) => {
|
|
1287
|
-
if (E.queryPoint(m).length > 1) return;
|
|
1288
|
-
const b = E.queryCircle(m, 0.4).filter((D) => {
|
|
1289
|
-
const L = D.userData;
|
|
1290
|
-
if (L === M || !M.parallel(L, 25)) return !1;
|
|
1291
|
-
if (E.queryPoint(D.point).length > 1) return;
|
|
1292
|
-
const I = new P(m, D.point), v = new P(M.start === m ? M.end : M.start, L.start === D.point ? L.end : L.start);
|
|
1293
|
-
if (!I.intersectLineSegment(v)) return !1;
|
|
1294
|
-
const G = m.distance(D.point);
|
|
1295
|
-
return G < 1e-3 ? !1 : (T.set(D.point, G), !0);
|
|
1296
|
-
}).sort((D, L) => {
|
|
1297
|
-
const I = T.get(D.point), v = T.get(L.point);
|
|
1298
|
-
return I - v;
|
|
1299
|
-
});
|
|
1300
|
-
b.length !== 0 && A.push(new P(m.clone(), b[0].point.clone()));
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
return [...g, ...A];
|
|
1304
|
-
}
|
|
1305
|
-
function s(g, E) {
|
|
1306
|
-
const A = [g], w = [], M = [];
|
|
1307
|
-
for (let T = 0; T < E.length; T++) {
|
|
1308
|
-
const m = E[T];
|
|
1309
|
-
if (g !== m) {
|
|
1310
|
-
if (m.userData.isDoor) {
|
|
1311
|
-
M.push(m);
|
|
1312
|
-
continue;
|
|
1313
|
-
}
|
|
1314
|
-
if (m.parallel(g, 45)) {
|
|
1315
|
-
const b = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x);
|
|
1316
|
-
let L = Math.atan2(g.end.y - g.start.y, g.end.x - g.start.x) - b;
|
|
1317
|
-
for (; L > Math.PI; ) L -= 2 * Math.PI;
|
|
1318
|
-
for (; L < -Math.PI; ) L += 2 * Math.PI;
|
|
1319
|
-
const I = m.center;
|
|
1320
|
-
m.start.rotate(I, L), m.end.rotate(I, L), A.push(m);
|
|
1321
|
-
} else {
|
|
1322
|
-
const b = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x), D = Math.atan2(g.end.y - g.start.y, g.end.x - g.start.x);
|
|
1323
|
-
let L = D + Math.PI / 2 - b, I = D - Math.PI / 2 - b;
|
|
1324
|
-
for (; L > Math.PI; ) L -= 2 * Math.PI;
|
|
1325
|
-
for (; L < -Math.PI; ) L += 2 * Math.PI;
|
|
1326
|
-
for (; I > Math.PI; ) I -= 2 * Math.PI;
|
|
1327
|
-
for (; I < -Math.PI; ) I += 2 * Math.PI;
|
|
1328
|
-
const v = Math.abs(L) < Math.abs(I) ? L : I, G = m.center;
|
|
1329
|
-
m.start.rotate(G, v), m.end.rotate(G, v), w.push(m);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
return { parallelLines: A, verticalLines: w, doorLines: M };
|
|
1334
|
-
}
|
|
1335
|
-
function i(g, E, A, w = 0.3, M = 0.06) {
|
|
1336
|
-
const T = [];
|
|
1337
|
-
g.forEach((D) => {
|
|
1338
|
-
const L = A.projectPoint(D.start, !1);
|
|
1339
|
-
L && (L.userData = D, T.push(L));
|
|
1340
|
-
}), T.sort((D, L) => L.distance(A.start) - D.distance(A.start));
|
|
1341
|
-
const m = [], b = [];
|
|
1342
|
-
for (let D = 0; D < T.length; D++) {
|
|
1343
|
-
const L = T[D];
|
|
1344
|
-
if (D === 0) {
|
|
1345
|
-
b.push(L);
|
|
1346
|
-
continue;
|
|
1347
|
-
}
|
|
1348
|
-
T[D - 1].distance(L) < M || (m.push([...b]), b.length = 0), b.push(L), D === T.length - 1 && m.push(b);
|
|
1349
|
-
}
|
|
1350
|
-
return m.flatMap((D) => {
|
|
1351
|
-
const L = D.flatMap((C) => {
|
|
1352
|
-
const N = C.userData;
|
|
1353
|
-
return N.points.map((F) => {
|
|
1354
|
-
const O = E.projectPoint(F, !1);
|
|
1355
|
-
return O.userData = N, O;
|
|
1356
|
-
});
|
|
1357
|
-
});
|
|
1358
|
-
L.sort((C, N) => C.distance(E.start) - N.distance(E.start));
|
|
1359
|
-
const I = /* @__PURE__ */ new Map(), v = [], G = [];
|
|
1360
|
-
return L.forEach((C, N) => {
|
|
1361
|
-
I.size === 0 && N > 0 && L[N - 1].distance(C) > w && (v.push([...G]), G.length = 0), I.set(C.userData, (I.get(C.userData) ?? 0) + 1);
|
|
1362
|
-
for (const F of I.values()) if (F !== 2) return;
|
|
1363
|
-
G.push(...I.keys()), I.clear();
|
|
1364
|
-
}), v.push([...G]), v;
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
function r(g, E = 0.1) {
|
|
1368
|
-
return g.map((A) => {
|
|
1369
|
-
if (A.length === 0) return;
|
|
1370
|
-
if (A.length === 1) return A[0];
|
|
1371
|
-
const w = [];
|
|
1372
|
-
A.forEach((O) => {
|
|
1373
|
-
w.push(O.start.clone(), O.end.clone());
|
|
1374
|
-
});
|
|
1375
|
-
const M = A[0].direction().normalize();
|
|
1376
|
-
let T = 1 / 0, m = -1 / 0, b = 0, D = 0;
|
|
1377
|
-
w.forEach((O) => {
|
|
1378
|
-
const k = O.x * M.x + O.y * M.y;
|
|
1379
|
-
T = Math.min(T, k), m = Math.max(m, k), b += O.x, D += O.y;
|
|
1380
|
-
});
|
|
1381
|
-
const L = new S(b / w.length, D / w.length), I = L.x * M.x + L.y * M.y, v = new S(L.x + (T - I) * M.x, L.y + (T - I) * M.y), G = new S(L.x + (m - I) * M.x, L.y + (m - I) * M.y), C = new P(v, G), N = A[0].normal().normalize();
|
|
1382
|
-
T = 1 / 0, m = -1 / 0, w.forEach((O) => {
|
|
1383
|
-
const k = O.x * N.x + O.y * N.y;
|
|
1384
|
-
T = Math.min(T, k), m = Math.max(m, k);
|
|
1385
|
-
});
|
|
1386
|
-
const F = m - T;
|
|
1387
|
-
return F >= E && (C.userData.wallWidth = F), C;
|
|
1388
|
-
}).filter((A) => !!A);
|
|
1389
|
-
}
|
|
1390
|
-
function o(g, E = 0.2) {
|
|
1391
|
-
const A = new z(U.fromByLineSegment(...g)), w = /* @__PURE__ */ new Map();
|
|
1392
|
-
g.forEach((T) => {
|
|
1393
|
-
w.set(T, { line: T, userData: void 0 }), A.insert(w.get(T));
|
|
1394
|
-
});
|
|
1395
|
-
const M = new P();
|
|
1396
|
-
for (let T = 0; T < g.length; T++) {
|
|
1397
|
-
const m = g[T];
|
|
1398
|
-
if (m.userData.isAdsorbed) continue;
|
|
1399
|
-
const b = m.direction().multiplyScalar(E), [D, L] = m.points.map((I) => {
|
|
1400
|
-
M.set(I, I), M.start.add(b), M.end.add(b.multiplyScalar(-1));
|
|
1401
|
-
const v = /* @__PURE__ */ new Map(), G = A.queryRect(M.expandToRectangle(0.1, "bothSides")).filter((C) => C.line !== m).map((C) => {
|
|
1402
|
-
const N = C.line.getIntersection(M);
|
|
1403
|
-
return v.set(C.line, N), C.line;
|
|
1404
|
-
}).sort((C, N) => {
|
|
1405
|
-
const F = v.get(C), O = v.get(N);
|
|
1406
|
-
return F && O ? F.distance(I) - O.distance(I) : 0;
|
|
1407
|
-
});
|
|
1408
|
-
return G.length ? v.get(G[0]) : void 0;
|
|
1409
|
-
});
|
|
1410
|
-
if (D && L) {
|
|
1411
|
-
if (D.equal(L)) {
|
|
1412
|
-
const I = m.start.distance(D), v = m.end.distance(L);
|
|
1413
|
-
I < v ? m.directionMove(m.start.direction(m.end), I) : m.directionMove(m.end.direction(m.start), v);
|
|
1414
|
-
} else
|
|
1415
|
-
m.start.copy(D), m.end.copy(L);
|
|
1416
|
-
m.userData.isAdsorbed = !0;
|
|
1417
|
-
} else D ? m.start.copy(D) : L && m.end.copy(L);
|
|
1418
|
-
A.remove(w.get(m)), A.insert(w.get(m));
|
|
1419
|
-
}
|
|
1420
|
-
return g.filter((T) => T.length() > 1e-3);
|
|
1421
|
-
}
|
|
1422
|
-
function a(g) {
|
|
1423
|
-
const E = new z(U.fromByLineSegment(...g));
|
|
1424
|
-
return g.forEach((A) => E.insert({ line: A, userData: void 0 })), g.flatMap((A) => {
|
|
1425
|
-
const w = E.queryLineSegment(A, !0).map((M) => {
|
|
1426
|
-
if (M.line === A) return;
|
|
1427
|
-
const T = M.line.getIntersection(A);
|
|
1428
|
-
if (!(!T || A.start.equal(T) || A.end.equal(T)))
|
|
1429
|
-
return T;
|
|
1430
|
-
}).filter((M) => !!M);
|
|
1431
|
-
return w.length ? (A = A.clone(), w.sort((T, m) => A.start.distance(T) - A.start.distance(m)), [...w.map((T) => {
|
|
1432
|
-
const m = A.clone();
|
|
1433
|
-
return m.set(A.start.clone(), T), A.start.copy(T), m;
|
|
1434
|
-
}), A]) : A;
|
|
1435
|
-
}).filter((A) => A.length() > 0.05);
|
|
1436
|
-
}
|
|
1437
|
-
e = n(e);
|
|
1438
|
-
const { parallelLines: l, verticalLines: c } = s(t, e.map((g) => g.clone())), h = t.normal(), f = t.center, u = t.direction(), p = new P(
|
|
1439
|
-
f.clone().add(h.clone().multiplyScalar(-1e3)),
|
|
1440
|
-
f.clone().add(h.clone().multiplyScalar(1e3))
|
|
1441
|
-
), y = new P(
|
|
1442
|
-
f.clone().add(u.clone().multiplyScalar(-1e3)),
|
|
1443
|
-
f.clone().add(u.clone().multiplyScalar(1e3))
|
|
1444
|
-
);
|
|
1445
|
-
let x = r([
|
|
1446
|
-
...i.call(this, l, y, p),
|
|
1447
|
-
...i.call(this, c, p, y)
|
|
1448
|
-
]);
|
|
1449
|
-
return x = o.call(this, x), x = o.call(this, x), x = a.call(this, x), x;
|
|
1450
|
-
}
|
|
1451
1282
|
/**
|
|
1452
1283
|
* 获取最长线段
|
|
1453
1284
|
* @param lines
|
|
1454
1285
|
*/
|
|
1455
|
-
static maxLengthLineIndex(e) {
|
|
1456
|
-
let
|
|
1457
|
-
for (let
|
|
1458
|
-
|
|
1459
|
-
|
|
1286
|
+
static maxLengthLineIndex(e, t) {
|
|
1287
|
+
let n = 0, s = -1;
|
|
1288
|
+
for (let i = 0; i < e.length; i++) {
|
|
1289
|
+
if (t && t(e[i])) continue;
|
|
1290
|
+
const r = e[i].length();
|
|
1291
|
+
r > n && (n = r, s = i);
|
|
1460
1292
|
}
|
|
1461
|
-
return
|
|
1293
|
+
return s;
|
|
1462
1294
|
}
|
|
1463
1295
|
}
|
|
1464
|
-
async function
|
|
1296
|
+
async function H(d, e = !0) {
|
|
1465
1297
|
if (typeof global < "u" && typeof require < "u")
|
|
1466
1298
|
return require(d);
|
|
1467
1299
|
{
|
|
@@ -1472,7 +1304,7 @@ async function V(d, e = !0) {
|
|
|
1472
1304
|
return e && (t = t.default), t;
|
|
1473
1305
|
}
|
|
1474
1306
|
}
|
|
1475
|
-
const
|
|
1307
|
+
const $e = {
|
|
1476
1308
|
Unitless: 1,
|
|
1477
1309
|
// 无单位,1米 = 1(无单位)
|
|
1478
1310
|
Inches: 39.37007874015748,
|
|
@@ -1516,27 +1348,27 @@ const We = {
|
|
|
1516
1348
|
Parsecs: 3240779289666404e-32
|
|
1517
1349
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
1518
1350
|
};
|
|
1519
|
-
function
|
|
1351
|
+
function fe(d) {
|
|
1520
1352
|
const e = [];
|
|
1521
1353
|
for (let t = 0; t < d.length; t++)
|
|
1522
|
-
e.push(new
|
|
1354
|
+
e.push(new B(
|
|
1523
1355
|
d[t].clone(),
|
|
1524
1356
|
d[(t + 1) % d.length].clone()
|
|
1525
1357
|
));
|
|
1526
1358
|
return e;
|
|
1527
1359
|
}
|
|
1528
|
-
function
|
|
1360
|
+
function pe(d) {
|
|
1529
1361
|
return d.flatMap((e, t) => (t === d.length - 1 && [...e.points, d[0].points[0]], [e.points[0]]));
|
|
1530
1362
|
}
|
|
1531
|
-
class X extends
|
|
1363
|
+
class X extends W {
|
|
1532
1364
|
static name = "Dxf";
|
|
1533
1365
|
shortLine = 0.04;
|
|
1534
1366
|
width = 0.04;
|
|
1535
1367
|
scale = 1;
|
|
1536
1368
|
originalData = [];
|
|
1537
1369
|
data = [];
|
|
1538
|
-
originalBox = new
|
|
1539
|
-
box = new
|
|
1370
|
+
originalBox = new _(0, 0, 0, 0);
|
|
1371
|
+
box = new _(0, 0, 0, 0);
|
|
1540
1372
|
pointsGroups = [];
|
|
1541
1373
|
wallsGroup = [];
|
|
1542
1374
|
doors = [];
|
|
@@ -1576,16 +1408,16 @@ class X extends j {
|
|
|
1576
1408
|
const n = [];
|
|
1577
1409
|
let s = -1;
|
|
1578
1410
|
e.forEach(({ start: r, end: o, ...a }, l) => {
|
|
1579
|
-
const c = new
|
|
1580
|
-
|
|
1581
|
-
|
|
1411
|
+
const c = new B(
|
|
1412
|
+
w.from(r),
|
|
1413
|
+
w.from(o)
|
|
1582
1414
|
);
|
|
1583
1415
|
c.userData = a, n.push(c), a.isVerticalReferenceLine && (s = l);
|
|
1584
|
-
}), s === -1 && (s =
|
|
1416
|
+
}), s === -1 && (s = B.maxLengthLineIndex(n, (r) => !r.userData.insetionArr?.length));
|
|
1585
1417
|
const i = n[s];
|
|
1586
1418
|
if (i.userData.isVerticalReferenceLine = !0, e[s].isVerticalReferenceLine = !0, t) {
|
|
1587
|
-
const r =
|
|
1588
|
-
return s =
|
|
1419
|
+
const r = X.axisAlignmentCorrection(n, i);
|
|
1420
|
+
return s = B.maxLengthLineIndex(r, (o) => !o.userData.insetionArr?.length), r[s].userData.isVerticalReferenceLine = !0, {
|
|
1589
1421
|
lineSegments: r,
|
|
1590
1422
|
data: this.lineDataToOriginalData(r)
|
|
1591
1423
|
};
|
|
@@ -1736,7 +1568,7 @@ class X extends j {
|
|
|
1736
1568
|
break;
|
|
1737
1569
|
}
|
|
1738
1570
|
}
|
|
1739
|
-
const t = this.mergeSameDirectionLine(
|
|
1571
|
+
const t = this.mergeSameDirectionLine(fe(e)), n = [t[0]];
|
|
1740
1572
|
for (let s = 1; s < t.length; s++) {
|
|
1741
1573
|
const i = t[s], r = t[(t.length + s - 1) % t.length];
|
|
1742
1574
|
if (i.length() > this.width * 0.9) {
|
|
@@ -1751,7 +1583,7 @@ class X extends j {
|
|
|
1751
1583
|
const a = t[s + 2];
|
|
1752
1584
|
a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
|
|
1753
1585
|
}
|
|
1754
|
-
return n.length > 3 ?
|
|
1586
|
+
return n.length > 3 ? pe(this.mergeSameDirectionLine(n)) : [];
|
|
1755
1587
|
}
|
|
1756
1588
|
/**
|
|
1757
1589
|
* 移除短线段
|
|
@@ -1759,7 +1591,7 @@ class X extends j {
|
|
|
1759
1591
|
* @param path
|
|
1760
1592
|
*/
|
|
1761
1593
|
removeShortLine(e, t = this.shortLine) {
|
|
1762
|
-
const n =
|
|
1594
|
+
const n = fe(e), s = [], i = Math.PI / 180;
|
|
1763
1595
|
for (let r = 0; r < n.length; r++) {
|
|
1764
1596
|
const o = n[r], a = o.length(), l = r;
|
|
1765
1597
|
if (a > t || s.length === 0) {
|
|
@@ -1787,19 +1619,19 @@ class X extends j {
|
|
|
1787
1619
|
} else
|
|
1788
1620
|
r = l;
|
|
1789
1621
|
}
|
|
1790
|
-
return s.length > 3 ?
|
|
1622
|
+
return s.length > 3 ? pe(s) : [];
|
|
1791
1623
|
}
|
|
1792
1624
|
/** 线偏移
|
|
1793
1625
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
1794
1626
|
*/
|
|
1795
1627
|
lineOffset(e = X.EndType.etOpenSquare, t = X.JoinType.jtMiter, n = 1e4) {
|
|
1796
|
-
let s = new
|
|
1797
|
-
const i = new
|
|
1628
|
+
let s = new de.Paths();
|
|
1629
|
+
const i = new de.ClipperOffset(20, 0.25);
|
|
1798
1630
|
return this.pointsGroups.forEach((r) => {
|
|
1799
1631
|
const o = this.lineTopology(r).map((a) => a.map((l) => l.clone().mutiplyScalar(n)));
|
|
1800
1632
|
i.AddPaths(o, t, e);
|
|
1801
1633
|
}), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
|
|
1802
|
-
let o = r.map((a) =>
|
|
1634
|
+
let o = r.map((a) => w.from(a).divisionScalar(n));
|
|
1803
1635
|
return o = this.lineSegmentStraightening(o), e == X.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
|
|
1804
1636
|
}), this.dispatchEvent({
|
|
1805
1637
|
type: "lineOffset",
|
|
@@ -1835,7 +1667,7 @@ class X extends j {
|
|
|
1835
1667
|
* 线段数据转为原始json数据
|
|
1836
1668
|
*/
|
|
1837
1669
|
lineDataToOriginalData(e, t) {
|
|
1838
|
-
return t || (t = new
|
|
1670
|
+
return t || (t = new Y(_.fromByLineSegment(...e)), e.forEach((n) => t?.insert({ line: n, userData: void 0 }))), e.map((n) => {
|
|
1839
1671
|
const s = n.userData, i = s.drawWindow, r = t.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: e.indexOf(o.line) }));
|
|
1840
1672
|
return {
|
|
1841
1673
|
start: n.start.toJson(this.originalZAverage),
|
|
@@ -1859,7 +1691,7 @@ class X extends j {
|
|
|
1859
1691
|
* 转为绘制数据
|
|
1860
1692
|
*/
|
|
1861
1693
|
toDrawDataJson(e = "Millimeters") {
|
|
1862
|
-
const t =
|
|
1694
|
+
const t = $e[e], n = {
|
|
1863
1695
|
unit: e,
|
|
1864
1696
|
line: [],
|
|
1865
1697
|
arc: [],
|
|
@@ -1871,7 +1703,7 @@ class X extends j {
|
|
|
1871
1703
|
};
|
|
1872
1704
|
let s = "white";
|
|
1873
1705
|
function i(l, c) {
|
|
1874
|
-
n.line.push([l.
|
|
1706
|
+
n.line.push([l.x * t, l.y * t, c.x * t, c.y * t, s]);
|
|
1875
1707
|
}
|
|
1876
1708
|
function r(l, c, h, f) {
|
|
1877
1709
|
n.arc.push([
|
|
@@ -1903,29 +1735,29 @@ class X extends j {
|
|
|
1903
1735
|
if (s = "cyan", c.length() < 1.2) {
|
|
1904
1736
|
c.expansion(-o * 0.5);
|
|
1905
1737
|
const h = l.normal();
|
|
1906
|
-
let f = new
|
|
1738
|
+
let f = new B(
|
|
1907
1739
|
c.start.clone(),
|
|
1908
1740
|
c.start.clone().add(h.clone().multiplyScalar(c.length()))
|
|
1909
1741
|
);
|
|
1910
1742
|
const u = f.clone().directionMove(f.normal(), c.length() * -0.5).expandToRectangle(c.length(), "bothSides");
|
|
1911
|
-
for (let
|
|
1912
|
-
if (a[
|
|
1913
|
-
f = new
|
|
1743
|
+
for (let m = 0; m < a.length; m++)
|
|
1744
|
+
if (a[m].intersectRectangle(u)) {
|
|
1745
|
+
f = new B(
|
|
1914
1746
|
c.start.clone(),
|
|
1915
1747
|
c.start.clone().add(h.clone().multiplyScalar(-c.length()))
|
|
1916
1748
|
);
|
|
1917
1749
|
break;
|
|
1918
1750
|
}
|
|
1919
|
-
f.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((
|
|
1920
|
-
const p = c.length(), y = f.length(), x = (p ** 2 + y ** 2) / (2 * y),
|
|
1921
|
-
r(
|
|
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)), [D, C] = this.getArcAngleRange(S, c.end, f.end);
|
|
1753
|
+
r(S, x, Math.min(D, C), Math.max(D, C)), a.push(u);
|
|
1922
1754
|
} else
|
|
1923
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));
|
|
1924
1756
|
}), s = "yellow", this.lineSegments.forEach((l) => {
|
|
1925
1757
|
if (!l.userData.isWindow) return !1;
|
|
1926
1758
|
Array.isArray(l.userData.drawWindow) && l.userData.drawWindow.forEach((c) => {
|
|
1927
|
-
const { p: h, width: f } = c, u =
|
|
1928
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((
|
|
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, D) => i(S, D));
|
|
1929
1761
|
});
|
|
1930
1762
|
}), n;
|
|
1931
1763
|
}
|
|
@@ -1939,7 +1771,7 @@ class X extends j {
|
|
|
1939
1771
|
if (typeof window < "u")
|
|
1940
1772
|
i = document.createElement("canvas");
|
|
1941
1773
|
else if (typeof global < "u") {
|
|
1942
|
-
const { createCanvas: l } = await
|
|
1774
|
+
const { createCanvas: l } = await H("canvas");
|
|
1943
1775
|
i = l();
|
|
1944
1776
|
} else
|
|
1945
1777
|
throw new Error("创建画布失败");
|
|
@@ -1950,14 +1782,14 @@ class X extends j {
|
|
|
1950
1782
|
};
|
|
1951
1783
|
i.width = s.width + r * 2, i.height = s.height + r * 2;
|
|
1952
1784
|
const a = i.getContext("2d");
|
|
1953
|
-
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), s.line.forEach(([l, c, h, f, u]) => {
|
|
1785
|
+
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(([l, c, h, f, u]) => {
|
|
1954
1786
|
a.strokeStyle = o[u], a.beginPath(), a.moveTo(l, c), a.lineTo(h, f), a.closePath(), a.stroke();
|
|
1955
1787
|
}), s.arc.forEach(([l, c, h, f, u, p]) => {
|
|
1956
1788
|
a.strokeStyle = o[p], a.beginPath(), a.arc(l, c, h, f * (Math.PI / 180), u * (Math.PI / 180)), a.stroke();
|
|
1957
1789
|
}), a.beginPath(), s.dimensionLine.forEach((l) => {
|
|
1958
1790
|
let [c, h, f, u] = l;
|
|
1959
|
-
const p = Math.min(h, u), y = Math.max(h, u), x = (i.width * 0.5 - 0.4 * s.scale) * (c < 0 ? -1 : 1),
|
|
1960
|
-
a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.fillText((y - p).toFixed(2) + "cm",
|
|
1791
|
+
const p = Math.min(h, u), y = Math.max(h, u), x = (i.width * 0.5 - 0.4 * s.scale) * (c < 0 ? -1 : 1), S = (y - p) * 0.45;
|
|
1792
|
+
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, S + p), a.moveTo(x, y), a.lineTo(x, y - S), a.moveTo(x - 0.1 * s.scale, y), a.lineTo(x + 0.1 * s.scale, y);
|
|
1961
1793
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((l) => {
|
|
1962
1794
|
i.toBlob((c) => {
|
|
1963
1795
|
l(c);
|
|
@@ -1968,8 +1800,8 @@ class X extends j {
|
|
|
1968
1800
|
* 将点json结构转换为Dxf string
|
|
1969
1801
|
*/
|
|
1970
1802
|
toDxfString(e = "Millimeters") {
|
|
1971
|
-
const t = new
|
|
1972
|
-
t.setUnits(e), t.addLayer("cyan",
|
|
1803
|
+
const t = new $();
|
|
1804
|
+
t.setUnits(e), t.addLayer("cyan", $.ACI.CYAN, "DOTTED"), t.addLayer("yellow", $.ACI.YELLOW, "DOTTED"), t.addLayer("white", $.ACI.WHITE, "DOTTED");
|
|
1973
1805
|
const n = this.toDrawDataJson();
|
|
1974
1806
|
return n.line.forEach((s) => {
|
|
1975
1807
|
let [i, r, o, a, l] = s;
|
|
@@ -1995,7 +1827,7 @@ class X extends j {
|
|
|
1995
1827
|
if (typeof window < "u") {
|
|
1996
1828
|
const n = new Blob([t], { type: "application/json" }), s = document.createElement("a");
|
|
1997
1829
|
s.href = URL.createObjectURL(n), s.download = e, s.click();
|
|
1998
|
-
} else typeof global < "u" && (await
|
|
1830
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, t);
|
|
1999
1831
|
}
|
|
2000
1832
|
/**
|
|
2001
1833
|
* 下载
|
|
@@ -2005,7 +1837,7 @@ class X extends j {
|
|
|
2005
1837
|
if (typeof window < "u") {
|
|
2006
1838
|
const n = this.toDxfBlob(t), s = document.createElement("a");
|
|
2007
1839
|
s.href = URL.createObjectURL(n), s.download = e + ".dxf", s.click();
|
|
2008
|
-
} else typeof global < "u" && (await
|
|
1840
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, this.toDxfString(t));
|
|
2009
1841
|
}
|
|
2010
1842
|
/**
|
|
2011
1843
|
* 下载
|
|
@@ -2017,7 +1849,7 @@ class X extends j {
|
|
|
2017
1849
|
if (typeof window < "u") {
|
|
2018
1850
|
const i = document.createElement("a");
|
|
2019
1851
|
i.href = URL.createObjectURL(s), i.download = e, i.click();
|
|
2020
|
-
} else typeof global < "u" ? (await
|
|
1852
|
+
} else typeof global < "u" ? (await H("fs", !1)).writeFileSync(e, s) : console.error("图片下载失败");
|
|
2021
1853
|
return !0;
|
|
2022
1854
|
}
|
|
2023
1855
|
/**
|
|
@@ -2025,7 +1857,7 @@ class X extends j {
|
|
|
2025
1857
|
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
2026
1858
|
* @returns
|
|
2027
1859
|
*/
|
|
2028
|
-
computedOriginalSize(e, t = new
|
|
1860
|
+
computedOriginalSize(e, t = new _(0, 0, 0, 0)) {
|
|
2029
1861
|
const n = e.flatMap((l) => [l.start.x, l.end.x]), s = e.flatMap((l) => [l.start.y, l.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
|
|
2030
1862
|
return t.set(i, r, o, a), t;
|
|
2031
1863
|
}
|
|
@@ -2052,18 +1884,224 @@ class X extends j {
|
|
|
2052
1884
|
return n += i.length, t || (r.pop(), r[r.length - 1].insetionArr.length = 0, n--), r;
|
|
2053
1885
|
});
|
|
2054
1886
|
}
|
|
1887
|
+
/**
|
|
1888
|
+
* 轴对齐垂直修正
|
|
1889
|
+
* @param lines 待调整线段组
|
|
1890
|
+
* @param targettLine 轴线段
|
|
1891
|
+
* @returns
|
|
1892
|
+
*/
|
|
1893
|
+
static axisAlignmentCorrection(e, t) {
|
|
1894
|
+
function n(m) {
|
|
1895
|
+
const E = new ce();
|
|
1896
|
+
m.forEach((M) => M.userData.isDoor || M.points.forEach((g) => E.insert(g, M)));
|
|
1897
|
+
const L = [];
|
|
1898
|
+
for (let M = 0; M < m.length; M++) {
|
|
1899
|
+
const g = m[M], b = /* @__PURE__ */ new Map();
|
|
1900
|
+
g.userData.isDoor || g.points.forEach((T) => {
|
|
1901
|
+
if (E.queryPoint(T).length > 1) return;
|
|
1902
|
+
const A = E.queryCircle(T, 0.4).filter((R) => {
|
|
1903
|
+
const I = R.userData;
|
|
1904
|
+
if (I === g || !g.parallel(I, 25)) return !1;
|
|
1905
|
+
if (E.queryPoint(R.point).length > 1) return;
|
|
1906
|
+
const N = new B(T, R.point), U = new B(g.start === T ? g.end : g.start, I.start === R.point ? I.end : I.start);
|
|
1907
|
+
if (!N.intersectLineSegment(U)) return !1;
|
|
1908
|
+
const O = T.distance(R.point);
|
|
1909
|
+
return O < 1e-3 ? !1 : (b.set(R.point, O), !0);
|
|
1910
|
+
}).sort((R, I) => {
|
|
1911
|
+
const N = b.get(R.point), U = b.get(I.point);
|
|
1912
|
+
return N - U;
|
|
1913
|
+
});
|
|
1914
|
+
if (A.length === 0) return;
|
|
1915
|
+
const P = A[0].userData;
|
|
1916
|
+
L.push(new B(g.projectLineSegment(P).center, P.projectLineSegment(g).center));
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
return [...m, ...L];
|
|
1920
|
+
}
|
|
1921
|
+
function s(m, E) {
|
|
1922
|
+
const L = [m], M = [], g = [], b = [];
|
|
1923
|
+
for (let T = 0; T < E.length; T++) {
|
|
1924
|
+
const A = E[T];
|
|
1925
|
+
if (m !== A) {
|
|
1926
|
+
if (A.userData.isDoor) {
|
|
1927
|
+
g.push(A);
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
if (A.userData.isWindow && b.push(A), A.parallel(m, 45)) {
|
|
1931
|
+
const P = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x);
|
|
1932
|
+
let I = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x) - P;
|
|
1933
|
+
for (; I > Math.PI; ) I -= 2 * Math.PI;
|
|
1934
|
+
for (; I < -Math.PI; ) I += 2 * Math.PI;
|
|
1935
|
+
const N = A.center;
|
|
1936
|
+
A.start.rotate(N, I), A.end.rotate(N, I), L.push(A);
|
|
1937
|
+
} else {
|
|
1938
|
+
const P = Math.atan2(A.end.y - A.start.y, A.end.x - A.start.x), R = Math.atan2(m.end.y - m.start.y, m.end.x - m.start.x);
|
|
1939
|
+
let I = R + Math.PI / 2 - P, N = R - Math.PI / 2 - P;
|
|
1940
|
+
for (; I > Math.PI; ) I -= 2 * Math.PI;
|
|
1941
|
+
for (; I < -Math.PI; ) I += 2 * Math.PI;
|
|
1942
|
+
for (; N > Math.PI; ) N -= 2 * Math.PI;
|
|
1943
|
+
for (; N < -Math.PI; ) N += 2 * Math.PI;
|
|
1944
|
+
const U = Math.abs(I) < Math.abs(N) ? I : N, O = A.center;
|
|
1945
|
+
A.start.rotate(O, U), A.end.rotate(O, U), M.push(A);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
return { parallelLines: L, verticalLines: M, doorLines: g, windowLines: b };
|
|
1950
|
+
}
|
|
1951
|
+
function i(m, E, L, M = 0.3, g = 0.06) {
|
|
1952
|
+
const b = [];
|
|
1953
|
+
m.forEach((P) => {
|
|
1954
|
+
const R = L.projectPoint(P.start, !1);
|
|
1955
|
+
R && (R.userData = P, b.push(R));
|
|
1956
|
+
}), b.sort((P, R) => R.distance(L.start) - P.distance(L.start));
|
|
1957
|
+
const T = [], A = [];
|
|
1958
|
+
for (let P = 0; P < b.length; P++) {
|
|
1959
|
+
const R = b[P];
|
|
1960
|
+
if (P === 0) {
|
|
1961
|
+
A.push(R);
|
|
1962
|
+
continue;
|
|
1963
|
+
}
|
|
1964
|
+
b[P - 1].distance(R) < g || (T.push([...A]), A.length = 0), A.push(R), P === b.length - 1 && T.push(A);
|
|
1965
|
+
}
|
|
1966
|
+
return T.flatMap((P) => {
|
|
1967
|
+
const R = P.flatMap((O) => {
|
|
1968
|
+
const z = O.userData;
|
|
1969
|
+
return z.points.map((j) => {
|
|
1970
|
+
const F = E.projectPoint(j, !1);
|
|
1971
|
+
return F.userData = z, F;
|
|
1972
|
+
});
|
|
1973
|
+
});
|
|
1974
|
+
R.sort((O, z) => O.distance(E.start) - z.distance(E.start));
|
|
1975
|
+
const I = /* @__PURE__ */ new Map(), N = [], U = [];
|
|
1976
|
+
return R.forEach((O, z) => {
|
|
1977
|
+
I.size === 0 && z > 0 && R[z - 1].distance(O) > M && (N.push([...U]), U.length = 0), I.set(O.userData, (I.get(O.userData) ?? 0) + 1);
|
|
1978
|
+
for (const j of I.values()) if (j !== 2) return;
|
|
1979
|
+
U.push(...I.keys()), I.clear();
|
|
1980
|
+
}), N.push([...U]), N;
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
function r(m, E = 0.1) {
|
|
1984
|
+
return m.map((L) => {
|
|
1985
|
+
if (L.length === 0) return;
|
|
1986
|
+
if (L.length === 1) return L[0];
|
|
1987
|
+
const M = [];
|
|
1988
|
+
L.forEach((F) => {
|
|
1989
|
+
M.push(F.start.clone(), F.end.clone());
|
|
1990
|
+
});
|
|
1991
|
+
const g = L[0].direction().normalize();
|
|
1992
|
+
let b = 1 / 0, T = -1 / 0, A = 0, P = 0;
|
|
1993
|
+
M.forEach((F) => {
|
|
1994
|
+
const J = F.x * g.x + F.y * g.y;
|
|
1995
|
+
b = Math.min(b, J), T = Math.max(T, J), A += F.x, P += F.y;
|
|
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 + (b - I) * g.x, R.y + (b - I) * g.y), U = new w(R.x + (T - I) * g.x, R.y + (T - I) * g.y), O = new B(N, U), z = L[0].normal().normalize();
|
|
1998
|
+
b = 1 / 0, T = -1 / 0, M.forEach((F) => {
|
|
1999
|
+
const J = F.x * z.x + F.y * z.y;
|
|
2000
|
+
b = Math.min(b, J), T = Math.max(T, J);
|
|
2001
|
+
});
|
|
2002
|
+
const j = T - b;
|
|
2003
|
+
return j >= E && (O.userData.wallWidth = j), L.forEach((F) => F.userData.fittedLine = O), O;
|
|
2004
|
+
}).filter((L) => !!L);
|
|
2005
|
+
}
|
|
2006
|
+
function o(m, E = 0.2) {
|
|
2007
|
+
const L = new Y(_.fromByLineSegment(...m)), M = /* @__PURE__ */ new Map();
|
|
2008
|
+
m.forEach((b) => {
|
|
2009
|
+
M.set(b, { line: b, userData: void 0 }), L.insert(M.get(b));
|
|
2010
|
+
});
|
|
2011
|
+
const g = new B();
|
|
2012
|
+
for (let b = 0; b < m.length; b++) {
|
|
2013
|
+
const T = m[b];
|
|
2014
|
+
if (T.userData.isAdsorbed) continue;
|
|
2015
|
+
const A = T.direction().multiplyScalar(E), [P, R] = T.points.map((I) => {
|
|
2016
|
+
g.set(I, I), g.start.add(A), g.end.add(A.multiplyScalar(-1));
|
|
2017
|
+
const N = /* @__PURE__ */ new Map(), U = L.queryRect(g.expandToRectangle(0.1, "bothSides")).filter((O) => O.line !== T).map((O) => {
|
|
2018
|
+
const z = O.line.getIntersection(g);
|
|
2019
|
+
return N.set(O.line, z), O.line;
|
|
2020
|
+
}).sort((O, z) => {
|
|
2021
|
+
const j = N.get(O), F = N.get(z);
|
|
2022
|
+
return j && F ? j.distance(I) - F.distance(I) : 0;
|
|
2023
|
+
});
|
|
2024
|
+
return U.length ? N.get(U[0]) : void 0;
|
|
2025
|
+
});
|
|
2026
|
+
if (P && R) {
|
|
2027
|
+
if (P.equal(R)) {
|
|
2028
|
+
const I = T.start.distance(P), N = T.end.distance(R);
|
|
2029
|
+
I < N ? T.directionMove(T.start.direction(T.end), I) : T.directionMove(T.end.direction(T.start), N);
|
|
2030
|
+
} else
|
|
2031
|
+
T.start.copy(P), T.end.copy(R);
|
|
2032
|
+
T.userData.isAdsorbed = !0;
|
|
2033
|
+
} else P ? T.start.copy(P) : R && T.end.copy(R);
|
|
2034
|
+
L.remove(M.get(T)), L.insert(M.get(T));
|
|
2035
|
+
}
|
|
2036
|
+
return m.filter((b) => b.length() > 1e-3);
|
|
2037
|
+
}
|
|
2038
|
+
function a(m) {
|
|
2039
|
+
for (let E = 0; E < m.length; E++) {
|
|
2040
|
+
const L = m[E], M = L.userData.fittedLine;
|
|
2041
|
+
if (M) {
|
|
2042
|
+
const g = L.direction();
|
|
2043
|
+
M.userData.isWindow = !0, M.userData.drawWindow = M.userData.drawWindow ?? [], L.userData.drawWindow?.forEach((b) => {
|
|
2044
|
+
const T = w.from(b.p), A = M.projectPoint(
|
|
2045
|
+
T.clone().add(g.clone().multiplyScalar(b.width * 0.5))
|
|
2046
|
+
), P = M.projectPoint(
|
|
2047
|
+
T.clone().add(g.clone().multiplyScalar(b.width * -0.5))
|
|
2048
|
+
), R = new B(A, P), I = R.center;
|
|
2049
|
+
M.userData.drawWindow?.push({
|
|
2050
|
+
p: new G.Vector3(I?.x ?? 0, I?.y ?? 0, b.p.z),
|
|
2051
|
+
width: R.length(),
|
|
2052
|
+
full: b.full
|
|
2053
|
+
});
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
function l(m) {
|
|
2059
|
+
const E = new Y(_.fromByLineSegment(...m));
|
|
2060
|
+
return m.forEach((L) => E.insert({ line: L, userData: void 0 })), m.flatMap((L) => {
|
|
2061
|
+
const M = E.queryLineSegment(L, !0).map((g) => {
|
|
2062
|
+
if (g.line === L) return;
|
|
2063
|
+
const b = g.line.getIntersection(L);
|
|
2064
|
+
if (!(!b || L.start.equal(b) || L.end.equal(b)))
|
|
2065
|
+
return b;
|
|
2066
|
+
}).filter((g) => !!g);
|
|
2067
|
+
if (M.length) {
|
|
2068
|
+
const g = L.clone();
|
|
2069
|
+
M.sort((T, A) => g.start.distance(T) - g.start.distance(A));
|
|
2070
|
+
const b = M.map((T) => {
|
|
2071
|
+
const A = g.clone();
|
|
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
|
+
});
|
|
2074
|
+
return g.userData.drawWindow = g.userData.drawWindow?.filter((T) => g.isPointOnSegment(w.from(T.p))) ?? [], [...b, g];
|
|
2075
|
+
}
|
|
2076
|
+
return L;
|
|
2077
|
+
}).filter((L) => L.length() > 0.05);
|
|
2078
|
+
}
|
|
2079
|
+
e = n(e);
|
|
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
|
+
y.clone().add(p.clone().multiplyScalar(-1e3)),
|
|
2082
|
+
y.clone().add(p.clone().multiplyScalar(1e3))
|
|
2083
|
+
), D = new B(
|
|
2084
|
+
y.clone().add(x.clone().multiplyScalar(-1e3)),
|
|
2085
|
+
y.clone().add(x.clone().multiplyScalar(1e3))
|
|
2086
|
+
);
|
|
2087
|
+
let C = r([
|
|
2088
|
+
...i.call(this, c, D, S),
|
|
2089
|
+
...i.call(this, h, S, D)
|
|
2090
|
+
]);
|
|
2091
|
+
return C = o.call(this, C), C = o.call(this, C), a(u), C = l.call(this, C), [...C, ...f];
|
|
2092
|
+
}
|
|
2055
2093
|
}
|
|
2056
|
-
function
|
|
2094
|
+
function le(d) {
|
|
2057
2095
|
if (d === null || typeof d != "object") return d;
|
|
2058
2096
|
if (d instanceof Date) return new Date(d.getTime());
|
|
2059
|
-
if (Array.isArray(d)) return d.map(
|
|
2097
|
+
if (Array.isArray(d)) return d.map(le);
|
|
2060
2098
|
const e = {};
|
|
2061
2099
|
for (const t in d)
|
|
2062
|
-
Object.prototype.hasOwnProperty.call(d, t) && (e[t] =
|
|
2100
|
+
Object.prototype.hasOwnProperty.call(d, t) && (e[t] = le(d[t]));
|
|
2063
2101
|
return e;
|
|
2064
2102
|
}
|
|
2065
|
-
const
|
|
2066
|
-
class
|
|
2103
|
+
const V = new B();
|
|
2104
|
+
class Ze extends X {
|
|
2067
2105
|
static name = "AngleCorrectionDxf";
|
|
2068
2106
|
angle = 0;
|
|
2069
2107
|
onAddFromParent(e) {
|
|
@@ -2074,27 +2112,27 @@ class Je extends X {
|
|
|
2074
2112
|
let s = 0, i = null;
|
|
2075
2113
|
for (let l = 0; l < t.originalData.length; l++) {
|
|
2076
2114
|
const c = t.originalData[l];
|
|
2077
|
-
if (
|
|
2078
|
-
const [h, f] = c.start.y < c.end.y ? [
|
|
2079
|
-
s = -new
|
|
2115
|
+
if (V.start.copy(c.start), V.end.copy(c.end), c.isVerticalReferenceLine) {
|
|
2116
|
+
const [h, f] = c.start.y < c.end.y ? [V.start, V.end] : [V.end, V.start];
|
|
2117
|
+
s = -new B(h, f).direction().angleBetween(new w(0, 1), "angle", "360"), i = null;
|
|
2080
2118
|
break;
|
|
2081
2119
|
}
|
|
2082
|
-
(!i ||
|
|
2120
|
+
(!i || V.length() > i.length()) && (i = V.clone(), i.userData.index = l);
|
|
2083
2121
|
}
|
|
2084
2122
|
if (i) {
|
|
2085
2123
|
t.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
2086
2124
|
const [l, c] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
|
|
2087
|
-
s = -new
|
|
2125
|
+
s = -new B(l, c).direction().angleBetween(new w(0, 1), "angle", "360");
|
|
2088
2126
|
}
|
|
2089
|
-
const r = t.originalBox.center, o =
|
|
2090
|
-
const c = o.copy(l.start).division(r).rotate(
|
|
2127
|
+
const r = t.originalBox.center, o = w.zero(), a = t.originalData.map((l) => {
|
|
2128
|
+
const c = o.copy(l.start).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(l.start.z), h = o.copy(l.end).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(l.end.z), f = Object.assign(le(l), { start: c, end: h });
|
|
2091
2129
|
return f.drawWindow && f.drawWindow.forEach((u) => {
|
|
2092
|
-
u.p = o.copy(u.p).division(r).rotate(
|
|
2130
|
+
u.p = o.copy(u.p).division(r).rotate(w.zero(), s * (Math.PI / 180)).toJson(u.p.z);
|
|
2093
2131
|
}), f;
|
|
2094
2132
|
});
|
|
2095
2133
|
n.appendLineSegmentList.forEach((l) => {
|
|
2096
2134
|
const c = l.clone();
|
|
2097
|
-
c.start.division(r).rotate(
|
|
2135
|
+
c.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), a.push({
|
|
2098
2136
|
start: c.start.toJson(t.originalZAverage),
|
|
2099
2137
|
end: c.end.toJson(t.originalZAverage),
|
|
2100
2138
|
insetionArr: [],
|
|
@@ -2102,13 +2140,13 @@ class Je extends X {
|
|
|
2102
2140
|
});
|
|
2103
2141
|
}), await this.set(a, t.width, t.scale), this.lineOffset(), this.doorLineSegment = t.doorLineSegment.map((l) => {
|
|
2104
2142
|
const c = l.clone();
|
|
2105
|
-
return c.start.division(r).rotate(
|
|
2143
|
+
return c.start.division(r).rotate(w.zero(), s * (Math.PI / 180)), c.end.division(r).rotate(w.zero(), s * (Math.PI / 180)), c;
|
|
2106
2144
|
}), this.angle = s, this.dispatchEvent({
|
|
2107
2145
|
type: "updateData"
|
|
2108
2146
|
});
|
|
2109
2147
|
}
|
|
2110
2148
|
}
|
|
2111
|
-
class
|
|
2149
|
+
class Ee extends W {
|
|
2112
2150
|
static name = "Variable";
|
|
2113
2151
|
originalLineVisible = !0;
|
|
2114
2152
|
dxfVisible = !0;
|
|
@@ -2135,13 +2173,13 @@ class Me extends j {
|
|
|
2135
2173
|
if (e in this) return this[e];
|
|
2136
2174
|
}
|
|
2137
2175
|
}
|
|
2138
|
-
class
|
|
2176
|
+
class Qe {
|
|
2139
2177
|
// 所有可查找的点位
|
|
2140
2178
|
possibleDoorPoints = [];
|
|
2141
2179
|
doorPoint = [];
|
|
2142
2180
|
dxf;
|
|
2143
2181
|
// 包含所有点的虚拟网格
|
|
2144
|
-
pointVirtualGrid = new
|
|
2182
|
+
pointVirtualGrid = new ce();
|
|
2145
2183
|
// 只包含可查找点的虚拟网格
|
|
2146
2184
|
findPointVirtualGrid;
|
|
2147
2185
|
quadtree;
|
|
@@ -2154,7 +2192,7 @@ class Ke {
|
|
|
2154
2192
|
lineAnalysis;
|
|
2155
2193
|
continueFind = !0;
|
|
2156
2194
|
constructor(e) {
|
|
2157
|
-
if (this.lineAnalysis = e, this.dxf = e.Dxf, this.findPointVirtualGrid = new
|
|
2195
|
+
if (this.lineAnalysis = e, this.dxf = e.Dxf, this.findPointVirtualGrid = new ce(), this.quadtree = e.quadtree, this.resultList = e.resultList, this.lineSegments = e.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
|
|
2158
2196
|
this.pointVirtualGrid.insert(n.start, n), this.pointVirtualGrid.insert(n.end, n);
|
|
2159
2197
|
}), this.doorPoint = this.getDoorPoint(), !this.continueFind) return;
|
|
2160
2198
|
const t = this.searchDoubleLinePoint();
|
|
@@ -2184,15 +2222,15 @@ class Ke {
|
|
|
2184
2222
|
);
|
|
2185
2223
|
const a = [];
|
|
2186
2224
|
return o.forEach((l) => {
|
|
2187
|
-
const c = new
|
|
2225
|
+
const c = new B(l?.start, l?.end), h = c.length();
|
|
2188
2226
|
if (h < n) return;
|
|
2189
2227
|
const f = c.normal(), u = c.direction(), p = (h - r.width * 2) / 2;
|
|
2190
2228
|
for (let y = 0; y < 3; y++) {
|
|
2191
|
-
const x = c.start.clone().add(u.clone().multiplyScalar(r.width + p * y)),
|
|
2229
|
+
const x = c.start.clone().add(u.clone().multiplyScalar(r.width + p * y)), S = new B(
|
|
2192
2230
|
x,
|
|
2193
2231
|
x.clone().add(f.clone().multiplyScalar(1))
|
|
2194
2232
|
);
|
|
2195
|
-
if (
|
|
2233
|
+
if (S.directionMove(f, -0.5), this.quadtree.queryLineSegment(S).length) return;
|
|
2196
2234
|
}
|
|
2197
2235
|
a.push(c);
|
|
2198
2236
|
}), a;
|
|
@@ -2212,7 +2250,7 @@ class Ke {
|
|
|
2212
2250
|
return this.lineSegments.forEach((t) => {
|
|
2213
2251
|
t.points.forEach((n, s) => {
|
|
2214
2252
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](t, n, s)) return;
|
|
2215
|
-
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid:
|
|
2253
|
+
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== t).length === 0 && e.push({ line: t, point: n, uuid: ae() });
|
|
2216
2254
|
});
|
|
2217
2255
|
}), e;
|
|
2218
2256
|
}
|
|
@@ -2224,7 +2262,7 @@ class Ke {
|
|
|
2224
2262
|
return t.doors.forEach((s) => {
|
|
2225
2263
|
const i = t.lineSegments[s[4]], r = t.originalData[s[4]];
|
|
2226
2264
|
if (r.drawDoorData) {
|
|
2227
|
-
const o =
|
|
2265
|
+
const o = w.from(r.drawDoorData.start), a = w.from(r.drawDoorData.n), l = n.queryPoint(o).filter((c) => {
|
|
2228
2266
|
if (c.userData === i) return !1;
|
|
2229
2267
|
const h = c.userData, f = h.direction();
|
|
2230
2268
|
h.start.equal(o) && f.multiplyScalar(-1);
|
|
@@ -2234,11 +2272,11 @@ class Ke {
|
|
|
2234
2272
|
l.length && e.push({
|
|
2235
2273
|
line: l[0].userData,
|
|
2236
2274
|
point: o,
|
|
2237
|
-
uuid:
|
|
2275
|
+
uuid: ae()
|
|
2238
2276
|
});
|
|
2239
2277
|
} else if (r.doorDirectConnection) {
|
|
2240
2278
|
this.continueFind = !1;
|
|
2241
|
-
const o = new
|
|
2279
|
+
const o = new B(w.from(r.start), w.from(r.end));
|
|
2242
2280
|
o.userData = {
|
|
2243
2281
|
doorDirectConnection: !0,
|
|
2244
2282
|
isDoor: !0
|
|
@@ -2268,83 +2306,83 @@ class Ke {
|
|
|
2268
2306
|
*/
|
|
2269
2307
|
searchNearby(e, t = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2270
2308
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2271
|
-
function o({ point: x, line:
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2274
|
-
const
|
|
2275
|
-
for (let
|
|
2276
|
-
const
|
|
2277
|
-
if (
|
|
2278
|
-
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2281
|
-
const
|
|
2282
|
-
M
|
|
2283
|
-
findData: M
|
|
2284
|
-
findUuid:
|
|
2285
|
-
doorLine:
|
|
2286
|
-
doorUuid:
|
|
2309
|
+
function o({ point: x, line: S }, D, C) {
|
|
2310
|
+
const m = S.direction();
|
|
2311
|
+
S.start === x && m.multiplyScalar(-1);
|
|
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
|
+
for (let M = 0; M < E.length; M++) {
|
|
2314
|
+
const g = t.findIndex((I) => I.point === E[M].point), b = e[D].uuid, T = t[g].uuid;
|
|
2315
|
+
if (C.has(`${b}.${T}`)) continue;
|
|
2316
|
+
C.add(`${b}.${T}`), C.add(`${T}.${b}`);
|
|
2317
|
+
const A = E[M].point, P = new B(x.clone(), A.clone());
|
|
2318
|
+
if (P.direction().angleBetween(m, "angle") < s) {
|
|
2319
|
+
const I = e[g].line.direction();
|
|
2320
|
+
E[M].userData.start.equal(E[M].point) && I.multiplyScalar(-1), P.direction().multiplyScalar(-1).angleBetween(I, "angle") < s && (r.queryLineSegment(P).length || L.push({
|
|
2321
|
+
findData: E[M],
|
|
2322
|
+
findUuid: T,
|
|
2323
|
+
doorLine: P,
|
|
2324
|
+
doorUuid: b
|
|
2287
2325
|
}));
|
|
2288
2326
|
}
|
|
2289
2327
|
}
|
|
2290
|
-
return
|
|
2328
|
+
return L;
|
|
2291
2329
|
}
|
|
2292
|
-
function a(x,
|
|
2293
|
-
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2296
|
-
for (let
|
|
2297
|
-
const
|
|
2298
|
-
if (
|
|
2299
|
-
const
|
|
2300
|
-
a(
|
|
2301
|
-
} else
|
|
2330
|
+
function a(x, S, D, C, m) {
|
|
2331
|
+
C.add(x);
|
|
2332
|
+
const E = [];
|
|
2333
|
+
m && E.push(m);
|
|
2334
|
+
for (let L = 0; L < D.length; L++) {
|
|
2335
|
+
const M = D[L];
|
|
2336
|
+
if (S.has(M.findUuid)) {
|
|
2337
|
+
const g = S.get(M.findUuid);
|
|
2338
|
+
a(M.findUuid, S, g, C, M) && E.push(M);
|
|
2339
|
+
} else E.push(M);
|
|
2302
2340
|
}
|
|
2303
|
-
return
|
|
2341
|
+
return E.sort((L, M) => L.doorLine.length() - M.doorLine.length()), m && E[0] === m ? (D.splice(0), !0) : (D.splice(1), !1);
|
|
2304
2342
|
}
|
|
2305
2343
|
const l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
2306
|
-
e.map((x,
|
|
2307
|
-
const
|
|
2308
|
-
|
|
2344
|
+
e.map((x, S) => {
|
|
2345
|
+
const D = o(x, S, l);
|
|
2346
|
+
D.length && c.set(x.uuid, D);
|
|
2309
2347
|
}), l.clear();
|
|
2310
2348
|
const h = /* @__PURE__ */ new Map();
|
|
2311
|
-
c.forEach((x,
|
|
2312
|
-
if (!l.has(
|
|
2313
|
-
const
|
|
2314
|
-
h.has(
|
|
2349
|
+
c.forEach((x, S) => {
|
|
2350
|
+
if (!l.has(S) && x.length && a(S, c, x, l), x.length) {
|
|
2351
|
+
const D = x[0];
|
|
2352
|
+
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);
|
|
2315
2353
|
}
|
|
2316
2354
|
});
|
|
2317
2355
|
const f = /* @__PURE__ */ new Set();
|
|
2318
2356
|
h.forEach((x) => {
|
|
2319
2357
|
if (x.length > 1) {
|
|
2320
|
-
x.sort((
|
|
2321
|
-
for (let
|
|
2358
|
+
x.sort((S, D) => S.doorLine.length() - D.doorLine.length());
|
|
2359
|
+
for (let S = 1; S < x.length; S++) f.add(x[S]);
|
|
2322
2360
|
}
|
|
2323
2361
|
});
|
|
2324
2362
|
const u = [], p = [];
|
|
2325
2363
|
c.forEach((x) => {
|
|
2326
2364
|
if (x.length) {
|
|
2327
|
-
const
|
|
2328
|
-
f.has(
|
|
2365
|
+
const S = x[0];
|
|
2366
|
+
f.has(S) || (u.push(S), p.push(S.doorUuid, S.findUuid));
|
|
2329
2367
|
}
|
|
2330
2368
|
});
|
|
2331
2369
|
const y = [];
|
|
2332
2370
|
return u.forEach((x) => {
|
|
2333
|
-
const
|
|
2334
|
-
if (
|
|
2335
|
-
|
|
2336
|
-
const
|
|
2337
|
-
(
|
|
2338
|
-
start:
|
|
2339
|
-
end:
|
|
2371
|
+
const S = e.findIndex((g) => g.uuid === x.doorUuid), D = t.findIndex((g) => g.uuid === x.findUuid), C = e[S].point.clone(), m = t[D].point.clone(), E = this.findLongLineSegment(e[S].line), L = this.findLongLineSegment(t[D].line), M = E.projectPoint(m);
|
|
2372
|
+
if (M) {
|
|
2373
|
+
C.copy(M);
|
|
2374
|
+
const g = new B(C, m), b = L.includedAngle(g);
|
|
2375
|
+
(b < 10 || b > 170 || Math.abs(90 - b) < 10) && y.push({
|
|
2376
|
+
start: C,
|
|
2377
|
+
end: m
|
|
2340
2378
|
});
|
|
2341
2379
|
} else {
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
const
|
|
2345
|
-
(
|
|
2346
|
-
start:
|
|
2347
|
-
end:
|
|
2380
|
+
const g = L.projectPoint(C);
|
|
2381
|
+
g && m.copy(g);
|
|
2382
|
+
const b = new B(C, m), T = E.includedAngle(b);
|
|
2383
|
+
(T < 10 || T > 170 || Math.abs(90 - T) < 10) && y.push({
|
|
2384
|
+
start: C,
|
|
2385
|
+
end: m
|
|
2348
2386
|
});
|
|
2349
2387
|
}
|
|
2350
2388
|
}), t.splice(
|
|
@@ -2365,7 +2403,7 @@ class Ke {
|
|
|
2365
2403
|
searchAlongDirection({ point: e, line: t }, n = this.doorSearchDistance) {
|
|
2366
2404
|
const s = this.quadtree, i = t.direction();
|
|
2367
2405
|
t.start === e && i.multiplyScalar(-1);
|
|
2368
|
-
const r = e.clone().add(i.clone().multiplyScalar(n)), o = new
|
|
2406
|
+
const r = e.clone().add(i.clone().multiplyScalar(n)), o = new B(e.clone(), r), a = s.queryLineSegment(o).map((l) => ({
|
|
2369
2407
|
point: l.line.getIntersection(o),
|
|
2370
2408
|
line: l.line
|
|
2371
2409
|
})).filter((l) => l.point).sort((l, c) => e.distance(l.point) - e.distance(c.point));
|
|
@@ -2392,7 +2430,7 @@ class Ke {
|
|
|
2392
2430
|
break;
|
|
2393
2431
|
}
|
|
2394
2432
|
}
|
|
2395
|
-
const c = new
|
|
2433
|
+
const c = new B(e.clone(), e.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(c).map((f) => ({
|
|
2396
2434
|
point: f.line.getIntersection(c),
|
|
2397
2435
|
line: f.line
|
|
2398
2436
|
})).filter((f) => f.point).sort((f, u) => e.distance(f.point) - e.distance(u.point));
|
|
@@ -2426,12 +2464,12 @@ class Ke {
|
|
|
2426
2464
|
return t;
|
|
2427
2465
|
}
|
|
2428
2466
|
}
|
|
2429
|
-
class
|
|
2467
|
+
class et extends W {
|
|
2430
2468
|
static name = "LineAnalysis";
|
|
2431
2469
|
Dxf = null;
|
|
2432
2470
|
Variable = null;
|
|
2433
2471
|
lineSegmentList = [];
|
|
2434
|
-
container = new
|
|
2472
|
+
container = new G.Group();
|
|
2435
2473
|
// 误差角度
|
|
2436
2474
|
errorAngle = 4;
|
|
2437
2475
|
width = 0.4;
|
|
@@ -2440,7 +2478,7 @@ class $e extends j {
|
|
|
2440
2478
|
* @param parent
|
|
2441
2479
|
*/
|
|
2442
2480
|
onAddFromParent(e) {
|
|
2443
|
-
this.Dxf = e.findComponentByType(X), this.Variable = this.parent?.findComponentByType(
|
|
2481
|
+
this.Dxf = e.findComponentByType(X), this.Variable = this.parent?.findComponentByType(Ee), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
|
|
2444
2482
|
}
|
|
2445
2483
|
/**
|
|
2446
2484
|
*
|
|
@@ -2454,11 +2492,11 @@ class $e extends j {
|
|
|
2454
2492
|
return {
|
|
2455
2493
|
points: [
|
|
2456
2494
|
// 第一条线
|
|
2457
|
-
new
|
|
2458
|
-
new
|
|
2495
|
+
new w(e.x + o, e.y + a).add(r),
|
|
2496
|
+
new w(t.x + o, t.y + a).add(i),
|
|
2459
2497
|
// 第二条线
|
|
2460
|
-
new
|
|
2461
|
-
new
|
|
2498
|
+
new w(e.x - o, e.y - a).add(r),
|
|
2499
|
+
new w(t.x - o, t.y - a).add(i)
|
|
2462
2500
|
],
|
|
2463
2501
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
2464
2502
|
rectIndices: [0, 1, 3, 2, 0]
|
|
@@ -2472,7 +2510,7 @@ class $e extends j {
|
|
|
2472
2510
|
*/
|
|
2473
2511
|
addData(e, t) {
|
|
2474
2512
|
const n = this.Dxf;
|
|
2475
|
-
n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new
|
|
2513
|
+
n.data.push([e.clone(), t.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new B(e.clone(), t.clone()));
|
|
2476
2514
|
}
|
|
2477
2515
|
/** 结果分析创建矩形
|
|
2478
2516
|
* @param result
|
|
@@ -2482,12 +2520,12 @@ class $e extends j {
|
|
|
2482
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]);
|
|
2483
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);
|
|
2484
2522
|
p.multiplyScalar(t.width * 0.5);
|
|
2485
|
-
const y = f.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)),
|
|
2486
|
-
if (!(
|
|
2523
|
+
const y = f.clone().add(p), x = u.clone().add(p.multiplyScalar(-1)), S = f.direction(u), D = y.direction(x);
|
|
2524
|
+
if (!(S.x > 0 && D.x < 0 || S.x < 0 && D.x > 0 || S.y > 0 && D.y < 0 || S.y < 0 && D.y > 0)) {
|
|
2487
2525
|
f.set(y.x, y.y), u.set(x.x, x.y);
|
|
2488
|
-
for (let
|
|
2489
|
-
const
|
|
2490
|
-
this.addData(
|
|
2526
|
+
for (let C = 1; C < o; C++) {
|
|
2527
|
+
const m = c.clone().multiplyScalar(a * C), E = h.clone().multiplyScalar(l * C), L = f.clone().add(m), M = u.clone().add(E);
|
|
2528
|
+
this.addData(L, M);
|
|
2491
2529
|
}
|
|
2492
2530
|
}
|
|
2493
2531
|
}
|
|
@@ -2497,7 +2535,7 @@ class $e extends j {
|
|
|
2497
2535
|
*/
|
|
2498
2536
|
buildQuadtree() {
|
|
2499
2537
|
const e = this.Dxf, t = [];
|
|
2500
|
-
this.quadtree = new
|
|
2538
|
+
this.quadtree = new Y(e.originalBox, 2), e.lineSegments.forEach((n) => {
|
|
2501
2539
|
n.userData?.isDoor || (this.quadtree?.insert({
|
|
2502
2540
|
line: n,
|
|
2503
2541
|
userData: t.length
|
|
@@ -2514,7 +2552,7 @@ class $e extends j {
|
|
|
2514
2552
|
this.buildQuadtree();
|
|
2515
2553
|
const e = this.quadtree, t = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
2516
2554
|
t.forEach((i, r) => {
|
|
2517
|
-
const o = t[r], a =
|
|
2555
|
+
const o = t[r], a = te.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
2518
2556
|
e.queryRect(a).map((c) => c.userData).filter((c) => c !== r).forEach((c) => {
|
|
2519
2557
|
try {
|
|
2520
2558
|
if (n.has(`${r}-${c}`) || n.has(`${c}-${r}`)) return;
|
|
@@ -2558,12 +2596,12 @@ class $e extends j {
|
|
|
2558
2596
|
doors = [];
|
|
2559
2597
|
DoorsAnalysis;
|
|
2560
2598
|
doorsAnalysis() {
|
|
2561
|
-
this.DoorsAnalysis = new
|
|
2599
|
+
this.DoorsAnalysis = new Qe(this), this.dispatchEvent({
|
|
2562
2600
|
type: "analysisCompleted"
|
|
2563
2601
|
});
|
|
2564
2602
|
}
|
|
2565
2603
|
}
|
|
2566
|
-
class
|
|
2604
|
+
class tt extends W {
|
|
2567
2605
|
static name = "ThreeVJia";
|
|
2568
2606
|
lineSegments = [];
|
|
2569
2607
|
onAddFromParent() {
|
|
@@ -2577,8 +2615,8 @@ class Ze extends j {
|
|
|
2577
2615
|
e.resultList.forEach((c) => {
|
|
2578
2616
|
const h = s.get(c.target) ?? [], f = s.get(c.source) ?? [], u = c.project.clone(), p = c.project2.clone();
|
|
2579
2617
|
u.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...u.points), f.push(...p.points), s.set(c.target, h), s.set(c.source, f);
|
|
2580
|
-
const y = new
|
|
2581
|
-
|
|
2618
|
+
const y = new B(u.start, p.start), x = new B(u.end, p.end), S = new B(y.center, x.center);
|
|
2619
|
+
S.userData.wallWidth = Math.max(y.length(), x.length()), r.push(S);
|
|
2582
2620
|
});
|
|
2583
2621
|
const a = [];
|
|
2584
2622
|
i = i.filter((c) => {
|
|
@@ -2594,7 +2632,7 @@ class Ze extends j {
|
|
|
2594
2632
|
const u = [];
|
|
2595
2633
|
for (let p = 0; p < h.length; p++) {
|
|
2596
2634
|
const y = h[p];
|
|
2597
|
-
y.userData.type === "start" ? (u.length === 0 && (a.push(new
|
|
2635
|
+
y.userData.type === "start" ? (u.length === 0 && (a.push(new B(f.start.clone(), y.clone())), f.start.copy(y)), u.push("start")) : (u.pop(), u.length === 0 && f.start.copy(y));
|
|
2598
2636
|
}
|
|
2599
2637
|
a.push(f);
|
|
2600
2638
|
}
|
|
@@ -2652,7 +2690,7 @@ class Ze extends j {
|
|
|
2652
2690
|
};
|
|
2653
2691
|
if (s.userData.isWindow)
|
|
2654
2692
|
return s.userData.drawWindow.map((i) => {
|
|
2655
|
-
const r =
|
|
2693
|
+
const r = w.from(i.p), o = r.clone().add(
|
|
2656
2694
|
s.direction().multiplyScalar(i.width * 0.5)
|
|
2657
2695
|
), a = r.clone().add(
|
|
2658
2696
|
s.direction().multiplyScalar(-i.width * 0.5)
|
|
@@ -2685,10 +2723,10 @@ class Ze extends j {
|
|
|
2685
2723
|
if (typeof window < "u") {
|
|
2686
2724
|
const t = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
|
|
2687
2725
|
n.href = URL.createObjectURL(t), n.download = e, n.click();
|
|
2688
|
-
} else typeof global < "u" && (await
|
|
2726
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(e, JSON.stringify(this.toJson()));
|
|
2689
2727
|
}
|
|
2690
2728
|
}
|
|
2691
|
-
class
|
|
2729
|
+
class nt extends Ke {
|
|
2692
2730
|
Dxf;
|
|
2693
2731
|
AngleCorrectionDxf;
|
|
2694
2732
|
Variable;
|
|
@@ -2699,7 +2737,7 @@ class Qe extends He {
|
|
|
2699
2737
|
* @param scale 原始数据缩放比例
|
|
2700
2738
|
*/
|
|
2701
2739
|
constructor(e = 0.1, t = 1) {
|
|
2702
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = e, this.Dxf = new X(this.wallWidth, t), this.AngleCorrectionDxf = new
|
|
2740
|
+
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = e, this.Dxf = new X(this.wallWidth, t), this.AngleCorrectionDxf = new Ze(), this.Variable = new Ee(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new et()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new tt());
|
|
2703
2741
|
}
|
|
2704
2742
|
usePlugin(e) {
|
|
2705
2743
|
return typeof e == "function" && e.call(this, this), this;
|
|
@@ -2712,7 +2750,7 @@ class Qe extends He {
|
|
|
2712
2750
|
});
|
|
2713
2751
|
}
|
|
2714
2752
|
}
|
|
2715
|
-
const
|
|
2753
|
+
const xe = {
|
|
2716
2754
|
POSITION: [
|
|
2717
2755
|
"byte",
|
|
2718
2756
|
"byte normalized",
|
|
@@ -2740,36 +2778,36 @@ const de = {
|
|
|
2740
2778
|
"unsigned short"
|
|
2741
2779
|
]
|
|
2742
2780
|
};
|
|
2743
|
-
class
|
|
2781
|
+
class ee {
|
|
2744
2782
|
constructor() {
|
|
2745
2783
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
2746
|
-
return new
|
|
2747
|
-
}), this.register(function(e) {
|
|
2748
|
-
return new ut(e);
|
|
2784
|
+
return new ft(e);
|
|
2749
2785
|
}), this.register(function(e) {
|
|
2750
|
-
return new
|
|
2786
|
+
return new pt(e);
|
|
2751
2787
|
}), this.register(function(e) {
|
|
2752
|
-
return new
|
|
2788
|
+
return new gt(e);
|
|
2753
2789
|
}), this.register(function(e) {
|
|
2754
|
-
return new
|
|
2790
|
+
return new wt(e);
|
|
2755
2791
|
}), this.register(function(e) {
|
|
2756
|
-
return new
|
|
2792
|
+
return new Mt(e);
|
|
2757
2793
|
}), this.register(function(e) {
|
|
2758
|
-
return new
|
|
2794
|
+
return new St(e);
|
|
2759
2795
|
}), this.register(function(e) {
|
|
2760
|
-
return new
|
|
2796
|
+
return new xt(e);
|
|
2761
2797
|
}), this.register(function(e) {
|
|
2762
|
-
return new
|
|
2798
|
+
return new yt(e);
|
|
2763
2799
|
}), this.register(function(e) {
|
|
2764
|
-
return new
|
|
2800
|
+
return new mt(e);
|
|
2765
2801
|
}), this.register(function(e) {
|
|
2766
|
-
return new
|
|
2802
|
+
return new Lt(e);
|
|
2767
2803
|
}), this.register(function(e) {
|
|
2768
|
-
return new
|
|
2804
|
+
return new Et(e);
|
|
2769
2805
|
}), this.register(function(e) {
|
|
2770
2806
|
return new Tt(e);
|
|
2771
2807
|
}), this.register(function(e) {
|
|
2772
|
-
return new
|
|
2808
|
+
return new At(e);
|
|
2809
|
+
}), this.register(function(e) {
|
|
2810
|
+
return new bt(e);
|
|
2773
2811
|
});
|
|
2774
2812
|
}
|
|
2775
2813
|
register(e) {
|
|
@@ -2782,7 +2820,7 @@ class $ {
|
|
|
2782
2820
|
return this.textureUtils = e, this;
|
|
2783
2821
|
}
|
|
2784
2822
|
parse(e, t, n, s) {
|
|
2785
|
-
const i = new
|
|
2823
|
+
const i = new dt(), r = [];
|
|
2786
2824
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
2787
2825
|
r.push(this.pluginCallbacks[o](i));
|
|
2788
2826
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(e, t, s).catch(n);
|
|
@@ -2794,7 +2832,7 @@ class $ {
|
|
|
2794
2832
|
});
|
|
2795
2833
|
}
|
|
2796
2834
|
}
|
|
2797
|
-
const
|
|
2835
|
+
const v = {
|
|
2798
2836
|
POINTS: 0,
|
|
2799
2837
|
LINES: 1,
|
|
2800
2838
|
LINE_LOOP: 2,
|
|
@@ -2818,34 +2856,34 @@ const R = {
|
|
|
2818
2856
|
CLAMP_TO_EDGE: 33071,
|
|
2819
2857
|
MIRRORED_REPEAT: 33648,
|
|
2820
2858
|
REPEAT: 10497
|
|
2821
|
-
},
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
const
|
|
2859
|
+
}, se = "KHR_mesh_quantization", q = {};
|
|
2860
|
+
q[_e] = v.NEAREST;
|
|
2861
|
+
q[ze] = v.NEAREST_MIPMAP_NEAREST;
|
|
2862
|
+
q[qe] = v.NEAREST_MIPMAP_LINEAR;
|
|
2863
|
+
q[je] = v.LINEAR;
|
|
2864
|
+
q[Ye] = v.LINEAR_MIPMAP_NEAREST;
|
|
2865
|
+
q[Ve] = v.LINEAR_MIPMAP_LINEAR;
|
|
2866
|
+
q[ke] = v.CLAMP_TO_EDGE;
|
|
2867
|
+
q[Xe] = v.REPEAT;
|
|
2868
|
+
q[We] = v.MIRRORED_REPEAT;
|
|
2869
|
+
const ye = {
|
|
2832
2870
|
scale: "scale",
|
|
2833
2871
|
position: "translation",
|
|
2834
2872
|
quaternion: "rotation",
|
|
2835
2873
|
morphTargetInfluences: "weights"
|
|
2836
|
-
},
|
|
2837
|
-
function
|
|
2874
|
+
}, st = new Re(), me = 12, it = 1179937895, rt = 2, ge = 8, ot = 1313821514, at = 5130562;
|
|
2875
|
+
function K(d, e) {
|
|
2838
2876
|
return d.length === e.length && d.every(function(t, n) {
|
|
2839
2877
|
return t === e[n];
|
|
2840
2878
|
});
|
|
2841
2879
|
}
|
|
2842
|
-
function
|
|
2880
|
+
function ct(d) {
|
|
2843
2881
|
return new TextEncoder().encode(d).buffer;
|
|
2844
2882
|
}
|
|
2845
|
-
function
|
|
2846
|
-
return
|
|
2883
|
+
function lt(d) {
|
|
2884
|
+
return K(d.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
2847
2885
|
}
|
|
2848
|
-
function
|
|
2886
|
+
function ht(d, e, t) {
|
|
2849
2887
|
const n = {
|
|
2850
2888
|
min: new Array(d.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
2851
2889
|
max: new Array(d.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
@@ -2853,15 +2891,15 @@ function at(d, e, t) {
|
|
|
2853
2891
|
for (let s = e; s < e + t; s++)
|
|
2854
2892
|
for (let i = 0; i < d.itemSize; i++) {
|
|
2855
2893
|
let r;
|
|
2856
|
-
d.itemSize > 4 ? r = d.array[s * d.itemSize + i] : (i === 0 ? r = d.getX(s) : i === 1 ? r = d.getY(s) : i === 2 ? r = d.getZ(s) : i === 3 && (r = d.getW(s)), d.normalized === !0 && (r =
|
|
2894
|
+
d.itemSize > 4 ? r = d.array[s * d.itemSize + i] : (i === 0 ? r = d.getX(s) : i === 1 ? r = d.getY(s) : i === 2 ? r = d.getZ(s) : i === 3 && (r = d.getW(s)), d.normalized === !0 && (r = oe.normalize(r, d.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
2857
2895
|
}
|
|
2858
2896
|
return n;
|
|
2859
2897
|
}
|
|
2860
|
-
function
|
|
2898
|
+
function Te(d) {
|
|
2861
2899
|
return Math.ceil(d / 4) * 4;
|
|
2862
2900
|
}
|
|
2863
|
-
function
|
|
2864
|
-
const t =
|
|
2901
|
+
function ie(d, e = 0) {
|
|
2902
|
+
const t = Te(d.byteLength);
|
|
2865
2903
|
if (t !== d.byteLength) {
|
|
2866
2904
|
const n = new Uint8Array(t);
|
|
2867
2905
|
if (n.set(new Uint8Array(d)), e !== 0)
|
|
@@ -2871,10 +2909,10 @@ function te(d, e = 0) {
|
|
|
2871
2909
|
}
|
|
2872
2910
|
return d;
|
|
2873
2911
|
}
|
|
2874
|
-
function
|
|
2912
|
+
function we() {
|
|
2875
2913
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
2876
2914
|
}
|
|
2877
|
-
function
|
|
2915
|
+
function ut(d, e) {
|
|
2878
2916
|
if (typeof OffscreenCanvas < "u" && d instanceof OffscreenCanvas) {
|
|
2879
2917
|
let t;
|
|
2880
2918
|
return e === "image/jpeg" ? t = 0.92 : e === "image/webp" && (t = 0.8), d.convertToBlob({
|
|
@@ -2884,12 +2922,12 @@ function ct(d, e) {
|
|
|
2884
2922
|
} else
|
|
2885
2923
|
return new Promise((t) => d.toBlob(t, e));
|
|
2886
2924
|
}
|
|
2887
|
-
class
|
|
2925
|
+
class dt {
|
|
2888
2926
|
constructor() {
|
|
2889
2927
|
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 = {
|
|
2890
2928
|
asset: {
|
|
2891
2929
|
version: "2.0",
|
|
2892
|
-
generator: "THREE.GLTFExporter r" +
|
|
2930
|
+
generator: "THREE.GLTFExporter r" + Ne
|
|
2893
2931
|
}
|
|
2894
2932
|
}, this.cache = {
|
|
2895
2933
|
meshes: /* @__PURE__ */ new Map(),
|
|
@@ -2926,26 +2964,26 @@ class lt {
|
|
|
2926
2964
|
const s = this, i = s.buffers, r = s.json;
|
|
2927
2965
|
n = s.options;
|
|
2928
2966
|
const o = s.extensionsUsed, a = s.extensionsRequired, l = new Blob(i, { type: "application/octet-stream" }), c = Object.keys(o), h = Object.keys(a);
|
|
2929
|
-
c.length > 0 && (r.extensionsUsed = c), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = l.size), n.binary === !0 ?
|
|
2930
|
-
const u =
|
|
2931
|
-
p.setUint32(0, u.byteLength, !0), p.setUint32(4,
|
|
2932
|
-
const y =
|
|
2933
|
-
x.setUint32(0, y.byteLength, !0), x.setUint32(4,
|
|
2934
|
-
const
|
|
2935
|
-
|
|
2936
|
-
const
|
|
2937
|
-
|
|
2938
|
-
const
|
|
2939
|
-
|
|
2967
|
+
c.length > 0 && (r.extensionsUsed = c), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = l.size), n.binary === !0 ? re(l).then(function(f) {
|
|
2968
|
+
const u = ie(f), p = new DataView(new ArrayBuffer(ge));
|
|
2969
|
+
p.setUint32(0, u.byteLength, !0), p.setUint32(4, at, !0);
|
|
2970
|
+
const y = ie(ct(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(ge));
|
|
2971
|
+
x.setUint32(0, y.byteLength, !0), x.setUint32(4, ot, !0);
|
|
2972
|
+
const S = new ArrayBuffer(me), D = new DataView(S);
|
|
2973
|
+
D.setUint32(0, it, !0), D.setUint32(4, rt, !0);
|
|
2974
|
+
const C = me + x.byteLength + y.byteLength + p.byteLength + u.byteLength;
|
|
2975
|
+
D.setUint32(8, C, !0);
|
|
2976
|
+
const m = new Blob([
|
|
2977
|
+
S,
|
|
2940
2978
|
x,
|
|
2941
2979
|
y,
|
|
2942
2980
|
p,
|
|
2943
2981
|
u
|
|
2944
2982
|
], { type: "application/octet-stream" });
|
|
2945
|
-
|
|
2946
|
-
t(
|
|
2983
|
+
re(m).then((E) => {
|
|
2984
|
+
t(E);
|
|
2947
2985
|
});
|
|
2948
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
2986
|
+
}) : r.buffers && r.buffers.length > 0 ? Dt(l).then((f) => {
|
|
2949
2987
|
r.buffers[0].uri = f, t(r);
|
|
2950
2988
|
}) : t(r);
|
|
2951
2989
|
}
|
|
@@ -2993,7 +3031,7 @@ class lt {
|
|
|
2993
3031
|
*/
|
|
2994
3032
|
isNormalizedNormalAttribute(e) {
|
|
2995
3033
|
if (this.cache.attributesNormalized.has(e)) return !1;
|
|
2996
|
-
const n = new
|
|
3034
|
+
const n = new Z();
|
|
2997
3035
|
for (let s = 0, i = e.count; s < i; s++)
|
|
2998
3036
|
if (Math.abs(n.fromBufferAttribute(e, s).length() - 1) > 5e-4) return !1;
|
|
2999
3037
|
return !0;
|
|
@@ -3008,7 +3046,7 @@ class lt {
|
|
|
3008
3046
|
createNormalizedNormalAttribute(e) {
|
|
3009
3047
|
const t = this.cache;
|
|
3010
3048
|
if (t.attributesNormalized.has(e)) return t.attributesNormalized.get(e);
|
|
3011
|
-
const n = e.clone(), s = new
|
|
3049
|
+
const n = e.clone(), s = new Z();
|
|
3012
3050
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3013
3051
|
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);
|
|
3014
3052
|
return t.attributesNormalized.set(e, n), n;
|
|
@@ -3028,14 +3066,14 @@ class lt {
|
|
|
3028
3066
|
async buildMetalRoughTextureAsync(e, t) {
|
|
3029
3067
|
if (e === t) return e;
|
|
3030
3068
|
function n(u) {
|
|
3031
|
-
return u.colorSpace ===
|
|
3069
|
+
return u.colorSpace === Fe ? function(y) {
|
|
3032
3070
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3033
3071
|
} : function(y) {
|
|
3034
3072
|
return y;
|
|
3035
3073
|
};
|
|
3036
3074
|
}
|
|
3037
|
-
e instanceof
|
|
3038
|
-
const s = e ? e.image : null, i = t ? t.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 =
|
|
3075
|
+
e instanceof ne && (e = await this.decompressTextureAsync(e)), t instanceof ne && (t = await this.decompressTextureAsync(t));
|
|
3076
|
+
const s = e ? e.image : null, i = t ? t.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 = we();
|
|
3039
3077
|
a.width = r, a.height = o;
|
|
3040
3078
|
const l = a.getContext("2d", {
|
|
3041
3079
|
willReadFrequently: !0
|
|
@@ -3056,7 +3094,7 @@ class lt {
|
|
|
3056
3094
|
}
|
|
3057
3095
|
l.putImageData(c, 0, 0);
|
|
3058
3096
|
const f = (e || t).clone();
|
|
3059
|
-
return f.source = new
|
|
3097
|
+
return f.source = new ve(a), f.colorSpace = Ce, f.channel = (e || t).channel, e && t && e.channel !== t.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), f;
|
|
3060
3098
|
}
|
|
3061
3099
|
async decompressTextureAsync(e, t = 1 / 0) {
|
|
3062
3100
|
if (this.textureUtils === null)
|
|
@@ -3086,25 +3124,25 @@ class lt {
|
|
|
3086
3124
|
r.bufferViews || (r.bufferViews = []);
|
|
3087
3125
|
let o;
|
|
3088
3126
|
switch (t) {
|
|
3089
|
-
case
|
|
3090
|
-
case
|
|
3127
|
+
case v.BYTE:
|
|
3128
|
+
case v.UNSIGNED_BYTE:
|
|
3091
3129
|
o = 1;
|
|
3092
3130
|
break;
|
|
3093
|
-
case
|
|
3094
|
-
case
|
|
3131
|
+
case v.SHORT:
|
|
3132
|
+
case v.UNSIGNED_SHORT:
|
|
3095
3133
|
o = 2;
|
|
3096
3134
|
break;
|
|
3097
3135
|
default:
|
|
3098
3136
|
o = 4;
|
|
3099
3137
|
}
|
|
3100
3138
|
let a = e.itemSize * o;
|
|
3101
|
-
i ===
|
|
3102
|
-
const l =
|
|
3139
|
+
i === v.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
|
|
3140
|
+
const l = Te(s * a), c = new DataView(new ArrayBuffer(l));
|
|
3103
3141
|
let h = 0;
|
|
3104
3142
|
for (let p = n; p < n + s; p++) {
|
|
3105
3143
|
for (let y = 0; y < e.itemSize; y++) {
|
|
3106
3144
|
let x;
|
|
3107
|
-
e.itemSize > 4 ? x = e.array[p * e.itemSize + y] : (y === 0 ? x = e.getX(p) : y === 1 ? x = e.getY(p) : y === 2 ? x = e.getZ(p) : y === 3 && (x = e.getW(p)), e.normalized === !0 && (x =
|
|
3145
|
+
e.itemSize > 4 ? x = e.array[p * e.itemSize + y] : (y === 0 ? x = e.getX(p) : y === 1 ? x = e.getY(p) : y === 2 ? x = e.getZ(p) : y === 3 && (x = e.getW(p)), e.normalized === !0 && (x = oe.normalize(x, e.array))), t === v.FLOAT ? c.setFloat32(h, x, !0) : t === v.INT ? c.setInt32(h, x, !0) : t === v.UNSIGNED_INT ? c.setUint32(h, x, !0) : t === v.SHORT ? c.setInt16(h, x, !0) : t === v.UNSIGNED_SHORT ? c.setUint16(h, x, !0) : t === v.BYTE ? c.setInt8(h, x) : t === v.UNSIGNED_BYTE && c.setUint8(h, x), h += o;
|
|
3108
3146
|
}
|
|
3109
3147
|
h % a !== 0 && (h += a - h % a);
|
|
3110
3148
|
}
|
|
@@ -3113,7 +3151,7 @@ class lt {
|
|
|
3113
3151
|
byteOffset: this.byteOffset,
|
|
3114
3152
|
byteLength: l
|
|
3115
3153
|
};
|
|
3116
|
-
return i !== void 0 && (f.target = i), i ===
|
|
3154
|
+
return i !== void 0 && (f.target = i), i === v.ARRAY_BUFFER && (f.byteStride = a), this.byteOffset += l, r.bufferViews.push(f), {
|
|
3117
3155
|
id: r.bufferViews.length - 1,
|
|
3118
3156
|
byteLength: 0
|
|
3119
3157
|
};
|
|
@@ -3126,8 +3164,8 @@ class lt {
|
|
|
3126
3164
|
processBufferViewImage(e) {
|
|
3127
3165
|
const t = this, n = t.json;
|
|
3128
3166
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3129
|
-
|
|
3130
|
-
const r =
|
|
3167
|
+
re(e).then((i) => {
|
|
3168
|
+
const r = ie(i), o = {
|
|
3131
3169
|
buffer: t.processBuffer(r),
|
|
3132
3170
|
byteOffset: t.byteOffset,
|
|
3133
3171
|
byteLength: r.byteLength
|
|
@@ -3155,25 +3193,25 @@ class lt {
|
|
|
3155
3193
|
};
|
|
3156
3194
|
let o;
|
|
3157
3195
|
if (e.array.constructor === Float32Array)
|
|
3158
|
-
o =
|
|
3196
|
+
o = v.FLOAT;
|
|
3159
3197
|
else if (e.array.constructor === Int32Array)
|
|
3160
|
-
o =
|
|
3198
|
+
o = v.INT;
|
|
3161
3199
|
else if (e.array.constructor === Uint32Array)
|
|
3162
|
-
o =
|
|
3200
|
+
o = v.UNSIGNED_INT;
|
|
3163
3201
|
else if (e.array.constructor === Int16Array)
|
|
3164
|
-
o =
|
|
3202
|
+
o = v.SHORT;
|
|
3165
3203
|
else if (e.array.constructor === Uint16Array)
|
|
3166
|
-
o =
|
|
3204
|
+
o = v.UNSIGNED_SHORT;
|
|
3167
3205
|
else if (e.array.constructor === Int8Array)
|
|
3168
|
-
o =
|
|
3206
|
+
o = v.BYTE;
|
|
3169
3207
|
else if (e.array.constructor === Uint8Array)
|
|
3170
|
-
o =
|
|
3208
|
+
o = v.UNSIGNED_BYTE;
|
|
3171
3209
|
else
|
|
3172
3210
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + e.array.constructor.name);
|
|
3173
3211
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = e.count), s === 0) return null;
|
|
3174
|
-
const a =
|
|
3212
|
+
const a = ht(e, n, s);
|
|
3175
3213
|
let l;
|
|
3176
|
-
t !== void 0 && (l = e === t.index ?
|
|
3214
|
+
t !== void 0 && (l = e === t.index ? v.ELEMENT_ARRAY_BUFFER : v.ARRAY_BUFFER);
|
|
3177
3215
|
const c = this.processBufferView(e, o, n, s, l), h = {
|
|
3178
3216
|
bufferView: c.id,
|
|
3179
3217
|
byteOffset: c.byteOffset,
|
|
@@ -3200,26 +3238,26 @@ class lt {
|
|
|
3200
3238
|
const c = r.images.get(e), h = s + ":flipY/" + n.toString();
|
|
3201
3239
|
if (c[h] !== void 0) return c[h];
|
|
3202
3240
|
o.images || (o.images = []);
|
|
3203
|
-
const f = { mimeType: s }, u =
|
|
3241
|
+
const f = { mimeType: s }, u = we();
|
|
3204
3242
|
u.width = Math.min(e.width, a.maxTextureSize), u.height = Math.min(e.height, a.maxTextureSize);
|
|
3205
3243
|
const p = u.getContext("2d", {
|
|
3206
3244
|
willReadFrequently: !0
|
|
3207
3245
|
});
|
|
3208
3246
|
if (n === !0 && (p.translate(0, u.height), p.scale(1, -1)), e.data !== void 0) {
|
|
3209
|
-
t !==
|
|
3247
|
+
t !== Be && console.error("GLTFExporter: Only RGBAFormat is supported.", t), (e.width > a.maxTextureSize || e.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", e);
|
|
3210
3248
|
const x = new Uint8ClampedArray(e.height * e.width * 4);
|
|
3211
|
-
for (let
|
|
3212
|
-
x[
|
|
3249
|
+
for (let S = 0; S < x.length; S += 4)
|
|
3250
|
+
x[S + 0] = e.data[S + 0], x[S + 1] = e.data[S + 1], x[S + 2] = e.data[S + 2], x[S + 3] = e.data[S + 3];
|
|
3213
3251
|
p.putImageData(new ImageData(x, e.width, e.height), 0, 0);
|
|
3214
3252
|
} else if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)
|
|
3215
3253
|
p.drawImage(e, 0, 0, u.width, u.height);
|
|
3216
3254
|
else
|
|
3217
3255
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
3218
3256
|
a.binary === !0 ? l.push(
|
|
3219
|
-
|
|
3257
|
+
ut(u, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3220
3258
|
f.bufferView = x;
|
|
3221
3259
|
})
|
|
3222
|
-
) : f.uri =
|
|
3260
|
+
) : f.uri = Oe.getDataURL(u, s);
|
|
3223
3261
|
const y = o.images.push(f) - 1;
|
|
3224
3262
|
return c[h] = y, y;
|
|
3225
3263
|
} else
|
|
@@ -3234,10 +3272,10 @@ class lt {
|
|
|
3234
3272
|
const t = this.json;
|
|
3235
3273
|
t.samplers || (t.samplers = []);
|
|
3236
3274
|
const n = {
|
|
3237
|
-
magFilter:
|
|
3238
|
-
minFilter:
|
|
3239
|
-
wrapS:
|
|
3240
|
-
wrapT:
|
|
3275
|
+
magFilter: q[e.magFilter],
|
|
3276
|
+
minFilter: q[e.minFilter],
|
|
3277
|
+
wrapS: q[e.wrapS],
|
|
3278
|
+
wrapT: q[e.wrapT]
|
|
3241
3279
|
};
|
|
3242
3280
|
return t.samplers.push(n) - 1;
|
|
3243
3281
|
}
|
|
@@ -3249,7 +3287,7 @@ class lt {
|
|
|
3249
3287
|
async processTextureAsync(e) {
|
|
3250
3288
|
const n = this.options, s = this.cache, i = this.json;
|
|
3251
3289
|
if (s.textures.has(e)) return s.textures.get(e);
|
|
3252
|
-
i.textures || (i.textures = []), e instanceof
|
|
3290
|
+
i.textures || (i.textures = []), e instanceof ne && (e = await this.decompressTextureAsync(e, n.maxTextureSize));
|
|
3253
3291
|
let r = e.userData.mimeType;
|
|
3254
3292
|
r === "image/webp" && (r = "image/png");
|
|
3255
3293
|
const o = {
|
|
@@ -3276,7 +3314,7 @@ class lt {
|
|
|
3276
3314
|
const s = { pbrMetallicRoughness: {} };
|
|
3277
3315
|
e.isMeshStandardMaterial !== !0 && e.isMeshBasicMaterial !== !0 && console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
|
|
3278
3316
|
const i = e.color.toArray().concat([e.opacity]);
|
|
3279
|
-
if (
|
|
3317
|
+
if (K(i, [1, 1, 1, 1]) || (s.pbrMetallicRoughness.baseColorFactor = i), e.isMeshStandardMaterial ? (s.pbrMetallicRoughness.metallicFactor = e.metalness, s.pbrMetallicRoughness.roughnessFactor = e.roughness) : (s.pbrMetallicRoughness.metallicFactor = 0, s.pbrMetallicRoughness.roughnessFactor = 1), e.metalnessMap || e.roughnessMap) {
|
|
3280
3318
|
const o = await this.buildMetalRoughTextureAsync(e.metalnessMap, e.roughnessMap), a = {
|
|
3281
3319
|
index: await this.processTextureAsync(o),
|
|
3282
3320
|
texCoord: o.channel
|
|
@@ -3314,7 +3352,7 @@ class lt {
|
|
|
3314
3352
|
};
|
|
3315
3353
|
e.aoMapIntensity !== 1 && (o.strength = e.aoMapIntensity), this.applyTextureTransform(o, e.aoMap), s.occlusionTexture = o;
|
|
3316
3354
|
}
|
|
3317
|
-
e.transparent ? s.alphaMode = "BLEND" : e.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = e.alphaTest), e.side ===
|
|
3355
|
+
e.transparent ? s.alphaMode = "BLEND" : e.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = e.alphaTest), e.side === Ge && (s.doubleSided = !0), e.name !== "" && (s.name = e.name), this.serializeUserData(e, s), await this._invokeAllAsync(async function(o) {
|
|
3318
3356
|
o.writeMaterialAsync && await o.writeMaterialAsync(e, s);
|
|
3319
3357
|
});
|
|
3320
3358
|
const r = n.materials.push(s) - 1;
|
|
@@ -3328,15 +3366,15 @@ class lt {
|
|
|
3328
3366
|
async processMeshAsync(e) {
|
|
3329
3367
|
const t = this.cache, n = this.json, s = [e.geometry.uuid];
|
|
3330
3368
|
if (Array.isArray(e.material))
|
|
3331
|
-
for (let
|
|
3332
|
-
s.push(e.material[
|
|
3369
|
+
for (let m = 0, E = e.material.length; m < E; m++)
|
|
3370
|
+
s.push(e.material[m].uuid);
|
|
3333
3371
|
else
|
|
3334
3372
|
s.push(e.material.uuid);
|
|
3335
3373
|
const i = s.join(":");
|
|
3336
3374
|
if (t.meshes.has(i)) return t.meshes.get(i);
|
|
3337
3375
|
const r = e.geometry;
|
|
3338
3376
|
let o;
|
|
3339
|
-
e.isLineSegments ? o =
|
|
3377
|
+
e.isLineSegments ? o = v.LINES : e.isLineLoop ? o = v.LINE_LOOP : e.isLine ? o = v.LINE_STRIP : e.isPoints ? o = v.POINTS : o = e.material.wireframe ? v.LINES : v.TRIANGLES;
|
|
3340
3378
|
const a = {}, l = {}, c = [], h = [], f = {
|
|
3341
3379
|
uv: "TEXCOORD_0",
|
|
3342
3380
|
uv1: "TEXCOORD_1",
|
|
@@ -3348,76 +3386,76 @@ class lt {
|
|
|
3348
3386
|
}, u = r.getAttribute("normal");
|
|
3349
3387
|
u !== void 0 && !this.isNormalizedNormalAttribute(u) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(u)));
|
|
3350
3388
|
let p = null;
|
|
3351
|
-
for (let
|
|
3352
|
-
if (
|
|
3353
|
-
const
|
|
3354
|
-
if (
|
|
3355
|
-
l[
|
|
3389
|
+
for (let m in r.attributes) {
|
|
3390
|
+
if (m.slice(0, 5) === "morph") continue;
|
|
3391
|
+
const E = r.attributes[m];
|
|
3392
|
+
if (m = f[m] || m.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(m) || (m = "_" + m), t.attributes.has(this.getUID(E))) {
|
|
3393
|
+
l[m] = t.attributes.get(this.getUID(E));
|
|
3356
3394
|
continue;
|
|
3357
3395
|
}
|
|
3358
3396
|
p = null;
|
|
3359
|
-
const
|
|
3360
|
-
|
|
3361
|
-
const
|
|
3362
|
-
|
|
3397
|
+
const M = E.array;
|
|
3398
|
+
m === "JOINTS_0" && !(M instanceof Uint16Array) && !(M instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new k(new Uint16Array(M), E.itemSize, E.normalized)) : (M instanceof Uint32Array || M instanceof Int32Array) && !m.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${m}" converted to type FLOAT.`), p = ee.Utils.toFloat32BufferAttribute(E));
|
|
3399
|
+
const g = this.processAccessor(p || E, r);
|
|
3400
|
+
g !== null && (m.startsWith("_") || this.detectMeshQuantization(m, E), l[m] = g, t.attributes.set(this.getUID(E), g));
|
|
3363
3401
|
}
|
|
3364
3402
|
if (u !== void 0 && r.setAttribute("normal", u), Object.keys(l).length === 0) return null;
|
|
3365
3403
|
if (e.morphTargetInfluences !== void 0 && e.morphTargetInfluences.length > 0) {
|
|
3366
|
-
const
|
|
3404
|
+
const m = [], E = [], L = {};
|
|
3367
3405
|
if (e.morphTargetDictionary !== void 0)
|
|
3368
|
-
for (const
|
|
3369
|
-
|
|
3370
|
-
for (let
|
|
3371
|
-
const
|
|
3372
|
-
let
|
|
3373
|
-
for (const
|
|
3374
|
-
if (
|
|
3375
|
-
|
|
3406
|
+
for (const M in e.morphTargetDictionary)
|
|
3407
|
+
L[e.morphTargetDictionary[M]] = M;
|
|
3408
|
+
for (let M = 0; M < e.morphTargetInfluences.length; ++M) {
|
|
3409
|
+
const g = {};
|
|
3410
|
+
let b = !1;
|
|
3411
|
+
for (const T in r.morphAttributes) {
|
|
3412
|
+
if (T !== "position" && T !== "normal") {
|
|
3413
|
+
b || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), b = !0);
|
|
3376
3414
|
continue;
|
|
3377
3415
|
}
|
|
3378
|
-
const
|
|
3379
|
-
if (t.attributes.has(this.getUID(
|
|
3380
|
-
|
|
3416
|
+
const A = r.morphAttributes[T][M], P = T.toUpperCase(), R = r.attributes[T];
|
|
3417
|
+
if (t.attributes.has(this.getUID(A, !0))) {
|
|
3418
|
+
g[P] = t.attributes.get(this.getUID(A, !0));
|
|
3381
3419
|
continue;
|
|
3382
3420
|
}
|
|
3383
|
-
const
|
|
3421
|
+
const I = A.clone();
|
|
3384
3422
|
if (!r.morphTargetsRelative)
|
|
3385
|
-
for (let N = 0,
|
|
3386
|
-
for (let O = 0; O <
|
|
3387
|
-
O === 0 &&
|
|
3388
|
-
|
|
3423
|
+
for (let N = 0, U = A.count; N < U; N++)
|
|
3424
|
+
for (let O = 0; O < A.itemSize; O++)
|
|
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
|
+
g[P] = this.processAccessor(I, r), t.attributes.set(this.getUID(R, !0), g[P]);
|
|
3389
3427
|
}
|
|
3390
|
-
h.push(
|
|
3428
|
+
h.push(g), m.push(e.morphTargetInfluences[M]), e.morphTargetDictionary !== void 0 && E.push(L[M]);
|
|
3391
3429
|
}
|
|
3392
|
-
a.weights =
|
|
3430
|
+
a.weights = m, E.length > 0 && (a.extras = {}, a.extras.targetNames = E);
|
|
3393
3431
|
}
|
|
3394
3432
|
const y = Array.isArray(e.material);
|
|
3395
3433
|
if (y && r.groups.length === 0) return null;
|
|
3396
3434
|
let x = !1;
|
|
3397
3435
|
if (y && r.index === null) {
|
|
3398
|
-
const
|
|
3399
|
-
for (let
|
|
3400
|
-
|
|
3401
|
-
r.setIndex(
|
|
3436
|
+
const m = [];
|
|
3437
|
+
for (let E = 0, L = r.attributes.position.count; E < L; E++)
|
|
3438
|
+
m[E] = E;
|
|
3439
|
+
r.setIndex(m), x = !0;
|
|
3402
3440
|
}
|
|
3403
|
-
const
|
|
3404
|
-
for (let
|
|
3405
|
-
const
|
|
3441
|
+
const S = y ? e.material : [e.material], D = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
3442
|
+
for (let m = 0, E = D.length; m < E; m++) {
|
|
3443
|
+
const L = {
|
|
3406
3444
|
mode: o,
|
|
3407
3445
|
attributes: l
|
|
3408
3446
|
};
|
|
3409
|
-
if (this.serializeUserData(r,
|
|
3410
|
-
let
|
|
3411
|
-
(
|
|
3447
|
+
if (this.serializeUserData(r, L), h.length > 0 && (L.targets = h), r.index !== null) {
|
|
3448
|
+
let g = this.getUID(r.index);
|
|
3449
|
+
(D[m].start !== void 0 || D[m].count !== void 0) && (g += ":" + D[m].start + ":" + D[m].count), t.attributes.has(g) ? L.indices = t.attributes.get(g) : (L.indices = this.processAccessor(r.index, r, D[m].start, D[m].count), t.attributes.set(g, L.indices)), L.indices === null && delete L.indices;
|
|
3412
3450
|
}
|
|
3413
|
-
const
|
|
3414
|
-
|
|
3451
|
+
const M = await this.processMaterialAsync(S[D[m].materialIndex]);
|
|
3452
|
+
M !== null && (L.material = M), c.push(L);
|
|
3415
3453
|
}
|
|
3416
|
-
x === !0 && r.setIndex(null), a.primitives = c, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(
|
|
3417
|
-
|
|
3454
|
+
x === !0 && r.setIndex(null), a.primitives = c, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(m) {
|
|
3455
|
+
m.writeMesh && m.writeMesh(e, a);
|
|
3418
3456
|
});
|
|
3419
|
-
const
|
|
3420
|
-
return t.meshes.set(i,
|
|
3457
|
+
const C = n.meshes.push(a) - 1;
|
|
3458
|
+
return t.meshes.set(i, C), C;
|
|
3421
3459
|
}
|
|
3422
3460
|
/**
|
|
3423
3461
|
* If a vertex attribute with a
|
|
@@ -3431,7 +3469,7 @@ class lt {
|
|
|
3431
3469
|
* @param {THREE.BufferAttribute} attribute
|
|
3432
3470
|
*/
|
|
3433
3471
|
detectMeshQuantization(e, t) {
|
|
3434
|
-
if (this.extensionsUsed[
|
|
3472
|
+
if (this.extensionsUsed[se]) return;
|
|
3435
3473
|
let n;
|
|
3436
3474
|
switch (t.array.constructor) {
|
|
3437
3475
|
case Int8Array:
|
|
@@ -3451,7 +3489,7 @@ class lt {
|
|
|
3451
3489
|
}
|
|
3452
3490
|
t.normalized && (n += " normalized");
|
|
3453
3491
|
const s = e.split("_", 1)[0];
|
|
3454
|
-
|
|
3492
|
+
xe[s] && xe[s].includes(n) && (this.extensionsUsed[se] = !0, this.extensionsRequired[se] = !0);
|
|
3455
3493
|
}
|
|
3456
3494
|
/**
|
|
3457
3495
|
* Process camera
|
|
@@ -3471,7 +3509,7 @@ class lt {
|
|
|
3471
3509
|
znear: e.near < 0 ? 0 : e.near
|
|
3472
3510
|
} : s.perspective = {
|
|
3473
3511
|
aspectRatio: e.aspect,
|
|
3474
|
-
yfov:
|
|
3512
|
+
yfov: oe.degToRad(e.fov),
|
|
3475
3513
|
zfar: e.far <= 0 ? 1e-3 : e.far,
|
|
3476
3514
|
znear: e.near < 0 ? 0 : e.near
|
|
3477
3515
|
}, e.name !== "" && (s.name = e.type), t.cameras.push(s) - 1;
|
|
@@ -3488,23 +3526,23 @@ class lt {
|
|
|
3488
3526
|
*/
|
|
3489
3527
|
processAnimation(e, t) {
|
|
3490
3528
|
const n = this.json, s = this.nodeMap;
|
|
3491
|
-
n.animations || (n.animations = []), e =
|
|
3529
|
+
n.animations || (n.animations = []), e = ee.Utils.mergeMorphTargetTracks(e.clone(), t);
|
|
3492
3530
|
const i = e.tracks, r = [], o = [];
|
|
3493
3531
|
for (let l = 0; l < i.length; ++l) {
|
|
3494
|
-
const c = i[l], h =
|
|
3495
|
-
let f =
|
|
3496
|
-
const u =
|
|
3532
|
+
const c = i[l], h = Q.parseTrackName(c.name);
|
|
3533
|
+
let f = Q.findNode(t, h.nodeName);
|
|
3534
|
+
const u = ye[h.propertyName];
|
|
3497
3535
|
if (h.objectName === "bones" && (f.isSkinnedMesh === !0 ? f = f.skeleton.getBoneByName(h.objectIndex) : f = void 0), !f || !u) {
|
|
3498
3536
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', c.name);
|
|
3499
3537
|
continue;
|
|
3500
3538
|
}
|
|
3501
3539
|
const p = 1;
|
|
3502
3540
|
let y = c.values.length / c.times.length;
|
|
3503
|
-
u ===
|
|
3541
|
+
u === ye.morphTargetInfluences && (y /= f.morphTargetInfluences.length);
|
|
3504
3542
|
let x;
|
|
3505
|
-
c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() ===
|
|
3506
|
-
input: this.processAccessor(new
|
|
3507
|
-
output: this.processAccessor(new
|
|
3543
|
+
c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : c.getInterpolation() === Ue ? x = "STEP" : x = "LINEAR", o.push({
|
|
3544
|
+
input: this.processAccessor(new k(c.times, p)),
|
|
3545
|
+
output: this.processAccessor(new k(c.values, y)),
|
|
3508
3546
|
interpolation: x
|
|
3509
3547
|
}), r.push({
|
|
3510
3548
|
sampler: o.length - 1,
|
|
@@ -3530,11 +3568,11 @@ class lt {
|
|
|
3530
3568
|
if (i === void 0) return null;
|
|
3531
3569
|
const r = e.skeleton.bones[0];
|
|
3532
3570
|
if (r === void 0) return null;
|
|
3533
|
-
const o = [], a = new Float32Array(i.bones.length * 16), l = new
|
|
3571
|
+
const o = [], a = new Float32Array(i.bones.length * 16), l = new Se();
|
|
3534
3572
|
for (let h = 0; h < i.bones.length; ++h)
|
|
3535
3573
|
o.push(n.get(i.bones[h])), l.copy(i.boneInverses[h]), l.multiply(e.bindMatrix).toArray(a, h * 16);
|
|
3536
3574
|
return t.skins === void 0 && (t.skins = []), t.skins.push({
|
|
3537
|
-
inverseBindMatrices: this.processAccessor(new
|
|
3575
|
+
inverseBindMatrices: this.processAccessor(new k(a, 16)),
|
|
3538
3576
|
joints: o,
|
|
3539
3577
|
skeleton: n.get(r)
|
|
3540
3578
|
}), s.skin = t.skins.length - 1;
|
|
@@ -3550,9 +3588,9 @@ class lt {
|
|
|
3550
3588
|
const i = {};
|
|
3551
3589
|
if (n.trs) {
|
|
3552
3590
|
const o = e.quaternion.toArray(), a = e.position.toArray(), l = e.scale.toArray();
|
|
3553
|
-
|
|
3591
|
+
K(o, [0, 0, 0, 1]) || (i.rotation = o), K(a, [0, 0, 0]) || (i.translation = a), K(l, [1, 1, 1]) || (i.scale = l);
|
|
3554
3592
|
} else
|
|
3555
|
-
e.matrixAutoUpdate && e.updateMatrix(),
|
|
3593
|
+
e.matrixAutoUpdate && e.updateMatrix(), lt(e.matrix) === !1 && (i.matrix = e.matrix.elements);
|
|
3556
3594
|
if (e.name !== "" && (i.name = String(e.name)), this.serializeUserData(e, i), e.isMesh || e.isLine || e.isPoints) {
|
|
3557
3595
|
const o = await this.processMeshAsync(e);
|
|
3558
3596
|
o !== null && (i.mesh = o);
|
|
@@ -3598,7 +3636,7 @@ class lt {
|
|
|
3598
3636
|
* @param {Array<THREE.Object3D>} objects List of objects to process
|
|
3599
3637
|
*/
|
|
3600
3638
|
async processObjectsAsync(e) {
|
|
3601
|
-
const t = new
|
|
3639
|
+
const t = new ue();
|
|
3602
3640
|
t.name = "AuxScene";
|
|
3603
3641
|
for (let n = 0; n < e.length; n++)
|
|
3604
3642
|
t.children.push(e[n]);
|
|
@@ -3614,7 +3652,7 @@ class lt {
|
|
|
3614
3652
|
});
|
|
3615
3653
|
const n = [];
|
|
3616
3654
|
for (let s = 0; s < e.length; s++)
|
|
3617
|
-
e[s] instanceof
|
|
3655
|
+
e[s] instanceof ue ? await this.processSceneAsync(e[s]) : n.push(e[s]);
|
|
3618
3656
|
n.length > 0 && await this.processObjectsAsync(n);
|
|
3619
3657
|
for (let s = 0; s < this.skins.length; ++s)
|
|
3620
3658
|
this.processSkin(this.skins[s]);
|
|
@@ -3629,7 +3667,7 @@ class lt {
|
|
|
3629
3667
|
await e(this.plugins[t]);
|
|
3630
3668
|
}
|
|
3631
3669
|
}
|
|
3632
|
-
class
|
|
3670
|
+
class ft {
|
|
3633
3671
|
constructor(e) {
|
|
3634
3672
|
this.writer = e, this.name = "KHR_lights_punctual";
|
|
3635
3673
|
}
|
|
@@ -3645,7 +3683,7 @@ class ht {
|
|
|
3645
3683
|
o.push(r), t.extensions = t.extensions || {}, t.extensions[this.name] = { light: o.length - 1 };
|
|
3646
3684
|
}
|
|
3647
3685
|
}
|
|
3648
|
-
class
|
|
3686
|
+
class pt {
|
|
3649
3687
|
constructor(e) {
|
|
3650
3688
|
this.writer = e, this.name = "KHR_materials_unlit";
|
|
3651
3689
|
}
|
|
@@ -3655,7 +3693,7 @@ class ut {
|
|
|
3655
3693
|
t.extensions = t.extensions || {}, t.extensions[this.name] = {}, s[this.name] = !0, t.pbrMetallicRoughness.metallicFactor = 0, t.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
3656
3694
|
}
|
|
3657
3695
|
}
|
|
3658
|
-
class
|
|
3696
|
+
class xt {
|
|
3659
3697
|
constructor(e) {
|
|
3660
3698
|
this.writer = e, this.name = "KHR_materials_clearcoat";
|
|
3661
3699
|
}
|
|
@@ -3686,7 +3724,7 @@ class dt {
|
|
|
3686
3724
|
t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3687
3725
|
}
|
|
3688
3726
|
}
|
|
3689
|
-
class
|
|
3727
|
+
class yt {
|
|
3690
3728
|
constructor(e) {
|
|
3691
3729
|
this.writer = e, this.name = "KHR_materials_dispersion";
|
|
3692
3730
|
}
|
|
@@ -3696,7 +3734,7 @@ class ft {
|
|
|
3696
3734
|
i.dispersion = e.dispersion, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3697
3735
|
}
|
|
3698
3736
|
}
|
|
3699
|
-
class
|
|
3737
|
+
class mt {
|
|
3700
3738
|
constructor(e) {
|
|
3701
3739
|
this.writer = e, this.name = "KHR_materials_iridescence";
|
|
3702
3740
|
}
|
|
@@ -3720,7 +3758,7 @@ class pt {
|
|
|
3720
3758
|
t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3721
3759
|
}
|
|
3722
3760
|
}
|
|
3723
|
-
class
|
|
3761
|
+
class gt {
|
|
3724
3762
|
constructor(e) {
|
|
3725
3763
|
this.writer = e, this.name = "KHR_materials_transmission";
|
|
3726
3764
|
}
|
|
@@ -3737,7 +3775,7 @@ class xt {
|
|
|
3737
3775
|
t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3738
3776
|
}
|
|
3739
3777
|
}
|
|
3740
|
-
class
|
|
3778
|
+
class wt {
|
|
3741
3779
|
constructor(e) {
|
|
3742
3780
|
this.writer = e, this.name = "KHR_materials_volume";
|
|
3743
3781
|
}
|
|
@@ -3754,7 +3792,7 @@ class yt {
|
|
|
3754
3792
|
e.attenuationDistance !== 1 / 0 && (i.attenuationDistance = e.attenuationDistance), i.attenuationColor = e.attenuationColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3755
3793
|
}
|
|
3756
3794
|
}
|
|
3757
|
-
class
|
|
3795
|
+
class Mt {
|
|
3758
3796
|
constructor(e) {
|
|
3759
3797
|
this.writer = e, this.name = "KHR_materials_ior";
|
|
3760
3798
|
}
|
|
@@ -3764,12 +3802,12 @@ class mt {
|
|
|
3764
3802
|
i.ior = e.ior, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3765
3803
|
}
|
|
3766
3804
|
}
|
|
3767
|
-
class
|
|
3805
|
+
class St {
|
|
3768
3806
|
constructor(e) {
|
|
3769
3807
|
this.writer = e, this.name = "KHR_materials_specular";
|
|
3770
3808
|
}
|
|
3771
3809
|
async writeMaterialAsync(e, t) {
|
|
3772
|
-
if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(
|
|
3810
|
+
if (!e.isMeshPhysicalMaterial || e.specularIntensity === 1 && e.specularColor.equals(st) && !e.specularIntensityMap && !e.specularColorMap) return;
|
|
3773
3811
|
const n = this.writer, s = n.extensionsUsed, i = {};
|
|
3774
3812
|
if (e.specularIntensityMap) {
|
|
3775
3813
|
const r = {
|
|
@@ -3788,7 +3826,7 @@ class gt {
|
|
|
3788
3826
|
i.specularFactor = e.specularIntensity, i.specularColorFactor = e.specularColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3789
3827
|
}
|
|
3790
3828
|
}
|
|
3791
|
-
class
|
|
3829
|
+
class Lt {
|
|
3792
3830
|
constructor(e) {
|
|
3793
3831
|
this.writer = e, this.name = "KHR_materials_sheen";
|
|
3794
3832
|
}
|
|
@@ -3812,7 +3850,7 @@ class wt {
|
|
|
3812
3850
|
i.sheenRoughnessFactor = e.sheenRoughness, i.sheenColorFactor = e.sheenColor.toArray(), t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3813
3851
|
}
|
|
3814
3852
|
}
|
|
3815
|
-
class
|
|
3853
|
+
class Et {
|
|
3816
3854
|
constructor(e) {
|
|
3817
3855
|
this.writer = e, this.name = "KHR_materials_anisotropy";
|
|
3818
3856
|
}
|
|
@@ -3826,7 +3864,7 @@ class Mt {
|
|
|
3826
3864
|
i.anisotropyStrength = e.anisotropy, i.anisotropyRotation = e.anisotropyRotation, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3827
3865
|
}
|
|
3828
3866
|
}
|
|
3829
|
-
class
|
|
3867
|
+
class Tt {
|
|
3830
3868
|
constructor(e) {
|
|
3831
3869
|
this.writer = e, this.name = "KHR_materials_emissive_strength";
|
|
3832
3870
|
}
|
|
@@ -3836,7 +3874,7 @@ class St {
|
|
|
3836
3874
|
i.emissiveStrength = e.emissiveIntensity, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3837
3875
|
}
|
|
3838
3876
|
}
|
|
3839
|
-
class
|
|
3877
|
+
class At {
|
|
3840
3878
|
constructor(e) {
|
|
3841
3879
|
this.writer = e, this.name = "EXT_materials_bump";
|
|
3842
3880
|
}
|
|
@@ -3853,24 +3891,24 @@ class Tt {
|
|
|
3853
3891
|
i.bumpFactor = e.bumpScale, t.extensions = t.extensions || {}, t.extensions[this.name] = i, s[this.name] = !0;
|
|
3854
3892
|
}
|
|
3855
3893
|
}
|
|
3856
|
-
class
|
|
3894
|
+
class bt {
|
|
3857
3895
|
constructor(e) {
|
|
3858
3896
|
this.writer = e, this.name = "EXT_mesh_gpu_instancing";
|
|
3859
3897
|
}
|
|
3860
3898
|
writeNode(e, t) {
|
|
3861
3899
|
if (!e.isInstancedMesh) return;
|
|
3862
|
-
const n = this.writer, s = e, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new
|
|
3900
|
+
const n = this.writer, s = e, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Se(), l = new Z(), c = new Pe(), h = new Z();
|
|
3863
3901
|
for (let u = 0; u < s.count; u++)
|
|
3864
3902
|
s.getMatrixAt(u, a), a.decompose(l, c, h), l.toArray(i, u * 3), c.toArray(r, u * 4), h.toArray(o, u * 3);
|
|
3865
3903
|
const f = {
|
|
3866
|
-
TRANSLATION: n.processAccessor(new
|
|
3867
|
-
ROTATION: n.processAccessor(new
|
|
3868
|
-
SCALE: n.processAccessor(new
|
|
3904
|
+
TRANSLATION: n.processAccessor(new k(i, 3)),
|
|
3905
|
+
ROTATION: n.processAccessor(new k(r, 4)),
|
|
3906
|
+
SCALE: n.processAccessor(new k(o, 3))
|
|
3869
3907
|
};
|
|
3870
3908
|
s.instanceColor && (f._COLOR_0 = n.processAccessor(s.instanceColor)), t.extensions = t.extensions || {}, t.extensions[this.name] = { attributes: f }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
|
|
3871
3909
|
}
|
|
3872
3910
|
}
|
|
3873
|
-
|
|
3911
|
+
ee.Utils = {
|
|
3874
3912
|
insertKeyframe: function(d, e) {
|
|
3875
3913
|
const n = d.getValueSize(), s = new d.TimeBufferType(d.times.length + 1), i = new d.ValueBufferType(d.values.length + n), r = d.createInterpolant(new d.ValueBufferType(n));
|
|
3876
3914
|
let o;
|
|
@@ -3900,7 +3938,7 @@ $.Utils = {
|
|
|
3900
3938
|
const t = [], n = {}, s = d.tracks;
|
|
3901
3939
|
for (let i = 0; i < s.length; ++i) {
|
|
3902
3940
|
let r = s[i];
|
|
3903
|
-
const o =
|
|
3941
|
+
const o = Q.parseTrackName(r.name), a = Q.findNode(e, o.nodeName);
|
|
3904
3942
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
3905
3943
|
t.push(r);
|
|
3906
3944
|
continue;
|
|
@@ -3908,7 +3946,7 @@ $.Utils = {
|
|
|
3908
3946
|
if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
|
|
3909
3947
|
if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
3910
3948
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
3911
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(
|
|
3949
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(He);
|
|
3912
3950
|
}
|
|
3913
3951
|
const l = a.morphTargetInfluences.length, c = a.morphTargetDictionary[o.propertyIndex];
|
|
3914
3952
|
if (c === void 0)
|
|
@@ -3934,7 +3972,7 @@ $.Utils = {
|
|
|
3934
3972
|
return d.tracks = t, d;
|
|
3935
3973
|
},
|
|
3936
3974
|
toFloat32BufferAttribute: function(d) {
|
|
3937
|
-
const e = new
|
|
3975
|
+
const e = new k(new Float32Array(d.count * d.itemSize), d.itemSize, !1);
|
|
3938
3976
|
if (!d.normalized && !d.isInterleavedBufferAttribute)
|
|
3939
3977
|
return e.array.set(d.array), e;
|
|
3940
3978
|
for (let t = 0, n = d.count; t < n; t++)
|
|
@@ -3943,11 +3981,11 @@ $.Utils = {
|
|
|
3943
3981
|
return e;
|
|
3944
3982
|
}
|
|
3945
3983
|
};
|
|
3946
|
-
async function
|
|
3984
|
+
async function Dt(d) {
|
|
3947
3985
|
const e = await d.arrayBuffer(), n = Buffer.from(e).toString("base64");
|
|
3948
3986
|
return `data:${d.type};base64,${n}`;
|
|
3949
3987
|
}
|
|
3950
|
-
async function
|
|
3988
|
+
async function re(d) {
|
|
3951
3989
|
if (typeof d.arrayBuffer == "function")
|
|
3952
3990
|
return await d.arrayBuffer();
|
|
3953
3991
|
if (typeof FileReader < "u")
|
|
@@ -3960,33 +3998,33 @@ async function ne(d) {
|
|
|
3960
3998
|
return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
|
|
3961
3999
|
}
|
|
3962
4000
|
}
|
|
3963
|
-
const
|
|
3964
|
-
function
|
|
4001
|
+
const It = new Je(), Rt = new ee();
|
|
4002
|
+
function Pt(d, e, t = 0.1) {
|
|
3965
4003
|
const n = e.normal(d), s = e.direction(d).mutiplyScalar(t * 0.5), i = d.direction(e).mutiplyScalar(t * 0.5), r = n.x * t * 0.5, o = n.y * t * 0.5;
|
|
3966
4004
|
return {
|
|
3967
4005
|
points: [
|
|
3968
4006
|
// 第一条线
|
|
3969
|
-
new
|
|
3970
|
-
new
|
|
4007
|
+
new w(d.x + r, d.y + o).add(i),
|
|
4008
|
+
new w(e.x + r, e.y + o).add(s),
|
|
3971
4009
|
// 第二条线
|
|
3972
|
-
new
|
|
3973
|
-
new
|
|
4010
|
+
new w(d.x - r, d.y - o).add(i),
|
|
4011
|
+
new w(e.x - r, e.y - o).add(s)
|
|
3974
4012
|
],
|
|
3975
4013
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
3976
4014
|
rectIndices: [0, 1, 3, 2, 0]
|
|
3977
4015
|
};
|
|
3978
4016
|
}
|
|
3979
|
-
class
|
|
4017
|
+
class Ae extends W {
|
|
3980
4018
|
static name = "WhiteModel";
|
|
3981
4019
|
Dxf = null;
|
|
3982
4020
|
Variable = null;
|
|
3983
4021
|
// dxf数据白模
|
|
3984
|
-
whiteModelGroup = new
|
|
4022
|
+
whiteModelGroup = new G.Group();
|
|
3985
4023
|
// dxf数据白模边缘线
|
|
3986
|
-
whiteModelLineGroup = new
|
|
4024
|
+
whiteModelLineGroup = new G.Group();
|
|
3987
4025
|
// 原始数据白模
|
|
3988
|
-
originalWhiteMode = new
|
|
3989
|
-
material = new
|
|
4026
|
+
originalWhiteMode = new G.Group();
|
|
4027
|
+
material = new G.MeshStandardMaterial({ color: 16777215, transparent: !0, opacity: 0.8, side: G.DoubleSide });
|
|
3990
4028
|
onAddFromParent(e) {
|
|
3991
4029
|
this.Dxf = e.findComponentByName("Dxf"), this.Variable = e.findComponentByName("Variable"), this.originalWhiteMode.visible = !1, this.Dxf?.addEventListener("lineOffset", () => {
|
|
3992
4030
|
this.updateModel();
|
|
@@ -3996,17 +4034,17 @@ class Te extends j {
|
|
|
3996
4034
|
this.Variable?.set("whiteModelVisible", !1);
|
|
3997
4035
|
const e = this.Dxf;
|
|
3998
4036
|
this.originalWhiteMode.clear(), this.whiteModelGroup.clear(), this.whiteModelLineGroup.clear(), this.whiteModelGroup.add(this.whiteModelLineGroup), this.whiteModelGroup.position.z = e.originalZAverage, this.originalWhiteMode.position.z = e.originalZAverage, e.wallsGroup.forEach((n) => {
|
|
3999
|
-
const s = new
|
|
4037
|
+
const s = new G.Shape();
|
|
4000
4038
|
n.forEach((o, a) => a === 0 ? s.moveTo(o.x / e.scale, o.y / e.scale) : s.lineTo(o.x / e.scale, o.y / e.scale));
|
|
4001
|
-
const i = new
|
|
4039
|
+
const i = new G.ExtrudeGeometry(s, {
|
|
4002
4040
|
depth: 2.8,
|
|
4003
4041
|
bevelSize: 0
|
|
4004
|
-
}), r = new
|
|
4042
|
+
}), r = new G.Mesh(i, this.material);
|
|
4005
4043
|
this.whiteModelGroup.add(r), this.whiteModelLineGroup.add(
|
|
4006
|
-
new
|
|
4044
|
+
new G.LineSegments(new G.EdgesGeometry(i), new G.LineBasicMaterial({ color: 0 }))
|
|
4007
4045
|
);
|
|
4008
4046
|
}), e.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
4009
|
-
const r = new
|
|
4047
|
+
const r = new w(n.x, n.y).mutiplyScalar(e.scale), o = new w(s.x, s.y).mutiplyScalar(e.scale), { points: a, indices: l, rectIndices: c } = Pt(r, o, e.width);
|
|
4010
4048
|
return {
|
|
4011
4049
|
points: a,
|
|
4012
4050
|
indices: l,
|
|
@@ -4014,17 +4052,17 @@ class Te extends j {
|
|
|
4014
4052
|
insetions: (i ?? []).map((h) => h.index)
|
|
4015
4053
|
};
|
|
4016
4054
|
}).forEach((n) => {
|
|
4017
|
-
const s = new
|
|
4055
|
+
const s = new G.Shape();
|
|
4018
4056
|
n.rectIndices.forEach((o, a) => {
|
|
4019
4057
|
const l = n.points[o];
|
|
4020
4058
|
a === 0 ? s.moveTo(l.x, l.y) : s.lineTo(l.x, l.y);
|
|
4021
4059
|
});
|
|
4022
|
-
const i = new
|
|
4060
|
+
const i = new G.ExtrudeGeometry(s, {
|
|
4023
4061
|
depth: 2.8,
|
|
4024
4062
|
bevelSize: 0
|
|
4025
4063
|
});
|
|
4026
4064
|
if (i.attributes.position.array.filter((o) => Number.isNaN(o)).length) return;
|
|
4027
|
-
const r = new
|
|
4065
|
+
const r = new G.Mesh(i);
|
|
4028
4066
|
this.originalWhiteMode?.add(r);
|
|
4029
4067
|
}), this.dispatchEvent({
|
|
4030
4068
|
type: "updateModel",
|
|
@@ -4039,7 +4077,7 @@ class Te extends j {
|
|
|
4039
4077
|
toOBJ() {
|
|
4040
4078
|
return new Promise((e) => {
|
|
4041
4079
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
4042
|
-
e(
|
|
4080
|
+
e(It.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4043
4081
|
}, 20);
|
|
4044
4082
|
});
|
|
4045
4083
|
}
|
|
@@ -4051,7 +4089,7 @@ class Te extends j {
|
|
|
4051
4089
|
toGltf(e = !0) {
|
|
4052
4090
|
return new Promise((t) => {
|
|
4053
4091
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
4054
|
-
|
|
4092
|
+
Rt.parse(this.whiteModelGroup.children, (n) => {
|
|
4055
4093
|
t(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4056
4094
|
}, () => {
|
|
4057
4095
|
t(void 0);
|
|
@@ -4092,7 +4130,7 @@ class Te extends j {
|
|
|
4092
4130
|
n.href = URL.createObjectURL(t), n.download = e, n.click();
|
|
4093
4131
|
} else if (typeof global < "u") {
|
|
4094
4132
|
const t = await this.toOBJ();
|
|
4095
|
-
t && (await
|
|
4133
|
+
t && (await H("fs", !1)).writeFileSync(e, t);
|
|
4096
4134
|
}
|
|
4097
4135
|
}
|
|
4098
4136
|
/**
|
|
@@ -4108,11 +4146,11 @@ class Te extends j {
|
|
|
4108
4146
|
s.href = URL.createObjectURL(n), s.download = e, s.click();
|
|
4109
4147
|
} else if (typeof global < "u") {
|
|
4110
4148
|
const n = await this.toGltf(t);
|
|
4111
|
-
n && (await
|
|
4149
|
+
n && (await H("fs", !1)).writeFileSync(e, t ? Buffer.from(n) : JSON.stringify(n));
|
|
4112
4150
|
}
|
|
4113
4151
|
}
|
|
4114
4152
|
}
|
|
4115
|
-
class
|
|
4153
|
+
class be extends W {
|
|
4116
4154
|
static name = "DetailsPoint";
|
|
4117
4155
|
Dxf = null;
|
|
4118
4156
|
WhiteModel = null;
|
|
@@ -4163,17 +4201,17 @@ class Ee extends j {
|
|
|
4163
4201
|
this._timer = null;
|
|
4164
4202
|
const e = this.parent?.findComponentByName("WhiteModel");
|
|
4165
4203
|
this.raylines.length = 0, this.desPoints.length = 0, this.data.forEach((t) => {
|
|
4166
|
-
const n = new
|
|
4204
|
+
const n = new G.Vector3(
|
|
4167
4205
|
t.position.x,
|
|
4168
4206
|
t.position.y,
|
|
4169
4207
|
t.position.z
|
|
4170
|
-
), s = new
|
|
4208
|
+
), s = new G.Vector3(
|
|
4171
4209
|
t.direction.x,
|
|
4172
4210
|
t.direction.y,
|
|
4173
4211
|
t.direction.z
|
|
4174
4212
|
), i = 100;
|
|
4175
4213
|
this.racasterHelper(n, s, i), s.z = 0;
|
|
4176
|
-
const o = new
|
|
4214
|
+
const o = new G.Raycaster(n, s, 0, i).intersectObject(e.originalWhiteMode);
|
|
4177
4215
|
if (o.length) {
|
|
4178
4216
|
const { point: a } = o[0];
|
|
4179
4217
|
this.desPoints.push({
|
|
@@ -4189,61 +4227,61 @@ class Ee extends j {
|
|
|
4189
4227
|
}, 50);
|
|
4190
4228
|
}
|
|
4191
4229
|
}
|
|
4192
|
-
class
|
|
4230
|
+
class De extends W {
|
|
4193
4231
|
static name = "DxfLineModel";
|
|
4194
|
-
dxfLineModel = new
|
|
4195
|
-
dxfDoorsLineModel = new
|
|
4196
|
-
dxfModelGroup = new
|
|
4232
|
+
dxfLineModel = new G.LineSegments();
|
|
4233
|
+
dxfDoorsLineModel = new G.LineSegments();
|
|
4234
|
+
dxfModelGroup = new G.Group();
|
|
4197
4235
|
onAddFromParent(e) {
|
|
4198
4236
|
const t = e.findComponentByName("Dxf");
|
|
4199
|
-
this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new
|
|
4237
|
+
this.dxfModelGroup.add(this.dxfLineModel), this.dxfModelGroup.add(this.dxfDoorsLineModel), this.dxfDoorsLineModel.material = new G.LineBasicMaterial({ color: 16776960, vertexColors: !0 }), t?.addEventListener("lineOffset", () => this.updateMode());
|
|
4200
4238
|
}
|
|
4201
4239
|
updateMode() {
|
|
4202
4240
|
const e = this.parent?.findComponentByName("Dxf");
|
|
4203
4241
|
this.dxfLineModel.clear();
|
|
4204
4242
|
const t = e.to3DArray(1 / e.scale, 0);
|
|
4205
|
-
this.dxfLineModel.geometry = new
|
|
4243
|
+
this.dxfLineModel.geometry = new G.BufferGeometry().setAttribute("position", new G.BufferAttribute(t, 3, !0));
|
|
4206
4244
|
const n = new Float32Array(
|
|
4207
4245
|
e.doorLineSegment.flatMap(({ start: i, end: r }) => [i.x, i.y, 0, r.x, r.y, 0])
|
|
4208
4246
|
).map((i) => i / e.scale), s = new Float32Array(e.doorLineSegment.flatMap(() => [1, 0, 0, 0, 1, 0]));
|
|
4209
|
-
this.dxfDoorsLineModel.geometry = new
|
|
4247
|
+
this.dxfDoorsLineModel.geometry = new G.BufferGeometry().setAttribute("position", new G.BufferAttribute(n, 3, !0)).setAttribute("color", new G.BufferAttribute(s, 3)), this.dxfModelGroup.position.z = e.originalZAverage, this.dispatchEvent({
|
|
4210
4248
|
type: "modelUpdate",
|
|
4211
4249
|
model: this.dxfModelGroup
|
|
4212
4250
|
});
|
|
4213
4251
|
}
|
|
4214
4252
|
}
|
|
4215
|
-
const
|
|
4253
|
+
const Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4216
4254
|
__proto__: null,
|
|
4217
|
-
DetailsPoint:
|
|
4218
|
-
DxfLineModel:
|
|
4219
|
-
WhiteModel:
|
|
4255
|
+
DetailsPoint: be,
|
|
4256
|
+
DxfLineModel: De,
|
|
4257
|
+
WhiteModel: Ae
|
|
4220
4258
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4221
|
-
function
|
|
4259
|
+
function Me(d, e = {}) {
|
|
4222
4260
|
const {
|
|
4223
4261
|
detailsPoint: t = !0,
|
|
4224
4262
|
whiteModel: n = !0,
|
|
4225
4263
|
dxfLineModel: s = !0
|
|
4226
4264
|
} = e;
|
|
4227
|
-
s && d.addComponent(new
|
|
4265
|
+
s && d.addComponent(new De()), n && d.addComponent(new Ae()), t && d.addComponent(new be());
|
|
4228
4266
|
}
|
|
4229
|
-
const
|
|
4267
|
+
const vt = Object.assign(Me, {
|
|
4230
4268
|
create(d = {}) {
|
|
4231
|
-
return (e) =>
|
|
4269
|
+
return (e) => Me(e, d);
|
|
4232
4270
|
}
|
|
4233
|
-
}),
|
|
4271
|
+
}), Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4234
4272
|
__proto__: null,
|
|
4235
|
-
ModelDataPlugin:
|
|
4236
|
-
components:
|
|
4273
|
+
ModelDataPlugin: vt,
|
|
4274
|
+
components: Nt
|
|
4237
4275
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4238
|
-
function
|
|
4276
|
+
function Bt() {
|
|
4239
4277
|
return import("./index2.js");
|
|
4240
4278
|
}
|
|
4241
|
-
function
|
|
4279
|
+
function Ot() {
|
|
4242
4280
|
return import("./index3.js");
|
|
4243
4281
|
}
|
|
4244
|
-
let
|
|
4245
|
-
async function
|
|
4246
|
-
const s = await Promise.resolve().then(() =>
|
|
4282
|
+
let he = null;
|
|
4283
|
+
async function qt(d, e, t = !1, n) {
|
|
4284
|
+
const s = await Promise.resolve().then(() => Ct), i = await Bt(), r = await Ot(), o = new nt().usePlugin(s.ModelDataPlugin.create({
|
|
4247
4285
|
detailsPoint: !1,
|
|
4248
4286
|
whiteModel: !0
|
|
4249
4287
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4253,12 +4291,12 @@ async function Ft(d, e, t = !1, n) {
|
|
|
4253
4291
|
orbitControls: t,
|
|
4254
4292
|
camera: e
|
|
4255
4293
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4256
|
-
return a && d.appendChild(a.domElement),
|
|
4294
|
+
return a && d.appendChild(a.domElement), he = o, {
|
|
4257
4295
|
dxfSystem: o,
|
|
4258
|
-
getFileAll: () =>
|
|
4296
|
+
getFileAll: () => Gt(o)
|
|
4259
4297
|
};
|
|
4260
4298
|
}
|
|
4261
|
-
async function
|
|
4299
|
+
async function Gt(d = he) {
|
|
4262
4300
|
const e = d.findComponentByName("WhiteModel"), t = new File([await d.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([d.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([d.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await e.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await e.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await e.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(d.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
4263
4301
|
return {
|
|
4264
4302
|
dxf: n,
|
|
@@ -4270,26 +4308,27 @@ async function Ct(d = ae) {
|
|
|
4270
4308
|
correctionDxf: s
|
|
4271
4309
|
};
|
|
4272
4310
|
}
|
|
4273
|
-
function
|
|
4274
|
-
return
|
|
4311
|
+
function jt() {
|
|
4312
|
+
return he;
|
|
4275
4313
|
}
|
|
4276
4314
|
export {
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4315
|
+
_ as B,
|
|
4316
|
+
W as C,
|
|
4317
|
+
nt as D,
|
|
4318
|
+
Le as E,
|
|
4319
|
+
B as L,
|
|
4320
|
+
vt as M,
|
|
4321
|
+
w as P,
|
|
4322
|
+
Y as Q,
|
|
4323
|
+
tt as T,
|
|
4324
|
+
Ee as V,
|
|
4325
|
+
Ae as W,
|
|
4326
|
+
be as a,
|
|
4327
|
+
ce as b,
|
|
4328
|
+
X as c,
|
|
4329
|
+
qt as d,
|
|
4330
|
+
jt as e,
|
|
4331
|
+
Gt as g,
|
|
4332
|
+
Nt as i,
|
|
4333
|
+
ae as u
|
|
4295
4334
|
};
|