@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.
- package/CHANGELOG.md +6 -2
- package/dist/Sculpt/Meshes/Prism.d.ts +1 -0
- package/dist/index.cjs.js +30 -30
- package/dist/index.js +58 -62
- package/dist/index.umd.js +30 -30
- package/dist/shared-utils/Object3DHelper/Controller/RotateController.d.ts +0 -1
- package/dist/shared-utils/Object3DHelper/Controller/ScaleController.d.ts +1 -1
- package/dist/shared-utils/three/PointSelector/index.d.ts +2 -1
- package/dist/shared-utils/three/generatePolygonGeometry.d.ts +1 -1
- package/libs/Sculpt/Meshes/Prism.d.ts +1 -0
- package/libs/Sculpt/Meshes/Prism.js +47 -37
- package/libs/Sculpt/utils/Modules/Global.js +1 -1
- package/libs/base/BasePlugin.js +1 -1
- package/libs/shared-utils/Object3DHelper/Controller/MoveController.js +57 -57
- package/libs/shared-utils/Object3DHelper/Controller/RotateController.d.ts +0 -1
- package/libs/shared-utils/Object3DHelper/Controller/RotateController.js +91 -97
- package/libs/shared-utils/Object3DHelper/Controller/ScaleController.d.ts +1 -1
- package/libs/shared-utils/Object3DHelper/Controller/ScaleController.js +34 -31
- package/libs/shared-utils/logger.js +1 -1
- package/libs/shared-utils/three/PointSelector/index.d.ts +2 -1
- package/libs/shared-utils/three/generatePolygonGeometry.d.ts +1 -1
- package/libs/shared-utils/three/generatePolygonGeometry.js +8 -10
- package/package.json +1 -1
|
@@ -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:
|
|
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
|
|
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
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
18
|
+
import { LineMesh as y } from "./Line.js";
|
|
10
19
|
import "../../shared-utils/three/THREESphere.js";
|
|
11
20
|
import "animejs";
|
|
12
|
-
import { notNil as
|
|
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
|
|
15
|
-
import { PolygonWithEdgeMesh as
|
|
16
|
-
import { intersectWithoutLine as
|
|
17
|
-
class
|
|
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
|
|
23
|
-
h(this, "topPolygon", new
|
|
24
|
-
h(this, "
|
|
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
|
|
35
|
-
const t = (
|
|
36
|
-
if (t &&
|
|
37
|
-
return new
|
|
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(
|
|
53
|
-
(
|
|
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
|
-
|
|
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(
|
|
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
|
|
75
|
-
this.up.copy(
|
|
76
|
-
const r = this.bottomPolygon.points.map((l) => l.clone().add(
|
|
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,
|
|
80
|
-
return this.children.forEach((
|
|
81
|
-
|
|
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,
|
|
86
|
-
this.addIfNotExists(this.edgePlanes), this.edgePlanes.removeChildren(), t.forEach((
|
|
87
|
-
if (
|
|
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
|
|
90
|
-
r.setPoints([t[
|
|
91
|
-
const l = new
|
|
92
|
-
l.name = "EdgeLine", l.setPoints([t[
|
|
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
|
-
|
|
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)
|
package/libs/base/BasePlugin.js
CHANGED
|
@@ -1,25 +1,61 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BaseController as
|
|
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
|
|
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
|
|
8
|
+
class w extends g {
|
|
9
9
|
constructor(...e) {
|
|
10
10
|
super(...e);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
r(this, "name", "MoveController");
|
|
12
|
+
r(this, "startInfo");
|
|
13
|
+
r(this, "_moveByMouse", {
|
|
14
14
|
enabled: !1
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
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.
|
|
21
|
-
this.domEvents.addEventListener(this.helperObject3D, "mousedown",
|
|
22
|
-
this.domEvents.removeEventListener(this.helperObject3D, "mousedown",
|
|
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
|
|
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
|
|
63
|
-
this.originObject3D.quaternion.setFromUnitVectors(
|
|
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,
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
this.hooks.emit("wantToMove",
|
|
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 {
|
|
@@ -1,155 +1,149 @@
|
|
|
1
|
-
var
|
|
2
|
-
var w = (
|
|
3
|
-
var d = (
|
|
4
|
-
import { BaseController as
|
|
5
|
-
import * as
|
|
6
|
-
import { getMouseRaycaster as
|
|
7
|
-
import { setObjectQuaternion as
|
|
8
|
-
import { rad2Deg as
|
|
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
|
|
11
|
-
class
|
|
12
|
-
constructor(...
|
|
13
|
-
var l,
|
|
14
|
-
super(...
|
|
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
|
|
19
|
-
this.hoverListener([(l =
|
|
20
|
-
const
|
|
21
|
-
this.domEvents.addEventListener(this.helperObject3D, "mousedown",
|
|
22
|
-
this.domEvents.removeEventListener(this.helperObject3D, "mousedown",
|
|
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
|
-
|
|
29
|
-
|
|
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:
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
this.
|
|
35
|
+
onApplyOriginObjectRotate(t) {
|
|
36
|
+
this.isDragging || super.onApplyOriginObjectRotate(t);
|
|
40
37
|
}
|
|
41
|
-
|
|
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(
|
|
43
|
+
dragStart(t) {
|
|
50
44
|
if (this.isDragging)
|
|
51
45
|
return;
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
46
|
+
const n = t == null ? void 0 : t.intersect;
|
|
47
|
+
if (!n)
|
|
54
48
|
return this.dragEnd();
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
49
|
+
const e = (n == null ? void 0 : n.object).direction;
|
|
50
|
+
if (!e)
|
|
57
51
|
return this.dragEnd();
|
|
58
|
-
const
|
|
52
|
+
const o = n.point, s = this.getAngleHelper(e);
|
|
59
53
|
this.setTipsAngle(0);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
return new
|
|
65
|
-
if (
|
|
66
|
-
return new
|
|
67
|
-
if (
|
|
68
|
-
return new
|
|
69
|
-
})(),
|
|
70
|
-
this.setAngleHelperStart(
|
|
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(
|
|
66
|
+
dragging(t) {
|
|
73
67
|
if (!this.isDragging)
|
|
74
68
|
return;
|
|
75
|
-
const e =
|
|
76
|
-
return
|
|
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(
|
|
72
|
+
rotate(t) {
|
|
79
73
|
if (!this.startInfo)
|
|
80
74
|
return this.dragEnd();
|
|
81
|
-
const { startVector:
|
|
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
|
|
85
|
-
if (
|
|
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
|
|
88
|
-
if (this.hooks.emit("wantToRotate",
|
|
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
|
|
91
|
-
new
|
|
92
|
-
|
|
93
|
-
p.clone().normalize().applyQuaternion(
|
|
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] *
|
|
97
|
-
if (this.startInfo.angle += E, this.setAngleHelperLength(s, this.startInfo.angle), this.setTipsAngle(
|
|
98
|
-
const
|
|
99
|
-
|
|
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
|
-
|
|
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(
|
|
107
|
-
var
|
|
108
|
-
switch (
|
|
100
|
+
getAngleHelper(t) {
|
|
101
|
+
var n, e, o;
|
|
102
|
+
switch (t) {
|
|
109
103
|
case "x":
|
|
110
|
-
return (
|
|
104
|
+
return (n = this.helperObject3D.xCircle) == null ? void 0 : n.angleSector;
|
|
111
105
|
case "y":
|
|
112
|
-
return (
|
|
106
|
+
return (e = this.helperObject3D.yCircle) == null ? void 0 : e.angleSector;
|
|
113
107
|
case "z":
|
|
114
|
-
return (
|
|
108
|
+
return (o = this.helperObject3D.zCircle) == null ? void 0 : o.angleSector;
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
|
-
setAngleHelperStart(
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
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 (
|
|
124
|
-
const { radius:
|
|
125
|
-
|
|
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(
|
|
130
|
-
const
|
|
131
|
-
if (s instanceof
|
|
132
|
-
const { radius:
|
|
133
|
-
s.geometry = new
|
|
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(
|
|
138
|
-
var
|
|
139
|
-
const
|
|
140
|
-
|
|
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(
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
136
|
+
setTipsPosition(t) {
|
|
137
|
+
const n = this.helperObject3D.angleTips;
|
|
138
|
+
if (!n)
|
|
145
139
|
return;
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
140
|
+
const e = t.project(this.camera), { x: o, y: s, z: i } = e;
|
|
141
|
+
if (i > 1)
|
|
148
142
|
return;
|
|
149
|
-
const
|
|
150
|
-
|
|
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
|
-
|
|
148
|
+
x as RotateController
|
|
155
149
|
};
|