@realsee/dnalogel 3.73.5 → 3.74.0-alpha.0
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 +5 -0
- package/dist/Sculpt/Objects/Polygon/index.d.ts +13 -0
- package/dist/Sculpt/index.d.ts +12 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.js +20 -9
- package/dist/index.umd.js +25 -25
- package/libs/Sculpt/Objects/Polygon/index.d.ts +13 -0
- package/libs/Sculpt/Objects/Polygon/index.js +86 -83
- package/libs/Sculpt/index.d.ts +12 -0
- package/libs/Sculpt/index.js +84 -76
- package/libs/base/BasePlugin.js +5 -5
- package/libs/shared-utils/logger.js +1 -1
- package/package.json +1 -1
|
@@ -14,11 +14,24 @@ export type PolygonCreateConfig = Partial<PolygonStyle & CreateLimitConfig & Pol
|
|
|
14
14
|
onPointPlaced?: (points: THREE.Vector3[]) => void;
|
|
15
15
|
onUndo?: () => void;
|
|
16
16
|
onRedo?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* @description 检测到自相交时的回调
|
|
19
|
+
* @param point 尝试添加但被拒绝的点坐标
|
|
20
|
+
*/
|
|
21
|
+
__onSelfIntersect?: (point: THREE.Vector3) => void;
|
|
22
|
+
/**
|
|
23
|
+
* @description 将要添加的下一个点
|
|
24
|
+
*/
|
|
25
|
+
__onWillAddPoint?: (point: THREE.Vector3) => void;
|
|
17
26
|
/**
|
|
18
27
|
* @description 检测是否自相交,如果自交,禁止添加下一个点
|
|
19
28
|
* @default false
|
|
20
29
|
*/
|
|
21
30
|
experimental_self_intersect_check?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 最多允许能添加的点数
|
|
33
|
+
*/
|
|
34
|
+
experimental_max_point_count?: number;
|
|
22
35
|
};
|
|
23
36
|
export declare class Polygon extends BaseObject<PolygonImportData> {
|
|
24
37
|
readonly type = "Polygon";
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ct = Object.defineProperty, Pt = Object.defineProperties;
|
|
2
2
|
var yt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var it = Object.getOwnPropertySymbols;
|
|
4
|
-
var mt = Object.prototype.hasOwnProperty,
|
|
5
|
-
var
|
|
4
|
+
var mt = Object.prototype.hasOwnProperty, xt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var _ = Math.pow, T = (e, s, t) => s in e ? ct(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t, H = (e, s) => {
|
|
6
6
|
for (var t in s || (s = {}))
|
|
7
|
-
mt.call(s, t) &&
|
|
7
|
+
mt.call(s, t) && T(e, t, s[t]);
|
|
8
8
|
if (it)
|
|
9
9
|
for (var t of it(s))
|
|
10
|
-
|
|
10
|
+
xt.call(s, t) && T(e, t, s[t]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
var C = (e, s, t) => (
|
|
12
|
+
}, R = (e, s) => Pt(e, yt(s));
|
|
13
|
+
var C = (e, s, t) => (T(e, typeof s != "symbol" ? s + "" : s, t), t);
|
|
14
14
|
var ot = (e, s, t) => new Promise((o, r) => {
|
|
15
|
-
var
|
|
15
|
+
var x = (c) => {
|
|
16
16
|
try {
|
|
17
|
-
w(t.next(
|
|
18
|
-
} catch (
|
|
19
|
-
r(
|
|
17
|
+
w(t.next(c));
|
|
18
|
+
} catch (u) {
|
|
19
|
+
r(u);
|
|
20
20
|
}
|
|
21
|
-
}, a = (
|
|
21
|
+
}, a = (c) => {
|
|
22
22
|
try {
|
|
23
|
-
w(t.throw(
|
|
24
|
-
} catch (
|
|
25
|
-
r(
|
|
23
|
+
w(t.throw(c));
|
|
24
|
+
} catch (u) {
|
|
25
|
+
r(u);
|
|
26
26
|
}
|
|
27
|
-
}, w = (
|
|
27
|
+
}, w = (c) => c.done ? o(c.value) : Promise.resolve(c.value).then(x, a);
|
|
28
28
|
w((t = t.apply(e, s)).next());
|
|
29
29
|
});
|
|
30
|
-
import { BaseObject as
|
|
31
|
-
import * as
|
|
30
|
+
import { BaseObject as ft } from "../Base/index.js";
|
|
31
|
+
import * as j from "three";
|
|
32
32
|
import { PolylineMesh as nt } from "../../Meshes/Polyline.js";
|
|
33
33
|
import { AreaMesh as rt } from "../../Meshes/Area.js";
|
|
34
34
|
import { PolygonEditor as bt } from "./Editor.js";
|
|
@@ -36,7 +36,7 @@ import { vector3ToArray as Ct } from "../../../shared-utils/three/vector3ToArray
|
|
|
36
36
|
import { withResolvers as wt } from "../../../shared-utils/promise/withResolvers.js";
|
|
37
37
|
import { anyPositionToVector3 as Dt } from "../../../shared-utils/positionToVector3.js";
|
|
38
38
|
import { PointMesh as Ht } from "../../Meshes/Point.js";
|
|
39
|
-
class
|
|
39
|
+
class Wt extends ft {
|
|
40
40
|
constructor(t, o) {
|
|
41
41
|
var r;
|
|
42
42
|
super(t, o);
|
|
@@ -59,7 +59,7 @@ class Rt extends xt {
|
|
|
59
59
|
typeof t == "function" && t(), this._editor && this._editor.updatePointMeshes();
|
|
60
60
|
}
|
|
61
61
|
get data() {
|
|
62
|
-
return this.updateMatrixWorld(),
|
|
62
|
+
return this.updateMatrixWorld(), R(H({}, this.baseData), {
|
|
63
63
|
points: Ct(this.applyObjectMatrixWorld(this.areaMesh.points)),
|
|
64
64
|
style: {
|
|
65
65
|
color: this.areaMesh.color.getHex(),
|
|
@@ -80,8 +80,8 @@ class Rt extends xt {
|
|
|
80
80
|
(t = this.areaMesh) == null || t.unhighlight();
|
|
81
81
|
}
|
|
82
82
|
canUndo() {
|
|
83
|
-
var o, r,
|
|
84
|
-
return this.creatingObject ? (
|
|
83
|
+
var o, r, x;
|
|
84
|
+
return this.creatingObject ? (x = (r = (o = this.creatingObject) == null ? void 0 : o.canUndo) == null ? void 0 : r.call(o)) != null ? x : !1 : this.currentHistoryIndex > 0;
|
|
85
85
|
}
|
|
86
86
|
canRedo() {
|
|
87
87
|
var t, o, r;
|
|
@@ -129,78 +129,81 @@ class Rt extends xt {
|
|
|
129
129
|
create(t) {
|
|
130
130
|
return ot(this, null, function* () {
|
|
131
131
|
var r;
|
|
132
|
-
this.children.forEach((
|
|
133
|
-
|
|
132
|
+
this.children.forEach((x) => {
|
|
133
|
+
x.parent === this && this.remove(x);
|
|
134
134
|
}), this.children.length = 0;
|
|
135
135
|
const o = new rt(t);
|
|
136
|
-
this.areaMesh = o, this.add(this.areaMesh), this.creatingObject =
|
|
136
|
+
this.areaMesh = o, this.add(this.areaMesh), this.creatingObject = jt(this.areaMesh, this.pointSelector, t), yield (r = this.creatingObject) == null ? void 0 : r.finished, this.creatingObject = null, this.recordHistory(), this.updateCreationPointMeshes(), this.config.defaultAction && this.editor.enable();
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
var
|
|
142
|
-
const { promise: o, resolve: r, reject:
|
|
140
|
+
function jt(e, s, t) {
|
|
141
|
+
var N, $, G, J, K, Q, X, Z, g;
|
|
142
|
+
const { promise: o, resolve: r, reject: x } = wt(), a = e.parent;
|
|
143
143
|
if (!a) {
|
|
144
|
-
|
|
144
|
+
x(new Error("No container"));
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
const w = (
|
|
148
|
-
e.userData = (
|
|
149
|
-
let
|
|
150
|
-
|
|
147
|
+
const w = (N = t == null ? void 0 : t.limit) != null ? N : "none", c = t == null ? void 0 : t.simpleMode, u = (Q = (K = (G = e.five) != null ? G : ($ = e.get) == null ? void 0 : $.call(e, "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;
|
|
148
|
+
e.userData = (Z = e.userData) != null ? Z : {}, e.userData.dragSelectPixelDistance = V;
|
|
149
|
+
let M = 0;
|
|
150
|
+
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
151
|
const P = new nt(e.style);
|
|
152
152
|
a == null || a.add(P);
|
|
153
|
-
const y = new nt(
|
|
153
|
+
const y = new nt(R(H({}, e.style), { dashed: !0, lengthEnable: !1 }));
|
|
154
154
|
a == null || a.add(y);
|
|
155
|
-
let
|
|
155
|
+
let v = [];
|
|
156
156
|
const lt = (i = n) => {
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
157
|
+
v.forEach((d, p) => {
|
|
158
|
+
const h = i[p];
|
|
159
|
+
h && d.position.copy(h);
|
|
160
160
|
});
|
|
161
161
|
};
|
|
162
162
|
function D() {
|
|
163
|
-
var d,
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
return (
|
|
163
|
+
var d, p;
|
|
164
|
+
v.forEach((h) => {
|
|
165
|
+
var f;
|
|
166
|
+
return (f = h.parent) == null ? void 0 : f.remove(h);
|
|
167
167
|
});
|
|
168
|
-
const i = (
|
|
169
|
-
|
|
168
|
+
const i = (p = (d = e.line) == null ? void 0 : d.style) != null ? p : e.style;
|
|
169
|
+
v = n.map((h, f) => {
|
|
170
170
|
var S, k;
|
|
171
|
-
const
|
|
171
|
+
const b = new Ht(R(H({}, i), {
|
|
172
172
|
color: (S = i.pointColor) != null ? S : i.lineColor,
|
|
173
173
|
tip: void 0,
|
|
174
|
-
point:
|
|
174
|
+
point: h
|
|
175
175
|
}));
|
|
176
|
-
return
|
|
176
|
+
return b.name = `PolygonPointMesh_${f}`, b.userData = (k = b.userData) != null ? k : {}, b.userData.dragSelectPixelDistance = V, a == null || a.add(b), b;
|
|
177
177
|
}), lt();
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
179
|
+
function Y() {
|
|
180
|
+
v.forEach((i) => {
|
|
181
181
|
var d;
|
|
182
182
|
return (d = i.parent) == null ? void 0 : d.remove(i);
|
|
183
|
-
}),
|
|
183
|
+
}), v = [], e.userData && (delete e.userData.creationPointMeshes, delete e.userData.syncCreationPointMeshes, delete e.userData.disposeCreationPointMeshes);
|
|
184
184
|
}
|
|
185
|
-
s.enable(),
|
|
185
|
+
s.enable(), c && s.setAdherePoints([]);
|
|
186
186
|
const n = [];
|
|
187
|
-
let l, m,
|
|
188
|
-
const
|
|
187
|
+
let l, m, W = !1, U;
|
|
188
|
+
const E = [], z = () => n.length > 0, B = () => E.length > 0, at = () => {
|
|
189
189
|
var i;
|
|
190
|
-
|
|
190
|
+
z() && (E.push(n.pop()), O(U), D(), (i = t == null ? void 0 : t.onUndo) == null || i.call(t), s.pointSelectorHelper && s.pointSelectorHelper.magnifier && s.pointSelectorHelper.magnifier.render());
|
|
191
191
|
}, ht = () => {
|
|
192
192
|
var i;
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
var
|
|
196
|
-
|
|
193
|
+
B() && (n.push(E.pop()), O(U), D(), (i = t == null ? void 0 : t.onRedo) == null || i.call(t), s.pointSelectorHelper && s.pointSelectorHelper.magnifier && s.pointSelectorHelper.magnifier.render());
|
|
194
|
+
}, q = (i) => {
|
|
195
|
+
var p, h;
|
|
196
|
+
E.length = 0;
|
|
197
197
|
let d = n.length === 0 ? i.point : l.clone();
|
|
198
|
-
if (
|
|
199
|
-
n.
|
|
200
|
-
|
|
198
|
+
if (c && (d = d.clone().setY(M)), t.__onWillAddPoint(d), !((t == null ? void 0 : t.experimental_max_point_count) != null && n.length === t.experimental_max_point_count)) {
|
|
199
|
+
if (n.push(d), e.setPoints(n, { closed: !1 }), t != null && t.experimental_self_intersect_check && n.length > 2 && e.isBlank) {
|
|
200
|
+
const f = n.pop();
|
|
201
|
+
e.setPoints(n, { closed: !1 }), D(), console.warn("[Polygon] 检测到自相交,无法添加该点"), (p = t == null ? void 0 : t.__onSelfIntersect) == null || p.call(t, f);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
D(), (h = t == null ? void 0 : t.onPointPlaced) == null || h.call(t, n), W && (F(), r());
|
|
201
205
|
}
|
|
202
|
-
|
|
203
|
-
}, g = (i) => {
|
|
206
|
+
}, O = (i) => {
|
|
204
207
|
const d = () => {
|
|
205
208
|
P.setPoints([]), y.setPoints([]), e.setPoints(n), s.pointSelectorHelper && s.pointSelectorHelper.magnifier && s.pointSelectorHelper.magnifier.render();
|
|
206
209
|
};
|
|
@@ -210,41 +213,41 @@ function vt(e, s, t) {
|
|
|
210
213
|
}
|
|
211
214
|
if (U = i, !(n != null && n.length))
|
|
212
215
|
return d();
|
|
213
|
-
const
|
|
214
|
-
if (n.length < 3 && (
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
let
|
|
216
|
+
const p = n.at(-1).clone();
|
|
217
|
+
if (n.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 j.Plane().setFromNormalAndCoplanarPoint(new j.Vector3(0, 1, 0), n[0]), s.plane = m, l = m.projectPoint(i.point, new j.Vector3()), P.setPoints([p, l]), y.setPoints([l, i.point])) : w === "y" && (n.length === 1 ? (l = i.point, P.setPoints([p, l]), y.setPoints([])) : (m = m != null ? m : new j.Plane().setFromCoplanarPoints(n[0], n[1], new j.Vector3(0, 1, 0).add(n[0])), s.plane = m, l = m.projectPoint(i.point, new j.Vector3()), P.setPoints([p, l]), y.setPoints([l, i.point])))), n.length >= 3) {
|
|
218
|
+
c ? l = i.point.clone().setY(M) : l = e.projectPoint(i.point);
|
|
219
|
+
const h = n[0];
|
|
220
|
+
let f = !1;
|
|
218
221
|
if (typeof (t == null ? void 0 : t.autoClosePixelDistance) == "number") {
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
const st =
|
|
222
|
+
if (u && u.camera && u.getElement) {
|
|
223
|
+
const b = u.getElement(), S = b.clientWidth, k = b.clientHeight, A = (pt) => {
|
|
224
|
+
const st = pt.clone().project(u.camera);
|
|
222
225
|
return {
|
|
223
226
|
x: (st.x * 0.5 + 0.5) * S,
|
|
224
227
|
y: (1 - (st.y * 0.5 + 0.5)) * k
|
|
225
228
|
};
|
|
226
|
-
},
|
|
227
|
-
(dt < t.autoClosePixelDistance ||
|
|
229
|
+
}, I = A(h), tt = A(l), et = A(i.point), dt = Math.sqrt(_(I.x - tt.x, 2) + _(I.y - tt.y, 2)), ut = Math.sqrt(_(I.x - et.x, 2) + _(I.y - et.y, 2));
|
|
230
|
+
(dt < t.autoClosePixelDistance || ut < t.autoClosePixelDistance) && (f = !0);
|
|
228
231
|
}
|
|
229
232
|
} else
|
|
230
|
-
(
|
|
231
|
-
|
|
233
|
+
(h.distanceTo(l) < 0.2 || h.distanceTo(i.point) < 0.2) && (f = !0);
|
|
234
|
+
f ? (l = h, i.point.copy(h), s.pointSelectorHelper.updateWithIntersect(i, { emitEvent: !1 }), W = !0) : W = !1, P.setPoints([p, l]), y.setPoints([l, i.point]);
|
|
232
235
|
}
|
|
233
236
|
n.length >= 2 ? (e.setPoints([...n, l], { closed: !1 }), e.line.setPoints(e.points.slice(0, -1)), e.isBlank ? (s.cursorError = !0, P.setStyle({ lineColor: 16734553 }), y.setStyle({ lineColor: 16734553 })) : (s.cursorError = !1, P.setStyle({ lineColor: e.lineColor }), y.setStyle({ lineColor: e.lineColor }))) : e.setPoints([]), D();
|
|
234
|
-
}, q = () => {
|
|
235
|
-
s.off("select", B), s.off("intersectionUpdate", g), s.off("disable", F), s.plane = null, s.disable(), a == null || a.remove(P, y), V();
|
|
236
237
|
}, F = () => {
|
|
237
|
-
q(), a == null || a.remove(
|
|
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();
|
|
239
|
+
}, L = () => {
|
|
240
|
+
F(), a == null || a.remove(e, y, P), Y(), x(new Error("Cancelled"));
|
|
238
241
|
};
|
|
239
|
-
return s.on("select",
|
|
242
|
+
return s.on("select", q), s.on("intersectionUpdate", O), s.on("disable", L), {
|
|
240
243
|
finished: o,
|
|
241
|
-
canUndo:
|
|
242
|
-
canRedo:
|
|
244
|
+
canUndo: z,
|
|
245
|
+
canRedo: B,
|
|
243
246
|
undo: at,
|
|
244
247
|
redo: ht
|
|
245
248
|
};
|
|
246
249
|
}
|
|
247
250
|
export {
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
Wt as Polygon,
|
|
252
|
+
jt as createPolygon
|
|
250
253
|
};
|
package/libs/Sculpt/index.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ type Event = {
|
|
|
53
53
|
* 返回 false 来禁用 Five 默认行为
|
|
54
54
|
*/
|
|
55
55
|
click: (e: MouseEvent, item: BuiltInItem) => void | false;
|
|
56
|
+
/**
|
|
57
|
+
* @description 当 Polygon 创建时检测到自相交时触发(需开启 experimental_self_intersect_check)
|
|
58
|
+
* @param item Polygon 实例
|
|
59
|
+
* @param point 尝试添加但被拒绝的点坐标
|
|
60
|
+
*/
|
|
61
|
+
'polygon.experimental_self_intersect': (item: Polygon, point: THREE.Vector3) => void;
|
|
62
|
+
/**
|
|
63
|
+
* @description polygon 将要添加到下一个点
|
|
64
|
+
* @param item Polygon 实例
|
|
65
|
+
* @param point polygon 将要添加到下一个点到坐标
|
|
66
|
+
*/
|
|
67
|
+
'polygon.experimental_point_will_add': (item: Polygon, point: THREE.Vector3) => void;
|
|
56
68
|
};
|
|
57
69
|
export declare class Sculpt extends Subscribe<Event> {
|
|
58
70
|
static modules: {
|
package/libs/Sculpt/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var S = Object.defineProperty, U = Object.defineProperties;
|
|
2
|
+
var x = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var y = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var p = (
|
|
6
|
-
for (var e in
|
|
7
|
-
|
|
4
|
+
var D = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var p = (c, n, e) => n in c ? S(c, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[n] = e, g = (c, n) => {
|
|
6
|
+
for (var e in n || (n = {}))
|
|
7
|
+
D.call(n, e) && p(c, e, n[e]);
|
|
8
8
|
if (y)
|
|
9
|
-
for (var e of y(
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, a = (
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var l = (
|
|
9
|
+
for (var e of y(n))
|
|
10
|
+
L.call(n, e) && p(c, e, n[e]);
|
|
11
|
+
return c;
|
|
12
|
+
}, a = (c, n) => U(c, x(n));
|
|
13
|
+
var u = (c, n, e) => (p(c, typeof n != "symbol" ? n + "" : n, e), e);
|
|
14
|
+
var m = (c, n, e) => new Promise((t, i) => {
|
|
15
|
+
var l = (s) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
r(e.next(s));
|
|
18
18
|
} catch (h) {
|
|
19
19
|
i(h);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, o = (s) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
r(e.throw(s));
|
|
24
24
|
} catch (h) {
|
|
25
25
|
i(h);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, r = (s) => s.done ? t(s.value) : Promise.resolve(s.value).then(l, o);
|
|
28
|
+
r((e = e.apply(c, n)).next());
|
|
29
29
|
});
|
|
30
|
-
import { globalModules as
|
|
31
|
-
import { Subscribe as
|
|
30
|
+
import { globalModules as B } from "./utils/Modules/Global.js";
|
|
31
|
+
import { Subscribe as E } from "../shared-utils/Subscribe.js";
|
|
32
32
|
import { IObject3D as z } from "../shared-utils/three/IObject3D.js";
|
|
33
33
|
import "../shared-utils/tag.js";
|
|
34
34
|
import "three";
|
|
@@ -47,29 +47,29 @@ import "../vendor/earcut/src/earcut.js";
|
|
|
47
47
|
import "../shared-utils/five/FivePuppet.js";
|
|
48
48
|
import { recurveFindObject as F } from "../shared-utils/three/recurveFindObject.js";
|
|
49
49
|
import { Polyline as I } from "./Objects/Polyline/index.js";
|
|
50
|
-
import { Point as
|
|
51
|
-
import { Polygon as
|
|
52
|
-
import { Prism as
|
|
53
|
-
import { Rectangle as
|
|
54
|
-
import { Circle as
|
|
55
|
-
import { Cylinder as
|
|
56
|
-
import { Box as
|
|
50
|
+
import { Point as w } from "./Objects/Point/index.js";
|
|
51
|
+
import { Polygon as b } from "./Objects/Polygon/index.js";
|
|
52
|
+
import { Prism as _ } from "./Objects/Prism/index.js";
|
|
53
|
+
import { Rectangle as j } from "./Objects/Rectangle/index.js";
|
|
54
|
+
import { Circle as v } from "./Objects/Circle/index.js";
|
|
55
|
+
import { Cylinder as R } from "./Objects/Cylinder/index.js";
|
|
56
|
+
import { Box as P } from "./Objects/Box/index.js";
|
|
57
57
|
import { forReverseEach as H } from "../shared-utils/forReverseEach.js";
|
|
58
|
-
import { Line as
|
|
58
|
+
import { Line as C } from "./Objects/Line/index.js";
|
|
59
59
|
import { hotkeys as O } from "../vendor/hotkeys-js/dist/hotkeys.esm.js";
|
|
60
60
|
import { withResolvers as M } from "../shared-utils/promise/withResolvers.js";
|
|
61
|
-
const d = class extends
|
|
61
|
+
const d = class extends E {
|
|
62
62
|
constructor(e, t, i) {
|
|
63
63
|
super();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
u(this, "group");
|
|
65
|
+
u(this, "theme");
|
|
66
|
+
u(this, "config");
|
|
67
|
+
u(this, "five");
|
|
68
|
+
u(this, "creatingItem", null);
|
|
69
69
|
/**
|
|
70
70
|
* @description: 撤销
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
u(this, "undo", () => {
|
|
73
73
|
if (this.creatingItem) {
|
|
74
74
|
this.creatingItem.undo(), this.five.needsRender = !0;
|
|
75
75
|
return;
|
|
@@ -80,7 +80,7 @@ const d = class extends x {
|
|
|
80
80
|
/**
|
|
81
81
|
* @description: 重做
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
u(this, "redo", () => {
|
|
84
84
|
if (this.creatingItem) {
|
|
85
85
|
this.creatingItem.redo(), this.five.needsRender = !0;
|
|
86
86
|
return;
|
|
@@ -90,10 +90,10 @@ const d = class extends x {
|
|
|
90
90
|
});
|
|
91
91
|
this.five = e, this.theme = t, this.config = g({
|
|
92
92
|
magnifier: { width: 190, height: 190, scale: 2, dragEnabled: !0 }
|
|
93
|
-
}, i), this.group = new z(), this.group.name = "Sculpt", this.group.__sculpt__ = this, e.scene.add(this.group), d.modules.init(e, this.config), O("ctrl+z, command+z", this.undo), O("ctrl+shift+z, command+shift+z", this.redo), d.modules.fiveDomEvents.addEventListener(this.group, "click", ({ intersects: l, origDomEvent:
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
return
|
|
93
|
+
}, i), this.group = new z(), this.group.name = "Sculpt", this.group.__sculpt__ = this, e.scene.add(this.group), d.modules.init(e, this.config), O("ctrl+z, command+z", this.undo), O("ctrl+shift+z, command+shift+z", this.redo), d.modules.fiveDomEvents.addEventListener(this.group, "click", ({ intersects: l, origDomEvent: o }) => {
|
|
94
|
+
var s;
|
|
95
|
+
const r = F((s = l == null ? void 0 : l[0]) == null ? void 0 : s.object, (h) => h.isSculptObject);
|
|
96
|
+
return r && !r.editing ? this.emit("click", o, r) : !1;
|
|
97
97
|
}), window.__SCULPT_DEBUG__ = this, window.__SCULPT_MODULES_DEBUG__ = d.modules;
|
|
98
98
|
}
|
|
99
99
|
get data() {
|
|
@@ -116,12 +116,12 @@ const d = class extends x {
|
|
|
116
116
|
load(e, t) {
|
|
117
117
|
var l;
|
|
118
118
|
this.clear();
|
|
119
|
-
const i = (l = e == null ? void 0 : e.items) == null ? void 0 : l.map((
|
|
120
|
-
var
|
|
121
|
-
const
|
|
122
|
-
style: g(g({}, (
|
|
119
|
+
const i = (l = e == null ? void 0 : e.items) == null ? void 0 : l.map((o) => {
|
|
120
|
+
var s;
|
|
121
|
+
const r = a(g({}, o), {
|
|
122
|
+
style: g(g({}, (s = this.theme) == null ? void 0 : s[o.type.toLowerCase()]), o.style)
|
|
123
123
|
});
|
|
124
|
-
return
|
|
124
|
+
return o.type === "Point" ? new w(r, t) : o.type === "line" ? new C(r, t) : o.type === "Polyline" ? new I(r, t) : o.type === "Polygon" ? new b(r, t) : o.type === "Prism" ? new _(r, t) : o.type === "Rectangle" ? new j(r, t) : o.type === "Circle" ? new v(r, t) : o.type === "Cylinder" ? new R(r, t) : o.type === "Box" ? new P(r, t) : null;
|
|
125
125
|
});
|
|
126
126
|
this.group.add(...i), this.five.needsRender = !0;
|
|
127
127
|
}
|
|
@@ -144,25 +144,25 @@ const d = class extends x {
|
|
|
144
144
|
* @description: 开始绘制点
|
|
145
145
|
*/
|
|
146
146
|
createPoint(...e) {
|
|
147
|
-
return
|
|
147
|
+
return m(this, null, function* () {
|
|
148
148
|
var t, i;
|
|
149
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.point, e[0]), this.createItem(
|
|
149
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.point, e[0]), this.createItem(w, ...e);
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* @description: 开始绘制线段
|
|
154
154
|
*/
|
|
155
155
|
createLine(...e) {
|
|
156
|
-
return
|
|
156
|
+
return m(this, null, function* () {
|
|
157
157
|
var t, i;
|
|
158
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.line, e[0]), this.createItem(
|
|
158
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.line, e[0]), this.createItem(C, ...e);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* @deprecated use createLine instead
|
|
163
163
|
*/
|
|
164
164
|
createline(...e) {
|
|
165
|
-
return
|
|
165
|
+
return m(this, null, function* () {
|
|
166
166
|
this.createLine(...e);
|
|
167
167
|
});
|
|
168
168
|
}
|
|
@@ -170,7 +170,7 @@ const d = class extends x {
|
|
|
170
170
|
* @description: 开始绘制空间折线
|
|
171
171
|
*/
|
|
172
172
|
createPolyline(...e) {
|
|
173
|
-
return
|
|
173
|
+
return m(this, null, function* () {
|
|
174
174
|
var t, i;
|
|
175
175
|
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.polyline, e[0]), this.createItem(I, ...e);
|
|
176
176
|
});
|
|
@@ -179,54 +179,62 @@ const d = class extends x {
|
|
|
179
179
|
* @description: 开始绘制平面多边形
|
|
180
180
|
*/
|
|
181
181
|
createPolygon(...e) {
|
|
182
|
-
return
|
|
183
|
-
var
|
|
184
|
-
|
|
182
|
+
return m(this, null, function* () {
|
|
183
|
+
var i, l, o;
|
|
184
|
+
Object.assign((i = e[0]) != null ? i : {}, (l = this.theme) == null ? void 0 : l.polygon, e[0]);
|
|
185
|
+
const t = (o = e[0]) != null ? o : {};
|
|
186
|
+
return t.__onSelfIntersect = (r) => {
|
|
187
|
+
const s = this.creatingItem;
|
|
188
|
+
this.emit("polygon.experimental_self_intersect", s, r);
|
|
189
|
+
}, t.__onWillAddPoint = (r) => {
|
|
190
|
+
const s = this.creatingItem;
|
|
191
|
+
this.emit("polygon.experimental_point_will_add", s, r);
|
|
192
|
+
}, e[0] = t, this.createItem(b, ...e);
|
|
185
193
|
});
|
|
186
194
|
}
|
|
187
195
|
/**
|
|
188
196
|
* @description: 开始绘制多棱柱
|
|
189
197
|
*/
|
|
190
198
|
createPrism(...e) {
|
|
191
|
-
return
|
|
199
|
+
return m(this, null, function* () {
|
|
192
200
|
var t, i;
|
|
193
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.prism, e[0]), this.createItem(
|
|
201
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.prism, e[0]), this.createItem(_, ...e);
|
|
194
202
|
});
|
|
195
203
|
}
|
|
196
204
|
/**
|
|
197
205
|
* @description: 开始绘制矩形
|
|
198
206
|
*/
|
|
199
207
|
createRectangle(...e) {
|
|
200
|
-
return
|
|
208
|
+
return m(this, null, function* () {
|
|
201
209
|
var t, i;
|
|
202
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.rectangle, e[0]), this.createItem(
|
|
210
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.rectangle, e[0]), this.createItem(j, ...e);
|
|
203
211
|
});
|
|
204
212
|
}
|
|
205
213
|
/**
|
|
206
214
|
* @description: 开始绘制圆形
|
|
207
215
|
*/
|
|
208
216
|
createCircle(...e) {
|
|
209
|
-
return
|
|
217
|
+
return m(this, null, function* () {
|
|
210
218
|
var t, i;
|
|
211
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.circle, e[0]), this.createItem(
|
|
219
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.circle, e[0]), this.createItem(v, ...e);
|
|
212
220
|
});
|
|
213
221
|
}
|
|
214
222
|
/**
|
|
215
223
|
* @description: 开始绘制圆柱
|
|
216
224
|
*/
|
|
217
225
|
createCylinder(...e) {
|
|
218
|
-
return
|
|
226
|
+
return m(this, null, function* () {
|
|
219
227
|
var t, i;
|
|
220
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.cylinder, e[0]), this.createItem(
|
|
228
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.cylinder, e[0]), this.createItem(R, ...e);
|
|
221
229
|
});
|
|
222
230
|
}
|
|
223
231
|
/**
|
|
224
232
|
* @description: 开始绘制 Box
|
|
225
233
|
*/
|
|
226
234
|
createBox(...e) {
|
|
227
|
-
return
|
|
235
|
+
return m(this, null, function* () {
|
|
228
236
|
var t, i;
|
|
229
|
-
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.box, e[0]), this.createItem(
|
|
237
|
+
return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.box, e[0]), this.createItem(P, ...e);
|
|
230
238
|
});
|
|
231
239
|
}
|
|
232
240
|
canUndo() {
|
|
@@ -248,28 +256,28 @@ const d = class extends x {
|
|
|
248
256
|
H(this.items, (e) => e.delete()), this.five.needsRender = !0;
|
|
249
257
|
}
|
|
250
258
|
createItem(e, ...t) {
|
|
251
|
-
return
|
|
259
|
+
return m(this, null, function* () {
|
|
252
260
|
this.creatingItem && (this.creatingItem.stopCreating(), this.creatingItem = null);
|
|
253
261
|
const i = new e();
|
|
254
262
|
this.creatingItem = i, this.group.add(i);
|
|
255
|
-
const { promise: l, resolve:
|
|
256
|
-
return yield i.create(...t).then((...
|
|
257
|
-
|
|
263
|
+
const { promise: l, resolve: o, reject: r } = M();
|
|
264
|
+
return yield i.create(...t).then((...s) => (this.creatingItem = null, i.select({ only: !0 }), o(i), s)).catch((s) => {
|
|
265
|
+
r(s), this.group.remove(i);
|
|
258
266
|
}), l;
|
|
259
267
|
});
|
|
260
268
|
}
|
|
261
269
|
};
|
|
262
270
|
let f = d;
|
|
263
|
-
|
|
264
|
-
const Ie = (
|
|
265
|
-
if (
|
|
266
|
-
const t =
|
|
267
|
-
return new f(
|
|
271
|
+
u(f, "modules", B);
|
|
272
|
+
const Ie = (c, n, e) => {
|
|
273
|
+
if (n && typeof n == "object" && ("theme" in n || "config" in n)) {
|
|
274
|
+
const t = n;
|
|
275
|
+
return new f(c, t.theme, t.config);
|
|
268
276
|
}
|
|
269
|
-
return new f(
|
|
270
|
-
},
|
|
277
|
+
return new f(c, n, e);
|
|
278
|
+
}, we = (c, n) => new f(c, n == null ? void 0 : n.theme, n == null ? void 0 : n.config);
|
|
271
279
|
export {
|
|
272
280
|
f as Sculpt,
|
|
273
281
|
Ie as SculptPlugin,
|
|
274
|
-
|
|
282
|
+
we as SculptPluginForFive
|
|
275
283
|
};
|