@realsee/dnalogel 3.48.7 → 3.49.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.
@@ -12,7 +12,6 @@ export declare class RotateController<T extends RotateHelperAbstract = RotateHel
12
12
  y?: number;
13
13
  z?: number;
14
14
  }): void;
15
- dispose(): void;
16
15
  protected onApplyOriginObjectRotate(params: {
17
16
  quaternion: THREE.Quaternion;
18
17
  origin: THREE.Vector3;
@@ -13,7 +13,7 @@ export declare class ScaleController<T extends ScaleHelperAbstract = ScaleHelper
13
13
  dragging: (point: {
14
14
  x: number;
15
15
  y: number;
16
- }) => false | void;
16
+ } | TouchEvent) => false | void;
17
17
  setScale(scale: number | {
18
18
  x?: number;
19
19
  y?: number;
@@ -6,12 +6,13 @@ import { Subscribe } from '../../Subscribe';
6
6
  import type { LiteralString } from '../../../typings/utils.type';
7
7
  export type { PointIntersection };
8
8
  export type ActionIfNoModelUnderMouse = LiteralString<'virtualPoint' | 'lastPoint' | 'disable'>;
9
+ type PointerSelectorMode = 'fixed' | 'cursor';
9
10
  interface Config {
10
11
  /**
11
12
  * @description: 选点的两种模式, 'fixed' 为固定选点为屏幕中心点,拖动five画布来更新点,'cursor' 为跟随鼠标移动来更新点, 'auto' 则根据设备类型自动选择
12
13
  * @default: 'auto'
13
14
  */
14
- mode: 'fixed' | 'cursor' | 'auto';
15
+ mode: PointerSelectorMode | 'auto';
15
16
  /**
16
17
  * @description 当鼠标位置没有模型时的行为
17
18
  * ```markdown
@@ -1,7 +1,7 @@
1
1
  import type { Vector3 } from 'three';
2
2
  import * as THREE from 'three';
3
3
  /**
4
- * @description: 根据多边形的顶点数组生成多边形的 BufferGeometry
4
+ * @description 根据多边形的顶点数组生成多边形的 BufferGeometry
5
5
  * @param checkLinesIntersect 检查多边形边线是否相交,需要保证传入的顶点是有序的
6
6
  */
7
7
  export default function generatePolygonGeometry(_points: Vector3[], config?: {
@@ -26,6 +26,7 @@ export declare class PrismMesh extends IObject3D {
26
26
  get color(): THREE.Color;
27
27
  get lineWidth(): number;
28
28
  get lineColor(): THREE.Color;
29
+ paramStyle: Partial<PrismStyle>;
29
30
  private edgePlanes;
30
31
  constructor(params?: Partial<PrismData & PrismStyle>);
31
32
  setStyle(params: Partial<PrismStyle>): void;
@@ -1,27 +1,37 @@
1
- var d = Object.defineProperty;
2
- var a = (s, i, t) => i in s ? d(s, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[i] = t;
3
- var h = (s, i, t) => (a(s, typeof i != "symbol" ? i + "" : i, t), t);
4
- import { IObject3D as g } from "../../shared-utils/three/IObject3D.js";
5
- import { anyPositionToVector3 as P } from "../../shared-utils/positionToVector3.js";
6
- import * as c from "three";
1
+ var b = Object.defineProperty;
2
+ var m = Object.getOwnPropertySymbols;
3
+ var E = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
4
+ var g = (n, o, t) => o in n ? b(n, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[o] = t, P = (n, o) => {
5
+ for (var t in o || (o = {}))
6
+ E.call(o, t) && g(n, t, o[t]);
7
+ if (m)
8
+ for (var t of m(o))
9
+ C.call(o, t) && g(n, t, o[t]);
10
+ return n;
11
+ };
12
+ var h = (n, o, t) => (g(n, typeof o != "symbol" ? o + "" : o, t), t);
13
+ import { IObject3D as c } from "../../shared-utils/three/IObject3D.js";
14
+ import { anyPositionToVector3 as a } from "../../shared-utils/positionToVector3.js";
15
+ import * as p from "three";
7
16
  import "hammerjs";
8
17
  import "three/examples/jsm/renderers/CSS3DRenderer";
9
- import { LineMesh as m } from "./Line.js";
18
+ import { LineMesh as y } from "./Line.js";
10
19
  import "../../shared-utils/three/THREESphere.js";
11
20
  import "animejs";
12
- import { notNil as p } from "../../shared-utils/isNil.js";
21
+ import { notNil as f } from "../../shared-utils/isNil.js";
13
22
  import "../../vendor/@tweenjs/tween/dist/tween.esm.js.js";
14
- import { PolygonMesh as y } from "./Polygon.js";
15
- import { PolygonWithEdgeMesh as f } from "./PolygonWithEdge.js";
16
- import { intersectWithoutLine as u } from "../../shared-utils/three/THREERaycaster.js";
17
- class L extends g {
23
+ import { PolygonMesh as d } from "./Polygon.js";
24
+ import { PolygonWithEdgeMesh as u } from "./PolygonWithEdge.js";
25
+ import { intersectWithoutLine as S } from "../../shared-utils/three/THREERaycaster.js";
26
+ class z extends c {
18
27
  constructor(t) {
19
28
  super();
20
29
  h(this, "name", "PrismMesh");
21
30
  h(this, "heightPoint");
22
- h(this, "bottomPolygon", new f());
23
- h(this, "topPolygon", new f());
24
- h(this, "edgePlanes", new g());
31
+ h(this, "bottomPolygon", new u());
32
+ h(this, "topPolygon", new u());
33
+ h(this, "paramStyle");
34
+ h(this, "edgePlanes", new c());
25
35
  this.topPolygon.name = "TopPolygon", this.bottomPolygon.name = "BottomPolygon", this.edgePlanes.name = "EdgePlanes", this.addIfNotExists(this.bottomPolygon), t && this.setPoints(t), t && this.setStyle(t);
26
36
  }
27
37
  /**
@@ -31,10 +41,10 @@ class L extends g {
31
41
  return this.localCenter;
32
42
  }
33
43
  get localCenter() {
34
- var n, e;
35
- const t = (n = this.topPolygon) == null ? void 0 : n.center, o = (e = this.bottomPolygon) == null ? void 0 : e.center;
36
- if (t && o)
37
- return new c.Vector3().lerpVectors(t, o, 0.5);
44
+ var s, i;
45
+ const t = (s = this.topPolygon) == null ? void 0 : s.center, e = (i = this.bottomPolygon) == null ? void 0 : i.center;
46
+ if (t && e)
47
+ return new p.Vector3().lerpVectors(t, e, 0.5);
38
48
  }
39
49
  get worldCenter() {
40
50
  return this.updateMatrixWorld(), this.localToWorld(this.localCenter);
@@ -49,12 +59,12 @@ class L extends g {
49
59
  return this.bottomPolygon.lineColor;
50
60
  }
51
61
  setStyle(t) {
52
- this.bottomPolygon.setStyle(t), this.topPolygon.setStyle(t), this.edgePlanes.children.forEach((o) => {
53
- (o instanceof m || o instanceof y) && o.setStyle(t);
62
+ this.paramStyle = P(P({}, this.paramStyle), t), this.bottomPolygon.setStyle(this.paramStyle), this.topPolygon.setStyle(this.paramStyle), this.edgePlanes.children.forEach((e) => {
63
+ (e instanceof y || e instanceof d) && e.setStyle(this.paramStyle);
54
64
  });
55
65
  }
56
66
  setPoints(t) {
57
- p(t.points) && this.setBottomPoints(t.points), p(t.heightPoint) && this.setTopHeightPoint(P(t.heightPoint));
67
+ f(t.points) && this.setBottomPoints(t.points), f(t.heightPoint) && this.setTopHeightPoint(a(t.heightPoint));
58
68
  }
59
69
  highlight() {
60
70
  this.bottomPolygon.highlight(), this.topPolygon.highlight(), this.edgePlanes.children.forEach((t) => {
@@ -67,32 +77,32 @@ class L extends g {
67
77
  });
68
78
  }
69
79
  setBottomPoints(t) {
70
- this.bottomPolygon.setPoints(t.map(P)), this.heightPoint && this.setTopHeightPoint(this.heightPoint);
80
+ this.bottomPolygon.setPoints(t.map(a)), this.heightPoint && this.setTopHeightPoint(this.heightPoint);
71
81
  }
72
82
  setTopHeightPoint(t) {
73
83
  this.heightPoint = t, this.addIfNotExists(this.topPolygon);
74
- const o = this.bottomPolygon.projectPoint(t), n = new c.Vector3().subVectors(t, o);
75
- this.up.copy(n.clone().normalize());
76
- const r = this.bottomPolygon.points.map((l) => l.clone().add(n));
84
+ const e = this.bottomPolygon.projectPoint(t), s = new p.Vector3().subVectors(t, e);
85
+ this.up.copy(s.clone().normalize());
86
+ const r = this.bottomPolygon.points.map((l) => l.clone().add(s));
77
87
  this.topPolygon.setPoints(r), this.setEdgePlanes();
78
88
  }
79
- raycast(t, o) {
80
- return this.children.forEach((n) => {
81
- u(n, t, o, !0);
89
+ raycast(t, e) {
90
+ return this.children.forEach((s) => {
91
+ S(s, t, e, !0);
82
92
  }), !1;
83
93
  }
84
94
  setEdgePlanes() {
85
- const t = this.bottomPolygon.points, o = this.topPolygon.points;
86
- this.addIfNotExists(this.edgePlanes), this.edgePlanes.removeChildren(), t.forEach((n, e) => {
87
- if (e === 0)
95
+ const t = this.bottomPolygon.points, e = this.topPolygon.points;
96
+ this.addIfNotExists(this.edgePlanes), this.edgePlanes.removeChildren(), t.forEach((s, i) => {
97
+ if (i === 0)
88
98
  return;
89
- const r = new y({ color: this.color });
90
- r.setPoints([t[e - 1], t[e], o[e], o[e - 1]]);
91
- const l = new m({ lineColor: this.lineColor, lineWidth: this.lineWidth });
92
- l.name = "EdgeLine", l.setPoints([t[e - 1], o[e - 1]]), this.edgePlanes.add(r, l);
99
+ const r = new d({ color: this.color });
100
+ r.setPoints([t[i - 1], t[i], e[i], e[i - 1]]);
101
+ const l = new y({ lineColor: this.lineColor, lineWidth: this.lineWidth });
102
+ l.name = "EdgeLine", l.setPoints([t[i - 1], e[i - 1]]), this.edgePlanes.add(r, l);
93
103
  });
94
104
  }
95
105
  }
96
106
  export {
97
- L as PrismMesh
107
+ z as PrismMesh
98
108
  };
@@ -25,7 +25,7 @@ class f {
25
25
  get pointSelector() {
26
26
  if (!this.inited)
27
27
  throw new Error("Global not inited");
28
- return this._pointSelector ? this._pointSelector : (this._pointSelector = new c(this.five), this._pointSelector);
28
+ return this._pointSelector ? this._pointSelector : (this._pointSelector = new c(this.five, { mode: "cursor" }), this._pointSelector);
29
29
  }
30
30
  get fiveDomEvents() {
31
31
  if (!this.inited)
@@ -17,7 +17,7 @@ let x = class {
17
17
  /**
18
18
  * @realsee/dnalogel 版本号
19
19
  */
20
- i(this, "VERSION", "3.48.7");
20
+ i(this, "VERSION", "3.49.0");
21
21
  i(this, "NAME");
22
22
  i(this, "five");
23
23
  i(this, "workUtil");
@@ -1,25 +1,61 @@
1
- var f = Object.defineProperty;
2
- var v = (c, a, e) => a in c ? f(c, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[a] = e;
3
- var u = (c, a, e) => (v(c, typeof a != "symbol" ? a + "" : a, e), e);
4
- import { BaseController as p } from "../Base/BaseController.js";
1
+ var v = Object.defineProperty;
2
+ var f = (c, a, e) => a in c ? v(c, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[a] = e;
3
+ var r = (c, a, e) => (f(c, typeof a != "symbol" ? a + "" : a, e), e);
4
+ import { BaseController as g } from "../Base/BaseController.js";
5
5
  import * as m from "three";
6
- import { getMouseRaycaster as g } from "../utils/getMouseRaycaster.js";
6
+ import { getMouseRaycaster as p } from "../utils/getMouseRaycaster.js";
7
7
  import { rayOnLine as y } from "../../../Sculpt/utils/three/rayOnLine.js";
8
- class w extends p {
8
+ class w extends g {
9
9
  constructor(...e) {
10
10
  super(...e);
11
- u(this, "name", "MoveController");
12
- u(this, "startInfo");
13
- u(this, "_moveByMouse", {
11
+ r(this, "name", "MoveController");
12
+ r(this, "startInfo");
13
+ r(this, "_moveByMouse", {
14
14
  enabled: !1
15
15
  });
16
- u(this, "mouseInfo");
17
- u(this, "mousedownEventListenerDisposer");
16
+ r(this, "mouseInfo");
17
+ r(this, "mousedownEventListenerDisposer");
18
+ /**
19
+ * @description: 拖动开始,找出拖的Direction
20
+ */
21
+ r(this, "dragStart", (e) => {
22
+ if (this.moveByMouseEnable || this.isDragging)
23
+ return;
24
+ const t = e == null ? void 0 : e.intersect;
25
+ if (!t)
26
+ return this.dragEnd();
27
+ const o = (t == null ? void 0 : t.object).direction;
28
+ if (!o)
29
+ return this.dragEnd();
30
+ const s = new m.Vector3(1, 0, 0).applyQuaternion(this.helperObject3D.quaternion), h = new m.Vector3(0, 1, 0).applyQuaternion(this.helperObject3D.quaternion), u = new m.Vector3(0, 0, 1).applyQuaternion(this.helperObject3D.quaternion), n = (() => {
31
+ switch (o) {
32
+ case "x":
33
+ return s;
34
+ case "y":
35
+ return h;
36
+ case "z":
37
+ return u;
38
+ }
39
+ })(), i = t.point.clone(), d = new m.Line3(
40
+ i.clone().sub(n.normalize()),
41
+ i.clone().add(n.normalize())
42
+ );
43
+ this.startInfo = { startVectorProject: i, line: d }, this.helperObject3D.showDraggingHelper([o]), this.hooks.emit("moveStart"), this.isDragging = !0;
44
+ });
45
+ r(this, "dragging", (e) => {
46
+ if (!this.isDragging || !this.startInfo)
47
+ return;
48
+ const t = "touches" in e ? e.touches[0].clientX : e.x, o = "touches" in e ? e.touches[0].clientY : e.y, s = p(this.camera, { x: t, y: o }, this.container);
49
+ return s ? (this.move(s), !1) : this.dragEnd();
50
+ });
51
+ r(this, "dragEnd", () => {
52
+ this.isDragging && (this.startInfo = void 0, this.isDragging = !1, this.helperObject3D.show(), this.hooks.emit("moveEnd"));
53
+ });
18
54
  const t = this.helperObject3D;
19
55
  this.hoverListener([t.xArrow, t.yArrow, t.zArrow]);
20
- const o = this.dragStart.bind(this), h = this.dragging.bind(this), i = this.dragEnd.bind(this), n = this.show.bind(this), s = this.hide.bind(this);
21
- this.domEvents.addEventListener(this.helperObject3D, "mousedown", o), document.addEventListener("mousemove", h), document.addEventListener("mouseup", i), this.hooks.on("rotateStart", s), this.hooks.on("rotateEnd", n), this.hooks.on("scaleStart", s), this.hooks.on("scaleEnd", n), this.hooks.on("moveByMouseEnable", s), this.hooks.on("moveByMouseDisable", n), this.disposers.push(() => {
22
- this.domEvents.removeEventListener(this.helperObject3D, "mousedown", o), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", i), this.hooks.off("rotateStart", s), this.hooks.off("rotateEnd", n), this.hooks.off("scaleStart", s), this.hooks.off("scaleEnd", n), this.hooks.off("moveByMouseEnable", s), this.hooks.off("moveByMouseDisable", n);
56
+ const o = this.show.bind(this), s = this.hide.bind(this);
57
+ this.domEvents.addEventListener(this.helperObject3D, "mousedown", this.dragStart), document.addEventListener("mousemove", this.dragging), document.addEventListener("mouseup", this.dragEnd), this.domEvents.addEventListener(this.helperObject3D, "touchstart", this.dragStart), document.addEventListener("touchmove", this.dragging), document.addEventListener("touchend", this.dragEnd), this.hooks.on("rotateStart", s), this.hooks.on("rotateEnd", o), this.hooks.on("scaleStart", s), this.hooks.on("scaleEnd", o), this.hooks.on("moveByMouseEnable", s), this.hooks.on("moveByMouseDisable", o), this.disposers.push(() => {
58
+ this.domEvents.removeEventListener(this.helperObject3D, "mousedown", this.dragStart), document.removeEventListener("mousemove", this.dragging), document.removeEventListener("mouseup", this.dragEnd), this.domEvents.removeEventListener(this.helperObject3D, "touchstart", this.dragStart), document.removeEventListener("touchmove", this.dragging), document.removeEventListener("touchend", this.dragEnd), this.hooks.off("rotateStart", s), this.hooks.off("rotateEnd", o), this.hooks.off("scaleStart", s), this.hooks.off("scaleEnd", o), this.hooks.off("moveByMouseEnable", s), this.hooks.off("moveByMouseDisable", o);
23
59
  }), this.moveByMouseEnable && this.moveByMouse();
24
60
  }
25
61
  get moveByMouseEnable() {
@@ -53,14 +89,14 @@ class w extends p {
53
89
  this._moveByMouse = { enabled: !1 }, this.preventTapDefaultEvent = !1, this.hooks.emit("moveByMouseDisable"), (e = this.mousedownEventListenerDisposer) == null || e.call(this);
54
90
  }
55
91
  onIntersectionOnModelUpdate(e) {
56
- var i, n, s;
92
+ var h, u, n;
57
93
  if (!this.moveByMouseEnable)
58
94
  return;
59
95
  const { point: t, face: o } = e;
60
96
  if (!this.hooks.emit("wantToMove", t)) {
61
97
  if (this.originObject3D.position.copy(t), (this._moveByMouse.useFaceNormal === !0 || typeof this._moveByMouse.useFaceNormal == "object" && this._moveByMouse.useFaceNormal.enable !== !1) && o != null && o.normal) {
62
- const r = (() => typeof this._moveByMouse.useFaceNormal == "object" && this._moveByMouse.useFaceNormal.alignmentVector ? this._moveByMouse.useFaceNormal.alignmentVector : { x: 0, y: 1, z: 0 })(), l = new m.Vector3((i = r.x) != null ? i : 0, (n = r.y) != null ? n : 0, (s = r.z) != null ? s : 0), d = (() => typeof this._moveByMouse.useFaceNormal == "object" && this._moveByMouse.useFaceNormal.fixedFaceNormal ? this._moveByMouse.useFaceNormal.fixedFaceNormal(o.normal) : o.normal)();
63
- this.originObject3D.quaternion.setFromUnitVectors(l, d), this.internalHooks.emit("setObjectRotate", this.originObject3D.quaternion.clone());
98
+ const i = (() => typeof this._moveByMouse.useFaceNormal == "object" && this._moveByMouse.useFaceNormal.alignmentVector ? this._moveByMouse.useFaceNormal.alignmentVector : { x: 0, y: 1, z: 0 })(), d = new m.Vector3((h = i.x) != null ? h : 0, (u = i.y) != null ? u : 0, (n = i.z) != null ? n : 0), l = (() => typeof this._moveByMouse.useFaceNormal == "object" && this._moveByMouse.useFaceNormal.fixedFaceNormal ? this._moveByMouse.useFaceNormal.fixedFaceNormal(o.normal) : o.normal)();
99
+ this.originObject3D.quaternion.setFromUnitVectors(d, l), this.internalHooks.emit("setObjectRotate", this.originObject3D.quaternion.clone());
64
100
  }
65
101
  this.internalHooks.emit("setObjectPosition", t), this.hooks.emit("move", t);
66
102
  }
@@ -75,49 +111,13 @@ class w extends p {
75
111
  const { x: t, y: o } = e;
76
112
  this.mouseInfo.x === t && this.mouseInfo.y === o && Date.now() - this.mouseInfo.mouseDownTimestamp < 500 && (this.disableMoveByMouse(), this.mouseInfo = void 0);
77
113
  }
78
- /**
79
- * @description: 拖动开始,找出拖的Direction
80
- */
81
- dragStart(e) {
82
- if (this.moveByMouseEnable || this.isDragging)
83
- return;
84
- const t = e == null ? void 0 : e.intersect;
85
- if (!t)
86
- return this.dragEnd();
87
- const o = (t == null ? void 0 : t.object).direction;
88
- if (!o)
89
- return this.dragEnd();
90
- const h = new m.Vector3(1, 0, 0).applyQuaternion(this.helperObject3D.quaternion), i = new m.Vector3(0, 1, 0).applyQuaternion(this.helperObject3D.quaternion), n = new m.Vector3(0, 0, 1).applyQuaternion(this.helperObject3D.quaternion), s = (() => {
91
- switch (o) {
92
- case "x":
93
- return h;
94
- case "y":
95
- return i;
96
- case "z":
97
- return n;
98
- }
99
- })(), r = t.point.clone(), l = new m.Line3(
100
- r.clone().sub(s.normalize()),
101
- r.clone().add(s.normalize())
102
- );
103
- this.startInfo = { startVectorProject: r, line: l }, this.helperObject3D.showDraggingHelper([o]), this.hooks.emit("moveStart"), this.isDragging = !0;
104
- }
105
- dragging(e) {
106
- if (!this.isDragging || !this.startInfo)
107
- return;
108
- const t = g(this.camera, e, this.container);
109
- return t ? (this.move(t), !1) : this.dragEnd();
110
- }
111
114
  move(e) {
112
115
  if (!this.startInfo)
113
116
  return this.dragEnd();
114
- const { line: t, startVectorProject: o } = this.startInfo, h = this.originObject3D, i = y({ raycaster: e, line: t, clampToLine: !1 }), n = i.clone().sub(o), s = new m.Matrix4();
115
- s.setPosition(n);
116
- const r = h.position.clone().applyMatrix4(s);
117
- this.hooks.emit("wantToMove", r) || (h.applyMatrix4(s), o.copy(i), this.internalHooks.emit("applyObjectPosition", { matrix: s }), this.hooks.emit("move", r));
118
- }
119
- dragEnd() {
120
- this.isDragging && (this.startInfo = void 0, this.isDragging = !1, this.helperObject3D.show(), this.hooks.emit("moveEnd"));
117
+ const { line: t, startVectorProject: o } = this.startInfo, s = this.originObject3D, h = y({ raycaster: e, line: t, clampToLine: !1 }), u = h.clone().sub(o), n = new m.Matrix4();
118
+ n.setPosition(u);
119
+ const i = s.position.clone().applyMatrix4(n);
120
+ this.hooks.emit("wantToMove", i) || (s.applyMatrix4(n), o.copy(h), this.internalHooks.emit("applyObjectPosition", { matrix: n }), this.hooks.emit("move", i));
121
121
  }
122
122
  }
123
123
  export {
@@ -12,7 +12,6 @@ export declare class RotateController<T extends RotateHelperAbstract = RotateHel
12
12
  y?: number;
13
13
  z?: number;
14
14
  }): void;
15
- dispose(): void;
16
15
  protected onApplyOriginObjectRotate(params: {
17
16
  quaternion: THREE.Quaternion;
18
17
  origin: THREE.Vector3;
@@ -1,155 +1,149 @@
1
- var v = Object.defineProperty;
2
- var w = (u, h, n) => h in u ? v(u, h, { enumerable: !0, configurable: !0, writable: !0, value: n }) : u[h] = n;
3
- var d = (u, h, n) => (w(u, typeof h != "symbol" ? h + "" : h, n), n);
4
- import { BaseController as C } from "../Base/BaseController.js";
5
- import * as a from "three";
6
- import { getMouseRaycaster as D } from "../utils/getMouseRaycaster.js";
7
- import { setObjectQuaternion as O } from "../utils/setObjectQuaternion.js";
8
- import { rad2Deg as k } from "../../math/rad2Deg.js";
1
+ var j = Object.defineProperty;
2
+ var w = (g, h, t) => h in g ? j(g, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[h] = t;
3
+ var d = (g, h, t) => (w(g, typeof h != "symbol" ? h + "" : h, t), t);
4
+ import { BaseController as D } from "../Base/BaseController.js";
5
+ import * as c from "three";
6
+ import { getMouseRaycaster as O } from "../utils/getMouseRaycaster.js";
7
+ import { setObjectQuaternion as C } from "../utils/setObjectQuaternion.js";
8
+ import { rad2Deg as L } from "../../math/rad2Deg.js";
9
9
  import { deg2Rad as f } from "../../math/deg2Rad.js";
10
- const y = new a.Quaternion();
11
- class P extends C {
12
- constructor(...n) {
13
- var l, c, m;
14
- super(...n);
10
+ const y = new c.Quaternion();
11
+ class x extends D {
12
+ constructor(...t) {
13
+ var l, a, m;
14
+ super(...t);
15
15
  d(this, "name", "RotateController");
16
16
  d(this, "startInfo");
17
17
  d(this, "removeListener");
18
- const e = this.helperObject3D;
19
- this.hoverListener([(l = e.xCircle) == null ? void 0 : l.circle, (c = e.yCircle) == null ? void 0 : c.circle, (m = e.zCircle) == null ? void 0 : m.circle].filter(Boolean));
20
- const t = this.dragStart.bind(this), i = this.dragging.bind(this), s = this.dragEnd.bind(this), r = this.show.bind(this), o = this.hide.bind(this);
21
- this.domEvents.addEventListener(this.helperObject3D, "mousedown", t), document.addEventListener("mousemove", i), document.addEventListener("mouseup", s), this.hooks.on("moveStart", o), this.hooks.on("moveEnd", r), this.hooks.on("scaleStart", o), this.hooks.on("scaleEnd", r), this.hooks.on("moveByMouseEnable", o), this.hooks.on("moveByMouseDisable", r), this.removeListener = () => {
22
- this.domEvents.removeEventListener(this.helperObject3D, "mousedown", t), document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", s), this.hooks.off("moveStart", o), this.hooks.off("moveEnd", r), this.hooks.off("scaleStart", o), this.hooks.off("scaleEnd", r), this.hooks.off("moveByMouseEnable", o), this.hooks.off("moveByMouseDisable", r);
23
- };
18
+ const n = this.helperObject3D;
19
+ this.hoverListener([(l = n.xCircle) == null ? void 0 : l.circle, (a = n.yCircle) == null ? void 0 : a.circle, (m = n.zCircle) == null ? void 0 : m.circle].filter(Boolean));
20
+ const e = this.dragStart.bind(this), o = this.dragging.bind(this), s = this.dragEnd.bind(this), i = this.show.bind(this), r = this.hide.bind(this);
21
+ this.domEvents.addEventListener(this.helperObject3D, "mousedown", e), document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), this.domEvents.addEventListener(this.helperObject3D, "touchstart", e), document.addEventListener("touchmove", o), document.addEventListener("touchend", s), this.hooks.on("moveStart", r), this.hooks.on("moveEnd", i), this.hooks.on("scaleStart", r), this.hooks.on("scaleEnd", i), this.hooks.on("moveByMouseEnable", r), this.hooks.on("moveByMouseDisable", i), this.disposers.push(() => {
22
+ this.domEvents.removeEventListener(this.helperObject3D, "mousedown", e), document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s), this.domEvents.removeEventListener(this.helperObject3D, "touchstart", e), document.removeEventListener("touchmove", o), document.removeEventListener("touchend", s), this.hooks.off("moveStart", r), this.hooks.off("moveEnd", i), this.hooks.off("scaleStart", r), this.hooks.off("scaleEnd", i), this.hooks.off("moveByMouseEnable", r), this.hooks.off("moveByMouseDisable", i);
23
+ });
24
24
  }
25
25
  get rotateCenter() {
26
26
  return this.helperObject3D.position.clone();
27
27
  }
28
- // public initialHelperQuaternion() {
29
- // this.helperObject3D.applyHelperQuaternion(this.originObject3D.quaternion)
30
- // }
31
- setRotateAngle(n) {
32
- const { x: e = 0, y: t = 0, z: i = 0 } = n, s = new a.Euler(f(e), f(t), f(i)), r = new a.Quaternion().setFromEuler(s);
33
- if (this.hooks.emit("wantToRotate", r))
28
+ setRotateAngle(t) {
29
+ const { x: n = 0, y: e = 0, z: o = 0 } = t, s = new c.Euler(f(n), f(e), f(o)), i = new c.Quaternion().setFromEuler(s);
30
+ if (this.hooks.emit("wantToRotate", i))
34
31
  return;
35
- const { originObject3D: l, rotateCenter: c } = this;
36
- O(l, r, c), this.internalHooks.emit("setObjectRotate", r, c), this.hooks.emit("rotate", r), this.render();
32
+ const { originObject3D: l, rotateCenter: a } = this;
33
+ C(l, i, a), this.internalHooks.emit("setObjectRotate", i, a), this.hooks.emit("rotate", i), this.render();
37
34
  }
38
- dispose() {
39
- this.removeListener(), super.dispose();
35
+ onApplyOriginObjectRotate(t) {
36
+ this.isDragging || super.onApplyOriginObjectRotate(t);
40
37
  }
41
- onApplyOriginObjectRotate(n) {
42
- this.isDragging || super.onApplyOriginObjectRotate(n);
43
- }
44
- onApplyOriginObjectScale(n) {
38
+ onApplyOriginObjectScale(t) {
45
39
  }
46
40
  /**
47
41
  * @description: 拖动开始,找出拖的Direction
48
42
  */
49
- dragStart(n) {
43
+ dragStart(t) {
50
44
  if (this.isDragging)
51
45
  return;
52
- const e = n == null ? void 0 : n.intersect;
53
- if (!e)
46
+ const n = t == null ? void 0 : t.intersect;
47
+ if (!n)
54
48
  return this.dragEnd();
55
- const t = (e == null ? void 0 : e.object).direction;
56
- if (!t)
49
+ const e = (n == null ? void 0 : n.object).direction;
50
+ if (!e)
57
51
  return this.dragEnd();
58
- const i = e.point, s = this.getAngleHelper(t);
52
+ const o = n.point, s = this.getAngleHelper(e);
59
53
  this.setTipsAngle(0);
60
- const r = i.clone();
61
- r.y += 0.2, this.setTipsPosition(r);
62
- const o = this.helperObject3D.quaternion.clone(), l = (() => {
63
- if (t === "x")
64
- return new a.Vector3(1, 0, 0).applyQuaternion(o);
65
- if (t === "y")
66
- return new a.Vector3(0, 1, 0).applyQuaternion(o);
67
- if (t === "z")
68
- return new a.Vector3(0, 0, 1).applyQuaternion(o);
69
- })(), c = new a.Plane().setFromNormalAndCoplanarPoint(l, i), p = c.projectPoint(i.clone(), new a.Vector3()).clone().sub(this.rotateCenter), g = p.angleTo(s.baseAxes.clone().applyQuaternion(o));
70
- this.setAngleHelperStart(t, g), this.setAngleHelperLength(t, 0), this.startInfo = { direction: t, startVector: p, plane: c, angleHelper: s, angle: 0, helperQuaternion: o.clone() }, y.copy(o), this.helperObject3D.showDraggingHelper([t]), this.hooks.emit("rotateStart"), this.isDragging = !0;
54
+ const i = o.clone();
55
+ i.y += 0.2, this.setTipsPosition(i);
56
+ const r = this.helperObject3D.quaternion.clone(), l = (() => {
57
+ if (e === "x")
58
+ return new c.Vector3(1, 0, 0).applyQuaternion(r);
59
+ if (e === "y")
60
+ return new c.Vector3(0, 1, 0).applyQuaternion(r);
61
+ if (e === "z")
62
+ return new c.Vector3(0, 0, 1).applyQuaternion(r);
63
+ })(), a = new c.Plane().setFromNormalAndCoplanarPoint(l, o), p = a.projectPoint(o.clone(), new c.Vector3()).clone().sub(this.rotateCenter), u = p.angleTo(s.baseAxes.clone().applyQuaternion(r));
64
+ this.setAngleHelperStart(e, u), this.setAngleHelperLength(e, 0), this.startInfo = { direction: e, startVector: p, plane: a, angleHelper: s, angle: 0, helperQuaternion: r.clone() }, y.copy(r), this.helperObject3D.showDraggingHelper([e]), this.hooks.emit("rotateStart"), this.isDragging = !0;
71
65
  }
72
- dragging(n) {
66
+ dragging(t) {
73
67
  if (!this.isDragging)
74
68
  return;
75
- const e = D(this.camera, n, this.container);
76
- return e ? (this.rotate(e), !1) : this.dragEnd();
69
+ const n = "touches" in t ? t.touches[0].clientX : t.x, e = "touches" in t ? t.touches[0].clientY : t.y, o = O(this.camera, { x: n, y: e }, this.container);
70
+ return o ? (this.rotate(o), !1) : this.dragEnd();
77
71
  }
78
- rotate(n) {
72
+ rotate(t) {
79
73
  if (!this.startInfo)
80
74
  return this.dragEnd();
81
- const { startVector: e, plane: t, angleHelper: i, direction: s, helperQuaternion: r } = this.startInfo, { originObject3D: o } = this, l = n.ray.intersectPlane(t, new a.Vector3());
75
+ const { startVector: n, plane: e, angleHelper: o, direction: s, helperQuaternion: i } = this.startInfo, { originObject3D: r } = this, l = t.ray.intersectPlane(e, new c.Vector3());
82
76
  if (!l)
83
77
  return;
84
- const c = this.rotateCenter.clone(), p = t.projectPoint(l.clone(), new a.Vector3()).clone().sub(c);
85
- if (e.angleTo(p) === 0)
78
+ const a = this.rotateCenter.clone(), p = e.projectPoint(l.clone(), new c.Vector3()).clone().sub(a);
79
+ if (n.angleTo(p) === 0)
86
80
  return;
87
- const g = new a.Quaternion().setFromUnitVectors(e.clone().normalize(), p.clone().normalize()), b = o.quaternion.clone().premultiply(g);
88
- if (this.hooks.emit("wantToRotate", b))
81
+ const u = new c.Quaternion().setFromUnitVectors(n.clone().normalize(), p.clone().normalize()), v = r.quaternion.clone().premultiply(u);
82
+ if (this.hooks.emit("wantToRotate", v))
89
83
  return;
90
- const E = new a.Euler().setFromQuaternion(
91
- new a.Quaternion().setFromUnitVectors(
92
- e.clone().normalize().applyQuaternion(r.clone().inverse()),
93
- p.clone().normalize().applyQuaternion(r.clone().inverse())
84
+ const E = new c.Euler().setFromQuaternion(
85
+ new c.Quaternion().setFromUnitVectors(
86
+ n.clone().normalize().applyQuaternion(i.clone().inverse()),
87
+ p.clone().normalize().applyQuaternion(i.clone().inverse())
94
88
  ),
95
89
  `${s.toUpperCase()}${"XZY".replace(s.toUpperCase(), "")}`
96
- )[s] * i.angleDirection;
97
- if (this.startInfo.angle += E, this.setAngleHelperLength(s, this.startInfo.angle), this.setTipsAngle(k(this.startInfo.angle)), c) {
98
- const j = new a.Vector3().subVectors(o.position, c).applyQuaternion(g).add(c);
99
- o.position.copy(j);
90
+ )[s] * o.angleDirection;
91
+ if (this.startInfo.angle += E, this.setAngleHelperLength(s, this.startInfo.angle), this.setTipsAngle(L(this.startInfo.angle)), a) {
92
+ const b = new c.Vector3().subVectors(r.position, a).applyQuaternion(u).add(a);
93
+ r.position.copy(b);
100
94
  }
101
- o.applyQuaternion(g), y.premultiply(g), this.internalHooks.emit("applyObjectRotate", { quaternion: g, origin: c }), this.hooks.emit("rotate", o.quaternion), this.startInfo.startVector = p;
95
+ r.applyQuaternion(u), y.premultiply(u), this.internalHooks.emit("applyObjectRotate", { quaternion: u, origin: a }), this.hooks.emit("rotate", r.quaternion), this.startInfo.startVector = p;
102
96
  }
103
97
  dragEnd() {
104
98
  this.isDragging && (this.internalHooks.emit("setObjectRotate", y, this.rotateCenter), this.startInfo = void 0, this.isDragging = !1, this.helperObject3D.show(), this.hooks.emit("rotateEnd"));
105
99
  }
106
- getAngleHelper(n) {
107
- var e, t, i;
108
- switch (n) {
100
+ getAngleHelper(t) {
101
+ var n, e, o;
102
+ switch (t) {
109
103
  case "x":
110
- return (e = this.helperObject3D.xCircle) == null ? void 0 : e.angleSector;
104
+ return (n = this.helperObject3D.xCircle) == null ? void 0 : n.angleSector;
111
105
  case "y":
112
- return (t = this.helperObject3D.yCircle) == null ? void 0 : t.angleSector;
106
+ return (e = this.helperObject3D.yCircle) == null ? void 0 : e.angleSector;
113
107
  case "z":
114
- return (i = this.helperObject3D.zCircle) == null ? void 0 : i.angleSector;
108
+ return (o = this.helperObject3D.zCircle) == null ? void 0 : o.angleSector;
115
109
  }
116
110
  }
117
- setAngleHelperStart(n, e) {
118
- const t = this.getAngleHelper(n);
119
- if (!t) {
111
+ setAngleHelperStart(t, n) {
112
+ const e = this.getAngleHelper(t);
113
+ if (!e) {
120
114
  console.warn("angleHelper is undefined");
121
115
  return;
122
116
  }
123
- if (t instanceof a.Mesh && t.geometry instanceof a.CircleGeometry) {
124
- const { radius: i, segments: s, thetaLength: r } = t.geometry.parameters;
125
- t.geometry = new a.CircleGeometry(i, s, e, r);
117
+ if (e instanceof c.Mesh && e.geometry instanceof c.CircleGeometry) {
118
+ const { radius: o, segments: s, thetaLength: i } = e.geometry.parameters;
119
+ e.geometry = new c.CircleGeometry(o, s, n, i);
126
120
  } else
127
121
  console.warn("only support THREE.CircleGeometry");
128
122
  }
129
- setAngleHelperLength(n, e) {
130
- const i = e >= 0 ? Math.max(e, 1e-3) : Math.min(e, -1e-3), s = this.getAngleHelper(n);
131
- if (s instanceof a.Mesh && s.geometry instanceof a.CircleGeometry) {
132
- const { radius: r, thetaStart: o } = s.geometry.parameters, l = Math.ceil(Math.abs(i) * (40 / (2 * Math.PI)));
133
- s.geometry = new a.CircleGeometry(r, l, o, i);
123
+ setAngleHelperLength(t, n) {
124
+ const o = n >= 0 ? Math.max(n, 1e-3) : Math.min(n, -1e-3), s = this.getAngleHelper(t);
125
+ if (s instanceof c.Mesh && s.geometry instanceof c.CircleGeometry) {
126
+ const { radius: i, thetaStart: r } = s.geometry.parameters, l = Math.ceil(Math.abs(o) * (40 / (2 * Math.PI)));
127
+ s.geometry = new c.CircleGeometry(i, l, r, o);
134
128
  } else
135
129
  console.warn("only support THREE.CircleGeometry");
136
130
  }
137
- setTipsAngle(n) {
138
- var t;
139
- const e = (t = this.helperObject3D.angleTips) == null ? void 0 : t.element;
140
- e && (e.innerText = `${n.toFixed(0)}°`);
131
+ setTipsAngle(t) {
132
+ var e;
133
+ const n = (e = this.helperObject3D.angleTips) == null ? void 0 : e.element;
134
+ n && (n.innerText = `${t.toFixed(0)}°`);
141
135
  }
142
- setTipsPosition(n) {
143
- const e = this.helperObject3D.angleTips;
144
- if (!e)
136
+ setTipsPosition(t) {
137
+ const n = this.helperObject3D.angleTips;
138
+ if (!n)
145
139
  return;
146
- const t = n.project(this.camera), { x: i, y: s, z: r } = t;
147
- if (r > 1)
140
+ const e = t.project(this.camera), { x: o, y: s, z: i } = e;
141
+ if (i > 1)
148
142
  return;
149
- const o = (i + 1) / 2 * 100 + "%", l = (-s + 1) / 2 * 100 + "%";
150
- e.setLeftTop(o, l);
143
+ const r = (o + 1) / 2 * 100 + "%", l = (-s + 1) / 2 * 100 + "%";
144
+ n.setLeftTop(r, l);
151
145
  }
152
146
  }
153
147
  export {
154
- P as RotateController
148
+ x as RotateController
155
149
  };
@@ -13,7 +13,7 @@ export declare class ScaleController<T extends ScaleHelperAbstract = ScaleHelper
13
13
  dragging: (point: {
14
14
  x: number;
15
15
  y: number;
16
- }) => false | void;
16
+ } | TouchEvent) => false | void;
17
17
  setScale(scale: number | {
18
18
  x?: number;
19
19
  y?: number;