build-dxf 0.0.42 → 0.0.44
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 +796 -705
- package/src/index3.js +337 -339
- package/src/pages/Editor.vue.d.ts +1 -1
- package/src/selectLocalFile.js +4640 -1769
- package/src/utils/DxfSystem/DxfSystem.d.ts +4 -0
- package/src/utils/DxfSystem/components/AngleCorrectionDxf.d.ts +2 -2
- package/src/utils/DxfSystem/components/DoorsAnalysis.d.ts +118 -0
- package/src/utils/DxfSystem/components/LineAnalysis.d.ts +0 -94
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/RenderManager.d.ts +3 -3
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/Renderer.d.ts +7 -1
- package/src/utils/DxfSystem/type.d.ts +1 -0
- package/src/utils/DxfSystem/utils/drawHelper.d.ts +6 -0
- package/src/utils/DxfSystem/utils/extractClosedPolygons.d.ts +11 -0
- package/src/utils/PointVirtualGrid/index.d.ts +2 -1
- package/src/utils/Quadtree/LineSegment.d.ts +1 -1
- package/src/utils/Quadtree/Point.d.ts +7 -0
package/src/build.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as I from "three";
|
|
2
|
-
import { EventDispatcher as
|
|
2
|
+
import { EventDispatcher as Ft, Color as Ut, Matrix4 as Tt, Vector3 as Q, Quaternion as jt, BufferAttribute as _, REVISION as Gt, CompressedTexture as rt, Source as zt, NoColorSpace as qt, MathUtils as lt, RGBAFormat as _t, ImageUtils as Yt, DoubleSide as kt, PropertyBinding as tt, InterpolateDiscrete as Xt, Scene as ft, SRGBColorSpace as Vt, NearestFilter as Wt, NearestMipmapNearestFilter as Ht, NearestMipmapLinearFilter as Jt, LinearFilter as $t, LinearMipmapNearestFilter as Kt, LinearMipmapLinearFilter as Zt, ClampToEdgeWrapping as Qt, RepeatWrapping as te, MirroredRepeatWrapping as ee, InterpolateLinear as ne } from "three";
|
|
3
3
|
import pt from "clipper-lib";
|
|
4
|
-
import
|
|
5
|
-
import { OBJExporter as
|
|
6
|
-
function
|
|
4
|
+
import K from "dxf-writer";
|
|
5
|
+
import { OBJExporter as se } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
+
function Z() {
|
|
7
7
|
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(u) {
|
|
8
8
|
var t = Math.random() * 16 | 0, e = u == "x" ? t : t & 3 | 8;
|
|
9
9
|
return e.toString(16);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
class
|
|
13
|
-
uuid =
|
|
12
|
+
class bt extends Ft {
|
|
13
|
+
uuid = Z();
|
|
14
14
|
addEventListener(t, e, n) {
|
|
15
15
|
const { once: s = !1 } = n ?? {}, i = (o) => {
|
|
16
16
|
e(o), s && r();
|
|
@@ -30,7 +30,7 @@ class It extends Ot {
|
|
|
30
30
|
e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class z extends bt {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...t) {
|
|
@@ -48,7 +48,7 @@ class _ extends It {
|
|
|
48
48
|
this.destroyed = !0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
class ie extends bt {
|
|
52
52
|
static EventType = {
|
|
53
53
|
ADD_COMPONENT: "addComponent"
|
|
54
54
|
};
|
|
@@ -71,7 +71,7 @@ class se extends It {
|
|
|
71
71
|
* @param component
|
|
72
72
|
*/
|
|
73
73
|
removeComponent(t) {
|
|
74
|
-
if (t instanceof
|
|
74
|
+
if (t instanceof z) {
|
|
75
75
|
const e = this.components.indexOf(t);
|
|
76
76
|
e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
|
|
77
77
|
type: "removeComponent",
|
|
@@ -116,7 +116,7 @@ class se extends It {
|
|
|
116
116
|
return e || null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class P {
|
|
120
120
|
minX = 0;
|
|
121
121
|
maxX = 0;
|
|
122
122
|
minY = 0;
|
|
@@ -203,8 +203,8 @@ class N {
|
|
|
203
203
|
for (let c = 0; c < 4; c++) {
|
|
204
204
|
const l = o[c], h = o[(c + 1) % 4];
|
|
205
205
|
for (let d = 0; d < 4; d++) {
|
|
206
|
-
const f = e[d], p = e[(d + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x),
|
|
207
|
-
if (y * x < 0 &&
|
|
206
|
+
const f = e[d], p = e[(d + 1) % 4], y = (h.x - l.x) * (f.y - l.y) - (h.y - l.y) * (f.x - l.x), x = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), g = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), w = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
|
|
207
|
+
if (y * x < 0 && g * w < 0 || y === 0 && Math.min(l.x, h.x) <= f.x && f.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= f.y && f.y <= Math.max(l.y, h.y) || x === 0 && Math.min(l.x, h.x) <= p.x && p.x <= Math.max(l.x, h.x) && Math.min(l.y, h.y) <= p.y && p.y <= Math.max(l.y, h.y) || g === 0 && Math.min(f.x, p.x) <= l.x && l.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= l.y && l.y <= Math.max(f.y, p.y) || w === 0 && Math.min(f.x, p.x) <= h.x && h.x <= Math.max(f.x, p.x) && Math.min(f.y, p.y) <= h.y && h.y <= Math.max(f.y, p.y))
|
|
208
208
|
return !0;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -299,7 +299,7 @@ class N {
|
|
|
299
299
|
* @returns
|
|
300
300
|
*/
|
|
301
301
|
clone() {
|
|
302
|
-
return new
|
|
302
|
+
return new P(this.minX, this.maxX, this.minY, this.maxY);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
*
|
|
@@ -310,7 +310,7 @@ class N {
|
|
|
310
310
|
const e = [], n = [];
|
|
311
311
|
return t.forEach((s) => {
|
|
312
312
|
e.push(s.x), n.push(s.y);
|
|
313
|
-
}), new
|
|
313
|
+
}), new P(
|
|
314
314
|
Math.min(...e),
|
|
315
315
|
Math.max(...e),
|
|
316
316
|
Math.min(...n),
|
|
@@ -328,7 +328,7 @@ class N {
|
|
|
328
328
|
s?.points?.forEach((i) => {
|
|
329
329
|
e.push(i.x), n.push(i.y);
|
|
330
330
|
});
|
|
331
|
-
}), new
|
|
331
|
+
}), new P(
|
|
332
332
|
Math.min(...e),
|
|
333
333
|
Math.max(...e),
|
|
334
334
|
Math.min(...n),
|
|
@@ -336,7 +336,7 @@ class N {
|
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
class
|
|
339
|
+
class k {
|
|
340
340
|
map = /* @__PURE__ */ new Map();
|
|
341
341
|
targetMap = /* @__PURE__ */ new Map();
|
|
342
342
|
gridSize;
|
|
@@ -374,6 +374,9 @@ class X {
|
|
|
374
374
|
n && (n.delete(e), delete t?.userData?.pointVirtualGridMap, this.targetMap.delete(t));
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
+
update(t) {
|
|
378
|
+
this.remove(t), this.insert(t);
|
|
379
|
+
}
|
|
377
380
|
/**
|
|
378
381
|
* 获取通过坐标,获取唯一网格索引
|
|
379
382
|
* @param point
|
|
@@ -415,7 +418,7 @@ class X {
|
|
|
415
418
|
* @returns 相交的节点数组
|
|
416
419
|
*/
|
|
417
420
|
queryCircle(t, e) {
|
|
418
|
-
const n = new
|
|
421
|
+
const n = new P(t.x - e, t.x + e, t.y - e, t.y + e), 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 = [];
|
|
419
422
|
for (let c = s; c <= i; c++)
|
|
420
423
|
for (let l = r; l <= o; l++) {
|
|
421
424
|
const h = `${c}.${l}`;
|
|
@@ -447,11 +450,14 @@ class X {
|
|
|
447
450
|
* 查找相同点
|
|
448
451
|
* @param point
|
|
449
452
|
*/
|
|
450
|
-
queryPoint(t) {
|
|
451
|
-
const
|
|
452
|
-
return this.map.has(
|
|
453
|
-
t.equal(
|
|
454
|
-
|
|
453
|
+
queryPoint(t, e = !1) {
|
|
454
|
+
const n = this.getGridId(t), s = [];
|
|
455
|
+
return this.map.has(n) && this.map.get(n)?.forEach((r) => {
|
|
456
|
+
if (t.equal(r.point)) {
|
|
457
|
+
if (e && t === r.point) return;
|
|
458
|
+
s.push(r);
|
|
459
|
+
}
|
|
460
|
+
}), s;
|
|
455
461
|
}
|
|
456
462
|
/**
|
|
457
463
|
* 查找点自己
|
|
@@ -465,7 +471,7 @@ class X {
|
|
|
465
471
|
return null;
|
|
466
472
|
}
|
|
467
473
|
}
|
|
468
|
-
class
|
|
474
|
+
class it {
|
|
469
475
|
points;
|
|
470
476
|
get p0() {
|
|
471
477
|
return this.points[0];
|
|
@@ -606,7 +612,7 @@ class nt {
|
|
|
606
612
|
let t = 1 / 0, e = -1 / 0, n = 1 / 0, s = -1 / 0;
|
|
607
613
|
return this.points.forEach((i) => {
|
|
608
614
|
e = Math.max(i.x, e), t = Math.min(i.x, t), s = Math.max(i.x, s), n = Math.min(i.x, n);
|
|
609
|
-
}), new
|
|
615
|
+
}), new P(t, e, n, s);
|
|
610
616
|
}
|
|
611
617
|
/**
|
|
612
618
|
*
|
|
@@ -616,7 +622,7 @@ class nt {
|
|
|
616
622
|
*/
|
|
617
623
|
static fromByLineSegment(t, e = 0.1, n = !1, s = 0.5) {
|
|
618
624
|
const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : M.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : M.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
|
|
619
|
-
return new
|
|
625
|
+
return new it([
|
|
620
626
|
new M(i.x + l, i.y + h).add(c),
|
|
621
627
|
new M(r.x + l, r.y + h).add(a),
|
|
622
628
|
new M(r.x - l, r.y - h).add(a),
|
|
@@ -624,7 +630,7 @@ class nt {
|
|
|
624
630
|
]);
|
|
625
631
|
}
|
|
626
632
|
}
|
|
627
|
-
class
|
|
633
|
+
class L {
|
|
628
634
|
points = [new M(), new M()];
|
|
629
635
|
userData = {};
|
|
630
636
|
// line: any
|
|
@@ -737,7 +743,7 @@ class A {
|
|
|
737
743
|
new M(n.x - a, n.y - c).add(o),
|
|
738
744
|
new M(s.x - a, s.y - c).add(r)
|
|
739
745
|
];
|
|
740
|
-
return new
|
|
746
|
+
return new it([0, 1, 3, 2].map((h) => l[h]));
|
|
741
747
|
}
|
|
742
748
|
/**
|
|
743
749
|
* 计算线段的长度
|
|
@@ -778,8 +784,8 @@ class A {
|
|
|
778
784
|
if (r.x === 0 && r.y === 0)
|
|
779
785
|
throw new Error("投影目标线段的两个点不能重合");
|
|
780
786
|
const o = (p) => {
|
|
781
|
-
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y,
|
|
782
|
-
return new M(
|
|
787
|
+
const y = new M(p.x - s.x, p.y - s.y), x = r.x * r.x + r.y * r.y, w = (y.x * r.x + y.y * r.y) / x, D = s.x + w * r.x, m = s.y + w * r.y;
|
|
788
|
+
return new M(D, m);
|
|
783
789
|
};
|
|
784
790
|
let a = o(e), c = o(n);
|
|
785
791
|
const l = (p) => {
|
|
@@ -788,10 +794,10 @@ class A {
|
|
|
788
794
|
};
|
|
789
795
|
let h = l(a), d = l(c);
|
|
790
796
|
const f = (p) => {
|
|
791
|
-
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x,
|
|
792
|
-
return new M(x,
|
|
797
|
+
const y = Math.max(0, Math.min(1, p)), x = s.x + y * r.x, g = s.y + y * r.y;
|
|
798
|
+
return new M(x, g);
|
|
793
799
|
};
|
|
794
|
-
return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new
|
|
800
|
+
return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new L(a, a) : new L(a, c);
|
|
795
801
|
}
|
|
796
802
|
/**
|
|
797
803
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -872,7 +878,7 @@ class A {
|
|
|
872
878
|
* @param line
|
|
873
879
|
*/
|
|
874
880
|
parallel(t, e = 1) {
|
|
875
|
-
return t instanceof
|
|
881
|
+
return t instanceof L ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
|
|
876
882
|
}
|
|
877
883
|
/** 两条线段或角度是否 垂直
|
|
878
884
|
* @param line
|
|
@@ -880,7 +886,7 @@ class A {
|
|
|
880
886
|
* @returns
|
|
881
887
|
*/
|
|
882
888
|
vertical(t, e = 0.1) {
|
|
883
|
-
return t instanceof
|
|
889
|
+
return t instanceof L ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
|
|
884
890
|
}
|
|
885
891
|
/**
|
|
886
892
|
* 两条线段方向相反否一致
|
|
@@ -955,7 +961,7 @@ class A {
|
|
|
955
961
|
* @returns
|
|
956
962
|
*/
|
|
957
963
|
clone() {
|
|
958
|
-
const t = new
|
|
964
|
+
const t = new L(
|
|
959
965
|
this.points[0].clone(),
|
|
960
966
|
this.points[1].clone()
|
|
961
967
|
);
|
|
@@ -978,7 +984,7 @@ class A {
|
|
|
978
984
|
* @param selectLines
|
|
979
985
|
*/
|
|
980
986
|
static groupBySamePointAndParallel(t) {
|
|
981
|
-
const e = new
|
|
987
|
+
const e = new k();
|
|
982
988
|
t.forEach((r) => r.points.forEach((o) => e.insert(o, r)));
|
|
983
989
|
const n = /* @__PURE__ */ new Set();
|
|
984
990
|
function s(r, o, a) {
|
|
@@ -1010,7 +1016,7 @@ class A {
|
|
|
1010
1016
|
const f = o(d);
|
|
1011
1017
|
f < a && (a = f, i = n.projectPoint(d, !1)), f > c && (c = f, r = n.projectPoint(d, !1));
|
|
1012
1018
|
}
|
|
1013
|
-
const l = new
|
|
1019
|
+
const l = new L(i, r);
|
|
1014
1020
|
return t.forEach((h) => h.userData.fittedLine = l), l;
|
|
1015
1021
|
}
|
|
1016
1022
|
/** 合并平行线段
|
|
@@ -1029,7 +1035,7 @@ class A {
|
|
|
1029
1035
|
const y = p.x * s.x + p.y * s.y;
|
|
1030
1036
|
i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
|
|
1031
1037
|
});
|
|
1032
|
-
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y), d = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new
|
|
1038
|
+
const c = new M(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new M(c.x + (i - l) * s.x, c.y + (i - l) * s.y), d = new M(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new L(h, d);
|
|
1033
1039
|
return t.forEach((p) => p.userData.fittedLine = f), f;
|
|
1034
1040
|
}
|
|
1035
1041
|
/** 合并满足平行的线段
|
|
@@ -1135,6 +1141,15 @@ class M {
|
|
|
1135
1141
|
division(t) {
|
|
1136
1142
|
return this.x -= t.x, this.y -= t.y, this;
|
|
1137
1143
|
}
|
|
1144
|
+
/**
|
|
1145
|
+
* 减法
|
|
1146
|
+
* @description 将当前点的坐标减去指定点的坐标
|
|
1147
|
+
* @param point
|
|
1148
|
+
* @returns
|
|
1149
|
+
*/
|
|
1150
|
+
subtract(t) {
|
|
1151
|
+
return this.x -= t.x, this.y -= t.y, this;
|
|
1152
|
+
}
|
|
1138
1153
|
/**
|
|
1139
1154
|
* 加法
|
|
1140
1155
|
* @description 将当前点的坐标加上指定点的坐标
|
|
@@ -1194,7 +1209,7 @@ class M {
|
|
|
1194
1209
|
* @param length
|
|
1195
1210
|
*/
|
|
1196
1211
|
expandAsLine(t, e, n) {
|
|
1197
|
-
const s = new
|
|
1212
|
+
const s = new L(
|
|
1198
1213
|
this.clone(),
|
|
1199
1214
|
this.clone().add(t.clone().multiplyScalar(e))
|
|
1200
1215
|
);
|
|
@@ -1289,7 +1304,7 @@ class M {
|
|
|
1289
1304
|
return new M(0, 0);
|
|
1290
1305
|
}
|
|
1291
1306
|
}
|
|
1292
|
-
async function
|
|
1307
|
+
async function X(u, t = !0) {
|
|
1293
1308
|
if (typeof global < "u" && typeof require < "u")
|
|
1294
1309
|
return require(u);
|
|
1295
1310
|
{
|
|
@@ -1300,7 +1315,7 @@ async function Y(u, t = !0) {
|
|
|
1300
1315
|
return t && (e = e.default), e;
|
|
1301
1316
|
}
|
|
1302
1317
|
}
|
|
1303
|
-
class
|
|
1318
|
+
class B {
|
|
1304
1319
|
bounds;
|
|
1305
1320
|
// 包围盒
|
|
1306
1321
|
capacity;
|
|
@@ -1326,7 +1341,7 @@ class F {
|
|
|
1326
1341
|
* @param node 线段节点
|
|
1327
1342
|
*/
|
|
1328
1343
|
insert(t) {
|
|
1329
|
-
if (t instanceof
|
|
1344
|
+
if (t instanceof L) {
|
|
1330
1345
|
this.insert({ line: t, userData: {} });
|
|
1331
1346
|
return;
|
|
1332
1347
|
}
|
|
@@ -1351,7 +1366,7 @@ class F {
|
|
|
1351
1366
|
* @param node
|
|
1352
1367
|
*/
|
|
1353
1368
|
remove(t) {
|
|
1354
|
-
if (t instanceof
|
|
1369
|
+
if (t instanceof L) {
|
|
1355
1370
|
t = this.targetMap.get(t), t && this.remove(t);
|
|
1356
1371
|
return;
|
|
1357
1372
|
}
|
|
@@ -1381,26 +1396,26 @@ class F {
|
|
|
1381
1396
|
if (!this.isLeaf) return;
|
|
1382
1397
|
this.isLeaf = !1, this.children = [];
|
|
1383
1398
|
const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
|
|
1384
|
-
this.children[0] = new
|
|
1385
|
-
new
|
|
1399
|
+
this.children[0] = new B(
|
|
1400
|
+
new P(this.bounds.minX, t, this.bounds.minY, e),
|
|
1386
1401
|
this.capacity,
|
|
1387
1402
|
this.maxDepth,
|
|
1388
1403
|
this.depth + 1,
|
|
1389
1404
|
this.targetMap
|
|
1390
|
-
), this.children[1] = new
|
|
1391
|
-
new
|
|
1405
|
+
), this.children[1] = new B(
|
|
1406
|
+
new P(t, this.bounds.maxX, this.bounds.minY, e),
|
|
1392
1407
|
this.capacity,
|
|
1393
1408
|
this.maxDepth,
|
|
1394
1409
|
this.depth + 1,
|
|
1395
1410
|
this.targetMap
|
|
1396
|
-
), this.children[2] = new
|
|
1397
|
-
new
|
|
1411
|
+
), this.children[2] = new B(
|
|
1412
|
+
new P(this.bounds.minX, t, e, this.bounds.maxY),
|
|
1398
1413
|
this.capacity,
|
|
1399
1414
|
this.maxDepth,
|
|
1400
1415
|
this.depth + 1,
|
|
1401
1416
|
this.targetMap
|
|
1402
|
-
), this.children[3] = new
|
|
1403
|
-
new
|
|
1417
|
+
), this.children[3] = new B(
|
|
1418
|
+
new P(t, this.bounds.maxX, e, this.bounds.maxY),
|
|
1404
1419
|
this.capacity,
|
|
1405
1420
|
this.maxDepth,
|
|
1406
1421
|
this.depth + 1,
|
|
@@ -1430,7 +1445,7 @@ class F {
|
|
|
1430
1445
|
* @returns 相交的节点数组
|
|
1431
1446
|
*/
|
|
1432
1447
|
queryCircle(t, e) {
|
|
1433
|
-
const n = [], s = new
|
|
1448
|
+
const n = [], s = new P(
|
|
1434
1449
|
t.x - e,
|
|
1435
1450
|
t.x + e,
|
|
1436
1451
|
t.y - e,
|
|
@@ -1512,7 +1527,7 @@ class F {
|
|
|
1512
1527
|
}
|
|
1513
1528
|
}
|
|
1514
1529
|
function J(u, t = 0, e) {
|
|
1515
|
-
return e || (e = new
|
|
1530
|
+
return e || (e = new B(P.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 }))), u.map((n) => {
|
|
1516
1531
|
const s = n.userData, i = s.drawWindow, r = e.queryLineSegment(n).filter((o) => o.line !== n && !o.userData?.isDoor).map((o) => ({ index: u.indexOf(o.line) }));
|
|
1517
1532
|
return {
|
|
1518
1533
|
start: n.start.toJson(t),
|
|
@@ -1528,13 +1543,14 @@ function J(u, t = 0, e) {
|
|
|
1528
1543
|
drawWindow: i && i.map((o) => ({
|
|
1529
1544
|
p: { x: o.p.x, y: o.p.y, z: o.p.z },
|
|
1530
1545
|
width: o.width,
|
|
1531
|
-
full: o.full
|
|
1546
|
+
full: o.full,
|
|
1547
|
+
rooftopPz: o.rooftopPz
|
|
1532
1548
|
}))
|
|
1533
1549
|
};
|
|
1534
1550
|
});
|
|
1535
1551
|
}
|
|
1536
|
-
function
|
|
1537
|
-
const e = new
|
|
1552
|
+
function et(u, t = 0.03) {
|
|
1553
|
+
const e = new B(P.fromByLineSegment(...u));
|
|
1538
1554
|
return u.forEach((n) => e.insert({ line: n, userData: void 0 })), u.flatMap((n) => {
|
|
1539
1555
|
const s = e.queryLineSegment(n, !0).map((i) => {
|
|
1540
1556
|
if (i.line === n) return;
|
|
@@ -1554,7 +1570,7 @@ function lt(u, t = 0.03) {
|
|
|
1554
1570
|
return n;
|
|
1555
1571
|
}).filter((n) => n.length() >= t);
|
|
1556
1572
|
}
|
|
1557
|
-
function
|
|
1573
|
+
function nt(...u) {
|
|
1558
1574
|
u.forEach((t) => {
|
|
1559
1575
|
const e = t.direction();
|
|
1560
1576
|
t.userData.drawWindow?.forEach((n) => {
|
|
@@ -1565,15 +1581,15 @@ function tt(...u) {
|
|
|
1565
1581
|
), r = t.projectPoint(
|
|
1566
1582
|
s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
|
|
1567
1583
|
!1
|
|
1568
|
-
), o = t.projectLineSegment(new
|
|
1584
|
+
), o = t.projectLineSegment(new L(i, r)), a = o.center;
|
|
1569
1585
|
n.p = new I.Vector3(a?.x ?? 0, a?.y ?? 0, n.p.z);
|
|
1570
1586
|
} catch {
|
|
1571
1587
|
}
|
|
1572
1588
|
});
|
|
1573
1589
|
});
|
|
1574
1590
|
}
|
|
1575
|
-
function
|
|
1576
|
-
e || (e = new
|
|
1591
|
+
function re(u, t = 0.1, e) {
|
|
1592
|
+
e || (e = new k(), u.forEach((i) => {
|
|
1577
1593
|
i.userData.isDoor || i.points.forEach((r) => e?.insert(r, i));
|
|
1578
1594
|
}));
|
|
1579
1595
|
const n = [], s = /* @__PURE__ */ new Set();
|
|
@@ -1586,34 +1602,34 @@ function ie(u, t = 0.1, e) {
|
|
|
1586
1602
|
if (s.has(y.point)) return !1;
|
|
1587
1603
|
const x = y.userData;
|
|
1588
1604
|
if (x === r || !r.parallel(x, 25) || e.queryPoint(y.point).length > 1) return !1;
|
|
1589
|
-
const
|
|
1590
|
-
if (
|
|
1591
|
-
const
|
|
1592
|
-
if (180 -
|
|
1593
|
-
return o.set(y.point,
|
|
1605
|
+
const g = a.distance(y.point);
|
|
1606
|
+
if (g < 1e-3) return !1;
|
|
1607
|
+
const w = a.direction(r.getAnotherPoint(a)), D = y.point.direction(x.getAnotherPoint(y.point));
|
|
1608
|
+
if (180 - w.angleBetween(D, "angle") < 25)
|
|
1609
|
+
return o.set(y.point, g), !0;
|
|
1594
1610
|
}).sort((y, x) => {
|
|
1595
|
-
const
|
|
1596
|
-
return
|
|
1611
|
+
const g = o.get(y.point), w = o.get(x.point);
|
|
1612
|
+
return g - w;
|
|
1597
1613
|
});
|
|
1598
1614
|
if (c.length === 0) return;
|
|
1599
1615
|
s.add(a), s.add(c[0].point);
|
|
1600
1616
|
const l = c[0].userData, h = r.projectLineSegment(l), d = l.projectLineSegment(r), f = h.length(), p = d.length();
|
|
1601
|
-
f === 0 && p === 0 ? n.push(new
|
|
1617
|
+
f === 0 && p === 0 ? n.push(new L(a.clone(), c[0].point.clone())) : n.push(new L(h.center, d.center));
|
|
1602
1618
|
});
|
|
1603
1619
|
}
|
|
1604
1620
|
return [...u, ...n];
|
|
1605
1621
|
}
|
|
1606
|
-
function
|
|
1607
|
-
const t = new
|
|
1622
|
+
function oe(u) {
|
|
1623
|
+
const t = new k(), e = new B(P.fromByLineSegment(...u)), n = [];
|
|
1608
1624
|
return u.forEach((s) => {
|
|
1609
1625
|
s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert({ line: s, userData: void 0 }));
|
|
1610
1626
|
}), n.forEach((s) => {
|
|
1611
1627
|
const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
|
|
1612
1628
|
i.length ? s.userData.startIntersection = i[0].userData : s.userData.startIntersection = e.queryPoint(s.start)[0]?.line, r.length ? s.userData.endIntersection = r[0].userData : s.userData.endIntersection = e.queryPoint(s.end)[0]?.line;
|
|
1613
|
-
}), u =
|
|
1629
|
+
}), u = re(u, 0.4, t), u;
|
|
1614
1630
|
}
|
|
1615
|
-
function
|
|
1616
|
-
const t = new
|
|
1631
|
+
function ae(u) {
|
|
1632
|
+
const t = new B(P.fromByLineSegment(...u));
|
|
1617
1633
|
u.forEach((n) => {
|
|
1618
1634
|
n.userData.isDoor || t.insert({ line: n, userData: void 0 });
|
|
1619
1635
|
});
|
|
@@ -1632,9 +1648,10 @@ function oe(u) {
|
|
|
1632
1648
|
}
|
|
1633
1649
|
return e;
|
|
1634
1650
|
}
|
|
1635
|
-
function
|
|
1651
|
+
function ce(u, t, e, n = 15) {
|
|
1636
1652
|
const s = [u], i = [], r = [], o = [];
|
|
1637
1653
|
function a(d) {
|
|
1654
|
+
if (d.userData.isDoor) return r.push(d);
|
|
1638
1655
|
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x);
|
|
1639
1656
|
let y = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x) - f;
|
|
1640
1657
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
@@ -1643,14 +1660,15 @@ function ae(u, t, e, n = 15) {
|
|
|
1643
1660
|
return d.start.rotate(x, y), d.end.rotate(x, y), d.userData.isDoor ? r.push(d) : s.push(d), d;
|
|
1644
1661
|
}
|
|
1645
1662
|
function c(d) {
|
|
1663
|
+
if (d.userData.isDoor) return r.push(d);
|
|
1646
1664
|
const f = Math.atan2(d.end.y - d.start.y, d.end.x - d.start.x), p = Math.atan2(u.end.y - u.start.y, u.end.x - u.start.x);
|
|
1647
1665
|
let y = p + Math.PI / 2 - f, x = p - Math.PI / 2 - f;
|
|
1648
1666
|
for (; y > Math.PI; ) y -= 2 * Math.PI;
|
|
1649
1667
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
1650
1668
|
for (; x > Math.PI; ) x -= 2 * Math.PI;
|
|
1651
1669
|
for (; x < -Math.PI; ) x += 2 * Math.PI;
|
|
1652
|
-
const
|
|
1653
|
-
return d.start.rotate(
|
|
1670
|
+
const g = Math.abs(y) < Math.abs(x) ? y : x, w = d.center;
|
|
1671
|
+
return d.start.rotate(w, g), d.end.rotate(w, g), d.userData.isDoor ? r.push(d) : i.push(d), d;
|
|
1654
1672
|
}
|
|
1655
1673
|
function l(d, f, p = !1) {
|
|
1656
1674
|
if (p) return l(d === "parallel" ? "vertical" : "parallel", f);
|
|
@@ -1663,17 +1681,17 @@ function ae(u, t, e, n = 15) {
|
|
|
1663
1681
|
if (f.userData.isWindow && o.push(f), f.parallel(u, n)) a(f);
|
|
1664
1682
|
else if (f.vertical(u, n)) c(f);
|
|
1665
1683
|
else {
|
|
1666
|
-
const y = e.get(f)?.reduce((x,
|
|
1684
|
+
const y = e.get(f)?.reduce((x, g) => (g.sourcePoint && (x.has(g.sourcePoint) || x.set(g.sourcePoint, []), x.get(g.sourcePoint)?.push(g)), x), /* @__PURE__ */ new Map());
|
|
1667
1685
|
y && y.size > 1 ? h.push(() => {
|
|
1668
1686
|
const x = [...y.values()].map(
|
|
1669
|
-
(
|
|
1670
|
-
).map((
|
|
1671
|
-
if (
|
|
1672
|
-
if (
|
|
1673
|
-
if (
|
|
1674
|
-
if (
|
|
1675
|
-
if (
|
|
1676
|
-
return l(
|
|
1687
|
+
(D) => D.map((m) => s.includes(m.line) ? "parallel" : i.includes(m.line) ? "vertical" : null).filter((m) => !!m)
|
|
1688
|
+
).map((D) => [...new Set(D)]), g = x[0], w = x[1];
|
|
1689
|
+
if (g.length === 1 && w.length === 1) {
|
|
1690
|
+
if (g[0] === w[0]) return l(g[0], f, !0);
|
|
1691
|
+
if (g.length === 1) {
|
|
1692
|
+
if (w.includes(g[0])) return l(g[0], f, !0);
|
|
1693
|
+
if (w.length === 1 && g.includes(w[0]))
|
|
1694
|
+
return l(w[0], f, !0);
|
|
1677
1695
|
}
|
|
1678
1696
|
}
|
|
1679
1697
|
c(f);
|
|
@@ -1701,8 +1719,8 @@ function yt(u, t, e, n, s) {
|
|
|
1701
1719
|
const l = c.flatMap((p) => {
|
|
1702
1720
|
const y = p.userData;
|
|
1703
1721
|
return y.points.map((x) => {
|
|
1704
|
-
const
|
|
1705
|
-
return
|
|
1722
|
+
const g = t.projectPoint(x, !1);
|
|
1723
|
+
return g.userData = y, g;
|
|
1706
1724
|
});
|
|
1707
1725
|
});
|
|
1708
1726
|
l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
|
|
@@ -1725,23 +1743,23 @@ function xt(u, t, e, n) {
|
|
|
1725
1743
|
});
|
|
1726
1744
|
}), o.sort((d, f) => f.distance(e.start) - d.distance(e.start));
|
|
1727
1745
|
const a = o.map((d) => {
|
|
1728
|
-
const f = d.userData, p = i.get(f), y = r.get(f), x = new
|
|
1729
|
-
for (let
|
|
1730
|
-
const
|
|
1731
|
-
if (d !==
|
|
1732
|
-
const
|
|
1733
|
-
(x.isPointOnSegment(S) || x.isPointOnSegment(
|
|
1746
|
+
const f = d.userData, p = i.get(f), y = r.get(f), x = new L(p, y), g = [];
|
|
1747
|
+
for (let w = 0; w < o.length; w++) {
|
|
1748
|
+
const D = o[w];
|
|
1749
|
+
if (d !== D && d.distance(D) < n) {
|
|
1750
|
+
const m = D.userData, S = i.get(m), T = r.get(m);
|
|
1751
|
+
(x.isPointOnSegment(S) || x.isPointOnSegment(T)) && g.push(w);
|
|
1734
1752
|
}
|
|
1735
1753
|
}
|
|
1736
|
-
return
|
|
1754
|
+
return g;
|
|
1737
1755
|
});
|
|
1738
1756
|
function c(d, f, p = /* @__PURE__ */ new Set()) {
|
|
1739
1757
|
if (p.has(d)) return p;
|
|
1740
1758
|
const y = f[d];
|
|
1741
1759
|
p.add(d);
|
|
1742
1760
|
for (let x = 0; x < y.length; x++) {
|
|
1743
|
-
const
|
|
1744
|
-
c(
|
|
1761
|
+
const g = y[x];
|
|
1762
|
+
c(g, f, p);
|
|
1745
1763
|
}
|
|
1746
1764
|
return p;
|
|
1747
1765
|
}
|
|
@@ -1752,23 +1770,23 @@ function xt(u, t, e, n) {
|
|
|
1752
1770
|
if (f.forEach((y) => {
|
|
1753
1771
|
l.add(y), p.push(o[y].userData);
|
|
1754
1772
|
}), p.length > 2) {
|
|
1755
|
-
const y = p.map((
|
|
1756
|
-
y.sort((
|
|
1757
|
-
const x = y[0],
|
|
1758
|
-
if (x.distance(
|
|
1759
|
-
const
|
|
1760
|
-
if (
|
|
1761
|
-
const
|
|
1773
|
+
const y = p.map((D) => s.get(D));
|
|
1774
|
+
y.sort((D, m) => m.distance(e.start) - D.distance(e.start));
|
|
1775
|
+
const x = y[0], g = y[y.length - 1];
|
|
1776
|
+
if (x.distance(g) > n) {
|
|
1777
|
+
const D = [...p].sort((N, j) => j.length() - N.length()), m = D[0], S = D[1], T = s.get(m), E = s.get(S), A = m.length(), v = S.length(), C = m.projectLineSegment(S), F = C.length();
|
|
1778
|
+
if (T.distance(E) || v / A > 0.5 && F / v < 0.5) {
|
|
1779
|
+
const N = [m], j = [S];
|
|
1762
1780
|
for (let O = 0; O < y.length; O++) {
|
|
1763
|
-
const
|
|
1764
|
-
if (
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1781
|
+
const R = y[O], V = R.userData;
|
|
1782
|
+
if (R === T || R === E) continue;
|
|
1783
|
+
const G = S.projectLineSegment(V), W = G.length();
|
|
1784
|
+
E.distance(R) <= n && W / v > 0 ? j.push(V) : N.push(V);
|
|
1767
1785
|
}
|
|
1768
|
-
h.push(
|
|
1786
|
+
h.push(N, j);
|
|
1769
1787
|
} else {
|
|
1770
|
-
const
|
|
1771
|
-
h.push(p.slice(0,
|
|
1788
|
+
const N = Math.floor(p.length * 0.5);
|
|
1789
|
+
h.push(p.slice(0, N), p.slice(N));
|
|
1772
1790
|
}
|
|
1773
1791
|
continue;
|
|
1774
1792
|
}
|
|
@@ -1798,7 +1816,7 @@ function gt(u, t) {
|
|
|
1798
1816
|
}
|
|
1799
1817
|
return s;
|
|
1800
1818
|
}
|
|
1801
|
-
function
|
|
1819
|
+
function le(u, t, e, n, s, i) {
|
|
1802
1820
|
const {
|
|
1803
1821
|
principalAxisThreshold: r = 0.3,
|
|
1804
1822
|
crossAxistThreshold: o = 0.06,
|
|
@@ -1819,25 +1837,30 @@ function ce(u, t, e, n, s, i) {
|
|
|
1819
1837
|
};
|
|
1820
1838
|
return c[a] ? c[a]() : c.originalInterPoint();
|
|
1821
1839
|
}
|
|
1822
|
-
function
|
|
1840
|
+
function he(u, t) {
|
|
1823
1841
|
const e = /* @__PURE__ */ new Set();
|
|
1824
1842
|
return u.forEach((n) => {
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
(
|
|
1843
|
+
const s = /* @__PURE__ */ new Map();
|
|
1844
|
+
n.map((i) => {
|
|
1845
|
+
t.get(i)?.forEach((o) => {
|
|
1846
|
+
s.has(o.line) || s.set(o.line, []), s.get(o.line)?.push({ intersect: o, targetLine: i });
|
|
1829
1847
|
});
|
|
1830
|
-
}
|
|
1848
|
+
});
|
|
1849
|
+
for (const [i, r] of s)
|
|
1850
|
+
if (r.length === 2) {
|
|
1851
|
+
const o = r[0].targetLine, a = r[1].targetLine;
|
|
1852
|
+
(i.sameEndpointAsStart(o) && i.sameEndpointAsEnd(a) || i.sameEndpointAsStart(a) && i.sameEndpointAsEnd(o)) && e.add(i);
|
|
1853
|
+
}
|
|
1831
1854
|
}), u.map((n) => n.filter((s) => !e.has(s)));
|
|
1832
1855
|
}
|
|
1833
|
-
function
|
|
1856
|
+
function ue(u, t = 0.1, e) {
|
|
1834
1857
|
const { fittingMethod: n = "average" } = e ?? {};
|
|
1835
1858
|
return u.map((s) => {
|
|
1836
1859
|
if (s.length === 0) return;
|
|
1837
1860
|
if (s.length === 1) return s[0];
|
|
1838
1861
|
const i = [];
|
|
1839
1862
|
s.forEach((h) => i.push(h.start.clone(), h.end.clone()));
|
|
1840
|
-
const r = n === "average" ?
|
|
1863
|
+
const r = n === "average" ? L.mergeLines(...s) : L.mergeLinesByMaxlength(...s);
|
|
1841
1864
|
r.userData.rooftopPz = Math.min(
|
|
1842
1865
|
...s.map((h) => {
|
|
1843
1866
|
const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } = h.userData;
|
|
@@ -1854,14 +1877,42 @@ function he(u, t = 0.1, e) {
|
|
|
1854
1877
|
return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
|
|
1855
1878
|
}).filter((s) => !!s);
|
|
1856
1879
|
}
|
|
1857
|
-
function
|
|
1858
|
-
const e = new
|
|
1859
|
-
u.forEach((
|
|
1860
|
-
|
|
1880
|
+
function de(u, t) {
|
|
1881
|
+
const e = new k(), n = new B(P.fromByLineSegment(...u));
|
|
1882
|
+
u.forEach((i) => {
|
|
1883
|
+
i.userData.isDoor || (n.insert(i), i.points.forEach((r) => e.insert(r, i)));
|
|
1884
|
+
}), u.forEach((i) => {
|
|
1885
|
+
i.userData.isDoor || (n.insert(i), i.points.forEach((r) => e.insert(r, i)));
|
|
1886
|
+
});
|
|
1887
|
+
function s(i, r, o) {
|
|
1888
|
+
if (o.length) {
|
|
1889
|
+
const a = o.map(({ line: c }) => {
|
|
1890
|
+
if (c.userData.fittedLine && (c = c.userData.fittedLine), c.vertical(i))
|
|
1891
|
+
return c.projectPoint(r, !0);
|
|
1892
|
+
}).filter((c) => !!c).sort((c, l) => c.distance(r) - l.distance(r));
|
|
1893
|
+
a.length && (r.copy(a[0]), e.update(r), n.update(i));
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
for (let i = 0; i < u.length; i++) {
|
|
1897
|
+
const r = u[i], a = (t.get(r) ?? []).reduce((c, l) => (l.sourcePoint === r.start ? c[0].push(l) : c[1].push(l), c), [[], []]);
|
|
1898
|
+
for (let c = 0; c < r.points.length; c++) {
|
|
1899
|
+
const l = r.points[c];
|
|
1900
|
+
e.queryPoint(l, !0).length || s(r, l, a[c]);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return u;
|
|
1904
|
+
}
|
|
1905
|
+
function fe(u, t = 0.4) {
|
|
1906
|
+
const e = new B(P.fromByLineSegment(...u));
|
|
1907
|
+
u.forEach((s) => {
|
|
1908
|
+
s.userData.isDoor || e.insert(s);
|
|
1909
|
+
});
|
|
1910
|
+
const n = new L();
|
|
1861
1911
|
for (let s = 0; s < u.length; s++) {
|
|
1862
1912
|
const i = u[s];
|
|
1863
1913
|
if (i.userData.isAdsorbed) continue;
|
|
1864
1914
|
const r = i.direction().multiplyScalar(t), [o, a] = i.points.map((c) => {
|
|
1915
|
+
if (e.queryPoint(c).length > 1) return;
|
|
1865
1916
|
n.set(c, c), n.start.add(r), n.end.add(r.multiplyScalar(-1));
|
|
1866
1917
|
const l = /* @__PURE__ */ new Map(), h = e.queryLineSegment(n).filter((d) => d.line !== i).map((d) => {
|
|
1867
1918
|
const f = d.line.getIntersection(n);
|
|
@@ -1872,56 +1923,60 @@ function mt(u, t = 0.4) {
|
|
|
1872
1923
|
});
|
|
1873
1924
|
return h.length ? l.get(h[0]) : void 0;
|
|
1874
1925
|
});
|
|
1875
|
-
if (o
|
|
1876
|
-
if (o
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1926
|
+
if (o || o) {
|
|
1927
|
+
if (o && a) {
|
|
1928
|
+
if (o.equal(a)) {
|
|
1929
|
+
const c = i.start.distance(o), l = i.end.distance(a);
|
|
1930
|
+
c < l ? i.directionMove(i.end.direction(i.start), c) : i.directionMove(i.start.direction(i.end), l);
|
|
1931
|
+
} else
|
|
1932
|
+
i.start.copy(o), i.end.copy(a);
|
|
1933
|
+
i.userData.isAdsorbed = !0;
|
|
1934
|
+
} else o ? i.start.copy(o) : a && i.end.copy(a);
|
|
1935
|
+
e.update(i);
|
|
1936
|
+
}
|
|
1884
1937
|
}
|
|
1885
|
-
return u
|
|
1938
|
+
return u;
|
|
1886
1939
|
}
|
|
1887
|
-
function
|
|
1888
|
-
const e = new
|
|
1889
|
-
u.forEach((
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
if (
|
|
1900
|
-
const
|
|
1901
|
-
if (l)
|
|
1902
|
-
|
|
1903
|
-
|
|
1940
|
+
function pe(u, t) {
|
|
1941
|
+
const e = new k(), n = new B(P.fromByLineSegment(...u));
|
|
1942
|
+
u.forEach((r) => {
|
|
1943
|
+
r.userData.isDoor || (n.insert(r), r.points.forEach((o) => e.insert(o, r)));
|
|
1944
|
+
});
|
|
1945
|
+
const s = /* @__PURE__ */ new Map();
|
|
1946
|
+
function i(r, o) {
|
|
1947
|
+
s.has(r) || s.set(r, []), s.get(r)?.push(o);
|
|
1948
|
+
}
|
|
1949
|
+
for (let r = 0; r < u.length; r++) {
|
|
1950
|
+
const o = u[r];
|
|
1951
|
+
o.points.forEach((a) => {
|
|
1952
|
+
if (e.queryPoint(a).filter((f) => f.userData !== o).length !== 0 || n.queryCircle(a, 1e-3).filter((f) => f.line !== o).length > 0) return;
|
|
1953
|
+
const l = e.queryCircle(a, t).filter((f) => f.userData !== o && f.userData?.vertical(o)).sort((f, p) => f.point.distance(a) - p.point.distance(a));
|
|
1954
|
+
if (!l.length) return;
|
|
1955
|
+
const h = l[0], d = h.userData?.projectPoint(a, !1);
|
|
1956
|
+
if (d) {
|
|
1957
|
+
const f = h.userData;
|
|
1958
|
+
i(o, new L(a.clone(), d.clone())), i(f, new L(h.point.clone(), d.clone()));
|
|
1904
1959
|
}
|
|
1905
1960
|
});
|
|
1906
1961
|
}
|
|
1907
|
-
return
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1962
|
+
return s.forEach((r, o) => {
|
|
1963
|
+
const a = L.mergeLines(o, ...r);
|
|
1964
|
+
o.set(a.start, a.end);
|
|
1910
1965
|
}), u;
|
|
1911
1966
|
}
|
|
1912
|
-
function
|
|
1913
|
-
const { snapThreshold:
|
|
1914
|
-
return u =
|
|
1967
|
+
function ye(u, t, e) {
|
|
1968
|
+
const { snapThreshold: n = 0.2 } = e ?? {};
|
|
1969
|
+
return u = de(u, t), u = fe(u, n), u = pe(u, n), u;
|
|
1915
1970
|
}
|
|
1916
|
-
function
|
|
1971
|
+
function xe(u) {
|
|
1917
1972
|
const t = /* @__PURE__ */ new Set();
|
|
1918
1973
|
for (let e = 0; e < u.length; e++) {
|
|
1919
1974
|
const n = u[e], s = n.userData.fittedLine;
|
|
1920
|
-
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) :
|
|
1975
|
+
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : nt(n);
|
|
1921
1976
|
}
|
|
1922
|
-
t.forEach((e) =>
|
|
1977
|
+
t.forEach((e) => nt(e));
|
|
1923
1978
|
}
|
|
1924
|
-
function
|
|
1979
|
+
function ge(u) {
|
|
1925
1980
|
for (let t = 0; t < u.length; t++) {
|
|
1926
1981
|
const e = u[t];
|
|
1927
1982
|
let { endIntersection: n, startIntersection: s } = e.userData;
|
|
@@ -1942,8 +1997,8 @@ function pe(u) {
|
|
|
1942
1997
|
}
|
|
1943
1998
|
return u;
|
|
1944
1999
|
}
|
|
1945
|
-
function
|
|
1946
|
-
const e = new
|
|
2000
|
+
function me(u, t = 0.01) {
|
|
2001
|
+
const e = new k();
|
|
1947
2002
|
return u.forEach((n) => n.points.forEach((s) => e.insert(s, n))), u.filter((n) => {
|
|
1948
2003
|
if (n.length() <= t) {
|
|
1949
2004
|
const s = e.queryPoint(n.start).filter((r) => r.userData !== n).length === 0, i = e.queryPoint(n.end).filter((r) => r.userData !== n).length === 0;
|
|
@@ -1952,7 +2007,7 @@ function ye(u, t = 0.01) {
|
|
|
1952
2007
|
return !0;
|
|
1953
2008
|
});
|
|
1954
2009
|
}
|
|
1955
|
-
class
|
|
2010
|
+
class It {
|
|
1956
2011
|
/**
|
|
1957
2012
|
* 轴对齐垂直修正
|
|
1958
2013
|
* @param lines 待调整线段组
|
|
@@ -1960,39 +2015,39 @@ class Pt {
|
|
|
1960
2015
|
* @returns
|
|
1961
2016
|
*/
|
|
1962
2017
|
static correction(t, e, n) {
|
|
1963
|
-
t =
|
|
1964
|
-
const s =
|
|
2018
|
+
t = oe(t.map((x) => x.clone()));
|
|
2019
|
+
const s = ae(t), { parallelLines: i, verticalLines: r, doorLines: o, windowLines: a } = ce(e, t, s, 25), c = e.normal(), l = e.center, h = e.direction(), d = new L(
|
|
1965
2020
|
l.clone().add(c.clone().multiplyScalar(-1e3)),
|
|
1966
2021
|
l.clone().add(c.clone().multiplyScalar(1e3))
|
|
1967
|
-
), f = new
|
|
2022
|
+
), f = new L(
|
|
1968
2023
|
l.clone().add(h.clone().multiplyScalar(-1e3)),
|
|
1969
2024
|
l.clone().add(h.clone().multiplyScalar(1e3))
|
|
1970
2025
|
);
|
|
1971
|
-
let p =
|
|
1972
|
-
p =
|
|
1973
|
-
let y =
|
|
1974
|
-
return y =
|
|
2026
|
+
let p = le(i, r, d, f, s, n);
|
|
2027
|
+
p = he(p, s);
|
|
2028
|
+
let y = ue(p, 0.1, n);
|
|
2029
|
+
return y = ye(y, s, n), xe(a), ge(o), y = et(y, 1e-9), y.push(...o), y = me(y, 0.15), y = y, y = L.autoMergeLines(y).lines, y = et(y, 1e-9), y;
|
|
1975
2030
|
}
|
|
1976
2031
|
}
|
|
1977
|
-
const
|
|
2032
|
+
const we = new L(
|
|
1978
2033
|
new M(0, 0),
|
|
1979
2034
|
new M(0, 1)
|
|
1980
2035
|
);
|
|
1981
|
-
function
|
|
2036
|
+
function Me(u) {
|
|
1982
2037
|
const t = [...u].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
|
|
1983
|
-
let r = parseInt(
|
|
2038
|
+
let r = parseInt(we.includedAngle(i) + "");
|
|
1984
2039
|
return r > 90 && (r = 180 - r), r;
|
|
1985
2040
|
}), n = /* @__PURE__ */ new Map();
|
|
1986
2041
|
return e.forEach((i, r) => {
|
|
1987
2042
|
n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
|
|
1988
2043
|
}), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
|
|
1989
2044
|
}
|
|
1990
|
-
function
|
|
2045
|
+
function Se(u) {
|
|
1991
2046
|
let t = [], e = -1;
|
|
1992
2047
|
const n = [];
|
|
1993
2048
|
return u.forEach(({ start: i, end: r, ...o }, a) => {
|
|
1994
2049
|
n.push(i.z ?? 0, r.z ?? 0);
|
|
1995
|
-
const c = new
|
|
2050
|
+
const c = new L(
|
|
1996
2051
|
M.from(i),
|
|
1997
2052
|
M.from(r)
|
|
1998
2053
|
);
|
|
@@ -2003,7 +2058,7 @@ function me(u) {
|
|
|
2003
2058
|
verticalReferenceIndex: e
|
|
2004
2059
|
};
|
|
2005
2060
|
}
|
|
2006
|
-
const
|
|
2061
|
+
const De = {
|
|
2007
2062
|
Unitless: 1,
|
|
2008
2063
|
// 无单位,1米 = 1(无单位)
|
|
2009
2064
|
Inches: 39.37007874015748,
|
|
@@ -2047,27 +2102,27 @@ const we = {
|
|
|
2047
2102
|
Parsecs: 3240779289666404e-32
|
|
2048
2103
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
2049
2104
|
};
|
|
2050
|
-
function
|
|
2105
|
+
function mt(u) {
|
|
2051
2106
|
const t = [];
|
|
2052
2107
|
for (let e = 0; e < u.length; e++)
|
|
2053
|
-
t.push(new
|
|
2108
|
+
t.push(new L(
|
|
2054
2109
|
u[e].clone(),
|
|
2055
2110
|
u[(e + 1) % u.length].clone()
|
|
2056
2111
|
));
|
|
2057
2112
|
return t;
|
|
2058
2113
|
}
|
|
2059
|
-
function
|
|
2114
|
+
function wt(u) {
|
|
2060
2115
|
return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
|
|
2061
2116
|
}
|
|
2062
|
-
class
|
|
2117
|
+
class Y extends z {
|
|
2063
2118
|
static name = "Dxf";
|
|
2064
2119
|
shortLine = 0.04;
|
|
2065
2120
|
width = 0.04;
|
|
2066
2121
|
scale = 1;
|
|
2067
2122
|
originalData = [];
|
|
2068
2123
|
data = [];
|
|
2069
|
-
originalBox = new
|
|
2070
|
-
box = new
|
|
2124
|
+
originalBox = new P(0, 0, 0, 0);
|
|
2125
|
+
box = new P(0, 0, 0, 0);
|
|
2071
2126
|
pointsGroups = [];
|
|
2072
2127
|
wallsGroup = [];
|
|
2073
2128
|
doors = [];
|
|
@@ -2104,9 +2159,9 @@ class k extends _ {
|
|
|
2104
2159
|
* @param data
|
|
2105
2160
|
*/
|
|
2106
2161
|
preprocessing(t) {
|
|
2107
|
-
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } =
|
|
2162
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = Se(t);
|
|
2108
2163
|
if (this.originalZAverage = s, n === -1) {
|
|
2109
|
-
const r =
|
|
2164
|
+
const r = Me(e);
|
|
2110
2165
|
n = e.indexOf(r);
|
|
2111
2166
|
}
|
|
2112
2167
|
const i = e[n];
|
|
@@ -2115,7 +2170,7 @@ class k extends _ {
|
|
|
2115
2170
|
data: t,
|
|
2116
2171
|
setData(r) {
|
|
2117
2172
|
e = r.map(({ start: o, end: a, ...c }) => {
|
|
2118
|
-
const l = new
|
|
2173
|
+
const l = new L(M.from(o), M.from(a));
|
|
2119
2174
|
return l.userData = c, l;
|
|
2120
2175
|
}), t = r;
|
|
2121
2176
|
}
|
|
@@ -2268,7 +2323,7 @@ class k extends _ {
|
|
|
2268
2323
|
break;
|
|
2269
2324
|
}
|
|
2270
2325
|
}
|
|
2271
|
-
const e = this.mergeSameDirectionLine(
|
|
2326
|
+
const e = this.mergeSameDirectionLine(mt(t)), n = [e[0]];
|
|
2272
2327
|
for (let s = 1; s < e.length; s++) {
|
|
2273
2328
|
const i = e[s], r = e[(e.length + s - 1) % e.length];
|
|
2274
2329
|
if (i.length() > this.width * 0.9) {
|
|
@@ -2283,7 +2338,7 @@ class k extends _ {
|
|
|
2283
2338
|
const a = e[s + 2];
|
|
2284
2339
|
a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
|
|
2285
2340
|
}
|
|
2286
|
-
return n.length > 3 ?
|
|
2341
|
+
return n.length > 3 ? wt(this.mergeSameDirectionLine(n)) : [];
|
|
2287
2342
|
}
|
|
2288
2343
|
/**
|
|
2289
2344
|
* 移除短线段
|
|
@@ -2291,7 +2346,7 @@ class k extends _ {
|
|
|
2291
2346
|
* @param path
|
|
2292
2347
|
*/
|
|
2293
2348
|
removeShortLine(t, e = this.shortLine) {
|
|
2294
|
-
const n =
|
|
2349
|
+
const n = mt(t), s = [], i = Math.PI / 180;
|
|
2295
2350
|
for (let r = 0; r < n.length; r++) {
|
|
2296
2351
|
const o = n[r], a = o.length(), c = r;
|
|
2297
2352
|
if (a > e || s.length === 0) {
|
|
@@ -2319,12 +2374,12 @@ class k extends _ {
|
|
|
2319
2374
|
} else
|
|
2320
2375
|
r = c;
|
|
2321
2376
|
}
|
|
2322
|
-
return s.length > 3 ?
|
|
2377
|
+
return s.length > 3 ? wt(s) : [];
|
|
2323
2378
|
}
|
|
2324
2379
|
/** 线偏移
|
|
2325
2380
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
2326
2381
|
*/
|
|
2327
|
-
lineOffset(t =
|
|
2382
|
+
lineOffset(t = Y.EndType.etOpenSquare, e = Y.JoinType.jtMiter, n = 1e4) {
|
|
2328
2383
|
let s = new pt.Paths();
|
|
2329
2384
|
const i = new pt.ClipperOffset(20, 0.25);
|
|
2330
2385
|
return this.pointsGroups.forEach((r) => {
|
|
@@ -2332,7 +2387,7 @@ class k extends _ {
|
|
|
2332
2387
|
i.AddPaths(o, e, t);
|
|
2333
2388
|
}), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
|
|
2334
2389
|
let o = r.map((a) => M.from(a).divisionScalar(n));
|
|
2335
|
-
return o = this.lineSegmentStraightening(o), t ==
|
|
2390
|
+
return o = this.lineSegmentStraightening(o), t == Y.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
|
|
2336
2391
|
}), this.dispatchEvent({
|
|
2337
2392
|
type: "lineOffset",
|
|
2338
2393
|
wallsGroup: this.wallsGroup
|
|
@@ -2344,7 +2399,7 @@ class k extends _ {
|
|
|
2344
2399
|
axisAlignCorr(t) {
|
|
2345
2400
|
if (this.verticalReferenceLine) {
|
|
2346
2401
|
this.doorLineSegment;
|
|
2347
|
-
const e =
|
|
2402
|
+
const e = It.correction(this.getLineSegments(), this.verticalReferenceLine, t), n = J(e);
|
|
2348
2403
|
this.set(n);
|
|
2349
2404
|
} else
|
|
2350
2405
|
throw new Error("未找到一条垂直纠正基准轴线");
|
|
@@ -2394,7 +2449,7 @@ class k extends _ {
|
|
|
2394
2449
|
* 转为绘制数据
|
|
2395
2450
|
*/
|
|
2396
2451
|
toDrawDataJson(t = "Millimeters") {
|
|
2397
|
-
const e =
|
|
2452
|
+
const e = De[t], n = {
|
|
2398
2453
|
unit: t,
|
|
2399
2454
|
line: [],
|
|
2400
2455
|
arc: [],
|
|
@@ -2438,29 +2493,29 @@ class k extends _ {
|
|
|
2438
2493
|
if (s = "cyan", l.length() < 1.2) {
|
|
2439
2494
|
l.expansion(-o * 0.5);
|
|
2440
2495
|
const h = c.normal();
|
|
2441
|
-
let d = new
|
|
2496
|
+
let d = new L(
|
|
2442
2497
|
l.start.clone(),
|
|
2443
2498
|
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2444
2499
|
);
|
|
2445
2500
|
const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
2446
|
-
for (let
|
|
2447
|
-
if (a[
|
|
2448
|
-
d = new
|
|
2501
|
+
for (let m = 0; m < a.length; m++)
|
|
2502
|
+
if (a[m].intersectRectangle(f)) {
|
|
2503
|
+
d = new L(
|
|
2449
2504
|
l.start.clone(),
|
|
2450
2505
|
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2451
2506
|
);
|
|
2452
2507
|
break;
|
|
2453
2508
|
}
|
|
2454
|
-
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((
|
|
2455
|
-
const p = l.length(), y = d.length(), x = (p ** 2 + y ** 2) / (2 * y),
|
|
2456
|
-
r(
|
|
2509
|
+
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((m, S) => i(m, S));
|
|
2510
|
+
const p = l.length(), y = d.length(), x = (p ** 2 + y ** 2) / (2 * y), g = d.end.clone().add(d.direction().multiplyScalar(-x)), [w, D] = this.getArcAngleRange(g, l.end, d.end);
|
|
2511
|
+
r(g, x, Math.min(w, D), Math.max(w, D)), a.push(f);
|
|
2457
2512
|
} else
|
|
2458
2513
|
l.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), o * 0.5).directionMove(l.direction(), o * 0.5).expansion(-l.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d)), l.clone().directionMove(l.normal(), -o * 0.5).directionMove(l.direction(), -o * 0.5).expansion(-l.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((h, d) => i(h, d));
|
|
2459
2514
|
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
2460
2515
|
if (!c.userData.isWindow) return !1;
|
|
2461
2516
|
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
2462
|
-
const { p: h, width: d } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), x = new
|
|
2463
|
-
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((
|
|
2517
|
+
const { p: h, width: d } = l, f = M.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), x = new L(p, y);
|
|
2518
|
+
i(x.start, x.end), x.expandToRectangle(this.width, "bothSides").path2D((g, w) => i(g, w));
|
|
2464
2519
|
});
|
|
2465
2520
|
}), n;
|
|
2466
2521
|
}
|
|
@@ -2474,7 +2529,7 @@ class k extends _ {
|
|
|
2474
2529
|
if (typeof window < "u")
|
|
2475
2530
|
i = document.createElement("canvas");
|
|
2476
2531
|
else if (typeof global < "u") {
|
|
2477
|
-
const { createCanvas: c } = await
|
|
2532
|
+
const { createCanvas: c } = await X("canvas");
|
|
2478
2533
|
i = c();
|
|
2479
2534
|
} else
|
|
2480
2535
|
throw new Error("创建画布失败");
|
|
@@ -2491,8 +2546,8 @@ class k extends _ {
|
|
|
2491
2546
|
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
|
|
2492
2547
|
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
2493
2548
|
let [l, h, d, f] = c;
|
|
2494
|
-
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1),
|
|
2495
|
-
a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(x, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(x - 0.1 * s.scale, p), a.lineTo(x + 0.1 * s.scale, p), a.moveTo(x, p), a.lineTo(x,
|
|
2549
|
+
const p = Math.min(h, f), y = Math.max(h, f), x = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), g = (y - p) * 0.45;
|
|
2550
|
+
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, g + p), a.moveTo(x, y), a.lineTo(x, y - g), a.moveTo(x - 0.1 * s.scale, y), a.lineTo(x + 0.1 * s.scale, y);
|
|
2496
2551
|
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
2497
2552
|
i.toBlob((l) => {
|
|
2498
2553
|
c(l);
|
|
@@ -2503,8 +2558,8 @@ class k extends _ {
|
|
|
2503
2558
|
* 将点json结构转换为Dxf string
|
|
2504
2559
|
*/
|
|
2505
2560
|
toDxfString(t = "Millimeters") {
|
|
2506
|
-
const e = new
|
|
2507
|
-
e.setUnits(t), e.addLayer("cyan",
|
|
2561
|
+
const e = new K();
|
|
2562
|
+
e.setUnits(t), e.addLayer("cyan", K.ACI.CYAN, "DOTTED"), e.addLayer("yellow", K.ACI.YELLOW, "DOTTED"), e.addLayer("white", K.ACI.WHITE, "DOTTED");
|
|
2508
2563
|
const n = this.toDrawDataJson();
|
|
2509
2564
|
return n.line.forEach((s) => {
|
|
2510
2565
|
let [i, r, o, a, c] = s;
|
|
@@ -2530,7 +2585,7 @@ class k extends _ {
|
|
|
2530
2585
|
if (typeof window < "u") {
|
|
2531
2586
|
const n = new Blob([e], { type: "application/json" }), s = document.createElement("a");
|
|
2532
2587
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
2533
|
-
} else typeof global < "u" && (await
|
|
2588
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, e);
|
|
2534
2589
|
}
|
|
2535
2590
|
/**
|
|
2536
2591
|
* 下载
|
|
@@ -2540,7 +2595,7 @@ class k extends _ {
|
|
|
2540
2595
|
if (typeof window < "u") {
|
|
2541
2596
|
const n = this.toDxfBlob(e), s = document.createElement("a");
|
|
2542
2597
|
s.href = URL.createObjectURL(n), s.download = t + ".dxf", s.click();
|
|
2543
|
-
} else typeof global < "u" && (await
|
|
2598
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, this.toDxfString(e));
|
|
2544
2599
|
}
|
|
2545
2600
|
/**
|
|
2546
2601
|
* 下载
|
|
@@ -2552,7 +2607,7 @@ class k extends _ {
|
|
|
2552
2607
|
if (typeof window < "u") {
|
|
2553
2608
|
const i = document.createElement("a");
|
|
2554
2609
|
i.href = URL.createObjectURL(s), i.download = t, i.click();
|
|
2555
|
-
} else typeof global < "u" ? (await
|
|
2610
|
+
} else typeof global < "u" ? (await X("fs", !1)).writeFileSync(t, s) : console.error("图片下载失败");
|
|
2556
2611
|
return !0;
|
|
2557
2612
|
}
|
|
2558
2613
|
/**
|
|
@@ -2560,7 +2615,7 @@ class k extends _ {
|
|
|
2560
2615
|
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
2561
2616
|
* @returns
|
|
2562
2617
|
*/
|
|
2563
|
-
computedOriginalSize(t, e = new
|
|
2618
|
+
computedOriginalSize(t, e = new P(0, 0, 0, 0)) {
|
|
2564
2619
|
const n = t.flatMap((c) => [c.start.x, c.end.x]), s = t.flatMap((c) => [c.start.y, c.end.y]), i = Math.min(...n), r = Math.min(...s), o = Math.max(...n), a = Math.max(...s);
|
|
2565
2620
|
return e.set(i, r, o, a), e;
|
|
2566
2621
|
}
|
|
@@ -2588,41 +2643,41 @@ class k extends _ {
|
|
|
2588
2643
|
});
|
|
2589
2644
|
}
|
|
2590
2645
|
}
|
|
2591
|
-
function
|
|
2646
|
+
function ht(u) {
|
|
2592
2647
|
if (u === null || typeof u != "object") return u;
|
|
2593
2648
|
if (u instanceof Date) return new Date(u.getTime());
|
|
2594
|
-
if (Array.isArray(u)) return u.map(
|
|
2649
|
+
if (Array.isArray(u)) return u.map(ht);
|
|
2595
2650
|
const t = {};
|
|
2596
2651
|
for (const e in u)
|
|
2597
|
-
Object.prototype.hasOwnProperty.call(u, e) && (t[e] =
|
|
2652
|
+
Object.prototype.hasOwnProperty.call(u, e) && (t[e] = ht(u[e]));
|
|
2598
2653
|
return t;
|
|
2599
2654
|
}
|
|
2600
|
-
const
|
|
2601
|
-
class
|
|
2655
|
+
const q = new L();
|
|
2656
|
+
class Le extends Y {
|
|
2602
2657
|
static name = "AngleCorrectionDxf";
|
|
2603
2658
|
angle = 0;
|
|
2604
2659
|
onAddFromParent(t) {
|
|
2605
|
-
t.
|
|
2660
|
+
t.DoorsAnalysis.addEventListener("analysisCompleted", async () => this.update());
|
|
2606
2661
|
}
|
|
2607
2662
|
async update() {
|
|
2608
2663
|
const t = this.parent, e = t.findComponentByName("Dxf"), n = t.findComponentByName("LineAnalysis");
|
|
2609
2664
|
let s = 0, i = null;
|
|
2610
2665
|
for (let c = 0; c < e.originalData.length; c++) {
|
|
2611
2666
|
const l = e.originalData[c];
|
|
2612
|
-
if (
|
|
2613
|
-
const [h, d] = l.start.y < l.end.y ? [
|
|
2614
|
-
s = -new
|
|
2667
|
+
if (q.start.copy(l.start), q.end.copy(l.end), l.isVerticalReferenceLine) {
|
|
2668
|
+
const [h, d] = l.start.y < l.end.y ? [q.start, q.end] : [q.end, q.start];
|
|
2669
|
+
s = -new L(h, d).direction().angleBetween(new M(0, 1), "angle", "360"), i = null;
|
|
2615
2670
|
break;
|
|
2616
2671
|
}
|
|
2617
|
-
(!i ||
|
|
2672
|
+
(!i || q.length() > i.length()) && (i = q.clone(), i.userData.index = c);
|
|
2618
2673
|
}
|
|
2619
2674
|
if (i) {
|
|
2620
2675
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
2621
2676
|
const [c, l] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
|
|
2622
|
-
s = -new
|
|
2677
|
+
s = -new L(c, l).direction().angleBetween(new M(0, 1), "angle", "360");
|
|
2623
2678
|
}
|
|
2624
2679
|
const r = e.originalBox.center, o = M.zero(), a = e.originalData.map((c) => {
|
|
2625
|
-
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(
|
|
2680
|
+
const l = o.copy(c.start).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.start.z), h = o.copy(c.end).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(ht(c), { start: l, end: h });
|
|
2626
2681
|
return d.drawWindow && d.drawWindow.forEach((f) => {
|
|
2627
2682
|
f.p = o.copy(f.p).division(r).rotate(M.zero(), s * (Math.PI / 180)).toJson(f.p.z);
|
|
2628
2683
|
}), d;
|
|
@@ -2643,7 +2698,7 @@ class Me extends k {
|
|
|
2643
2698
|
});
|
|
2644
2699
|
}
|
|
2645
2700
|
}
|
|
2646
|
-
class
|
|
2701
|
+
class Pt extends z {
|
|
2647
2702
|
static name = "Variable";
|
|
2648
2703
|
originalLineVisible = !0;
|
|
2649
2704
|
dxfVisible = !0;
|
|
@@ -2670,14 +2725,166 @@ class Rt extends _ {
|
|
|
2670
2725
|
if (t in this) return this[t];
|
|
2671
2726
|
}
|
|
2672
2727
|
}
|
|
2673
|
-
class
|
|
2728
|
+
class Rt extends z {
|
|
2729
|
+
static name = "LineAnalysis";
|
|
2730
|
+
Dxf = null;
|
|
2731
|
+
Variable = null;
|
|
2732
|
+
lineSegmentList = [];
|
|
2733
|
+
container = new I.Group();
|
|
2734
|
+
// 误差角度
|
|
2735
|
+
errorAngle = 4;
|
|
2736
|
+
width = 0.4;
|
|
2737
|
+
/**
|
|
2738
|
+
*
|
|
2739
|
+
* @param parent
|
|
2740
|
+
*/
|
|
2741
|
+
onAddFromParent(t) {
|
|
2742
|
+
this.Dxf = t.findComponentByType(Y), this.Variable = this.parent?.findComponentByType(Pt), this.Dxf.addEventListener("setDta", () => {
|
|
2743
|
+
this.lineAnalysis(), this.dispatchEvent({ type: "analysisCompleted" });
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
*
|
|
2748
|
+
* @param p1
|
|
2749
|
+
* @param p2
|
|
2750
|
+
* @param width
|
|
2751
|
+
* @returns
|
|
2752
|
+
*/
|
|
2753
|
+
expandLineSegment(t, e, n = 0.1) {
|
|
2754
|
+
const s = e.normal(t), i = e.direction(t).mutiplyScalar(n * 0.5), r = t.direction(e).mutiplyScalar(n * 0.5), o = s.x * n * 0.5, a = s.y * n * 0.5;
|
|
2755
|
+
return {
|
|
2756
|
+
points: [
|
|
2757
|
+
// 第一条线
|
|
2758
|
+
new M(t.x + o, t.y + a).add(r),
|
|
2759
|
+
new M(e.x + o, e.y + a).add(i),
|
|
2760
|
+
// 第二条线
|
|
2761
|
+
new M(t.x - o, t.y - a).add(r),
|
|
2762
|
+
new M(e.x - o, e.y - a).add(i)
|
|
2763
|
+
],
|
|
2764
|
+
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
2765
|
+
rectIndices: [0, 1, 3, 2, 0]
|
|
2766
|
+
};
|
|
2767
|
+
}
|
|
2768
|
+
appendLineSegmentList = [];
|
|
2769
|
+
/**
|
|
2770
|
+
* 追加数据
|
|
2771
|
+
* @param p1
|
|
2772
|
+
* @param p2
|
|
2773
|
+
*/
|
|
2774
|
+
addData(t, e) {
|
|
2775
|
+
const n = this.Dxf;
|
|
2776
|
+
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new L(t.clone(), e.clone()));
|
|
2777
|
+
}
|
|
2778
|
+
/** 结果分析创建矩形
|
|
2779
|
+
* @param result
|
|
2780
|
+
*/
|
|
2781
|
+
createRectangle(t) {
|
|
2782
|
+
const e = this.Dxf, n = t.project, s = t.project2;
|
|
2783
|
+
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]);
|
|
2784
|
+
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(d);
|
|
2785
|
+
p.multiplyScalar(e.width * 0.5);
|
|
2786
|
+
const y = d.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), g = d.direction(f), w = y.direction(x);
|
|
2787
|
+
if (!(g.x > 0 && w.x < 0 || g.x < 0 && w.x > 0 || g.y > 0 && w.y < 0 || g.y < 0 && w.y > 0)) {
|
|
2788
|
+
d.set(y.x, y.y), f.set(x.x, x.y);
|
|
2789
|
+
for (let D = 1; D < o; D++) {
|
|
2790
|
+
const m = l.clone().multiplyScalar(a * D), S = h.clone().multiplyScalar(c * D), T = d.clone().add(m), E = f.clone().add(S);
|
|
2791
|
+
this.addData(T, E);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
quadtree;
|
|
2796
|
+
/**
|
|
2797
|
+
* 构建线段四叉树,快速查找,
|
|
2798
|
+
*/
|
|
2799
|
+
buildQuadtree() {
|
|
2800
|
+
const t = this.Dxf, e = [];
|
|
2801
|
+
this.quadtree = new B(t.originalBox, 2), t.lineSegments.forEach((n) => {
|
|
2802
|
+
n.userData?.isDoor || (this.quadtree?.insert({
|
|
2803
|
+
line: n,
|
|
2804
|
+
userData: e.length
|
|
2805
|
+
}), e.push(n));
|
|
2806
|
+
}), this.lineSegmentList = e;
|
|
2807
|
+
}
|
|
2808
|
+
resultList = [];
|
|
2809
|
+
mergeWallLines = [];
|
|
2810
|
+
/** 线段分析
|
|
2811
|
+
* @description 判断两条线段距离是否较短且趋近平行,然后查找两条线段的重合部分的投影线,以此判断两根线是否需要合并
|
|
2812
|
+
* @param data
|
|
2813
|
+
*/
|
|
2814
|
+
lineAnalysis() {
|
|
2815
|
+
this.buildQuadtree();
|
|
2816
|
+
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
2817
|
+
e.forEach((i, r) => {
|
|
2818
|
+
const o = e[r], a = it.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
2819
|
+
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
2820
|
+
try {
|
|
2821
|
+
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
2822
|
+
const h = this.projectionAnalysis(l, r, o, e);
|
|
2823
|
+
h && s.push(h), n.add(`${r}-${l}`);
|
|
2824
|
+
} catch {
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
}), this.appendLineSegmentList.length = 0, s.forEach(this.createRectangle.bind(this)), this.resultList = s;
|
|
2828
|
+
}
|
|
2829
|
+
/** 线段投影分析
|
|
2830
|
+
* @param index
|
|
2831
|
+
* @param sourceLineSegment
|
|
2832
|
+
* @param lineSegmentList
|
|
2833
|
+
* @returns
|
|
2834
|
+
*/
|
|
2835
|
+
projectionAnalysis(t, e, n, s) {
|
|
2836
|
+
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
2837
|
+
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
2838
|
+
let c;
|
|
2839
|
+
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
2840
|
+
return l.getLength() > h.getLength() ? c = {
|
|
2841
|
+
target: i,
|
|
2842
|
+
targetIndex: t,
|
|
2843
|
+
source: n,
|
|
2844
|
+
sourceIndex: e,
|
|
2845
|
+
project: l,
|
|
2846
|
+
project2: h
|
|
2847
|
+
} : c = {
|
|
2848
|
+
target: n,
|
|
2849
|
+
targetIndex: e,
|
|
2850
|
+
source: i,
|
|
2851
|
+
sourceIndex: t,
|
|
2852
|
+
project: h,
|
|
2853
|
+
project2: l
|
|
2854
|
+
}, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
function vt(u, t, e = 1e-3) {
|
|
2859
|
+
if (Array.isArray(u) && u[0] instanceof M) {
|
|
2860
|
+
const s = u;
|
|
2861
|
+
u = s.map((i, r) => {
|
|
2862
|
+
const o = s[(r + 1) % s.length];
|
|
2863
|
+
return new L(i, o);
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2866
|
+
if (u instanceof L) return vt([u], t, e);
|
|
2867
|
+
const n = $.finalInstance;
|
|
2868
|
+
if (n) {
|
|
2869
|
+
const s = n.findComponentByName("Renderer"), i = n.findComponentByName("Editor"), r = s.createLineSegments(u, 0, t, i?.container);
|
|
2870
|
+
return r.position.z = e, r;
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
function Ee(u, t, e = 1e-3) {
|
|
2874
|
+
const n = $.finalInstance;
|
|
2875
|
+
if (n) {
|
|
2876
|
+
const s = n.findComponentByName("Renderer"), i = n.findComponentByName("Editor"), r = s.createCircle(u, t, i?.container);
|
|
2877
|
+
return r.position.z = e, r;
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
class Ae {
|
|
2674
2881
|
// 所有可查找的点位
|
|
2675
2882
|
possibleDoorPoints = [];
|
|
2676
2883
|
doorPoint = [];
|
|
2677
2884
|
calculatedDoorPoint = [];
|
|
2678
2885
|
dxf;
|
|
2679
2886
|
// 包含所有点的虚拟网格
|
|
2680
|
-
pointVirtualGrid = new
|
|
2887
|
+
pointVirtualGrid = new k();
|
|
2681
2888
|
// 只包含可查找点的虚拟网格
|
|
2682
2889
|
findPointVirtualGrid;
|
|
2683
2890
|
quadtree;
|
|
@@ -2690,7 +2897,7 @@ class Se {
|
|
|
2690
2897
|
lineAnalysis;
|
|
2691
2898
|
continueFind = !0;
|
|
2692
2899
|
constructor(t) {
|
|
2693
|
-
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new
|
|
2900
|
+
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new k(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((i) => {
|
|
2694
2901
|
this.pointVirtualGrid.insert(i.start, i), this.pointVirtualGrid.insert(i.end, i);
|
|
2695
2902
|
});
|
|
2696
2903
|
const { doorPoints: e, calculatedDoorPoint: n } = this.getDoorPoint();
|
|
@@ -2730,15 +2937,15 @@ class Se {
|
|
|
2730
2937
|
);
|
|
2731
2938
|
const a = [];
|
|
2732
2939
|
return o.forEach((c) => {
|
|
2733
|
-
const l = new
|
|
2940
|
+
const l = new L(c?.start, c?.end), h = l.length();
|
|
2734
2941
|
if (h < n) return;
|
|
2735
2942
|
const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
2736
2943
|
for (let y = 0; y < 3; y++) {
|
|
2737
|
-
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)),
|
|
2944
|
+
const x = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), g = new L(
|
|
2738
2945
|
x,
|
|
2739
2946
|
x.clone().add(d.clone().multiplyScalar(1))
|
|
2740
2947
|
);
|
|
2741
|
-
if (
|
|
2948
|
+
if (g.directionMove(d, -0.5), this.quadtree.queryLineSegment(g).length) return;
|
|
2742
2949
|
}
|
|
2743
2950
|
a.push(l);
|
|
2744
2951
|
}), a;
|
|
@@ -2758,7 +2965,7 @@ class Se {
|
|
|
2758
2965
|
return this.lineSegments.forEach((e) => {
|
|
2759
2966
|
e.points.forEach((n, s) => {
|
|
2760
2967
|
for (let r = 0; r < this._pointsExcludeRule.length; r++) if (this._pointsExcludeRule[r](e, n, s)) return;
|
|
2761
|
-
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid:
|
|
2968
|
+
this.pointVirtualGrid.queryPoint(n).filter((r) => r.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: Z() });
|
|
2762
2969
|
});
|
|
2763
2970
|
}), t;
|
|
2764
2971
|
}
|
|
@@ -2771,7 +2978,7 @@ class Se {
|
|
|
2771
2978
|
const r = n.lineSegments[i[4]], o = n.originalData[i[4]];
|
|
2772
2979
|
if (o.doorDirectConnection) {
|
|
2773
2980
|
this.continueFind = !1;
|
|
2774
|
-
const a = new
|
|
2981
|
+
const a = new L(M.from(o.start), M.from(o.end));
|
|
2775
2982
|
a.userData = {
|
|
2776
2983
|
doorDirectConnection: !0,
|
|
2777
2984
|
isDoor: !0
|
|
@@ -2780,7 +2987,7 @@ class Se {
|
|
|
2780
2987
|
l.length && e.push({
|
|
2781
2988
|
line: l[0].userData,
|
|
2782
2989
|
point: l[0].point,
|
|
2783
|
-
uuid:
|
|
2990
|
+
uuid: Z()
|
|
2784
2991
|
});
|
|
2785
2992
|
});
|
|
2786
2993
|
} else if (o.drawDoorData) {
|
|
@@ -2794,7 +3001,7 @@ class Se {
|
|
|
2794
3001
|
l.length && t.push({
|
|
2795
3002
|
line: l[0].userData,
|
|
2796
3003
|
point: a,
|
|
2797
|
-
uuid:
|
|
3004
|
+
uuid: Z()
|
|
2798
3005
|
});
|
|
2799
3006
|
} else
|
|
2800
3007
|
console.warn(`门的线段顺序${i[4]} 没有drawDoorData属性`);
|
|
@@ -2821,83 +3028,85 @@ class Se {
|
|
|
2821
3028
|
*/
|
|
2822
3029
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
2823
3030
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
2824
|
-
function o({ point: x, line:
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2827
|
-
const S = i.queryCircle(x, n).filter((
|
|
2828
|
-
for (let
|
|
2829
|
-
const
|
|
2830
|
-
if (
|
|
2831
|
-
w.
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
3031
|
+
function o({ point: x, line: g }, w, D) {
|
|
3032
|
+
const m = g.direction();
|
|
3033
|
+
g.start === x && m.multiplyScalar(-1);
|
|
3034
|
+
const S = i.queryCircle(x, n).filter((E) => E.userData !== g).sort((E, A) => E.point.distance(x) - A.point.distance(x)), T = [];
|
|
3035
|
+
for (let E = 0; E < S.length; E++) {
|
|
3036
|
+
const A = e.findIndex((O) => O.point === S[E].point);
|
|
3037
|
+
if (A === -1) continue;
|
|
3038
|
+
const v = t[w].uuid, C = e[A].uuid;
|
|
3039
|
+
if (D.has(`${v}.${C}`)) continue;
|
|
3040
|
+
D.add(`${v}.${C}`), D.add(`${C}.${v}`);
|
|
3041
|
+
const F = S[E].point, N = new L(x.clone(), F.clone());
|
|
3042
|
+
if (N.direction().angleBetween(m, "angle") < s) {
|
|
3043
|
+
const O = t[w].line.direction(), R = S[E].userData;
|
|
3044
|
+
R.start.equal(S[E].point) && O.multiplyScalar(-1), N.direction().multiplyScalar(-1).angleBetween(O, "angle") < s && (r.queryLineSegment(N).filter((W) => !(W.line.start.equal(x) || W.line.end.equal(x) || W.line === R)).length || T.push({
|
|
3045
|
+
findData: S[E],
|
|
3046
|
+
findUuid: C,
|
|
3047
|
+
doorLine: N,
|
|
3048
|
+
doorUuid: v
|
|
2840
3049
|
}));
|
|
2841
3050
|
}
|
|
2842
3051
|
}
|
|
2843
|
-
return
|
|
3052
|
+
return T;
|
|
2844
3053
|
}
|
|
2845
|
-
function a(x,
|
|
2846
|
-
|
|
3054
|
+
function a(x, g, w, D, m) {
|
|
3055
|
+
D.add(x);
|
|
2847
3056
|
const S = [];
|
|
2848
|
-
|
|
2849
|
-
for (let
|
|
2850
|
-
const
|
|
2851
|
-
if (
|
|
2852
|
-
const
|
|
2853
|
-
a(
|
|
2854
|
-
} else S.push(
|
|
3057
|
+
m && S.push(m);
|
|
3058
|
+
for (let T = 0; T < w.length; T++) {
|
|
3059
|
+
const E = w[T];
|
|
3060
|
+
if (g.has(E.findUuid)) {
|
|
3061
|
+
const A = g.get(E.findUuid);
|
|
3062
|
+
a(E.findUuid, g, A, D, E) && S.push(E);
|
|
3063
|
+
} else S.push(E);
|
|
2855
3064
|
}
|
|
2856
|
-
return S.sort((
|
|
3065
|
+
return S.sort((T, E) => T.doorLine.length() - E.doorLine.length()), m && S[0] === m ? (w.splice(0), !0) : (w.splice(1), !1);
|
|
2857
3066
|
}
|
|
2858
3067
|
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
2859
|
-
t.map((x,
|
|
2860
|
-
const
|
|
2861
|
-
|
|
3068
|
+
t.map((x, g) => {
|
|
3069
|
+
const w = o(x, g, c);
|
|
3070
|
+
w.length && l.set(x.uuid, w);
|
|
2862
3071
|
}), c.clear();
|
|
2863
3072
|
const h = /* @__PURE__ */ new Map();
|
|
2864
|
-
l.forEach((x,
|
|
2865
|
-
if (!c.has(
|
|
2866
|
-
const
|
|
2867
|
-
h.has(
|
|
3073
|
+
l.forEach((x, g) => {
|
|
3074
|
+
if (!c.has(g) && x.length && a(g, l, x, c), x.length) {
|
|
3075
|
+
const w = x[0];
|
|
3076
|
+
h.has(w.doorUuid) || h.set(w.doorUuid, []), h.get(w.doorUuid)?.push(w), h.has(w.findUuid) || h.set(w.findUuid, []), h.get(w.findUuid)?.push(w);
|
|
2868
3077
|
}
|
|
2869
3078
|
});
|
|
2870
3079
|
const d = /* @__PURE__ */ new Set();
|
|
2871
3080
|
h.forEach((x) => {
|
|
2872
3081
|
if (x.length > 1) {
|
|
2873
|
-
x.sort((
|
|
2874
|
-
for (let
|
|
3082
|
+
x.sort((g, w) => g.doorLine.length() - w.doorLine.length());
|
|
3083
|
+
for (let g = 1; g < x.length; g++) d.add(x[g]);
|
|
2875
3084
|
}
|
|
2876
3085
|
});
|
|
2877
3086
|
const f = [], p = [];
|
|
2878
3087
|
l.forEach((x) => {
|
|
2879
3088
|
if (x.length) {
|
|
2880
|
-
const
|
|
2881
|
-
d.has(
|
|
3089
|
+
const g = x[0];
|
|
3090
|
+
d.has(g) || (f.push(g), p.push(g.doorUuid, g.findUuid));
|
|
2882
3091
|
}
|
|
2883
3092
|
});
|
|
2884
3093
|
const y = [];
|
|
2885
3094
|
return f.forEach((x) => {
|
|
2886
|
-
const
|
|
2887
|
-
if (
|
|
2888
|
-
|
|
2889
|
-
const
|
|
2890
|
-
(
|
|
2891
|
-
start:
|
|
2892
|
-
end:
|
|
3095
|
+
const g = t.findIndex((A) => A.uuid === x.doorUuid), w = e.findIndex((A) => A.uuid === x.findUuid), D = t[g].point.clone(), m = e[w].point.clone(), S = this.findLongLineSegment(t[g].line), T = this.findLongLineSegment(e[w].line), E = S.projectPoint(m);
|
|
3096
|
+
if (E) {
|
|
3097
|
+
D.copy(E);
|
|
3098
|
+
const A = new L(D, m), v = T.includedAngle(A);
|
|
3099
|
+
(v < 10 || v > 170 || Math.abs(90 - v) < 10) && y.push({
|
|
3100
|
+
start: D,
|
|
3101
|
+
end: m
|
|
2893
3102
|
});
|
|
2894
3103
|
} else {
|
|
2895
|
-
const
|
|
2896
|
-
|
|
2897
|
-
const
|
|
2898
|
-
(
|
|
2899
|
-
start:
|
|
2900
|
-
end:
|
|
3104
|
+
const A = T.projectPoint(D);
|
|
3105
|
+
A && m.copy(A);
|
|
3106
|
+
const v = new L(D, m), C = S.includedAngle(v);
|
|
3107
|
+
(C < 10 || C > 170 || Math.abs(90 - C) < 10) && y.push({
|
|
3108
|
+
start: D,
|
|
3109
|
+
end: m
|
|
2901
3110
|
});
|
|
2902
3111
|
}
|
|
2903
3112
|
}), e.splice(
|
|
@@ -2918,7 +3127,7 @@ class Se {
|
|
|
2918
3127
|
searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
2919
3128
|
const s = this.quadtree, i = e.direction();
|
|
2920
3129
|
e.start === t && i.multiplyScalar(-1);
|
|
2921
|
-
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new
|
|
3130
|
+
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new L(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
|
|
2922
3131
|
point: c.line.getIntersection(o),
|
|
2923
3132
|
line: c.line
|
|
2924
3133
|
})).filter((c) => c.point).sort((c, l) => t.distance(c.point) - t.distance(l.point));
|
|
@@ -2945,7 +3154,7 @@ class Se {
|
|
|
2945
3154
|
break;
|
|
2946
3155
|
}
|
|
2947
3156
|
}
|
|
2948
|
-
const l = new
|
|
3157
|
+
const l = new L(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
|
|
2949
3158
|
point: d.line.getIntersection(l),
|
|
2950
3159
|
line: d.line
|
|
2951
3160
|
})).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
|
|
@@ -2979,143 +3188,25 @@ class Se {
|
|
|
2979
3188
|
return e;
|
|
2980
3189
|
}
|
|
2981
3190
|
}
|
|
2982
|
-
class
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
errorAngle = 4;
|
|
2990
|
-
width = 0.4;
|
|
3191
|
+
class Te extends z {
|
|
3192
|
+
doorSearchNearAngle = 110;
|
|
3193
|
+
doorSearchDistance = 2;
|
|
3194
|
+
DoorsAnalysis;
|
|
3195
|
+
skipFindDoor = !1;
|
|
3196
|
+
needsSaveDoor = !1;
|
|
3197
|
+
doors = [];
|
|
2991
3198
|
/**
|
|
2992
3199
|
*
|
|
2993
3200
|
* @param parent
|
|
2994
3201
|
*/
|
|
2995
3202
|
onAddFromParent(t) {
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
* @param p1
|
|
3001
|
-
* @param p2
|
|
3002
|
-
* @param width
|
|
3003
|
-
* @returns
|
|
3004
|
-
*/
|
|
3005
|
-
expandLineSegment(t, e, n = 0.1) {
|
|
3006
|
-
const s = e.normal(t), i = e.direction(t).mutiplyScalar(n * 0.5), r = t.direction(e).mutiplyScalar(n * 0.5), o = s.x * n * 0.5, a = s.y * n * 0.5;
|
|
3007
|
-
return {
|
|
3008
|
-
points: [
|
|
3009
|
-
// 第一条线
|
|
3010
|
-
new M(t.x + o, t.y + a).add(r),
|
|
3011
|
-
new M(e.x + o, e.y + a).add(i),
|
|
3012
|
-
// 第二条线
|
|
3013
|
-
new M(t.x - o, t.y - a).add(r),
|
|
3014
|
-
new M(e.x - o, e.y - a).add(i)
|
|
3015
|
-
],
|
|
3016
|
-
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
3017
|
-
rectIndices: [0, 1, 3, 2, 0]
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
appendLineSegmentList = [];
|
|
3021
|
-
/**
|
|
3022
|
-
* 追加数据
|
|
3023
|
-
* @param p1
|
|
3024
|
-
* @param p2
|
|
3025
|
-
*/
|
|
3026
|
-
addData(t, e) {
|
|
3027
|
-
const n = this.Dxf;
|
|
3028
|
-
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new A(t.clone(), e.clone()));
|
|
3029
|
-
}
|
|
3030
|
-
/** 结果分析创建矩形
|
|
3031
|
-
* @param result
|
|
3032
|
-
*/
|
|
3033
|
-
createRectangle(t) {
|
|
3034
|
-
const e = this.Dxf, n = t.project, s = t.project2;
|
|
3035
|
-
n.includedAngle(s) > 135 && (s.points = [s.points[1], s.points[0]]), this.addData(n.points[0], s.points[0]), this.addData(n.points[1], s.points[1]);
|
|
3036
|
-
const i = n.points[0].distance(s.points[0]), r = n.points[1].distance(s.points[1]), o = Math.ceil(Math.max(i, r) / e.width), a = i / o, c = r / o, l = s.points[0].direction(n.points[0]), h = s.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), p = f.direction(d);
|
|
3037
|
-
p.multiplyScalar(e.width * 0.5);
|
|
3038
|
-
const y = d.clone().add(p), x = f.clone().add(p.multiplyScalar(-1)), m = d.direction(f), D = y.direction(x);
|
|
3039
|
-
if (!(m.x > 0 && D.x < 0 || m.x < 0 && D.x > 0 || m.y > 0 && D.y < 0 || m.y < 0 && D.y > 0)) {
|
|
3040
|
-
d.set(y.x, y.y), f.set(x.x, x.y);
|
|
3041
|
-
for (let w = 1; w < o; w++) {
|
|
3042
|
-
const g = l.clone().multiplyScalar(a * w), S = h.clone().multiplyScalar(c * w), E = d.clone().add(g), L = f.clone().add(S);
|
|
3043
|
-
this.addData(E, L);
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
quadtree;
|
|
3048
|
-
/**
|
|
3049
|
-
* 构建线段四叉树,快速查找,
|
|
3050
|
-
*/
|
|
3051
|
-
buildQuadtree() {
|
|
3052
|
-
const t = this.Dxf, e = [];
|
|
3053
|
-
this.quadtree = new F(t.originalBox, 2), t.lineSegments.forEach((n) => {
|
|
3054
|
-
n.userData?.isDoor || (this.quadtree?.insert({
|
|
3055
|
-
line: n,
|
|
3056
|
-
userData: e.length
|
|
3057
|
-
}), e.push(n));
|
|
3058
|
-
}), this.lineSegmentList = e;
|
|
3059
|
-
}
|
|
3060
|
-
resultList = [];
|
|
3061
|
-
mergeWallLines = [];
|
|
3062
|
-
/** 线段分析
|
|
3063
|
-
* @description 判断两条线段距离是否较短且趋近平行,然后查找两条线段的重合部分的投影线,以此判断两根线是否需要合并
|
|
3064
|
-
* @param data
|
|
3065
|
-
*/
|
|
3066
|
-
lineAnalysis() {
|
|
3067
|
-
this.buildQuadtree();
|
|
3068
|
-
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
3069
|
-
e.forEach((i, r) => {
|
|
3070
|
-
const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
3071
|
-
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
3072
|
-
try {
|
|
3073
|
-
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
3074
|
-
const h = this.projectionAnalysis(l, r, o, e);
|
|
3075
|
-
h && s.push(h), n.add(`${r}-${l}`);
|
|
3076
|
-
} catch {
|
|
3077
|
-
}
|
|
3078
|
-
});
|
|
3079
|
-
}), this.appendLineSegmentList.length = 0, s.forEach(this.createRectangle.bind(this)), this.resultList = s;
|
|
3080
|
-
}
|
|
3081
|
-
/** 线段投影分析
|
|
3082
|
-
* @param index
|
|
3083
|
-
* @param sourceLineSegment
|
|
3084
|
-
* @param lineSegmentList
|
|
3085
|
-
* @returns
|
|
3086
|
-
*/
|
|
3087
|
-
projectionAnalysis(t, e, n, s) {
|
|
3088
|
-
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
3089
|
-
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
3090
|
-
let c;
|
|
3091
|
-
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
3092
|
-
return l.getLength() > h.getLength() ? c = {
|
|
3093
|
-
target: i,
|
|
3094
|
-
targetIndex: t,
|
|
3095
|
-
source: n,
|
|
3096
|
-
sourceIndex: e,
|
|
3097
|
-
project: l,
|
|
3098
|
-
project2: h
|
|
3099
|
-
} : c = {
|
|
3100
|
-
target: n,
|
|
3101
|
-
targetIndex: e,
|
|
3102
|
-
source: i,
|
|
3103
|
-
sourceIndex: t,
|
|
3104
|
-
project: h,
|
|
3105
|
-
project2: l
|
|
3106
|
-
}, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
|
|
3107
|
-
}
|
|
3108
|
-
}
|
|
3109
|
-
doorSearchNearAngle = 110;
|
|
3110
|
-
doorSearchDistance = 2;
|
|
3111
|
-
doors = [];
|
|
3112
|
-
DoorsAnalysis;
|
|
3113
|
-
skipFindDoor = !1;
|
|
3114
|
-
doorsAnalysis() {
|
|
3115
|
-
this.skipFindDoor || (this.DoorsAnalysis = new Se(this), this.skipFindDoor = !1), this.dispatchEvent({ type: "analysisCompleted" });
|
|
3203
|
+
const e = t.findComponentByType(Y), n = this.parent?.findComponentByType(Rt);
|
|
3204
|
+
e.addEventListener("createGroup", () => {
|
|
3205
|
+
this.skipFindDoor ? this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])) : this.DoorsAnalysis = new Ae(n), this.skipFindDoor = !1, this.dispatchEvent({ type: "analysisCompleted" });
|
|
3206
|
+
});
|
|
3116
3207
|
}
|
|
3117
3208
|
}
|
|
3118
|
-
class
|
|
3209
|
+
class be extends z {
|
|
3119
3210
|
static name = "ThreeVJia";
|
|
3120
3211
|
lineSegments = [];
|
|
3121
3212
|
onAddFromParent() {
|
|
@@ -3127,8 +3218,8 @@ class Le extends _ {
|
|
|
3127
3218
|
t.resultList.forEach((l) => {
|
|
3128
3219
|
const h = s.get(l.target) ?? [], d = s.get(l.source) ?? [], f = l.project.clone(), p = l.project2.clone();
|
|
3129
3220
|
f.includedAngle(p) > 135 && (p.points = [p.points[1], p.points[0]]), h.push(...f.points), d.push(...p.points), s.set(l.target, h), s.set(l.source, d);
|
|
3130
|
-
const y = new
|
|
3131
|
-
|
|
3221
|
+
const y = new L(f.start, p.start), x = new L(f.end, p.end), g = new L(y.center, x.center);
|
|
3222
|
+
g.userData.wallWidth = Math.max(y.length(), x.length()), r.push(g);
|
|
3132
3223
|
});
|
|
3133
3224
|
const a = [];
|
|
3134
3225
|
i = i.filter((l) => {
|
|
@@ -3144,7 +3235,7 @@ class Le extends _ {
|
|
|
3144
3235
|
const f = [];
|
|
3145
3236
|
for (let p = 0; p < h.length; p++) {
|
|
3146
3237
|
const y = h[p];
|
|
3147
|
-
y.userData.type === "start" ? (f.length === 0 && (a.push(new
|
|
3238
|
+
y.userData.type === "start" ? (f.length === 0 && (a.push(new L(d.start.clone(), y.clone())), d.start.copy(y)), f.push("start")) : (f.pop(), f.length === 0 && d.start.copy(y));
|
|
3148
3239
|
}
|
|
3149
3240
|
a.push(d);
|
|
3150
3241
|
}
|
|
@@ -3235,13 +3326,15 @@ class Le extends _ {
|
|
|
3235
3326
|
if (typeof window < "u") {
|
|
3236
3327
|
const e = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
|
|
3237
3328
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
3238
|
-
} else typeof global < "u" && (await
|
|
3329
|
+
} else typeof global < "u" && (await X("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
|
|
3239
3330
|
}
|
|
3240
3331
|
}
|
|
3241
|
-
class
|
|
3332
|
+
class $ extends ie {
|
|
3242
3333
|
Dxf;
|
|
3243
3334
|
AngleCorrectionDxf;
|
|
3244
3335
|
Variable;
|
|
3336
|
+
LineAnalysis;
|
|
3337
|
+
DoorsAnalysis;
|
|
3245
3338
|
wallWidth;
|
|
3246
3339
|
environment;
|
|
3247
3340
|
static finalInstance;
|
|
@@ -3250,7 +3343,7 @@ class ht extends se {
|
|
|
3250
3343
|
* @param scale 原始数据缩放比例
|
|
3251
3344
|
*/
|
|
3252
3345
|
constructor(t = 0.1, e = 1) {
|
|
3253
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new
|
|
3346
|
+
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new Y(this.wallWidth, e), this.AngleCorrectionDxf = new Le(), this.Variable = new Pt(), this.LineAnalysis = new Rt(), this.DoorsAnalysis = new Te(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(this.LineAnalysis), this.addComponent(this.DoorsAnalysis), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new be()), $.finalInstance = this;
|
|
3254
3347
|
}
|
|
3255
3348
|
usePlugin(t) {
|
|
3256
3349
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3270,12 +3363,12 @@ class ut {
|
|
|
3270
3363
|
* @returns
|
|
3271
3364
|
*/
|
|
3272
3365
|
static findExtWallByTraj(t, e, n = 0.4) {
|
|
3273
|
-
const s = new
|
|
3366
|
+
const s = new B(P.fromByLineSegment(...t));
|
|
3274
3367
|
return t.forEach((i) => s.insert({ line: i, userData: void 0 })), t = t.filter((i) => {
|
|
3275
3368
|
const r = i.center, o = /* @__PURE__ */ new Set();
|
|
3276
3369
|
for (const a of e) {
|
|
3277
3370
|
if (o.size === 2) break;
|
|
3278
|
-
const c = new
|
|
3371
|
+
const c = new L(r, a);
|
|
3279
3372
|
if (!s.queryLineSegment(c).filter((h) => !(h.line === i || h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
|
|
3280
3373
|
const h = i.pointPosition(a);
|
|
3281
3374
|
h !== "on" && o.add(h);
|
|
@@ -3289,89 +3382,87 @@ class ut {
|
|
|
3289
3382
|
* @param trajectoryPoints
|
|
3290
3383
|
*/
|
|
3291
3384
|
static boundExtbyTraj(t, e, n = 0.12) {
|
|
3292
|
-
function s(
|
|
3293
|
-
return
|
|
3294
|
-
const
|
|
3295
|
-
|
|
3296
|
-
const
|
|
3297
|
-
if (
|
|
3385
|
+
function s(g, w) {
|
|
3386
|
+
return w.queryLineSegment(g).filter((D) => D.line !== g).map(({ line: D }) => {
|
|
3387
|
+
const m = { resultLine: D, type: "intersect", direction: "vertical", point: null, newLine: null };
|
|
3388
|
+
g.sameEndpoint(D) && (m.type = "endpoint"), g.parallel(D) && (m.direction = "parallel");
|
|
3389
|
+
const S = g.getSameEndpoint(D);
|
|
3390
|
+
if (S) m.point = S[1];
|
|
3298
3391
|
else {
|
|
3299
|
-
const
|
|
3300
|
-
|
|
3392
|
+
const T = D.getIntersection(g);
|
|
3393
|
+
T && (m.point = D.start.equal(T) ? D.start : D.end);
|
|
3301
3394
|
}
|
|
3302
|
-
return
|
|
3395
|
+
return m;
|
|
3303
3396
|
});
|
|
3304
3397
|
}
|
|
3305
|
-
function i(
|
|
3306
|
-
const
|
|
3307
|
-
if (
|
|
3308
|
-
const
|
|
3309
|
-
|
|
3310
|
-
} else if (
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3398
|
+
function i(g) {
|
|
3399
|
+
const w = g.userData.expandDirect;
|
|
3400
|
+
if (w === "left") {
|
|
3401
|
+
const D = g.getLeftDirection();
|
|
3402
|
+
g.directionMove(D, n * 0.5);
|
|
3403
|
+
} else if (w === "right") {
|
|
3404
|
+
const D = g.getRightDirection();
|
|
3405
|
+
g.directionMove(D, n * 0.5);
|
|
3313
3406
|
}
|
|
3314
3407
|
}
|
|
3315
|
-
function r({ resultLine:
|
|
3316
|
-
if (
|
|
3317
|
-
|
|
3318
|
-
else if (
|
|
3319
|
-
if (
|
|
3320
|
-
const
|
|
3321
|
-
|
|
3408
|
+
function r({ resultLine: g, type: w, direction: D, point: m }, S, T, E) {
|
|
3409
|
+
if (w === "intersect")
|
|
3410
|
+
m && m.copy(S.projectPoint(m) ?? m);
|
|
3411
|
+
else if (D === "vertical") {
|
|
3412
|
+
if (m) {
|
|
3413
|
+
const A = S.projectPoint(m, !1);
|
|
3414
|
+
m.copy(A), S.isPointOnSegment(A) || (S.start.distance(A) < S.end.distance(A) ? E.push(new L(A.clone(), S.start.clone())) : E.push(new L(A.clone(), S.end.clone())));
|
|
3322
3415
|
}
|
|
3323
|
-
} else if (!d.includes(
|
|
3324
|
-
let
|
|
3325
|
-
if (
|
|
3326
|
-
|
|
3327
|
-
const C = new A
|
|
3328
|
-
C.length() &&
|
|
3416
|
+
} else if (!d.includes(g) && m) {
|
|
3417
|
+
let A = S.projectPoint(m, !1), v;
|
|
3418
|
+
if (S.start.distance(m) < S.end.distance(m) ? v = S.start : v = S.end, A) {
|
|
3419
|
+
E.push(new L(m.clone(), A.clone()));
|
|
3420
|
+
const C = new L(A.clone(), v.clone());
|
|
3421
|
+
C.length() && E.push(C);
|
|
3329
3422
|
}
|
|
3330
3423
|
}
|
|
3331
|
-
|
|
3424
|
+
T.update(g);
|
|
3332
3425
|
}
|
|
3333
|
-
const o = Object.keys(e).map((
|
|
3334
|
-
let c = t.map(({ start:
|
|
3335
|
-
const
|
|
3336
|
-
return
|
|
3426
|
+
const o = Object.keys(e).map((g) => M.from(e[g])), a = [];
|
|
3427
|
+
let c = t.map(({ start: g, end: w, ...D }) => {
|
|
3428
|
+
const m = new L(M.from(g), M.from(w));
|
|
3429
|
+
return m.userData = D, a.push(g.z ?? 0, w.z ?? 0), m;
|
|
3337
3430
|
});
|
|
3338
|
-
const l = a.reduce((
|
|
3339
|
-
let d = ut.findExtWallByTraj(c, o).filter((
|
|
3340
|
-
c = c.filter((
|
|
3341
|
-
const p =
|
|
3342
|
-
|
|
3343
|
-
const y =
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
let L;
|
|
3349
|
-
return Object.defineProperty(E, "newLine", {
|
|
3431
|
+
const l = a.reduce((g, w) => g + w, 0) / a.length;
|
|
3432
|
+
let d = ut.findExtWallByTraj(c, o).filter((g) => g.userData.expandDirect);
|
|
3433
|
+
c = c.filter((g) => !d.includes(g)), c.push(...d), vt(d, { color: 65280 }), Ee(o, { size: 6 });
|
|
3434
|
+
const f = L.groupBySamePointAndParallel(d), p = new B(P.fromByLineSegment(...c));
|
|
3435
|
+
c.forEach((g) => g.userData.isDoor || p.insert(g));
|
|
3436
|
+
const y = f.map((g) => g.flatMap((w) => s(w, p))), x = [];
|
|
3437
|
+
return f.flatMap((g, w) => (g.forEach((m) => (i(m), p.update(m))), y[w].filter((m) => {
|
|
3438
|
+
if (!d.includes(m.resultLine)) {
|
|
3439
|
+
let S;
|
|
3440
|
+
return Object.defineProperty(m, "newLine", {
|
|
3350
3441
|
get() {
|
|
3351
|
-
return
|
|
3442
|
+
return S || (S = L.mergeLines(...g)), S;
|
|
3352
3443
|
}
|
|
3353
3444
|
}), !0;
|
|
3354
3445
|
}
|
|
3355
|
-
r(
|
|
3356
|
-
}))).reduce((
|
|
3357
|
-
|
|
3358
|
-
const
|
|
3359
|
-
for (let
|
|
3360
|
-
const
|
|
3361
|
-
|
|
3446
|
+
r(m, L.mergeLines(...g), p, x);
|
|
3447
|
+
}))).reduce((g, w) => (g.has(w.resultLine) || g.set(w.resultLine, []), g.get(w.resultLine)?.push(w), g), /* @__PURE__ */ new Map()).forEach((g) => {
|
|
3448
|
+
g.reduce((w, D) => (w.has(D.point) || w.set(D.point, []), w.get(D.point)?.push(D), w), /* @__PURE__ */ new Map()).forEach((w) => {
|
|
3449
|
+
const D = /* @__PURE__ */ new Set();
|
|
3450
|
+
for (let m = 0; m < w.length; m++) {
|
|
3451
|
+
const S = w[m];
|
|
3452
|
+
D.has(S.point) || (r(S, S.newLine, p, x), D.add(S.point));
|
|
3362
3453
|
}
|
|
3363
3454
|
});
|
|
3364
|
-
}), c.push(...
|
|
3455
|
+
}), c.push(...L.deduplication(x)), c.forEach((g) => g.userData.isWindow && nt(g)), c = et(c), c = L.deduplication(c), J(c, l);
|
|
3365
3456
|
}
|
|
3366
3457
|
}
|
|
3367
|
-
const
|
|
3458
|
+
const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3368
3459
|
__proto__: null,
|
|
3369
|
-
AxisAlignCorr:
|
|
3460
|
+
AxisAlignCorr: It,
|
|
3370
3461
|
BoundExt: ut,
|
|
3371
3462
|
lineDataToOriginalData: J,
|
|
3372
|
-
lineSegmentClipping:
|
|
3373
|
-
recomputedWindow:
|
|
3374
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
3463
|
+
lineSegmentClipping: et,
|
|
3464
|
+
recomputedWindow: nt
|
|
3465
|
+
}, Symbol.toStringTag, { value: "Module" })), Mt = {
|
|
3375
3466
|
POSITION: [
|
|
3376
3467
|
"byte",
|
|
3377
3468
|
"byte normalized",
|
|
@@ -3399,24 +3490,10 @@ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3399
3490
|
"unsigned short"
|
|
3400
3491
|
]
|
|
3401
3492
|
};
|
|
3402
|
-
class
|
|
3493
|
+
class st {
|
|
3403
3494
|
constructor() {
|
|
3404
3495
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
3405
|
-
return new Be(t);
|
|
3406
|
-
}), this.register(function(t) {
|
|
3407
|
-
return new Oe(t);
|
|
3408
|
-
}), this.register(function(t) {
|
|
3409
3496
|
return new je(t);
|
|
3410
|
-
}), this.register(function(t) {
|
|
3411
|
-
return new ze(t);
|
|
3412
|
-
}), this.register(function(t) {
|
|
3413
|
-
return new qe(t);
|
|
3414
|
-
}), this.register(function(t) {
|
|
3415
|
-
return new _e(t);
|
|
3416
|
-
}), this.register(function(t) {
|
|
3417
|
-
return new Fe(t);
|
|
3418
|
-
}), this.register(function(t) {
|
|
3419
|
-
return new Ue(t);
|
|
3420
3497
|
}), this.register(function(t) {
|
|
3421
3498
|
return new Ge(t);
|
|
3422
3499
|
}), this.register(function(t) {
|
|
@@ -3427,8 +3504,22 @@ class et {
|
|
|
3427
3504
|
return new Xe(t);
|
|
3428
3505
|
}), this.register(function(t) {
|
|
3429
3506
|
return new Ve(t);
|
|
3507
|
+
}), this.register(function(t) {
|
|
3508
|
+
return new ze(t);
|
|
3509
|
+
}), this.register(function(t) {
|
|
3510
|
+
return new qe(t);
|
|
3511
|
+
}), this.register(function(t) {
|
|
3512
|
+
return new _e(t);
|
|
3430
3513
|
}), this.register(function(t) {
|
|
3431
3514
|
return new We(t);
|
|
3515
|
+
}), this.register(function(t) {
|
|
3516
|
+
return new He(t);
|
|
3517
|
+
}), this.register(function(t) {
|
|
3518
|
+
return new Je(t);
|
|
3519
|
+
}), this.register(function(t) {
|
|
3520
|
+
return new $e(t);
|
|
3521
|
+
}), this.register(function(t) {
|
|
3522
|
+
return new Ke(t);
|
|
3432
3523
|
});
|
|
3433
3524
|
}
|
|
3434
3525
|
register(t) {
|
|
@@ -3441,7 +3532,7 @@ class et {
|
|
|
3441
3532
|
return this.textureUtils = t, this;
|
|
3442
3533
|
}
|
|
3443
3534
|
parse(t, e, n, s) {
|
|
3444
|
-
const i = new
|
|
3535
|
+
const i = new Ue(), r = [];
|
|
3445
3536
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
3446
3537
|
r.push(this.pluginCallbacks[o](i));
|
|
3447
3538
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
|
|
@@ -3453,7 +3544,7 @@ class et {
|
|
|
3453
3544
|
});
|
|
3454
3545
|
}
|
|
3455
3546
|
}
|
|
3456
|
-
const
|
|
3547
|
+
const b = {
|
|
3457
3548
|
POINTS: 0,
|
|
3458
3549
|
LINES: 1,
|
|
3459
3550
|
LINE_LOOP: 2,
|
|
@@ -3477,34 +3568,34 @@ const T = {
|
|
|
3477
3568
|
CLAMP_TO_EDGE: 33071,
|
|
3478
3569
|
MIRRORED_REPEAT: 33648,
|
|
3479
3570
|
REPEAT: 10497
|
|
3480
|
-
},
|
|
3481
|
-
U[
|
|
3482
|
-
U[
|
|
3483
|
-
U[
|
|
3484
|
-
U[
|
|
3485
|
-
U[
|
|
3486
|
-
U[
|
|
3487
|
-
U[
|
|
3488
|
-
U[
|
|
3489
|
-
U[
|
|
3490
|
-
const
|
|
3571
|
+
}, ot = "KHR_mesh_quantization", U = {};
|
|
3572
|
+
U[Wt] = b.NEAREST;
|
|
3573
|
+
U[Ht] = b.NEAREST_MIPMAP_NEAREST;
|
|
3574
|
+
U[Jt] = b.NEAREST_MIPMAP_LINEAR;
|
|
3575
|
+
U[$t] = b.LINEAR;
|
|
3576
|
+
U[Kt] = b.LINEAR_MIPMAP_NEAREST;
|
|
3577
|
+
U[Zt] = b.LINEAR_MIPMAP_LINEAR;
|
|
3578
|
+
U[Qt] = b.CLAMP_TO_EDGE;
|
|
3579
|
+
U[te] = b.REPEAT;
|
|
3580
|
+
U[ee] = b.MIRRORED_REPEAT;
|
|
3581
|
+
const St = {
|
|
3491
3582
|
scale: "scale",
|
|
3492
3583
|
position: "translation",
|
|
3493
3584
|
quaternion: "rotation",
|
|
3494
3585
|
morphTargetInfluences: "weights"
|
|
3495
|
-
},
|
|
3586
|
+
}, Ie = new Ut(), Dt = 12, Pe = 1179937895, Re = 2, Lt = 8, ve = 1313821514, Ce = 5130562;
|
|
3496
3587
|
function H(u, t) {
|
|
3497
3588
|
return u.length === t.length && u.every(function(e, n) {
|
|
3498
3589
|
return e === t[n];
|
|
3499
3590
|
});
|
|
3500
3591
|
}
|
|
3501
|
-
function
|
|
3592
|
+
function Ne(u) {
|
|
3502
3593
|
return new TextEncoder().encode(u).buffer;
|
|
3503
3594
|
}
|
|
3504
|
-
function
|
|
3595
|
+
function Be(u) {
|
|
3505
3596
|
return H(u.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
3506
3597
|
}
|
|
3507
|
-
function
|
|
3598
|
+
function Oe(u, t, e) {
|
|
3508
3599
|
const n = {
|
|
3509
3600
|
min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
3510
3601
|
max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
@@ -3512,15 +3603,15 @@ function ve(u, t, e) {
|
|
|
3512
3603
|
for (let s = t; s < t + e; s++)
|
|
3513
3604
|
for (let i = 0; i < u.itemSize; i++) {
|
|
3514
3605
|
let r;
|
|
3515
|
-
u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r =
|
|
3606
|
+
u.itemSize > 4 ? r = u.array[s * u.itemSize + i] : (i === 0 ? r = u.getX(s) : i === 1 ? r = u.getY(s) : i === 2 ? r = u.getZ(s) : i === 3 && (r = u.getW(s)), u.normalized === !0 && (r = lt.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
3516
3607
|
}
|
|
3517
3608
|
return n;
|
|
3518
3609
|
}
|
|
3519
|
-
function
|
|
3610
|
+
function Ct(u) {
|
|
3520
3611
|
return Math.ceil(u / 4) * 4;
|
|
3521
3612
|
}
|
|
3522
|
-
function
|
|
3523
|
-
const e =
|
|
3613
|
+
function at(u, t = 0) {
|
|
3614
|
+
const e = Ct(u.byteLength);
|
|
3524
3615
|
if (e !== u.byteLength) {
|
|
3525
3616
|
const n = new Uint8Array(e);
|
|
3526
3617
|
if (n.set(new Uint8Array(u)), t !== 0)
|
|
@@ -3530,10 +3621,10 @@ function rt(u, t = 0) {
|
|
|
3530
3621
|
}
|
|
3531
3622
|
return u;
|
|
3532
3623
|
}
|
|
3533
|
-
function
|
|
3624
|
+
function Et() {
|
|
3534
3625
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
3535
3626
|
}
|
|
3536
|
-
function
|
|
3627
|
+
function Fe(u, t) {
|
|
3537
3628
|
if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
|
|
3538
3629
|
let e;
|
|
3539
3630
|
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8), u.convertToBlob({
|
|
@@ -3543,7 +3634,7 @@ function Ne(u, t) {
|
|
|
3543
3634
|
} else
|
|
3544
3635
|
return new Promise((e) => u.toBlob(e, t));
|
|
3545
3636
|
}
|
|
3546
|
-
class
|
|
3637
|
+
class Ue {
|
|
3547
3638
|
constructor() {
|
|
3548
3639
|
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 = {
|
|
3549
3640
|
asset: {
|
|
@@ -3585,26 +3676,26 @@ class Ce {
|
|
|
3585
3676
|
const s = this, i = s.buffers, r = s.json;
|
|
3586
3677
|
n = s.options;
|
|
3587
3678
|
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
3588
|
-
l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ?
|
|
3589
|
-
const f =
|
|
3590
|
-
p.setUint32(0, f.byteLength, !0), p.setUint32(4,
|
|
3591
|
-
const y =
|
|
3592
|
-
x.setUint32(0, y.byteLength, !0), x.setUint32(4,
|
|
3593
|
-
const
|
|
3594
|
-
|
|
3595
|
-
const
|
|
3596
|
-
|
|
3597
|
-
const
|
|
3598
|
-
|
|
3679
|
+
l.length > 0 && (r.extensionsUsed = l), h.length > 0 && (r.extensionsRequired = h), r.buffers && r.buffers.length > 0 && (r.buffers[0].byteLength = c.size), n.binary === !0 ? ct(c).then(function(d) {
|
|
3680
|
+
const f = at(d), p = new DataView(new ArrayBuffer(Lt));
|
|
3681
|
+
p.setUint32(0, f.byteLength, !0), p.setUint32(4, Ce, !0);
|
|
3682
|
+
const y = at(Ne(JSON.stringify(r)), 32), x = new DataView(new ArrayBuffer(Lt));
|
|
3683
|
+
x.setUint32(0, y.byteLength, !0), x.setUint32(4, ve, !0);
|
|
3684
|
+
const g = new ArrayBuffer(Dt), w = new DataView(g);
|
|
3685
|
+
w.setUint32(0, Pe, !0), w.setUint32(4, Re, !0);
|
|
3686
|
+
const D = Dt + x.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
3687
|
+
w.setUint32(8, D, !0);
|
|
3688
|
+
const m = new Blob([
|
|
3689
|
+
g,
|
|
3599
3690
|
x,
|
|
3600
3691
|
y,
|
|
3601
3692
|
p,
|
|
3602
3693
|
f
|
|
3603
3694
|
], { type: "application/octet-stream" });
|
|
3604
|
-
|
|
3695
|
+
ct(m).then((S) => {
|
|
3605
3696
|
e(S);
|
|
3606
3697
|
});
|
|
3607
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
3698
|
+
}) : r.buffers && r.buffers.length > 0 ? Ze(c).then((d) => {
|
|
3608
3699
|
r.buffers[0].uri = d, e(r);
|
|
3609
3700
|
}) : e(r);
|
|
3610
3701
|
}
|
|
@@ -3652,7 +3743,7 @@ class Ce {
|
|
|
3652
3743
|
*/
|
|
3653
3744
|
isNormalizedNormalAttribute(t) {
|
|
3654
3745
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
3655
|
-
const n = new
|
|
3746
|
+
const n = new Q();
|
|
3656
3747
|
for (let s = 0, i = t.count; s < i; s++)
|
|
3657
3748
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
3658
3749
|
return !0;
|
|
@@ -3667,7 +3758,7 @@ class Ce {
|
|
|
3667
3758
|
createNormalizedNormalAttribute(t) {
|
|
3668
3759
|
const e = this.cache;
|
|
3669
3760
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
3670
|
-
const n = t.clone(), s = new
|
|
3761
|
+
const n = t.clone(), s = new Q();
|
|
3671
3762
|
for (let i = 0, r = n.count; i < r; i++)
|
|
3672
3763
|
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);
|
|
3673
3764
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -3687,14 +3778,14 @@ class Ce {
|
|
|
3687
3778
|
async buildMetalRoughTextureAsync(t, e) {
|
|
3688
3779
|
if (t === e) return t;
|
|
3689
3780
|
function n(f) {
|
|
3690
|
-
return f.colorSpace ===
|
|
3781
|
+
return f.colorSpace === Vt ? function(y) {
|
|
3691
3782
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
3692
3783
|
} : function(y) {
|
|
3693
3784
|
return y;
|
|
3694
3785
|
};
|
|
3695
3786
|
}
|
|
3696
|
-
t instanceof
|
|
3697
|
-
const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a =
|
|
3787
|
+
t instanceof rt && (t = await this.decompressTextureAsync(t)), e instanceof rt && (e = await this.decompressTextureAsync(e));
|
|
3788
|
+
const s = t ? t.image : null, i = e ? e.image : null, r = Math.max(s ? s.width : 0, i ? i.width : 0), o = Math.max(s ? s.height : 0, i ? i.height : 0), a = Et();
|
|
3698
3789
|
a.width = r, a.height = o;
|
|
3699
3790
|
const c = a.getContext("2d", {
|
|
3700
3791
|
willReadFrequently: !0
|
|
@@ -3715,7 +3806,7 @@ class Ce {
|
|
|
3715
3806
|
}
|
|
3716
3807
|
c.putImageData(l, 0, 0);
|
|
3717
3808
|
const d = (t || e).clone();
|
|
3718
|
-
return d.source = new
|
|
3809
|
+
return d.source = new zt(a), d.colorSpace = qt, d.channel = (t || e).channel, t && e && t.channel !== e.channel && console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."), console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."), d;
|
|
3719
3810
|
}
|
|
3720
3811
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
3721
3812
|
if (this.textureUtils === null)
|
|
@@ -3745,25 +3836,25 @@ class Ce {
|
|
|
3745
3836
|
r.bufferViews || (r.bufferViews = []);
|
|
3746
3837
|
let o;
|
|
3747
3838
|
switch (e) {
|
|
3748
|
-
case
|
|
3749
|
-
case
|
|
3839
|
+
case b.BYTE:
|
|
3840
|
+
case b.UNSIGNED_BYTE:
|
|
3750
3841
|
o = 1;
|
|
3751
3842
|
break;
|
|
3752
|
-
case
|
|
3753
|
-
case
|
|
3843
|
+
case b.SHORT:
|
|
3844
|
+
case b.UNSIGNED_SHORT:
|
|
3754
3845
|
o = 2;
|
|
3755
3846
|
break;
|
|
3756
3847
|
default:
|
|
3757
3848
|
o = 4;
|
|
3758
3849
|
}
|
|
3759
3850
|
let a = t.itemSize * o;
|
|
3760
|
-
i ===
|
|
3761
|
-
const c =
|
|
3851
|
+
i === b.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
|
|
3852
|
+
const c = Ct(s * a), l = new DataView(new ArrayBuffer(c));
|
|
3762
3853
|
let h = 0;
|
|
3763
3854
|
for (let p = n; p < n + s; p++) {
|
|
3764
3855
|
for (let y = 0; y < t.itemSize; y++) {
|
|
3765
3856
|
let x;
|
|
3766
|
-
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x =
|
|
3857
|
+
t.itemSize > 4 ? x = t.array[p * t.itemSize + y] : (y === 0 ? x = t.getX(p) : y === 1 ? x = t.getY(p) : y === 2 ? x = t.getZ(p) : y === 3 && (x = t.getW(p)), t.normalized === !0 && (x = lt.normalize(x, t.array))), e === b.FLOAT ? l.setFloat32(h, x, !0) : e === b.INT ? l.setInt32(h, x, !0) : e === b.UNSIGNED_INT ? l.setUint32(h, x, !0) : e === b.SHORT ? l.setInt16(h, x, !0) : e === b.UNSIGNED_SHORT ? l.setUint16(h, x, !0) : e === b.BYTE ? l.setInt8(h, x) : e === b.UNSIGNED_BYTE && l.setUint8(h, x), h += o;
|
|
3767
3858
|
}
|
|
3768
3859
|
h % a !== 0 && (h += a - h % a);
|
|
3769
3860
|
}
|
|
@@ -3772,7 +3863,7 @@ class Ce {
|
|
|
3772
3863
|
byteOffset: this.byteOffset,
|
|
3773
3864
|
byteLength: c
|
|
3774
3865
|
};
|
|
3775
|
-
return i !== void 0 && (d.target = i), i ===
|
|
3866
|
+
return i !== void 0 && (d.target = i), i === b.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
|
|
3776
3867
|
id: r.bufferViews.length - 1,
|
|
3777
3868
|
byteLength: 0
|
|
3778
3869
|
};
|
|
@@ -3785,8 +3876,8 @@ class Ce {
|
|
|
3785
3876
|
processBufferViewImage(t) {
|
|
3786
3877
|
const e = this, n = e.json;
|
|
3787
3878
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
3788
|
-
|
|
3789
|
-
const r =
|
|
3879
|
+
ct(t).then((i) => {
|
|
3880
|
+
const r = at(i), o = {
|
|
3790
3881
|
buffer: e.processBuffer(r),
|
|
3791
3882
|
byteOffset: e.byteOffset,
|
|
3792
3883
|
byteLength: r.byteLength
|
|
@@ -3814,25 +3905,25 @@ class Ce {
|
|
|
3814
3905
|
};
|
|
3815
3906
|
let o;
|
|
3816
3907
|
if (t.array.constructor === Float32Array)
|
|
3817
|
-
o =
|
|
3908
|
+
o = b.FLOAT;
|
|
3818
3909
|
else if (t.array.constructor === Int32Array)
|
|
3819
|
-
o =
|
|
3910
|
+
o = b.INT;
|
|
3820
3911
|
else if (t.array.constructor === Uint32Array)
|
|
3821
|
-
o =
|
|
3912
|
+
o = b.UNSIGNED_INT;
|
|
3822
3913
|
else if (t.array.constructor === Int16Array)
|
|
3823
|
-
o =
|
|
3914
|
+
o = b.SHORT;
|
|
3824
3915
|
else if (t.array.constructor === Uint16Array)
|
|
3825
|
-
o =
|
|
3916
|
+
o = b.UNSIGNED_SHORT;
|
|
3826
3917
|
else if (t.array.constructor === Int8Array)
|
|
3827
|
-
o =
|
|
3918
|
+
o = b.BYTE;
|
|
3828
3919
|
else if (t.array.constructor === Uint8Array)
|
|
3829
|
-
o =
|
|
3920
|
+
o = b.UNSIGNED_BYTE;
|
|
3830
3921
|
else
|
|
3831
3922
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
3832
3923
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
3833
|
-
const a =
|
|
3924
|
+
const a = Oe(t, n, s);
|
|
3834
3925
|
let c;
|
|
3835
|
-
e !== void 0 && (c = t === e.index ?
|
|
3926
|
+
e !== void 0 && (c = t === e.index ? b.ELEMENT_ARRAY_BUFFER : b.ARRAY_BUFFER);
|
|
3836
3927
|
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
3837
3928
|
bufferView: l.id,
|
|
3838
3929
|
byteOffset: l.byteOffset,
|
|
@@ -3859,26 +3950,26 @@ class Ce {
|
|
|
3859
3950
|
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
3860
3951
|
if (l[h] !== void 0) return l[h];
|
|
3861
3952
|
o.images || (o.images = []);
|
|
3862
|
-
const d = { mimeType: s }, f =
|
|
3953
|
+
const d = { mimeType: s }, f = Et();
|
|
3863
3954
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
3864
3955
|
const p = f.getContext("2d", {
|
|
3865
3956
|
willReadFrequently: !0
|
|
3866
3957
|
});
|
|
3867
3958
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
3868
|
-
e !==
|
|
3959
|
+
e !== _t && console.error("GLTFExporter: Only RGBAFormat is supported.", e), (t.width > a.maxTextureSize || t.height > a.maxTextureSize) && console.warn("GLTFExporter: Image size is bigger than maxTextureSize", t);
|
|
3869
3960
|
const x = new Uint8ClampedArray(t.height * t.width * 4);
|
|
3870
|
-
for (let
|
|
3871
|
-
x[
|
|
3961
|
+
for (let g = 0; g < x.length; g += 4)
|
|
3962
|
+
x[g + 0] = t.data[g + 0], x[g + 1] = t.data[g + 1], x[g + 2] = t.data[g + 2], x[g + 3] = t.data[g + 3];
|
|
3872
3963
|
p.putImageData(new ImageData(x, t.width, t.height), 0, 0);
|
|
3873
3964
|
} else if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas)
|
|
3874
3965
|
p.drawImage(t, 0, 0, f.width, f.height);
|
|
3875
3966
|
else
|
|
3876
3967
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
3877
3968
|
a.binary === !0 ? c.push(
|
|
3878
|
-
|
|
3969
|
+
Fe(f, s).then((x) => i.processBufferViewImage(x)).then((x) => {
|
|
3879
3970
|
d.bufferView = x;
|
|
3880
3971
|
})
|
|
3881
|
-
) : d.uri =
|
|
3972
|
+
) : d.uri = Yt.getDataURL(f, s);
|
|
3882
3973
|
const y = o.images.push(d) - 1;
|
|
3883
3974
|
return l[h] = y, y;
|
|
3884
3975
|
} else
|
|
@@ -3908,7 +3999,7 @@ class Ce {
|
|
|
3908
3999
|
async processTextureAsync(t) {
|
|
3909
4000
|
const n = this.options, s = this.cache, i = this.json;
|
|
3910
4001
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
3911
|
-
i.textures || (i.textures = []), t instanceof
|
|
4002
|
+
i.textures || (i.textures = []), t instanceof rt && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
3912
4003
|
let r = t.userData.mimeType;
|
|
3913
4004
|
r === "image/webp" && (r = "image/png");
|
|
3914
4005
|
const o = {
|
|
@@ -3973,7 +4064,7 @@ class Ce {
|
|
|
3973
4064
|
};
|
|
3974
4065
|
t.aoMapIntensity !== 1 && (o.strength = t.aoMapIntensity), this.applyTextureTransform(o, t.aoMap), s.occlusionTexture = o;
|
|
3975
4066
|
}
|
|
3976
|
-
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side ===
|
|
4067
|
+
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === kt && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
|
|
3977
4068
|
o.writeMaterialAsync && await o.writeMaterialAsync(t, s);
|
|
3978
4069
|
});
|
|
3979
4070
|
const r = n.materials.push(s) - 1;
|
|
@@ -3987,15 +4078,15 @@ class Ce {
|
|
|
3987
4078
|
async processMeshAsync(t) {
|
|
3988
4079
|
const e = this.cache, n = this.json, s = [t.geometry.uuid];
|
|
3989
4080
|
if (Array.isArray(t.material))
|
|
3990
|
-
for (let
|
|
3991
|
-
s.push(t.material[
|
|
4081
|
+
for (let m = 0, S = t.material.length; m < S; m++)
|
|
4082
|
+
s.push(t.material[m].uuid);
|
|
3992
4083
|
else
|
|
3993
4084
|
s.push(t.material.uuid);
|
|
3994
4085
|
const i = s.join(":");
|
|
3995
4086
|
if (e.meshes.has(i)) return e.meshes.get(i);
|
|
3996
4087
|
const r = t.geometry;
|
|
3997
4088
|
let o;
|
|
3998
|
-
t.isLineSegments ? o =
|
|
4089
|
+
t.isLineSegments ? o = b.LINES : t.isLineLoop ? o = b.LINE_LOOP : t.isLine ? o = b.LINE_STRIP : t.isPoints ? o = b.POINTS : o = t.material.wireframe ? b.LINES : b.TRIANGLES;
|
|
3999
4090
|
const a = {}, c = {}, l = [], h = [], d = {
|
|
4000
4091
|
uv: "TEXCOORD_0",
|
|
4001
4092
|
uv1: "TEXCOORD_1",
|
|
@@ -4007,76 +4098,76 @@ class Ce {
|
|
|
4007
4098
|
}, f = r.getAttribute("normal");
|
|
4008
4099
|
f !== void 0 && !this.isNormalizedNormalAttribute(f) && (console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."), r.setAttribute("normal", this.createNormalizedNormalAttribute(f)));
|
|
4009
4100
|
let p = null;
|
|
4010
|
-
for (let
|
|
4011
|
-
if (
|
|
4012
|
-
const S = r.attributes[
|
|
4013
|
-
if (
|
|
4014
|
-
c[
|
|
4101
|
+
for (let m in r.attributes) {
|
|
4102
|
+
if (m.slice(0, 5) === "morph") continue;
|
|
4103
|
+
const S = r.attributes[m];
|
|
4104
|
+
if (m = d[m] || m.toUpperCase(), /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(m) || (m = "_" + m), e.attributes.has(this.getUID(S))) {
|
|
4105
|
+
c[m] = e.attributes.get(this.getUID(S));
|
|
4015
4106
|
continue;
|
|
4016
4107
|
}
|
|
4017
4108
|
p = null;
|
|
4018
|
-
const
|
|
4019
|
-
|
|
4020
|
-
const
|
|
4021
|
-
|
|
4109
|
+
const E = S.array;
|
|
4110
|
+
m === "JOINTS_0" && !(E instanceof Uint16Array) && !(E instanceof Uint8Array) ? (console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'), p = new _(new Uint16Array(E), S.itemSize, S.normalized)) : (E instanceof Uint32Array || E instanceof Int32Array) && !m.startsWith("_") && (console.warn(`GLTFExporter: Attribute "${m}" converted to type FLOAT.`), p = st.Utils.toFloat32BufferAttribute(S));
|
|
4111
|
+
const A = this.processAccessor(p || S, r);
|
|
4112
|
+
A !== null && (m.startsWith("_") || this.detectMeshQuantization(m, S), c[m] = A, e.attributes.set(this.getUID(S), A));
|
|
4022
4113
|
}
|
|
4023
4114
|
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
4024
4115
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
4025
|
-
const
|
|
4116
|
+
const m = [], S = [], T = {};
|
|
4026
4117
|
if (t.morphTargetDictionary !== void 0)
|
|
4027
|
-
for (const
|
|
4028
|
-
|
|
4029
|
-
for (let
|
|
4030
|
-
const
|
|
4031
|
-
let
|
|
4032
|
-
for (const
|
|
4033
|
-
if (
|
|
4034
|
-
|
|
4118
|
+
for (const E in t.morphTargetDictionary)
|
|
4119
|
+
T[t.morphTargetDictionary[E]] = E;
|
|
4120
|
+
for (let E = 0; E < t.morphTargetInfluences.length; ++E) {
|
|
4121
|
+
const A = {};
|
|
4122
|
+
let v = !1;
|
|
4123
|
+
for (const C in r.morphAttributes) {
|
|
4124
|
+
if (C !== "position" && C !== "normal") {
|
|
4125
|
+
v || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), v = !0);
|
|
4035
4126
|
continue;
|
|
4036
4127
|
}
|
|
4037
|
-
const
|
|
4038
|
-
if (e.attributes.has(this.getUID(
|
|
4039
|
-
|
|
4128
|
+
const F = r.morphAttributes[C][E], N = C.toUpperCase(), j = r.attributes[C];
|
|
4129
|
+
if (e.attributes.has(this.getUID(F, !0))) {
|
|
4130
|
+
A[N] = e.attributes.get(this.getUID(F, !0));
|
|
4040
4131
|
continue;
|
|
4041
4132
|
}
|
|
4042
|
-
const O =
|
|
4133
|
+
const O = F.clone();
|
|
4043
4134
|
if (!r.morphTargetsRelative)
|
|
4044
|
-
for (let
|
|
4045
|
-
for (let
|
|
4046
|
-
|
|
4047
|
-
|
|
4135
|
+
for (let R = 0, V = F.count; R < V; R++)
|
|
4136
|
+
for (let G = 0; G < F.itemSize; G++)
|
|
4137
|
+
G === 0 && O.setX(R, F.getX(R) - j.getX(R)), G === 1 && O.setY(R, F.getY(R) - j.getY(R)), G === 2 && O.setZ(R, F.getZ(R) - j.getZ(R)), G === 3 && O.setW(R, F.getW(R) - j.getW(R));
|
|
4138
|
+
A[N] = this.processAccessor(O, r), e.attributes.set(this.getUID(j, !0), A[N]);
|
|
4048
4139
|
}
|
|
4049
|
-
h.push(
|
|
4140
|
+
h.push(A), m.push(t.morphTargetInfluences[E]), t.morphTargetDictionary !== void 0 && S.push(T[E]);
|
|
4050
4141
|
}
|
|
4051
|
-
a.weights =
|
|
4142
|
+
a.weights = m, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
4052
4143
|
}
|
|
4053
4144
|
const y = Array.isArray(t.material);
|
|
4054
4145
|
if (y && r.groups.length === 0) return null;
|
|
4055
4146
|
let x = !1;
|
|
4056
4147
|
if (y && r.index === null) {
|
|
4057
|
-
const
|
|
4058
|
-
for (let S = 0,
|
|
4059
|
-
|
|
4060
|
-
r.setIndex(
|
|
4148
|
+
const m = [];
|
|
4149
|
+
for (let S = 0, T = r.attributes.position.count; S < T; S++)
|
|
4150
|
+
m[S] = S;
|
|
4151
|
+
r.setIndex(m), x = !0;
|
|
4061
4152
|
}
|
|
4062
|
-
const
|
|
4063
|
-
for (let
|
|
4064
|
-
const
|
|
4153
|
+
const g = y ? t.material : [t.material], w = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
4154
|
+
for (let m = 0, S = w.length; m < S; m++) {
|
|
4155
|
+
const T = {
|
|
4065
4156
|
mode: o,
|
|
4066
4157
|
attributes: c
|
|
4067
4158
|
};
|
|
4068
|
-
if (this.serializeUserData(r,
|
|
4069
|
-
let
|
|
4070
|
-
(
|
|
4159
|
+
if (this.serializeUserData(r, T), h.length > 0 && (T.targets = h), r.index !== null) {
|
|
4160
|
+
let A = this.getUID(r.index);
|
|
4161
|
+
(w[m].start !== void 0 || w[m].count !== void 0) && (A += ":" + w[m].start + ":" + w[m].count), e.attributes.has(A) ? T.indices = e.attributes.get(A) : (T.indices = this.processAccessor(r.index, r, w[m].start, w[m].count), e.attributes.set(A, T.indices)), T.indices === null && delete T.indices;
|
|
4071
4162
|
}
|
|
4072
|
-
const
|
|
4073
|
-
|
|
4163
|
+
const E = await this.processMaterialAsync(g[w[m].materialIndex]);
|
|
4164
|
+
E !== null && (T.material = E), l.push(T);
|
|
4074
4165
|
}
|
|
4075
|
-
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(
|
|
4076
|
-
|
|
4166
|
+
x === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(m) {
|
|
4167
|
+
m.writeMesh && m.writeMesh(t, a);
|
|
4077
4168
|
});
|
|
4078
|
-
const
|
|
4079
|
-
return e.meshes.set(i,
|
|
4169
|
+
const D = n.meshes.push(a) - 1;
|
|
4170
|
+
return e.meshes.set(i, D), D;
|
|
4080
4171
|
}
|
|
4081
4172
|
/**
|
|
4082
4173
|
* If a vertex attribute with a
|
|
@@ -4090,7 +4181,7 @@ class Ce {
|
|
|
4090
4181
|
* @param {THREE.BufferAttribute} attribute
|
|
4091
4182
|
*/
|
|
4092
4183
|
detectMeshQuantization(t, e) {
|
|
4093
|
-
if (this.extensionsUsed[
|
|
4184
|
+
if (this.extensionsUsed[ot]) return;
|
|
4094
4185
|
let n;
|
|
4095
4186
|
switch (e.array.constructor) {
|
|
4096
4187
|
case Int8Array:
|
|
@@ -4110,7 +4201,7 @@ class Ce {
|
|
|
4110
4201
|
}
|
|
4111
4202
|
e.normalized && (n += " normalized");
|
|
4112
4203
|
const s = t.split("_", 1)[0];
|
|
4113
|
-
|
|
4204
|
+
Mt[s] && Mt[s].includes(n) && (this.extensionsUsed[ot] = !0, this.extensionsRequired[ot] = !0);
|
|
4114
4205
|
}
|
|
4115
4206
|
/**
|
|
4116
4207
|
* Process camera
|
|
@@ -4130,7 +4221,7 @@ class Ce {
|
|
|
4130
4221
|
znear: t.near < 0 ? 0 : t.near
|
|
4131
4222
|
} : s.perspective = {
|
|
4132
4223
|
aspectRatio: t.aspect,
|
|
4133
|
-
yfov:
|
|
4224
|
+
yfov: lt.degToRad(t.fov),
|
|
4134
4225
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4135
4226
|
znear: t.near < 0 ? 0 : t.near
|
|
4136
4227
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4147,23 +4238,23 @@ class Ce {
|
|
|
4147
4238
|
*/
|
|
4148
4239
|
processAnimation(t, e) {
|
|
4149
4240
|
const n = this.json, s = this.nodeMap;
|
|
4150
|
-
n.animations || (n.animations = []), t =
|
|
4241
|
+
n.animations || (n.animations = []), t = st.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4151
4242
|
const i = t.tracks, r = [], o = [];
|
|
4152
4243
|
for (let c = 0; c < i.length; ++c) {
|
|
4153
|
-
const l = i[c], h =
|
|
4154
|
-
let d =
|
|
4155
|
-
const f =
|
|
4244
|
+
const l = i[c], h = tt.parseTrackName(l.name);
|
|
4245
|
+
let d = tt.findNode(e, h.nodeName);
|
|
4246
|
+
const f = St[h.propertyName];
|
|
4156
4247
|
if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !f) {
|
|
4157
4248
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4158
4249
|
continue;
|
|
4159
4250
|
}
|
|
4160
4251
|
const p = 1;
|
|
4161
4252
|
let y = l.values.length / l.times.length;
|
|
4162
|
-
f ===
|
|
4253
|
+
f === St.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
|
|
4163
4254
|
let x;
|
|
4164
|
-
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() ===
|
|
4165
|
-
input: this.processAccessor(new
|
|
4166
|
-
output: this.processAccessor(new
|
|
4255
|
+
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (x = "CUBICSPLINE", y /= 3) : l.getInterpolation() === Xt ? x = "STEP" : x = "LINEAR", o.push({
|
|
4256
|
+
input: this.processAccessor(new _(l.times, p)),
|
|
4257
|
+
output: this.processAccessor(new _(l.values, y)),
|
|
4167
4258
|
interpolation: x
|
|
4168
4259
|
}), r.push({
|
|
4169
4260
|
sampler: o.length - 1,
|
|
@@ -4189,11 +4280,11 @@ class Ce {
|
|
|
4189
4280
|
if (i === void 0) return null;
|
|
4190
4281
|
const r = t.skeleton.bones[0];
|
|
4191
4282
|
if (r === void 0) return null;
|
|
4192
|
-
const o = [], a = new Float32Array(i.bones.length * 16), c = new
|
|
4283
|
+
const o = [], a = new Float32Array(i.bones.length * 16), c = new Tt();
|
|
4193
4284
|
for (let h = 0; h < i.bones.length; ++h)
|
|
4194
4285
|
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4195
4286
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
4196
|
-
inverseBindMatrices: this.processAccessor(new
|
|
4287
|
+
inverseBindMatrices: this.processAccessor(new _(a, 16)),
|
|
4197
4288
|
joints: o,
|
|
4198
4289
|
skeleton: n.get(r)
|
|
4199
4290
|
}), s.skin = e.skins.length - 1;
|
|
@@ -4211,7 +4302,7 @@ class Ce {
|
|
|
4211
4302
|
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4212
4303
|
H(o, [0, 0, 0, 1]) || (i.rotation = o), H(a, [0, 0, 0]) || (i.translation = a), H(c, [1, 1, 1]) || (i.scale = c);
|
|
4213
4304
|
} else
|
|
4214
|
-
t.matrixAutoUpdate && t.updateMatrix(),
|
|
4305
|
+
t.matrixAutoUpdate && t.updateMatrix(), Be(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4215
4306
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
4216
4307
|
const o = await this.processMeshAsync(t);
|
|
4217
4308
|
o !== null && (i.mesh = o);
|
|
@@ -4288,7 +4379,7 @@ class Ce {
|
|
|
4288
4379
|
await t(this.plugins[e]);
|
|
4289
4380
|
}
|
|
4290
4381
|
}
|
|
4291
|
-
class
|
|
4382
|
+
class je {
|
|
4292
4383
|
constructor(t) {
|
|
4293
4384
|
this.writer = t, this.name = "KHR_lights_punctual";
|
|
4294
4385
|
}
|
|
@@ -4304,7 +4395,7 @@ class Be {
|
|
|
4304
4395
|
o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
|
|
4305
4396
|
}
|
|
4306
4397
|
}
|
|
4307
|
-
class
|
|
4398
|
+
class Ge {
|
|
4308
4399
|
constructor(t) {
|
|
4309
4400
|
this.writer = t, this.name = "KHR_materials_unlit";
|
|
4310
4401
|
}
|
|
@@ -4314,7 +4405,7 @@ class Oe {
|
|
|
4314
4405
|
e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
4315
4406
|
}
|
|
4316
4407
|
}
|
|
4317
|
-
class
|
|
4408
|
+
class ze {
|
|
4318
4409
|
constructor(t) {
|
|
4319
4410
|
this.writer = t, this.name = "KHR_materials_clearcoat";
|
|
4320
4411
|
}
|
|
@@ -4345,7 +4436,7 @@ class Fe {
|
|
|
4345
4436
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4346
4437
|
}
|
|
4347
4438
|
}
|
|
4348
|
-
class
|
|
4439
|
+
class qe {
|
|
4349
4440
|
constructor(t) {
|
|
4350
4441
|
this.writer = t, this.name = "KHR_materials_dispersion";
|
|
4351
4442
|
}
|
|
@@ -4355,7 +4446,7 @@ class Ue {
|
|
|
4355
4446
|
i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4356
4447
|
}
|
|
4357
4448
|
}
|
|
4358
|
-
class
|
|
4449
|
+
class _e {
|
|
4359
4450
|
constructor(t) {
|
|
4360
4451
|
this.writer = t, this.name = "KHR_materials_iridescence";
|
|
4361
4452
|
}
|
|
@@ -4379,7 +4470,7 @@ class Ge {
|
|
|
4379
4470
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4380
4471
|
}
|
|
4381
4472
|
}
|
|
4382
|
-
class
|
|
4473
|
+
class Ye {
|
|
4383
4474
|
constructor(t) {
|
|
4384
4475
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4385
4476
|
}
|
|
@@ -4396,7 +4487,7 @@ class je {
|
|
|
4396
4487
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4397
4488
|
}
|
|
4398
4489
|
}
|
|
4399
|
-
class
|
|
4490
|
+
class ke {
|
|
4400
4491
|
constructor(t) {
|
|
4401
4492
|
this.writer = t, this.name = "KHR_materials_volume";
|
|
4402
4493
|
}
|
|
@@ -4413,7 +4504,7 @@ class ze {
|
|
|
4413
4504
|
t.attenuationDistance !== 1 / 0 && (i.attenuationDistance = t.attenuationDistance), i.attenuationColor = t.attenuationColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4414
4505
|
}
|
|
4415
4506
|
}
|
|
4416
|
-
class
|
|
4507
|
+
class Xe {
|
|
4417
4508
|
constructor(t) {
|
|
4418
4509
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
4419
4510
|
}
|
|
@@ -4423,12 +4514,12 @@ class qe {
|
|
|
4423
4514
|
i.ior = t.ior, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4424
4515
|
}
|
|
4425
4516
|
}
|
|
4426
|
-
class
|
|
4517
|
+
class Ve {
|
|
4427
4518
|
constructor(t) {
|
|
4428
4519
|
this.writer = t, this.name = "KHR_materials_specular";
|
|
4429
4520
|
}
|
|
4430
4521
|
async writeMaterialAsync(t, e) {
|
|
4431
|
-
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(
|
|
4522
|
+
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(Ie) && !t.specularIntensityMap && !t.specularColorMap) return;
|
|
4432
4523
|
const n = this.writer, s = n.extensionsUsed, i = {};
|
|
4433
4524
|
if (t.specularIntensityMap) {
|
|
4434
4525
|
const r = {
|
|
@@ -4447,7 +4538,7 @@ class _e {
|
|
|
4447
4538
|
i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4448
4539
|
}
|
|
4449
4540
|
}
|
|
4450
|
-
class
|
|
4541
|
+
class We {
|
|
4451
4542
|
constructor(t) {
|
|
4452
4543
|
this.writer = t, this.name = "KHR_materials_sheen";
|
|
4453
4544
|
}
|
|
@@ -4471,7 +4562,7 @@ class Ye {
|
|
|
4471
4562
|
i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4472
4563
|
}
|
|
4473
4564
|
}
|
|
4474
|
-
class
|
|
4565
|
+
class He {
|
|
4475
4566
|
constructor(t) {
|
|
4476
4567
|
this.writer = t, this.name = "KHR_materials_anisotropy";
|
|
4477
4568
|
}
|
|
@@ -4485,7 +4576,7 @@ class ke {
|
|
|
4485
4576
|
i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4486
4577
|
}
|
|
4487
4578
|
}
|
|
4488
|
-
class
|
|
4579
|
+
class Je {
|
|
4489
4580
|
constructor(t) {
|
|
4490
4581
|
this.writer = t, this.name = "KHR_materials_emissive_strength";
|
|
4491
4582
|
}
|
|
@@ -4495,7 +4586,7 @@ class Xe {
|
|
|
4495
4586
|
i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4496
4587
|
}
|
|
4497
4588
|
}
|
|
4498
|
-
class
|
|
4589
|
+
class $e {
|
|
4499
4590
|
constructor(t) {
|
|
4500
4591
|
this.writer = t, this.name = "EXT_materials_bump";
|
|
4501
4592
|
}
|
|
@@ -4512,24 +4603,24 @@ class Ve {
|
|
|
4512
4603
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4513
4604
|
}
|
|
4514
4605
|
}
|
|
4515
|
-
class
|
|
4606
|
+
class Ke {
|
|
4516
4607
|
constructor(t) {
|
|
4517
4608
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
4518
4609
|
}
|
|
4519
4610
|
writeNode(t, e) {
|
|
4520
4611
|
if (!t.isInstancedMesh) return;
|
|
4521
|
-
const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new
|
|
4612
|
+
const n = this.writer, s = t, i = new Float32Array(s.count * 3), r = new Float32Array(s.count * 4), o = new Float32Array(s.count * 3), a = new Tt(), c = new Q(), l = new jt(), h = new Q();
|
|
4522
4613
|
for (let f = 0; f < s.count; f++)
|
|
4523
4614
|
s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
|
|
4524
4615
|
const d = {
|
|
4525
|
-
TRANSLATION: n.processAccessor(new
|
|
4526
|
-
ROTATION: n.processAccessor(new
|
|
4527
|
-
SCALE: n.processAccessor(new
|
|
4616
|
+
TRANSLATION: n.processAccessor(new _(i, 3)),
|
|
4617
|
+
ROTATION: n.processAccessor(new _(r, 4)),
|
|
4618
|
+
SCALE: n.processAccessor(new _(o, 3))
|
|
4528
4619
|
};
|
|
4529
4620
|
s.instanceColor && (d._COLOR_0 = n.processAccessor(s.instanceColor)), e.extensions = e.extensions || {}, e.extensions[this.name] = { attributes: d }, n.extensionsUsed[this.name] = !0, n.extensionsRequired[this.name] = !0;
|
|
4530
4621
|
}
|
|
4531
4622
|
}
|
|
4532
|
-
|
|
4623
|
+
st.Utils = {
|
|
4533
4624
|
insertKeyframe: function(u, t) {
|
|
4534
4625
|
const n = u.getValueSize(), s = new u.TimeBufferType(u.times.length + 1), i = new u.ValueBufferType(u.values.length + n), r = u.createInterpolant(new u.ValueBufferType(n));
|
|
4535
4626
|
let o;
|
|
@@ -4559,7 +4650,7 @@ et.Utils = {
|
|
|
4559
4650
|
const e = [], n = {}, s = u.tracks;
|
|
4560
4651
|
for (let i = 0; i < s.length; ++i) {
|
|
4561
4652
|
let r = s[i];
|
|
4562
|
-
const o =
|
|
4653
|
+
const o = tt.parseTrackName(r.name), a = tt.findNode(t, o.nodeName);
|
|
4563
4654
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
4564
4655
|
e.push(r);
|
|
4565
4656
|
continue;
|
|
@@ -4567,7 +4658,7 @@ et.Utils = {
|
|
|
4567
4658
|
if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
|
|
4568
4659
|
if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
4569
4660
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
4570
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(
|
|
4661
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(ne);
|
|
4571
4662
|
}
|
|
4572
4663
|
const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
|
|
4573
4664
|
if (l === void 0)
|
|
@@ -4593,7 +4684,7 @@ et.Utils = {
|
|
|
4593
4684
|
return u.tracks = e, u;
|
|
4594
4685
|
},
|
|
4595
4686
|
toFloat32BufferAttribute: function(u) {
|
|
4596
|
-
const t = new
|
|
4687
|
+
const t = new _(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
|
|
4597
4688
|
if (!u.normalized && !u.isInterleavedBufferAttribute)
|
|
4598
4689
|
return t.array.set(u.array), t;
|
|
4599
4690
|
for (let e = 0, n = u.count; e < n; e++)
|
|
@@ -4602,7 +4693,7 @@ et.Utils = {
|
|
|
4602
4693
|
return t;
|
|
4603
4694
|
}
|
|
4604
4695
|
};
|
|
4605
|
-
async function
|
|
4696
|
+
async function Ze(u) {
|
|
4606
4697
|
if (typeof FileReader > "u") {
|
|
4607
4698
|
const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
|
|
4608
4699
|
return `data:${u.type};base64,${n}`;
|
|
@@ -4612,7 +4703,7 @@ async function He(u) {
|
|
|
4612
4703
|
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(u);
|
|
4613
4704
|
});
|
|
4614
4705
|
}
|
|
4615
|
-
async function
|
|
4706
|
+
async function ct(u) {
|
|
4616
4707
|
if (typeof u.arrayBuffer == "function")
|
|
4617
4708
|
return await u.arrayBuffer();
|
|
4618
4709
|
if (typeof FileReader < "u")
|
|
@@ -4625,8 +4716,8 @@ async function ot(u) {
|
|
|
4625
4716
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
4626
4717
|
}
|
|
4627
4718
|
}
|
|
4628
|
-
const
|
|
4629
|
-
function
|
|
4719
|
+
const Qe = new se(), tn = new st();
|
|
4720
|
+
function en(u, t, e = 0.1) {
|
|
4630
4721
|
const n = t.normal(u), s = t.direction(u).mutiplyScalar(e * 0.5), i = u.direction(t).mutiplyScalar(e * 0.5), r = n.x * e * 0.5, o = n.y * e * 0.5;
|
|
4631
4722
|
return {
|
|
4632
4723
|
points: [
|
|
@@ -4641,7 +4732,7 @@ function Ke(u, t, e = 0.1) {
|
|
|
4641
4732
|
rectIndices: [0, 1, 3, 2, 0]
|
|
4642
4733
|
};
|
|
4643
4734
|
}
|
|
4644
|
-
class Nt extends
|
|
4735
|
+
class Nt extends z {
|
|
4645
4736
|
static name = "WhiteModel";
|
|
4646
4737
|
Dxf = null;
|
|
4647
4738
|
Variable = null;
|
|
@@ -4671,7 +4762,7 @@ class Nt extends _ {
|
|
|
4671
4762
|
new I.LineSegments(new I.EdgesGeometry(i), new I.LineBasicMaterial({ color: 0 }))
|
|
4672
4763
|
);
|
|
4673
4764
|
}), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
4674
|
-
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } =
|
|
4765
|
+
const r = new M(n.x, n.y).mutiplyScalar(t.scale), o = new M(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = en(r, o, t.width);
|
|
4675
4766
|
return {
|
|
4676
4767
|
points: a,
|
|
4677
4768
|
indices: c,
|
|
@@ -4704,7 +4795,7 @@ class Nt extends _ {
|
|
|
4704
4795
|
toOBJ() {
|
|
4705
4796
|
return new Promise((t) => {
|
|
4706
4797
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
4707
|
-
t(
|
|
4798
|
+
t(Qe.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4708
4799
|
}, 20);
|
|
4709
4800
|
});
|
|
4710
4801
|
}
|
|
@@ -4716,7 +4807,7 @@ class Nt extends _ {
|
|
|
4716
4807
|
toGltf(t = !0) {
|
|
4717
4808
|
return new Promise((e) => {
|
|
4718
4809
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
4719
|
-
|
|
4810
|
+
tn.parse(this.whiteModelGroup.children, (n) => {
|
|
4720
4811
|
e(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
4721
4812
|
}, () => {
|
|
4722
4813
|
e(void 0);
|
|
@@ -4757,7 +4848,7 @@ class Nt extends _ {
|
|
|
4757
4848
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
4758
4849
|
} else if (typeof global < "u") {
|
|
4759
4850
|
const e = await this.toOBJ();
|
|
4760
|
-
e && (await
|
|
4851
|
+
e && (await X("fs", !1)).writeFileSync(t, e);
|
|
4761
4852
|
}
|
|
4762
4853
|
}
|
|
4763
4854
|
/**
|
|
@@ -4773,11 +4864,11 @@ class Nt extends _ {
|
|
|
4773
4864
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
4774
4865
|
} else if (typeof global < "u") {
|
|
4775
4866
|
const n = await this.toGltf(e);
|
|
4776
|
-
n && (await
|
|
4867
|
+
n && (await X("fs", !1)).writeFileSync(t, e ? Buffer.from(n) : JSON.stringify(n));
|
|
4777
4868
|
}
|
|
4778
4869
|
}
|
|
4779
4870
|
}
|
|
4780
|
-
class
|
|
4871
|
+
class Bt extends z {
|
|
4781
4872
|
static name = "DetailsPoint";
|
|
4782
4873
|
Dxf = null;
|
|
4783
4874
|
WhiteModel = null;
|
|
@@ -4854,7 +4945,7 @@ class Ct extends _ {
|
|
|
4854
4945
|
}, 50);
|
|
4855
4946
|
}
|
|
4856
4947
|
}
|
|
4857
|
-
class
|
|
4948
|
+
class Ot extends z {
|
|
4858
4949
|
static name = "DxfLineModel";
|
|
4859
4950
|
dxfLineModel = new I.LineSegments();
|
|
4860
4951
|
dxfDoorsLineModel = new I.LineSegments();
|
|
@@ -4877,38 +4968,38 @@ class Bt extends _ {
|
|
|
4877
4968
|
});
|
|
4878
4969
|
}
|
|
4879
4970
|
}
|
|
4880
|
-
const
|
|
4971
|
+
const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4881
4972
|
__proto__: null,
|
|
4882
|
-
DetailsPoint:
|
|
4883
|
-
DxfLineModel:
|
|
4973
|
+
DetailsPoint: Bt,
|
|
4974
|
+
DxfLineModel: Ot,
|
|
4884
4975
|
WhiteModel: Nt
|
|
4885
4976
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4886
|
-
function
|
|
4977
|
+
function At(u, t = {}) {
|
|
4887
4978
|
const {
|
|
4888
4979
|
detailsPoint: e = !0,
|
|
4889
4980
|
whiteModel: n = !0,
|
|
4890
4981
|
dxfLineModel: s = !0
|
|
4891
4982
|
} = t;
|
|
4892
|
-
s && u.addComponent(new
|
|
4983
|
+
s && u.addComponent(new Ot()), n && u.addComponent(new Nt()), e && u.addComponent(new Bt());
|
|
4893
4984
|
}
|
|
4894
|
-
const
|
|
4985
|
+
const sn = Object.assign(At, {
|
|
4895
4986
|
create(u = {}) {
|
|
4896
|
-
return (t) =>
|
|
4987
|
+
return (t) => At(t, u);
|
|
4897
4988
|
}
|
|
4898
|
-
}),
|
|
4989
|
+
}), rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4899
4990
|
__proto__: null,
|
|
4900
|
-
ModelDataPlugin:
|
|
4901
|
-
components:
|
|
4991
|
+
ModelDataPlugin: sn,
|
|
4992
|
+
components: nn
|
|
4902
4993
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4903
|
-
function
|
|
4994
|
+
function on() {
|
|
4904
4995
|
return import("./index2.js");
|
|
4905
4996
|
}
|
|
4906
|
-
function
|
|
4997
|
+
function an() {
|
|
4907
4998
|
return import("./index3.js");
|
|
4908
4999
|
}
|
|
4909
5000
|
let dt = null;
|
|
4910
|
-
async function
|
|
4911
|
-
const s = await Promise.resolve().then(() =>
|
|
5001
|
+
async function pn(u, t, e = !1, n) {
|
|
5002
|
+
const s = await Promise.resolve().then(() => rn), i = await on(), r = await an(), o = new $().usePlugin(s.ModelDataPlugin.create({
|
|
4912
5003
|
detailsPoint: !1,
|
|
4913
5004
|
whiteModel: !0
|
|
4914
5005
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -4920,10 +5011,10 @@ async function hn(u, t, e = !1, n) {
|
|
|
4920
5011
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
4921
5012
|
return a && u.appendChild(a.domElement), dt = o, {
|
|
4922
5013
|
dxfSystem: o,
|
|
4923
|
-
getFileAll: () =>
|
|
5014
|
+
getFileAll: () => cn(o)
|
|
4924
5015
|
};
|
|
4925
5016
|
}
|
|
4926
|
-
async function
|
|
5017
|
+
async function cn(u = dt) {
|
|
4927
5018
|
const t = u.findComponentByName("WhiteModel"), e = new File([await u.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([u.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([u.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(u.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
4928
5019
|
return {
|
|
4929
5020
|
dxf: n,
|
|
@@ -4935,31 +5026,31 @@ async function sn(u = dt) {
|
|
|
4935
5026
|
correctionDxf: s
|
|
4936
5027
|
};
|
|
4937
5028
|
}
|
|
4938
|
-
function
|
|
5029
|
+
function yn() {
|
|
4939
5030
|
return dt;
|
|
4940
5031
|
}
|
|
4941
5032
|
export {
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
5033
|
+
It as A,
|
|
5034
|
+
P as B,
|
|
5035
|
+
z as C,
|
|
5036
|
+
$ as D,
|
|
5037
|
+
bt as E,
|
|
5038
|
+
L,
|
|
5039
|
+
sn as M,
|
|
4949
5040
|
M as P,
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
5041
|
+
B as Q,
|
|
5042
|
+
be as T,
|
|
5043
|
+
Pt as V,
|
|
4953
5044
|
Nt as W,
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
5045
|
+
Bt as a,
|
|
5046
|
+
k as b,
|
|
5047
|
+
Te as c,
|
|
5048
|
+
pn as d,
|
|
5049
|
+
yn as e,
|
|
5050
|
+
Y as f,
|
|
5051
|
+
cn as g,
|
|
5052
|
+
fn as h,
|
|
5053
|
+
nn as i,
|
|
5054
|
+
nt as r,
|
|
5055
|
+
Z as u
|
|
4965
5056
|
};
|