@shopware-ag/dive 2.2.24 → 2.2.26
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/build/chunks/{AssetCache-CT7yQAu0.mjs → AssetCache-Dl6HGxhQ.mjs} +1 -1
- package/build/chunks/{AssetCache-BvteEWMc.cjs → AssetCache-whxF6SOV.cjs} +1 -1
- package/build/chunks/{AssetLoader-C8es4ZuG.cjs → AssetLoader-BrWrEPlt.cjs} +1 -1
- package/build/chunks/{AssetLoader-CIsnnlqu.mjs → AssetLoader-gxRul277.mjs} +2 -2
- package/build/chunks/{FileTypes-D_r2gn3i.mjs → FileTypes-3cvLT4Y_.mjs} +1 -1
- package/build/chunks/{FileTypes-CjUNNEmP.cjs → FileTypes-B5p1lVF7.cjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +1 -1
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +1 -1
- package/build/plugins/state/index.cjs +8 -8
- package/build/plugins/state/index.mjs +978 -979
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.d.ts +9 -1
- package/build/plugins/toolbox/index.mjs +1166 -88
- package/build/plugins/toolbox/src/BaseTool.d.ts +13 -0
- package/build/plugins/toolbox/src/PointerContext.d.ts +46 -0
- package/build/plugins/toolbox/src/SelectionState.d.ts +43 -0
- package/build/plugins/toolbox/src/Tool.d.ts +44 -0
- package/build/plugins/toolbox/src/Toolbox.d.ts +73 -17
- package/build/plugins/toolbox/src/drag/DragTool.d.ts +53 -0
- package/build/plugins/toolbox/src/drag/DraggableEvent.d.ts +16 -0
- package/build/plugins/toolbox/src/hover/HoverTool.d.ts +24 -0
- package/build/plugins/toolbox/src/select/SelectTool.d.ts +32 -16
- package/build/plugins/toolbox/src/transform/TransformTool.d.ts +48 -10
- package/build/plugins/toolbox/types/ToolType.d.ts +14 -1
- package/package.json +1 -1
- package/build/chunks/SelectTool-C-G8iiqX.cjs +0 -1
- package/build/chunks/SelectTool-CP-RUr3R.mjs +0 -718
|
@@ -1,105 +1,1183 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this
|
|
13
|
-
}
|
|
14
|
-
get selectTool() {
|
|
15
|
-
return this._selectTool || (this._selectTool = new l(
|
|
16
|
-
this._scene,
|
|
17
|
-
this._controller
|
|
18
|
-
)), this._selectTool;
|
|
1
|
+
var Xt = Object.defineProperty;
|
|
2
|
+
var Yt = (h, t, e) => t in h ? Xt(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
|
|
3
|
+
var o = (h, t, e) => Yt(h, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Object3D as lt, Vector3 as l, Quaternion as E, Raycaster as ot, MeshBasicMaterial as Dt, LineBasicMaterial as jt, CylinderGeometry as w, BoxGeometry as f, BufferGeometry as dt, Float32BufferAttribute as pt, Mesh as r, OctahedronGeometry as tt, Line as A, TorusGeometry as Q, SphereGeometry as kt, Euler as Qt, Matrix4 as Et, PlaneGeometry as Ot, DoubleSide as Rt, Vector2 as F, Layers as _t } from "three";
|
|
5
|
+
import "../../chunks/FileTypes-3cvLT4Y_.mjs";
|
|
6
|
+
import { P as G, U as W } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
|
|
7
|
+
import { f as B, i as O } from "../../chunks/findInterface-DbJ5qzbc.mjs";
|
|
8
|
+
import { A as ut, a as gt, b as ft } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
9
|
+
class Zt {
|
|
10
|
+
constructor() {
|
|
11
|
+
o(this, "_selected", null);
|
|
12
|
+
o(this, "_listeners", /* @__PURE__ */ new Set());
|
|
19
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Currently selected object, or null if nothing is selected.
|
|
16
|
+
*/
|
|
17
|
+
get selected() {
|
|
18
|
+
return this._selected;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Select an object. Deselects any previously selected object.
|
|
22
|
+
* Calls onSelect on the new object and onDeselect on the previous.
|
|
23
|
+
*/
|
|
24
|
+
select(t) {
|
|
25
|
+
var e, i, n;
|
|
26
|
+
this._selected !== t && (this._selected && ((i = (e = this._selected).onDeselect) == null || i.call(e)), this._selected = t, (n = t.onSelect) == null || n.call(t), this.notifyListeners());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Deselect the currently selected object.
|
|
30
|
+
* Calls onDeselect on the object.
|
|
31
|
+
*/
|
|
32
|
+
deselect() {
|
|
33
|
+
var t, e;
|
|
34
|
+
this._selected && ((e = (t = this._selected).onDeselect) == null || e.call(t), this._selected = null, this.notifyListeners());
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Register a callback to be notified when selection changes.
|
|
38
|
+
*/
|
|
39
|
+
onChange(t) {
|
|
40
|
+
this._listeners.add(t);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Unregister a previously registered callback.
|
|
44
|
+
*/
|
|
45
|
+
offChange(t) {
|
|
46
|
+
this._listeners.delete(t);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Dispose of the selection state and clear all listeners.
|
|
50
|
+
*/
|
|
20
51
|
dispose() {
|
|
21
|
-
this.
|
|
52
|
+
this._selected = null, this._listeners.clear();
|
|
53
|
+
}
|
|
54
|
+
notifyListeners() {
|
|
55
|
+
for (const t of this._listeners)
|
|
56
|
+
t(this._selected);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class Gt {
|
|
60
|
+
constructor() {
|
|
61
|
+
o(this, "name", "hover");
|
|
62
|
+
o(this, "priority", 20);
|
|
63
|
+
o(this, "_hovered", null);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Currently hovered object, or null if nothing is hovered.
|
|
67
|
+
*/
|
|
68
|
+
get hovered() {
|
|
69
|
+
return this._hovered;
|
|
70
|
+
}
|
|
71
|
+
onActivate() {
|
|
72
|
+
this._hovered = null;
|
|
73
|
+
}
|
|
74
|
+
onDeactivate() {
|
|
75
|
+
var t, e;
|
|
76
|
+
this._hovered && ((e = (t = this._hovered).onPointerLeave) == null || e.call(t), this._hovered = null);
|
|
77
|
+
}
|
|
78
|
+
onPointerMove(t) {
|
|
79
|
+
var n, a, s, c, u, P, M;
|
|
80
|
+
const e = t.modelIntersects[0], i = B(
|
|
81
|
+
e == null ? void 0 : e.object,
|
|
82
|
+
"isHoverable"
|
|
83
|
+
);
|
|
84
|
+
if (e && i) {
|
|
85
|
+
if (!this._hovered) {
|
|
86
|
+
(n = i.onPointerEnter) == null || n.call(i, e), this._hovered = i;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (this._hovered.uuid !== i.uuid) {
|
|
90
|
+
(s = (a = this._hovered).onPointerLeave) == null || s.call(a), (c = i.onPointerEnter) == null || c.call(i, e), this._hovered = i;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
(u = i.onPointerOver) == null || u.call(i, e);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this._hovered && ((M = (P = this._hovered).onPointerLeave) == null || M.call(P), this._hovered = null);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const he = (h) => h.name === "select";
|
|
100
|
+
class Wt {
|
|
101
|
+
constructor(t) {
|
|
102
|
+
o(this, "name", "select");
|
|
103
|
+
o(this, "priority", 30);
|
|
104
|
+
o(this, "_selectionState");
|
|
105
|
+
this._selectionState = t;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the currently selected object.
|
|
109
|
+
*/
|
|
110
|
+
get selected() {
|
|
111
|
+
return this._selectionState.selected;
|
|
112
|
+
}
|
|
113
|
+
onActivate() {
|
|
114
|
+
}
|
|
115
|
+
onDeactivate() {
|
|
116
|
+
}
|
|
117
|
+
onClick(t) {
|
|
118
|
+
const e = t.modelIntersects[0], i = B(
|
|
119
|
+
e == null ? void 0 : e.object,
|
|
120
|
+
"isSelectable"
|
|
121
|
+
);
|
|
122
|
+
if (!e || !i) {
|
|
123
|
+
this._selectionState.deselect();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const n = this._selectionState.selected;
|
|
127
|
+
n && n.uuid === i.uuid || this._selectionState.select(i);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Programmatically select an object.
|
|
131
|
+
*/
|
|
132
|
+
select(t) {
|
|
133
|
+
this._selectionState.select(t);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Programmatically deselect the current selection.
|
|
137
|
+
*/
|
|
138
|
+
deselect() {
|
|
139
|
+
this._selectionState.deselect();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const L = new ot(), _ = new l(), C = new l(), p = new E(), mt = {
|
|
143
|
+
X: new l(1, 0, 0),
|
|
144
|
+
Y: new l(0, 1, 0),
|
|
145
|
+
Z: new l(0, 0, 1)
|
|
146
|
+
}, rt = { type: "change" }, wt = { type: "mouseDown" }, yt = { type: "mouseUp", mode: null }, bt = { type: "objectChange" };
|
|
147
|
+
class qt extends lt {
|
|
148
|
+
constructor(t, e) {
|
|
149
|
+
super(), e === void 0 && (console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'), e = document), this.isTransformControls = !0, this.visible = !1, this.domElement = e, this.domElement.style.touchAction = "none";
|
|
150
|
+
const i = new Kt();
|
|
151
|
+
this._gizmo = i, this.add(i);
|
|
152
|
+
const n = new $t();
|
|
153
|
+
this._plane = n, this.add(n);
|
|
154
|
+
const a = this;
|
|
155
|
+
function s(g, b) {
|
|
156
|
+
let X = b;
|
|
157
|
+
Object.defineProperty(a, g, {
|
|
158
|
+
get: function() {
|
|
159
|
+
return X !== void 0 ? X : b;
|
|
160
|
+
},
|
|
161
|
+
set: function(z) {
|
|
162
|
+
X !== z && (X = z, n[g] = z, i[g] = z, a.dispatchEvent({ type: g + "-changed", value: z }), a.dispatchEvent(rt));
|
|
163
|
+
}
|
|
164
|
+
}), a[g] = b, n[g] = b, i[g] = b;
|
|
165
|
+
}
|
|
166
|
+
s("camera", t), s("object", void 0), s("enabled", !0), s("axis", null), s("mode", "translate"), s("translationSnap", null), s("rotationSnap", null), s("scaleSnap", null), s("space", "world"), s("size", 1), s("dragging", !1), s("showX", !0), s("showY", !0), s("showZ", !0);
|
|
167
|
+
const c = new l(), u = new l(), P = new E(), M = new E(), j = new l(), k = new E(), ht = new l(), V = new l(), x = new l(), I = 0, S = new l();
|
|
168
|
+
s("worldPosition", c), s("worldPositionStart", u), s("worldQuaternion", P), s("worldQuaternionStart", M), s("cameraPosition", j), s("cameraQuaternion", k), s("pointStart", ht), s("pointEnd", V), s("rotationAxis", x), s("rotationAngle", I), s("eye", S), this._offset = new l(), this._startNorm = new l(), this._endNorm = new l(), this._cameraScale = new l(), this._parentPosition = new l(), this._parentQuaternion = new E(), this._parentQuaternionInv = new E(), this._parentScale = new l(), this._worldScaleStart = new l(), this._worldQuaternionInv = new E(), this._worldScale = new l(), this._positionStart = new l(), this._quaternionStart = new E(), this._scaleStart = new l(), this._getPointer = Ut.bind(this), this._onPointerDown = Bt.bind(this), this._onPointerHover = Ft.bind(this), this._onPointerMove = Vt.bind(this), this._onPointerUp = Nt.bind(this), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp);
|
|
169
|
+
}
|
|
170
|
+
// updateMatrixWorld updates key transformation variables
|
|
171
|
+
updateMatrixWorld(t) {
|
|
172
|
+
this.object !== void 0 && (this.object.updateMatrixWorld(), this.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : this.object.parent.matrixWorld.decompose(this._parentPosition, this._parentQuaternion, this._parentScale), this.object.matrixWorld.decompose(this.worldPosition, this.worldQuaternion, this._worldScale), this._parentQuaternionInv.copy(this._parentQuaternion).invert(), this._worldQuaternionInv.copy(this.worldQuaternion).invert()), this.camera.updateMatrixWorld(), this.camera.matrixWorld.decompose(this.cameraPosition, this.cameraQuaternion, this._cameraScale), this.camera.isOrthographicCamera ? this.camera.getWorldDirection(this.eye).negate() : this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(), super.updateMatrixWorld(t);
|
|
173
|
+
}
|
|
174
|
+
pointerHover(t) {
|
|
175
|
+
if (this.object === void 0 || this.dragging === !0) return;
|
|
176
|
+
t !== null && L.setFromCamera(t, this.camera);
|
|
177
|
+
const e = at(this._gizmo.picker[this.mode], L);
|
|
178
|
+
e ? this.axis = e.object.name : this.axis = null;
|
|
179
|
+
}
|
|
180
|
+
pointerDown(t) {
|
|
181
|
+
if (!(this.object === void 0 || this.dragging === !0 || t != null && t.button !== 0) && this.axis !== null) {
|
|
182
|
+
t !== null && L.setFromCamera(t, this.camera);
|
|
183
|
+
const e = at(this._plane, L, !0);
|
|
184
|
+
e && (this.object.updateMatrixWorld(), this.object.parent.updateMatrixWorld(), this._positionStart.copy(this.object.position), this._quaternionStart.copy(this.object.quaternion), this._scaleStart.copy(this.object.scale), this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart), this.pointStart.copy(e.point).sub(this.worldPositionStart)), this.dragging = !0, wt.mode = this.mode, this.dispatchEvent(wt);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
pointerMove(t) {
|
|
188
|
+
const e = this.axis, i = this.mode, n = this.object;
|
|
189
|
+
let a = this.space;
|
|
190
|
+
if (i === "scale" ? a = "local" : (e === "E" || e === "XYZE" || e === "XYZ") && (a = "world"), n === void 0 || e === null || this.dragging === !1 || t !== null && t.button !== -1) return;
|
|
191
|
+
t !== null && L.setFromCamera(t, this.camera);
|
|
192
|
+
const s = at(this._plane, L, !0);
|
|
193
|
+
if (s) {
|
|
194
|
+
if (this.pointEnd.copy(s.point).sub(this.worldPositionStart), i === "translate")
|
|
195
|
+
this._offset.copy(this.pointEnd).sub(this.pointStart), a === "local" && e !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), e.indexOf("X") === -1 && (this._offset.x = 0), e.indexOf("Y") === -1 && (this._offset.y = 0), e.indexOf("Z") === -1 && (this._offset.z = 0), a === "local" && e !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), n.position.copy(this._offset).add(this._positionStart), this.translationSnap && (a === "local" && (n.position.applyQuaternion(p.copy(this._quaternionStart).invert()), e.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), e.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), e.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.position.applyQuaternion(this._quaternionStart)), a === "world" && (n.parent && n.position.add(_.setFromMatrixPosition(n.parent.matrixWorld)), e.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), e.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), e.search("Z") !== -1 && (n.position.z = Math.round(n.position.z / this.translationSnap) * this.translationSnap), n.parent && n.position.sub(_.setFromMatrixPosition(n.parent.matrixWorld))));
|
|
196
|
+
else if (i === "scale") {
|
|
197
|
+
if (e.search("XYZ") !== -1) {
|
|
198
|
+
let c = this.pointEnd.length() / this.pointStart.length();
|
|
199
|
+
this.pointEnd.dot(this.pointStart) < 0 && (c *= -1), C.set(c, c, c);
|
|
200
|
+
} else
|
|
201
|
+
_.copy(this.pointStart), C.copy(this.pointEnd), _.applyQuaternion(this._worldQuaternionInv), C.applyQuaternion(this._worldQuaternionInv), C.divide(_), e.search("X") === -1 && (C.x = 1), e.search("Y") === -1 && (C.y = 1), e.search("Z") === -1 && (C.z = 1);
|
|
202
|
+
n.scale.copy(this._scaleStart).multiply(C), this.scaleSnap && (e.search("X") !== -1 && (n.scale.x = Math.round(n.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), e.search("Y") !== -1 && (n.scale.y = Math.round(n.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), e.search("Z") !== -1 && (n.scale.z = Math.round(n.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
203
|
+
} else if (i === "rotate") {
|
|
204
|
+
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
205
|
+
const c = 20 / this.worldPosition.distanceTo(_.setFromMatrixPosition(this.camera.matrixWorld));
|
|
206
|
+
let u = !1;
|
|
207
|
+
e === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(_.copy(this.rotationAxis).cross(this.eye)) * c) : (e === "X" || e === "Y" || e === "Z") && (this.rotationAxis.copy(mt[e]), _.copy(mt[e]), a === "local" && _.applyQuaternion(this.worldQuaternion), _.cross(this.eye), _.length() === 0 ? u = !0 : this.rotationAngle = this._offset.dot(_.normalize()) * c), (e === "E" || u) && (this.rotationAxis.copy(this.eye), this.rotationAngle = this.pointEnd.angleTo(this.pointStart), this._startNorm.copy(this.pointStart).normalize(), this._endNorm.copy(this.pointEnd).normalize(), this.rotationAngle *= this._endNorm.cross(this._startNorm).dot(this.eye) < 0 ? 1 : -1), this.rotationSnap && (this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap), a === "local" && e !== "E" && e !== "XYZE" ? (n.quaternion.copy(this._quaternionStart), n.quaternion.multiply(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), n.quaternion.copy(p.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), n.quaternion.multiply(this._quaternionStart).normalize());
|
|
208
|
+
}
|
|
209
|
+
this.dispatchEvent(rt), this.dispatchEvent(bt);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
pointerUp(t) {
|
|
213
|
+
t !== null && t.button !== 0 || (this.dragging && this.axis !== null && (yt.mode = this.mode, this.dispatchEvent(yt)), this.dragging = !1, this.axis = null);
|
|
214
|
+
}
|
|
215
|
+
dispose() {
|
|
216
|
+
this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointermove", this._onPointerHover), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.traverse(function(t) {
|
|
217
|
+
t.geometry && t.geometry.dispose(), t.material && t.material.dispose();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// Set current object
|
|
221
|
+
attach(t) {
|
|
222
|
+
return this.object = t, this.visible = !0, this;
|
|
223
|
+
}
|
|
224
|
+
// Detach from object
|
|
225
|
+
detach() {
|
|
226
|
+
return this.object = void 0, this.visible = !1, this.axis = null, this;
|
|
227
|
+
}
|
|
228
|
+
reset() {
|
|
229
|
+
this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(rt), this.dispatchEvent(bt), this.pointStart.copy(this.pointEnd));
|
|
230
|
+
}
|
|
231
|
+
getRaycaster() {
|
|
232
|
+
return L;
|
|
233
|
+
}
|
|
234
|
+
// TODO: deprecate
|
|
235
|
+
getMode() {
|
|
236
|
+
return this.mode;
|
|
237
|
+
}
|
|
238
|
+
setMode(t) {
|
|
239
|
+
this.mode = t;
|
|
240
|
+
}
|
|
241
|
+
setTranslationSnap(t) {
|
|
242
|
+
this.translationSnap = t;
|
|
243
|
+
}
|
|
244
|
+
setRotationSnap(t) {
|
|
245
|
+
this.rotationSnap = t;
|
|
246
|
+
}
|
|
247
|
+
setScaleSnap(t) {
|
|
248
|
+
this.scaleSnap = t;
|
|
249
|
+
}
|
|
250
|
+
setSize(t) {
|
|
251
|
+
this.size = t;
|
|
252
|
+
}
|
|
253
|
+
setSpace(t) {
|
|
254
|
+
this.space = t;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function Ut(h) {
|
|
258
|
+
if (this.domElement.ownerDocument.pointerLockElement)
|
|
259
|
+
return {
|
|
260
|
+
x: 0,
|
|
261
|
+
y: 0,
|
|
262
|
+
button: h.button
|
|
263
|
+
};
|
|
264
|
+
{
|
|
265
|
+
const t = this.domElement.getBoundingClientRect();
|
|
266
|
+
return {
|
|
267
|
+
x: (h.clientX - t.left) / t.width * 2 - 1,
|
|
268
|
+
y: -(h.clientY - t.top) / t.height * 2 + 1,
|
|
269
|
+
button: h.button
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function Ft(h) {
|
|
274
|
+
if (this.enabled)
|
|
275
|
+
switch (h.pointerType) {
|
|
276
|
+
case "mouse":
|
|
277
|
+
case "pen":
|
|
278
|
+
this.pointerHover(this._getPointer(h));
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function Bt(h) {
|
|
283
|
+
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(h.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(h)), this.pointerDown(this._getPointer(h)));
|
|
284
|
+
}
|
|
285
|
+
function Vt(h) {
|
|
286
|
+
this.enabled && this.pointerMove(this._getPointer(h));
|
|
287
|
+
}
|
|
288
|
+
function Nt(h) {
|
|
289
|
+
this.enabled && (this.domElement.releasePointerCapture(h.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(h)));
|
|
290
|
+
}
|
|
291
|
+
function at(h, t, e) {
|
|
292
|
+
const i = t.intersectObject(h, !0);
|
|
293
|
+
for (let n = 0; n < i.length; n++)
|
|
294
|
+
if (i[n].object.visible || e)
|
|
295
|
+
return i[n];
|
|
296
|
+
return !1;
|
|
297
|
+
}
|
|
298
|
+
const et = new Qt(), d = new l(0, 1, 0), vt = new l(0, 0, 0), Pt = new Et(), it = new E(), nt = new E(), D = new l(), St = new Et(), q = new l(1, 0, 0), H = new l(0, 1, 0), U = new l(0, 0, 1), st = new l(), R = new l(), Z = new l();
|
|
299
|
+
class Kt extends lt {
|
|
300
|
+
constructor() {
|
|
301
|
+
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
302
|
+
const t = new Dt({
|
|
303
|
+
depthTest: !1,
|
|
304
|
+
depthWrite: !1,
|
|
305
|
+
fog: !1,
|
|
306
|
+
toneMapped: !1,
|
|
307
|
+
transparent: !0
|
|
308
|
+
}), e = new jt({
|
|
309
|
+
depthTest: !1,
|
|
310
|
+
depthWrite: !1,
|
|
311
|
+
fog: !1,
|
|
312
|
+
toneMapped: !1,
|
|
313
|
+
transparent: !0
|
|
314
|
+
}), i = t.clone();
|
|
315
|
+
i.opacity = 0.15;
|
|
316
|
+
const n = e.clone();
|
|
317
|
+
n.opacity = 0.5;
|
|
318
|
+
const a = t.clone();
|
|
319
|
+
a.color.setHex(16711680);
|
|
320
|
+
const s = t.clone();
|
|
321
|
+
s.color.setHex(65280);
|
|
322
|
+
const c = t.clone();
|
|
323
|
+
c.color.setHex(255);
|
|
324
|
+
const u = t.clone();
|
|
325
|
+
u.color.setHex(16711680), u.opacity = 0.5;
|
|
326
|
+
const P = t.clone();
|
|
327
|
+
P.color.setHex(65280), P.opacity = 0.5;
|
|
328
|
+
const M = t.clone();
|
|
329
|
+
M.color.setHex(255), M.opacity = 0.5;
|
|
330
|
+
const j = t.clone();
|
|
331
|
+
j.opacity = 0.25;
|
|
332
|
+
const k = t.clone();
|
|
333
|
+
k.color.setHex(16776960), k.opacity = 0.25, t.clone().color.setHex(16776960);
|
|
334
|
+
const V = t.clone();
|
|
335
|
+
V.color.setHex(7895160);
|
|
336
|
+
const x = new w(0, 0.04, 0.1, 12);
|
|
337
|
+
x.translate(0, 0.05, 0);
|
|
338
|
+
const I = new f(0.08, 0.08, 0.08);
|
|
339
|
+
I.translate(0, 0.04, 0);
|
|
340
|
+
const S = new dt();
|
|
341
|
+
S.setAttribute("position", new pt([0, 0, 0, 1, 0, 0], 3));
|
|
342
|
+
const g = new w(75e-4, 75e-4, 0.5, 3);
|
|
343
|
+
g.translate(0, 0.25, 0);
|
|
344
|
+
function b(y, N) {
|
|
345
|
+
const v = new Q(y, 75e-4, 3, 64, N * Math.PI * 2);
|
|
346
|
+
return v.rotateY(Math.PI / 2), v.rotateX(Math.PI / 2), v;
|
|
347
|
+
}
|
|
348
|
+
function X() {
|
|
349
|
+
const y = new dt();
|
|
350
|
+
return y.setAttribute("position", new pt([0, 0, 0, 1, 1, 1], 3)), y;
|
|
351
|
+
}
|
|
352
|
+
const z = {
|
|
353
|
+
X: [
|
|
354
|
+
[new r(x, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
355
|
+
[new r(x, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
356
|
+
[new r(g, a), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
357
|
+
],
|
|
358
|
+
Y: [
|
|
359
|
+
[new r(x, s), [0, 0.5, 0]],
|
|
360
|
+
[new r(x, s), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
361
|
+
[new r(g, s)]
|
|
362
|
+
],
|
|
363
|
+
Z: [
|
|
364
|
+
[new r(x, c), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
365
|
+
[new r(x, c), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
366
|
+
[new r(g, c), null, [Math.PI / 2, 0, 0]]
|
|
367
|
+
],
|
|
368
|
+
XYZ: [
|
|
369
|
+
[new r(new tt(0.1, 0), j.clone()), [0, 0, 0]]
|
|
370
|
+
],
|
|
371
|
+
XY: [
|
|
372
|
+
[new r(new f(0.15, 0.15, 0.01), M.clone()), [0.15, 0.15, 0]]
|
|
373
|
+
],
|
|
374
|
+
YZ: [
|
|
375
|
+
[new r(new f(0.15, 0.15, 0.01), u.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
376
|
+
],
|
|
377
|
+
XZ: [
|
|
378
|
+
[new r(new f(0.15, 0.15, 0.01), P.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
379
|
+
]
|
|
380
|
+
}, Mt = {
|
|
381
|
+
X: [
|
|
382
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
383
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
384
|
+
],
|
|
385
|
+
Y: [
|
|
386
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
|
|
387
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
388
|
+
],
|
|
389
|
+
Z: [
|
|
390
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
391
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
392
|
+
],
|
|
393
|
+
XYZ: [
|
|
394
|
+
[new r(new tt(0.2, 0), i)]
|
|
395
|
+
],
|
|
396
|
+
XY: [
|
|
397
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
|
|
398
|
+
],
|
|
399
|
+
YZ: [
|
|
400
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
401
|
+
],
|
|
402
|
+
XZ: [
|
|
403
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
404
|
+
]
|
|
405
|
+
}, xt = {
|
|
406
|
+
START: [
|
|
407
|
+
[new r(new tt(0.01, 2), n), null, null, null, "helper"]
|
|
408
|
+
],
|
|
409
|
+
END: [
|
|
410
|
+
[new r(new tt(0.01, 2), n), null, null, null, "helper"]
|
|
411
|
+
],
|
|
412
|
+
DELTA: [
|
|
413
|
+
[new A(X(), n), null, null, null, "helper"]
|
|
414
|
+
],
|
|
415
|
+
X: [
|
|
416
|
+
[new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
417
|
+
],
|
|
418
|
+
Y: [
|
|
419
|
+
[new A(S, n.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
420
|
+
],
|
|
421
|
+
Z: [
|
|
422
|
+
[new A(S, n.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
423
|
+
]
|
|
424
|
+
}, It = {
|
|
425
|
+
XYZE: [
|
|
426
|
+
[new r(b(0.5, 1), V), null, [0, Math.PI / 2, 0]]
|
|
427
|
+
],
|
|
428
|
+
X: [
|
|
429
|
+
[new r(b(0.5, 0.5), a)]
|
|
430
|
+
],
|
|
431
|
+
Y: [
|
|
432
|
+
[new r(b(0.5, 0.5), s), null, [0, 0, -Math.PI / 2]]
|
|
433
|
+
],
|
|
434
|
+
Z: [
|
|
435
|
+
[new r(b(0.5, 0.5), c), null, [0, Math.PI / 2, 0]]
|
|
436
|
+
],
|
|
437
|
+
E: [
|
|
438
|
+
[new r(b(0.75, 1), k), null, [0, Math.PI / 2, 0]]
|
|
439
|
+
]
|
|
440
|
+
}, Tt = {
|
|
441
|
+
AXIS: [
|
|
442
|
+
[new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
443
|
+
]
|
|
444
|
+
}, At = {
|
|
445
|
+
XYZE: [
|
|
446
|
+
[new r(new kt(0.25, 10, 8), i)]
|
|
447
|
+
],
|
|
448
|
+
X: [
|
|
449
|
+
[new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
450
|
+
],
|
|
451
|
+
Y: [
|
|
452
|
+
[new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [Math.PI / 2, 0, 0]]
|
|
453
|
+
],
|
|
454
|
+
Z: [
|
|
455
|
+
[new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
456
|
+
],
|
|
457
|
+
E: [
|
|
458
|
+
[new r(new Q(0.75, 0.1, 2, 24), i)]
|
|
459
|
+
]
|
|
460
|
+
}, Ct = {
|
|
461
|
+
X: [
|
|
462
|
+
[new r(I, a), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
463
|
+
[new r(g, a), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
464
|
+
[new r(I, a), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
|
|
465
|
+
],
|
|
466
|
+
Y: [
|
|
467
|
+
[new r(I, s), [0, 0.5, 0]],
|
|
468
|
+
[new r(g, s)],
|
|
469
|
+
[new r(I, s), [0, -0.5, 0], [0, 0, Math.PI]]
|
|
470
|
+
],
|
|
471
|
+
Z: [
|
|
472
|
+
[new r(I, c), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
473
|
+
[new r(g, c), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
474
|
+
[new r(I, c), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
475
|
+
],
|
|
476
|
+
XY: [
|
|
477
|
+
[new r(new f(0.15, 0.15, 0.01), M), [0.15, 0.15, 0]]
|
|
478
|
+
],
|
|
479
|
+
YZ: [
|
|
480
|
+
[new r(new f(0.15, 0.15, 0.01), u), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
481
|
+
],
|
|
482
|
+
XZ: [
|
|
483
|
+
[new r(new f(0.15, 0.15, 0.01), P), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
484
|
+
],
|
|
485
|
+
XYZ: [
|
|
486
|
+
[new r(new f(0.1, 0.1, 0.1), j.clone())]
|
|
487
|
+
]
|
|
488
|
+
}, zt = {
|
|
489
|
+
X: [
|
|
490
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
491
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
492
|
+
],
|
|
493
|
+
Y: [
|
|
494
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0.3, 0]],
|
|
495
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
496
|
+
],
|
|
497
|
+
Z: [
|
|
498
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
499
|
+
[new r(new w(0.2, 0, 0.6, 4), i), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
500
|
+
],
|
|
501
|
+
XY: [
|
|
502
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0.15, 0.15, 0]]
|
|
503
|
+
],
|
|
504
|
+
YZ: [
|
|
505
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
506
|
+
],
|
|
507
|
+
XZ: [
|
|
508
|
+
[new r(new f(0.2, 0.2, 0.01), i), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
509
|
+
],
|
|
510
|
+
XYZ: [
|
|
511
|
+
[new r(new f(0.2, 0.2, 0.2), i), [0, 0, 0]]
|
|
512
|
+
]
|
|
513
|
+
}, Lt = {
|
|
514
|
+
X: [
|
|
515
|
+
[new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
516
|
+
],
|
|
517
|
+
Y: [
|
|
518
|
+
[new A(S, n.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
519
|
+
],
|
|
520
|
+
Z: [
|
|
521
|
+
[new A(S, n.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
522
|
+
]
|
|
523
|
+
};
|
|
524
|
+
function T(y) {
|
|
525
|
+
const N = new lt();
|
|
526
|
+
for (const v in y)
|
|
527
|
+
for (let Y = y[v].length; Y--; ) {
|
|
528
|
+
const m = y[v][Y][0].clone(), K = y[v][Y][1], $ = y[v][Y][2], J = y[v][Y][3], Ht = y[v][Y][4];
|
|
529
|
+
m.name = v, m.tag = Ht, K && m.position.set(K[0], K[1], K[2]), $ && m.rotation.set($[0], $[1], $[2]), J && m.scale.set(J[0], J[1], J[2]), m.updateMatrix();
|
|
530
|
+
const ct = m.geometry.clone();
|
|
531
|
+
ct.applyMatrix4(m.matrix), m.geometry = ct, m.renderOrder = 1 / 0, m.position.set(0, 0, 0), m.rotation.set(0, 0, 0), m.scale.set(1, 1, 1), N.add(m);
|
|
532
|
+
}
|
|
533
|
+
return N;
|
|
534
|
+
}
|
|
535
|
+
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = T(z)), this.add(this.gizmo.rotate = T(It)), this.add(this.gizmo.scale = T(Ct)), this.add(this.picker.translate = T(Mt)), this.add(this.picker.rotate = T(At)), this.add(this.picker.scale = T(zt)), this.add(this.helper.translate = T(xt)), this.add(this.helper.rotate = T(Tt)), this.add(this.helper.scale = T(Lt)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
536
|
+
}
|
|
537
|
+
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
538
|
+
updateMatrixWorld(t) {
|
|
539
|
+
const i = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : nt;
|
|
540
|
+
this.gizmo.translate.visible = this.mode === "translate", this.gizmo.rotate.visible = this.mode === "rotate", this.gizmo.scale.visible = this.mode === "scale", this.helper.translate.visible = this.mode === "translate", this.helper.rotate.visible = this.mode === "rotate", this.helper.scale.visible = this.mode === "scale";
|
|
541
|
+
let n = [];
|
|
542
|
+
n = n.concat(this.picker[this.mode].children), n = n.concat(this.gizmo[this.mode].children), n = n.concat(this.helper[this.mode].children);
|
|
543
|
+
for (let a = 0; a < n.length; a++) {
|
|
544
|
+
const s = n[a];
|
|
545
|
+
s.visible = !0, s.rotation.set(0, 0, 0), s.position.copy(this.worldPosition);
|
|
546
|
+
let c;
|
|
547
|
+
if (this.camera.isOrthographicCamera ? c = (this.camera.top - this.camera.bottom) / this.camera.zoom : c = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), s.scale.set(1, 1, 1).multiplyScalar(c * this.size / 4), s.tag === "helper") {
|
|
548
|
+
s.visible = !1, s.name === "AXIS" ? (s.visible = !!this.axis, this.axis === "X" && (p.setFromEuler(et.set(0, 0, 0)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "Y" && (p.setFromEuler(et.set(0, 0, Math.PI / 2)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(H).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "Z" && (p.setFromEuler(et.set(0, Math.PI / 2, 0)), s.quaternion.copy(i).multiply(p), Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) > 0.9 && (s.visible = !1)), this.axis === "XYZE" && (p.setFromEuler(et.set(0, Math.PI / 2, 0)), d.copy(this.rotationAxis), s.quaternion.setFromRotationMatrix(Pt.lookAt(vt, d, H)), s.quaternion.multiply(p), s.visible = this.dragging), this.axis === "E" && (s.visible = !1)) : s.name === "START" ? (s.position.copy(this.worldPositionStart), s.visible = this.dragging) : s.name === "END" ? (s.position.copy(this.worldPosition), s.visible = this.dragging) : s.name === "DELTA" ? (s.position.copy(this.worldPositionStart), s.quaternion.copy(this.worldQuaternionStart), _.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), _.applyQuaternion(this.worldQuaternionStart.clone().invert()), s.scale.copy(_), s.visible = this.dragging) : (s.quaternion.copy(i), this.dragging ? s.position.copy(this.worldPositionStart) : s.position.copy(this.worldPosition), this.axis && (s.visible = this.axis.search(s.name) !== -1));
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
s.quaternion.copy(i), this.mode === "translate" || this.mode === "scale" ? (s.name === "X" && Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "Y" && Math.abs(d.copy(H).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "Z" && Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) > 0.99 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "XY" && Math.abs(d.copy(U).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "YZ" && Math.abs(d.copy(q).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1), s.name === "XZ" && Math.abs(d.copy(H).applyQuaternion(i).dot(this.eye)) < 0.2 && (s.scale.set(1e-10, 1e-10, 1e-10), s.visible = !1)) : this.mode === "rotate" && (it.copy(i), d.copy(this.eye).applyQuaternion(p.copy(i).invert()), s.name.search("E") !== -1 && s.quaternion.setFromRotationMatrix(Pt.lookAt(this.eye, vt, H)), s.name === "X" && (p.setFromAxisAngle(q, Math.atan2(-d.y, d.z)), p.multiplyQuaternions(it, p), s.quaternion.copy(p)), s.name === "Y" && (p.setFromAxisAngle(H, Math.atan2(d.x, d.z)), p.multiplyQuaternions(it, p), s.quaternion.copy(p)), s.name === "Z" && (p.setFromAxisAngle(U, Math.atan2(d.y, d.x)), p.multiplyQuaternions(it, p), s.quaternion.copy(p))), s.visible = s.visible && (s.name.indexOf("X") === -1 || this.showX), s.visible = s.visible && (s.name.indexOf("Y") === -1 || this.showY), s.visible = s.visible && (s.name.indexOf("Z") === -1 || this.showZ), s.visible = s.visible && (s.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), s.material._color = s.material._color || s.material.color.clone(), s.material._opacity = s.material._opacity || s.material.opacity, s.material.color.copy(s.material._color), s.material.opacity = s.material._opacity, this.enabled && this.axis && (s.name === this.axis || this.axis.split("").some(function(u) {
|
|
552
|
+
return s.name === u;
|
|
553
|
+
})) && (s.material.color.setHex(16776960), s.material.opacity = 1);
|
|
554
|
+
}
|
|
555
|
+
super.updateMatrixWorld(t);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
class $t extends r {
|
|
559
|
+
constructor() {
|
|
560
|
+
super(
|
|
561
|
+
new Ot(1e5, 1e5, 2, 2),
|
|
562
|
+
new Dt({ visible: !1, wireframe: !0, side: Rt, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
563
|
+
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
564
|
+
}
|
|
565
|
+
updateMatrixWorld(t) {
|
|
566
|
+
let e = this.space;
|
|
567
|
+
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (e = "local"), st.copy(q).applyQuaternion(e === "local" ? this.worldQuaternion : nt), R.copy(H).applyQuaternion(e === "local" ? this.worldQuaternion : nt), Z.copy(U).applyQuaternion(e === "local" ? this.worldQuaternion : nt), d.copy(R), this.mode) {
|
|
568
|
+
case "translate":
|
|
569
|
+
case "scale":
|
|
570
|
+
switch (this.axis) {
|
|
571
|
+
case "X":
|
|
572
|
+
d.copy(this.eye).cross(st), D.copy(st).cross(d);
|
|
573
|
+
break;
|
|
574
|
+
case "Y":
|
|
575
|
+
d.copy(this.eye).cross(R), D.copy(R).cross(d);
|
|
576
|
+
break;
|
|
577
|
+
case "Z":
|
|
578
|
+
d.copy(this.eye).cross(Z), D.copy(Z).cross(d);
|
|
579
|
+
break;
|
|
580
|
+
case "XY":
|
|
581
|
+
D.copy(Z);
|
|
582
|
+
break;
|
|
583
|
+
case "YZ":
|
|
584
|
+
D.copy(st);
|
|
585
|
+
break;
|
|
586
|
+
case "XZ":
|
|
587
|
+
d.copy(Z), D.copy(R);
|
|
588
|
+
break;
|
|
589
|
+
case "XYZ":
|
|
590
|
+
case "E":
|
|
591
|
+
D.set(0, 0, 0);
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
break;
|
|
595
|
+
case "rotate":
|
|
596
|
+
default:
|
|
597
|
+
D.set(0, 0, 0);
|
|
598
|
+
}
|
|
599
|
+
D.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (St.lookAt(_.set(0, 0, 0), D, d), this.quaternion.setFromRotationMatrix(St)), super.updateMatrixWorld(t);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const ce = (h) => h.name === "transform";
|
|
603
|
+
class Jt {
|
|
604
|
+
constructor(t, e, i) {
|
|
605
|
+
o(this, "name", "transform");
|
|
606
|
+
o(this, "priority", 5);
|
|
607
|
+
o(this, "_scene");
|
|
608
|
+
o(this, "_controller");
|
|
609
|
+
o(this, "_selectionState");
|
|
610
|
+
o(this, "_gizmo");
|
|
611
|
+
o(this, "_scaleLinked", !1);
|
|
612
|
+
o(this, "_gizmoVisible", !0);
|
|
613
|
+
o(this, "_selectionChangeHandler");
|
|
614
|
+
this._scene = t, this._controller = e, this._selectionState = i, this._gizmo = this.initGizmo(), this._scene.add(this._gizmo), this._selectionChangeHandler = this.onSelectionChange.bind(this);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Get the TransformControls gizmo.
|
|
618
|
+
*/
|
|
619
|
+
get gizmo() {
|
|
620
|
+
return this._gizmo;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Whether a drag operation is currently in progress.
|
|
624
|
+
*/
|
|
625
|
+
get isDragging() {
|
|
626
|
+
return this._gizmo.dragging;
|
|
627
|
+
}
|
|
628
|
+
onActivate() {
|
|
629
|
+
this._selectionState.onChange(this._selectionChangeHandler);
|
|
630
|
+
const t = this._selectionState.selected;
|
|
631
|
+
t && this.attachGizmo(t);
|
|
632
|
+
}
|
|
633
|
+
onDeactivate() {
|
|
634
|
+
this._selectionState.offChange(this._selectionChangeHandler), this._gizmo.detach();
|
|
635
|
+
}
|
|
636
|
+
onPointerMove(t) {
|
|
637
|
+
if (this._gizmo.dragging || t.uiIntersects.length > 0 && t.uiIntersects.some(
|
|
638
|
+
(i) => this.isGizmoChild(i.object)
|
|
639
|
+
))
|
|
640
|
+
return !0;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Set the gizmo transformation mode.
|
|
644
|
+
*/
|
|
645
|
+
setGizmoMode(t) {
|
|
646
|
+
this._gizmo.mode = t;
|
|
22
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Set whether the gizmo is visible.
|
|
650
|
+
*/
|
|
651
|
+
setGizmoVisible(t) {
|
|
652
|
+
this._gizmoVisible = t;
|
|
653
|
+
const e = this._scene.children.includes(this._gizmo);
|
|
654
|
+
t && !e ? (this._scene.add(this._gizmo), this._gizmo.getRaycaster().layers.enableAll()) : !t && e && (this._scene.remove(this._gizmo), this._gizmo.getRaycaster().layers.disableAll());
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Set whether scale operations are linked (uniform scaling).
|
|
658
|
+
*/
|
|
659
|
+
setGizmoScaleLinked(t) {
|
|
660
|
+
this._scaleLinked = t;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Dispose of the tool and clean up resources.
|
|
664
|
+
*/
|
|
665
|
+
dispose() {
|
|
666
|
+
this._selectionState.offChange(this._selectionChangeHandler), this._gizmo.detach(), this._scene.remove(this._gizmo), this._gizmo.dispose();
|
|
667
|
+
}
|
|
668
|
+
// ============ Private Methods ============
|
|
669
|
+
onSelectionChange(t) {
|
|
670
|
+
t && O(t, "isMovable") ? this.attachGizmo(t) : this._gizmo.detach();
|
|
671
|
+
}
|
|
672
|
+
attachGizmo(t) {
|
|
673
|
+
O(t, "isMovable") && (this._gizmo.attach(t), this.setGizmoVisible(t.visible && this._gizmoVisible));
|
|
674
|
+
}
|
|
675
|
+
isGizmoChild(t) {
|
|
676
|
+
let e = t;
|
|
677
|
+
for (; e; ) {
|
|
678
|
+
if (e === this._gizmo) return !0;
|
|
679
|
+
e = e.parent;
|
|
680
|
+
}
|
|
681
|
+
return !1;
|
|
682
|
+
}
|
|
683
|
+
initGizmo() {
|
|
684
|
+
const t = new qt(
|
|
685
|
+
this._controller.object,
|
|
686
|
+
this._controller.domElement
|
|
687
|
+
);
|
|
688
|
+
return t.mode = "translate", t.traverse((e) => {
|
|
689
|
+
if (!("isMesh" in e)) return;
|
|
690
|
+
const i = e.material;
|
|
691
|
+
e.name === "X" && i.color.set(ut), e.name === "Y" && i.color.set(gt), e.name === "Z" && i.color.set(ft), e.name === "XY" && i.color.set(ft), e.name === "YZ" && i.color.set(ut), e.name === "XZ" && i.color.set(gt);
|
|
692
|
+
}), t.addEventListener("mouseDown", () => {
|
|
693
|
+
var e, i;
|
|
694
|
+
this._controller.enabled = !1, O(t.object, "isMovable") && ((i = (e = t.object).onMoveStart) == null || i.call(e));
|
|
695
|
+
}), t.addEventListener("objectChange", () => {
|
|
696
|
+
var e, i;
|
|
697
|
+
if (O(t.object, "isMovable") && ((i = (e = t.object).onMove) == null || i.call(e), this._scaleLinked && t.object)) {
|
|
698
|
+
const n = t.object.scale, a = (n.x + n.y + n.z) / 3;
|
|
699
|
+
t.object.scale.set(a, a, a);
|
|
700
|
+
}
|
|
701
|
+
}), t.addEventListener("mouseUp", () => {
|
|
702
|
+
var e, i;
|
|
703
|
+
this._controller.enabled = !0, O(t.object, "isMovable") && ((i = (e = t.object).onMoveEnd) == null || i.call(e));
|
|
704
|
+
}), t;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
const te = 1e-3;
|
|
708
|
+
class ee {
|
|
709
|
+
constructor(t) {
|
|
710
|
+
o(this, "name", "drag");
|
|
711
|
+
o(this, "priority", 10);
|
|
712
|
+
o(this, "_controller");
|
|
713
|
+
o(this, "_raycaster");
|
|
714
|
+
// Drag state
|
|
715
|
+
o(this, "_dragging", !1);
|
|
716
|
+
o(this, "_draggable", null);
|
|
717
|
+
o(this, "_dragStart", new l());
|
|
718
|
+
o(this, "_dragCurrent", new l());
|
|
719
|
+
o(this, "_dragEnd", new l());
|
|
720
|
+
o(this, "_dragDelta", new l());
|
|
721
|
+
// Custom raycast targets for drag plane
|
|
722
|
+
o(this, "_dragRaycastTargets", null);
|
|
723
|
+
this._controller = t, this._raycaster = new ot();
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Whether a drag operation is currently in progress.
|
|
727
|
+
*/
|
|
728
|
+
get isDragging() {
|
|
729
|
+
return this._dragging;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* The object currently being dragged, or null.
|
|
733
|
+
*/
|
|
734
|
+
get draggable() {
|
|
735
|
+
return this._draggable;
|
|
736
|
+
}
|
|
737
|
+
onActivate() {
|
|
738
|
+
this.resetDragState();
|
|
739
|
+
}
|
|
740
|
+
onDeactivate() {
|
|
741
|
+
this._dragging && this._draggable && this.endDrag(), this.resetDragState();
|
|
742
|
+
}
|
|
743
|
+
onPointerDown(t) {
|
|
744
|
+
var e;
|
|
745
|
+
t.pointerPrimaryDown && (this._draggable = B(
|
|
746
|
+
(e = t.intersects[0]) == null ? void 0 : e.object,
|
|
747
|
+
"isDraggable"
|
|
748
|
+
) || null);
|
|
749
|
+
}
|
|
750
|
+
onPointerMove(t) {
|
|
751
|
+
if (t.pointerPrimaryDown && this._draggable && (this._raycaster.setFromCamera(t.pointer, this._controller.object), this._dragging || t.lastPointerDown.distanceTo(t.pointer) > te && this.startDrag(t), this._dragging))
|
|
752
|
+
return this.updateDrag(t), !0;
|
|
753
|
+
}
|
|
754
|
+
onPointerUp(t) {
|
|
755
|
+
this._dragging && (this._raycaster.setFromCamera(t.pointer, this._controller.object), this.endDrag()), this._draggable = null;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Set custom objects to raycast against during drag.
|
|
759
|
+
* Useful for constraining drag to a floor plane.
|
|
760
|
+
*
|
|
761
|
+
* @param targets Objects to raycast against, or null to use scene objects
|
|
762
|
+
*/
|
|
763
|
+
setDragRaycastTargets(t) {
|
|
764
|
+
this._dragRaycastTargets = t;
|
|
765
|
+
}
|
|
766
|
+
// ============ Private Methods ============
|
|
767
|
+
startDrag(t) {
|
|
768
|
+
var i, n;
|
|
769
|
+
const e = this.getDragIntersect(t);
|
|
770
|
+
e && (this._dragStart.copy(e.point), this._dragCurrent.copy(e.point), this._dragEnd.copy(e.point), this._dragDelta.set(0, 0, 0), (n = (i = this._draggable) == null ? void 0 : i.onDragStart) == null || n.call(i, this.createDragEvent()), this._dragging = !0, this._controller.enabled = !1);
|
|
771
|
+
}
|
|
772
|
+
updateDrag(t) {
|
|
773
|
+
var i, n;
|
|
774
|
+
const e = this.getDragIntersect(t);
|
|
775
|
+
e && (this._dragCurrent.copy(e.point), this._dragEnd.copy(e.point), this._dragDelta.subVectors(this._dragCurrent, this._dragStart), (n = (i = this._draggable) == null ? void 0 : i.onDrag) == null || n.call(i, this.createDragEvent()));
|
|
776
|
+
}
|
|
777
|
+
endDrag() {
|
|
778
|
+
var e, i;
|
|
779
|
+
const t = this.createDragEvent();
|
|
780
|
+
(i = (e = this._draggable) == null ? void 0 : e.onDragEnd) == null || i.call(e, t), this._dragging = !1, this._controller.enabled = !0, this.resetDragState();
|
|
781
|
+
}
|
|
782
|
+
getDragIntersect(t) {
|
|
783
|
+
return this._dragRaycastTargets ? this._raycaster.intersectObjects(
|
|
784
|
+
this._dragRaycastTargets,
|
|
785
|
+
!0
|
|
786
|
+
)[0] || null : t.intersects[0] || null;
|
|
787
|
+
}
|
|
788
|
+
createDragEvent() {
|
|
789
|
+
return {
|
|
790
|
+
dragStart: this._dragStart.clone(),
|
|
791
|
+
dragCurrent: this._dragCurrent.clone(),
|
|
792
|
+
dragEnd: this._dragEnd.clone(),
|
|
793
|
+
dragDelta: this._dragDelta.clone()
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
resetDragState() {
|
|
797
|
+
this._dragStart.set(0, 0, 0), this._dragCurrent.set(0, 0, 0), this._dragEnd.set(0, 0, 0), this._dragDelta.set(0, 0, 0);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const ie = 1e-3;
|
|
801
|
+
class de {
|
|
802
|
+
constructor(t, e) {
|
|
803
|
+
o(this, "_scene");
|
|
804
|
+
o(this, "_controller");
|
|
805
|
+
o(this, "_canvas");
|
|
806
|
+
// Tool management
|
|
807
|
+
o(this, "_tools");
|
|
808
|
+
o(this, "_activeTools", /* @__PURE__ */ new Map());
|
|
809
|
+
o(this, "_sortedActiveTools", []);
|
|
810
|
+
// Shared selection state
|
|
811
|
+
o(this, "_selectionState");
|
|
812
|
+
// Raycasting (shared, computed once per event)
|
|
813
|
+
o(this, "_raycaster");
|
|
814
|
+
o(this, "_pointer");
|
|
815
|
+
o(this, "_productLayerMask");
|
|
816
|
+
o(this, "_uiLayerMask");
|
|
817
|
+
// Pointer state
|
|
818
|
+
o(this, "_pointerPrimaryDown", !1);
|
|
819
|
+
o(this, "_pointerMiddleDown", !1);
|
|
820
|
+
o(this, "_pointerSecondaryDown", !1);
|
|
821
|
+
o(this, "_lastPointerDown");
|
|
822
|
+
// Bound event handlers (for cleanup)
|
|
823
|
+
o(this, "_boundPointerMove");
|
|
824
|
+
o(this, "_boundPointerDown");
|
|
825
|
+
o(this, "_boundPointerUp");
|
|
826
|
+
o(this, "_boundWheel");
|
|
827
|
+
this._scene = t, this._controller = e, this._canvas = e.domElement, this._selectionState = new Zt(), this._raycaster = new ot(), this._pointer = new F(), this._lastPointerDown = new F(), this._productLayerMask = new _t(), this._productLayerMask.set(Math.log2(G)), this._uiLayerMask = new _t(), this._uiLayerMask.set(Math.log2(W)), this._tools = /* @__PURE__ */ new Map([
|
|
828
|
+
[
|
|
829
|
+
"hover",
|
|
830
|
+
new Gt()
|
|
831
|
+
],
|
|
832
|
+
[
|
|
833
|
+
"select",
|
|
834
|
+
new Wt(this._selectionState)
|
|
835
|
+
],
|
|
836
|
+
[
|
|
837
|
+
"transform",
|
|
838
|
+
new Jt(t, e, this._selectionState)
|
|
839
|
+
],
|
|
840
|
+
[
|
|
841
|
+
"drag",
|
|
842
|
+
new ee(e)
|
|
843
|
+
]
|
|
844
|
+
]), this._boundPointerMove = this.onPointerMove.bind(this), this._boundPointerDown = this.onPointerDown.bind(this), this._boundPointerUp = this.onPointerUp.bind(this), this._boundWheel = this.onWheel.bind(this), this._canvas.addEventListener("pointermove", this._boundPointerMove), this._canvas.addEventListener("pointerdown", this._boundPointerDown), this._canvas.addEventListener("pointerup", this._boundPointerUp), this._canvas.addEventListener("wheel", this._boundWheel);
|
|
845
|
+
}
|
|
846
|
+
get selectionState() {
|
|
847
|
+
return this._selectionState;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Enable a tool by type.
|
|
851
|
+
*/
|
|
852
|
+
enableTool(t) {
|
|
853
|
+
var i;
|
|
854
|
+
const e = this._tools.get(t);
|
|
855
|
+
e && (this._activeTools.has(t) || (this._activeTools.set(t, e), this.updateSortedTools(), (i = e.onActivate) == null || i.call(e)));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Disable an active tool by type.
|
|
859
|
+
*/
|
|
860
|
+
disableTool(t) {
|
|
861
|
+
var i;
|
|
862
|
+
const e = this._activeTools.get(t);
|
|
863
|
+
e && ((i = e.onDeactivate) == null || i.call(e), this._activeTools.delete(t), this.updateSortedTools());
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Check if a tool is currently enabled.
|
|
867
|
+
*/
|
|
868
|
+
isToolEnabled(t) {
|
|
869
|
+
return this._activeTools.has(t);
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Get a tool by type.
|
|
873
|
+
*/
|
|
874
|
+
getTool(t) {
|
|
875
|
+
return this._tools.get(t);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Get all currently active tools.
|
|
879
|
+
*/
|
|
880
|
+
getActiveTools() {
|
|
881
|
+
return [...this._sortedActiveTools];
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Dispose of the toolbox and clean up resources.
|
|
885
|
+
*/
|
|
886
|
+
dispose() {
|
|
887
|
+
var t;
|
|
888
|
+
for (const e of this._activeTools.values())
|
|
889
|
+
(t = e.onDeactivate) == null || t.call(e);
|
|
890
|
+
this._activeTools.clear(), this._tools.clear(), this._sortedActiveTools = [], this._canvas.removeEventListener("pointermove", this._boundPointerMove), this._canvas.removeEventListener("pointerdown", this._boundPointerDown), this._canvas.removeEventListener("pointerup", this._boundPointerUp), this._canvas.removeEventListener("wheel", this._boundWheel), this._selectionState.dispose();
|
|
891
|
+
}
|
|
892
|
+
// ============ Event Handlers ============
|
|
893
|
+
onPointerMove(t) {
|
|
894
|
+
var i;
|
|
895
|
+
this.updatePointer(t);
|
|
896
|
+
const e = this.createPointerContext(t);
|
|
897
|
+
for (const n of this._sortedActiveTools)
|
|
898
|
+
if ((i = n.onPointerMove) == null ? void 0 : i.call(n, e)) break;
|
|
899
|
+
}
|
|
900
|
+
onPointerDown(t) {
|
|
901
|
+
var i;
|
|
902
|
+
this.updatePointerState(t, !0), this.updatePointer(t), this._lastPointerDown.copy(this._pointer);
|
|
903
|
+
const e = this.createPointerContext(t);
|
|
904
|
+
for (const n of this._sortedActiveTools)
|
|
905
|
+
if ((i = n.onPointerDown) == null ? void 0 : i.call(n, e)) break;
|
|
906
|
+
}
|
|
907
|
+
onPointerUp(t) {
|
|
908
|
+
var n, a;
|
|
909
|
+
this.updatePointer(t);
|
|
910
|
+
const e = this.createPointerContext(t), i = !this.pointerWasDragged();
|
|
911
|
+
for (const s of this._sortedActiveTools)
|
|
912
|
+
if ((n = s.onPointerUp) == null ? void 0 : n.call(s, e)) break;
|
|
913
|
+
if (i) {
|
|
914
|
+
for (const s of this._sortedActiveTools)
|
|
915
|
+
if ((a = s.onClick) == null ? void 0 : a.call(s, e)) break;
|
|
916
|
+
}
|
|
917
|
+
this.updatePointerState(t, !1);
|
|
918
|
+
}
|
|
919
|
+
onWheel(t) {
|
|
920
|
+
var i;
|
|
921
|
+
const e = this.createWheelContext(t);
|
|
922
|
+
for (const n of this._sortedActiveTools)
|
|
923
|
+
if ((i = n.onWheel) == null ? void 0 : i.call(n, e)) break;
|
|
924
|
+
}
|
|
925
|
+
// ============ Context Creation ============
|
|
926
|
+
createPointerContext(t) {
|
|
927
|
+
const e = this.raycast();
|
|
928
|
+
return {
|
|
929
|
+
event: t,
|
|
930
|
+
pointer: this._pointer.clone(),
|
|
931
|
+
intersects: e,
|
|
932
|
+
modelIntersects: this.filterIntersectsByLayer(
|
|
933
|
+
e,
|
|
934
|
+
G
|
|
935
|
+
),
|
|
936
|
+
uiIntersects: this.filterIntersectsByLayer(
|
|
937
|
+
e,
|
|
938
|
+
W
|
|
939
|
+
),
|
|
940
|
+
pointerPrimaryDown: this._pointerPrimaryDown,
|
|
941
|
+
pointerMiddleDown: this._pointerMiddleDown,
|
|
942
|
+
pointerSecondaryDown: this._pointerSecondaryDown,
|
|
943
|
+
lastPointerDown: this._lastPointerDown.clone()
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
createWheelContext(t) {
|
|
947
|
+
const e = this.raycast();
|
|
948
|
+
return {
|
|
949
|
+
event: t,
|
|
950
|
+
pointer: this._pointer.clone(),
|
|
951
|
+
intersects: e,
|
|
952
|
+
modelIntersects: this.filterIntersectsByLayer(
|
|
953
|
+
e,
|
|
954
|
+
G
|
|
955
|
+
),
|
|
956
|
+
uiIntersects: this.filterIntersectsByLayer(
|
|
957
|
+
e,
|
|
958
|
+
W
|
|
959
|
+
)
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
// ============ Helper Methods ============
|
|
963
|
+
updatePointer(t) {
|
|
964
|
+
this._pointer.x = t.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(t.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object);
|
|
965
|
+
}
|
|
966
|
+
updatePointerState(t, e) {
|
|
967
|
+
switch (t.button) {
|
|
968
|
+
case 0:
|
|
969
|
+
this._pointerPrimaryDown = e;
|
|
970
|
+
break;
|
|
971
|
+
case 1:
|
|
972
|
+
this._pointerMiddleDown = e;
|
|
973
|
+
break;
|
|
974
|
+
case 2:
|
|
975
|
+
this._pointerSecondaryDown = e;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
raycast() {
|
|
980
|
+
this._raycaster.layers.mask = G | W;
|
|
981
|
+
const t = this._scene.children.filter(
|
|
982
|
+
(e) => e.visible && "isMesh" in e && e.isMesh
|
|
983
|
+
);
|
|
984
|
+
return this._raycaster.intersectObjects(t, !0);
|
|
985
|
+
}
|
|
986
|
+
filterIntersectsByLayer(t, e) {
|
|
987
|
+
return t.filter(
|
|
988
|
+
(i) => (i.object.layers.mask & e) !== 0
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
updateSortedTools() {
|
|
992
|
+
this._sortedActiveTools = [...this._activeTools.values()].sort(
|
|
993
|
+
(t, e) => t.priority - e.priority
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
pointerWasDragged() {
|
|
997
|
+
return this._lastPointerDown.distanceTo(this._pointer) > ie;
|
|
998
|
+
}
|
|
999
|
+
// ============ Legacy API Compatibility ============
|
|
1000
|
+
/**
|
|
1001
|
+
* @deprecated Use enableTool/disableTool instead.
|
|
1002
|
+
* Enable or disable a tool by type.
|
|
1003
|
+
*/
|
|
1004
|
+
useTool(t) {
|
|
1005
|
+
const e = [
|
|
1006
|
+
"hover",
|
|
1007
|
+
"select",
|
|
1008
|
+
"transform",
|
|
1009
|
+
"drag"
|
|
1010
|
+
];
|
|
1011
|
+
for (const i of e)
|
|
1012
|
+
(i === t || t === "select") && this.enableTool(i);
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* @deprecated Use getActiveTools instead.
|
|
1016
|
+
* Get the first active tool (for legacy compatibility).
|
|
1017
|
+
*/
|
|
23
1018
|
getActiveTool() {
|
|
24
|
-
return this.
|
|
1019
|
+
return this._sortedActiveTools[0] || null;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
class pe {
|
|
1023
|
+
constructor(t, e) {
|
|
1024
|
+
o(this, "POINTER_DRAG_THRESHOLD", 1e-3);
|
|
1025
|
+
o(this, "name");
|
|
1026
|
+
o(this, "_canvas");
|
|
1027
|
+
o(this, "_scene");
|
|
1028
|
+
o(this, "_controller");
|
|
1029
|
+
// general pointer members
|
|
1030
|
+
o(this, "_pointer");
|
|
1031
|
+
o(this, "_pointerPrimaryDown");
|
|
1032
|
+
o(this, "_pointerMiddleDown");
|
|
1033
|
+
o(this, "_pointerSecondaryDown");
|
|
1034
|
+
o(this, "_lastPointerDown");
|
|
1035
|
+
o(this, "_lastPointerUp");
|
|
1036
|
+
// raycast members
|
|
1037
|
+
o(this, "_raycaster");
|
|
1038
|
+
o(this, "_intersects");
|
|
1039
|
+
// hovering members
|
|
1040
|
+
o(this, "_hovered");
|
|
1041
|
+
// dragging members
|
|
1042
|
+
o(this, "_dragging");
|
|
1043
|
+
o(this, "_dragStart");
|
|
1044
|
+
o(this, "_dragCurrent");
|
|
1045
|
+
o(this, "_dragEnd");
|
|
1046
|
+
o(this, "_dragDelta");
|
|
1047
|
+
o(this, "_draggable");
|
|
1048
|
+
o(this, "_dragRaycastOnObjects");
|
|
1049
|
+
this.name = "BaseTool", this._canvas = e.domElement, this._scene = t, this._controller = e, this._pointer = new F(), this._pointerPrimaryDown = !1, this._pointerMiddleDown = !1, this._pointerSecondaryDown = !1, this._lastPointerDown = new F(), this._lastPointerUp = new F(), this._raycaster = new ot(), this._raycaster.layers.mask = G | W, this._intersects = [], this._hovered = null, this._dragging = !1, this._dragStart = new l(), this._dragCurrent = new l(), this._dragEnd = new l(), this._dragDelta = new l(), this._draggable = null, this._dragRaycastOnObjects = null;
|
|
25
1050
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1051
|
+
get _pointerAnyDown() {
|
|
1052
|
+
return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
|
|
1053
|
+
}
|
|
1054
|
+
activate() {
|
|
1055
|
+
}
|
|
1056
|
+
deactivate() {
|
|
1057
|
+
}
|
|
1058
|
+
onPointerDown(t) {
|
|
1059
|
+
var e;
|
|
1060
|
+
switch (t.button) {
|
|
1061
|
+
case 0: {
|
|
1062
|
+
this._pointerPrimaryDown = !0;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
case 1: {
|
|
1066
|
+
this._pointerMiddleDown = !0;
|
|
31
1067
|
break;
|
|
32
1068
|
}
|
|
33
|
-
case
|
|
34
|
-
this.
|
|
1069
|
+
case 2: {
|
|
1070
|
+
this._pointerSecondaryDown = !0;
|
|
35
1071
|
break;
|
|
36
1072
|
}
|
|
37
1073
|
default:
|
|
38
|
-
console.warn(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(o = this._activeTool) == null || o.onWheel(e);
|
|
65
|
-
}
|
|
66
|
-
addEventListeners() {
|
|
67
|
-
this._controller.domElement.addEventListener(
|
|
68
|
-
"pointermove",
|
|
69
|
-
(e) => this.onPointerMove(e)
|
|
70
|
-
), this._controller.domElement.addEventListener(
|
|
71
|
-
"pointerdown",
|
|
72
|
-
(e) => this.onPointerDown(e)
|
|
73
|
-
), this._controller.domElement.addEventListener(
|
|
74
|
-
"pointerup",
|
|
75
|
-
(e) => this.onPointerUp(e)
|
|
76
|
-
), this._controller.domElement.addEventListener(
|
|
77
|
-
"wheel",
|
|
78
|
-
(e) => this.onWheel(e)
|
|
1074
|
+
console.warn(
|
|
1075
|
+
"DIVEBaseTool.onPointerDown: Unknown button: " + t.button
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
this._lastPointerDown.copy(this._pointer), this._draggable = B(
|
|
1079
|
+
(e = this._intersects[0]) == null ? void 0 : e.object,
|
|
1080
|
+
"isDraggable"
|
|
1081
|
+
) || null;
|
|
1082
|
+
}
|
|
1083
|
+
onDragStart(t) {
|
|
1084
|
+
this._draggable && (this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
1085
|
+
this._dragRaycastOnObjects,
|
|
1086
|
+
!0
|
|
1087
|
+
)), this._intersects.length !== 0 && (this._dragStart.copy(this._intersects[0].point.clone()), this._dragCurrent.copy(this._intersects[0].point.clone()), this._dragEnd.copy(this._dragStart.clone()), this._dragDelta.set(0, 0, 0), this._draggable && this._draggable.onDragStart && (this._draggable.onDragStart({
|
|
1088
|
+
dragStart: this._dragStart,
|
|
1089
|
+
dragCurrent: this._dragCurrent,
|
|
1090
|
+
dragEnd: this._dragEnd,
|
|
1091
|
+
dragDelta: this._dragDelta
|
|
1092
|
+
}), this._dragging = !0, this._controller.enabled = !1)));
|
|
1093
|
+
}
|
|
1094
|
+
onPointerMove(t) {
|
|
1095
|
+
var i;
|
|
1096
|
+
this._pointer.x = t.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(t.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object), this._intersects = this.raycast(this._scene.children);
|
|
1097
|
+
const e = B(
|
|
1098
|
+
(i = this._intersects[0]) == null ? void 0 : i.object,
|
|
1099
|
+
"isHoverable"
|
|
79
1100
|
);
|
|
1101
|
+
if (this._intersects[0] && e) {
|
|
1102
|
+
if (!this._hovered) {
|
|
1103
|
+
e.onPointerEnter && e.onPointerEnter(this._intersects[0]), this._hovered = e;
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (this._hovered.uuid !== e.uuid) {
|
|
1107
|
+
this._hovered.onPointerLeave && this._hovered.onPointerLeave(), e.onPointerEnter && e.onPointerEnter(this._intersects[0]), this._hovered = e;
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
e.onPointerOver && e.onPointerOver(this._intersects[0]), this._hovered = e;
|
|
1111
|
+
} else
|
|
1112
|
+
this._hovered && this._hovered.onPointerLeave && this._hovered.onPointerLeave(), this._hovered = null;
|
|
1113
|
+
this._pointerAnyDown && (this._dragging || this.onDragStart(t), this.onDrag(t));
|
|
80
1114
|
}
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1115
|
+
onDrag(t) {
|
|
1116
|
+
this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
1117
|
+
this._dragRaycastOnObjects,
|
|
1118
|
+
!0
|
|
1119
|
+
));
|
|
1120
|
+
const e = this._intersects[0];
|
|
1121
|
+
e && (this._dragCurrent.copy(e.point.clone()), this._dragEnd.copy(e.point.clone()), this._dragDelta.subVectors(
|
|
1122
|
+
this._dragCurrent.clone(),
|
|
1123
|
+
this._dragStart.clone()
|
|
1124
|
+
), this._draggable && this._draggable.onDrag && this._draggable.onDrag({
|
|
1125
|
+
dragStart: this._dragStart,
|
|
1126
|
+
dragCurrent: this._dragCurrent,
|
|
1127
|
+
dragEnd: this._dragEnd,
|
|
1128
|
+
dragDelta: this._dragDelta
|
|
1129
|
+
}));
|
|
1130
|
+
}
|
|
1131
|
+
onPointerUp(t) {
|
|
1132
|
+
switch (this.pointerWasDragged() || this._dragging ? this._draggable && this.onDragEnd(t) : this.onClick(t), t.button) {
|
|
1133
|
+
case 0:
|
|
1134
|
+
this._pointerPrimaryDown = !1;
|
|
1135
|
+
break;
|
|
1136
|
+
case 1:
|
|
1137
|
+
this._pointerMiddleDown = !1;
|
|
1138
|
+
break;
|
|
1139
|
+
case 2:
|
|
1140
|
+
this._pointerSecondaryDown = !1;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
this._lastPointerUp.copy(this._pointer);
|
|
1144
|
+
}
|
|
1145
|
+
onClick(t) {
|
|
1146
|
+
}
|
|
1147
|
+
onDragEnd(t) {
|
|
1148
|
+
const e = this._intersects[0];
|
|
1149
|
+
e && (this._dragEnd.copy(e.point.clone()), this._dragCurrent.copy(e.point.clone()), this._dragDelta.subVectors(
|
|
1150
|
+
this._dragCurrent.clone(),
|
|
1151
|
+
this._dragStart.clone()
|
|
1152
|
+
)), this._draggable && this._draggable.onDragEnd && this._draggable.onDragEnd({
|
|
1153
|
+
dragStart: this._dragStart,
|
|
1154
|
+
dragCurrent: this._dragCurrent,
|
|
1155
|
+
dragEnd: this._dragEnd,
|
|
1156
|
+
dragDelta: this._dragDelta
|
|
1157
|
+
}), this._draggable = null, this._dragging = !1, this._dragStart.set(0, 0, 0), this._dragCurrent.set(0, 0, 0), this._dragEnd.set(0, 0, 0), this._dragDelta.set(0, 0, 0), this._controller.enabled = !0;
|
|
1158
|
+
}
|
|
1159
|
+
onWheel(t) {
|
|
1160
|
+
}
|
|
1161
|
+
raycast(t) {
|
|
1162
|
+
const i = (t || this._scene.children).filter(
|
|
1163
|
+
(n) => n.visible && "isMesh" in n && n.isMesh
|
|
94
1164
|
);
|
|
1165
|
+
return this._raycaster.intersectObjects(i, !0);
|
|
1166
|
+
}
|
|
1167
|
+
pointerWasDragged() {
|
|
1168
|
+
return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
|
|
95
1169
|
}
|
|
96
1170
|
}
|
|
97
|
-
n(r, "DefaultTool", "select");
|
|
98
1171
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1172
|
+
pe as DIVEBaseTool,
|
|
1173
|
+
Wt as DIVESelectTool,
|
|
1174
|
+
Jt as DIVETransformTool,
|
|
1175
|
+
ee as DragTool,
|
|
1176
|
+
Gt as HoverTool,
|
|
1177
|
+
Wt as SelectTool,
|
|
1178
|
+
Zt as SelectionState,
|
|
1179
|
+
de as Toolbox,
|
|
1180
|
+
Jt as TransformTool,
|
|
1181
|
+
he as isSelectTool,
|
|
1182
|
+
ce as isTransformTool
|
|
105
1183
|
};
|