@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.
@@ -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 pt = Object.defineProperty, Pt = Object.defineProperties;
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, ft = Object.prototype.propertyIsEnumerable;
5
- var M = Math.pow, A = (e, s, t) => s in e ? pt(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t, H = (e, s) => {
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) && A(e, t, 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
- ft.call(s, t) && A(e, t, s[t]);
10
+ xt.call(s, t) && T(e, t, s[t]);
11
11
  return e;
12
- }, I = (e, s) => Pt(e, yt(s));
13
- var C = (e, s, t) => (A(e, typeof s != "symbol" ? s + "" : s, t), 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 f = (u) => {
15
+ var x = (c) => {
16
16
  try {
17
- w(t.next(u));
18
- } catch (h) {
19
- r(h);
17
+ w(t.next(c));
18
+ } catch (u) {
19
+ r(u);
20
20
  }
21
- }, a = (u) => {
21
+ }, a = (c) => {
22
22
  try {
23
- w(t.throw(u));
24
- } catch (h) {
25
- r(h);
23
+ w(t.throw(c));
24
+ } catch (u) {
25
+ r(u);
26
26
  }
27
- }, w = (u) => u.done ? o(u.value) : Promise.resolve(u.value).then(f, a);
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 xt } from "../Base/index.js";
31
- import * as v from "three";
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 Rt extends xt {
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(), I(H({}, this.baseData), {
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, f;
84
- return this.creatingObject ? (f = (r = (o = this.creatingObject) == null ? void 0 : o.canUndo) == null ? void 0 : r.call(o)) != null ? f : !1 : this.currentHistoryIndex > 0;
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((f) => {
133
- f.parent === this && this.remove(f);
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 = vt(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();
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 vt(e, s, t) {
141
- var L, N, $, G, J, K, Q, X, Z;
142
- const { promise: o, resolve: r, reject: f } = wt(), a = e.parent;
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
- f(new Error("No container"));
144
+ x(new Error("No container"));
145
145
  return;
146
146
  }
147
- const w = (L = t == null ? void 0 : t.limit) != null ? L : "none", u = t == null ? void 0 : t.simpleMode, h = (K = (J = ($ = e.five) != null ? $ : (N = e.get) == null ? void 0 : N.call(e, "five")) != null ? J : (G = window.globalModules) == null ? void 0 : G.five) != null ? K : window.$five, T = (Q = t == null ? void 0 : t.autoClosePixelDistance) != null ? Q : 10;
148
- e.userData = (X = e.userData) != null ? X : {}, e.userData.dragSelectPixelDistance = T;
149
- let E = 0;
150
- u && h && h.model && h.model.bounding && typeof ((Z = h.model.bounding.max) == null ? void 0 : Z.y) == "number" && (E = h.model.bounding.max.y + 1);
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(I(H({}, e.style), { dashed: !0, lengthEnable: !1 }));
153
+ const y = new nt(R(H({}, e.style), { dashed: !0, lengthEnable: !1 }));
154
154
  a == null || a.add(y);
155
- let j = [];
155
+ let v = [];
156
156
  const lt = (i = n) => {
157
- j.forEach((d, c) => {
158
- const p = i[c];
159
- p && d.position.copy(p);
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, c;
164
- j.forEach((p) => {
165
- var b;
166
- return (b = p.parent) == null ? void 0 : b.remove(p);
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 = (c = (d = e.line) == null ? void 0 : d.style) != null ? c : e.style;
169
- j = n.map((p, b) => {
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 x = new Ht(I(H({}, i), {
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: p
174
+ point: h
175
175
  }));
176
- return x.name = `PolygonPointMesh_${b}`, x.userData = (k = x.userData) != null ? k : {}, x.userData.dragSelectPixelDistance = T, a == null || a.add(x), x;
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 V() {
180
- j.forEach((i) => {
179
+ function Y() {
180
+ v.forEach((i) => {
181
181
  var d;
182
182
  return (d = i.parent) == null ? void 0 : d.remove(i);
183
- }), j = [], e.userData && (delete e.userData.creationPointMeshes, delete e.userData.syncCreationPointMeshes, delete e.userData.disposeCreationPointMeshes);
183
+ }), v = [], e.userData && (delete e.userData.creationPointMeshes, delete e.userData.syncCreationPointMeshes, delete e.userData.disposeCreationPointMeshes);
184
184
  }
185
- s.enable(), u && s.setAdherePoints([]);
185
+ s.enable(), c && s.setAdherePoints([]);
186
186
  const n = [];
187
- let l, m, R = !1, U;
188
- const O = [], Y = () => n.length > 0, z = () => O.length > 0, at = () => {
187
+ let l, m, W = !1, U;
188
+ const E = [], z = () => n.length > 0, B = () => E.length > 0, at = () => {
189
189
  var i;
190
- Y() && (O.push(n.pop()), g(U), D(), (i = t == null ? void 0 : t.onUndo) == null || i.call(t), s.pointSelectorHelper && s.pointSelectorHelper.magnifier && s.pointSelectorHelper.magnifier.render());
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
- z() && (n.push(O.pop()), g(U), D(), (i = t == null ? void 0 : t.onRedo) == null || i.call(t), s.pointSelectorHelper && s.pointSelectorHelper.magnifier && s.pointSelectorHelper.magnifier.render());
194
- }, B = (i) => {
195
- var c;
196
- O.length = 0;
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 (u && (d = d.clone().setY(E)), n.push(d), e.setPoints(n, { closed: !1 }), t != null && t.experimental_self_intersect_check && n.length > 2 && e.isBlank) {
199
- n.pop(), e.setPoints(n, { closed: !1 }), D(), console.warn("[Polygon] 检测到自相交,无法添加该点");
200
- return;
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
- D(), (c = t == null ? void 0 : t.onPointPlaced) == null || c.call(t, n), R && (q(), r());
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 c = n.at(-1).clone();
214
- if (n.length < 3 && (u ? (l = i.point.clone().setY(E), P.setPoints([c, l]), y.setPoints([])) : w === "none" ? (l = i.point, P.setPoints([c, l]), y.setPoints([])) : w === "xoz" ? (m = m != null ? m : new v.Plane().setFromNormalAndCoplanarPoint(new v.Vector3(0, 1, 0), n[0]), s.plane = m, l = m.projectPoint(i.point, new v.Vector3()), P.setPoints([c, l]), y.setPoints([l, i.point])) : w === "y" && (n.length === 1 ? (l = i.point, P.setPoints([c, l]), y.setPoints([])) : (m = m != null ? m : new v.Plane().setFromCoplanarPoints(n[0], n[1], new v.Vector3(0, 1, 0).add(n[0])), s.plane = m, l = m.projectPoint(i.point, new v.Vector3()), P.setPoints([c, l]), y.setPoints([l, i.point])))), n.length >= 3) {
215
- u ? l = i.point.clone().setY(E) : l = e.projectPoint(i.point);
216
- const p = n[0];
217
- let b = !1;
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 (h && h.camera && h.getElement) {
220
- const x = h.getElement(), S = x.clientWidth, k = x.clientHeight, W = (ut) => {
221
- const st = ut.clone().project(h.camera);
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
- }, _ = W(p), tt = W(l), et = W(i.point), dt = Math.sqrt(M(_.x - tt.x, 2) + M(_.y - tt.y, 2)), ct = Math.sqrt(M(_.x - et.x, 2) + M(_.y - et.y, 2));
227
- (dt < t.autoClosePixelDistance || ct < t.autoClosePixelDistance) && (b = !0);
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
- (p.distanceTo(l) < 0.2 || p.distanceTo(i.point) < 0.2) && (b = !0);
231
- b ? (l = p, i.point.copy(p), s.pointSelectorHelper.updateWithIntersect(i, { emitEvent: !1 }), R = !0) : R = !1, P.setPoints([c, l]), y.setPoints([l, i.point]);
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(e, y, P), V(), f(new Error("Cancelled"));
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", B), s.on("intersectionUpdate", g), s.on("disable", F), {
242
+ return s.on("select", q), s.on("intersectionUpdate", O), s.on("disable", L), {
240
243
  finished: o,
241
- canUndo: Y,
242
- canRedo: z,
244
+ canUndo: z,
245
+ canRedo: B,
243
246
  undo: at,
244
247
  redo: ht
245
248
  };
246
249
  }
247
250
  export {
248
- Rt as Polygon,
249
- vt as createPolygon
251
+ Wt as Polygon,
252
+ jt as createPolygon
250
253
  };
@@ -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: {
@@ -1,34 +1,34 @@
1
- var U = Object.defineProperty, D = Object.defineProperties;
2
- var L = Object.getOwnPropertyDescriptors;
1
+ var S = Object.defineProperty, U = Object.defineProperties;
2
+ var x = Object.getOwnPropertyDescriptors;
3
3
  var y = Object.getOwnPropertySymbols;
4
- var S = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
5
- var p = (o, r, e) => r in o ? U(o, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[r] = e, g = (o, r) => {
6
- for (var e in r || (r = {}))
7
- S.call(r, e) && p(o, e, r[e]);
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(r))
10
- B.call(r, e) && p(o, e, r[e]);
11
- return o;
12
- }, a = (o, r) => D(o, L(r));
13
- var m = (o, r, e) => (p(o, typeof r != "symbol" ? r + "" : r, e), e);
14
- var u = (o, r, e) => new Promise((t, i) => {
15
- var l = (c) => {
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
- n(e.next(c));
17
+ r(e.next(s));
18
18
  } catch (h) {
19
19
  i(h);
20
20
  }
21
- }, s = (c) => {
21
+ }, o = (s) => {
22
22
  try {
23
- n(e.throw(c));
23
+ r(e.throw(s));
24
24
  } catch (h) {
25
25
  i(h);
26
26
  }
27
- }, n = (c) => c.done ? t(c.value) : Promise.resolve(c.value).then(l, s);
28
- n((e = e.apply(o, r)).next());
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 E } from "./utils/Modules/Global.js";
31
- import { Subscribe as x } from "../shared-utils/Subscribe.js";
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 b } from "./Objects/Point/index.js";
51
- import { Polygon as w } from "./Objects/Polygon/index.js";
52
- import { Prism as j } from "./Objects/Prism/index.js";
53
- import { Rectangle as v } from "./Objects/Rectangle/index.js";
54
- import { Circle as R } from "./Objects/Circle/index.js";
55
- import { Cylinder as P } from "./Objects/Cylinder/index.js";
56
- import { Box as C } from "./Objects/Box/index.js";
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 _ } from "./Objects/Line/index.js";
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 x {
61
+ const d = class extends E {
62
62
  constructor(e, t, i) {
63
63
  super();
64
- m(this, "group");
65
- m(this, "theme");
66
- m(this, "config");
67
- m(this, "five");
68
- m(this, "creatingItem", null);
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
- m(this, "undo", () => {
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
- m(this, "redo", () => {
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: s }) => {
94
- var c;
95
- const n = F((c = l == null ? void 0 : l[0]) == null ? void 0 : c.object, (h) => h.isSculptObject);
96
- return n && !n.editing ? this.emit("click", s, n) : !1;
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((s) => {
120
- var c;
121
- const n = a(g({}, s), {
122
- style: g(g({}, (c = this.theme) == null ? void 0 : c[s.type.toLowerCase()]), s.style)
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 s.type === "Point" ? new b(n, t) : s.type === "line" ? new _(n, t) : s.type === "Polyline" ? new I(n, t) : s.type === "Polygon" ? new w(n, t) : s.type === "Prism" ? new j(n, t) : s.type === "Rectangle" ? new v(n, t) : s.type === "Circle" ? new R(n, t) : s.type === "Cylinder" ? new P(n, t) : s.type === "Box" ? new C(n, t) : null;
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 u(this, null, function* () {
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(b, ...e);
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 u(this, null, function* () {
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(_, ...e);
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 u(this, null, function* () {
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 u(this, null, function* () {
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 u(this, null, function* () {
183
- var t, i;
184
- return Object.assign((t = e[0]) != null ? t : {}, (i = this.theme) == null ? void 0 : i.polygon, e[0]), this.createItem(w, ...e);
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 u(this, null, function* () {
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(j, ...e);
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 u(this, null, function* () {
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(v, ...e);
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 u(this, null, function* () {
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(R, ...e);
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 u(this, null, function* () {
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(P, ...e);
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 u(this, null, function* () {
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(C, ...e);
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 u(this, null, function* () {
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: s, reject: n } = M();
256
- return yield i.create(...t).then((...c) => (this.creatingItem = null, i.select({ only: !0 }), s(i), c)).catch((c) => {
257
- n(c), this.group.remove(i);
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
- m(f, "modules", E);
264
- const Ie = (o, r, e) => {
265
- if (r && typeof r == "object" && ("theme" in r || "config" in r)) {
266
- const t = r;
267
- return new f(o, t.theme, t.config);
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(o, r, e);
270
- }, be = (o, r) => new f(o, r == null ? void 0 : r.theme, r == null ? void 0 : r.config);
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
- be as SculptPluginForFive
282
+ we as SculptPluginForFive
275
283
  };