build-dxf 0.0.47 → 0.0.48
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 +1287 -1224
- package/src/utils/DxfSystem/utils/BoundExt.d.ts +6 -2
- package/src/utils/DxfSystem/utils/BoundExtOld.d.ts +16 -0
- package/src/utils/DxfSystem/utils/TrajectoryHelper.d.ts +29 -0
- package/src/utils/DxfSystem/utils/findClosedPolygons.d.ts +1 -1
- package/src/utils/LineIndexGenerator.d.ts +10 -0
- package/src/utils/LineSegment.d.ts +7 -0
- package/src/utils/Path.d.ts +6 -0
- package/src/utils/PointVirtualGrid/index.d.ts +10 -5
- package/src/utils/Quadtree.d.ts +1 -0
package/src/build.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as P from "three";
|
|
2
|
-
import { EventDispatcher as
|
|
2
|
+
import { EventDispatcher as $t, Color as Kt, Matrix4 as Ct, Vector3 as it, Quaternion as Zt, BufferAttribute as _, REVISION as Qt, CompressedTexture as ct, Source as te, NoColorSpace as ee, MathUtils as dt, RGBAFormat as ne, ImageUtils as se, DoubleSide as ie, PropertyBinding as rt, InterpolateDiscrete as re, Scene as yt, SRGBColorSpace as oe, NearestFilter as ae, NearestMipmapNearestFilter as ce, NearestMipmapLinearFilter as le, LinearFilter as he, LinearMipmapNearestFilter as ue, LinearMipmapLinearFilter as de, ClampToEdgeWrapping as fe, RepeatWrapping as pe, MirroredRepeatWrapping as ge, InterpolateLinear as ye } from "three";
|
|
3
3
|
import xt from "clipper-lib";
|
|
4
|
-
import
|
|
5
|
-
import { OBJExporter as
|
|
4
|
+
import st from "dxf-writer";
|
|
5
|
+
import { OBJExporter as xe } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
6
|
function tt() {
|
|
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
|
|
12
|
+
class Nt extends $t {
|
|
13
13
|
uuid = tt();
|
|
14
14
|
addEventListener(t, e, n) {
|
|
15
15
|
const { once: s = !1 } = n ?? {}, i = (o) => {
|
|
@@ -30,7 +30,7 @@ class Rt extends Vt {
|
|
|
30
30
|
e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class G extends Nt {
|
|
34
34
|
parent;
|
|
35
35
|
destroyed = !1;
|
|
36
36
|
constructor(...t) {
|
|
@@ -48,7 +48,7 @@ class z extends Rt {
|
|
|
48
48
|
this.destroyed = !0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
class me extends Nt {
|
|
52
52
|
static EventType = {
|
|
53
53
|
ADD_COMPONENT: "addComponent"
|
|
54
54
|
};
|
|
@@ -71,7 +71,7 @@ class ge extends Rt {
|
|
|
71
71
|
* @param component
|
|
72
72
|
*/
|
|
73
73
|
removeComponent(t) {
|
|
74
|
-
if (t instanceof
|
|
74
|
+
if (t instanceof G) {
|
|
75
75
|
const e = this.components.indexOf(t);
|
|
76
76
|
e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
|
|
77
77
|
type: "removeComponent",
|
|
@@ -116,17 +116,17 @@ class ge extends Rt {
|
|
|
116
116
|
return e || null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
class
|
|
119
|
+
class I {
|
|
120
120
|
minX = 0;
|
|
121
121
|
maxX = 0;
|
|
122
122
|
minY = 0;
|
|
123
123
|
maxY = 0;
|
|
124
124
|
get points() {
|
|
125
125
|
return [
|
|
126
|
-
new
|
|
127
|
-
new
|
|
128
|
-
new
|
|
129
|
-
new
|
|
126
|
+
new w(this.minX, this.minY),
|
|
127
|
+
new w(this.maxX, this.minY),
|
|
128
|
+
new w(this.maxX, this.maxY),
|
|
129
|
+
new w(this.minX, this.maxY)
|
|
130
130
|
];
|
|
131
131
|
}
|
|
132
132
|
get width() {
|
|
@@ -136,7 +136,7 @@ class R {
|
|
|
136
136
|
return this.maxY - this.minY;
|
|
137
137
|
}
|
|
138
138
|
get center() {
|
|
139
|
-
return new
|
|
139
|
+
return new w(
|
|
140
140
|
this.minX + (this.maxX - this.minX) * 0.5,
|
|
141
141
|
this.minY + (this.maxY - this.minY) * 0.5
|
|
142
142
|
);
|
|
@@ -167,13 +167,13 @@ class R {
|
|
|
167
167
|
return this.minX <= e.x && e.x <= this.maxX && this.minY <= e.y && e.y <= this.maxY;
|
|
168
168
|
let r = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY;
|
|
169
169
|
if (s !== 0) {
|
|
170
|
-
const a = (this.minX - e.x) / s,
|
|
171
|
-
r = Math.max(r, Math.min(a,
|
|
170
|
+
const a = (this.minX - e.x) / s, c = (this.maxX - e.x) / s;
|
|
171
|
+
r = Math.max(r, Math.min(a, c)), o = Math.min(o, Math.max(a, c));
|
|
172
172
|
} else if (e.x < this.minX || e.x > this.maxX)
|
|
173
173
|
return !1;
|
|
174
174
|
if (i !== 0) {
|
|
175
|
-
const a = (this.minY - e.y) / i,
|
|
176
|
-
r = Math.max(r, Math.min(a,
|
|
175
|
+
const a = (this.minY - e.y) / i, c = (this.maxY - e.y) / i;
|
|
176
|
+
r = Math.max(r, Math.min(a, c)), o = Math.min(o, Math.max(a, c));
|
|
177
177
|
} else if (e.y < this.minY || e.y > this.maxY)
|
|
178
178
|
return !1;
|
|
179
179
|
return r <= o && r <= 1 && o >= 0;
|
|
@@ -193,43 +193,43 @@ class R {
|
|
|
193
193
|
intersectRectangle(t) {
|
|
194
194
|
const e = t.points;
|
|
195
195
|
let n = e[0].x, s = e[0].y, i = e[0].x, r = e[0].y;
|
|
196
|
-
for (let
|
|
197
|
-
const
|
|
198
|
-
|
|
196
|
+
for (let c = 1; c < 4; c++) {
|
|
197
|
+
const l = e[c];
|
|
198
|
+
l.x < n && (n = l.x), l.y < s && (s = l.y), l.x > i && (i = l.x), l.y > r && (r = l.y);
|
|
199
199
|
}
|
|
200
200
|
if (this.maxX < n || this.minX > i || this.maxY < s || this.minY > r)
|
|
201
201
|
return !1;
|
|
202
202
|
const o = this.points;
|
|
203
|
-
for (let
|
|
204
|
-
const
|
|
203
|
+
for (let c = 0; c < 4; c++) {
|
|
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 = (
|
|
207
|
-
if (y * g < 0 && x *
|
|
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), g = (h.x - l.x) * (p.y - l.y) - (h.y - l.y) * (p.x - l.x), x = (p.x - f.x) * (l.y - f.y) - (p.y - f.y) * (l.x - f.x), m = (p.x - f.x) * (h.y - f.y) - (p.y - f.y) * (h.x - f.x);
|
|
207
|
+
if (y * g < 0 && x * m < 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) || g === 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) || x === 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) || m === 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
|
}
|
|
211
|
-
for (let
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
211
|
+
for (let c = 0; c < 4; c++) {
|
|
212
|
+
const l = e[c];
|
|
213
|
+
if (l.x >= this.minX && l.x <= this.maxX && l.y >= this.minY && l.y <= this.maxY)
|
|
214
214
|
return !0;
|
|
215
215
|
}
|
|
216
|
-
const a = (
|
|
217
|
-
let
|
|
218
|
-
for (let
|
|
219
|
-
const d = e[
|
|
216
|
+
const a = (c) => {
|
|
217
|
+
let l = 0;
|
|
218
|
+
for (let h = 0; h < 4; h++) {
|
|
219
|
+
const d = e[h], f = e[(h + 1) % 4], p = (f.x - d.x) * (c.y - d.y) - (f.y - d.y) * (c.x - d.x);
|
|
220
220
|
if (p === 0) {
|
|
221
|
-
const y = Math.abs(f.x - d.x) > 1e-10 ? f.x - d.x : f.y - d.y, g = y ? (
|
|
221
|
+
const y = Math.abs(f.x - d.x) > 1e-10 ? f.x - d.x : f.y - d.y, g = y ? (c.x - d.x) / y : 0;
|
|
222
222
|
if (g >= 0 && g <= 1) return !0;
|
|
223
223
|
} else {
|
|
224
224
|
const y = p > 0 ? 1 : -1;
|
|
225
|
-
if (
|
|
226
|
-
else if (
|
|
225
|
+
if (l === 0) l = y;
|
|
226
|
+
else if (l !== y) return !1;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
return !0;
|
|
230
230
|
};
|
|
231
|
-
for (let
|
|
232
|
-
if (a(o[
|
|
231
|
+
for (let c = 0; c < 4; c++)
|
|
232
|
+
if (a(o[c])) return !0;
|
|
233
233
|
return !1;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
@@ -299,7 +299,7 @@ class R {
|
|
|
299
299
|
* @returns
|
|
300
300
|
*/
|
|
301
301
|
clone() {
|
|
302
|
-
return new
|
|
302
|
+
return new I(this.minX, this.maxX, this.minY, this.maxY);
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
*
|
|
@@ -310,7 +310,7 @@ class R {
|
|
|
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 I(
|
|
314
314
|
Math.min(...e),
|
|
315
315
|
Math.max(...e),
|
|
316
316
|
Math.min(...n),
|
|
@@ -328,7 +328,7 @@ class R {
|
|
|
328
328
|
s?.points?.forEach((i) => {
|
|
329
329
|
e.push(i.x), n.push(i.y);
|
|
330
330
|
});
|
|
331
|
-
}), new
|
|
331
|
+
}), new I(
|
|
332
332
|
Math.min(...e),
|
|
333
333
|
Math.max(...e),
|
|
334
334
|
Math.min(...n),
|
|
@@ -336,12 +336,20 @@ class R {
|
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
class
|
|
339
|
+
class we extends Array {
|
|
340
|
+
userDataList() {
|
|
341
|
+
return this.map((t) => t.userData);
|
|
342
|
+
}
|
|
343
|
+
points() {
|
|
344
|
+
return this.map((t) => t.point);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
class Y {
|
|
340
348
|
map = /* @__PURE__ */ new Map();
|
|
341
349
|
gridSize;
|
|
342
|
-
id
|
|
350
|
+
id;
|
|
343
351
|
constructor(t = 2) {
|
|
344
|
-
this.gridSize = t;
|
|
352
|
+
this.gridSize = t, this.id = Symbol("id");
|
|
345
353
|
}
|
|
346
354
|
/**
|
|
347
355
|
* 插入
|
|
@@ -377,7 +385,11 @@ class G {
|
|
|
377
385
|
}
|
|
378
386
|
}
|
|
379
387
|
update(t) {
|
|
380
|
-
|
|
388
|
+
const { target: e, set: n } = t.currentData[this.id];
|
|
389
|
+
if (!e) return !1;
|
|
390
|
+
const s = this.getGridId(t);
|
|
391
|
+
let i = this.map.get(s);
|
|
392
|
+
return i === n ? !1 : (n.delete(e), i || (i = /* @__PURE__ */ new Set(), this.map.set(s, i)), i.add(e), t.currentData[this.id].set = i, t.currentData[this.id].id = s, !0);
|
|
381
393
|
}
|
|
382
394
|
/**
|
|
383
395
|
* 获取通过坐标,获取唯一网格索引
|
|
@@ -388,6 +400,15 @@ class G {
|
|
|
388
400
|
const e = Math.ceil(t.x / this.gridSize), n = Math.ceil(t.y / this.gridSize);
|
|
389
401
|
return `${e}.${n}`;
|
|
390
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* 清空所有数据
|
|
405
|
+
*/
|
|
406
|
+
clear() {
|
|
407
|
+
for (const t of this.map.values())
|
|
408
|
+
for (const e of t)
|
|
409
|
+
delete e.point.currentData[this.id], delete e.point.currentData.pointVirtualGrid;
|
|
410
|
+
this.map.clear();
|
|
411
|
+
}
|
|
391
412
|
/**
|
|
392
413
|
*
|
|
393
414
|
* @param gridId
|
|
@@ -395,7 +416,7 @@ class G {
|
|
|
395
416
|
*/
|
|
396
417
|
decodeGridId(t) {
|
|
397
418
|
const [e, n] = t.split(".").map(Number);
|
|
398
|
-
return new
|
|
419
|
+
return new w(e, n);
|
|
399
420
|
}
|
|
400
421
|
/**
|
|
401
422
|
* 查询与矩形相交的点
|
|
@@ -406,10 +427,10 @@ class G {
|
|
|
406
427
|
const e = t.toBox(), n = Math.ceil(e.minX / this.gridSize), s = Math.ceil(e.maxX / this.gridSize), i = Math.ceil(e.minY / this.gridSize), r = Math.ceil(e.maxY / this.gridSize);
|
|
407
428
|
for (let o = n; o <= s; o++)
|
|
408
429
|
for (let a = i; a <= r; a++) {
|
|
409
|
-
const
|
|
410
|
-
if (!this.map.has(
|
|
411
|
-
this.map.get(
|
|
412
|
-
t.containsPoint(
|
|
430
|
+
const c = `${o}.${a}`;
|
|
431
|
+
if (!this.map.has(c)) continue;
|
|
432
|
+
this.map.get(c)?.forEach((h) => {
|
|
433
|
+
t.containsPoint(h.point);
|
|
413
434
|
});
|
|
414
435
|
}
|
|
415
436
|
}
|
|
@@ -420,12 +441,12 @@ class G {
|
|
|
420
441
|
* @returns 相交的节点数组
|
|
421
442
|
*/
|
|
422
443
|
queryCircle(t, e) {
|
|
423
|
-
const n = new
|
|
424
|
-
for (let
|
|
425
|
-
for (let
|
|
426
|
-
const
|
|
427
|
-
if (!this.map.has(
|
|
428
|
-
this.map.get(
|
|
444
|
+
const n = new I(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 = [];
|
|
445
|
+
for (let c = s; c <= i; c++)
|
|
446
|
+
for (let l = r; l <= o; l++) {
|
|
447
|
+
const h = `${c}.${l}`;
|
|
448
|
+
if (!this.map.has(h)) continue;
|
|
449
|
+
this.map.get(h)?.forEach((f) => {
|
|
429
450
|
t.distance(f.point) <= e && a.push(f);
|
|
430
451
|
});
|
|
431
452
|
}
|
|
@@ -440,10 +461,10 @@ class G {
|
|
|
440
461
|
const e = Math.ceil(t.minX / this.gridSize), n = Math.ceil(t.maxX / this.gridSize), s = Math.ceil(t.minY / this.gridSize), i = Math.ceil(t.maxY / this.gridSize), r = [];
|
|
441
462
|
for (let o = e; o <= n; o++)
|
|
442
463
|
for (let a = s; a <= i; a++) {
|
|
443
|
-
const
|
|
444
|
-
if (!this.map.has(
|
|
445
|
-
this.map.get(
|
|
446
|
-
t.containsPoint(
|
|
464
|
+
const c = `${o}.${a}`;
|
|
465
|
+
if (!this.map.has(c)) continue;
|
|
466
|
+
this.map.get(c)?.forEach((h) => {
|
|
467
|
+
t.containsPoint(h.point) && r.push(h);
|
|
447
468
|
});
|
|
448
469
|
}
|
|
449
470
|
return r;
|
|
@@ -453,7 +474,7 @@ class G {
|
|
|
453
474
|
* @param point
|
|
454
475
|
*/
|
|
455
476
|
queryPoint(t, e = !1) {
|
|
456
|
-
const n =
|
|
477
|
+
const n = new we();
|
|
457
478
|
let s;
|
|
458
479
|
if (t.currentData[this.id])
|
|
459
480
|
s = t.currentData[this.id]?.set;
|
|
@@ -494,7 +515,7 @@ class G {
|
|
|
494
515
|
if (t.size === 1) return [...t][0];
|
|
495
516
|
}
|
|
496
517
|
}
|
|
497
|
-
function
|
|
518
|
+
function J(u) {
|
|
498
519
|
if (!u || typeof u != "object")
|
|
499
520
|
return u;
|
|
500
521
|
const t = Array.isArray(u) ? [] : {}, e = Object.keys(u);
|
|
@@ -505,17 +526,17 @@ function W(u) {
|
|
|
505
526
|
continue;
|
|
506
527
|
}
|
|
507
528
|
if (Array.isArray(s)) {
|
|
508
|
-
t[n] = s.map((i) =>
|
|
529
|
+
t[n] = s.map((i) => J(i));
|
|
509
530
|
continue;
|
|
510
531
|
}
|
|
511
532
|
if (Object.getPrototypeOf(s) === Object.prototype) {
|
|
512
|
-
t[n] =
|
|
533
|
+
t[n] = J(s);
|
|
513
534
|
continue;
|
|
514
535
|
}
|
|
515
536
|
}
|
|
516
537
|
return t;
|
|
517
538
|
}
|
|
518
|
-
class
|
|
539
|
+
class nt {
|
|
519
540
|
points;
|
|
520
541
|
get p0() {
|
|
521
542
|
return this.points[0];
|
|
@@ -538,7 +559,7 @@ class st {
|
|
|
538
559
|
path2D(t) {
|
|
539
560
|
return this.points.flatMap((e, n) => {
|
|
540
561
|
const s = this.points[(n + 1) % this.points.length];
|
|
541
|
-
return t && t(new
|
|
562
|
+
return t && t(new w(e.x, e.y), new w(s.x, s.y)), [e.x, e.y, s.x, s.y];
|
|
542
563
|
});
|
|
543
564
|
}
|
|
544
565
|
createGeometry() {
|
|
@@ -566,14 +587,14 @@ class st {
|
|
|
566
587
|
throw new Error("LineSegment must have exactly 2 points");
|
|
567
588
|
const [e, n] = t.points, s = n.x - e.x, i = n.y - e.y;
|
|
568
589
|
for (let r = 0; r < 4; r++) {
|
|
569
|
-
const o = this.points[r], a = this.points[(r + 1) % 4],
|
|
570
|
-
if (
|
|
571
|
-
if ((e.x - o.x) *
|
|
572
|
-
const f =
|
|
590
|
+
const o = this.points[r], a = this.points[(r + 1) % 4], c = a.x - o.x, l = a.y - o.y, h = s * l - i * c;
|
|
591
|
+
if (h === 0) {
|
|
592
|
+
if ((e.x - o.x) * l - (e.y - o.y) * c !== 0) continue;
|
|
593
|
+
const f = c * c + l * l, p = ((e.x - o.x) * c + (e.y - o.y) * l) / f, y = ((n.x - o.x) * c + (n.y - o.y) * l) / f;
|
|
573
594
|
if (Math.max(p, y) >= 0 && Math.min(p, y) <= 1)
|
|
574
595
|
return !0;
|
|
575
596
|
} else {
|
|
576
|
-
const d = ((o.x - e.x) *
|
|
597
|
+
const d = ((o.x - e.x) * l - (o.y - e.y) * c) / h, f = ((o.x - e.x) * i - (o.y - e.y) * s) / h;
|
|
577
598
|
if (d >= 0 && d <= 1 && f >= 0 && f <= 1)
|
|
578
599
|
return !0;
|
|
579
600
|
}
|
|
@@ -591,13 +612,13 @@ class st {
|
|
|
591
612
|
const e = (n) => {
|
|
592
613
|
let s = 0;
|
|
593
614
|
for (let i = 0; i < 4; i++) {
|
|
594
|
-
const r = this.points[i], o = this.points[(i + 1) % 4], a = { x: o.x - r.x, y: o.y - r.y },
|
|
595
|
-
if (
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
615
|
+
const r = this.points[i], o = this.points[(i + 1) % 4], a = { x: o.x - r.x, y: o.y - r.y }, c = { x: n.x - r.x, y: n.y - r.y }, l = a.x * c.y - a.y * c.x;
|
|
616
|
+
if (l === 0) {
|
|
617
|
+
const h = a.x !== 0 ? (n.x - r.x) / a.x : (n.y - r.y) / a.y;
|
|
618
|
+
if (h >= 0 && h <= 1) return !0;
|
|
598
619
|
} else {
|
|
599
|
-
const
|
|
600
|
-
if (s === 0 && (s =
|
|
620
|
+
const h = l > 0 ? 1 : -1;
|
|
621
|
+
if (s === 0 && (s = h), s !== h) return !1;
|
|
601
622
|
}
|
|
602
623
|
}
|
|
603
624
|
return !0;
|
|
@@ -656,7 +677,7 @@ class st {
|
|
|
656
677
|
let t = 1 / 0, e = -1 / 0, n = 1 / 0, s = -1 / 0;
|
|
657
678
|
return this.points.forEach((i) => {
|
|
658
679
|
e = Math.max(i.x, e), t = Math.min(i.x, t), s = Math.max(i.x, s), n = Math.min(i.x, n);
|
|
659
|
-
}), new
|
|
680
|
+
}), new I(t, e, n, s);
|
|
660
681
|
}
|
|
661
682
|
/**
|
|
662
683
|
*
|
|
@@ -665,16 +686,16 @@ class st {
|
|
|
665
686
|
* @returns
|
|
666
687
|
*/
|
|
667
688
|
static fromByLineSegment(t, e = 0.1, n = !1, s = 0.5) {
|
|
668
|
-
const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) :
|
|
669
|
-
return new
|
|
670
|
-
new
|
|
671
|
-
new
|
|
672
|
-
new
|
|
673
|
-
new
|
|
689
|
+
const i = t.points[0], r = t.points[1], o = r.normal(i), a = n ? r.direction(i).mutiplyScalar(e * s) : w.zero(), c = n ? i.direction(r).mutiplyScalar(e * s) : w.zero(), l = o.x * e * 0.5, h = o.y * e * 0.5;
|
|
690
|
+
return new nt([
|
|
691
|
+
new w(i.x + l, i.y + h).add(c),
|
|
692
|
+
new w(r.x + l, r.y + h).add(a),
|
|
693
|
+
new w(r.x - l, r.y - h).add(a),
|
|
694
|
+
new w(i.x - l, i.y - h).add(c)
|
|
674
695
|
]);
|
|
675
696
|
}
|
|
676
697
|
}
|
|
677
|
-
class
|
|
698
|
+
class B {
|
|
678
699
|
bounds;
|
|
679
700
|
// 包围盒
|
|
680
701
|
capacity;
|
|
@@ -700,7 +721,7 @@ class O {
|
|
|
700
721
|
* @param node 线段节点
|
|
701
722
|
*/
|
|
702
723
|
insert(t) {
|
|
703
|
-
if (t instanceof
|
|
724
|
+
if (t instanceof D) {
|
|
704
725
|
this.insert({ line: t, userData: {} });
|
|
705
726
|
return;
|
|
706
727
|
}
|
|
@@ -725,7 +746,7 @@ class O {
|
|
|
725
746
|
* @param node
|
|
726
747
|
*/
|
|
727
748
|
remove(t) {
|
|
728
|
-
if (t instanceof
|
|
749
|
+
if (t instanceof D) {
|
|
729
750
|
t = t.currentData[this.id], t && this.remove(t);
|
|
730
751
|
return;
|
|
731
752
|
}
|
|
@@ -738,6 +759,11 @@ class O {
|
|
|
738
759
|
update(t) {
|
|
739
760
|
this.remove(t), this.insert(t);
|
|
740
761
|
}
|
|
762
|
+
clear() {
|
|
763
|
+
this.isLeaf || (this.children?.forEach((t) => t.clear()), this.children = null, this.isLeaf = !0), this.nodes.forEach((t) => {
|
|
764
|
+
delete t.line.currentData[this.id];
|
|
765
|
+
}), this.nodes = [];
|
|
766
|
+
}
|
|
741
767
|
/**
|
|
742
768
|
* 获取线段所属的象限
|
|
743
769
|
* @param line 线段
|
|
@@ -755,26 +781,26 @@ class O {
|
|
|
755
781
|
if (!this.isLeaf) return;
|
|
756
782
|
this.isLeaf = !1, this.children = [];
|
|
757
783
|
const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
|
|
758
|
-
this.children[0] = new
|
|
759
|
-
new
|
|
784
|
+
this.children[0] = new B(
|
|
785
|
+
new I(this.bounds.minX, t, this.bounds.minY, e),
|
|
760
786
|
this.capacity,
|
|
761
787
|
this.maxDepth,
|
|
762
788
|
this.depth + 1,
|
|
763
789
|
this.id
|
|
764
|
-
), this.children[1] = new
|
|
765
|
-
new
|
|
790
|
+
), this.children[1] = new B(
|
|
791
|
+
new I(t, this.bounds.maxX, this.bounds.minY, e),
|
|
766
792
|
this.capacity,
|
|
767
793
|
this.maxDepth,
|
|
768
794
|
this.depth + 1,
|
|
769
795
|
this.id
|
|
770
|
-
), this.children[2] = new
|
|
771
|
-
new
|
|
796
|
+
), this.children[2] = new B(
|
|
797
|
+
new I(this.bounds.minX, t, e, this.bounds.maxY),
|
|
772
798
|
this.capacity,
|
|
773
799
|
this.maxDepth,
|
|
774
800
|
this.depth + 1,
|
|
775
801
|
this.id
|
|
776
|
-
), this.children[3] = new
|
|
777
|
-
new
|
|
802
|
+
), this.children[3] = new B(
|
|
803
|
+
new I(t, this.bounds.maxX, e, this.bounds.maxY),
|
|
778
804
|
this.capacity,
|
|
779
805
|
this.maxDepth,
|
|
780
806
|
this.depth + 1,
|
|
@@ -804,7 +830,7 @@ class O {
|
|
|
804
830
|
* @returns 相交的节点数组
|
|
805
831
|
*/
|
|
806
832
|
queryCircle(t, e) {
|
|
807
|
-
const n = [], s = new
|
|
833
|
+
const n = [], s = new I(
|
|
808
834
|
t.x - e,
|
|
809
835
|
t.x + e,
|
|
810
836
|
t.y - e,
|
|
@@ -813,11 +839,11 @@ class O {
|
|
|
813
839
|
if (!this.bounds.intersectBox(s))
|
|
814
840
|
return n;
|
|
815
841
|
for (const i of this.nodes) {
|
|
816
|
-
const [r, o] = i.line.points, a = o.x - r.x,
|
|
817
|
-
let
|
|
818
|
-
|
|
819
|
-
const d = r.x +
|
|
820
|
-
t.distance(new
|
|
842
|
+
const [r, o] = i.line.points, a = o.x - r.x, c = o.y - r.y, l = a * a + c * c;
|
|
843
|
+
let h = ((t.x - r.x) * a + (t.y - r.y) * c) / l;
|
|
844
|
+
h = Math.max(0, Math.min(1, h));
|
|
845
|
+
const d = r.x + h * a, f = r.y + h * c;
|
|
846
|
+
t.distance(new w(d, f)) <= e && n.push(i);
|
|
821
847
|
}
|
|
822
848
|
if (!this.isLeaf)
|
|
823
849
|
for (const i of this.children)
|
|
@@ -885,13 +911,13 @@ class O {
|
|
|
885
911
|
})), t;
|
|
886
912
|
}
|
|
887
913
|
}
|
|
888
|
-
class
|
|
889
|
-
points = [new
|
|
914
|
+
class D {
|
|
915
|
+
points = [new w(), new w()];
|
|
890
916
|
userData = {};
|
|
891
917
|
currentData = {};
|
|
892
918
|
// line: any
|
|
893
919
|
get center() {
|
|
894
|
-
return new
|
|
920
|
+
return new w(
|
|
895
921
|
this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
|
|
896
922
|
this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
|
|
897
923
|
);
|
|
@@ -903,7 +929,7 @@ class E {
|
|
|
903
929
|
return this.points[1];
|
|
904
930
|
}
|
|
905
931
|
id = 0;
|
|
906
|
-
constructor(t = new
|
|
932
|
+
constructor(t = new w(), e = new w()) {
|
|
907
933
|
this.points = [t, e];
|
|
908
934
|
}
|
|
909
935
|
set(t, e) {
|
|
@@ -986,21 +1012,28 @@ class E {
|
|
|
986
1012
|
const n = t.clone().multiplyScalar(e);
|
|
987
1013
|
return this.start.add(n), this.end.add(n), this;
|
|
988
1014
|
}
|
|
1015
|
+
/** 旋转
|
|
1016
|
+
* @param angle 弧度
|
|
1017
|
+
*/
|
|
1018
|
+
rotate(t) {
|
|
1019
|
+
const e = this.center;
|
|
1020
|
+
return this.start.rotate(e, t), this.end.rotate(e, t), this;
|
|
1021
|
+
}
|
|
989
1022
|
/** 膨胀为矩形
|
|
990
1023
|
*
|
|
991
1024
|
* @param width
|
|
992
1025
|
* @returns {Rectangle}
|
|
993
1026
|
*/
|
|
994
1027
|
expandToRectangle(t = 0.1, e = "all") {
|
|
995
|
-
const n = this.start, s = this.end, i = s.normal(n), r = e === "bothSides" ?
|
|
1028
|
+
const n = this.start, s = this.end, i = s.normal(n), r = e === "bothSides" ? w.zero() : s.direction(n).mutiplyScalar(t * 0.5), o = e === "bothSides" ? w.zero() : n.direction(s).mutiplyScalar(t * 0.5), a = i.x * t * 0.5, c = i.y * t * 0.5, l = [
|
|
996
1029
|
// 第一条线
|
|
997
|
-
new
|
|
998
|
-
new
|
|
1030
|
+
new w(n.x + a, n.y + c).add(o),
|
|
1031
|
+
new w(s.x + a, s.y + c).add(r),
|
|
999
1032
|
// 第二条线
|
|
1000
|
-
new
|
|
1001
|
-
new
|
|
1033
|
+
new w(n.x - a, n.y - c).add(o),
|
|
1034
|
+
new w(s.x - a, s.y - c).add(r)
|
|
1002
1035
|
];
|
|
1003
|
-
return new
|
|
1036
|
+
return new nt([0, 1, 3, 2].map((h) => l[h]));
|
|
1004
1037
|
}
|
|
1005
1038
|
/**
|
|
1006
1039
|
* 计算线段的长度
|
|
@@ -1037,24 +1070,24 @@ class E {
|
|
|
1037
1070
|
projectLineSegment(t) {
|
|
1038
1071
|
if (t.points.length !== 2 || this.points.length !== 2)
|
|
1039
1072
|
throw new Error("每条线段必须由两个点定义");
|
|
1040
|
-
const [e, n] = t.points, [s, i] = this.points, r = new
|
|
1073
|
+
const [e, n] = t.points, [s, i] = this.points, r = new w(i.x - s.x, i.y - s.y);
|
|
1041
1074
|
if (r.x === 0 && r.y === 0)
|
|
1042
1075
|
throw new Error("投影目标线段的两个点不能重合");
|
|
1043
1076
|
const o = (p) => {
|
|
1044
|
-
const y = new
|
|
1045
|
-
return new
|
|
1077
|
+
const y = new w(p.x - s.x, p.y - s.y), g = r.x * r.x + r.y * r.y, m = (y.x * r.x + y.y * r.y) / g, L = s.x + m * r.x, M = s.y + m * r.y;
|
|
1078
|
+
return new w(L, M);
|
|
1046
1079
|
};
|
|
1047
|
-
let a = o(e),
|
|
1048
|
-
const
|
|
1049
|
-
const y = new
|
|
1080
|
+
let a = o(e), c = o(n);
|
|
1081
|
+
const l = (p) => {
|
|
1082
|
+
const y = new w(p.x - s.x, p.y - s.y), g = r.x * r.x + r.y * r.y;
|
|
1050
1083
|
return (y.x * r.x + y.y * r.y) / g;
|
|
1051
1084
|
};
|
|
1052
|
-
let
|
|
1085
|
+
let h = l(a), d = l(c);
|
|
1053
1086
|
const f = (p) => {
|
|
1054
1087
|
const y = Math.max(0, Math.min(1, p)), g = s.x + y * r.x, x = s.y + y * r.y;
|
|
1055
|
-
return new
|
|
1088
|
+
return new w(g, x);
|
|
1056
1089
|
};
|
|
1057
|
-
return (
|
|
1090
|
+
return (h < 0 || h > 1) && (a = f(h)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new D(a, a) : new D(a, c);
|
|
1058
1091
|
}
|
|
1059
1092
|
/**
|
|
1060
1093
|
* 计算一条线段在另一条直线上的投影
|
|
@@ -1063,19 +1096,28 @@ class E {
|
|
|
1063
1096
|
* @returns 投影并裁剪后的线段
|
|
1064
1097
|
*/
|
|
1065
1098
|
projectPoint(t, e = !0) {
|
|
1066
|
-
const [n, s] = this.points, i = new
|
|
1099
|
+
const [n, s] = this.points, i = new w(s.x - n.x, s.y - n.y);
|
|
1067
1100
|
if (i.x === 0 && i.y === 0)
|
|
1068
1101
|
return null;
|
|
1069
|
-
let o = ((
|
|
1070
|
-
const
|
|
1071
|
-
return new
|
|
1102
|
+
let o = ((l) => {
|
|
1103
|
+
const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y, p = (h.x * i.x + h.y * i.y) / d, y = n.x + p * i.x, g = n.y + p * i.y;
|
|
1104
|
+
return new w(y, g);
|
|
1072
1105
|
})(t);
|
|
1073
1106
|
if (!e) return o;
|
|
1074
|
-
let
|
|
1075
|
-
const
|
|
1076
|
-
return (
|
|
1107
|
+
let c = ((l) => {
|
|
1108
|
+
const h = new w(l.x - n.x, l.y - n.y), d = i.x * i.x + i.y * i.y;
|
|
1109
|
+
return (h.x * i.x + h.y * i.y) / d;
|
|
1077
1110
|
})(o);
|
|
1078
|
-
return
|
|
1111
|
+
return c < 0 || c > 1 ? null : o;
|
|
1112
|
+
}
|
|
1113
|
+
/** 获取点的投影值
|
|
1114
|
+
*/
|
|
1115
|
+
projectValue(t) {
|
|
1116
|
+
const [e, n] = this.points, s = new w(n.x - e.x, n.y - e.y);
|
|
1117
|
+
if (s.x === 0 && s.y === 0)
|
|
1118
|
+
return 0;
|
|
1119
|
+
const i = new w(t.x - e.x, t.y - e.y), r = s.x * s.x + s.y * s.y;
|
|
1120
|
+
return (i.x * s.x + i.y * s.y) / r;
|
|
1079
1121
|
}
|
|
1080
1122
|
/**
|
|
1081
1123
|
* 判断两条线段,是否在同一直线上:
|
|
@@ -1084,7 +1126,7 @@ class E {
|
|
|
1084
1126
|
* - 返回 1:共线且有重合(端点或区间重叠)
|
|
1085
1127
|
*/
|
|
1086
1128
|
sameLine(t) {
|
|
1087
|
-
const e = this.start, n = this.end, s = t.start, i = t.end, r = 1e-10, o = (a,
|
|
1129
|
+
const e = this.start, n = this.end, s = t.start, i = t.end, r = 1e-10, o = (a, c, l) => Math.abs((c.x - a.x) * (l.y - a.y) - (c.y - a.y) * (l.x - a.x)) < r;
|
|
1088
1130
|
return o(e, n, s) && o(e, n, i) ? this.containsPoint(s) || this.containsPoint(i) || t.containsPoint(e) || t.containsPoint(n) ? 1 : 0 : -1;
|
|
1089
1131
|
}
|
|
1090
1132
|
/**
|
|
@@ -1101,8 +1143,8 @@ class E {
|
|
|
1101
1143
|
function a(f, p, y) {
|
|
1102
1144
|
return Math.min(p.x, y.x) - 1e-10 <= f.x && f.x <= Math.max(p.x, y.x) + 1e-10 && Math.min(p.y, y.y) - 1e-10 <= f.y && f.y <= Math.max(p.y, y.y) + 1e-10;
|
|
1103
1145
|
}
|
|
1104
|
-
const
|
|
1105
|
-
return !!(
|
|
1146
|
+
const c = o(n, s, i), l = o(n, s, r), h = o(i, r, n), d = o(i, r, s);
|
|
1147
|
+
return !!(c * l < 0 && h * d < 0 || e && (Math.abs(c) < 1e-10 && a(i, n, s) || Math.abs(l) < 1e-10 && a(r, n, s) || Math.abs(h) < 1e-10 && a(n, i, r) || Math.abs(d) < 1e-10 && a(s, i, r)));
|
|
1106
1148
|
}
|
|
1107
1149
|
/**
|
|
1108
1150
|
* 判断一个点是否在线段上(含端点)
|
|
@@ -1122,8 +1164,8 @@ class E {
|
|
|
1122
1164
|
const e = this.start, n = this.end, s = t.start, i = t.end, r = (e.x - n.x) * (s.y - i.y) - (e.y - n.y) * (s.x - i.x);
|
|
1123
1165
|
if (Math.abs(r) < 1e-10)
|
|
1124
1166
|
return null;
|
|
1125
|
-
const o = ((e.x - s.x) * (s.y - i.y) - (e.y - s.y) * (s.x - i.x)) / r, a = e.x + o * (n.x - e.x),
|
|
1126
|
-
return new
|
|
1167
|
+
const o = ((e.x - s.x) * (s.y - i.y) - (e.y - s.y) * (s.x - i.x)) / r, a = e.x + o * (n.x - e.x), c = e.y + o * (n.y - e.y);
|
|
1168
|
+
return new w(a, c);
|
|
1127
1169
|
}
|
|
1128
1170
|
/**
|
|
1129
1171
|
* 获取两条线段夹角
|
|
@@ -1145,7 +1187,7 @@ class E {
|
|
|
1145
1187
|
* @param line
|
|
1146
1188
|
*/
|
|
1147
1189
|
parallel(t, e = 1) {
|
|
1148
|
-
return t instanceof
|
|
1190
|
+
return t instanceof D ? this.parallel(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), t < e || t > 180 - e);
|
|
1149
1191
|
}
|
|
1150
1192
|
/** 两条线段或角度是否 垂直
|
|
1151
1193
|
* @param line
|
|
@@ -1153,7 +1195,7 @@ class E {
|
|
|
1153
1195
|
* @returns
|
|
1154
1196
|
*/
|
|
1155
1197
|
vertical(t, e = 0.1) {
|
|
1156
|
-
return t instanceof
|
|
1198
|
+
return t instanceof D ? this.vertical(this.includedAngle(t), e) : (typeof t != "number" && (t = Number(t)), Math.abs(t - 90) < e);
|
|
1157
1199
|
}
|
|
1158
1200
|
/**
|
|
1159
1201
|
* 两条线段方向相反否一致
|
|
@@ -1180,14 +1222,14 @@ class E {
|
|
|
1180
1222
|
* @returns
|
|
1181
1223
|
*/
|
|
1182
1224
|
getRightDirection() {
|
|
1183
|
-
return this.normal();
|
|
1225
|
+
return this.normal().multiplyScalar(-1);
|
|
1184
1226
|
}
|
|
1185
1227
|
/**
|
|
1186
1228
|
*
|
|
1187
1229
|
* @returns
|
|
1188
1230
|
*/
|
|
1189
1231
|
getLeftDirection() {
|
|
1190
|
-
return this.normal()
|
|
1232
|
+
return this.normal();
|
|
1191
1233
|
}
|
|
1192
1234
|
/** @param line 获取两条线段之间的最短距离
|
|
1193
1235
|
*/
|
|
@@ -1195,17 +1237,17 @@ class E {
|
|
|
1195
1237
|
if (this.intersectLineSegment(t))
|
|
1196
1238
|
return 0;
|
|
1197
1239
|
const e = (n, s) => {
|
|
1198
|
-
const i = s.start, r = s.end, o = r.x - i.x, a = r.y - i.y,
|
|
1199
|
-
if (
|
|
1240
|
+
const i = s.start, r = s.end, o = r.x - i.x, a = r.y - i.y, c = o * o + a * a;
|
|
1241
|
+
if (c < 1e-10)
|
|
1200
1242
|
return n.distance(i);
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1243
|
+
const l = ((n.x - i.x) * o + (n.y - i.y) * a) / c;
|
|
1244
|
+
if (l < 0)
|
|
1203
1245
|
return n.distance(i);
|
|
1204
|
-
if (
|
|
1246
|
+
if (l > 1)
|
|
1205
1247
|
return n.distance(r);
|
|
1206
1248
|
{
|
|
1207
|
-
const
|
|
1208
|
-
return n.distance(new
|
|
1249
|
+
const h = i.x + l * o, d = i.y + l * a;
|
|
1250
|
+
return n.distance(new w(h, d));
|
|
1209
1251
|
}
|
|
1210
1252
|
};
|
|
1211
1253
|
return Math.min(
|
|
@@ -1221,18 +1263,18 @@ class E {
|
|
|
1221
1263
|
* @returns
|
|
1222
1264
|
*/
|
|
1223
1265
|
areLinesCoincident(t) {
|
|
1224
|
-
const e = this.start, n = this.end, s = t.start, i = t.end, r = (n.y - e.y) / (n.x - e.x), o = e.y - r * e.x, a = (i.y - s.y) / (i.x - s.x),
|
|
1225
|
-
return !isFinite(r) && !isFinite(a) ? e.x === s.x && n.x === s.x : Math.abs(r - a) < 1e-3 && Math.abs(o -
|
|
1266
|
+
const e = this.start, n = this.end, s = t.start, i = t.end, r = (n.y - e.y) / (n.x - e.x), o = e.y - r * e.x, a = (i.y - s.y) / (i.x - s.x), c = s.y - a * s.x;
|
|
1267
|
+
return !isFinite(r) && !isFinite(a) ? e.x === s.x && n.x === s.x : Math.abs(r - a) < 1e-3 && Math.abs(o - c) < 1e-3;
|
|
1226
1268
|
}
|
|
1227
1269
|
/** 克隆
|
|
1228
1270
|
* @returns
|
|
1229
1271
|
*/
|
|
1230
1272
|
clone() {
|
|
1231
|
-
const t = new
|
|
1273
|
+
const t = new D(
|
|
1232
1274
|
this.points[0].clone(),
|
|
1233
1275
|
this.points[1].clone()
|
|
1234
1276
|
);
|
|
1235
|
-
return t.userData =
|
|
1277
|
+
return t.userData = J(this.userData), t;
|
|
1236
1278
|
}
|
|
1237
1279
|
/**
|
|
1238
1280
|
* 获取最长线段
|
|
@@ -1251,29 +1293,29 @@ class E {
|
|
|
1251
1293
|
* @param lines
|
|
1252
1294
|
*/
|
|
1253
1295
|
static groupBySamePointAndParallel(t) {
|
|
1254
|
-
const e = new
|
|
1296
|
+
const e = new Y(), n = new B(I.fromByLineSegment(...t));
|
|
1255
1297
|
t.forEach((o) => {
|
|
1256
1298
|
o.points.forEach((a) => e.insert(a, o)), n.insert(o);
|
|
1257
1299
|
});
|
|
1258
1300
|
const s = /* @__PURE__ */ new Set();
|
|
1259
|
-
function i(o, a,
|
|
1301
|
+
function i(o, a, c) {
|
|
1260
1302
|
if (a.has(o)) return;
|
|
1261
|
-
const
|
|
1262
|
-
return
|
|
1263
|
-
...e.queryPoint(o.start).filter((
|
|
1264
|
-
...e.queryPoint(o.end).filter((
|
|
1265
|
-
...n.queryPoint(o.start).filter((
|
|
1266
|
-
...n.queryPoint(o.end).filter((
|
|
1267
|
-
),
|
|
1268
|
-
|
|
1269
|
-
}), a.add(o),
|
|
1303
|
+
const l = [];
|
|
1304
|
+
return l.push(
|
|
1305
|
+
...e.queryPoint(o.start).filter((h) => h.userData !== o && o.parallel(h.userData, 0.1)).map((h) => h.userData),
|
|
1306
|
+
...e.queryPoint(o.end).filter((h) => h.userData !== o && o.parallel(h.userData, 0.1)).map((h) => h.userData),
|
|
1307
|
+
...n.queryPoint(o.start).filter((h) => h.line !== o && o.parallel(h.line, 0.1)).map((h) => h.line),
|
|
1308
|
+
...n.queryPoint(o.end).filter((h) => h.line !== o && o.parallel(h.line, 0.1)).map((h) => h.line)
|
|
1309
|
+
), l.forEach((h) => {
|
|
1310
|
+
h && !c.has(h) && (c.add(h), i(h, a, c));
|
|
1311
|
+
}), a.add(o), c;
|
|
1270
1312
|
}
|
|
1271
1313
|
const r = [];
|
|
1272
1314
|
for (let o = 0; o < t.length; o++) {
|
|
1273
1315
|
const a = t[o];
|
|
1274
1316
|
if (s.has(a)) continue;
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1317
|
+
const c = i(a, s, /* @__PURE__ */ new Set([a]));
|
|
1318
|
+
c && r.push([...c]);
|
|
1277
1319
|
}
|
|
1278
1320
|
return r;
|
|
1279
1321
|
}
|
|
@@ -1295,17 +1337,17 @@ class E {
|
|
|
1295
1337
|
*/
|
|
1296
1338
|
static mergeLinesByMaxlength(...t) {
|
|
1297
1339
|
if (t.length === 1) return t[0];
|
|
1298
|
-
const n = t.slice(0).sort((
|
|
1340
|
+
const n = t.slice(0).sort((h, d) => d.length() - h.length())[0], s = n.direction().normalize();
|
|
1299
1341
|
let i = n.start.clone(), r = n.end.clone();
|
|
1300
|
-
const o = (
|
|
1301
|
-
let a = o(i),
|
|
1302
|
-
for (const
|
|
1303
|
-
for (const d of
|
|
1342
|
+
const o = (h) => h.x * s.x + h.y * s.y;
|
|
1343
|
+
let a = o(i), c = o(r);
|
|
1344
|
+
for (const h of t)
|
|
1345
|
+
for (const d of h.points) {
|
|
1304
1346
|
const f = o(d);
|
|
1305
|
-
f < a && (a = f, i = n.projectPoint(d, !1)), f >
|
|
1347
|
+
f < a && (a = f, i = n.projectPoint(d, !1)), f > c && (c = f, r = n.projectPoint(d, !1));
|
|
1306
1348
|
}
|
|
1307
|
-
const
|
|
1308
|
-
return t.forEach((
|
|
1349
|
+
const l = new D(i, r);
|
|
1350
|
+
return t.forEach((h) => h.userData.fittedLine = l), l;
|
|
1309
1351
|
}
|
|
1310
1352
|
/** 合并平行线段
|
|
1311
1353
|
* @param lines
|
|
@@ -1323,7 +1365,7 @@ class E {
|
|
|
1323
1365
|
const y = p.x * s.x + p.y * s.y;
|
|
1324
1366
|
i = Math.min(i, y), r = Math.max(r, y), o += p.x, a += p.y;
|
|
1325
1367
|
});
|
|
1326
|
-
const
|
|
1368
|
+
const c = new w(o / n.length, a / n.length), l = c.x * s.x + c.y * s.y, h = new w(c.x + (i - l) * s.x, c.y + (i - l) * s.y), d = new w(c.x + (r - l) * s.x, c.y + (r - l) * s.y), f = new D(h, d);
|
|
1327
1369
|
return t.forEach((p) => p.userData.fittedLine = f), f;
|
|
1328
1370
|
}
|
|
1329
1371
|
/** 合并满足平行的线段
|
|
@@ -1348,38 +1390,38 @@ class E {
|
|
|
1348
1390
|
*/
|
|
1349
1391
|
static brokenLineMerging(t, e) {
|
|
1350
1392
|
const n = /* @__PURE__ */ new Map();
|
|
1351
|
-
t.forEach((
|
|
1352
|
-
const
|
|
1353
|
-
n.has(
|
|
1393
|
+
t.forEach((c) => c.points.forEach((l) => {
|
|
1394
|
+
const h = `${l.X.toFixed(6)}_${l.Y.toFixed(6)}`;
|
|
1395
|
+
n.has(h) || n.set(h, []), n.get(h)?.push(c);
|
|
1354
1396
|
}));
|
|
1355
1397
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
1356
|
-
function r(
|
|
1357
|
-
const
|
|
1398
|
+
function r(c) {
|
|
1399
|
+
const l = i.get(c[0]), h = i.get(c[1]);
|
|
1358
1400
|
let d;
|
|
1359
|
-
if (
|
|
1360
|
-
d =
|
|
1361
|
-
const p = s.get(
|
|
1362
|
-
[...s.get(
|
|
1401
|
+
if (l && h) {
|
|
1402
|
+
d = l;
|
|
1403
|
+
const p = s.get(l);
|
|
1404
|
+
[...s.get(h)].forEach((g) => {
|
|
1363
1405
|
p.add(g), i.set(g, d);
|
|
1364
1406
|
});
|
|
1365
|
-
} else d =
|
|
1407
|
+
} else d = l ?? h ?? (Math.random() * 16777215).toString(16);
|
|
1366
1408
|
s.has(d) || s.set(d, /* @__PURE__ */ new Set());
|
|
1367
1409
|
const f = s.get(d);
|
|
1368
|
-
|
|
1410
|
+
c.forEach((p) => {
|
|
1369
1411
|
i.set(p, d), f?.add(p);
|
|
1370
1412
|
});
|
|
1371
1413
|
}
|
|
1372
|
-
for (const
|
|
1373
|
-
if (
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1414
|
+
for (const c of n.values()) {
|
|
1415
|
+
if (c.length !== 2) continue;
|
|
1416
|
+
const l = c[0], h = c[1];
|
|
1417
|
+
l.parallel(h) && r(c);
|
|
1376
1418
|
}
|
|
1377
1419
|
const o = /* @__PURE__ */ new Set(), a = [];
|
|
1378
|
-
for (const
|
|
1379
|
-
const
|
|
1380
|
-
e && e(
|
|
1420
|
+
for (const c of s.values()) {
|
|
1421
|
+
const l = [...c], h = this.mergeLines(...l);
|
|
1422
|
+
e && e(h, l), l.forEach((d) => o.add(d)), a.push(h);
|
|
1381
1423
|
}
|
|
1382
|
-
return t = t.filter((
|
|
1424
|
+
return t = t.filter((c) => !o.has(c)), t.push(...a), t;
|
|
1383
1425
|
}
|
|
1384
1426
|
/** 去重
|
|
1385
1427
|
* @param lines
|
|
@@ -1388,8 +1430,8 @@ class E {
|
|
|
1388
1430
|
static deduplication(t) {
|
|
1389
1431
|
const e = /* @__PURE__ */ new Set(), n = [];
|
|
1390
1432
|
for (const s of t) {
|
|
1391
|
-
const i = s.start, r = s.end, o = `${i.x.toFixed(10)}_${i.y.toFixed(10)}`, a = `${r.x.toFixed(10)}_${r.y.toFixed(10)}`,
|
|
1392
|
-
e.has(
|
|
1433
|
+
const i = s.start, r = s.end, o = `${i.x.toFixed(10)}_${i.y.toFixed(10)}`, a = `${r.x.toFixed(10)}_${r.y.toFixed(10)}`, c = o < a ? `${o}_${a}` : `${a}_${o}`;
|
|
1434
|
+
e.has(c) || (e.add(c), n.push(s));
|
|
1393
1435
|
}
|
|
1394
1436
|
return n;
|
|
1395
1437
|
}
|
|
@@ -1399,7 +1441,7 @@ class E {
|
|
|
1399
1441
|
* @returns
|
|
1400
1442
|
*/
|
|
1401
1443
|
static clipping(t, e, n) {
|
|
1402
|
-
if (!(t instanceof
|
|
1444
|
+
if (!(t instanceof D)) throw new Error("参数1并非线段");
|
|
1403
1445
|
e = e.map((r) => t.projectPoint(r)).filter((r) => !!r);
|
|
1404
1446
|
const s = t.clone();
|
|
1405
1447
|
e.sort((r, o) => s.start.distance(r) - s.start.distance(o));
|
|
@@ -1418,7 +1460,7 @@ class E {
|
|
|
1418
1460
|
return this.clipping(t, [s, i].filter((o) => !!o), n).filter((o) => !(e.projectLineSegment(o).length() / e.length() > 0.8));
|
|
1419
1461
|
}
|
|
1420
1462
|
}
|
|
1421
|
-
class
|
|
1463
|
+
class w {
|
|
1422
1464
|
x;
|
|
1423
1465
|
y;
|
|
1424
1466
|
get X() {
|
|
@@ -1545,7 +1587,7 @@ class D {
|
|
|
1545
1587
|
*/
|
|
1546
1588
|
normal(t) {
|
|
1547
1589
|
const e = this.x - t.x, n = this.y - t.y, s = Math.sqrt(e * e + n * n), i = -n / s, r = e / s;
|
|
1548
|
-
return new
|
|
1590
|
+
return new w(i, r);
|
|
1549
1591
|
}
|
|
1550
1592
|
/**
|
|
1551
1593
|
* 获取由传入的点到该点的单位方向向量
|
|
@@ -1555,14 +1597,14 @@ class D {
|
|
|
1555
1597
|
*/
|
|
1556
1598
|
direction(t) {
|
|
1557
1599
|
const e = this.x - t.x, n = this.y - t.y, s = Math.sqrt(e * e + n * n);
|
|
1558
|
-
return s === 0 ? new
|
|
1600
|
+
return s === 0 ? new w(0, 0) : new w(e / s, n / s);
|
|
1559
1601
|
}
|
|
1560
1602
|
/** 展开为线
|
|
1561
1603
|
* @param direction
|
|
1562
1604
|
* @param length
|
|
1563
1605
|
*/
|
|
1564
1606
|
expandAsLine(t, e, n) {
|
|
1565
|
-
const s = new
|
|
1607
|
+
const s = new D(
|
|
1566
1608
|
this.clone(),
|
|
1567
1609
|
this.clone().add(t.clone().multiplyScalar(e))
|
|
1568
1610
|
);
|
|
@@ -1637,7 +1679,7 @@ class D {
|
|
|
1637
1679
|
* @returns
|
|
1638
1680
|
*/
|
|
1639
1681
|
clone() {
|
|
1640
|
-
return new
|
|
1682
|
+
return new w(this.x, this.y);
|
|
1641
1683
|
}
|
|
1642
1684
|
/**
|
|
1643
1685
|
* 克隆
|
|
@@ -1654,13 +1696,13 @@ class D {
|
|
|
1654
1696
|
};
|
|
1655
1697
|
}
|
|
1656
1698
|
static from(t) {
|
|
1657
|
-
return Array.isArray(t) ? new
|
|
1699
|
+
return Array.isArray(t) ? new w(t[0], t[1]) : "x" in t && "y" in t ? new w(t.x, t.y) : "X" in t && "Y" in t ? new w(t.X, t.Y) : this.zero();
|
|
1658
1700
|
}
|
|
1659
1701
|
static zero() {
|
|
1660
|
-
return new
|
|
1702
|
+
return new w(0, 0);
|
|
1661
1703
|
}
|
|
1662
1704
|
}
|
|
1663
|
-
async function
|
|
1705
|
+
async function H(u, t = !0) {
|
|
1664
1706
|
if (typeof global < "u" && typeof require < "u")
|
|
1665
1707
|
return require(u);
|
|
1666
1708
|
{
|
|
@@ -1671,67 +1713,69 @@ async function X(u, t = !0) {
|
|
|
1671
1713
|
return t && (e = e.default), e;
|
|
1672
1714
|
}
|
|
1673
1715
|
}
|
|
1674
|
-
function
|
|
1716
|
+
function Bt(u, t = 0, e, n) {
|
|
1675
1717
|
const s = u.userData, i = s.drawWindow, r = e ? e.queryLineSegment(u).filter((a) => a.line !== u && !a.userData?.isDoor).map((a) => ({ index: n?.indexOf(a.line) })) : [];
|
|
1676
1718
|
return {
|
|
1677
|
-
...
|
|
1719
|
+
...J(s),
|
|
1678
1720
|
start: u.start.toJson(t),
|
|
1679
1721
|
end: u.end.toJson(t),
|
|
1680
1722
|
insetionArr: r,
|
|
1681
1723
|
length: u.length(),
|
|
1682
1724
|
drawWindow: i && i.map((a) => ({
|
|
1683
|
-
...
|
|
1725
|
+
...J(a),
|
|
1684
1726
|
p: { x: a.p.x, y: a.p.y, z: a.p.z }
|
|
1685
1727
|
}))
|
|
1686
1728
|
};
|
|
1687
1729
|
}
|
|
1688
1730
|
function et(u, t = 0, e) {
|
|
1689
|
-
return e || (e = new
|
|
1731
|
+
return e || (e = new B(I.fromByLineSegment(...u)), u.forEach((n) => e?.insert({ line: n, userData: void 0 })), Promise.resolve().then(() => e?.clear())), u.map((n) => Bt(n, t, e, u));
|
|
1690
1732
|
}
|
|
1691
|
-
function
|
|
1692
|
-
const e = new
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1733
|
+
function ft(u, t = 0.03) {
|
|
1734
|
+
const e = new B(I.fromByLineSegment(...u));
|
|
1735
|
+
u.forEach((s) => e.insert({ line: s, userData: void 0 }));
|
|
1736
|
+
const n = u.flatMap((s) => {
|
|
1737
|
+
const i = e.queryLineSegment(s, !0).map((r) => {
|
|
1738
|
+
if (r.line === s) return;
|
|
1739
|
+
const o = r.line.getIntersection(s);
|
|
1740
|
+
if (!(!o || s.start.equal(o) || s.end.equal(o)))
|
|
1741
|
+
return o;
|
|
1742
|
+
}).filter((r) => !!r);
|
|
1743
|
+
if (i.length) {
|
|
1744
|
+
const r = s.clone();
|
|
1745
|
+
i.sort((a, c) => r.start.distance(a) - r.start.distance(c));
|
|
1746
|
+
const o = i.map((a) => {
|
|
1747
|
+
const c = r.clone();
|
|
1748
|
+
return c.set(r.start.clone(), a), r.start.copy(a), r.userData.isWindow && (c.userData.isWindow = !0, c.userData.drawWindow = r.userData.drawWindow?.filter((l) => c.isPointOnSegment(w.from(l.p))) ?? []), c;
|
|
1706
1749
|
});
|
|
1707
|
-
return
|
|
1750
|
+
return r.userData.drawWindow = r.userData.drawWindow?.filter((a) => r.isPointOnSegment(w.from(a.p))) ?? [], [...o, r];
|
|
1708
1751
|
}
|
|
1709
|
-
return
|
|
1710
|
-
}).filter((
|
|
1752
|
+
return s;
|
|
1753
|
+
}).filter((s) => s.length() >= t);
|
|
1754
|
+
return e.clear(), n;
|
|
1711
1755
|
}
|
|
1712
|
-
function
|
|
1756
|
+
function X(...u) {
|
|
1713
1757
|
u.forEach((t) => {
|
|
1714
1758
|
const e = t.direction();
|
|
1715
1759
|
t.userData.drawWindow?.forEach((n) => {
|
|
1716
1760
|
try {
|
|
1717
|
-
const s =
|
|
1761
|
+
const s = w.from(n.p), i = t.projectPoint(
|
|
1718
1762
|
s.clone().add(e.clone().multiplyScalar(n.width * 0.5)),
|
|
1719
1763
|
!1
|
|
1720
1764
|
), r = t.projectPoint(
|
|
1721
1765
|
s.clone().add(e.clone().multiplyScalar(n.width * -0.5)),
|
|
1722
1766
|
!1
|
|
1723
|
-
), o = t.projectLineSegment(new
|
|
1767
|
+
), o = t.projectLineSegment(new D(i, r)), a = o.center;
|
|
1724
1768
|
n.p = {
|
|
1725
1769
|
x: a?.x ?? 0,
|
|
1726
1770
|
y: a?.y ?? 0,
|
|
1727
1771
|
z: n.p.z
|
|
1728
|
-
};
|
|
1772
|
+
}, n.width = o.length();
|
|
1729
1773
|
} catch {
|
|
1730
1774
|
}
|
|
1731
|
-
});
|
|
1775
|
+
}), t.userData.drawWindow = t.userData.drawWindow?.filter((n) => n.width > 1e-9);
|
|
1732
1776
|
});
|
|
1733
1777
|
}
|
|
1734
|
-
function
|
|
1778
|
+
function Ot(u) {
|
|
1735
1779
|
if (u.length < 3) return 0;
|
|
1736
1780
|
let t = 0;
|
|
1737
1781
|
const e = u.length;
|
|
@@ -1741,13 +1785,13 @@ function Nt(u) {
|
|
|
1741
1785
|
}
|
|
1742
1786
|
return Math.abs(t) / 2;
|
|
1743
1787
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const t = new
|
|
1788
|
+
function V(u) {
|
|
1789
|
+
const t = new Y();
|
|
1746
1790
|
for (const e of u)
|
|
1747
1791
|
t.insert(e.start, e), t.insert(e.end, e);
|
|
1748
1792
|
return t;
|
|
1749
1793
|
}
|
|
1750
|
-
class
|
|
1794
|
+
class Me extends Map {
|
|
1751
1795
|
get valueArray() {
|
|
1752
1796
|
return [...this.values()];
|
|
1753
1797
|
}
|
|
@@ -1793,7 +1837,7 @@ class ye extends Map {
|
|
|
1793
1837
|
return t.every((e) => this.has(e));
|
|
1794
1838
|
}
|
|
1795
1839
|
group(t) {
|
|
1796
|
-
const e = new
|
|
1840
|
+
const e = new at();
|
|
1797
1841
|
for (const [n, s] of this) {
|
|
1798
1842
|
const i = t(s, n);
|
|
1799
1843
|
e.append(i, s);
|
|
@@ -1804,35 +1848,35 @@ class ye extends Map {
|
|
|
1804
1848
|
return this.reduce((t, e, n) => (t[`${n}`] = e, t), {});
|
|
1805
1849
|
}
|
|
1806
1850
|
}
|
|
1807
|
-
class
|
|
1851
|
+
class at extends Me {
|
|
1808
1852
|
append(t, ...e) {
|
|
1809
1853
|
return e.forEach((n) => {
|
|
1810
1854
|
this.has(t) || this.set(t, []), this.get(t)?.push(n);
|
|
1811
1855
|
}), this;
|
|
1812
1856
|
}
|
|
1813
1857
|
}
|
|
1814
|
-
function
|
|
1858
|
+
function De(u, t, e, n = !0) {
|
|
1815
1859
|
e = e ?? /* @__PURE__ */ new Set();
|
|
1816
|
-
const s = t ||
|
|
1817
|
-
function
|
|
1818
|
-
if (!(
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1860
|
+
const s = !!t, i = t || V(u);
|
|
1861
|
+
function r(o) {
|
|
1862
|
+
if (!(o instanceof D) || e?.has(o)) return;
|
|
1863
|
+
const a = i?.queryPoint(o.start, !0), c = i?.queryPoint(o.end, !0);
|
|
1864
|
+
a && c && (a?.length === 0 || c?.length === 0) && (e?.add(o), i.remove(o.start), i.remove(o.end), n && (a.forEach(({ userData: l }) => r(l)), c.forEach(({ userData: l }) => r(l))));
|
|
1821
1865
|
}
|
|
1822
|
-
for (let
|
|
1823
|
-
const
|
|
1824
|
-
|
|
1866
|
+
for (let o = 0; o < u.length; o++) {
|
|
1867
|
+
const a = u[o];
|
|
1868
|
+
r(a);
|
|
1825
1869
|
}
|
|
1826
|
-
return e;
|
|
1870
|
+
return s || i.clear(), e;
|
|
1827
1871
|
}
|
|
1828
|
-
function
|
|
1829
|
-
const e = t ||
|
|
1872
|
+
function jt(u, t) {
|
|
1873
|
+
const e = t || V(u);
|
|
1830
1874
|
function n(r, o, a) {
|
|
1831
|
-
e.queryPoint(r, !0).forEach((
|
|
1832
|
-
const
|
|
1833
|
-
if (a.has(
|
|
1834
|
-
a.add(
|
|
1835
|
-
const d =
|
|
1875
|
+
e.queryPoint(r, !0).forEach((l) => {
|
|
1876
|
+
const h = l.userData;
|
|
1877
|
+
if (a.has(h)) return;
|
|
1878
|
+
a.add(h), o.push(h);
|
|
1879
|
+
const d = h.getAnotherPoint(l.point);
|
|
1836
1880
|
n(d, o, a);
|
|
1837
1881
|
});
|
|
1838
1882
|
}
|
|
@@ -1845,36 +1889,36 @@ function Ot(u, t) {
|
|
|
1845
1889
|
}
|
|
1846
1890
|
return i;
|
|
1847
1891
|
}
|
|
1848
|
-
function
|
|
1849
|
-
const n = e ??
|
|
1892
|
+
function Le(u, t = /* @__PURE__ */ new Set(), e) {
|
|
1893
|
+
const n = e ?? V(u), s = /* @__PURE__ */ new Set();
|
|
1850
1894
|
let i = 0;
|
|
1851
|
-
function r(a, l, h
|
|
1852
|
-
const d = a.getAnotherPoint(
|
|
1853
|
-
if (
|
|
1895
|
+
function r(a, c, l, h = /* @__PURE__ */ new Set()) {
|
|
1896
|
+
const d = a.getAnotherPoint(c);
|
|
1897
|
+
if (l.length > 1 && d.equal(l[0].end)) return !1;
|
|
1854
1898
|
const f = n.queryPoint(d, !0);
|
|
1855
1899
|
for (let p = 0; p < f.length; p++) {
|
|
1856
1900
|
const y = f[p].userData, g = f[p].point;
|
|
1857
|
-
if (y ===
|
|
1901
|
+
if (y === l[0]) {
|
|
1858
1902
|
if (y.end === g) continue;
|
|
1859
1903
|
return !0;
|
|
1860
1904
|
}
|
|
1861
|
-
if (!
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1905
|
+
if (!h.has(y)) {
|
|
1906
|
+
if (l.push(y), h.add(y), r(y, g, l, h)) return !0;
|
|
1907
|
+
l.pop();
|
|
1864
1908
|
}
|
|
1865
1909
|
}
|
|
1866
1910
|
}
|
|
1867
1911
|
for (i = 0; i < u.length; i++) {
|
|
1868
1912
|
const a = u[i];
|
|
1869
1913
|
if (s.has(a)) continue;
|
|
1870
|
-
const
|
|
1871
|
-
r(a, a.start,
|
|
1914
|
+
const c = [a];
|
|
1915
|
+
r(a, a.start, c) ? c.forEach((l) => s.add(l)) : (t.add(a), n.remove(a.start), n.remove(a.end));
|
|
1872
1916
|
}
|
|
1873
1917
|
const o = u.length;
|
|
1874
|
-
return u = u.filter((a) => !t.has(a)), o !== u.length ?
|
|
1918
|
+
return u = u.filter((a) => !t.has(a)), o !== u.length ? jt(u) : [u];
|
|
1875
1919
|
}
|
|
1876
|
-
function
|
|
1877
|
-
const t =
|
|
1920
|
+
function Se(u) {
|
|
1921
|
+
const t = V(u), e = u[0].start, n = /* @__PURE__ */ new Set();
|
|
1878
1922
|
let s = e;
|
|
1879
1923
|
for (n.add(s); ; ) {
|
|
1880
1924
|
const i = t.queryPoint(s, !0);
|
|
@@ -1885,42 +1929,42 @@ function me(u) {
|
|
|
1885
1929
|
}
|
|
1886
1930
|
return n.add(e.clone()), [...n];
|
|
1887
1931
|
}
|
|
1888
|
-
function
|
|
1889
|
-
const
|
|
1890
|
-
function
|
|
1891
|
-
if (performance.now() -
|
|
1932
|
+
function Ee(u) {
|
|
1933
|
+
const t = V(u), e = [], n = /* @__PURE__ */ new Set(), s = performance.now();
|
|
1934
|
+
function i(c, l = [], h) {
|
|
1935
|
+
if (performance.now() - s > 200)
|
|
1892
1936
|
return;
|
|
1893
|
-
let
|
|
1894
|
-
|
|
1895
|
-
const
|
|
1896
|
-
if (
|
|
1897
|
-
if (
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1937
|
+
let d = c.start;
|
|
1938
|
+
h && (d = c.getAnotherPoint(h)), t.queryPoint(d, !0).forEach((p) => {
|
|
1939
|
+
const y = p.userData;
|
|
1940
|
+
if (l.includes(y)) {
|
|
1941
|
+
if (l[0] === y) {
|
|
1942
|
+
const g = [...l];
|
|
1943
|
+
e.push(g), g.forEach((x) => n.add(x));
|
|
1900
1944
|
}
|
|
1901
1945
|
return;
|
|
1902
1946
|
}
|
|
1903
|
-
|
|
1947
|
+
l.push(y), i(y, l, p.point), l.pop();
|
|
1904
1948
|
});
|
|
1905
1949
|
}
|
|
1906
|
-
for (let
|
|
1907
|
-
const
|
|
1908
|
-
|
|
1950
|
+
for (let c = 0; c < u.length; c++) {
|
|
1951
|
+
const l = u[c];
|
|
1952
|
+
n.has(l) || i(l, [l]);
|
|
1909
1953
|
}
|
|
1910
|
-
let
|
|
1911
|
-
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1954
|
+
let r = 0, o = [];
|
|
1955
|
+
e.forEach((c) => {
|
|
1956
|
+
const l = Se(c), h = Ot(l);
|
|
1957
|
+
h >= r && (r = h, o = c);
|
|
1914
1958
|
});
|
|
1915
|
-
const
|
|
1916
|
-
return
|
|
1959
|
+
const a = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
|
|
1960
|
+
return o.forEach((c) => Object.assign(c.userData, { groupId: a, groupType: "doubleWall" })), t.clear(), o;
|
|
1917
1961
|
}
|
|
1918
|
-
function
|
|
1962
|
+
function Ft(u) {
|
|
1919
1963
|
if (u.length === 0) return { lines: u, groups: [], removeLines: [] };
|
|
1920
|
-
const t =
|
|
1964
|
+
const t = V(u), e = De(u, t);
|
|
1921
1965
|
let n = u.filter((i) => !e.has(i));
|
|
1922
|
-
const s =
|
|
1923
|
-
return u = [...e, ...s.flat()], {
|
|
1966
|
+
const s = jt(n, t).flatMap((i) => Le(i, e, t)).map((i) => Ee(i));
|
|
1967
|
+
return u = [...e, ...s.flat()], t.clear(), {
|
|
1924
1968
|
removeLines: [...e],
|
|
1925
1969
|
groups: s,
|
|
1926
1970
|
lines: u
|
|
@@ -1934,14 +1978,14 @@ function $(u, t) {
|
|
|
1934
1978
|
n[s] === void 0 && delete n[s];
|
|
1935
1979
|
}), e && (u.userData.drawWindow || (u.userData.drawWindow = []), u.userData.drawWindow.push(...e)), Object.assign(u.userData, n);
|
|
1936
1980
|
}
|
|
1937
|
-
function
|
|
1981
|
+
function qt(u, t) {
|
|
1938
1982
|
const { drawWindow: e, ...n } = t.userData;
|
|
1939
1983
|
e && (u.userData.drawWindow || (u.userData.drawWindow = []), e.forEach((s) => {
|
|
1940
|
-
const i =
|
|
1984
|
+
const i = w.from(s.p);
|
|
1941
1985
|
u.projectPoint(i) && u.userData.drawWindow?.push(s);
|
|
1942
|
-
}),
|
|
1986
|
+
}), X(u)), Object.assign(u.userData, n);
|
|
1943
1987
|
}
|
|
1944
|
-
class
|
|
1988
|
+
class Ae {
|
|
1945
1989
|
static errorAngle = 4;
|
|
1946
1990
|
/** 线段投影分析
|
|
1947
1991
|
* @param index
|
|
@@ -1952,23 +1996,23 @@ class Me {
|
|
|
1952
1996
|
static projectionAnalysis(t, e, n, s) {
|
|
1953
1997
|
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
1954
1998
|
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
1955
|
-
let
|
|
1956
|
-
const
|
|
1957
|
-
return
|
|
1999
|
+
let c;
|
|
2000
|
+
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
2001
|
+
return l.getLength() > h.getLength() ? c = {
|
|
1958
2002
|
target: i,
|
|
1959
2003
|
targetIndex: t,
|
|
1960
2004
|
source: n,
|
|
1961
2005
|
sourceIndex: e,
|
|
1962
|
-
project:
|
|
1963
|
-
project2:
|
|
1964
|
-
} :
|
|
2006
|
+
project: l,
|
|
2007
|
+
project2: h
|
|
2008
|
+
} : c = {
|
|
1965
2009
|
target: n,
|
|
1966
2010
|
targetIndex: e,
|
|
1967
2011
|
source: i,
|
|
1968
2012
|
sourceIndex: t,
|
|
1969
|
-
project:
|
|
1970
|
-
project2:
|
|
1971
|
-
}, !
|
|
2013
|
+
project: h,
|
|
2014
|
+
project2: l
|
|
2015
|
+
}, !c || c.project.getLength() < 0.08 || c.project2.getLength() < 0.08 ? void 0 : c;
|
|
1972
2016
|
}
|
|
1973
2017
|
}
|
|
1974
2018
|
/**
|
|
@@ -1978,14 +2022,14 @@ class Me {
|
|
|
1978
2022
|
* @returns
|
|
1979
2023
|
*/
|
|
1980
2024
|
static complementSide(t, e = 0.4) {
|
|
1981
|
-
const n = t.filter((
|
|
1982
|
-
let r = new
|
|
1983
|
-
n.forEach((
|
|
1984
|
-
const f =
|
|
2025
|
+
const n = t.filter((h) => !h.userData.isDoor && !h.userData.groupId), s = /* @__PURE__ */ new Set(), i = [];
|
|
2026
|
+
let r = new B(I.fromByLineSegment(...n));
|
|
2027
|
+
n.forEach((h, d) => r.insert({ line: h, userData: d })), n.forEach((h, d) => {
|
|
2028
|
+
const f = nt.fromByLineSegment(h, e * 2, !1, -0.01);
|
|
1985
2029
|
r.queryRect(f).map((y) => y.userData).filter((y) => y !== d).forEach((y) => {
|
|
1986
2030
|
try {
|
|
1987
2031
|
if (s.has(`${d}-${y}`) || s.has(`${y}-${d}`)) return;
|
|
1988
|
-
const g = this.projectionAnalysis(y, d,
|
|
2032
|
+
const g = this.projectionAnalysis(y, d, h, n);
|
|
1989
2033
|
g && i.push(g), s.add(`${d}-${y}`);
|
|
1990
2034
|
} catch (g) {
|
|
1991
2035
|
console.log(g);
|
|
@@ -1993,33 +2037,81 @@ class Me {
|
|
|
1993
2037
|
});
|
|
1994
2038
|
});
|
|
1995
2039
|
let o = [];
|
|
1996
|
-
const a = /* @__PURE__ */ new Set(),
|
|
1997
|
-
function h
|
|
1998
|
-
|
|
1999
|
-
const f =
|
|
2000
|
-
f && y.push(f), p && y.push(p), a.add(
|
|
2040
|
+
const a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
2041
|
+
function l(h, d) {
|
|
2042
|
+
c.has(h) || c.set(h, []);
|
|
2043
|
+
const f = h.projectPoint(d.start), p = h.projectPoint(d.end), y = c.get(h);
|
|
2044
|
+
f && y.push(f), p && y.push(p), a.add(h), r.remove(h);
|
|
2001
2045
|
}
|
|
2002
|
-
return i.forEach((
|
|
2003
|
-
const d =
|
|
2046
|
+
return i.forEach((h) => {
|
|
2047
|
+
const d = h.project, f = h.project2, p = h.source, y = h.target;
|
|
2004
2048
|
d.includedAngle(f) > 135 && (f.points = [f.points[1], f.points[0]]);
|
|
2005
|
-
const g = new
|
|
2006
|
-
o.push(g, x),
|
|
2007
|
-
}),
|
|
2008
|
-
const f =
|
|
2049
|
+
const g = new D(d.start.clone(), f.start.clone()), x = new D(d.end.clone(), f.end.clone());
|
|
2050
|
+
o.push(g, x), l(p, d), l(y, f);
|
|
2051
|
+
}), c.forEach((h, d) => {
|
|
2052
|
+
const f = D.clipping(d, h, qt);
|
|
2009
2053
|
t.push(...f);
|
|
2010
|
-
}), t = t.filter((
|
|
2011
|
-
const d = r.queryLineSegment(
|
|
2054
|
+
}), t = t.filter((h) => !a.has(h)), r.clear(), r = new B(I.fromByLineSegment(...t)), t.forEach((h) => h.userData.isDoor || r.insert(h)), o = D.autoMergeLines(o).lines, o = o.filter((h) => h.length() !== 0).map((h) => {
|
|
2055
|
+
const d = r.queryLineSegment(h).filter((p) => !(!p.line.parallel(h) || p.line.projectLineSegment(h).length() === 0)).map((p) => p.line);
|
|
2012
2056
|
if (d.length === 0)
|
|
2013
|
-
return r.insert(
|
|
2014
|
-
const f =
|
|
2057
|
+
return r.insert(h), h;
|
|
2058
|
+
const f = D.mergeLines(...d, h);
|
|
2015
2059
|
return d.forEach((p) => {
|
|
2016
2060
|
$(f, p), r.remove(p), a.add(p);
|
|
2017
2061
|
}), r.insert(f), f;
|
|
2018
|
-
}), t = t.filter((
|
|
2062
|
+
}), t = t.filter((h) => !a.has(h)), t.push(...o), r.clear(), t;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
class be {
|
|
2066
|
+
index = 0;
|
|
2067
|
+
next() {
|
|
2068
|
+
return this.index++;
|
|
2069
|
+
}
|
|
2070
|
+
reset() {
|
|
2071
|
+
this.index = 0;
|
|
2072
|
+
}
|
|
2073
|
+
map = /* @__PURE__ */ new Map();
|
|
2074
|
+
lineMap = /* @__PURE__ */ new Map();
|
|
2075
|
+
getIndex(t) {
|
|
2076
|
+
if (!this.map.has(t)) {
|
|
2077
|
+
const e = this.next();
|
|
2078
|
+
this.map.set(t, e), this.lineMap.set(e, t);
|
|
2079
|
+
}
|
|
2080
|
+
return this.map.get(t);
|
|
2081
|
+
}
|
|
2082
|
+
getLine(t) {
|
|
2083
|
+
return this.lineMap.get(t);
|
|
2019
2084
|
}
|
|
2020
2085
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2086
|
+
class Te {
|
|
2087
|
+
parent;
|
|
2088
|
+
rank;
|
|
2089
|
+
constructor(t) {
|
|
2090
|
+
this.parent = Array(t).fill(0).map((e, n) => n), this.rank = Array(t).fill(1);
|
|
2091
|
+
}
|
|
2092
|
+
// 查找操作,使用路径压缩优化
|
|
2093
|
+
find(t) {
|
|
2094
|
+
return this.parent[t] !== t && (this.parent[t] = this.find(this.parent[t])), this.parent[t];
|
|
2095
|
+
}
|
|
2096
|
+
// 合并操作,使用按秩合并优化
|
|
2097
|
+
union(t, e) {
|
|
2098
|
+
let n = this.find(t), s = this.find(e);
|
|
2099
|
+
n !== s && (this.rank[n] > this.rank[s] ? this.parent[s] = n : this.rank[n] < this.rank[s] ? this.parent[n] = s : (this.parent[s] = n, this.rank[n] += 1));
|
|
2100
|
+
}
|
|
2101
|
+
/** 获取所有集合
|
|
2102
|
+
* @returns
|
|
2103
|
+
*/
|
|
2104
|
+
getAllSets() {
|
|
2105
|
+
const t = new at();
|
|
2106
|
+
for (const e of this.parent.keys()) {
|
|
2107
|
+
const n = this.find(e);
|
|
2108
|
+
t.append(n, e);
|
|
2109
|
+
}
|
|
2110
|
+
return t;
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
function Pe(u, t = 0.1, e) {
|
|
2114
|
+
e || (e = new Y(), u.forEach((i) => {
|
|
2023
2115
|
i.userData.isDoor || i.points.forEach((r) => e?.insert(r, i));
|
|
2024
2116
|
}));
|
|
2025
2117
|
const n = [], s = /* @__PURE__ */ new Set();
|
|
@@ -2028,38 +2120,38 @@ function De(u, t = 0.1, e) {
|
|
|
2028
2120
|
r.userData.isDoor || r.points.forEach((a) => {
|
|
2029
2121
|
if (s.has(a)) return !1;
|
|
2030
2122
|
if (e.queryPoint(a).length > 1) return;
|
|
2031
|
-
const
|
|
2123
|
+
const c = e.queryCircle(a, t).filter((y) => {
|
|
2032
2124
|
if (s.has(y.point)) return !1;
|
|
2033
2125
|
const g = y.userData;
|
|
2034
2126
|
if (g === r || !r.parallel(g, 25) || e.queryPoint(y.point).length > 1) return !1;
|
|
2035
2127
|
const x = a.distance(y.point);
|
|
2036
2128
|
if (x < 1e-3) return !1;
|
|
2037
|
-
const
|
|
2038
|
-
if (180 -
|
|
2129
|
+
const m = a.direction(r.getAnotherPoint(a)), L = y.point.direction(g.getAnotherPoint(y.point));
|
|
2130
|
+
if (180 - m.angleBetween(L, "angle") < 25)
|
|
2039
2131
|
return o.set(y.point, x), !0;
|
|
2040
2132
|
}).sort((y, g) => {
|
|
2041
|
-
const x = o.get(y.point),
|
|
2042
|
-
return x -
|
|
2133
|
+
const x = o.get(y.point), m = o.get(g.point);
|
|
2134
|
+
return x - m;
|
|
2043
2135
|
});
|
|
2044
|
-
if (
|
|
2045
|
-
s.add(a), s.add(
|
|
2046
|
-
const
|
|
2047
|
-
f === 0 && p === 0 ? n.push(new
|
|
2136
|
+
if (c.length === 0) return;
|
|
2137
|
+
s.add(a), s.add(c[0].point);
|
|
2138
|
+
const l = c[0].userData, h = r.projectLineSegment(l), d = l.projectLineSegment(r), f = h.length(), p = d.length();
|
|
2139
|
+
f === 0 && p === 0 ? n.push(new D(a.clone(), c[0].point.clone())) : n.push(new D(h.center, d.center));
|
|
2048
2140
|
});
|
|
2049
2141
|
}
|
|
2050
2142
|
return [...u, ...n];
|
|
2051
2143
|
}
|
|
2052
|
-
function
|
|
2053
|
-
const t = new
|
|
2144
|
+
function Ie(u) {
|
|
2145
|
+
const t = new Y(), e = new B(I.fromByLineSegment(...u)), n = [];
|
|
2054
2146
|
return u.forEach((s) => {
|
|
2055
2147
|
s.userData.isDoor ? n.push(s) : (s.points.forEach((i) => t.insert(i, s)), e.insert(s));
|
|
2056
2148
|
}), n.forEach((s) => {
|
|
2057
2149
|
const i = t.queryPoint(s.start), r = t.queryPoint(s.end);
|
|
2058
2150
|
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;
|
|
2059
|
-
}), u =
|
|
2151
|
+
}), u = Pe(u, 0.4, t), t.clear(), e.clear(), u;
|
|
2060
2152
|
}
|
|
2061
|
-
function
|
|
2062
|
-
const t = new
|
|
2153
|
+
function ve(u) {
|
|
2154
|
+
const t = new B(I.fromByLineSegment(...u));
|
|
2063
2155
|
u.forEach((n) => {
|
|
2064
2156
|
n.userData.isDoor || t.insert({ line: n, userData: void 0 });
|
|
2065
2157
|
});
|
|
@@ -2076,9 +2168,9 @@ function Le(u) {
|
|
|
2076
2168
|
});
|
|
2077
2169
|
e.set(s, i);
|
|
2078
2170
|
}
|
|
2079
|
-
return e;
|
|
2171
|
+
return t.clear(), e;
|
|
2080
2172
|
}
|
|
2081
|
-
function
|
|
2173
|
+
function Re(u, t, e, n = 15) {
|
|
2082
2174
|
const s = [u], i = [], r = [], o = [];
|
|
2083
2175
|
function a(d) {
|
|
2084
2176
|
if (d.userData.isDoor) return r.push(d);
|
|
@@ -2089,7 +2181,7 @@ function Ee(u, t, e, n = 15) {
|
|
|
2089
2181
|
const g = d.center;
|
|
2090
2182
|
return d.start.rotate(g, y), d.end.rotate(g, y), d.userData.isDoor ? r.push(d) : s.push(d), d;
|
|
2091
2183
|
}
|
|
2092
|
-
function
|
|
2184
|
+
function c(d) {
|
|
2093
2185
|
if (d.userData.isDoor) return r.push(d);
|
|
2094
2186
|
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);
|
|
2095
2187
|
let y = p + Math.PI / 2 - f, g = p - Math.PI / 2 - f;
|
|
@@ -2097,133 +2189,139 @@ function Ee(u, t, e, n = 15) {
|
|
|
2097
2189
|
for (; y < -Math.PI; ) y += 2 * Math.PI;
|
|
2098
2190
|
for (; g > Math.PI; ) g -= 2 * Math.PI;
|
|
2099
2191
|
for (; g < -Math.PI; ) g += 2 * Math.PI;
|
|
2100
|
-
const x = Math.abs(y) < Math.abs(g) ? y : g,
|
|
2101
|
-
return d.start.rotate(
|
|
2192
|
+
const x = Math.abs(y) < Math.abs(g) ? y : g, m = d.center;
|
|
2193
|
+
return d.start.rotate(m, x), d.end.rotate(m, x), d.userData.isDoor ? r.push(d) : i.push(d), d;
|
|
2102
2194
|
}
|
|
2103
|
-
function
|
|
2104
|
-
if (p) return
|
|
2105
|
-
d === "parallel" ? a(f) :
|
|
2195
|
+
function l(d, f, p = !1) {
|
|
2196
|
+
if (p) return l(d === "parallel" ? "vertical" : "parallel", f);
|
|
2197
|
+
d === "parallel" ? a(f) : c(f);
|
|
2106
2198
|
}
|
|
2107
|
-
const
|
|
2199
|
+
const h = [];
|
|
2108
2200
|
for (let d = 0; d < t.length; d++) {
|
|
2109
2201
|
const f = t[d];
|
|
2110
2202
|
if (u !== f)
|
|
2111
2203
|
if (f.userData.isWindow && o.push(f), f.parallel(u, n)) a(f);
|
|
2112
|
-
else if (f.vertical(u, n))
|
|
2204
|
+
else if (f.vertical(u, n)) c(f);
|
|
2113
2205
|
else {
|
|
2114
2206
|
const y = e.get(f)?.reduce((g, x) => (x.sourcePoint && (g.has(x.sourcePoint) || g.set(x.sourcePoint, []), g.get(x.sourcePoint)?.push(x)), g), /* @__PURE__ */ new Map());
|
|
2115
|
-
y && y.size > 1 ?
|
|
2207
|
+
y && y.size > 1 ? h.push(() => {
|
|
2116
2208
|
const g = [...y.values()].map(
|
|
2117
|
-
(
|
|
2118
|
-
).map((
|
|
2119
|
-
if (x.length === 1 &&
|
|
2120
|
-
if (x[0] ===
|
|
2209
|
+
(L) => L.map((M) => s.includes(M.line) ? "parallel" : i.includes(M.line) ? "vertical" : null).filter((M) => !!M)
|
|
2210
|
+
).map((L) => [...new Set(L)]), x = g[0], m = g[1];
|
|
2211
|
+
if (x.length === 1 && m.length === 1) {
|
|
2212
|
+
if (x[0] === m[0]) return l(x[0], f, !0);
|
|
2121
2213
|
if (x.length === 1) {
|
|
2122
|
-
if (
|
|
2123
|
-
if (
|
|
2124
|
-
return
|
|
2214
|
+
if (m.includes(x[0])) return l(x[0], f, !0);
|
|
2215
|
+
if (m.length === 1 && x.includes(m[0]))
|
|
2216
|
+
return l(m[0], f, !0);
|
|
2125
2217
|
}
|
|
2126
2218
|
}
|
|
2127
|
-
|
|
2128
|
-
}) :
|
|
2219
|
+
c(f);
|
|
2220
|
+
}) : c(f);
|
|
2129
2221
|
}
|
|
2130
2222
|
}
|
|
2131
|
-
return
|
|
2223
|
+
return h.forEach((d) => d()), { parallelLines: s, verticalLines: i, doorLines: r, windowLines: o };
|
|
2132
2224
|
}
|
|
2133
2225
|
function mt(u, t, e, n, s) {
|
|
2134
2226
|
const i = [], r = /* @__PURE__ */ new Map();
|
|
2135
|
-
u.forEach((
|
|
2136
|
-
const
|
|
2137
|
-
|
|
2138
|
-
}), i.sort((
|
|
2227
|
+
u.forEach((c) => {
|
|
2228
|
+
const l = e.projectPoint(c.start, !1);
|
|
2229
|
+
l && (l.userData = c, i.push(l), r.set(c, l));
|
|
2230
|
+
}), i.sort((c, l) => l.distance(e.start) - c.distance(e.start));
|
|
2139
2231
|
const o = [], a = [];
|
|
2140
|
-
for (let
|
|
2141
|
-
const
|
|
2142
|
-
if (
|
|
2143
|
-
a.push(
|
|
2232
|
+
for (let c = 0; c < i.length; c++) {
|
|
2233
|
+
const l = i[c];
|
|
2234
|
+
if (c === 0) {
|
|
2235
|
+
a.push(l);
|
|
2144
2236
|
continue;
|
|
2145
2237
|
}
|
|
2146
|
-
i[
|
|
2238
|
+
i[c - 1].distance(l) < s || (o.push([...a]), a.length = 0), a.push(l), c === i.length - 1 && o.push(a);
|
|
2147
2239
|
}
|
|
2148
|
-
return o.flatMap((
|
|
2149
|
-
const
|
|
2240
|
+
return o.flatMap((c) => {
|
|
2241
|
+
const l = c.flatMap((p) => {
|
|
2150
2242
|
const y = p.userData;
|
|
2151
2243
|
return y.points.map((g) => {
|
|
2152
2244
|
const x = t.projectPoint(g, !1);
|
|
2153
2245
|
return x.userData = y, x;
|
|
2154
2246
|
});
|
|
2155
2247
|
});
|
|
2156
|
-
|
|
2157
|
-
const
|
|
2248
|
+
l.sort((p, y) => p.distance(t.start) - y.distance(t.start));
|
|
2249
|
+
const h = /* @__PURE__ */ new Map(), d = [];
|
|
2158
2250
|
let f = [];
|
|
2159
|
-
return
|
|
2160
|
-
|
|
2161
|
-
for (const g of
|
|
2162
|
-
d.push(...
|
|
2251
|
+
return l.forEach((p, y) => {
|
|
2252
|
+
h.size === 0 && y > 0 && l[y - 1].distance(p) > n && (f.push([...d]), d.length = 0), h.set(p.userData, (h.get(p.userData) ?? 0) + 1);
|
|
2253
|
+
for (const g of h.values()) if (g !== 2) return;
|
|
2254
|
+
d.push(...h.keys()), h.clear();
|
|
2163
2255
|
}), f.push([...d]), f;
|
|
2164
2256
|
});
|
|
2165
2257
|
}
|
|
2166
2258
|
function wt(u, t, e, n) {
|
|
2167
2259
|
const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = [];
|
|
2168
|
-
u.forEach((
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2260
|
+
u.forEach((p) => {
|
|
2261
|
+
const y = e.projectPoint(p.start, !1);
|
|
2262
|
+
y && (y.userData = p, s.set(p, y), o.push(y)), p.points.forEach((g, x) => {
|
|
2263
|
+
const m = t.projectPoint(g, !1);
|
|
2264
|
+
m && (m.userData = p, x === 0 ? i.set(p, m) : r.set(p, m));
|
|
2173
2265
|
});
|
|
2174
|
-
}), o.sort((
|
|
2175
|
-
const a = o.map((
|
|
2176
|
-
const
|
|
2266
|
+
}), o.sort((p, y) => y.distance(e.start) - p.distance(e.start));
|
|
2267
|
+
const a = o.map((p) => {
|
|
2268
|
+
const y = p.userData, g = i.get(y), x = r.get(y), m = new D(g, x), L = [];
|
|
2177
2269
|
for (let M = 0; M < o.length; M++) {
|
|
2178
|
-
const
|
|
2179
|
-
if (
|
|
2180
|
-
const
|
|
2181
|
-
(
|
|
2270
|
+
const S = o[M];
|
|
2271
|
+
if (p !== S && p.distance(S) < n) {
|
|
2272
|
+
const A = S.userData, E = i.get(A), T = r.get(A);
|
|
2273
|
+
(m.isPointOnSegment(E) || m.isPointOnSegment(T)) && L.push(M);
|
|
2182
2274
|
}
|
|
2183
2275
|
}
|
|
2184
|
-
return
|
|
2276
|
+
return L;
|
|
2185
2277
|
});
|
|
2186
|
-
function
|
|
2187
|
-
if (
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
for (let
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2278
|
+
function c(p, y, g = /* @__PURE__ */ new Set()) {
|
|
2279
|
+
if (g.has(p)) return g;
|
|
2280
|
+
const x = y[p];
|
|
2281
|
+
g.add(p);
|
|
2282
|
+
for (let m = 0; m < x.length; m++) {
|
|
2283
|
+
const L = x[m];
|
|
2284
|
+
c(L, y, g);
|
|
2193
2285
|
}
|
|
2194
|
-
return
|
|
2195
|
-
}
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2286
|
+
return g;
|
|
2287
|
+
}
|
|
2288
|
+
const l = /* @__PURE__ */ new Set();
|
|
2289
|
+
let h = [];
|
|
2290
|
+
for (let p = 0; p < o.length; p++) {
|
|
2291
|
+
if (l.has(p)) continue;
|
|
2292
|
+
const y = c(p, a), g = [];
|
|
2293
|
+
if (y.forEach((x) => {
|
|
2294
|
+
l.add(x), g.push(o[x].userData);
|
|
2295
|
+
}), g.length > 2) {
|
|
2296
|
+
const x = g.map((S) => s.get(S));
|
|
2297
|
+
x.sort((S, A) => A.distance(e.start) - S.distance(e.start));
|
|
2298
|
+
const m = x[0], L = x[x.length - 1];
|
|
2299
|
+
if (m.distance(L) > n) {
|
|
2300
|
+
const S = [...g].sort((R, v) => v.length() - R.length()), A = S[0], E = S[1], T = s.get(A), C = s.get(E), N = A.length(), O = E.length(), q = A.projectLineSegment(E), U = q.length();
|
|
2301
|
+
if (T.distance(C) || O / N > 0.5 && U / O < 0.5) {
|
|
2302
|
+
const R = [A], v = [E];
|
|
2303
|
+
for (let K = 0; K < x.length; K++) {
|
|
2304
|
+
const F = x[K], W = F.userData;
|
|
2305
|
+
if (F === T || F === C) continue;
|
|
2306
|
+
const Ht = E.projectLineSegment(W), Jt = Ht.length();
|
|
2307
|
+
C.distance(F) <= n && Jt / O > 0 ? v.push(W) : R.push(W);
|
|
2215
2308
|
}
|
|
2216
|
-
|
|
2309
|
+
h.push(R, v);
|
|
2217
2310
|
} else {
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2311
|
+
const R = Math.floor(g.length * 0.5);
|
|
2312
|
+
h.push(g.slice(0, R), g.slice(R));
|
|
2220
2313
|
}
|
|
2221
2314
|
continue;
|
|
2222
2315
|
}
|
|
2223
2316
|
}
|
|
2224
|
-
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2317
|
+
h.push(g);
|
|
2318
|
+
}
|
|
2319
|
+
const d = new be(), f = new Te(u.length);
|
|
2320
|
+
return h.forEach((p) => {
|
|
2321
|
+
const y = p.map((g) => d.getIndex(g));
|
|
2322
|
+
for (let g = 1; g < y.length; g++)
|
|
2323
|
+
f.union(y[0], y[g]);
|
|
2324
|
+
}), h = f.getAllSets().valueArray.map((p) => p.map((y) => d.getLine(y))), h;
|
|
2227
2325
|
}
|
|
2228
2326
|
function Mt(u, t) {
|
|
2229
2327
|
function e(i, r = /* @__PURE__ */ new Set()) {
|
|
@@ -2232,8 +2330,8 @@ function Mt(u, t) {
|
|
|
2232
2330
|
const o = t.get(i);
|
|
2233
2331
|
if (!o) return r;
|
|
2234
2332
|
for (let a = 0; a < o.length; a++) {
|
|
2235
|
-
const { line:
|
|
2236
|
-
|
|
2333
|
+
const { line: c, angle: l } = o[a];
|
|
2334
|
+
c.parallel(l, 0.5) && e(c, r);
|
|
2237
2335
|
}
|
|
2238
2336
|
return r;
|
|
2239
2337
|
}
|
|
@@ -2246,12 +2344,12 @@ function Mt(u, t) {
|
|
|
2246
2344
|
}
|
|
2247
2345
|
return s;
|
|
2248
2346
|
}
|
|
2249
|
-
function
|
|
2347
|
+
function Ce(u, t, e, n, s, i) {
|
|
2250
2348
|
const {
|
|
2251
2349
|
principalAxisThreshold: r = 0.3,
|
|
2252
2350
|
crossAxistThreshold: o = 0.06,
|
|
2253
2351
|
groupMethod: a = "principalAndCross"
|
|
2254
|
-
} = i ?? {},
|
|
2352
|
+
} = i ?? {}, c = {
|
|
2255
2353
|
cross: () => [
|
|
2256
2354
|
...wt(u, n, e, o),
|
|
2257
2355
|
...wt(t, e, n, o)
|
|
@@ -2265,9 +2363,9 @@ function Ae(u, t, e, n, s, i) {
|
|
|
2265
2363
|
...Mt(t, s)
|
|
2266
2364
|
]
|
|
2267
2365
|
};
|
|
2268
|
-
return
|
|
2366
|
+
return c[a] ? c[a]() : c.originalInterPoint();
|
|
2269
2367
|
}
|
|
2270
|
-
function
|
|
2368
|
+
function Ne(u, t) {
|
|
2271
2369
|
const e = /* @__PURE__ */ new Set();
|
|
2272
2370
|
return u.forEach((n) => {
|
|
2273
2371
|
const s = /* @__PURE__ */ new Map();
|
|
@@ -2283,65 +2381,65 @@ function be(u, t) {
|
|
|
2283
2381
|
}
|
|
2284
2382
|
}), u.map((n) => n.filter((s) => !e.has(s)));
|
|
2285
2383
|
}
|
|
2286
|
-
function
|
|
2384
|
+
function Be(u, t = 0.1, e) {
|
|
2287
2385
|
const { fittingMethod: n = "average" } = e ?? {};
|
|
2288
2386
|
return u.map((s) => {
|
|
2289
2387
|
if (s.length === 0) return;
|
|
2290
2388
|
if (s.length === 1) return s[0];
|
|
2291
2389
|
const i = [];
|
|
2292
|
-
s.forEach((
|
|
2293
|
-
const r = n === "average" ?
|
|
2390
|
+
s.forEach((h) => i.push(h.start.clone(), h.end.clone()));
|
|
2391
|
+
const r = n === "average" ? D.mergeLines(...s) : D.mergeLinesByMaxlength(...s);
|
|
2294
2392
|
r.userData.rooftopPz = Math.min(
|
|
2295
|
-
...s.map((
|
|
2296
|
-
const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } =
|
|
2393
|
+
...s.map((h) => {
|
|
2394
|
+
const { drawDoorData: d, drawWindow: f, rooftopPz: p, ...y } = h.userData;
|
|
2297
2395
|
return Object.assign(r.userData, y), p ?? 1 / 0;
|
|
2298
2396
|
})
|
|
2299
2397
|
), r.userData.rooftopPz === 1 / 0 && (r.userData.rooftopPz = 0);
|
|
2300
2398
|
let o = 1 / 0, a = -1 / 0;
|
|
2301
|
-
const
|
|
2302
|
-
o = 1 / 0, a = -1 / 0, i.forEach((
|
|
2303
|
-
const d =
|
|
2399
|
+
const c = s[0].normal().normalize();
|
|
2400
|
+
o = 1 / 0, a = -1 / 0, i.forEach((h) => {
|
|
2401
|
+
const d = h.x * c.x + h.y * c.y;
|
|
2304
2402
|
o = Math.min(o, d), a = Math.max(a, d);
|
|
2305
2403
|
});
|
|
2306
|
-
const
|
|
2307
|
-
return
|
|
2404
|
+
const l = a - o;
|
|
2405
|
+
return l >= t && (r.userData.wallWidth = l), s.forEach((h) => h.userData.fittedLine = r), r;
|
|
2308
2406
|
}).filter((s) => !!s);
|
|
2309
2407
|
}
|
|
2310
|
-
function
|
|
2311
|
-
const { snapThreshold: n = 0.2 } = e ?? {}, s = new
|
|
2408
|
+
function Oe(u, t, e) {
|
|
2409
|
+
const { snapThreshold: n = 0.2 } = e ?? {}, s = new Y(), i = new B(I.fromByLineSegment(...u)), r = new D(), o = /* @__PURE__ */ new Map();
|
|
2312
2410
|
u.forEach((d) => {
|
|
2313
2411
|
d.userData.isDoor || (i.insert(d), d.points.forEach((f) => s.insert(f, d)));
|
|
2314
2412
|
});
|
|
2315
2413
|
function a(d, f) {
|
|
2316
2414
|
o.has(d) || o.set(d, []), o.get(d)?.push(f);
|
|
2317
2415
|
}
|
|
2318
|
-
function
|
|
2416
|
+
function c(d, f) {
|
|
2319
2417
|
if (i.queryPoint(d).length > 1) return;
|
|
2320
2418
|
const p = f.direction().multiplyScalar(n);
|
|
2321
2419
|
r.set(d, d), r.start.add(p), r.end.add(p.multiplyScalar(-1));
|
|
2322
2420
|
const y = /* @__PURE__ */ new Map(), g = i.queryLineSegment(r).filter((x) => x.line !== f).map((x) => {
|
|
2323
|
-
const
|
|
2324
|
-
return y.set(x.line,
|
|
2325
|
-
}).sort((x,
|
|
2326
|
-
const
|
|
2327
|
-
return
|
|
2421
|
+
const m = x.line.getIntersection(r);
|
|
2422
|
+
return y.set(x.line, m), x.line;
|
|
2423
|
+
}).sort((x, m) => {
|
|
2424
|
+
const L = y.get(x), M = y.get(m);
|
|
2425
|
+
return L && M ? L.distance(d) - M.distance(d) : 0;
|
|
2328
2426
|
});
|
|
2329
2427
|
if (g.length) return y.get(g[0]);
|
|
2330
2428
|
}
|
|
2331
|
-
function
|
|
2332
|
-
let p =
|
|
2429
|
+
function l(d, f) {
|
|
2430
|
+
let p = c(d, f);
|
|
2333
2431
|
if (p)
|
|
2334
|
-
return a(f, new
|
|
2335
|
-
if (s.queryPoint(d).filter((
|
|
2336
|
-
const g = s.queryCircle(d, n).filter((
|
|
2432
|
+
return a(f, new D(d.clone(), p.clone()));
|
|
2433
|
+
if (s.queryPoint(d).filter((L) => L.userData !== f).length !== 0 || i.queryCircle(d, 1e-3).filter((L) => L.line !== f).length > 0) return;
|
|
2434
|
+
const g = s.queryCircle(d, n).filter((L) => L.userData !== f && L.userData?.vertical(f)).sort((L, M) => L.point.distance(d) - M.point.distance(d));
|
|
2337
2435
|
if (!g.length) return;
|
|
2338
|
-
const x = g[0],
|
|
2339
|
-
if (
|
|
2340
|
-
const
|
|
2341
|
-
a(f, new
|
|
2436
|
+
const x = g[0], m = x.userData?.projectPoint(d, !1);
|
|
2437
|
+
if (m) {
|
|
2438
|
+
const L = x.userData;
|
|
2439
|
+
a(f, new D(d.clone(), m.clone())), a(L, new D(x.point.clone(), m.clone()));
|
|
2342
2440
|
}
|
|
2343
2441
|
}
|
|
2344
|
-
function
|
|
2442
|
+
function h(d, f, p) {
|
|
2345
2443
|
if (p.length) {
|
|
2346
2444
|
const y = p.map(({ line: g }) => {
|
|
2347
2445
|
if (g.userData.fittedLine && (g = g.userData.fittedLine), g.vertical(d)) {
|
|
@@ -2353,31 +2451,31 @@ function Pe(u, t, e) {
|
|
|
2353
2451
|
}
|
|
2354
2452
|
}
|
|
2355
2453
|
for (let d = 0; d < u.length; d++) {
|
|
2356
|
-
const f = u[d], y = (t.get(f) ?? []).reduce((
|
|
2357
|
-
if (!s.queryPoint(
|
|
2358
|
-
const
|
|
2359
|
-
if (
|
|
2360
|
-
|
|
2454
|
+
const f = u[d], y = (t.get(f) ?? []).reduce((m, L) => (L.sourcePoint === f.start ? m[0].push(L) : m[1].push(L), m), [[], []]), [g, x] = f.points.map((m, L) => {
|
|
2455
|
+
if (!s.queryPoint(m, !0).length) {
|
|
2456
|
+
const M = h(f, m, y[L]);
|
|
2457
|
+
if (M)
|
|
2458
|
+
m.copy(M), s.update(m), i.update(f);
|
|
2361
2459
|
else return !1;
|
|
2362
2460
|
}
|
|
2363
2461
|
return !0;
|
|
2364
2462
|
});
|
|
2365
|
-
g ||
|
|
2463
|
+
g || l(f.start, f), x || l(f.end, f);
|
|
2366
2464
|
}
|
|
2367
2465
|
return o.forEach((d, f) => {
|
|
2368
|
-
const p =
|
|
2466
|
+
const p = D.mergeLines(f, ...d);
|
|
2369
2467
|
f.set(p.start, p.end);
|
|
2370
|
-
}), u;
|
|
2468
|
+
}), s.clear(), i.clear(), u;
|
|
2371
2469
|
}
|
|
2372
|
-
function
|
|
2470
|
+
function je(u) {
|
|
2373
2471
|
const t = /* @__PURE__ */ new Set();
|
|
2374
2472
|
for (let e = 0; e < u.length; e++) {
|
|
2375
2473
|
const n = u[e], s = n.userData.fittedLine;
|
|
2376
|
-
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) :
|
|
2474
|
+
s ? (t.add(s), s.userData.isWindow = !0, s.userData.drawWindow || (s.userData.drawWindow = []), s.userData.drawWindow.push(...n.userData.drawWindow ?? [])) : X(n);
|
|
2377
2475
|
}
|
|
2378
|
-
t.forEach((e) =>
|
|
2476
|
+
t.forEach((e) => X(e));
|
|
2379
2477
|
}
|
|
2380
|
-
function
|
|
2478
|
+
function Fe(u) {
|
|
2381
2479
|
for (let t = 0; t < u.length; t++) {
|
|
2382
2480
|
const e = u[t];
|
|
2383
2481
|
let { endIntersection: n, startIntersection: s } = e.userData;
|
|
@@ -2399,25 +2497,25 @@ function ve(u) {
|
|
|
2399
2497
|
return u;
|
|
2400
2498
|
}
|
|
2401
2499
|
function Dt(u, t = 0.01) {
|
|
2402
|
-
const e = new
|
|
2500
|
+
const e = new Y();
|
|
2403
2501
|
return u.forEach((n) => n.points.forEach((s) => e.insert(s, n))), u = u.filter((n) => {
|
|
2404
2502
|
if (n.length() <= t) {
|
|
2405
2503
|
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;
|
|
2406
2504
|
if (s || i) return !1;
|
|
2407
2505
|
}
|
|
2408
2506
|
return !0;
|
|
2409
|
-
}), u =
|
|
2410
|
-
s.forEach((i) => $(n, i)),
|
|
2411
|
-
}), u;
|
|
2507
|
+
}), u = D.brokenLineMerging(u, (n, s) => {
|
|
2508
|
+
s.forEach((i) => $(n, i)), X(n);
|
|
2509
|
+
}), e.clear(), u;
|
|
2412
2510
|
}
|
|
2413
|
-
function
|
|
2414
|
-
const { lines: t, groups: e, removeLines: n } =
|
|
2511
|
+
function qe(u) {
|
|
2512
|
+
const { lines: t, groups: e, removeLines: n } = Ft(u);
|
|
2415
2513
|
return e.forEach((s) => {
|
|
2416
2514
|
const i = tt();
|
|
2417
2515
|
s.forEach((r) => Object.assign(r.userData, { groupId: i, groupType: "doubleWall" }));
|
|
2418
2516
|
}), n.forEach((s) => Object.assign(s.userData, { groupId: "default", groupType: "wall" })), u = t, u;
|
|
2419
2517
|
}
|
|
2420
|
-
class
|
|
2518
|
+
class Gt {
|
|
2421
2519
|
/**
|
|
2422
2520
|
* 轴对齐垂直修正
|
|
2423
2521
|
* @param lines 待调整线段组
|
|
@@ -2426,52 +2524,52 @@ class qt {
|
|
|
2426
2524
|
*/
|
|
2427
2525
|
static correction(t, e, n) {
|
|
2428
2526
|
const s = t.indexOf(e);
|
|
2429
|
-
t = t.map((
|
|
2430
|
-
const i =
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
), p = new
|
|
2434
|
-
|
|
2435
|
-
|
|
2527
|
+
t = t.map((L) => L.clone()), e = s > -1 ? t[s] : e, t = Ie(t);
|
|
2528
|
+
const i = ve(t), { parallelLines: r, verticalLines: o, doorLines: a, windowLines: c } = Re(e, t, i, 25), l = e.normal(), h = e.center, d = e.direction(), f = new D(
|
|
2529
|
+
h.clone().add(l.clone().multiplyScalar(-1e3)),
|
|
2530
|
+
h.clone().add(l.clone().multiplyScalar(1e3))
|
|
2531
|
+
), p = new D(
|
|
2532
|
+
h.clone().add(d.clone().multiplyScalar(-1e3)),
|
|
2533
|
+
h.clone().add(d.clone().multiplyScalar(1e3))
|
|
2436
2534
|
);
|
|
2437
|
-
let y =
|
|
2438
|
-
y =
|
|
2439
|
-
let g =
|
|
2440
|
-
g =
|
|
2441
|
-
const { removeClosedLine: x = !0, wallGroup:
|
|
2442
|
-
return x && (g =
|
|
2535
|
+
let y = Ce(r, o, f, p, i, n);
|
|
2536
|
+
y = Ne(y, i);
|
|
2537
|
+
let g = Be(y, 0.1, n);
|
|
2538
|
+
g = D.brokenLineMerging(g, $), X(...g), g = Oe(g, i, n), je(c), g = ft(g, 1e-9), g = Dt(g, 0.15);
|
|
2539
|
+
const { removeClosedLine: x = !0, wallGroup: m = !0 } = n ?? {};
|
|
2540
|
+
return x && (g = Ft(g).lines, m && (g = Ae.complementSide(g), g = D.brokenLineMerging(g, $), X(...g), g = ft(g, 1e-9), g = qe(g)), g = Dt(g, 0.15)), Fe(a), g.push(...a), g;
|
|
2443
2541
|
}
|
|
2444
2542
|
}
|
|
2445
|
-
const
|
|
2446
|
-
new
|
|
2447
|
-
new
|
|
2543
|
+
const Ge = new D(
|
|
2544
|
+
new w(0, 0),
|
|
2545
|
+
new w(0, 1)
|
|
2448
2546
|
);
|
|
2449
|
-
function
|
|
2547
|
+
function Ue(u) {
|
|
2450
2548
|
const t = [...u].sort((i, r) => r.length() - i.length()).slice(0, 20), e = t.map((i) => {
|
|
2451
|
-
let r = parseInt(
|
|
2549
|
+
let r = parseInt(Ge.includedAngle(i) + "");
|
|
2452
2550
|
return r > 90 && (r = 180 - r), r;
|
|
2453
2551
|
}), n = /* @__PURE__ */ new Map();
|
|
2454
2552
|
return e.forEach((i, r) => {
|
|
2455
2553
|
n.has(i) || n.set(i, []), n.get(i)?.push(t[r]);
|
|
2456
2554
|
}), [...n.values()].sort((i, r) => r.length - i.length)[0].sort((i, r) => r.length() - i.length())[0];
|
|
2457
2555
|
}
|
|
2458
|
-
function
|
|
2556
|
+
function ze(u) {
|
|
2459
2557
|
let t = [], e = -1;
|
|
2460
2558
|
const n = [];
|
|
2461
2559
|
return u.forEach(({ start: i, end: r, ...o }, a) => {
|
|
2462
2560
|
n.push(i.z ?? 0, r.z ?? 0);
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2465
|
-
|
|
2561
|
+
const c = new D(
|
|
2562
|
+
w.from(i),
|
|
2563
|
+
w.from(r)
|
|
2466
2564
|
);
|
|
2467
|
-
|
|
2565
|
+
c.userData = o, t.push(c), o.isVerticalReferenceLine && (e = a);
|
|
2468
2566
|
}), {
|
|
2469
2567
|
originalZAverage: n.reduce((i, r) => i + r, 0) / n.length,
|
|
2470
2568
|
lineSegments: t,
|
|
2471
2569
|
verticalReferenceIndex: e
|
|
2472
2570
|
};
|
|
2473
2571
|
}
|
|
2474
|
-
const
|
|
2572
|
+
const _e = {
|
|
2475
2573
|
Unitless: 1,
|
|
2476
2574
|
// 无单位,1米 = 1(无单位)
|
|
2477
2575
|
Inches: 39.37007874015748,
|
|
@@ -2515,27 +2613,27 @@ const Oe = {
|
|
|
2515
2613
|
Parsecs: 3240779289666404e-32
|
|
2516
2614
|
// 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
|
|
2517
2615
|
};
|
|
2518
|
-
function
|
|
2616
|
+
function Lt(u) {
|
|
2519
2617
|
const t = [];
|
|
2520
2618
|
for (let e = 0; e < u.length; e++)
|
|
2521
|
-
t.push(new
|
|
2619
|
+
t.push(new D(
|
|
2522
2620
|
u[e].clone(),
|
|
2523
2621
|
u[(e + 1) % u.length].clone()
|
|
2524
2622
|
));
|
|
2525
2623
|
return t;
|
|
2526
2624
|
}
|
|
2527
|
-
function
|
|
2625
|
+
function St(u) {
|
|
2528
2626
|
return u.flatMap((t, e) => (e === u.length - 1 && [...t.points, u[0].points[0]], [t.points[0]]));
|
|
2529
2627
|
}
|
|
2530
|
-
class k extends
|
|
2628
|
+
class k extends G {
|
|
2531
2629
|
static name = "Dxf";
|
|
2532
2630
|
shortLine = 0.04;
|
|
2533
2631
|
width = 0.04;
|
|
2534
2632
|
scale = 1;
|
|
2535
2633
|
originalData = [];
|
|
2536
2634
|
data = [];
|
|
2537
|
-
originalBox = new
|
|
2538
|
-
box = new
|
|
2635
|
+
originalBox = new I(0, 0, 0, 0);
|
|
2636
|
+
box = new I(0, 0, 0, 0);
|
|
2539
2637
|
pointsGroups = [];
|
|
2540
2638
|
wallsGroup = [];
|
|
2541
2639
|
doors = [];
|
|
@@ -2572,9 +2670,9 @@ class k extends z {
|
|
|
2572
2670
|
* @param data
|
|
2573
2671
|
*/
|
|
2574
2672
|
preprocessing(t) {
|
|
2575
|
-
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } =
|
|
2673
|
+
let { lineSegments: e, verticalReferenceIndex: n, originalZAverage: s } = ze(t);
|
|
2576
2674
|
if (this.originalZAverage = s, n === -1) {
|
|
2577
|
-
const r =
|
|
2675
|
+
const r = Ue(e);
|
|
2578
2676
|
n = e.indexOf(r);
|
|
2579
2677
|
}
|
|
2580
2678
|
const i = e[n];
|
|
@@ -2582,9 +2680,9 @@ class k extends z {
|
|
|
2582
2680
|
type: "preprocessing",
|
|
2583
2681
|
data: t,
|
|
2584
2682
|
setData(r) {
|
|
2585
|
-
e = r.map(({ start: o, end: a, ...
|
|
2586
|
-
const
|
|
2587
|
-
return
|
|
2683
|
+
e = r.map(({ start: o, end: a, ...c }) => {
|
|
2684
|
+
const l = new D(w.from(o), w.from(a));
|
|
2685
|
+
return l.userData = c, l;
|
|
2588
2686
|
}), t = r;
|
|
2589
2687
|
}
|
|
2590
2688
|
}), { lineSegments: e, data: t };
|
|
@@ -2614,15 +2712,15 @@ class k extends z {
|
|
|
2614
2712
|
t = i.data, this.lineSegments = i.lineSegments, this.originalData = t;
|
|
2615
2713
|
}
|
|
2616
2714
|
const s = [];
|
|
2617
|
-
this.data = t.map(({ start: i, end: r, insetionArr: o, isDoor: a = !1 },
|
|
2715
|
+
this.data = t.map(({ start: i, end: r, insetionArr: o, isDoor: a = !1 }, c) => {
|
|
2618
2716
|
s.push(i.z ?? 0, r.z ?? 0);
|
|
2619
|
-
const
|
|
2717
|
+
const l = this.lineSegments[c];
|
|
2620
2718
|
return [
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
(o ?? []).map((
|
|
2719
|
+
l.points[0],
|
|
2720
|
+
l.points[1],
|
|
2721
|
+
(o ?? []).map((h) => h.index),
|
|
2624
2722
|
a,
|
|
2625
|
-
|
|
2723
|
+
c
|
|
2626
2724
|
];
|
|
2627
2725
|
}), this.originalZAverage = s.reduce((i, r) => i + r, 0) / s.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
|
|
2628
2726
|
type: "setDta",
|
|
@@ -2640,10 +2738,10 @@ class k extends z {
|
|
|
2640
2738
|
createGroups() {
|
|
2641
2739
|
const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), i = (r, o, a = -1) => {
|
|
2642
2740
|
if (!this.data[r]) return;
|
|
2643
|
-
const [l, h,
|
|
2741
|
+
const [c, l, h, d] = this.data[r];
|
|
2644
2742
|
if (e.add(r), d)
|
|
2645
2743
|
return s.has(r) || s.set(r, []), s.get(r)?.push(a), n.add(this.data[r]);
|
|
2646
|
-
o.push([
|
|
2744
|
+
o.push([c, l]), h.forEach((f) => {
|
|
2647
2745
|
e.has(f) || i(f, o, r);
|
|
2648
2746
|
});
|
|
2649
2747
|
};
|
|
@@ -2672,10 +2770,10 @@ class k extends z {
|
|
|
2672
2770
|
function n(i, r) {
|
|
2673
2771
|
const [o, a] = t[i];
|
|
2674
2772
|
e[i] = !0, r.push(a);
|
|
2675
|
-
for (let
|
|
2676
|
-
const [
|
|
2677
|
-
if (!e[
|
|
2678
|
-
return n(
|
|
2773
|
+
for (let c = 0; c < t.length; c++) {
|
|
2774
|
+
const [l, h] = t[c];
|
|
2775
|
+
if (!e[c] && Math.abs(a.x - l.x) < 1e-6 && Math.abs(a.y - l.y) < 1e-6)
|
|
2776
|
+
return n(c, r);
|
|
2679
2777
|
}
|
|
2680
2778
|
}
|
|
2681
2779
|
const s = [];
|
|
@@ -2713,8 +2811,8 @@ class k extends z {
|
|
|
2713
2811
|
if (s.distance(i) < this.width * 0.5) {
|
|
2714
2812
|
let o = 0;
|
|
2715
2813
|
for (let a = n + 1; a < t.length; a++) {
|
|
2716
|
-
const
|
|
2717
|
-
if (
|
|
2814
|
+
const c = t[a - 1], l = t[a];
|
|
2815
|
+
if (c.distance(l) < this.width * 0.8) o++;
|
|
2718
2816
|
else break;
|
|
2719
2817
|
}
|
|
2720
2818
|
o === 0 && n + o === t.length - 1 || n == 1 && o === 1 || (o === 3 ? (e.push(t[n + 1]), n += o) : o === 5 ? (e.push(t[n + 2]), n += o) : e.push(i));
|
|
@@ -2736,7 +2834,7 @@ class k extends z {
|
|
|
2736
2834
|
break;
|
|
2737
2835
|
}
|
|
2738
2836
|
}
|
|
2739
|
-
const e = this.mergeSameDirectionLine(
|
|
2837
|
+
const e = this.mergeSameDirectionLine(Lt(t)), n = [e[0]];
|
|
2740
2838
|
for (let s = 1; s < e.length; s++) {
|
|
2741
2839
|
const i = e[s], r = e[(e.length + s - 1) % e.length];
|
|
2742
2840
|
if (i.length() > this.width * 0.9) {
|
|
@@ -2751,7 +2849,7 @@ class k extends z {
|
|
|
2751
2849
|
const a = e[s + 2];
|
|
2752
2850
|
a && r.includedAngle(a) < 2 ? (s = s + 2, n.push(a)) : n.push(i);
|
|
2753
2851
|
}
|
|
2754
|
-
return n.length > 3 ?
|
|
2852
|
+
return n.length > 3 ? St(this.mergeSameDirectionLine(n)) : [];
|
|
2755
2853
|
}
|
|
2756
2854
|
/**
|
|
2757
2855
|
* 移除短线段
|
|
@@ -2759,35 +2857,35 @@ class k extends z {
|
|
|
2759
2857
|
* @param path
|
|
2760
2858
|
*/
|
|
2761
2859
|
removeShortLine(t, e = this.shortLine) {
|
|
2762
|
-
const n =
|
|
2860
|
+
const n = Lt(t), s = [], i = Math.PI / 180;
|
|
2763
2861
|
for (let r = 0; r < n.length; r++) {
|
|
2764
|
-
const o = n[r], a = o.length(),
|
|
2862
|
+
const o = n[r], a = o.length(), c = r;
|
|
2765
2863
|
if (a > e || s.length === 0) {
|
|
2766
2864
|
s.push(o);
|
|
2767
2865
|
continue;
|
|
2768
2866
|
}
|
|
2769
|
-
let
|
|
2770
|
-
const
|
|
2867
|
+
let l = n[++r];
|
|
2868
|
+
const h = s[s.length - 1], d = h.direction();
|
|
2771
2869
|
for (; r < n.length; ) {
|
|
2772
|
-
const p = d.angleBetween(
|
|
2773
|
-
if (
|
|
2774
|
-
|
|
2870
|
+
const p = d.angleBetween(l.direction()) / i;
|
|
2871
|
+
if (l.length() <= e || p < 4 || p > 176)
|
|
2872
|
+
l = n[++r];
|
|
2775
2873
|
else break;
|
|
2776
2874
|
}
|
|
2777
|
-
if (!
|
|
2875
|
+
if (!l) continue;
|
|
2778
2876
|
const f = n[r - 1];
|
|
2779
|
-
if (
|
|
2780
|
-
const p =
|
|
2877
|
+
if (h.length() > f.length()) {
|
|
2878
|
+
const p = h.getIntersection(l);
|
|
2781
2879
|
if (p) {
|
|
2782
|
-
const y =
|
|
2783
|
-
|
|
2880
|
+
const y = h.points[1].clone(), g = l.points[0].clone();
|
|
2881
|
+
h.points[1].copy(p), l.points[0].copy(p), h.length() < this.width ? (h.points[1].copy(y), l.points[0].copy(y)) : l.length() < this.width && (h.points[1].copy(g), l.points[0].copy(g));
|
|
2784
2882
|
} else
|
|
2785
|
-
|
|
2786
|
-
s.push(
|
|
2883
|
+
h.points[1].copy(l.points[0]);
|
|
2884
|
+
s.push(l);
|
|
2787
2885
|
} else
|
|
2788
|
-
r =
|
|
2886
|
+
r = c;
|
|
2789
2887
|
}
|
|
2790
|
-
return s.length > 3 ?
|
|
2888
|
+
return s.length > 3 ? St(s) : [];
|
|
2791
2889
|
}
|
|
2792
2890
|
/** 线偏移
|
|
2793
2891
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
@@ -2796,12 +2894,12 @@ class k extends z {
|
|
|
2796
2894
|
let s = new xt.Paths();
|
|
2797
2895
|
const i = new xt.ClipperOffset(20, 0.25);
|
|
2798
2896
|
return this.pointsGroups.forEach((r) => {
|
|
2799
|
-
const o = this.lineTopology(r).map((a) => a.map((
|
|
2897
|
+
const o = this.lineTopology(r).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
|
|
2800
2898
|
i.AddPaths(o, e, t);
|
|
2801
2899
|
}), i.Execute(s, this.width / 2 * n), this.wallsGroup = s.map((r) => {
|
|
2802
|
-
let o = r.map((a) =>
|
|
2900
|
+
let o = r.map((a) => w.from(a).divisionScalar(n));
|
|
2803
2901
|
return o = this.lineSegmentStraightening(o), t == k.EndType.etOpenSquare && (o = this.squareRemoveBurr(o)), o;
|
|
2804
|
-
}).filter((r) => r.length > 4 ||
|
|
2902
|
+
}).filter((r) => r.length > 4 || Ot(r) > 0.2), this.dispatchEvent({
|
|
2805
2903
|
type: "lineOffset",
|
|
2806
2904
|
wallsGroup: this.wallsGroup
|
|
2807
2905
|
}), this.wallsGroup;
|
|
@@ -2812,7 +2910,7 @@ class k extends z {
|
|
|
2812
2910
|
axisAlignCorr(t) {
|
|
2813
2911
|
if (this.verticalReferenceLine) {
|
|
2814
2912
|
this.doorLineSegment;
|
|
2815
|
-
const e = this.getLineSegments(), n = performance.now(), s =
|
|
2913
|
+
const e = this.getLineSegments(), n = performance.now(), s = Gt.correction(e, this.verticalReferenceLine, t);
|
|
2816
2914
|
console.log("垂直纠正消耗时间:", (performance.now() - n).toFixed(2), "ms", "处理线段数量:", e.length);
|
|
2817
2915
|
const i = et(s);
|
|
2818
2916
|
this.set(i);
|
|
@@ -2849,10 +2947,10 @@ class k extends z {
|
|
|
2849
2947
|
*/
|
|
2850
2948
|
getArcAngleRange(t, e, n) {
|
|
2851
2949
|
const s = e.x - t.x, i = e.y - t.y, r = n.x - t.x, o = n.y - t.y;
|
|
2852
|
-
let a = Math.atan2(i, s),
|
|
2853
|
-
a = a < 0 ? a + 2 * Math.PI : a,
|
|
2854
|
-
let
|
|
2855
|
-
return Math.abs(
|
|
2950
|
+
let a = Math.atan2(i, s), c = Math.atan2(o, r);
|
|
2951
|
+
a = a < 0 ? a + 2 * Math.PI : a, c = c < 0 ? c + 2 * Math.PI : c;
|
|
2952
|
+
let l, h;
|
|
2953
|
+
return Math.abs(c - a) <= Math.PI ? (l = Math.min(a, c), h = Math.max(a, c)) : (l = Math.max(a, c), h = Math.min(a, c) + 2 * Math.PI), [l / (Math.PI / 180), h / (Math.PI / 180)];
|
|
2856
2954
|
}
|
|
2857
2955
|
/**
|
|
2858
2956
|
* 线段数据转为原始json数据
|
|
@@ -2864,7 +2962,7 @@ class k extends z {
|
|
|
2864
2962
|
* 转为绘制数据
|
|
2865
2963
|
*/
|
|
2866
2964
|
toDrawDataJson(t = "Millimeters") {
|
|
2867
|
-
const e =
|
|
2965
|
+
const e = _e[t], n = {
|
|
2868
2966
|
unit: t,
|
|
2869
2967
|
line: [],
|
|
2870
2968
|
arc: [],
|
|
@@ -2875,62 +2973,62 @@ class k extends z {
|
|
|
2875
2973
|
scale: e
|
|
2876
2974
|
};
|
|
2877
2975
|
let s = "white";
|
|
2878
|
-
function i(
|
|
2879
|
-
n.line.push([
|
|
2976
|
+
function i(c, l) {
|
|
2977
|
+
n.line.push([c.x * e, c.y * e, l.x * e, l.y * e, s]);
|
|
2880
2978
|
}
|
|
2881
|
-
function r(l, h,
|
|
2979
|
+
function r(c, l, h, d) {
|
|
2882
2980
|
n.arc.push([
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2981
|
+
c.x * e,
|
|
2982
|
+
c.y * e,
|
|
2983
|
+
l * e,
|
|
2984
|
+
h,
|
|
2887
2985
|
d,
|
|
2888
2986
|
s
|
|
2889
2987
|
]);
|
|
2890
2988
|
}
|
|
2891
|
-
for (let
|
|
2892
|
-
const
|
|
2893
|
-
if (
|
|
2894
|
-
n.dimensionLine.push([
|
|
2989
|
+
for (let c = 0; c < this.originalData.length; c++) {
|
|
2990
|
+
const l = this.originalData[c];
|
|
2991
|
+
if (l.isVerticalReferenceLine) {
|
|
2992
|
+
n.dimensionLine.push([l.start.x * e, l.start.y * e, l.end.x * e, l.end.y * e]);
|
|
2895
2993
|
break;
|
|
2896
2994
|
}
|
|
2897
2995
|
}
|
|
2898
|
-
this.wallsGroup.forEach((
|
|
2899
|
-
for (let
|
|
2900
|
-
const
|
|
2901
|
-
i(
|
|
2996
|
+
this.wallsGroup.forEach((c) => {
|
|
2997
|
+
for (let l = 0; l < c.length; l++) {
|
|
2998
|
+
const h = c[l], d = l === c.length - 1 ? 0 : l + 1, f = c[d];
|
|
2999
|
+
i(h, f);
|
|
2902
3000
|
}
|
|
2903
3001
|
});
|
|
2904
3002
|
const o = this.width * 0.2, a = [];
|
|
2905
|
-
return this.doorLineSegment.forEach((
|
|
2906
|
-
if (
|
|
2907
|
-
const
|
|
2908
|
-
if (s = "cyan",
|
|
2909
|
-
|
|
2910
|
-
const
|
|
2911
|
-
let d = new
|
|
2912
|
-
|
|
2913
|
-
|
|
3003
|
+
return this.doorLineSegment.forEach((c) => {
|
|
3004
|
+
if (c.length() < 0.4) return;
|
|
3005
|
+
const l = c.clone().expansion(-this.width * 0.5);
|
|
3006
|
+
if (s = "cyan", l.length() < 1.2) {
|
|
3007
|
+
l.expansion(-o * 0.5);
|
|
3008
|
+
const h = c.normal();
|
|
3009
|
+
let d = new D(
|
|
3010
|
+
l.start.clone(),
|
|
3011
|
+
l.start.clone().add(h.clone().multiplyScalar(l.length()))
|
|
2914
3012
|
);
|
|
2915
|
-
const f = d.clone().directionMove(d.normal(),
|
|
2916
|
-
for (let
|
|
2917
|
-
if (a[
|
|
2918
|
-
d = new
|
|
2919
|
-
|
|
2920
|
-
|
|
3013
|
+
const f = d.clone().directionMove(d.normal(), l.length() * -0.5).expandToRectangle(l.length(), "bothSides");
|
|
3014
|
+
for (let M = 0; M < a.length; M++)
|
|
3015
|
+
if (a[M].intersectRectangle(f)) {
|
|
3016
|
+
d = new D(
|
|
3017
|
+
l.start.clone(),
|
|
3018
|
+
l.start.clone().add(h.clone().multiplyScalar(-l.length()))
|
|
2921
3019
|
);
|
|
2922
3020
|
break;
|
|
2923
3021
|
}
|
|
2924
|
-
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((
|
|
2925
|
-
const p =
|
|
2926
|
-
r(x, g, Math.min(
|
|
3022
|
+
d.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((M, S) => i(M, S));
|
|
3023
|
+
const p = l.length(), y = d.length(), g = (p ** 2 + y ** 2) / (2 * y), x = d.end.clone().add(d.direction().multiplyScalar(-g)), [m, L] = this.getArcAngleRange(x, l.end, d.end);
|
|
3024
|
+
r(x, g, Math.min(m, L), Math.max(m, L)), a.push(f);
|
|
2927
3025
|
} else
|
|
2928
|
-
|
|
2929
|
-
}), s = "yellow", this.lineSegments.forEach((
|
|
2930
|
-
if (!
|
|
2931
|
-
Array.isArray(
|
|
2932
|
-
const { p:
|
|
2933
|
-
i(g.start, g.end), g.expandToRectangle(this.width, "bothSides").path2D((x,
|
|
3026
|
+
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));
|
|
3027
|
+
}), s = "yellow", this.lineSegments.forEach((c) => {
|
|
3028
|
+
if (!c.userData.isWindow) return !1;
|
|
3029
|
+
Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((l) => {
|
|
3030
|
+
const { p: h, width: d } = l, f = w.from(h), p = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), g = new D(p, y);
|
|
3031
|
+
i(g.start, g.end), g.expandToRectangle(this.width, "bothSides").path2D((x, m) => i(x, m));
|
|
2934
3032
|
});
|
|
2935
3033
|
}), n;
|
|
2936
3034
|
}
|
|
@@ -2944,8 +3042,8 @@ class k extends z {
|
|
|
2944
3042
|
if (typeof window < "u")
|
|
2945
3043
|
i = document.createElement("canvas");
|
|
2946
3044
|
else if (typeof global < "u") {
|
|
2947
|
-
const { createCanvas:
|
|
2948
|
-
i =
|
|
3045
|
+
const { createCanvas: c } = await H("canvas");
|
|
3046
|
+
i = c();
|
|
2949
3047
|
} else
|
|
2950
3048
|
throw new Error("创建画布失败");
|
|
2951
3049
|
const r = 2 * s.scale, o = {
|
|
@@ -2955,17 +3053,17 @@ class k extends z {
|
|
|
2955
3053
|
};
|
|
2956
3054
|
i.width = s.width + r * 2, i.height = s.height + r * 2;
|
|
2957
3055
|
const a = i.getContext("2d");
|
|
2958
|
-
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([l, h,
|
|
2959
|
-
a.strokeStyle = o[f], a.beginPath(), a.moveTo(
|
|
2960
|
-
}), s.arc.forEach(([l, h,
|
|
2961
|
-
a.strokeStyle = o[p], a.beginPath(), a.arc(l, h,
|
|
2962
|
-
}), a.beginPath(), s.dimensionLine.forEach((
|
|
2963
|
-
let [
|
|
2964
|
-
const p = Math.min(
|
|
3056
|
+
return n && (a.fillStyle = n, a.fillRect(0, 0, i.width, i.height)), a.translate(s.width * 0.5 + r, s.height * 0.5 + r), a.scale(1, -1), s.line.forEach(([c, l, h, d, f]) => {
|
|
3057
|
+
a.strokeStyle = o[f], a.beginPath(), a.moveTo(c, l), a.lineTo(h, d), a.closePath(), a.stroke();
|
|
3058
|
+
}), s.arc.forEach(([c, l, h, d, f, p]) => {
|
|
3059
|
+
a.strokeStyle = o[p], a.beginPath(), a.arc(c, l, h, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
|
|
3060
|
+
}), a.beginPath(), s.dimensionLine.forEach((c) => {
|
|
3061
|
+
let [l, h, d, f] = c;
|
|
3062
|
+
const p = Math.min(h, f), y = Math.max(h, f), g = (i.width * 0.5 - 0.4 * s.scale) * (l < 0 ? -1 : 1), x = (y - p) * 0.45;
|
|
2965
3063
|
a.fillStyle = "#fff", a.font = `${0.15 * s.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.save(), a.translate(g, p + (y - p) * 0.5), a.scale(1, -1), a.fillText((y - p).toFixed(2) + "cm", 0, 0), a.restore(), a.moveTo(g - 0.1 * s.scale, p), a.lineTo(g + 0.1 * s.scale, p), a.moveTo(g, p), a.lineTo(g, x + p), a.moveTo(g, y), a.lineTo(g, y - x), a.moveTo(g - 0.1 * s.scale, y), a.lineTo(g + 0.1 * s.scale, y);
|
|
2966
|
-
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((
|
|
2967
|
-
i.toBlob((
|
|
2968
|
-
l
|
|
3064
|
+
}), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in i ? new Promise((c) => {
|
|
3065
|
+
i.toBlob((l) => {
|
|
3066
|
+
c(l);
|
|
2969
3067
|
}, e, 1);
|
|
2970
3068
|
}) : i.toBuffer(e, { quality: 1 });
|
|
2971
3069
|
}
|
|
@@ -2973,15 +3071,15 @@ class k extends z {
|
|
|
2973
3071
|
* 将点json结构转换为Dxf string
|
|
2974
3072
|
*/
|
|
2975
3073
|
toDxfString(t = "Millimeters") {
|
|
2976
|
-
const e = new
|
|
2977
|
-
e.setUnits(t), e.addLayer("cyan",
|
|
3074
|
+
const e = new st();
|
|
3075
|
+
e.setUnits(t), e.addLayer("cyan", st.ACI.CYAN, "DOTTED"), e.addLayer("yellow", st.ACI.YELLOW, "DOTTED"), e.addLayer("white", st.ACI.WHITE, "DOTTED");
|
|
2978
3076
|
const n = this.toDrawDataJson();
|
|
2979
3077
|
return n.line.forEach((s) => {
|
|
2980
|
-
let [i, r, o, a,
|
|
2981
|
-
e.setActiveLayer(
|
|
3078
|
+
let [i, r, o, a, c] = s;
|
|
3079
|
+
e.setActiveLayer(c), e.drawLine(i, r, o, a);
|
|
2982
3080
|
}), n.arc.forEach((s) => {
|
|
2983
|
-
const [i, r, o, a,
|
|
2984
|
-
e.setActiveLayer(
|
|
3081
|
+
const [i, r, o, a, c, l] = s;
|
|
3082
|
+
e.setActiveLayer(l), e.drawArc(i, r, o, a, c);
|
|
2985
3083
|
}), e.toDxfString();
|
|
2986
3084
|
}
|
|
2987
3085
|
/**
|
|
@@ -3000,7 +3098,7 @@ class k extends z {
|
|
|
3000
3098
|
if (typeof window < "u") {
|
|
3001
3099
|
const s = new Blob([n], { type: "application/json" }), i = document.createElement("a");
|
|
3002
3100
|
i.href = URL.createObjectURL(s), i.download = t, i.click();
|
|
3003
|
-
} else typeof global < "u" && (await
|
|
3101
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(t, n);
|
|
3004
3102
|
}
|
|
3005
3103
|
/**
|
|
3006
3104
|
* 下载
|
|
@@ -3010,7 +3108,7 @@ class k extends z {
|
|
|
3010
3108
|
if (typeof window < "u") {
|
|
3011
3109
|
const n = this.toDxfBlob(e), s = document.createElement("a");
|
|
3012
3110
|
s.href = URL.createObjectURL(n), s.download = t + ".dxf", s.click();
|
|
3013
|
-
} else typeof global < "u" && (await
|
|
3111
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(t, this.toDxfString(e));
|
|
3014
3112
|
}
|
|
3015
3113
|
/**
|
|
3016
3114
|
* 下载
|
|
@@ -3022,7 +3120,7 @@ class k extends z {
|
|
|
3022
3120
|
if (typeof window < "u") {
|
|
3023
3121
|
const i = document.createElement("a");
|
|
3024
3122
|
i.href = URL.createObjectURL(s), i.download = t, i.click();
|
|
3025
|
-
} else typeof global < "u" ? (await
|
|
3123
|
+
} else typeof global < "u" ? (await H("fs", !1)).writeFileSync(t, s) : console.error("图片下载失败");
|
|
3026
3124
|
return !0;
|
|
3027
3125
|
}
|
|
3028
3126
|
/**
|
|
@@ -3030,8 +3128,8 @@ class k extends z {
|
|
|
3030
3128
|
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
3031
3129
|
* @returns
|
|
3032
3130
|
*/
|
|
3033
|
-
computedOriginalSize(t, e = new
|
|
3034
|
-
const n = t.flatMap((
|
|
3131
|
+
computedOriginalSize(t, e = new I(0, 0, 0, 0)) {
|
|
3132
|
+
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);
|
|
3035
3133
|
return e.set(i, r, o, a), e;
|
|
3036
3134
|
}
|
|
3037
3135
|
/**
|
|
@@ -3043,13 +3141,13 @@ class k extends z {
|
|
|
3043
3141
|
let n = 0;
|
|
3044
3142
|
return t.flatMap((i) => {
|
|
3045
3143
|
const r = i.map((o, a) => {
|
|
3046
|
-
const
|
|
3144
|
+
const c = a === i.length - 1 ? 0 : a + 1, l = i[c];
|
|
3047
3145
|
return {
|
|
3048
3146
|
start: { x: o.x, y: o.y },
|
|
3049
|
-
end: { x:
|
|
3147
|
+
end: { x: l.x, y: l.y },
|
|
3050
3148
|
insetionArr: [
|
|
3051
3149
|
{
|
|
3052
|
-
index:
|
|
3150
|
+
index: c + n
|
|
3053
3151
|
}
|
|
3054
3152
|
]
|
|
3055
3153
|
};
|
|
@@ -3058,8 +3156,8 @@ class k extends z {
|
|
|
3058
3156
|
});
|
|
3059
3157
|
}
|
|
3060
3158
|
}
|
|
3061
|
-
const
|
|
3062
|
-
class
|
|
3159
|
+
const z = new D();
|
|
3160
|
+
class ke extends k {
|
|
3063
3161
|
static name = "AngleCorrectionDxf";
|
|
3064
3162
|
angle = 0;
|
|
3065
3163
|
onAddFromParent(t) {
|
|
@@ -3068,44 +3166,44 @@ class je extends k {
|
|
|
3068
3166
|
async update() {
|
|
3069
3167
|
const t = this.parent, e = t.findComponentByName("Dxf"), n = t.findComponentByName("LineAnalysis");
|
|
3070
3168
|
let s = 0, i = null;
|
|
3071
|
-
for (let
|
|
3072
|
-
const
|
|
3073
|
-
if (
|
|
3074
|
-
const [d, f] =
|
|
3075
|
-
s = -new
|
|
3169
|
+
for (let l = 0; l < e.originalData.length; l++) {
|
|
3170
|
+
const h = e.originalData[l];
|
|
3171
|
+
if (z.start.copy(h.start), z.end.copy(h.end), h.isVerticalReferenceLine) {
|
|
3172
|
+
const [d, f] = h.start.y < h.end.y ? [z.start, z.end] : [z.end, z.start];
|
|
3173
|
+
s = -new D(d, f).direction().angleBetween(new w(0, 1), "angle", "360"), i = null;
|
|
3076
3174
|
break;
|
|
3077
3175
|
}
|
|
3078
|
-
(!i ||
|
|
3176
|
+
(!i || z.length() > i.length()) && (i = z.clone(), i.userData.index = l);
|
|
3079
3177
|
}
|
|
3080
3178
|
if (i) {
|
|
3081
3179
|
e.originalData[i.userData.index].isVerticalReferenceLine = !0;
|
|
3082
|
-
const [
|
|
3083
|
-
s = -new
|
|
3180
|
+
const [l, h] = i.start.y < i.end.y ? [i.start, i.end] : [i.end, i.start];
|
|
3181
|
+
s = -new D(l, h).direction().angleBetween(new w(0, 1), "angle", "360");
|
|
3084
3182
|
}
|
|
3085
|
-
function r(
|
|
3086
|
-
return
|
|
3183
|
+
function r(l, h) {
|
|
3184
|
+
return l.division(o).rotate(w.zero(), h * (Math.PI / 180));
|
|
3087
3185
|
}
|
|
3088
|
-
const o = e.originalBox.center, a =
|
|
3089
|
-
const
|
|
3186
|
+
const o = e.originalBox.center, a = w.zero(), c = e.originalData.map((l) => {
|
|
3187
|
+
const h = r(a.copy(l.start), s).toJson(l.start.z), d = r(a.copy(l.end), s).toJson(l.start.z), f = Object.assign(J(l), { start: h, end: d });
|
|
3090
3188
|
return f.drawWindow && f.drawWindow.forEach((p) => p.p = r(a.copy(p.p), s).toJson(p.p.z)), f;
|
|
3091
3189
|
});
|
|
3092
|
-
n.appendLineSegmentList.forEach((
|
|
3093
|
-
const
|
|
3094
|
-
r(
|
|
3095
|
-
start:
|
|
3096
|
-
end:
|
|
3190
|
+
n.appendLineSegmentList.forEach((l) => {
|
|
3191
|
+
const h = l.clone();
|
|
3192
|
+
r(h.start, s), r(h.end, s), c.push({
|
|
3193
|
+
start: h.start.toJson(e.originalZAverage),
|
|
3194
|
+
end: h.end.toJson(e.originalZAverage),
|
|
3097
3195
|
insetionArr: [],
|
|
3098
|
-
length:
|
|
3196
|
+
length: h.length()
|
|
3099
3197
|
});
|
|
3100
|
-
}), await this.set(
|
|
3101
|
-
const
|
|
3102
|
-
return
|
|
3198
|
+
}), await this.set(c, e.width, e.scale), this.lineOffset(), this.doorLineSegment = e.doorLineSegment.map((l) => {
|
|
3199
|
+
const h = l.clone();
|
|
3200
|
+
return h.start.division(o).rotate(w.zero(), s * (Math.PI / 180)), h.end.division(o).rotate(w.zero(), s * (Math.PI / 180)), h;
|
|
3103
3201
|
}), this.angle = s, this.dispatchEvent({
|
|
3104
3202
|
type: "updateData"
|
|
3105
3203
|
});
|
|
3106
3204
|
}
|
|
3107
3205
|
}
|
|
3108
|
-
class Ut extends
|
|
3206
|
+
class Ut extends G {
|
|
3109
3207
|
static name = "Variable";
|
|
3110
3208
|
originalLineVisible = !0;
|
|
3111
3209
|
dxfVisible = !0;
|
|
@@ -3132,7 +3230,7 @@ class Ut extends z {
|
|
|
3132
3230
|
if (t in this) return this[t];
|
|
3133
3231
|
}
|
|
3134
3232
|
}
|
|
3135
|
-
class
|
|
3233
|
+
class zt extends G {
|
|
3136
3234
|
static name = "LineAnalysis";
|
|
3137
3235
|
Dxf = null;
|
|
3138
3236
|
Variable = null;
|
|
@@ -3162,11 +3260,11 @@ class Gt extends z {
|
|
|
3162
3260
|
return {
|
|
3163
3261
|
points: [
|
|
3164
3262
|
// 第一条线
|
|
3165
|
-
new
|
|
3166
|
-
new
|
|
3263
|
+
new w(t.x + o, t.y + a).add(r),
|
|
3264
|
+
new w(e.x + o, e.y + a).add(i),
|
|
3167
3265
|
// 第二条线
|
|
3168
|
-
new
|
|
3169
|
-
new
|
|
3266
|
+
new w(t.x - o, t.y - a).add(r),
|
|
3267
|
+
new w(e.x - o, e.y - a).add(i)
|
|
3170
3268
|
],
|
|
3171
3269
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
3172
3270
|
rectIndices: [0, 1, 3, 2, 0]
|
|
@@ -3180,7 +3278,7 @@ class Gt extends z {
|
|
|
3180
3278
|
*/
|
|
3181
3279
|
addData(t, e) {
|
|
3182
3280
|
const n = this.Dxf;
|
|
3183
|
-
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new
|
|
3281
|
+
n.data.push([t.clone(), e.clone(), [], !1, n.data.length]), this.appendLineSegmentList.push(new D(t.clone(), e.clone()));
|
|
3184
3282
|
}
|
|
3185
3283
|
/** 结果分析创建矩形
|
|
3186
3284
|
* @param result
|
|
@@ -3188,14 +3286,14 @@ class Gt extends z {
|
|
|
3188
3286
|
createRectangle(t) {
|
|
3189
3287
|
const e = this.Dxf, n = t.project, s = t.project2;
|
|
3190
3288
|
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]);
|
|
3191
|
-
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,
|
|
3289
|
+
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);
|
|
3192
3290
|
p.multiplyScalar(e.width * 0.5);
|
|
3193
|
-
const y = d.clone().add(p), g = f.clone().add(p.multiplyScalar(-1)), x = d.direction(f),
|
|
3194
|
-
if (!(x.x > 0 &&
|
|
3291
|
+
const y = d.clone().add(p), g = f.clone().add(p.multiplyScalar(-1)), x = d.direction(f), m = y.direction(g);
|
|
3292
|
+
if (!(x.x > 0 && m.x < 0 || x.x < 0 && m.x > 0 || x.y > 0 && m.y < 0 || x.y < 0 && m.y > 0)) {
|
|
3195
3293
|
d.set(y.x, y.y), f.set(g.x, g.y);
|
|
3196
|
-
for (let
|
|
3197
|
-
const
|
|
3198
|
-
this.addData(A,
|
|
3294
|
+
for (let L = 1; L < o; L++) {
|
|
3295
|
+
const M = l.clone().multiplyScalar(a * L), S = h.clone().multiplyScalar(c * L), A = d.clone().add(M), E = f.clone().add(S);
|
|
3296
|
+
this.addData(A, E);
|
|
3199
3297
|
}
|
|
3200
3298
|
}
|
|
3201
3299
|
}
|
|
@@ -3205,7 +3303,7 @@ class Gt extends z {
|
|
|
3205
3303
|
*/
|
|
3206
3304
|
buildQuadtree() {
|
|
3207
3305
|
const t = this.Dxf, e = [];
|
|
3208
|
-
this.quadtree = new
|
|
3306
|
+
this.quadtree = new B(t.originalBox, 2), t.lineSegments.forEach((n) => {
|
|
3209
3307
|
n.userData?.isDoor || (this.quadtree?.insert({
|
|
3210
3308
|
line: n,
|
|
3211
3309
|
userData: e.length
|
|
@@ -3222,12 +3320,12 @@ class Gt extends z {
|
|
|
3222
3320
|
this.buildQuadtree();
|
|
3223
3321
|
const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), s = [];
|
|
3224
3322
|
e.forEach((i, r) => {
|
|
3225
|
-
const o = e[r], a =
|
|
3226
|
-
t.queryRect(a).map((
|
|
3323
|
+
const o = e[r], a = nt.fromByLineSegment(o, this.width * 2, !1, -0.01);
|
|
3324
|
+
t.queryRect(a).map((l) => l.userData).filter((l) => l !== r).forEach((l) => {
|
|
3227
3325
|
try {
|
|
3228
|
-
if (n.has(`${r}-${
|
|
3229
|
-
const
|
|
3230
|
-
|
|
3326
|
+
if (n.has(`${r}-${l}`) || n.has(`${l}-${r}`)) return;
|
|
3327
|
+
const h = this.projectionAnalysis(l, r, o, e);
|
|
3328
|
+
h && s.push(h), n.add(`${r}-${l}`);
|
|
3231
3329
|
} catch {
|
|
3232
3330
|
}
|
|
3233
3331
|
});
|
|
@@ -3242,34 +3340,34 @@ class Gt extends z {
|
|
|
3242
3340
|
projectionAnalysis(t, e, n, s) {
|
|
3243
3341
|
const i = s[t], r = n.direction(), o = i.direction(), a = r.angleBetween(o) / (Math.PI / 180);
|
|
3244
3342
|
if (a < this.errorAngle || a > 180 - this.errorAngle) {
|
|
3245
|
-
let
|
|
3246
|
-
const
|
|
3247
|
-
return
|
|
3343
|
+
let c;
|
|
3344
|
+
const l = i.projectLineSegment(n), h = n.projectLineSegment(i);
|
|
3345
|
+
return l.getLength() > h.getLength() ? c = {
|
|
3248
3346
|
target: i,
|
|
3249
3347
|
targetIndex: t,
|
|
3250
3348
|
source: n,
|
|
3251
3349
|
sourceIndex: e,
|
|
3252
|
-
project:
|
|
3253
|
-
project2:
|
|
3254
|
-
} :
|
|
3350
|
+
project: l,
|
|
3351
|
+
project2: h
|
|
3352
|
+
} : c = {
|
|
3255
3353
|
target: n,
|
|
3256
3354
|
targetIndex: e,
|
|
3257
3355
|
source: i,
|
|
3258
3356
|
sourceIndex: t,
|
|
3259
|
-
project:
|
|
3260
|
-
project2:
|
|
3261
|
-
}, !
|
|
3357
|
+
project: h,
|
|
3358
|
+
project2: l
|
|
3359
|
+
}, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
|
|
3262
3360
|
}
|
|
3263
3361
|
}
|
|
3264
3362
|
}
|
|
3265
|
-
class
|
|
3363
|
+
class Ye {
|
|
3266
3364
|
// 所有可查找的点位
|
|
3267
3365
|
possibleDoorPoints = [];
|
|
3268
3366
|
doorPoint = [];
|
|
3269
3367
|
calculatedDoorPoint = [];
|
|
3270
3368
|
dxf;
|
|
3271
3369
|
// 包含所有点的虚拟网格
|
|
3272
|
-
pointVirtualGrid = new
|
|
3370
|
+
pointVirtualGrid = new Y();
|
|
3273
3371
|
// 只包含可查找点的虚拟网格
|
|
3274
3372
|
findPointVirtualGrid;
|
|
3275
3373
|
quadtree;
|
|
@@ -3282,15 +3380,15 @@ class Fe {
|
|
|
3282
3380
|
lineAnalysis;
|
|
3283
3381
|
continueFind = !0;
|
|
3284
3382
|
constructor(t) {
|
|
3285
|
-
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new
|
|
3383
|
+
this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new Y(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((i) => {
|
|
3286
3384
|
this.pointVirtualGrid.insert(i.start, i), this.pointVirtualGrid.insert(i.end, i);
|
|
3287
3385
|
});
|
|
3288
3386
|
const { doorPoints: e, calculatedDoorPoint: n } = this.getDoorPoint();
|
|
3289
3387
|
this.doorPoint = e, this.calculatedDoorPoint = n;
|
|
3290
3388
|
const s = this.searchDoubleLinePoint();
|
|
3291
3389
|
this.addPointsExcludeRule((i, r, o) => {
|
|
3292
|
-
const a = this.lineSegments.indexOf(i),
|
|
3293
|
-
return typeof
|
|
3390
|
+
const a = this.lineSegments.indexOf(i), c = s.get(a);
|
|
3391
|
+
return typeof c == "number" ? c === -1 || c === o : !1;
|
|
3294
3392
|
}), this.addPointsExcludeRule((i, r) => !!this.doorPoint.find((o) => o.point.equal(r))), this.addPointsExcludeRule((i, r) => !!this.calculatedDoorPoint.find((o) => o.point.equal(r))), this.possibleDoorPoints = this.getPossiblePoints(), this.possibleDoorPoints.forEach((i) => this.findPointVirtualGrid.insert(i.point, i.line)), this.handle();
|
|
3295
3393
|
}
|
|
3296
3394
|
handle() {
|
|
@@ -3307,32 +3405,32 @@ class Fe {
|
|
|
3307
3405
|
search(t, e = [], n = 0.6, s = this.doorSearchDistance, i = this.doorSearchNearAngle) {
|
|
3308
3406
|
const r = this.dxf, o = this.searchNearby(t, e, s, i);
|
|
3309
3407
|
o.push(
|
|
3310
|
-
...t.map((
|
|
3311
|
-
const
|
|
3408
|
+
...t.map((c) => {
|
|
3409
|
+
const l = this.searchAlongDirection(c, s);
|
|
3410
|
+
if (l) return {
|
|
3411
|
+
start: c.point,
|
|
3412
|
+
end: l.point
|
|
3413
|
+
};
|
|
3414
|
+
const h = this.searchAlongNormalDirection(c, s);
|
|
3312
3415
|
if (h) return {
|
|
3313
|
-
start:
|
|
3416
|
+
start: c.point,
|
|
3314
3417
|
end: h.point
|
|
3315
3418
|
};
|
|
3316
|
-
|
|
3317
|
-
if (c) return {
|
|
3318
|
-
start: l.point,
|
|
3319
|
-
end: c.point
|
|
3320
|
-
};
|
|
3321
|
-
}).filter((l) => !!l && l.start.distance(l.end) < s)
|
|
3419
|
+
}).filter((c) => !!c && c.start.distance(c.end) < s)
|
|
3322
3420
|
);
|
|
3323
3421
|
const a = [];
|
|
3324
|
-
return o.forEach((
|
|
3325
|
-
const
|
|
3326
|
-
if (
|
|
3327
|
-
const d =
|
|
3422
|
+
return o.forEach((c) => {
|
|
3423
|
+
const l = new D(c?.start, c?.end), h = l.length();
|
|
3424
|
+
if (h < n) return;
|
|
3425
|
+
const d = l.normal(), f = l.direction(), p = (h - r.width * 2) / 2;
|
|
3328
3426
|
for (let y = 0; y < 3; y++) {
|
|
3329
|
-
const g =
|
|
3427
|
+
const g = l.start.clone().add(f.clone().multiplyScalar(r.width + p * y)), x = new D(
|
|
3330
3428
|
g,
|
|
3331
3429
|
g.clone().add(d.clone().multiplyScalar(1))
|
|
3332
3430
|
);
|
|
3333
3431
|
if (x.directionMove(d, -0.5), this.quadtree.queryLineSegment(x).length) return;
|
|
3334
3432
|
}
|
|
3335
|
-
a.push(
|
|
3433
|
+
a.push(l);
|
|
3336
3434
|
}), a;
|
|
3337
3435
|
}
|
|
3338
3436
|
/** 添加可查找点的过滤规则
|
|
@@ -3363,28 +3461,28 @@ class Fe {
|
|
|
3363
3461
|
const r = n.lineSegments[i[4]], o = n.originalData[i[4]];
|
|
3364
3462
|
if (o.doorDirectConnection) {
|
|
3365
3463
|
this.continueFind = !1;
|
|
3366
|
-
const a = new
|
|
3464
|
+
const a = new D(w.from(o.start), w.from(o.end));
|
|
3367
3465
|
a.userData = {
|
|
3368
3466
|
doorDirectConnection: !0,
|
|
3369
3467
|
isDoor: !0
|
|
3370
|
-
}, this.dxf.doorLineSegment.push(a), a.points.forEach((
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3373
|
-
line:
|
|
3374
|
-
point:
|
|
3468
|
+
}, this.dxf.doorLineSegment.push(a), a.points.forEach((c) => {
|
|
3469
|
+
const l = s.queryPoint(c);
|
|
3470
|
+
l.length && e.push({
|
|
3471
|
+
line: l[0].userData,
|
|
3472
|
+
point: l[0].point,
|
|
3375
3473
|
uuid: tt()
|
|
3376
3474
|
});
|
|
3377
3475
|
});
|
|
3378
3476
|
} else if (o.drawDoorData) {
|
|
3379
|
-
const a =
|
|
3380
|
-
if (
|
|
3381
|
-
const d =
|
|
3477
|
+
const a = w.from(o.drawDoorData.start), c = w.from(o.drawDoorData.n), l = s.queryPoint(a).filter((h) => {
|
|
3478
|
+
if (h.userData === r) return !1;
|
|
3479
|
+
const d = h.userData, f = d.direction();
|
|
3382
3480
|
d.start.equal(a) && f.multiplyScalar(-1);
|
|
3383
|
-
const p =
|
|
3481
|
+
const p = c.angleBetween(f, "angle");
|
|
3384
3482
|
return p > 170 || p < 10;
|
|
3385
3483
|
});
|
|
3386
|
-
|
|
3387
|
-
line:
|
|
3484
|
+
l.length && t.push({
|
|
3485
|
+
line: l[0].userData,
|
|
3388
3486
|
point: a,
|
|
3389
3487
|
uuid: tt()
|
|
3390
3488
|
});
|
|
@@ -3399,8 +3497,8 @@ class Fe {
|
|
|
3399
3497
|
searchDoubleLinePoint() {
|
|
3400
3498
|
const t = /* @__PURE__ */ new Map();
|
|
3401
3499
|
return this.resultList.flatMap((e) => {
|
|
3402
|
-
const n = this.lineSegments[e.sourceIndex], s = this.lineSegments[e.targetIndex], i = s.projectPoint(n.start), r = s.projectPoint(n.end), o = n.projectPoint(s.start), a = n.projectPoint(s.end),
|
|
3403
|
-
t.has(e.sourceIndex) ? t.get(e.sourceIndex) !=
|
|
3500
|
+
const n = this.lineSegments[e.sourceIndex], s = this.lineSegments[e.targetIndex], i = s.projectPoint(n.start), r = s.projectPoint(n.end), o = n.projectPoint(s.start), a = n.projectPoint(s.end), c = i && r ? -1 : i ? 0 : r ? 1 : -1, l = o && a ? -1 : o ? 0 : a ? 1 : -1;
|
|
3501
|
+
t.has(e.sourceIndex) ? t.get(e.sourceIndex) != c && t.set(e.sourceIndex, -1) : t.set(e.sourceIndex, c), t.has(e.targetIndex) ? t.get(e.targetIndex) != l && t.set(e.targetIndex, -1) : t.set(e.targetIndex, l);
|
|
3404
3502
|
}), t;
|
|
3405
3503
|
}
|
|
3406
3504
|
/** 查找方案一:最近点查找
|
|
@@ -3413,63 +3511,63 @@ class Fe {
|
|
|
3413
3511
|
*/
|
|
3414
3512
|
searchNearby(t, e = [], n = this.doorSearchDistance, s = this.doorSearchNearAngle) {
|
|
3415
3513
|
const i = this.findPointVirtualGrid, r = this.quadtree;
|
|
3416
|
-
function o({ point: g, line: x },
|
|
3417
|
-
const
|
|
3418
|
-
x.start === g &&
|
|
3419
|
-
const S = i.queryCircle(g, n).filter((
|
|
3420
|
-
for (let
|
|
3421
|
-
const
|
|
3422
|
-
if (
|
|
3423
|
-
const
|
|
3424
|
-
if (
|
|
3425
|
-
|
|
3426
|
-
const
|
|
3427
|
-
if (
|
|
3428
|
-
const
|
|
3429
|
-
|
|
3430
|
-
findData: S[
|
|
3431
|
-
findUuid:
|
|
3432
|
-
doorLine:
|
|
3433
|
-
doorUuid:
|
|
3514
|
+
function o({ point: g, line: x }, m, L) {
|
|
3515
|
+
const M = x.direction();
|
|
3516
|
+
x.start === g && M.multiplyScalar(-1);
|
|
3517
|
+
const S = i.queryCircle(g, n).filter((E) => E.userData !== x).sort((E, T) => E.point.distance(g) - T.point.distance(g)), A = [];
|
|
3518
|
+
for (let E = 0; E < S.length; E++) {
|
|
3519
|
+
const T = e.findIndex((R) => R.point === S[E].point);
|
|
3520
|
+
if (T === -1) continue;
|
|
3521
|
+
const C = t[m].uuid, N = e[T].uuid;
|
|
3522
|
+
if (L.has(`${C}.${N}`)) continue;
|
|
3523
|
+
L.add(`${C}.${N}`), L.add(`${N}.${C}`);
|
|
3524
|
+
const O = S[E].point, q = new D(g.clone(), O.clone());
|
|
3525
|
+
if (q.direction().angleBetween(M, "angle") < s) {
|
|
3526
|
+
const R = t[m].line.direction(), v = S[E].userData;
|
|
3527
|
+
v.start.equal(S[E].point) && R.multiplyScalar(-1), q.direction().multiplyScalar(-1).angleBetween(R, "angle") < s && (r.queryLineSegment(q).filter((W) => !(W.line.start.equal(g) || W.line.end.equal(g) || W.line === v)).length || A.push({
|
|
3528
|
+
findData: S[E],
|
|
3529
|
+
findUuid: N,
|
|
3530
|
+
doorLine: q,
|
|
3531
|
+
doorUuid: C
|
|
3434
3532
|
}));
|
|
3435
3533
|
}
|
|
3436
3534
|
}
|
|
3437
3535
|
return A;
|
|
3438
3536
|
}
|
|
3439
|
-
function a(g, x,
|
|
3440
|
-
|
|
3537
|
+
function a(g, x, m, L, M) {
|
|
3538
|
+
L.add(g);
|
|
3441
3539
|
const S = [];
|
|
3442
|
-
|
|
3443
|
-
for (let A = 0; A <
|
|
3444
|
-
const
|
|
3445
|
-
if (x.has(
|
|
3446
|
-
const
|
|
3447
|
-
a(
|
|
3448
|
-
} else S.push(
|
|
3540
|
+
M && S.push(M);
|
|
3541
|
+
for (let A = 0; A < m.length; A++) {
|
|
3542
|
+
const E = m[A];
|
|
3543
|
+
if (x.has(E.findUuid)) {
|
|
3544
|
+
const T = x.get(E.findUuid);
|
|
3545
|
+
a(E.findUuid, x, T, L, E) && S.push(E);
|
|
3546
|
+
} else S.push(E);
|
|
3449
3547
|
}
|
|
3450
|
-
return S.sort((A,
|
|
3548
|
+
return S.sort((A, E) => A.doorLine.length() - E.doorLine.length()), M && S[0] === M ? (m.splice(0), !0) : (m.splice(1), !1);
|
|
3451
3549
|
}
|
|
3452
|
-
const
|
|
3550
|
+
const c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
|
|
3453
3551
|
t.map((g, x) => {
|
|
3454
|
-
const
|
|
3455
|
-
|
|
3456
|
-
}),
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3459
|
-
if (!
|
|
3460
|
-
const
|
|
3461
|
-
|
|
3552
|
+
const m = o(g, x, c);
|
|
3553
|
+
m.length && l.set(g.uuid, m);
|
|
3554
|
+
}), c.clear();
|
|
3555
|
+
const h = /* @__PURE__ */ new Map();
|
|
3556
|
+
l.forEach((g, x) => {
|
|
3557
|
+
if (!c.has(x) && g.length && a(x, l, g, c), g.length) {
|
|
3558
|
+
const m = g[0];
|
|
3559
|
+
h.has(m.doorUuid) || h.set(m.doorUuid, []), h.get(m.doorUuid)?.push(m), h.has(m.findUuid) || h.set(m.findUuid, []), h.get(m.findUuid)?.push(m);
|
|
3462
3560
|
}
|
|
3463
3561
|
});
|
|
3464
3562
|
const d = /* @__PURE__ */ new Set();
|
|
3465
|
-
|
|
3563
|
+
h.forEach((g) => {
|
|
3466
3564
|
if (g.length > 1) {
|
|
3467
|
-
g.sort((x,
|
|
3565
|
+
g.sort((x, m) => x.doorLine.length() - m.doorLine.length());
|
|
3468
3566
|
for (let x = 1; x < g.length; x++) d.add(g[x]);
|
|
3469
3567
|
}
|
|
3470
3568
|
});
|
|
3471
3569
|
const f = [], p = [];
|
|
3472
|
-
|
|
3570
|
+
l.forEach((g) => {
|
|
3473
3571
|
if (g.length) {
|
|
3474
3572
|
const x = g[0];
|
|
3475
3573
|
d.has(x) || (f.push(x), p.push(x.doorUuid, x.findUuid));
|
|
@@ -3477,21 +3575,21 @@ class Fe {
|
|
|
3477
3575
|
});
|
|
3478
3576
|
const y = [];
|
|
3479
3577
|
return f.forEach((g) => {
|
|
3480
|
-
const x = t.findIndex((
|
|
3481
|
-
if (
|
|
3482
|
-
|
|
3483
|
-
const
|
|
3484
|
-
(
|
|
3485
|
-
start:
|
|
3486
|
-
end:
|
|
3578
|
+
const x = t.findIndex((T) => T.uuid === g.doorUuid), m = e.findIndex((T) => T.uuid === g.findUuid), L = t[x].point.clone(), M = e[m].point.clone(), S = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[m].line), E = S.projectPoint(M);
|
|
3579
|
+
if (E) {
|
|
3580
|
+
L.copy(E);
|
|
3581
|
+
const T = new D(L, M), C = A.includedAngle(T);
|
|
3582
|
+
(C < 10 || C > 170 || Math.abs(90 - C) < 10) && y.push({
|
|
3583
|
+
start: L,
|
|
3584
|
+
end: M
|
|
3487
3585
|
});
|
|
3488
3586
|
} else {
|
|
3489
|
-
const
|
|
3490
|
-
|
|
3491
|
-
const
|
|
3492
|
-
(
|
|
3493
|
-
start:
|
|
3494
|
-
end:
|
|
3587
|
+
const T = A.projectPoint(L);
|
|
3588
|
+
T && M.copy(T);
|
|
3589
|
+
const C = new D(L, M), N = S.includedAngle(C);
|
|
3590
|
+
(N < 10 || N > 170 || Math.abs(90 - N) < 10) && y.push({
|
|
3591
|
+
start: L,
|
|
3592
|
+
end: M
|
|
3495
3593
|
});
|
|
3496
3594
|
}
|
|
3497
3595
|
}), e.splice(
|
|
@@ -3512,14 +3610,14 @@ class Fe {
|
|
|
3512
3610
|
searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
3513
3611
|
const s = this.quadtree, i = e.direction();
|
|
3514
3612
|
e.start === t && i.multiplyScalar(-1);
|
|
3515
|
-
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new
|
|
3516
|
-
point:
|
|
3517
|
-
line:
|
|
3518
|
-
})).filter((
|
|
3613
|
+
const r = t.clone().add(i.clone().multiplyScalar(n)), o = new D(t.clone(), r), a = s.queryLineSegment(o).map((c) => ({
|
|
3614
|
+
point: c.line.getIntersection(o),
|
|
3615
|
+
line: c.line
|
|
3616
|
+
})).filter((c) => c.point).sort((c, l) => t.distance(c.point) - t.distance(l.point));
|
|
3519
3617
|
if (a.length) {
|
|
3520
|
-
const
|
|
3521
|
-
if (Math.abs(90 -
|
|
3522
|
-
return
|
|
3618
|
+
const c = a[0];
|
|
3619
|
+
if (Math.abs(90 - c.line.direction().angleBetween(i, "angle")) < 5)
|
|
3620
|
+
return c;
|
|
3523
3621
|
}
|
|
3524
3622
|
}
|
|
3525
3623
|
/** 方案三: 沿法线方向查找
|
|
@@ -3531,20 +3629,20 @@ class Fe {
|
|
|
3531
3629
|
searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
|
|
3532
3630
|
const s = this.pointVirtualGrid, i = this.quadtree, r = e.direction(), o = e.start.normal(e.end), a = e.start.clone();
|
|
3533
3631
|
e.start === t && r.multiplyScalar(-1), e.start === t && a.copy(e.end);
|
|
3534
|
-
const
|
|
3535
|
-
for (let d = 0; d <
|
|
3536
|
-
const f =
|
|
3632
|
+
const c = s.queryPoint(a).filter((d) => d.userData !== e);
|
|
3633
|
+
for (let d = 0; d < c.length; d++) {
|
|
3634
|
+
const f = c[d], p = f.userData, y = p.direction();
|
|
3537
3635
|
if (p.start === f.point && r.multiplyScalar(-1), y.angleBetween(o) / (Math.PI / 180) > 90) {
|
|
3538
3636
|
o.multiplyScalar(-1);
|
|
3539
3637
|
break;
|
|
3540
3638
|
}
|
|
3541
3639
|
}
|
|
3542
|
-
const
|
|
3543
|
-
point: d.line.getIntersection(
|
|
3640
|
+
const l = new D(t.clone(), t.clone().add(o.multiplyScalar(n))), h = i.queryLineSegment(l).map((d) => ({
|
|
3641
|
+
point: d.line.getIntersection(l),
|
|
3544
3642
|
line: d.line
|
|
3545
3643
|
})).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
|
|
3546
|
-
if (
|
|
3547
|
-
const d =
|
|
3644
|
+
if (h.length) {
|
|
3645
|
+
const d = h[0];
|
|
3548
3646
|
if (Math.abs(90 - d.line.direction().angleBetween(o, "angle")) < 5)
|
|
3549
3647
|
return d;
|
|
3550
3648
|
}
|
|
@@ -3573,7 +3671,7 @@ class Fe {
|
|
|
3573
3671
|
return e;
|
|
3574
3672
|
}
|
|
3575
3673
|
}
|
|
3576
|
-
class
|
|
3674
|
+
class Xe extends G {
|
|
3577
3675
|
doorSearchNearAngle = 110;
|
|
3578
3676
|
doorSearchDistance = 2;
|
|
3579
3677
|
DoorsAnalysis;
|
|
@@ -3585,80 +3683,74 @@ class qe extends z {
|
|
|
3585
3683
|
* @param parent
|
|
3586
3684
|
*/
|
|
3587
3685
|
onAddFromParent(t) {
|
|
3588
|
-
const e = t.findComponentByType(k), n = this.parent?.findComponentByType(
|
|
3686
|
+
const e = t.findComponentByType(k), n = this.parent?.findComponentByType(zt);
|
|
3589
3687
|
e.addEventListener("createGroup", () => {
|
|
3590
|
-
this.skipFindDoor ? this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])) : this.DoorsAnalysis = new
|
|
3688
|
+
this.skipFindDoor ? this.needsSaveDoor && (this.doors = e.doors.map((s) => e.lineSegments[s[4]])) : this.DoorsAnalysis = new Ye(n), this.skipFindDoor = !1, this.dispatchEvent({ type: "analysisCompleted" });
|
|
3591
3689
|
});
|
|
3592
3690
|
}
|
|
3593
3691
|
}
|
|
3594
|
-
function
|
|
3595
|
-
const t = new G();
|
|
3596
|
-
for (const e of u)
|
|
3597
|
-
t.insert(e.start, e), t.insert(e.end, e);
|
|
3598
|
-
return t;
|
|
3599
|
-
}
|
|
3600
|
-
function Ge(u, t) {
|
|
3692
|
+
function Ve(u, t) {
|
|
3601
3693
|
const e = t.queryPoint(u.start, !0)[0], n = t.queryPoint(u.end, !0)[0];
|
|
3602
3694
|
if (e && n) {
|
|
3603
3695
|
const s = e.userData.length(), i = n.userData.length();
|
|
3604
3696
|
if (Math.abs(s - i) < 1e-9) return null;
|
|
3605
|
-
const r = e.userData?.getAnotherPoint(e.point), o = n.userData?.getAnotherPoint(n.point), a = r.direction(e.point),
|
|
3606
|
-
if (a.angleBetween(
|
|
3607
|
-
const
|
|
3697
|
+
const r = e.userData?.getAnotherPoint(e.point), o = n.userData?.getAnotherPoint(n.point), a = r.direction(e.point), c = o.direction(n.point);
|
|
3698
|
+
if (a.angleBetween(c) > 1e-9) return null;
|
|
3699
|
+
const l = s > i ? n : e, h = l.userData, d = h.getAnotherPoint(l.point), f = t.queryPoint(d, !0)[0];
|
|
3608
3700
|
if (!f) return null;
|
|
3609
3701
|
const p = f.userData?.getAnotherPoint(f.point), y = p.direction(f.point);
|
|
3610
|
-
return (u.start.equal(
|
|
3702
|
+
return (u.start.equal(l.point) ? u.end : u.start).direction(l.point).angleBetween(y, "angle") < 1 ? null : h;
|
|
3611
3703
|
}
|
|
3612
3704
|
return null;
|
|
3613
3705
|
}
|
|
3614
|
-
function
|
|
3615
|
-
const e = new
|
|
3706
|
+
function We(u, t) {
|
|
3707
|
+
const e = new B(I.fromByLineSegment(...u)), n = t.clone().expansion(100), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
3616
3708
|
u.forEach((a) => e.insert(a));
|
|
3617
3709
|
const r = e.queryLineSegment(n);
|
|
3618
3710
|
for (let a = 0; a < r.length; a++) {
|
|
3619
|
-
const { line:
|
|
3620
|
-
if (
|
|
3621
|
-
s.add(
|
|
3711
|
+
const { line: c } = r[a];
|
|
3712
|
+
if (c.parallel(n)) {
|
|
3713
|
+
s.add(c);
|
|
3622
3714
|
continue;
|
|
3623
3715
|
}
|
|
3624
|
-
const
|
|
3625
|
-
if (
|
|
3626
|
-
if (
|
|
3627
|
-
const
|
|
3628
|
-
s.add(
|
|
3716
|
+
const l = c.getIntersection(n);
|
|
3717
|
+
if (l) {
|
|
3718
|
+
if (c.start.equal(l) || c.end.equal(l)) continue;
|
|
3719
|
+
const h = D.clipping(c, [l], qt);
|
|
3720
|
+
s.add(c), h.forEach((d) => i.add(d));
|
|
3629
3721
|
}
|
|
3630
3722
|
}
|
|
3631
3723
|
u = u.filter((a) => !s.has(a)), u.push(...i);
|
|
3632
|
-
const o =
|
|
3724
|
+
const o = D.groupByPosition(u, n);
|
|
3633
3725
|
return o.forEach((a) => {
|
|
3634
|
-
const
|
|
3635
|
-
for (let
|
|
3636
|
-
const d = a[
|
|
3637
|
-
|
|
3726
|
+
const c = new at();
|
|
3727
|
+
for (let h = 0; h < a.length; h++) {
|
|
3728
|
+
const d = a[h], f = d.start.hashCode(), p = d.end.hashCode();
|
|
3729
|
+
c.append(f, d.start), c.append(p, d.end);
|
|
3638
3730
|
}
|
|
3639
|
-
const
|
|
3640
|
-
if (
|
|
3641
|
-
const
|
|
3642
|
-
a.push(
|
|
3731
|
+
const l = c.filter((h) => h.length === 1).map((h) => h[0]);
|
|
3732
|
+
if (l.length === 2) {
|
|
3733
|
+
const h = new D(l[0].clone(), l[1].clone());
|
|
3734
|
+
a.push(h);
|
|
3643
3735
|
}
|
|
3644
|
-
}), o;
|
|
3736
|
+
}), e.clear(), o;
|
|
3645
3737
|
}
|
|
3646
|
-
function
|
|
3647
|
-
if (u = u.map((n) => n.clone()), u =
|
|
3738
|
+
function _t(u) {
|
|
3739
|
+
if (u = u.map((n) => n.clone()), u = D.brokenLineMerging(u, $), u.length <= 4) return [u];
|
|
3648
3740
|
u = u.sort((n, s) => s.length() - n.length());
|
|
3649
|
-
const t =
|
|
3741
|
+
const t = V(u), e = [];
|
|
3650
3742
|
for (let n = 0; n < u.length; n++) {
|
|
3651
|
-
const s = u[n], i =
|
|
3743
|
+
const s = u[n], i = Ve(s, t);
|
|
3652
3744
|
if (i) {
|
|
3653
|
-
|
|
3654
|
-
r.length === 4 ? e.push(r) : e.push(...
|
|
3745
|
+
We(u, i).forEach((r) => {
|
|
3746
|
+
r.length === 4 ? e.push(r) : e.push(..._t(r));
|
|
3655
3747
|
});
|
|
3656
3748
|
break;
|
|
3657
3749
|
}
|
|
3658
3750
|
}
|
|
3659
|
-
return e;
|
|
3751
|
+
return t.clear(), e;
|
|
3660
3752
|
}
|
|
3661
|
-
class
|
|
3753
|
+
class He extends G {
|
|
3662
3754
|
static name = "ThreeVJia";
|
|
3663
3755
|
lineSegments = [];
|
|
3664
3756
|
neededUpdate = !0;
|
|
@@ -3675,7 +3767,7 @@ class _e extends z {
|
|
|
3675
3767
|
const e = t.reduce((n, s) => {
|
|
3676
3768
|
let i = s.userData.groupId ?? "door";
|
|
3677
3769
|
return s.userData.groupType === "wall" && (i = "wall"), n.append(i, s);
|
|
3678
|
-
}, new
|
|
3770
|
+
}, new at());
|
|
3679
3771
|
return e.size === 1 ? null : e;
|
|
3680
3772
|
}
|
|
3681
3773
|
/** 更新
|
|
@@ -3691,11 +3783,11 @@ class _e extends z {
|
|
|
3691
3783
|
const e = t.group((r, o) => ({ wall: "wall", door: "wall" })[o] ?? "doubleWall"), n = e.get("wall") ?? [], s = e.get("doubleWall") ?? [];
|
|
3692
3784
|
let i = [];
|
|
3693
3785
|
n.forEach((r) => i.push(...r)), s.forEach((r) => {
|
|
3694
|
-
|
|
3786
|
+
_t(r).forEach((a) => {
|
|
3695
3787
|
if (a.length < 4) return i.push(...a);
|
|
3696
3788
|
a = a.sort((d, f) => d.length() - f.length());
|
|
3697
|
-
const
|
|
3698
|
-
$(
|
|
3789
|
+
const c = a[0], l = a[1], h = new D(c.center.clone(), l.center.clone());
|
|
3790
|
+
$(h, a), h.userData.wallWidth = c.length(), i.push(h);
|
|
3699
3791
|
});
|
|
3700
3792
|
}), i = i.map((r) => r.clone()), this.lineSegments = i;
|
|
3701
3793
|
}
|
|
@@ -3705,7 +3797,7 @@ class _e extends z {
|
|
|
3705
3797
|
angleCorrection() {
|
|
3706
3798
|
const t = this.parent?.findComponentByName("Dxf"), e = this.parent?.findComponentByName("AngleCorrectionDxf"), n = t.box.center;
|
|
3707
3799
|
this.lineSegments = this.lineSegments.map((s) => (s.start.rotate(n, e.angle * (Math.PI / 180)), s.end.rotate(n, e.angle * (Math.PI / 180)), s.userData.drawWindow && s.userData.drawWindow.forEach((i) => {
|
|
3708
|
-
const r =
|
|
3800
|
+
const r = w.from(i.p);
|
|
3709
3801
|
r.rotate(n, e.angle * (Math.PI / 180)), i.p = r.toJson(i.p.z);
|
|
3710
3802
|
}), s));
|
|
3711
3803
|
}
|
|
@@ -3716,28 +3808,28 @@ class _e extends z {
|
|
|
3716
3808
|
const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf"), n = /* @__PURE__ */ new Map();
|
|
3717
3809
|
let s = [...e.lineSegments], i = [], r = [];
|
|
3718
3810
|
t.resultList.forEach((a) => {
|
|
3719
|
-
const
|
|
3720
|
-
|
|
3721
|
-
const f = new
|
|
3811
|
+
const c = n.get(a.target) ?? [], l = n.get(a.source) ?? [], h = a.project.clone(), d = a.project2.clone();
|
|
3812
|
+
h.includedAngle(d) > 135 && (d.points = [d.points[1], d.points[0]]), c.push(...h.points), l.push(...d.points), n.set(a.target, c), n.set(a.source, l);
|
|
3813
|
+
const f = new D(h.start, d.start), p = new D(h.end, d.end), y = new D(f.center, p.center);
|
|
3722
3814
|
y.userData.wallWidth = Math.max(f.length(), p.length()), i.push(y);
|
|
3723
3815
|
});
|
|
3724
3816
|
const o = [];
|
|
3725
3817
|
s = s.filter((a) => {
|
|
3726
3818
|
if (r.indexOf(a) > -1) return !1;
|
|
3727
3819
|
if (n.has(a)) {
|
|
3728
|
-
const
|
|
3729
|
-
if (
|
|
3730
|
-
for (let d = 0; d <
|
|
3731
|
-
const f =
|
|
3732
|
-
f.userData.length = f.distance(
|
|
3820
|
+
const c = n.get(a), l = a.clone();
|
|
3821
|
+
if (c) {
|
|
3822
|
+
for (let d = 0; d < c.length; d += 2) {
|
|
3823
|
+
const f = c[d], p = c[d + 1];
|
|
3824
|
+
f.userData.length = f.distance(l.start), p.userData.length = p.distance(l.start), f.userData.type = "start", p.userData.type = "end", l.start.distance(f) > l.start.distance(p) && (c[d] = p, c[d + 1] = f, f.userData.type = "end", p.userData.type = "start");
|
|
3733
3825
|
}
|
|
3734
|
-
|
|
3735
|
-
const
|
|
3736
|
-
for (let d = 0; d <
|
|
3737
|
-
const f =
|
|
3738
|
-
f.userData.type === "start" ? (
|
|
3826
|
+
c.sort((d, f) => d.userData.length - f.userData.length);
|
|
3827
|
+
const h = [];
|
|
3828
|
+
for (let d = 0; d < c.length; d++) {
|
|
3829
|
+
const f = c[d];
|
|
3830
|
+
f.userData.type === "start" ? (h.length === 0 && (o.push(new D(l.start.clone(), f.clone())), l.start.copy(f)), h.push("start")) : (h.pop(), h.length === 0 && l.start.copy(f));
|
|
3739
3831
|
}
|
|
3740
|
-
o.push(
|
|
3832
|
+
o.push(l);
|
|
3741
3833
|
}
|
|
3742
3834
|
return !1;
|
|
3743
3835
|
}
|
|
@@ -3790,7 +3882,7 @@ class _e extends z {
|
|
|
3790
3882
|
};
|
|
3791
3883
|
if (s.userData.isWindow && s.userData.drawWindow)
|
|
3792
3884
|
return s.userData.drawWindow.map((i) => {
|
|
3793
|
-
const r =
|
|
3885
|
+
const r = w.from(i.p), o = r.clone().add(
|
|
3794
3886
|
s.direction().multiplyScalar(i.width * 0.5)
|
|
3795
3887
|
), a = r.clone().add(
|
|
3796
3888
|
s.direction().multiplyScalar(-i.width * 0.5)
|
|
@@ -3823,10 +3915,10 @@ class _e extends z {
|
|
|
3823
3915
|
if (typeof window < "u") {
|
|
3824
3916
|
const e = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
|
|
3825
3917
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
3826
|
-
} else typeof global < "u" && (await
|
|
3918
|
+
} else typeof global < "u" && (await H("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
|
|
3827
3919
|
}
|
|
3828
3920
|
}
|
|
3829
|
-
class
|
|
3921
|
+
class Z extends me {
|
|
3830
3922
|
Dxf;
|
|
3831
3923
|
AngleCorrectionDxf;
|
|
3832
3924
|
Variable;
|
|
@@ -3840,7 +3932,7 @@ class K extends ge {
|
|
|
3840
3932
|
* @param scale 原始数据缩放比例
|
|
3841
3933
|
*/
|
|
3842
3934
|
constructor(t = 0.1, e = 1) {
|
|
3843
|
-
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new
|
|
3935
|
+
super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new k(this.wallWidth, e), this.AngleCorrectionDxf = new ke(), this.Variable = new Ut(), this.LineAnalysis = new zt(), this.DoorsAnalysis = new Xe(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(this.LineAnalysis), this.addComponent(this.DoorsAnalysis), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new He()), Z.finalInstance = this;
|
|
3844
3936
|
}
|
|
3845
3937
|
usePlugin(t) {
|
|
3846
3938
|
return typeof t == "function" && t.call(this, this), this;
|
|
@@ -3853,6 +3945,48 @@ class K extends ge {
|
|
|
3853
3945
|
});
|
|
3854
3946
|
}
|
|
3855
3947
|
}
|
|
3948
|
+
function Et(u, t, e) {
|
|
3949
|
+
return e.reduce((n, s, i) => {
|
|
3950
|
+
const r = s.userData;
|
|
3951
|
+
if (r.parallel(u)) n[0] = i;
|
|
3952
|
+
else {
|
|
3953
|
+
const o = r.center, a = u.pointPosition(o);
|
|
3954
|
+
t !== a ? n[1] = i : n[2] = i;
|
|
3955
|
+
}
|
|
3956
|
+
return n;
|
|
3957
|
+
}, [-1, -1, -1]);
|
|
3958
|
+
}
|
|
3959
|
+
function Je(u, t, e, n, s) {
|
|
3960
|
+
const { point: i } = u[e[0]], r = new D(i.clone(), t.clone());
|
|
3961
|
+
return r.points.forEach((o) => s.insert(o, r)), n.push(r), r;
|
|
3962
|
+
}
|
|
3963
|
+
function $e(u, t, e, n) {
|
|
3964
|
+
const { point: s } = u[e[1]];
|
|
3965
|
+
s.copy(t), n.update(s);
|
|
3966
|
+
}
|
|
3967
|
+
function Ke(u, t, e, n) {
|
|
3968
|
+
const { point: s } = u[e[2]];
|
|
3969
|
+
s.copy(t), n.update(s);
|
|
3970
|
+
}
|
|
3971
|
+
function At(u, t, e, n, s) {
|
|
3972
|
+
const i = e[0] > -1, r = e[1] > -1, o = e[2] > -1;
|
|
3973
|
+
if (r && $e(t, u, e, s), i) {
|
|
3974
|
+
const a = Je(t, u, e, n, s);
|
|
3975
|
+
r && (a.userData = J(t[e[1]].userData?.userData ?? {}));
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
if (o) {
|
|
3979
|
+
if (r) {
|
|
3980
|
+
const a = t[e[1]].userData;
|
|
3981
|
+
u = a.start.distance(t[e[2]].point) < a.end.distance(t[e[2]].point) ? a.start : a.end;
|
|
3982
|
+
}
|
|
3983
|
+
Ke(t, u, e, s);
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
function Ze(u, t = 0.12, e, n) {
|
|
3987
|
+
const s = n.queryPoint(u.start, !0), i = n.queryPoint(u.end, !0), r = u.userData.expandDirect, o = Et(u, r, s), a = Et(u, r, i), c = r === "left" ? u.getRightDirection() : u.getLeftDirection();
|
|
3988
|
+
u.directionMove(c, t * 0.5), u.points.forEach((l) => n.update(l)), At(u.start, s, o, e, n), At(u.end, i, a, e, n);
|
|
3989
|
+
}
|
|
3856
3990
|
class pt {
|
|
3857
3991
|
/** 通过轨迹点查找外墙
|
|
3858
3992
|
* @param lines
|
|
@@ -3860,16 +3994,16 @@ class pt {
|
|
|
3860
3994
|
* @returns
|
|
3861
3995
|
*/
|
|
3862
3996
|
static findExtWallByTraj(t, e, n = 0.4) {
|
|
3863
|
-
const s = new
|
|
3997
|
+
const s = new B(I.fromByLineSegment(...t));
|
|
3864
3998
|
return t.forEach((i) => s.insert({ line: i, userData: void 0 })), t = t.filter((i) => {
|
|
3865
|
-
if (i.userData.groupType === "doubleWall") return;
|
|
3999
|
+
if (i.userData.groupType === "doubleWall" || i.userData.isDoor) return;
|
|
3866
4000
|
const r = i.center, o = /* @__PURE__ */ new Set();
|
|
3867
4001
|
for (const a of e) {
|
|
3868
4002
|
if (o.size === 2) break;
|
|
3869
|
-
const
|
|
3870
|
-
if (!s.queryLineSegment(
|
|
3871
|
-
const
|
|
3872
|
-
|
|
4003
|
+
const c = new D(r, a);
|
|
4004
|
+
if (!s.queryLineSegment(c).filter((h) => h.line === i ? !1 : i.userData.groupType === "wall" ? !0 : !(h.line.parallel(i) && i.getMinLength(h.line) < n && h.line.projectLineSegment(i).length() / i.length() > 0.6)).length) {
|
|
4005
|
+
const h = i.pointPosition(a);
|
|
4006
|
+
h !== "on" && o.add(h);
|
|
3873
4007
|
}
|
|
3874
4008
|
}
|
|
3875
4009
|
if (i.userData.expandDirect = [...o][0], o.size < 2) return !0;
|
|
@@ -3880,100 +4014,29 @@ class pt {
|
|
|
3880
4014
|
* @param trajectoryPoints
|
|
3881
4015
|
*/
|
|
3882
4016
|
static boundExtbyTraj(t, e, n = 0.12, s) {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
const L = w.getSameEndpoint(S);
|
|
3888
|
-
if (L) A.point = L[1];
|
|
3889
|
-
else {
|
|
3890
|
-
const b = S.getIntersection(w);
|
|
3891
|
-
b && (A.point = S.start.equal(b) ? S.start : S.end);
|
|
3892
|
-
}
|
|
3893
|
-
return A;
|
|
3894
|
-
});
|
|
3895
|
-
}
|
|
3896
|
-
function r(w) {
|
|
3897
|
-
const m = w.userData.expandDirect;
|
|
3898
|
-
if (m === "left") {
|
|
3899
|
-
const S = w.getLeftDirection();
|
|
3900
|
-
w.directionMove(S, n * 0.5);
|
|
3901
|
-
} else if (m === "right") {
|
|
3902
|
-
const S = w.getRightDirection();
|
|
3903
|
-
w.directionMove(S, n * 0.5);
|
|
3904
|
-
}
|
|
3905
|
-
}
|
|
3906
|
-
function o({ resultLine: w, type: m, direction: S, point: A }, L, b, v) {
|
|
3907
|
-
const C = [];
|
|
3908
|
-
if (m === "intersect")
|
|
3909
|
-
A && A.copy(L.projectPoint(A) ?? A);
|
|
3910
|
-
else if (S === "vertical") {
|
|
3911
|
-
if (A) {
|
|
3912
|
-
const I = L.projectPoint(A, !1);
|
|
3913
|
-
A.copy(I), L.isPointOnSegment(I) || (L.start.distance(I) < L.end.distance(I) ? C.push(new E(I.clone(), L.start.clone())) : C.push(new E(I.clone(), L.end.clone())));
|
|
3914
|
-
}
|
|
3915
|
-
} else if (!p.includes(w) && A) {
|
|
3916
|
-
let I = L.projectPoint(A, !1), B;
|
|
3917
|
-
if (L.start.distance(A) < L.end.distance(A) ? B = L.start : B = L.end, I) {
|
|
3918
|
-
C.push(new E(A.clone(), I.clone()));
|
|
3919
|
-
const j = new E(I.clone(), B.clone());
|
|
3920
|
-
j.length() && C.push(j);
|
|
3921
|
-
}
|
|
3922
|
-
}
|
|
3923
|
-
b.update(w), C.forEach((I) => Object.assign(I.userData, W(w.userData))), v.push(...C);
|
|
3924
|
-
}
|
|
3925
|
-
function a(w) {
|
|
3926
|
-
const m = w.reduce((L, b) => {
|
|
3927
|
-
let v = b.userData.groupId ?? "door";
|
|
3928
|
-
return b.userData.groupType === "wall" && (v = "wall"), L.append(v, b);
|
|
3929
|
-
}, new nt());
|
|
3930
|
-
return m.size === 1 || (m.group((L, b) => ({ wall: "wall", door: "wall" })[b] ?? "doubleWall").get("doubleWall") ?? []).forEach((L) => {
|
|
3931
|
-
Bt(L).forEach((v) => {
|
|
3932
|
-
v.userData.groupId = "default", v.userData.groupType = "wall";
|
|
3933
|
-
});
|
|
3934
|
-
}), w;
|
|
3935
|
-
}
|
|
3936
|
-
const l = Object.keys(e).map((w) => D.from(e[w])), h = [];
|
|
3937
|
-
let c = t.map(({ start: w, end: m, ...S }) => {
|
|
3938
|
-
const A = new E(D.from(w), D.from(m));
|
|
3939
|
-
return A.userData = S, h.push(w.z ?? 0, m.z ?? 0), A;
|
|
4017
|
+
const i = Object.keys(e).map((f) => w.from(e[f])), r = [];
|
|
4018
|
+
let o = t.map(({ start: f, end: p, ...y }) => {
|
|
4019
|
+
const g = new D(w.from(f), w.from(p));
|
|
4020
|
+
return g.userData = y, r.push(f.z ?? 0, p.z ?? 0), g;
|
|
3940
4021
|
});
|
|
3941
|
-
const
|
|
3942
|
-
let
|
|
3943
|
-
|
|
3944
|
-
const
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
if (!p.includes(A.resultLine)) {
|
|
3949
|
-
let L;
|
|
3950
|
-
return Object.defineProperty(A, "newLine", {
|
|
3951
|
-
get() {
|
|
3952
|
-
return L || (L = E.mergeLines(...w)), L;
|
|
3953
|
-
}
|
|
3954
|
-
}), !0;
|
|
3955
|
-
}
|
|
3956
|
-
o(A, E.mergeLines(...w), g, M);
|
|
3957
|
-
}))).reduce((w, m) => (w.append(m.resultLine, m), w), new nt()).forEach((w) => {
|
|
3958
|
-
w.reduce((m, S) => (m.has(S.point) || m.set(S.point, []), m.get(S.point)?.push(S), m), /* @__PURE__ */ new Map()).forEach((m) => {
|
|
3959
|
-
const S = /* @__PURE__ */ new Set();
|
|
3960
|
-
for (let A = 0; A < m.length; A++) {
|
|
3961
|
-
const L = m[A];
|
|
3962
|
-
S.has(L.point) || (o(L, L.newLine, g, M), S.add(L.point));
|
|
3963
|
-
}
|
|
3964
|
-
});
|
|
3965
|
-
}), c.push(...E.deduplication(M)), c.forEach((w) => w.userData.isWindow && V(w)), c = at(c), c = E.deduplication(c), c = a(c), et(c, d);
|
|
4022
|
+
const a = r.reduce((f, p) => f + p, 0) / r.length;
|
|
4023
|
+
let l = pt.findExtWallByTraj(o, i).filter((f) => f.userData.expandDirect);
|
|
4024
|
+
o = o.filter((f) => !l.includes(f)), o.push(...l), s && s(l, i);
|
|
4025
|
+
const h = V(o), d = [];
|
|
4026
|
+
return l.forEach((f) => {
|
|
4027
|
+
f.userData.isDoor || Ze(f, n, d, h);
|
|
4028
|
+
}), o.push(...d.filter((f) => f.length() > 1e-9)), X(...o), et(o, a);
|
|
3966
4029
|
}
|
|
3967
4030
|
}
|
|
3968
|
-
const
|
|
4031
|
+
const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3969
4032
|
__proto__: null,
|
|
3970
|
-
AxisAlignCorr:
|
|
4033
|
+
AxisAlignCorr: Gt,
|
|
3971
4034
|
BoundExt: pt,
|
|
3972
4035
|
lineDataToOriginalData: et,
|
|
3973
|
-
lineSegmentClipping:
|
|
3974
|
-
recomputedWindow:
|
|
3975
|
-
toOriginalDataItem:
|
|
3976
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
4036
|
+
lineSegmentClipping: ft,
|
|
4037
|
+
recomputedWindow: X,
|
|
4038
|
+
toOriginalDataItem: Bt
|
|
4039
|
+
}, Symbol.toStringTag, { value: "Module" })), bt = {
|
|
3977
4040
|
POSITION: [
|
|
3978
4041
|
"byte",
|
|
3979
4042
|
"byte normalized",
|
|
@@ -4001,36 +4064,36 @@ const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4001
4064
|
"unsigned short"
|
|
4002
4065
|
]
|
|
4003
4066
|
};
|
|
4004
|
-
class
|
|
4067
|
+
class ot {
|
|
4005
4068
|
constructor() {
|
|
4006
4069
|
this.textureUtils = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
4007
|
-
return new
|
|
4070
|
+
return new hn(t);
|
|
4008
4071
|
}), this.register(function(t) {
|
|
4009
|
-
return new
|
|
4072
|
+
return new un(t);
|
|
4010
4073
|
}), this.register(function(t) {
|
|
4011
|
-
return new
|
|
4074
|
+
return new gn(t);
|
|
4012
4075
|
}), this.register(function(t) {
|
|
4013
|
-
return new
|
|
4076
|
+
return new yn(t);
|
|
4014
4077
|
}), this.register(function(t) {
|
|
4015
|
-
return new
|
|
4078
|
+
return new xn(t);
|
|
4016
4079
|
}), this.register(function(t) {
|
|
4017
|
-
return new
|
|
4080
|
+
return new mn(t);
|
|
4018
4081
|
}), this.register(function(t) {
|
|
4019
|
-
return new
|
|
4082
|
+
return new dn(t);
|
|
4020
4083
|
}), this.register(function(t) {
|
|
4021
|
-
return new
|
|
4084
|
+
return new fn(t);
|
|
4022
4085
|
}), this.register(function(t) {
|
|
4023
|
-
return new
|
|
4086
|
+
return new pn(t);
|
|
4024
4087
|
}), this.register(function(t) {
|
|
4025
|
-
return new
|
|
4088
|
+
return new wn(t);
|
|
4026
4089
|
}), this.register(function(t) {
|
|
4027
|
-
return new
|
|
4090
|
+
return new Mn(t);
|
|
4028
4091
|
}), this.register(function(t) {
|
|
4029
|
-
return new
|
|
4092
|
+
return new Dn(t);
|
|
4030
4093
|
}), this.register(function(t) {
|
|
4031
|
-
return new
|
|
4094
|
+
return new Ln(t);
|
|
4032
4095
|
}), this.register(function(t) {
|
|
4033
|
-
return new
|
|
4096
|
+
return new Sn(t);
|
|
4034
4097
|
});
|
|
4035
4098
|
}
|
|
4036
4099
|
register(t) {
|
|
@@ -4043,7 +4106,7 @@ class ct {
|
|
|
4043
4106
|
return this.textureUtils = t, this;
|
|
4044
4107
|
}
|
|
4045
4108
|
parse(t, e, n, s) {
|
|
4046
|
-
const i = new
|
|
4109
|
+
const i = new ln(), r = [];
|
|
4047
4110
|
for (let o = 0, a = this.pluginCallbacks.length; o < a; o++)
|
|
4048
4111
|
r.push(this.pluginCallbacks[o](i));
|
|
4049
4112
|
i.setPlugins(r), i.setTextureUtils(this.textureUtils), i.writeAsync(t, e, s).catch(n);
|
|
@@ -4055,7 +4118,7 @@ class ct {
|
|
|
4055
4118
|
});
|
|
4056
4119
|
}
|
|
4057
4120
|
}
|
|
4058
|
-
const
|
|
4121
|
+
const b = {
|
|
4059
4122
|
POINTS: 0,
|
|
4060
4123
|
LINES: 1,
|
|
4061
4124
|
LINE_LOOP: 2,
|
|
@@ -4079,34 +4142,34 @@ const T = {
|
|
|
4079
4142
|
CLAMP_TO_EDGE: 33071,
|
|
4080
4143
|
MIRRORED_REPEAT: 33648,
|
|
4081
4144
|
REPEAT: 10497
|
|
4082
|
-
},
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
const
|
|
4145
|
+
}, lt = "KHR_mesh_quantization", j = {};
|
|
4146
|
+
j[ae] = b.NEAREST;
|
|
4147
|
+
j[ce] = b.NEAREST_MIPMAP_NEAREST;
|
|
4148
|
+
j[le] = b.NEAREST_MIPMAP_LINEAR;
|
|
4149
|
+
j[he] = b.LINEAR;
|
|
4150
|
+
j[ue] = b.LINEAR_MIPMAP_NEAREST;
|
|
4151
|
+
j[de] = b.LINEAR_MIPMAP_LINEAR;
|
|
4152
|
+
j[fe] = b.CLAMP_TO_EDGE;
|
|
4153
|
+
j[pe] = b.REPEAT;
|
|
4154
|
+
j[ge] = b.MIRRORED_REPEAT;
|
|
4155
|
+
const Tt = {
|
|
4093
4156
|
scale: "scale",
|
|
4094
4157
|
position: "translation",
|
|
4095
4158
|
quaternion: "rotation",
|
|
4096
4159
|
morphTargetInfluences: "weights"
|
|
4097
|
-
},
|
|
4160
|
+
}, Qe = new Kt(), Pt = 12, tn = 1179937895, en = 2, It = 8, nn = 1313821514, sn = 5130562;
|
|
4098
4161
|
function Q(u, t) {
|
|
4099
4162
|
return u.length === t.length && u.every(function(e, n) {
|
|
4100
4163
|
return e === t[n];
|
|
4101
4164
|
});
|
|
4102
4165
|
}
|
|
4103
|
-
function
|
|
4166
|
+
function rn(u) {
|
|
4104
4167
|
return new TextEncoder().encode(u).buffer;
|
|
4105
4168
|
}
|
|
4106
|
-
function
|
|
4169
|
+
function on(u) {
|
|
4107
4170
|
return Q(u.elements, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
4108
4171
|
}
|
|
4109
|
-
function
|
|
4172
|
+
function an(u, t, e) {
|
|
4110
4173
|
const n = {
|
|
4111
4174
|
min: new Array(u.itemSize).fill(Number.POSITIVE_INFINITY),
|
|
4112
4175
|
max: new Array(u.itemSize).fill(Number.NEGATIVE_INFINITY)
|
|
@@ -4114,15 +4177,15 @@ function $e(u, t, e) {
|
|
|
4114
4177
|
for (let s = t; s < t + e; s++)
|
|
4115
4178
|
for (let i = 0; i < u.itemSize; i++) {
|
|
4116
4179
|
let r;
|
|
4117
|
-
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 =
|
|
4180
|
+
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 = dt.normalize(r, u.array))), n.min[i] = Math.min(n.min[i], r), n.max[i] = Math.max(n.max[i], r);
|
|
4118
4181
|
}
|
|
4119
4182
|
return n;
|
|
4120
4183
|
}
|
|
4121
|
-
function
|
|
4184
|
+
function kt(u) {
|
|
4122
4185
|
return Math.ceil(u / 4) * 4;
|
|
4123
4186
|
}
|
|
4124
|
-
function
|
|
4125
|
-
const e =
|
|
4187
|
+
function ht(u, t = 0) {
|
|
4188
|
+
const e = kt(u.byteLength);
|
|
4126
4189
|
if (e !== u.byteLength) {
|
|
4127
4190
|
const n = new Uint8Array(e);
|
|
4128
4191
|
if (n.set(new Uint8Array(u)), t !== 0)
|
|
@@ -4132,10 +4195,10 @@ function ut(u, t = 0) {
|
|
|
4132
4195
|
}
|
|
4133
4196
|
return u;
|
|
4134
4197
|
}
|
|
4135
|
-
function
|
|
4198
|
+
function vt() {
|
|
4136
4199
|
return typeof document > "u" && typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1) : document.createElement("canvas");
|
|
4137
4200
|
}
|
|
4138
|
-
function
|
|
4201
|
+
function cn(u, t) {
|
|
4139
4202
|
if (typeof OffscreenCanvas < "u" && u instanceof OffscreenCanvas) {
|
|
4140
4203
|
let e;
|
|
4141
4204
|
return t === "image/jpeg" ? e = 0.92 : t === "image/webp" && (e = 0.8), u.convertToBlob({
|
|
@@ -4145,12 +4208,12 @@ function Ke(u, t) {
|
|
|
4145
4208
|
} else
|
|
4146
4209
|
return new Promise((e) => u.toBlob(e, t));
|
|
4147
4210
|
}
|
|
4148
|
-
class
|
|
4211
|
+
class ln {
|
|
4149
4212
|
constructor() {
|
|
4150
4213
|
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 = {
|
|
4151
4214
|
asset: {
|
|
4152
4215
|
version: "2.0",
|
|
4153
|
-
generator: "THREE.GLTFExporter r" +
|
|
4216
|
+
generator: "THREE.GLTFExporter r" + Qt
|
|
4154
4217
|
}
|
|
4155
4218
|
}, this.cache = {
|
|
4156
4219
|
meshes: /* @__PURE__ */ new Map(),
|
|
@@ -4186,27 +4249,27 @@ class Ze {
|
|
|
4186
4249
|
}, n), this.options.animations.length > 0 && (this.options.trs = !0), await this.processInputAsync(t), await Promise.all(this.pending);
|
|
4187
4250
|
const s = this, i = s.buffers, r = s.json;
|
|
4188
4251
|
n = s.options;
|
|
4189
|
-
const o = s.extensionsUsed, a = s.extensionsRequired,
|
|
4190
|
-
|
|
4191
|
-
const f =
|
|
4192
|
-
p.setUint32(0, f.byteLength, !0), p.setUint32(4,
|
|
4193
|
-
const y =
|
|
4194
|
-
g.setUint32(0, y.byteLength, !0), g.setUint32(4,
|
|
4195
|
-
const x = new ArrayBuffer(
|
|
4196
|
-
|
|
4197
|
-
const
|
|
4198
|
-
|
|
4199
|
-
const
|
|
4252
|
+
const o = s.extensionsUsed, a = s.extensionsRequired, c = new Blob(i, { type: "application/octet-stream" }), l = Object.keys(o), h = Object.keys(a);
|
|
4253
|
+
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 ? ut(c).then(function(d) {
|
|
4254
|
+
const f = ht(d), p = new DataView(new ArrayBuffer(It));
|
|
4255
|
+
p.setUint32(0, f.byteLength, !0), p.setUint32(4, sn, !0);
|
|
4256
|
+
const y = ht(rn(JSON.stringify(r)), 32), g = new DataView(new ArrayBuffer(It));
|
|
4257
|
+
g.setUint32(0, y.byteLength, !0), g.setUint32(4, nn, !0);
|
|
4258
|
+
const x = new ArrayBuffer(Pt), m = new DataView(x);
|
|
4259
|
+
m.setUint32(0, tn, !0), m.setUint32(4, en, !0);
|
|
4260
|
+
const L = Pt + g.byteLength + y.byteLength + p.byteLength + f.byteLength;
|
|
4261
|
+
m.setUint32(8, L, !0);
|
|
4262
|
+
const M = new Blob([
|
|
4200
4263
|
x,
|
|
4201
4264
|
g,
|
|
4202
4265
|
y,
|
|
4203
4266
|
p,
|
|
4204
4267
|
f
|
|
4205
4268
|
], { type: "application/octet-stream" });
|
|
4206
|
-
|
|
4269
|
+
ut(M).then((S) => {
|
|
4207
4270
|
e(S);
|
|
4208
4271
|
});
|
|
4209
|
-
}) : r.buffers && r.buffers.length > 0 ?
|
|
4272
|
+
}) : r.buffers && r.buffers.length > 0 ? En(c).then((d) => {
|
|
4210
4273
|
r.buffers[0].uri = d, e(r);
|
|
4211
4274
|
}) : e(r);
|
|
4212
4275
|
}
|
|
@@ -4254,7 +4317,7 @@ class Ze {
|
|
|
4254
4317
|
*/
|
|
4255
4318
|
isNormalizedNormalAttribute(t) {
|
|
4256
4319
|
if (this.cache.attributesNormalized.has(t)) return !1;
|
|
4257
|
-
const n = new
|
|
4320
|
+
const n = new it();
|
|
4258
4321
|
for (let s = 0, i = t.count; s < i; s++)
|
|
4259
4322
|
if (Math.abs(n.fromBufferAttribute(t, s).length() - 1) > 5e-4) return !1;
|
|
4260
4323
|
return !0;
|
|
@@ -4269,7 +4332,7 @@ class Ze {
|
|
|
4269
4332
|
createNormalizedNormalAttribute(t) {
|
|
4270
4333
|
const e = this.cache;
|
|
4271
4334
|
if (e.attributesNormalized.has(t)) return e.attributesNormalized.get(t);
|
|
4272
|
-
const n = t.clone(), s = new
|
|
4335
|
+
const n = t.clone(), s = new it();
|
|
4273
4336
|
for (let i = 0, r = n.count; i < r; i++)
|
|
4274
4337
|
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);
|
|
4275
4338
|
return e.attributesNormalized.set(t, n), n;
|
|
@@ -4289,35 +4352,35 @@ class Ze {
|
|
|
4289
4352
|
async buildMetalRoughTextureAsync(t, e) {
|
|
4290
4353
|
if (t === e) return t;
|
|
4291
4354
|
function n(f) {
|
|
4292
|
-
return f.colorSpace ===
|
|
4355
|
+
return f.colorSpace === oe ? function(y) {
|
|
4293
4356
|
return y < 0.04045 ? y * 0.0773993808 : Math.pow(y * 0.9478672986 + 0.0521327014, 2.4);
|
|
4294
4357
|
} : function(y) {
|
|
4295
4358
|
return y;
|
|
4296
4359
|
};
|
|
4297
4360
|
}
|
|
4298
|
-
t instanceof
|
|
4299
|
-
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 =
|
|
4361
|
+
t instanceof ct && (t = await this.decompressTextureAsync(t)), e instanceof ct && (e = await this.decompressTextureAsync(e));
|
|
4362
|
+
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 = vt();
|
|
4300
4363
|
a.width = r, a.height = o;
|
|
4301
|
-
const
|
|
4364
|
+
const c = a.getContext("2d", {
|
|
4302
4365
|
willReadFrequently: !0
|
|
4303
4366
|
});
|
|
4304
|
-
|
|
4305
|
-
const
|
|
4367
|
+
c.fillStyle = "#00ffff", c.fillRect(0, 0, r, o);
|
|
4368
|
+
const l = c.getImageData(0, 0, r, o);
|
|
4306
4369
|
if (s) {
|
|
4307
|
-
|
|
4308
|
-
const f = n(t), p =
|
|
4370
|
+
c.drawImage(s, 0, 0, r, o);
|
|
4371
|
+
const f = n(t), p = c.getImageData(0, 0, r, o).data;
|
|
4309
4372
|
for (let y = 2; y < p.length; y += 4)
|
|
4310
|
-
|
|
4373
|
+
l.data[y] = f(p[y] / 256) * 256;
|
|
4311
4374
|
}
|
|
4312
4375
|
if (i) {
|
|
4313
|
-
|
|
4314
|
-
const f = n(e), p =
|
|
4376
|
+
c.drawImage(i, 0, 0, r, o);
|
|
4377
|
+
const f = n(e), p = c.getImageData(0, 0, r, o).data;
|
|
4315
4378
|
for (let y = 1; y < p.length; y += 4)
|
|
4316
|
-
|
|
4379
|
+
l.data[y] = f(p[y] / 256) * 256;
|
|
4317
4380
|
}
|
|
4318
|
-
|
|
4381
|
+
c.putImageData(l, 0, 0);
|
|
4319
4382
|
const d = (t || e).clone();
|
|
4320
|
-
return d.source = new
|
|
4383
|
+
return d.source = new te(a), d.colorSpace = ee, 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;
|
|
4321
4384
|
}
|
|
4322
4385
|
async decompressTextureAsync(t, e = 1 / 0) {
|
|
4323
4386
|
if (this.textureUtils === null)
|
|
@@ -4347,34 +4410,34 @@ class Ze {
|
|
|
4347
4410
|
r.bufferViews || (r.bufferViews = []);
|
|
4348
4411
|
let o;
|
|
4349
4412
|
switch (e) {
|
|
4350
|
-
case
|
|
4351
|
-
case
|
|
4413
|
+
case b.BYTE:
|
|
4414
|
+
case b.UNSIGNED_BYTE:
|
|
4352
4415
|
o = 1;
|
|
4353
4416
|
break;
|
|
4354
|
-
case
|
|
4355
|
-
case
|
|
4417
|
+
case b.SHORT:
|
|
4418
|
+
case b.UNSIGNED_SHORT:
|
|
4356
4419
|
o = 2;
|
|
4357
4420
|
break;
|
|
4358
4421
|
default:
|
|
4359
4422
|
o = 4;
|
|
4360
4423
|
}
|
|
4361
4424
|
let a = t.itemSize * o;
|
|
4362
|
-
i ===
|
|
4363
|
-
const
|
|
4364
|
-
let
|
|
4425
|
+
i === b.ARRAY_BUFFER && (a = Math.ceil(a / 4) * 4);
|
|
4426
|
+
const c = kt(s * a), l = new DataView(new ArrayBuffer(c));
|
|
4427
|
+
let h = 0;
|
|
4365
4428
|
for (let p = n; p < n + s; p++) {
|
|
4366
4429
|
for (let y = 0; y < t.itemSize; y++) {
|
|
4367
4430
|
let g;
|
|
4368
|
-
t.itemSize > 4 ? g = t.array[p * t.itemSize + y] : (y === 0 ? g = t.getX(p) : y === 1 ? g = t.getY(p) : y === 2 ? g = t.getZ(p) : y === 3 && (g = t.getW(p)), t.normalized === !0 && (g =
|
|
4431
|
+
t.itemSize > 4 ? g = t.array[p * t.itemSize + y] : (y === 0 ? g = t.getX(p) : y === 1 ? g = t.getY(p) : y === 2 ? g = t.getZ(p) : y === 3 && (g = t.getW(p)), t.normalized === !0 && (g = dt.normalize(g, t.array))), e === b.FLOAT ? l.setFloat32(h, g, !0) : e === b.INT ? l.setInt32(h, g, !0) : e === b.UNSIGNED_INT ? l.setUint32(h, g, !0) : e === b.SHORT ? l.setInt16(h, g, !0) : e === b.UNSIGNED_SHORT ? l.setUint16(h, g, !0) : e === b.BYTE ? l.setInt8(h, g) : e === b.UNSIGNED_BYTE && l.setUint8(h, g), h += o;
|
|
4369
4432
|
}
|
|
4370
|
-
|
|
4433
|
+
h % a !== 0 && (h += a - h % a);
|
|
4371
4434
|
}
|
|
4372
4435
|
const d = {
|
|
4373
|
-
buffer: this.processBuffer(
|
|
4436
|
+
buffer: this.processBuffer(l.buffer),
|
|
4374
4437
|
byteOffset: this.byteOffset,
|
|
4375
|
-
byteLength:
|
|
4438
|
+
byteLength: c
|
|
4376
4439
|
};
|
|
4377
|
-
return i !== void 0 && (d.target = i), i ===
|
|
4440
|
+
return i !== void 0 && (d.target = i), i === b.ARRAY_BUFFER && (d.byteStride = a), this.byteOffset += c, r.bufferViews.push(d), {
|
|
4378
4441
|
id: r.bufferViews.length - 1,
|
|
4379
4442
|
byteLength: 0
|
|
4380
4443
|
};
|
|
@@ -4387,8 +4450,8 @@ class Ze {
|
|
|
4387
4450
|
processBufferViewImage(t) {
|
|
4388
4451
|
const e = this, n = e.json;
|
|
4389
4452
|
return n.bufferViews || (n.bufferViews = []), new Promise(async function(s) {
|
|
4390
|
-
|
|
4391
|
-
const r =
|
|
4453
|
+
ut(t).then((i) => {
|
|
4454
|
+
const r = ht(i), o = {
|
|
4392
4455
|
buffer: e.processBuffer(r),
|
|
4393
4456
|
byteOffset: e.byteOffset,
|
|
4394
4457
|
byteLength: r.byteLength
|
|
@@ -4416,35 +4479,35 @@ class Ze {
|
|
|
4416
4479
|
};
|
|
4417
4480
|
let o;
|
|
4418
4481
|
if (t.array.constructor === Float32Array)
|
|
4419
|
-
o =
|
|
4482
|
+
o = b.FLOAT;
|
|
4420
4483
|
else if (t.array.constructor === Int32Array)
|
|
4421
|
-
o =
|
|
4484
|
+
o = b.INT;
|
|
4422
4485
|
else if (t.array.constructor === Uint32Array)
|
|
4423
|
-
o =
|
|
4486
|
+
o = b.UNSIGNED_INT;
|
|
4424
4487
|
else if (t.array.constructor === Int16Array)
|
|
4425
|
-
o =
|
|
4488
|
+
o = b.SHORT;
|
|
4426
4489
|
else if (t.array.constructor === Uint16Array)
|
|
4427
|
-
o =
|
|
4490
|
+
o = b.UNSIGNED_SHORT;
|
|
4428
4491
|
else if (t.array.constructor === Int8Array)
|
|
4429
|
-
o =
|
|
4492
|
+
o = b.BYTE;
|
|
4430
4493
|
else if (t.array.constructor === Uint8Array)
|
|
4431
|
-
o =
|
|
4494
|
+
o = b.UNSIGNED_BYTE;
|
|
4432
4495
|
else
|
|
4433
4496
|
throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + t.array.constructor.name);
|
|
4434
4497
|
if (n === void 0 && (n = 0), (s === void 0 || s === 1 / 0) && (s = t.count), s === 0) return null;
|
|
4435
|
-
const a =
|
|
4436
|
-
let
|
|
4437
|
-
e !== void 0 && (
|
|
4438
|
-
const
|
|
4439
|
-
bufferView:
|
|
4440
|
-
byteOffset:
|
|
4498
|
+
const a = an(t, n, s);
|
|
4499
|
+
let c;
|
|
4500
|
+
e !== void 0 && (c = t === e.index ? b.ELEMENT_ARRAY_BUFFER : b.ARRAY_BUFFER);
|
|
4501
|
+
const l = this.processBufferView(t, o, n, s, c), h = {
|
|
4502
|
+
bufferView: l.id,
|
|
4503
|
+
byteOffset: l.byteOffset,
|
|
4441
4504
|
componentType: o,
|
|
4442
4505
|
count: s,
|
|
4443
4506
|
max: a.max,
|
|
4444
4507
|
min: a.min,
|
|
4445
4508
|
type: r[t.itemSize]
|
|
4446
4509
|
};
|
|
4447
|
-
return t.normalized === !0 && (
|
|
4510
|
+
return t.normalized === !0 && (h.normalized = !0), i.accessors || (i.accessors = []), i.accessors.push(h) - 1;
|
|
4448
4511
|
}
|
|
4449
4512
|
/**
|
|
4450
4513
|
* Process image
|
|
@@ -4456,18 +4519,18 @@ class Ze {
|
|
|
4456
4519
|
*/
|
|
4457
4520
|
processImage(t, e, n, s = "image/png") {
|
|
4458
4521
|
if (t !== null) {
|
|
4459
|
-
const i = this, r = i.cache, o = i.json, a = i.options,
|
|
4522
|
+
const i = this, r = i.cache, o = i.json, a = i.options, c = i.pending;
|
|
4460
4523
|
r.images.has(t) || r.images.set(t, {});
|
|
4461
|
-
const
|
|
4462
|
-
if (h
|
|
4524
|
+
const l = r.images.get(t), h = s + ":flipY/" + n.toString();
|
|
4525
|
+
if (l[h] !== void 0) return l[h];
|
|
4463
4526
|
o.images || (o.images = []);
|
|
4464
|
-
const d = { mimeType: s }, f =
|
|
4527
|
+
const d = { mimeType: s }, f = vt();
|
|
4465
4528
|
f.width = Math.min(t.width, a.maxTextureSize), f.height = Math.min(t.height, a.maxTextureSize);
|
|
4466
4529
|
const p = f.getContext("2d", {
|
|
4467
4530
|
willReadFrequently: !0
|
|
4468
4531
|
});
|
|
4469
4532
|
if (n === !0 && (p.translate(0, f.height), p.scale(1, -1)), t.data !== void 0) {
|
|
4470
|
-
e !==
|
|
4533
|
+
e !== ne && 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);
|
|
4471
4534
|
const g = new Uint8ClampedArray(t.height * t.width * 4);
|
|
4472
4535
|
for (let x = 0; x < g.length; x += 4)
|
|
4473
4536
|
g[x + 0] = t.data[x + 0], g[x + 1] = t.data[x + 1], g[x + 2] = t.data[x + 2], g[x + 3] = t.data[x + 3];
|
|
@@ -4476,13 +4539,13 @@ class Ze {
|
|
|
4476
4539
|
p.drawImage(t, 0, 0, f.width, f.height);
|
|
4477
4540
|
else
|
|
4478
4541
|
throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");
|
|
4479
|
-
a.binary === !0 ?
|
|
4480
|
-
|
|
4542
|
+
a.binary === !0 ? c.push(
|
|
4543
|
+
cn(f, s).then((g) => i.processBufferViewImage(g)).then((g) => {
|
|
4481
4544
|
d.bufferView = g;
|
|
4482
4545
|
})
|
|
4483
|
-
) : d.uri =
|
|
4546
|
+
) : d.uri = se.getDataURL(f, s);
|
|
4484
4547
|
const y = o.images.push(d) - 1;
|
|
4485
|
-
return h
|
|
4548
|
+
return l[h] = y, y;
|
|
4486
4549
|
} else
|
|
4487
4550
|
throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
|
|
4488
4551
|
}
|
|
@@ -4495,10 +4558,10 @@ class Ze {
|
|
|
4495
4558
|
const e = this.json;
|
|
4496
4559
|
e.samplers || (e.samplers = []);
|
|
4497
4560
|
const n = {
|
|
4498
|
-
magFilter:
|
|
4499
|
-
minFilter:
|
|
4500
|
-
wrapS:
|
|
4501
|
-
wrapT:
|
|
4561
|
+
magFilter: j[t.magFilter],
|
|
4562
|
+
minFilter: j[t.minFilter],
|
|
4563
|
+
wrapS: j[t.wrapS],
|
|
4564
|
+
wrapT: j[t.wrapT]
|
|
4502
4565
|
};
|
|
4503
4566
|
return e.samplers.push(n) - 1;
|
|
4504
4567
|
}
|
|
@@ -4510,15 +4573,15 @@ class Ze {
|
|
|
4510
4573
|
async processTextureAsync(t) {
|
|
4511
4574
|
const n = this.options, s = this.cache, i = this.json;
|
|
4512
4575
|
if (s.textures.has(t)) return s.textures.get(t);
|
|
4513
|
-
i.textures || (i.textures = []), t instanceof
|
|
4576
|
+
i.textures || (i.textures = []), t instanceof ct && (t = await this.decompressTextureAsync(t, n.maxTextureSize));
|
|
4514
4577
|
let r = t.userData.mimeType;
|
|
4515
4578
|
r === "image/webp" && (r = "image/png");
|
|
4516
4579
|
const o = {
|
|
4517
4580
|
sampler: this.processSampler(t),
|
|
4518
4581
|
source: this.processImage(t.image, t.format, t.flipY, r)
|
|
4519
4582
|
};
|
|
4520
|
-
t.name && (o.name = t.name), await this._invokeAllAsync(async function(
|
|
4521
|
-
|
|
4583
|
+
t.name && (o.name = t.name), await this._invokeAllAsync(async function(c) {
|
|
4584
|
+
c.writeTexture && await c.writeTexture(t, o);
|
|
4522
4585
|
});
|
|
4523
4586
|
const a = i.textures.push(o) - 1;
|
|
4524
4587
|
return s.textures.set(t, a), a;
|
|
@@ -4554,11 +4617,11 @@ class Ze {
|
|
|
4554
4617
|
if (t.emissive) {
|
|
4555
4618
|
const o = t.emissive;
|
|
4556
4619
|
if (Math.max(o.r, o.g, o.b) > 0 && (s.emissiveFactor = t.emissive.toArray()), t.emissiveMap) {
|
|
4557
|
-
const
|
|
4620
|
+
const c = {
|
|
4558
4621
|
index: await this.processTextureAsync(t.emissiveMap),
|
|
4559
4622
|
texCoord: t.emissiveMap.channel
|
|
4560
4623
|
};
|
|
4561
|
-
this.applyTextureTransform(
|
|
4624
|
+
this.applyTextureTransform(c, t.emissiveMap), s.emissiveTexture = c;
|
|
4562
4625
|
}
|
|
4563
4626
|
}
|
|
4564
4627
|
if (t.normalMap) {
|
|
@@ -4575,7 +4638,7 @@ class Ze {
|
|
|
4575
4638
|
};
|
|
4576
4639
|
t.aoMapIntensity !== 1 && (o.strength = t.aoMapIntensity), this.applyTextureTransform(o, t.aoMap), s.occlusionTexture = o;
|
|
4577
4640
|
}
|
|
4578
|
-
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side ===
|
|
4641
|
+
t.transparent ? s.alphaMode = "BLEND" : t.alphaTest > 0 && (s.alphaMode = "MASK", s.alphaCutoff = t.alphaTest), t.side === ie && (s.doubleSided = !0), t.name !== "" && (s.name = t.name), this.serializeUserData(t, s), await this._invokeAllAsync(async function(o) {
|
|
4579
4642
|
o.writeMaterialAsync && await o.writeMaterialAsync(t, s);
|
|
4580
4643
|
});
|
|
4581
4644
|
const r = n.materials.push(s) - 1;
|
|
@@ -4589,16 +4652,16 @@ class Ze {
|
|
|
4589
4652
|
async processMeshAsync(t) {
|
|
4590
4653
|
const e = this.cache, n = this.json, s = [t.geometry.uuid];
|
|
4591
4654
|
if (Array.isArray(t.material))
|
|
4592
|
-
for (let
|
|
4593
|
-
s.push(t.material[
|
|
4655
|
+
for (let M = 0, S = t.material.length; M < S; M++)
|
|
4656
|
+
s.push(t.material[M].uuid);
|
|
4594
4657
|
else
|
|
4595
4658
|
s.push(t.material.uuid);
|
|
4596
4659
|
const i = s.join(":");
|
|
4597
4660
|
if (e.meshes.has(i)) return e.meshes.get(i);
|
|
4598
4661
|
const r = t.geometry;
|
|
4599
4662
|
let o;
|
|
4600
|
-
t.isLineSegments ? o =
|
|
4601
|
-
const a = {},
|
|
4663
|
+
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;
|
|
4664
|
+
const a = {}, c = {}, l = [], h = [], d = {
|
|
4602
4665
|
uv: "TEXCOORD_0",
|
|
4603
4666
|
uv1: "TEXCOORD_1",
|
|
4604
4667
|
uv2: "TEXCOORD_2",
|
|
@@ -4609,76 +4672,76 @@ class Ze {
|
|
|
4609
4672
|
}, f = r.getAttribute("normal");
|
|
4610
4673
|
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)));
|
|
4611
4674
|
let p = null;
|
|
4612
|
-
for (let
|
|
4613
|
-
if (
|
|
4614
|
-
const S = r.attributes[
|
|
4615
|
-
if (
|
|
4616
|
-
|
|
4675
|
+
for (let M in r.attributes) {
|
|
4676
|
+
if (M.slice(0, 5) === "morph") continue;
|
|
4677
|
+
const S = r.attributes[M];
|
|
4678
|
+
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))) {
|
|
4679
|
+
c[M] = e.attributes.get(this.getUID(S));
|
|
4617
4680
|
continue;
|
|
4618
4681
|
}
|
|
4619
4682
|
p = null;
|
|
4620
|
-
const
|
|
4621
|
-
|
|
4622
|
-
const
|
|
4623
|
-
|
|
4683
|
+
const E = S.array;
|
|
4684
|
+
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 = ot.Utils.toFloat32BufferAttribute(S));
|
|
4685
|
+
const T = this.processAccessor(p || S, r);
|
|
4686
|
+
T !== null && (M.startsWith("_") || this.detectMeshQuantization(M, S), c[M] = T, e.attributes.set(this.getUID(S), T));
|
|
4624
4687
|
}
|
|
4625
|
-
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(
|
|
4688
|
+
if (f !== void 0 && r.setAttribute("normal", f), Object.keys(c).length === 0) return null;
|
|
4626
4689
|
if (t.morphTargetInfluences !== void 0 && t.morphTargetInfluences.length > 0) {
|
|
4627
|
-
const
|
|
4690
|
+
const M = [], S = [], A = {};
|
|
4628
4691
|
if (t.morphTargetDictionary !== void 0)
|
|
4629
|
-
for (const
|
|
4630
|
-
A[t.morphTargetDictionary[
|
|
4631
|
-
for (let
|
|
4632
|
-
const
|
|
4633
|
-
let
|
|
4634
|
-
for (const
|
|
4635
|
-
if (
|
|
4636
|
-
|
|
4692
|
+
for (const E in t.morphTargetDictionary)
|
|
4693
|
+
A[t.morphTargetDictionary[E]] = E;
|
|
4694
|
+
for (let E = 0; E < t.morphTargetInfluences.length; ++E) {
|
|
4695
|
+
const T = {};
|
|
4696
|
+
let C = !1;
|
|
4697
|
+
for (const N in r.morphAttributes) {
|
|
4698
|
+
if (N !== "position" && N !== "normal") {
|
|
4699
|
+
C || (console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."), C = !0);
|
|
4637
4700
|
continue;
|
|
4638
4701
|
}
|
|
4639
|
-
const
|
|
4640
|
-
if (e.attributes.has(this.getUID(
|
|
4641
|
-
|
|
4702
|
+
const O = r.morphAttributes[N][E], q = N.toUpperCase(), U = r.attributes[N];
|
|
4703
|
+
if (e.attributes.has(this.getUID(O, !0))) {
|
|
4704
|
+
T[q] = e.attributes.get(this.getUID(O, !0));
|
|
4642
4705
|
continue;
|
|
4643
4706
|
}
|
|
4644
|
-
const
|
|
4707
|
+
const R = O.clone();
|
|
4645
4708
|
if (!r.morphTargetsRelative)
|
|
4646
|
-
for (let
|
|
4647
|
-
for (let
|
|
4648
|
-
|
|
4649
|
-
|
|
4709
|
+
for (let v = 0, K = O.count; v < K; v++)
|
|
4710
|
+
for (let F = 0; F < O.itemSize; F++)
|
|
4711
|
+
F === 0 && R.setX(v, O.getX(v) - U.getX(v)), F === 1 && R.setY(v, O.getY(v) - U.getY(v)), F === 2 && R.setZ(v, O.getZ(v) - U.getZ(v)), F === 3 && R.setW(v, O.getW(v) - U.getW(v));
|
|
4712
|
+
T[q] = this.processAccessor(R, r), e.attributes.set(this.getUID(U, !0), T[q]);
|
|
4650
4713
|
}
|
|
4651
|
-
|
|
4714
|
+
h.push(T), M.push(t.morphTargetInfluences[E]), t.morphTargetDictionary !== void 0 && S.push(A[E]);
|
|
4652
4715
|
}
|
|
4653
|
-
a.weights =
|
|
4716
|
+
a.weights = M, S.length > 0 && (a.extras = {}, a.extras.targetNames = S);
|
|
4654
4717
|
}
|
|
4655
4718
|
const y = Array.isArray(t.material);
|
|
4656
4719
|
if (y && r.groups.length === 0) return null;
|
|
4657
4720
|
let g = !1;
|
|
4658
4721
|
if (y && r.index === null) {
|
|
4659
|
-
const
|
|
4722
|
+
const M = [];
|
|
4660
4723
|
for (let S = 0, A = r.attributes.position.count; S < A; S++)
|
|
4661
|
-
|
|
4662
|
-
r.setIndex(
|
|
4724
|
+
M[S] = S;
|
|
4725
|
+
r.setIndex(M), g = !0;
|
|
4663
4726
|
}
|
|
4664
|
-
const x = y ? t.material : [t.material],
|
|
4665
|
-
for (let
|
|
4727
|
+
const x = y ? t.material : [t.material], m = y ? r.groups : [{ materialIndex: 0, start: void 0, count: void 0 }];
|
|
4728
|
+
for (let M = 0, S = m.length; M < S; M++) {
|
|
4666
4729
|
const A = {
|
|
4667
4730
|
mode: o,
|
|
4668
|
-
attributes:
|
|
4731
|
+
attributes: c
|
|
4669
4732
|
};
|
|
4670
|
-
if (this.serializeUserData(r, A),
|
|
4671
|
-
let
|
|
4672
|
-
(M
|
|
4733
|
+
if (this.serializeUserData(r, A), h.length > 0 && (A.targets = h), r.index !== null) {
|
|
4734
|
+
let T = this.getUID(r.index);
|
|
4735
|
+
(m[M].start !== void 0 || m[M].count !== void 0) && (T += ":" + m[M].start + ":" + m[M].count), e.attributes.has(T) ? A.indices = e.attributes.get(T) : (A.indices = this.processAccessor(r.index, r, m[M].start, m[M].count), e.attributes.set(T, A.indices)), A.indices === null && delete A.indices;
|
|
4673
4736
|
}
|
|
4674
|
-
const
|
|
4675
|
-
|
|
4737
|
+
const E = await this.processMaterialAsync(x[m[M].materialIndex]);
|
|
4738
|
+
E !== null && (A.material = E), l.push(A);
|
|
4676
4739
|
}
|
|
4677
|
-
g === !0 && r.setIndex(null), a.primitives =
|
|
4678
|
-
|
|
4740
|
+
g === !0 && r.setIndex(null), a.primitives = l, n.meshes || (n.meshes = []), await this._invokeAllAsync(function(M) {
|
|
4741
|
+
M.writeMesh && M.writeMesh(t, a);
|
|
4679
4742
|
});
|
|
4680
|
-
const
|
|
4681
|
-
return e.meshes.set(i,
|
|
4743
|
+
const L = n.meshes.push(a) - 1;
|
|
4744
|
+
return e.meshes.set(i, L), L;
|
|
4682
4745
|
}
|
|
4683
4746
|
/**
|
|
4684
4747
|
* If a vertex attribute with a
|
|
@@ -4692,7 +4755,7 @@ class Ze {
|
|
|
4692
4755
|
* @param {THREE.BufferAttribute} attribute
|
|
4693
4756
|
*/
|
|
4694
4757
|
detectMeshQuantization(t, e) {
|
|
4695
|
-
if (this.extensionsUsed[
|
|
4758
|
+
if (this.extensionsUsed[lt]) return;
|
|
4696
4759
|
let n;
|
|
4697
4760
|
switch (e.array.constructor) {
|
|
4698
4761
|
case Int8Array:
|
|
@@ -4712,7 +4775,7 @@ class Ze {
|
|
|
4712
4775
|
}
|
|
4713
4776
|
e.normalized && (n += " normalized");
|
|
4714
4777
|
const s = t.split("_", 1)[0];
|
|
4715
|
-
|
|
4778
|
+
bt[s] && bt[s].includes(n) && (this.extensionsUsed[lt] = !0, this.extensionsRequired[lt] = !0);
|
|
4716
4779
|
}
|
|
4717
4780
|
/**
|
|
4718
4781
|
* Process camera
|
|
@@ -4732,7 +4795,7 @@ class Ze {
|
|
|
4732
4795
|
znear: t.near < 0 ? 0 : t.near
|
|
4733
4796
|
} : s.perspective = {
|
|
4734
4797
|
aspectRatio: t.aspect,
|
|
4735
|
-
yfov:
|
|
4798
|
+
yfov: dt.degToRad(t.fov),
|
|
4736
4799
|
zfar: t.far <= 0 ? 1e-3 : t.far,
|
|
4737
4800
|
znear: t.near < 0 ? 0 : t.near
|
|
4738
4801
|
}, t.name !== "" && (s.name = t.type), e.cameras.push(s) - 1;
|
|
@@ -4749,23 +4812,23 @@ class Ze {
|
|
|
4749
4812
|
*/
|
|
4750
4813
|
processAnimation(t, e) {
|
|
4751
4814
|
const n = this.json, s = this.nodeMap;
|
|
4752
|
-
n.animations || (n.animations = []), t =
|
|
4815
|
+
n.animations || (n.animations = []), t = ot.Utils.mergeMorphTargetTracks(t.clone(), e);
|
|
4753
4816
|
const i = t.tracks, r = [], o = [];
|
|
4754
|
-
for (let
|
|
4755
|
-
const
|
|
4756
|
-
let d =
|
|
4757
|
-
const f =
|
|
4758
|
-
if (
|
|
4759
|
-
console.warn('THREE.GLTFExporter: Could not export animation track "%s".',
|
|
4817
|
+
for (let c = 0; c < i.length; ++c) {
|
|
4818
|
+
const l = i[c], h = rt.parseTrackName(l.name);
|
|
4819
|
+
let d = rt.findNode(e, h.nodeName);
|
|
4820
|
+
const f = Tt[h.propertyName];
|
|
4821
|
+
if (h.objectName === "bones" && (d.isSkinnedMesh === !0 ? d = d.skeleton.getBoneByName(h.objectIndex) : d = void 0), !d || !f) {
|
|
4822
|
+
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
4760
4823
|
continue;
|
|
4761
4824
|
}
|
|
4762
4825
|
const p = 1;
|
|
4763
|
-
let y =
|
|
4764
|
-
f ===
|
|
4826
|
+
let y = l.values.length / l.times.length;
|
|
4827
|
+
f === Tt.morphTargetInfluences && (y /= d.morphTargetInfluences.length);
|
|
4765
4828
|
let g;
|
|
4766
|
-
|
|
4767
|
-
input: this.processAccessor(new
|
|
4768
|
-
output: this.processAccessor(new
|
|
4829
|
+
l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === !0 ? (g = "CUBICSPLINE", y /= 3) : l.getInterpolation() === re ? g = "STEP" : g = "LINEAR", o.push({
|
|
4830
|
+
input: this.processAccessor(new _(l.times, p)),
|
|
4831
|
+
output: this.processAccessor(new _(l.values, y)),
|
|
4769
4832
|
interpolation: g
|
|
4770
4833
|
}), r.push({
|
|
4771
4834
|
sampler: o.length - 1,
|
|
@@ -4791,11 +4854,11 @@ class Ze {
|
|
|
4791
4854
|
if (i === void 0) return null;
|
|
4792
4855
|
const r = t.skeleton.bones[0];
|
|
4793
4856
|
if (r === void 0) return null;
|
|
4794
|
-
const o = [], a = new Float32Array(i.bones.length * 16),
|
|
4795
|
-
for (let
|
|
4796
|
-
o.push(n.get(i.bones[
|
|
4857
|
+
const o = [], a = new Float32Array(i.bones.length * 16), c = new Ct();
|
|
4858
|
+
for (let h = 0; h < i.bones.length; ++h)
|
|
4859
|
+
o.push(n.get(i.bones[h])), c.copy(i.boneInverses[h]), c.multiply(t.bindMatrix).toArray(a, h * 16);
|
|
4797
4860
|
return e.skins === void 0 && (e.skins = []), e.skins.push({
|
|
4798
|
-
inverseBindMatrices: this.processAccessor(new
|
|
4861
|
+
inverseBindMatrices: this.processAccessor(new _(a, 16)),
|
|
4799
4862
|
joints: o,
|
|
4800
4863
|
skeleton: n.get(r)
|
|
4801
4864
|
}), s.skin = e.skins.length - 1;
|
|
@@ -4810,10 +4873,10 @@ class Ze {
|
|
|
4810
4873
|
e.nodes || (e.nodes = []);
|
|
4811
4874
|
const i = {};
|
|
4812
4875
|
if (n.trs) {
|
|
4813
|
-
const o = t.quaternion.toArray(), a = t.position.toArray(),
|
|
4814
|
-
Q(o, [0, 0, 0, 1]) || (i.rotation = o), Q(a, [0, 0, 0]) || (i.translation = a), Q(
|
|
4876
|
+
const o = t.quaternion.toArray(), a = t.position.toArray(), c = t.scale.toArray();
|
|
4877
|
+
Q(o, [0, 0, 0, 1]) || (i.rotation = o), Q(a, [0, 0, 0]) || (i.translation = a), Q(c, [1, 1, 1]) || (i.scale = c);
|
|
4815
4878
|
} else
|
|
4816
|
-
t.matrixAutoUpdate && t.updateMatrix(),
|
|
4879
|
+
t.matrixAutoUpdate && t.updateMatrix(), on(t.matrix) === !1 && (i.matrix = t.matrix.elements);
|
|
4817
4880
|
if (t.name !== "" && (i.name = String(t.name)), this.serializeUserData(t, i), t.isMesh || t.isLine || t.isPoints) {
|
|
4818
4881
|
const o = await this.processMeshAsync(t);
|
|
4819
4882
|
o !== null && (i.mesh = o);
|
|
@@ -4822,11 +4885,11 @@ class Ze {
|
|
|
4822
4885
|
const r = e.nodes.push(i) - 1;
|
|
4823
4886
|
if (s.set(t, r), t.children.length > 0) {
|
|
4824
4887
|
const o = [];
|
|
4825
|
-
for (let a = 0,
|
|
4826
|
-
const
|
|
4827
|
-
if (
|
|
4828
|
-
const
|
|
4829
|
-
|
|
4888
|
+
for (let a = 0, c = t.children.length; a < c; a++) {
|
|
4889
|
+
const l = t.children[a];
|
|
4890
|
+
if (l.visible || n.onlyVisible === !1) {
|
|
4891
|
+
const h = await this.processNodeAsync(l);
|
|
4892
|
+
h !== null && o.push(h);
|
|
4830
4893
|
}
|
|
4831
4894
|
}
|
|
4832
4895
|
o.length > 0 && (i.children = o);
|
|
@@ -4848,8 +4911,8 @@ class Ze {
|
|
|
4848
4911
|
for (let r = 0, o = t.children.length; r < o; r++) {
|
|
4849
4912
|
const a = t.children[r];
|
|
4850
4913
|
if (a.visible || n.onlyVisible === !1) {
|
|
4851
|
-
const
|
|
4852
|
-
|
|
4914
|
+
const c = await this.processNodeAsync(a);
|
|
4915
|
+
c !== null && i.push(c);
|
|
4853
4916
|
}
|
|
4854
4917
|
}
|
|
4855
4918
|
i.length > 0 && (s.nodes = i), this.serializeUserData(t, s);
|
|
@@ -4890,7 +4953,7 @@ class Ze {
|
|
|
4890
4953
|
await t(this.plugins[e]);
|
|
4891
4954
|
}
|
|
4892
4955
|
}
|
|
4893
|
-
class
|
|
4956
|
+
class hn {
|
|
4894
4957
|
constructor(t) {
|
|
4895
4958
|
this.writer = t, this.name = "KHR_lights_punctual";
|
|
4896
4959
|
}
|
|
@@ -4906,7 +4969,7 @@ class Qe {
|
|
|
4906
4969
|
o.push(r), e.extensions = e.extensions || {}, e.extensions[this.name] = { light: o.length - 1 };
|
|
4907
4970
|
}
|
|
4908
4971
|
}
|
|
4909
|
-
class
|
|
4972
|
+
class un {
|
|
4910
4973
|
constructor(t) {
|
|
4911
4974
|
this.writer = t, this.name = "KHR_materials_unlit";
|
|
4912
4975
|
}
|
|
@@ -4916,7 +4979,7 @@ class tn {
|
|
|
4916
4979
|
e.extensions = e.extensions || {}, e.extensions[this.name] = {}, s[this.name] = !0, e.pbrMetallicRoughness.metallicFactor = 0, e.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
4917
4980
|
}
|
|
4918
4981
|
}
|
|
4919
|
-
class
|
|
4982
|
+
class dn {
|
|
4920
4983
|
constructor(t) {
|
|
4921
4984
|
this.writer = t, this.name = "KHR_materials_clearcoat";
|
|
4922
4985
|
}
|
|
@@ -4947,7 +5010,7 @@ class en {
|
|
|
4947
5010
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4948
5011
|
}
|
|
4949
5012
|
}
|
|
4950
|
-
class
|
|
5013
|
+
class fn {
|
|
4951
5014
|
constructor(t) {
|
|
4952
5015
|
this.writer = t, this.name = "KHR_materials_dispersion";
|
|
4953
5016
|
}
|
|
@@ -4957,7 +5020,7 @@ class nn {
|
|
|
4957
5020
|
i.dispersion = t.dispersion, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4958
5021
|
}
|
|
4959
5022
|
}
|
|
4960
|
-
class
|
|
5023
|
+
class pn {
|
|
4961
5024
|
constructor(t) {
|
|
4962
5025
|
this.writer = t, this.name = "KHR_materials_iridescence";
|
|
4963
5026
|
}
|
|
@@ -4981,7 +5044,7 @@ class sn {
|
|
|
4981
5044
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4982
5045
|
}
|
|
4983
5046
|
}
|
|
4984
|
-
class
|
|
5047
|
+
class gn {
|
|
4985
5048
|
constructor(t) {
|
|
4986
5049
|
this.writer = t, this.name = "KHR_materials_transmission";
|
|
4987
5050
|
}
|
|
@@ -4998,7 +5061,7 @@ class rn {
|
|
|
4998
5061
|
e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
4999
5062
|
}
|
|
5000
5063
|
}
|
|
5001
|
-
class
|
|
5064
|
+
class yn {
|
|
5002
5065
|
constructor(t) {
|
|
5003
5066
|
this.writer = t, this.name = "KHR_materials_volume";
|
|
5004
5067
|
}
|
|
@@ -5015,7 +5078,7 @@ class on {
|
|
|
5015
5078
|
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;
|
|
5016
5079
|
}
|
|
5017
5080
|
}
|
|
5018
|
-
class
|
|
5081
|
+
class xn {
|
|
5019
5082
|
constructor(t) {
|
|
5020
5083
|
this.writer = t, this.name = "KHR_materials_ior";
|
|
5021
5084
|
}
|
|
@@ -5025,12 +5088,12 @@ class an {
|
|
|
5025
5088
|
i.ior = t.ior, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5026
5089
|
}
|
|
5027
5090
|
}
|
|
5028
|
-
class
|
|
5091
|
+
class mn {
|
|
5029
5092
|
constructor(t) {
|
|
5030
5093
|
this.writer = t, this.name = "KHR_materials_specular";
|
|
5031
5094
|
}
|
|
5032
5095
|
async writeMaterialAsync(t, e) {
|
|
5033
|
-
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(
|
|
5096
|
+
if (!t.isMeshPhysicalMaterial || t.specularIntensity === 1 && t.specularColor.equals(Qe) && !t.specularIntensityMap && !t.specularColorMap) return;
|
|
5034
5097
|
const n = this.writer, s = n.extensionsUsed, i = {};
|
|
5035
5098
|
if (t.specularIntensityMap) {
|
|
5036
5099
|
const r = {
|
|
@@ -5049,7 +5112,7 @@ class cn {
|
|
|
5049
5112
|
i.specularFactor = t.specularIntensity, i.specularColorFactor = t.specularColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5050
5113
|
}
|
|
5051
5114
|
}
|
|
5052
|
-
class
|
|
5115
|
+
class wn {
|
|
5053
5116
|
constructor(t) {
|
|
5054
5117
|
this.writer = t, this.name = "KHR_materials_sheen";
|
|
5055
5118
|
}
|
|
@@ -5073,7 +5136,7 @@ class ln {
|
|
|
5073
5136
|
i.sheenRoughnessFactor = t.sheenRoughness, i.sheenColorFactor = t.sheenColor.toArray(), e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5074
5137
|
}
|
|
5075
5138
|
}
|
|
5076
|
-
class
|
|
5139
|
+
class Mn {
|
|
5077
5140
|
constructor(t) {
|
|
5078
5141
|
this.writer = t, this.name = "KHR_materials_anisotropy";
|
|
5079
5142
|
}
|
|
@@ -5087,7 +5150,7 @@ class hn {
|
|
|
5087
5150
|
i.anisotropyStrength = t.anisotropy, i.anisotropyRotation = t.anisotropyRotation, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5088
5151
|
}
|
|
5089
5152
|
}
|
|
5090
|
-
class
|
|
5153
|
+
class Dn {
|
|
5091
5154
|
constructor(t) {
|
|
5092
5155
|
this.writer = t, this.name = "KHR_materials_emissive_strength";
|
|
5093
5156
|
}
|
|
@@ -5097,7 +5160,7 @@ class un {
|
|
|
5097
5160
|
i.emissiveStrength = t.emissiveIntensity, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5098
5161
|
}
|
|
5099
5162
|
}
|
|
5100
|
-
class
|
|
5163
|
+
class Ln {
|
|
5101
5164
|
constructor(t) {
|
|
5102
5165
|
this.writer = t, this.name = "EXT_materials_bump";
|
|
5103
5166
|
}
|
|
@@ -5114,24 +5177,24 @@ class dn {
|
|
|
5114
5177
|
i.bumpFactor = t.bumpScale, e.extensions = e.extensions || {}, e.extensions[this.name] = i, s[this.name] = !0;
|
|
5115
5178
|
}
|
|
5116
5179
|
}
|
|
5117
|
-
class
|
|
5180
|
+
class Sn {
|
|
5118
5181
|
constructor(t) {
|
|
5119
5182
|
this.writer = t, this.name = "EXT_mesh_gpu_instancing";
|
|
5120
5183
|
}
|
|
5121
5184
|
writeNode(t, e) {
|
|
5122
5185
|
if (!t.isInstancedMesh) return;
|
|
5123
|
-
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
|
|
5186
|
+
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 Ct(), c = new it(), l = new Zt(), h = new it();
|
|
5124
5187
|
for (let f = 0; f < s.count; f++)
|
|
5125
|
-
s.getMatrixAt(f, a), a.decompose(l, h, c
|
|
5188
|
+
s.getMatrixAt(f, a), a.decompose(c, l, h), c.toArray(i, f * 3), l.toArray(r, f * 4), h.toArray(o, f * 3);
|
|
5126
5189
|
const d = {
|
|
5127
|
-
TRANSLATION: n.processAccessor(new
|
|
5128
|
-
ROTATION: n.processAccessor(new
|
|
5129
|
-
SCALE: n.processAccessor(new
|
|
5190
|
+
TRANSLATION: n.processAccessor(new _(i, 3)),
|
|
5191
|
+
ROTATION: n.processAccessor(new _(r, 4)),
|
|
5192
|
+
SCALE: n.processAccessor(new _(o, 3))
|
|
5130
5193
|
};
|
|
5131
5194
|
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;
|
|
5132
5195
|
}
|
|
5133
5196
|
}
|
|
5134
|
-
|
|
5197
|
+
ot.Utils = {
|
|
5135
5198
|
insertKeyframe: function(u, t) {
|
|
5136
5199
|
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));
|
|
5137
5200
|
let o;
|
|
@@ -5161,7 +5224,7 @@ ct.Utils = {
|
|
|
5161
5224
|
const e = [], n = {}, s = u.tracks;
|
|
5162
5225
|
for (let i = 0; i < s.length; ++i) {
|
|
5163
5226
|
let r = s[i];
|
|
5164
|
-
const o =
|
|
5227
|
+
const o = rt.parseTrackName(r.name), a = rt.findNode(t, o.nodeName);
|
|
5165
5228
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
5166
5229
|
e.push(r);
|
|
5167
5230
|
continue;
|
|
@@ -5169,33 +5232,33 @@ ct.Utils = {
|
|
|
5169
5232
|
if (r.createInterpolant !== r.InterpolantFactoryMethodDiscrete && r.createInterpolant !== r.InterpolantFactoryMethodLinear) {
|
|
5170
5233
|
if (r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
5171
5234
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
5172
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(
|
|
5235
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), r = r.clone(), r.setInterpolation(ye);
|
|
5173
5236
|
}
|
|
5174
|
-
const
|
|
5175
|
-
if (
|
|
5237
|
+
const c = a.morphTargetInfluences.length, l = a.morphTargetDictionary[o.propertyIndex];
|
|
5238
|
+
if (l === void 0)
|
|
5176
5239
|
throw new Error("THREE.GLTFExporter: Morph target name not found: " + o.propertyIndex);
|
|
5177
|
-
let
|
|
5240
|
+
let h;
|
|
5178
5241
|
if (n[a.uuid] === void 0) {
|
|
5179
|
-
|
|
5180
|
-
const f = new
|
|
5181
|
-
for (let p = 0; p <
|
|
5182
|
-
f[p *
|
|
5183
|
-
|
|
5242
|
+
h = r.clone();
|
|
5243
|
+
const f = new h.ValueBufferType(c * h.times.length);
|
|
5244
|
+
for (let p = 0; p < h.times.length; p++)
|
|
5245
|
+
f[p * c + l] = h.values[p];
|
|
5246
|
+
h.name = (o.nodeName || "") + ".morphTargetInfluences", h.values = f, n[a.uuid] = h, e.push(h);
|
|
5184
5247
|
continue;
|
|
5185
5248
|
}
|
|
5186
5249
|
const d = r.createInterpolant(new r.ValueBufferType(1));
|
|
5187
|
-
|
|
5188
|
-
for (let f = 0; f <
|
|
5189
|
-
|
|
5250
|
+
h = n[a.uuid];
|
|
5251
|
+
for (let f = 0; f < h.times.length; f++)
|
|
5252
|
+
h.values[f * c + l] = d.evaluate(h.times[f]);
|
|
5190
5253
|
for (let f = 0; f < r.times.length; f++) {
|
|
5191
|
-
const p = this.insertKeyframe(
|
|
5192
|
-
|
|
5254
|
+
const p = this.insertKeyframe(h, r.times[f]);
|
|
5255
|
+
h.values[p * c + l] = r.values[f];
|
|
5193
5256
|
}
|
|
5194
5257
|
}
|
|
5195
5258
|
return u.tracks = e, u;
|
|
5196
5259
|
},
|
|
5197
5260
|
toFloat32BufferAttribute: function(u) {
|
|
5198
|
-
const t = new
|
|
5261
|
+
const t = new _(new Float32Array(u.count * u.itemSize), u.itemSize, !1);
|
|
5199
5262
|
if (!u.normalized && !u.isInterleavedBufferAttribute)
|
|
5200
5263
|
return t.array.set(u.array), t;
|
|
5201
5264
|
for (let e = 0, n = u.count; e < n; e++)
|
|
@@ -5204,7 +5267,7 @@ ct.Utils = {
|
|
|
5204
5267
|
return t;
|
|
5205
5268
|
}
|
|
5206
5269
|
};
|
|
5207
|
-
async function
|
|
5270
|
+
async function En(u) {
|
|
5208
5271
|
if (typeof FileReader > "u") {
|
|
5209
5272
|
const t = await u.arrayBuffer(), n = Buffer.from(t).toString("base64");
|
|
5210
5273
|
return `data:${u.type};base64,${n}`;
|
|
@@ -5214,7 +5277,7 @@ async function pn(u) {
|
|
|
5214
5277
|
n.onload = () => t(n.result), n.onerror = () => e(new Error("Failed to read Blob as Data URL")), n.readAsDataURL(u);
|
|
5215
5278
|
});
|
|
5216
5279
|
}
|
|
5217
|
-
async function
|
|
5280
|
+
async function ut(u) {
|
|
5218
5281
|
if (typeof u.arrayBuffer == "function")
|
|
5219
5282
|
return await u.arrayBuffer();
|
|
5220
5283
|
if (typeof FileReader < "u")
|
|
@@ -5227,23 +5290,23 @@ async function dt(u) {
|
|
|
5227
5290
|
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
5228
5291
|
}
|
|
5229
5292
|
}
|
|
5230
|
-
const
|
|
5231
|
-
function
|
|
5293
|
+
const An = new xe(), bn = new ot();
|
|
5294
|
+
function Tn(u, t, e = 0.1) {
|
|
5232
5295
|
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;
|
|
5233
5296
|
return {
|
|
5234
5297
|
points: [
|
|
5235
5298
|
// 第一条线
|
|
5236
|
-
new
|
|
5237
|
-
new
|
|
5299
|
+
new w(u.x + r, u.y + o).add(i),
|
|
5300
|
+
new w(t.x + r, t.y + o).add(s),
|
|
5238
5301
|
// 第二条线
|
|
5239
|
-
new
|
|
5240
|
-
new
|
|
5302
|
+
new w(u.x - r, u.y - o).add(i),
|
|
5303
|
+
new w(t.x - r, t.y - o).add(s)
|
|
5241
5304
|
],
|
|
5242
5305
|
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
5243
5306
|
rectIndices: [0, 1, 3, 2, 0]
|
|
5244
5307
|
};
|
|
5245
5308
|
}
|
|
5246
|
-
class Yt extends
|
|
5309
|
+
class Yt extends G {
|
|
5247
5310
|
static name = "WhiteModel";
|
|
5248
5311
|
Dxf = null;
|
|
5249
5312
|
Variable = null;
|
|
@@ -5273,18 +5336,18 @@ class Yt extends z {
|
|
|
5273
5336
|
new P.LineSegments(new P.EdgesGeometry(i), new P.LineBasicMaterial({ color: 0 }))
|
|
5274
5337
|
);
|
|
5275
5338
|
}), t.originalData.map(({ start: n, end: s, insetionArr: i }) => {
|
|
5276
|
-
const r = new
|
|
5339
|
+
const r = new w(n.x, n.y).mutiplyScalar(t.scale), o = new w(s.x, s.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: l } = Tn(r, o, t.width);
|
|
5277
5340
|
return {
|
|
5278
5341
|
points: a,
|
|
5279
|
-
indices:
|
|
5280
|
-
rectIndices:
|
|
5281
|
-
insetions: (i ?? []).map((
|
|
5342
|
+
indices: c,
|
|
5343
|
+
rectIndices: l,
|
|
5344
|
+
insetions: (i ?? []).map((h) => h.index)
|
|
5282
5345
|
};
|
|
5283
5346
|
}).forEach((n) => {
|
|
5284
5347
|
const s = new P.Shape();
|
|
5285
5348
|
n.rectIndices.forEach((o, a) => {
|
|
5286
|
-
const
|
|
5287
|
-
a === 0 ? s.moveTo(
|
|
5349
|
+
const c = n.points[o];
|
|
5350
|
+
a === 0 ? s.moveTo(c.x, c.y) : s.lineTo(c.x, c.y);
|
|
5288
5351
|
});
|
|
5289
5352
|
const i = new P.ExtrudeGeometry(s, {
|
|
5290
5353
|
depth: 2.8,
|
|
@@ -5306,7 +5369,7 @@ class Yt extends z {
|
|
|
5306
5369
|
toOBJ() {
|
|
5307
5370
|
return new Promise((t) => {
|
|
5308
5371
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
|
|
5309
|
-
t(
|
|
5372
|
+
t(An.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
5310
5373
|
}, 20);
|
|
5311
5374
|
});
|
|
5312
5375
|
}
|
|
@@ -5318,7 +5381,7 @@ class Yt extends z {
|
|
|
5318
5381
|
toGltf(t = !0) {
|
|
5319
5382
|
return new Promise((e) => {
|
|
5320
5383
|
this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
|
|
5321
|
-
|
|
5384
|
+
bn.parse(this.whiteModelGroup.children, (n) => {
|
|
5322
5385
|
e(n), this.material.opacity = 0.8, this.material.transparent = !0;
|
|
5323
5386
|
}, () => {
|
|
5324
5387
|
e(void 0);
|
|
@@ -5359,7 +5422,7 @@ class Yt extends z {
|
|
|
5359
5422
|
n.href = URL.createObjectURL(e), n.download = t, n.click();
|
|
5360
5423
|
} else if (typeof global < "u") {
|
|
5361
5424
|
const e = await this.toOBJ();
|
|
5362
|
-
e && (await
|
|
5425
|
+
e && (await H("fs", !1)).writeFileSync(t, e);
|
|
5363
5426
|
}
|
|
5364
5427
|
}
|
|
5365
5428
|
/**
|
|
@@ -5375,11 +5438,11 @@ class Yt extends z {
|
|
|
5375
5438
|
s.href = URL.createObjectURL(n), s.download = t, s.click();
|
|
5376
5439
|
} else if (typeof global < "u") {
|
|
5377
5440
|
const n = await this.toGltf(e);
|
|
5378
|
-
n && (await
|
|
5441
|
+
n && (await H("fs", !1)).writeFileSync(t, e ? Buffer.from(n) : JSON.stringify(n));
|
|
5379
5442
|
}
|
|
5380
5443
|
}
|
|
5381
5444
|
}
|
|
5382
|
-
class
|
|
5445
|
+
class Xt extends G {
|
|
5383
5446
|
static name = "DetailsPoint";
|
|
5384
5447
|
Dxf = null;
|
|
5385
5448
|
WhiteModel = null;
|
|
@@ -5456,7 +5519,7 @@ class kt extends z {
|
|
|
5456
5519
|
}, 50);
|
|
5457
5520
|
}
|
|
5458
5521
|
}
|
|
5459
|
-
class
|
|
5522
|
+
class Vt extends G {
|
|
5460
5523
|
static name = "DxfLineModel";
|
|
5461
5524
|
dxfLineModel = new P.LineSegments();
|
|
5462
5525
|
dxfDoorsLineModel = new P.LineSegments();
|
|
@@ -5479,39 +5542,39 @@ class Xt extends z {
|
|
|
5479
5542
|
});
|
|
5480
5543
|
}
|
|
5481
5544
|
}
|
|
5482
|
-
const
|
|
5545
|
+
const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5483
5546
|
__proto__: null,
|
|
5484
|
-
DetailsPoint:
|
|
5485
|
-
DxfLineModel:
|
|
5547
|
+
DetailsPoint: Xt,
|
|
5548
|
+
DxfLineModel: Vt,
|
|
5486
5549
|
WhiteModel: Yt
|
|
5487
5550
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5488
|
-
function
|
|
5551
|
+
function Rt(u, t = {}) {
|
|
5489
5552
|
const {
|
|
5490
5553
|
detailsPoint: e = !0,
|
|
5491
5554
|
whiteModel: n = !0,
|
|
5492
5555
|
dxfLineModel: s = !0
|
|
5493
5556
|
} = t;
|
|
5494
|
-
s && u.addComponent(new
|
|
5557
|
+
s && u.addComponent(new Vt()), n && u.addComponent(new Yt()), e && u.addComponent(new Xt());
|
|
5495
5558
|
}
|
|
5496
|
-
const
|
|
5559
|
+
const In = Object.assign(Rt, {
|
|
5497
5560
|
create(u = {}) {
|
|
5498
|
-
return (t) =>
|
|
5561
|
+
return (t) => Rt(t, u);
|
|
5499
5562
|
}
|
|
5500
|
-
}),
|
|
5563
|
+
}), vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5501
5564
|
__proto__: null,
|
|
5502
|
-
ModelDataPlugin:
|
|
5503
|
-
components:
|
|
5565
|
+
ModelDataPlugin: In,
|
|
5566
|
+
components: Pn
|
|
5504
5567
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5505
5568
|
function Wt(u, t, e = 1e-3) {
|
|
5506
|
-
if (Array.isArray(u) && u[0] instanceof
|
|
5569
|
+
if (Array.isArray(u) && u[0] instanceof w) {
|
|
5507
5570
|
const s = u;
|
|
5508
5571
|
u = s.map((i, r) => {
|
|
5509
5572
|
const o = s[(r + 1) % s.length];
|
|
5510
|
-
return new
|
|
5573
|
+
return new D(i, o);
|
|
5511
5574
|
});
|
|
5512
5575
|
}
|
|
5513
|
-
if (u instanceof
|
|
5514
|
-
const n =
|
|
5576
|
+
if (u instanceof D) return Wt([u], t, e);
|
|
5577
|
+
const n = Z.finalInstance;
|
|
5515
5578
|
if (n) {
|
|
5516
5579
|
const s = n.findComponentByName("Renderer");
|
|
5517
5580
|
if (s) {
|
|
@@ -5520,8 +5583,8 @@ function Wt(u, t, e = 1e-3) {
|
|
|
5520
5583
|
}
|
|
5521
5584
|
}
|
|
5522
5585
|
}
|
|
5523
|
-
function
|
|
5524
|
-
const n =
|
|
5586
|
+
function Rn(u, t, e = 1e-3) {
|
|
5587
|
+
const n = Z.finalInstance;
|
|
5525
5588
|
if (n) {
|
|
5526
5589
|
const s = n.findComponentByName("Renderer");
|
|
5527
5590
|
if (s) {
|
|
@@ -5530,8 +5593,8 @@ function Dn(u, t, e = 1e-3) {
|
|
|
5530
5593
|
}
|
|
5531
5594
|
}
|
|
5532
5595
|
}
|
|
5533
|
-
function
|
|
5534
|
-
const s =
|
|
5596
|
+
function Cn(u, t, e, n = 1e-3) {
|
|
5597
|
+
const s = Z.finalInstance;
|
|
5535
5598
|
if (s) {
|
|
5536
5599
|
const i = s.findComponentByName("Renderer"), r = s.findComponentByName("Editor");
|
|
5537
5600
|
if (i) {
|
|
@@ -5540,16 +5603,16 @@ function Sn(u, t, e, n = 1e-3) {
|
|
|
5540
5603
|
}
|
|
5541
5604
|
}
|
|
5542
5605
|
}
|
|
5543
|
-
function
|
|
5606
|
+
function Nn() {
|
|
5544
5607
|
return import("./index2.js");
|
|
5545
5608
|
}
|
|
5546
|
-
function
|
|
5609
|
+
function Bn() {
|
|
5547
5610
|
return import("./index3.js");
|
|
5548
5611
|
}
|
|
5549
5612
|
let gt = null;
|
|
5550
|
-
typeof window < "u" && (window.drawLines = Wt, window.drawPoint =
|
|
5551
|
-
async function
|
|
5552
|
-
const s = await Promise.resolve().then(() =>
|
|
5613
|
+
typeof window < "u" && (window.drawLines = Wt, window.drawPoint = Rn, window.drawText = Cn, window.randomColor = () => Math.floor(Math.random() * 16777215));
|
|
5614
|
+
async function zn(u, t, e = !1, n) {
|
|
5615
|
+
const s = await Promise.resolve().then(() => vn), i = await Nn(), r = await Bn(), o = new Z().usePlugin(s.ModelDataPlugin.create({
|
|
5553
5616
|
detailsPoint: !1,
|
|
5554
5617
|
whiteModel: !0
|
|
5555
5618
|
})).usePlugin(i.RenderPlugin.create({
|
|
@@ -5561,10 +5624,10 @@ async function Rn(u, t, e = !1, n) {
|
|
|
5561
5624
|
})).usePlugin(r.Editor.create({ viewPermission: n })), a = o.findComponentByType(i.components.DomContainer);
|
|
5562
5625
|
return a && u.appendChild(a.domElement), gt = o, {
|
|
5563
5626
|
dxfSystem: o,
|
|
5564
|
-
getFileAll: () =>
|
|
5627
|
+
getFileAll: () => On(o)
|
|
5565
5628
|
};
|
|
5566
5629
|
}
|
|
5567
|
-
async function
|
|
5630
|
+
async function On(u = gt) {
|
|
5568
5631
|
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" });
|
|
5569
5632
|
return {
|
|
5570
5633
|
dxf: n,
|
|
@@ -5576,32 +5639,32 @@ async function An(u = gt) {
|
|
|
5576
5639
|
correctionDxf: s
|
|
5577
5640
|
};
|
|
5578
5641
|
}
|
|
5579
|
-
function
|
|
5642
|
+
function _n() {
|
|
5580
5643
|
return gt;
|
|
5581
5644
|
}
|
|
5582
5645
|
export {
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5646
|
+
Gt as A,
|
|
5647
|
+
I as B,
|
|
5648
|
+
G as C,
|
|
5649
|
+
Z as D,
|
|
5650
|
+
Nt as E,
|
|
5651
|
+
D as L,
|
|
5652
|
+
In as M,
|
|
5653
|
+
w as P,
|
|
5654
|
+
B as Q,
|
|
5655
|
+
He as T,
|
|
5593
5656
|
Ut as V,
|
|
5594
5657
|
Yt as W,
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5658
|
+
Xt as a,
|
|
5659
|
+
Y as b,
|
|
5660
|
+
J as c,
|
|
5661
|
+
Xe as d,
|
|
5662
|
+
zn as e,
|
|
5663
|
+
_n as f,
|
|
5664
|
+
On as g,
|
|
5602
5665
|
k as h,
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5666
|
+
Pn as i,
|
|
5667
|
+
Un as j,
|
|
5668
|
+
X as r,
|
|
5606
5669
|
tt as u
|
|
5607
5670
|
};
|