@realsee/dnalogel 3.79.2 → 3.79.4
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/CHANGELOG.md +4 -0
- package/dist/PanoTagPlugin/controller/Tag/PlaneTag.d.ts +7 -1
- package/dist/Sculpt/utils/isIntersecting.d.ts +17 -0
- package/dist/index.cjs.js +74 -74
- package/dist/index.js +5076 -4991
- package/dist/index.umd.js +67 -67
- package/libs/CruisePlugin/Move.js +3 -2
- package/libs/CruisePlugin/Work.js +3 -2
- package/libs/CruisePlugin/index.js +7 -6
- package/libs/GuideLinePlugin/Controller.js +5 -4
- package/libs/GuideLinePlugin/GuideLineItem.js +3 -2
- package/libs/GuideLinePlugin/GuideLineModeItem.js +3 -2
- package/libs/GuideLinePlugin/index.js +7 -6
- package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +21 -20
- package/libs/PanoTagPlugin/controller/Tag/PlaneTag.d.ts +7 -1
- package/libs/PanoTagPlugin/controller/Tag/PlaneTag.js +129 -108
- package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +3 -2
- package/libs/PanoTagPlugin/controller/index.js +6 -5
- package/libs/PanoTagPlugin/index.js +12 -11
- package/libs/Sculpt/Objects/Polygon/index.js +100 -99
- package/libs/Sculpt/utils/isIntersecting.d.ts +17 -0
- package/libs/Sculpt/utils/isIntersecting.js +68 -0
- package/libs/base/BasePlugin.js +1 -1
- package/libs/index.js +159 -158
- package/libs/shared-utils/logger.js +1 -1
- package/package.json +1 -1
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Pt = Object.defineProperty, yt = Object.defineProperties;
|
|
2
|
+
var mt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var it = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var t in
|
|
7
|
-
|
|
4
|
+
var xt = Object.prototype.hasOwnProperty, ft = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var v = Math.pow, T = (s, e, t) => e in s ? Pt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, _ = (s, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
xt.call(e, t) && T(s, t, e[t]);
|
|
8
8
|
if (it)
|
|
9
|
-
for (var t of it(
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, R = (
|
|
13
|
-
var C = (
|
|
14
|
-
var ot = (
|
|
9
|
+
for (var t of it(e))
|
|
10
|
+
ft.call(e, t) && T(s, t, e[t]);
|
|
11
|
+
return s;
|
|
12
|
+
}, R = (s, e) => yt(s, mt(e));
|
|
13
|
+
var C = (s, e, t) => (T(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
|
+
var ot = (s, e, t) => new Promise((r, n) => {
|
|
15
15
|
var x = (c) => {
|
|
16
16
|
try {
|
|
17
17
|
w(t.next(c));
|
|
18
18
|
} catch (u) {
|
|
19
|
-
|
|
19
|
+
n(u);
|
|
20
20
|
}
|
|
21
21
|
}, a = (c) => {
|
|
22
22
|
try {
|
|
23
23
|
w(t.throw(c));
|
|
24
24
|
} catch (u) {
|
|
25
|
-
|
|
25
|
+
n(u);
|
|
26
26
|
}
|
|
27
|
-
}, w = (c) => c.done ?
|
|
28
|
-
w((t = t.apply(
|
|
27
|
+
}, w = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(x, a);
|
|
28
|
+
w((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
|
-
import { BaseObject as
|
|
31
|
-
import * as
|
|
32
|
-
import { PolylineMesh as
|
|
33
|
-
import { AreaMesh as
|
|
34
|
-
import { PolygonEditor as
|
|
35
|
-
import { vector3ToArray as
|
|
36
|
-
import { withResolvers as
|
|
37
|
-
import { anyPositionToVector3 as
|
|
30
|
+
import { BaseObject as bt } from "../Base/index.js";
|
|
31
|
+
import * as H from "three";
|
|
32
|
+
import { PolylineMesh as rt } from "../../Meshes/Polyline.js";
|
|
33
|
+
import { AreaMesh as nt } from "../../Meshes/Area.js";
|
|
34
|
+
import { PolygonEditor as Ct } from "./Editor.js";
|
|
35
|
+
import { vector3ToArray as wt } from "../../../shared-utils/three/vector3ToArray.js";
|
|
36
|
+
import { withResolvers as Dt } from "../../../shared-utils/promise/withResolvers.js";
|
|
37
|
+
import { anyPositionToVector3 as _t } from "../../../shared-utils/positionToVector3.js";
|
|
38
38
|
import { PointMesh as Ht } from "../../Meshes/Point.js";
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
import { isPolygenIntersecting as lt } from "../../utils/isIntersecting.js";
|
|
40
|
+
class At extends bt {
|
|
41
|
+
constructor(t, r) {
|
|
42
|
+
var n;
|
|
43
|
+
super(t, r);
|
|
43
44
|
C(this, "type", "Polygon");
|
|
44
45
|
C(this, "areaMesh");
|
|
45
46
|
// 新增:Polygon 专属的历史记录
|
|
@@ -48,19 +49,19 @@ class Wt extends ft {
|
|
|
48
49
|
C(this, "maxHistorySize", 50);
|
|
49
50
|
C(this, "_editor");
|
|
50
51
|
C(this, "creatingObject");
|
|
51
|
-
t && (this.areaMesh = new
|
|
52
|
+
t && (this.areaMesh = new nt(_(_({}, t.style), t)), this.areaMesh.userData = (n = this.areaMesh.userData) != null ? n : {}, typeof this.areaMesh.userData.dragSelectPixelDistance != "number" && (this.areaMesh.userData.dragSelectPixelDistance = 10), this.add(this.areaMesh));
|
|
52
53
|
}
|
|
53
54
|
get editor() {
|
|
54
|
-
return this._editor || (this._editor = new
|
|
55
|
+
return this._editor || (this._editor = new Ct(this)), this._editor;
|
|
55
56
|
}
|
|
56
57
|
updateCreationPointMeshes() {
|
|
57
|
-
var
|
|
58
|
-
const t = (
|
|
58
|
+
var r, n;
|
|
59
|
+
const t = (n = (r = this.areaMesh) == null ? void 0 : r.userData) == null ? void 0 : n.syncCreationPointMeshes;
|
|
59
60
|
typeof t == "function" && t(), this._editor && this._editor.updatePointMeshes();
|
|
60
61
|
}
|
|
61
62
|
get data() {
|
|
62
|
-
return this.updateMatrixWorld(), R(
|
|
63
|
-
points:
|
|
63
|
+
return this.updateMatrixWorld(), R(_({}, this.baseData), {
|
|
64
|
+
points: wt(this.applyObjectMatrixWorld(this.areaMesh.points)),
|
|
64
65
|
style: {
|
|
65
66
|
color: this.areaMesh.color.getHex(),
|
|
66
67
|
lineColor: this.areaMesh.lineColor.getHex(),
|
|
@@ -69,7 +70,7 @@ class Wt extends ft {
|
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
72
|
setData(t) {
|
|
72
|
-
t.points && this.areaMesh.setPoints(this.applyObjectReversalMatrixWorld(t.points.map(
|
|
73
|
+
t.points && this.areaMesh.setPoints(this.applyObjectReversalMatrixWorld(t.points.map(_t))), this.areaMesh.setStyle(t.style), this.updateCreationPointMeshes();
|
|
73
74
|
}
|
|
74
75
|
highlight() {
|
|
75
76
|
var t;
|
|
@@ -80,32 +81,32 @@ class Wt extends ft {
|
|
|
80
81
|
(t = this.areaMesh) == null || t.unhighlight();
|
|
81
82
|
}
|
|
82
83
|
canUndo() {
|
|
83
|
-
var
|
|
84
|
-
return this.creatingObject ? (x = (
|
|
84
|
+
var r, n, x;
|
|
85
|
+
return this.creatingObject ? (x = (n = (r = this.creatingObject) == null ? void 0 : r.canUndo) == null ? void 0 : n.call(r)) != null ? x : !1 : this.currentHistoryIndex > 0;
|
|
85
86
|
}
|
|
86
87
|
canRedo() {
|
|
87
|
-
var t,
|
|
88
|
-
return this.creatingObject ? (
|
|
88
|
+
var t, r, n;
|
|
89
|
+
return this.creatingObject ? (n = (r = (t = this.creatingObject) == null ? void 0 : t.canRedo) == null ? void 0 : r.call(t)) != null ? n : !1 : this.currentHistoryIndex < this.historyStack.length - 1;
|
|
89
90
|
}
|
|
90
91
|
undo() {
|
|
91
|
-
var t,
|
|
92
|
+
var t, r;
|
|
92
93
|
if (this.creatingObject)
|
|
93
|
-
return (
|
|
94
|
+
return (r = (t = this.creatingObject) == null ? void 0 : t.undo) == null ? void 0 : r.call(t);
|
|
94
95
|
if (this.canUndo()) {
|
|
95
96
|
this.currentHistoryIndex--;
|
|
96
|
-
const
|
|
97
|
-
this.restoreSnapshot(
|
|
97
|
+
const n = this.historyStack[this.currentHistoryIndex];
|
|
98
|
+
this.restoreSnapshot(n);
|
|
98
99
|
} else
|
|
99
100
|
console.log("[Polygon] undo: 无法撤销", { uuid: this.uuid });
|
|
100
101
|
}
|
|
101
102
|
redo() {
|
|
102
|
-
var t,
|
|
103
|
+
var t, r;
|
|
103
104
|
if (this.creatingObject)
|
|
104
|
-
return (
|
|
105
|
+
return (r = (t = this.creatingObject) == null ? void 0 : t.redo) == null ? void 0 : r.call(t);
|
|
105
106
|
if (this.canRedo()) {
|
|
106
107
|
this.currentHistoryIndex++;
|
|
107
|
-
const
|
|
108
|
-
this.restoreSnapshot(
|
|
108
|
+
const n = this.historyStack[this.currentHistoryIndex];
|
|
109
|
+
this.restoreSnapshot(n);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
/**
|
|
@@ -116,7 +117,7 @@ class Wt extends ft {
|
|
|
116
117
|
return;
|
|
117
118
|
this.historyStack = this.historyStack.slice(0, this.currentHistoryIndex + 1);
|
|
118
119
|
const t = {
|
|
119
|
-
points: this.areaMesh.points.map((
|
|
120
|
+
points: this.areaMesh.points.map((r) => r.clone())
|
|
120
121
|
};
|
|
121
122
|
this.historyStack.push(t), this.historyStack.length > this.maxHistorySize ? this.historyStack.shift() : this.currentHistoryIndex++;
|
|
122
123
|
}
|
|
@@ -124,88 +125,88 @@ class Wt extends ft {
|
|
|
124
125
|
* 恢复快照
|
|
125
126
|
*/
|
|
126
127
|
restoreSnapshot(t) {
|
|
127
|
-
this.areaMesh.setPoints(t.points.map((
|
|
128
|
+
this.areaMesh.setPoints(t.points.map((r) => r.clone())), this.updateCreationPointMeshes(), this._editor && this._editor.updatePointMeshes();
|
|
128
129
|
}
|
|
129
130
|
create(t) {
|
|
130
131
|
return ot(this, null, function* () {
|
|
131
|
-
var
|
|
132
|
+
var n;
|
|
132
133
|
this.children.forEach((x) => {
|
|
133
134
|
x.parent === this && this.remove(x);
|
|
134
135
|
}), this.children.length = 0;
|
|
135
|
-
const
|
|
136
|
-
this.areaMesh =
|
|
136
|
+
const r = new nt(t);
|
|
137
|
+
this.areaMesh = r, this.add(this.areaMesh), this.creatingObject = jt(this.areaMesh, this.pointSelector, t), yield (n = this.creatingObject) == null ? void 0 : n.finished, this.creatingObject = null, this.recordHistory(), this.updateCreationPointMeshes(), this.config.defaultAction && this.editor.enable();
|
|
137
138
|
});
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
|
-
function jt(
|
|
141
|
-
var
|
|
142
|
-
const { promise:
|
|
141
|
+
function jt(s, e, t) {
|
|
142
|
+
var $, B, G, J, K, Q, X, Z, g;
|
|
143
|
+
const { promise: r, resolve: n, reject: x } = Dt(), a = s.parent;
|
|
143
144
|
if (!a) {
|
|
144
145
|
x(new Error("No container"));
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
|
-
const w = (
|
|
148
|
-
|
|
148
|
+
const w = ($ = t == null ? void 0 : t.limit) != null ? $ : "none", c = t == null ? void 0 : t.simpleMode, u = (Q = (K = (G = s.five) != null ? G : (B = s.get) == null ? void 0 : B.call(s, "five")) != null ? K : (J = window.globalModules) == null ? void 0 : J.five) != null ? Q : window.$five, V = (X = t == null ? void 0 : t.autoClosePixelDistance) != null ? X : 10;
|
|
149
|
+
s.userData = (Z = s.userData) != null ? Z : {}, s.userData.dragSelectPixelDistance = V;
|
|
149
150
|
let M = 0;
|
|
150
151
|
c && u && u.model && u.model.bounding && typeof ((g = u.model.bounding.max) == null ? void 0 : g.y) == "number" && (M = u.model.bounding.max.y + 1);
|
|
151
|
-
const P = new
|
|
152
|
+
const P = new rt(s.style);
|
|
152
153
|
a == null || a.add(P);
|
|
153
|
-
const y = new
|
|
154
|
+
const y = new rt(R(_({}, s.style), { dashed: !0, lengthEnable: !1 }));
|
|
154
155
|
a == null || a.add(y);
|
|
155
|
-
let
|
|
156
|
-
const
|
|
157
|
-
|
|
156
|
+
let j = [];
|
|
157
|
+
const at = (i = o) => {
|
|
158
|
+
j.forEach((d, p) => {
|
|
158
159
|
const h = i[p];
|
|
159
160
|
h && d.position.copy(h);
|
|
160
161
|
});
|
|
161
162
|
};
|
|
162
163
|
function D() {
|
|
163
164
|
var d, p;
|
|
164
|
-
|
|
165
|
+
j.forEach((h) => {
|
|
165
166
|
var f;
|
|
166
167
|
return (f = h.parent) == null ? void 0 : f.remove(h);
|
|
167
168
|
});
|
|
168
|
-
const i = (p = (d =
|
|
169
|
-
|
|
170
|
-
var S,
|
|
171
|
-
const b = new Ht(R(
|
|
169
|
+
const i = (p = (d = s.line) == null ? void 0 : d.style) != null ? p : s.style;
|
|
170
|
+
j = o.map((h, f) => {
|
|
171
|
+
var S, I;
|
|
172
|
+
const b = new Ht(R(_({}, i), {
|
|
172
173
|
color: (S = i.pointColor) != null ? S : i.lineColor,
|
|
173
174
|
tip: void 0,
|
|
174
175
|
point: h
|
|
175
176
|
}));
|
|
176
|
-
return b.name = `PolygonPointMesh_${f}`, b.userData = (
|
|
177
|
-
}),
|
|
177
|
+
return b.name = `PolygonPointMesh_${f}`, b.userData = (I = b.userData) != null ? I : {}, b.userData.dragSelectPixelDistance = V, a == null || a.add(b), b;
|
|
178
|
+
}), at();
|
|
178
179
|
}
|
|
179
180
|
function Y() {
|
|
180
|
-
|
|
181
|
+
j.forEach((i) => {
|
|
181
182
|
var d;
|
|
182
183
|
return (d = i.parent) == null ? void 0 : d.remove(i);
|
|
183
|
-
}),
|
|
184
|
+
}), j = [], s.userData && (delete s.userData.creationPointMeshes, delete s.userData.syncCreationPointMeshes, delete s.userData.disposeCreationPointMeshes);
|
|
184
185
|
}
|
|
185
|
-
|
|
186
|
+
e.enable(), c && e.setAdherePoints([]);
|
|
186
187
|
const o = [];
|
|
187
188
|
let l, m, W = !1, U;
|
|
188
|
-
const E = [], z = () => o.length > 0,
|
|
189
|
+
const E = [], z = () => o.length > 0, q = () => E.length > 0, ht = () => {
|
|
189
190
|
var i;
|
|
190
|
-
z() && (E.push(o.pop()), O(U), D(), (i = t == null ? void 0 : t.onUndo) == null || i.call(t),
|
|
191
|
-
},
|
|
191
|
+
z() && (E.push(o.pop()), O(U), D(), (i = t == null ? void 0 : t.onUndo) == null || i.call(t), e.pointSelectorHelper && e.pointSelectorHelper.magnifier && e.pointSelectorHelper.magnifier.render());
|
|
192
|
+
}, dt = () => {
|
|
192
193
|
var i;
|
|
193
|
-
|
|
194
|
-
},
|
|
194
|
+
q() && (o.push(E.pop()), O(U), D(), (i = t == null ? void 0 : t.onRedo) == null || i.call(t), e.pointSelectorHelper && e.pointSelectorHelper.magnifier && e.pointSelectorHelper.magnifier.render());
|
|
195
|
+
}, F = (i) => {
|
|
195
196
|
var p, h;
|
|
196
197
|
E.length = 0;
|
|
197
198
|
let d = o.length === 0 ? i.point : l.clone();
|
|
198
199
|
if (c && (d = d.clone().setY(M)), t.__onWillAddPoint(d, o), !((t == null ? void 0 : t.experimental_max_point_count) != null && o.length === t.experimental_max_point_count)) {
|
|
199
|
-
if (o.push(d),
|
|
200
|
+
if (o.push(d), s.setPoints(o, { closed: !1 }), t != null && t.experimental_self_intersect_check && lt(o)) {
|
|
200
201
|
const f = o.pop();
|
|
201
|
-
|
|
202
|
+
s.setPoints(o, { closed: !1 }), D(), console.warn("[Polygon] 检测到自相交,无法添加该点"), (p = t == null ? void 0 : t.__onSelfIntersect) == null || p.call(t, f);
|
|
202
203
|
return;
|
|
203
204
|
}
|
|
204
|
-
D(), (h = t == null ? void 0 : t.onPointPlaced) == null || h.call(t, o), W && (
|
|
205
|
+
D(), (h = t == null ? void 0 : t.onPointPlaced) == null || h.call(t, o), W && (L(), n());
|
|
205
206
|
}
|
|
206
207
|
}, O = (i) => {
|
|
207
208
|
const d = () => {
|
|
208
|
-
P.setPoints([]), y.setPoints([]),
|
|
209
|
+
P.setPoints([]), y.setPoints([]), s.setPoints(o), e.pointSelectorHelper && e.pointSelectorHelper.magnifier && e.pointSelectorHelper.magnifier.render();
|
|
209
210
|
};
|
|
210
211
|
if (!i) {
|
|
211
212
|
d(), D();
|
|
@@ -214,40 +215,40 @@ function jt(e, s, t) {
|
|
|
214
215
|
if (U = i, !(o != null && o.length))
|
|
215
216
|
return d();
|
|
216
217
|
const p = o.at(-1).clone();
|
|
217
|
-
if (o.length < 3 && (c ? (l = i.point.clone().setY(M), P.setPoints([p, l]), y.setPoints([])) : w === "none" ? (l = i.point, P.setPoints([p, l]), y.setPoints([])) : w === "xoz" ? (m = m != null ? m : new
|
|
218
|
-
c ? l = i.point.clone().setY(M) : l =
|
|
218
|
+
if (o.length < 3 && (c ? (l = i.point.clone().setY(M), P.setPoints([p, l]), y.setPoints([])) : w === "none" ? (l = i.point, P.setPoints([p, l]), y.setPoints([])) : w === "xoz" ? (m = m != null ? m : new H.Plane().setFromNormalAndCoplanarPoint(new H.Vector3(0, 1, 0), o[0]), e.plane = m, l = m.projectPoint(i.point, new H.Vector3()), P.setPoints([p, l]), y.setPoints([l, i.point])) : w === "y" && (o.length === 1 ? (l = i.point, P.setPoints([p, l]), y.setPoints([])) : (m = m != null ? m : new H.Plane().setFromCoplanarPoints(o[0], o[1], new H.Vector3(0, 1, 0).add(o[0])), e.plane = m, l = m.projectPoint(i.point, new H.Vector3()), P.setPoints([p, l]), y.setPoints([l, i.point])))), o.length >= 3) {
|
|
219
|
+
c ? l = i.point.clone().setY(M) : l = s.projectPoint(i.point);
|
|
219
220
|
const h = o[0];
|
|
220
221
|
let f = !1;
|
|
221
222
|
if (typeof (t == null ? void 0 : t.autoClosePixelDistance) == "number") {
|
|
222
223
|
if (u && u.camera && u.getElement) {
|
|
223
|
-
const b = u.getElement(), S = b.clientWidth,
|
|
224
|
-
const st =
|
|
224
|
+
const b = u.getElement(), S = b.clientWidth, I = b.clientHeight, A = (ct) => {
|
|
225
|
+
const st = ct.clone().project(u.camera);
|
|
225
226
|
return {
|
|
226
227
|
x: (st.x * 0.5 + 0.5) * S,
|
|
227
|
-
y: (1 - (st.y * 0.5 + 0.5)) *
|
|
228
|
+
y: (1 - (st.y * 0.5 + 0.5)) * I
|
|
228
229
|
};
|
|
229
|
-
},
|
|
230
|
-
(
|
|
230
|
+
}, k = A(h), tt = A(l), et = A(i.point), ut = Math.sqrt(v(k.x - tt.x, 2) + v(k.y - tt.y, 2)), pt = Math.sqrt(v(k.x - et.x, 2) + v(k.y - et.y, 2));
|
|
231
|
+
(ut < t.autoClosePixelDistance || pt < t.autoClosePixelDistance) && (f = !0);
|
|
231
232
|
}
|
|
232
233
|
} else
|
|
233
234
|
(h.distanceTo(l) < 0.2 || h.distanceTo(i.point) < 0.2) && (f = !0);
|
|
234
|
-
f ? (l = h, i.point.copy(h),
|
|
235
|
+
f ? (l = h, i.point.copy(h), e.pointSelectorHelper.updateWithIntersect(i, { emitEvent: !1 }), W = !0) : W = !1, P.setPoints([p, l]), y.setPoints([l, i.point]);
|
|
235
236
|
}
|
|
236
|
-
o.length >= 2 ? (
|
|
237
|
-
}, F = () => {
|
|
238
|
-
s.off("select", q), s.off("intersectionUpdate", O), s.off("disable", L), s.plane = null, s.disable(), a == null || a.remove(P, y), Y();
|
|
237
|
+
o.length >= 2 ? (s.setPoints([...o, l], { closed: !1 }), s.line.setPoints(s.points.slice(0, -1)), t != null && t.experimental_self_intersect_check && lt([...o, l]) ? (e.cursorError = !0, P.setStyle({ lineColor: 16734553 }), y.setStyle({ lineColor: 16734553 })) : (e.cursorError = !1, P.setStyle({ lineColor: s.lineColor }), y.setStyle({ lineColor: s.lineColor }))) : s.setPoints([]), D();
|
|
239
238
|
}, L = () => {
|
|
240
|
-
F(), a == null || a.remove(
|
|
239
|
+
e.off("select", F), e.off("intersectionUpdate", O), e.off("disable", N), e.plane = null, e.disable(), a == null || a.remove(P, y), Y();
|
|
240
|
+
}, N = () => {
|
|
241
|
+
L(), a == null || a.remove(s, y, P), Y(), x(new Error("Cancelled"));
|
|
241
242
|
};
|
|
242
|
-
return
|
|
243
|
-
finished:
|
|
243
|
+
return e.on("select", F), e.on("intersectionUpdate", O), e.on("disable", N), {
|
|
244
|
+
finished: r,
|
|
244
245
|
canUndo: z,
|
|
245
|
-
canRedo:
|
|
246
|
-
undo:
|
|
247
|
-
redo:
|
|
246
|
+
canRedo: q,
|
|
247
|
+
undo: ht,
|
|
248
|
+
redo: dt
|
|
248
249
|
};
|
|
249
250
|
}
|
|
250
251
|
export {
|
|
251
|
-
|
|
252
|
+
At as Polygon,
|
|
252
253
|
jt as createPolygon
|
|
253
254
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Point3D {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
z: number;
|
|
5
|
+
}
|
|
6
|
+
interface Line3D {
|
|
7
|
+
start: Point3D;
|
|
8
|
+
end: Point3D;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @description 判断线段是否相交
|
|
12
|
+
* @todo ai写的一些变量名起的比较怪,懒得改了
|
|
13
|
+
*/
|
|
14
|
+
export declare function isIntersecting(line1: Line3D, line2: Line3D | Line3D[]): boolean;
|
|
15
|
+
export declare function isLinesIntersecting(lines: Line3D[]): boolean;
|
|
16
|
+
export declare function isPolygenIntersecting(points: Point3D[]): boolean;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function q(n, t) {
|
|
2
|
+
const s = Array.isArray(t) ? t : [t];
|
|
3
|
+
for (let r = 0; r < s.length; r++) {
|
|
4
|
+
const e = n.start, c = n.end, o = s[r].start, u = s[r].end;
|
|
5
|
+
if (!(f(e, o) || f(e, u) || f(c, o) || f(c, u) || f(e, c)) && V([e.x, e.y, e.z], [c.x, c.y, c.z], [o.x, o.y, o.z], [u.x, u.y, u.z]))
|
|
6
|
+
return !0;
|
|
7
|
+
}
|
|
8
|
+
return !1;
|
|
9
|
+
}
|
|
10
|
+
function M(n) {
|
|
11
|
+
if (n.length < 2)
|
|
12
|
+
return !1;
|
|
13
|
+
for (let t = 0; t < n.length; t++)
|
|
14
|
+
if (q(n[t], n.slice(t + 1)))
|
|
15
|
+
return !0;
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
18
|
+
function w(n) {
|
|
19
|
+
const t = [];
|
|
20
|
+
for (let s = 1; s < n.length; s++) {
|
|
21
|
+
const r = { start: n[s - 1], end: n[s] };
|
|
22
|
+
t.push(r);
|
|
23
|
+
}
|
|
24
|
+
return M(t);
|
|
25
|
+
}
|
|
26
|
+
function V(n, t, s, r) {
|
|
27
|
+
const e = [t[0] - n[0], t[1] - n[1], t[2] - n[2]], c = [r[0] - s[0], r[1] - s[1], r[2] - s[2]], o = [
|
|
28
|
+
{ a: [e[0], -c[0]], b: s[0] - n[0] },
|
|
29
|
+
{ a: [e[1], -c[1]], b: s[1] - n[1] },
|
|
30
|
+
{ a: [e[2], -c[2]], b: s[2] - n[2] }
|
|
31
|
+
], u = [
|
|
32
|
+
[0, 1],
|
|
33
|
+
// X 和 Y
|
|
34
|
+
[0, 2],
|
|
35
|
+
// X 和 Z
|
|
36
|
+
[1, 2]
|
|
37
|
+
// Y 和 Z
|
|
38
|
+
];
|
|
39
|
+
for (const [i, a] of u) {
|
|
40
|
+
const g = [o[i].a, o[a].a], h = [o[i].b, o[a].b], y = L(g);
|
|
41
|
+
if (Math.abs(y) < 1e-10)
|
|
42
|
+
continue;
|
|
43
|
+
const I = j(g, y), [x, z] = m(I, h);
|
|
44
|
+
return !!(b(x) && b(z));
|
|
45
|
+
}
|
|
46
|
+
return !1;
|
|
47
|
+
}
|
|
48
|
+
function L(n) {
|
|
49
|
+
return n[0][0] * n[1][1] - n[0][1] * n[1][0];
|
|
50
|
+
}
|
|
51
|
+
function j(n, t) {
|
|
52
|
+
return [
|
|
53
|
+
[n[1][1] / t, -n[0][1] / t],
|
|
54
|
+
[-n[1][0] / t, n[0][0] / t]
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
function m(n, t) {
|
|
58
|
+
return [n[0][0] * t[0] + n[0][1] * t[1], n[1][0] * t[0] + n[1][1] * t[1]];
|
|
59
|
+
}
|
|
60
|
+
function b(n) {
|
|
61
|
+
return n >= 0 && n <= 1;
|
|
62
|
+
}
|
|
63
|
+
function f(n, t) {
|
|
64
|
+
return n.x === t.x && n.y === t.y && n.z === t.z;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
w as isPolygenIntersecting
|
|
68
|
+
};
|