@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,718 +0,0 @@
|
|
|
1
|
-
var jt = Object.defineProperty;
|
|
2
|
-
var Xt = (r, i, t) => i in r ? jt(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
|
|
3
|
-
var c = (r, i, t) => Xt(r, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
-
import "./FileTypes-D_r2gn3i.mjs";
|
|
5
|
-
import { Object3D as st, Vector3 as a, Quaternion as E, Raycaster as bt, MeshBasicMaterial as St, LineBasicMaterial as Yt, CylinderGeometry as w, BoxGeometry as f, BufferGeometry as lt, Float32BufferAttribute as ht, Mesh as o, OctahedronGeometry as B, Line as I, TorusGeometry as C, SphereGeometry as Qt, Euler as Zt, Matrix4 as vt, PlaneGeometry as Ht, DoubleSide as Ot, Vector2 as tt } from "three";
|
|
6
|
-
import { f as ot, i as et } from "./findInterface-DbJ5qzbc.mjs";
|
|
7
|
-
import { P as Ct, U as kt } from "./PerspectiveCamera-BFzE2TQU.mjs";
|
|
8
|
-
import { A as ct, a as dt, b as pt } from "./AxisHelperColors-JLBHYQDi.mjs";
|
|
9
|
-
const j = new bt(), u = new a(), T = new a(), d = new E(), ut = {
|
|
10
|
-
X: new a(1, 0, 0),
|
|
11
|
-
Y: new a(0, 1, 0),
|
|
12
|
-
Z: new a(0, 0, 1)
|
|
13
|
-
}, it = { type: "change" }, mt = { type: "mouseDown" }, ft = { type: "mouseUp", mode: null }, _t = { type: "objectChange" };
|
|
14
|
-
class Lt extends st {
|
|
15
|
-
constructor(i, t) {
|
|
16
|
-
super(), t === void 0 && (console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'), t = document), this.isTransformControls = !0, this.visible = !1, this.domElement = t, this.domElement.style.touchAction = "none";
|
|
17
|
-
const n = new Ut();
|
|
18
|
-
this._gizmo = n, this.add(n);
|
|
19
|
-
const s = new Vt();
|
|
20
|
-
this._plane = s, this.add(s);
|
|
21
|
-
const l = this;
|
|
22
|
-
function e(m, b) {
|
|
23
|
-
let Q = b;
|
|
24
|
-
Object.defineProperty(l, m, {
|
|
25
|
-
get: function() {
|
|
26
|
-
return Q !== void 0 ? Q : b;
|
|
27
|
-
},
|
|
28
|
-
set: function(A) {
|
|
29
|
-
Q !== A && (Q = A, s[m] = A, n[m] = A, l.dispatchEvent({ type: m + "-changed", value: A }), l.dispatchEvent(it));
|
|
30
|
-
}
|
|
31
|
-
}), l[m] = b, s[m] = b, n[m] = b;
|
|
32
|
-
}
|
|
33
|
-
e("camera", i), e("object", void 0), e("enabled", !0), e("axis", null), e("mode", "translate"), e("translationSnap", null), e("rotationSnap", null), e("scaleSnap", null), e("space", "world"), e("size", 1), e("dragging", !1), e("showX", !0), e("showY", !0), e("showZ", !0);
|
|
34
|
-
const p = new a(), g = new a(), z = new E(), Y = new E(), H = new a(), O = new E(), at = new a(), q = new a(), M = new a(), x = 0, v = new a();
|
|
35
|
-
e("worldPosition", p), e("worldPositionStart", g), e("worldQuaternion", z), e("worldQuaternionStart", Y), e("cameraPosition", H), e("cameraQuaternion", O), e("pointStart", at), e("pointEnd", q), e("rotationAxis", M), e("rotationAngle", x), e("eye", v), this._offset = new a(), this._startNorm = new a(), this._endNorm = new a(), this._cameraScale = new a(), this._parentPosition = new a(), this._parentQuaternion = new E(), this._parentQuaternionInv = new E(), this._parentScale = new a(), this._worldScaleStart = new a(), this._worldQuaternionInv = new E(), this._worldScale = new a(), this._positionStart = new a(), this._quaternionStart = new E(), this._scaleStart = new a(), this._getPointer = Rt.bind(this), this._onPointerDown = qt.bind(this), this._onPointerHover = Gt.bind(this), this._onPointerMove = Wt.bind(this), this._onPointerUp = Ft.bind(this), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp);
|
|
36
|
-
}
|
|
37
|
-
// updateMatrixWorld updates key transformation variables
|
|
38
|
-
updateMatrixWorld(i) {
|
|
39
|
-
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(i);
|
|
40
|
-
}
|
|
41
|
-
pointerHover(i) {
|
|
42
|
-
if (this.object === void 0 || this.dragging === !0) return;
|
|
43
|
-
i !== null && j.setFromCamera(i, this.camera);
|
|
44
|
-
const t = nt(this._gizmo.picker[this.mode], j);
|
|
45
|
-
t ? this.axis = t.object.name : this.axis = null;
|
|
46
|
-
}
|
|
47
|
-
pointerDown(i) {
|
|
48
|
-
if (!(this.object === void 0 || this.dragging === !0 || i != null && i.button !== 0) && this.axis !== null) {
|
|
49
|
-
i !== null && j.setFromCamera(i, this.camera);
|
|
50
|
-
const t = nt(this._plane, j, !0);
|
|
51
|
-
t && (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(t.point).sub(this.worldPositionStart)), this.dragging = !0, mt.mode = this.mode, this.dispatchEvent(mt);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
pointerMove(i) {
|
|
55
|
-
const t = this.axis, n = this.mode, s = this.object;
|
|
56
|
-
let l = this.space;
|
|
57
|
-
if (n === "scale" ? l = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (l = "world"), s === void 0 || t === null || this.dragging === !1 || i !== null && i.button !== -1) return;
|
|
58
|
-
i !== null && j.setFromCamera(i, this.camera);
|
|
59
|
-
const e = nt(this._plane, j, !0);
|
|
60
|
-
if (e) {
|
|
61
|
-
if (this.pointEnd.copy(e.point).sub(this.worldPositionStart), n === "translate")
|
|
62
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart), l === "local" && t !== "XYZ" && this._offset.applyQuaternion(this._worldQuaternionInv), t.indexOf("X") === -1 && (this._offset.x = 0), t.indexOf("Y") === -1 && (this._offset.y = 0), t.indexOf("Z") === -1 && (this._offset.z = 0), l === "local" && t !== "XYZ" ? this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale) : this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale), s.position.copy(this._offset).add(this._positionStart), this.translationSnap && (l === "local" && (s.position.applyQuaternion(d.copy(this._quaternionStart).invert()), t.search("X") !== -1 && (s.position.x = Math.round(s.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (s.position.y = Math.round(s.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (s.position.z = Math.round(s.position.z / this.translationSnap) * this.translationSnap), s.position.applyQuaternion(this._quaternionStart)), l === "world" && (s.parent && s.position.add(u.setFromMatrixPosition(s.parent.matrixWorld)), t.search("X") !== -1 && (s.position.x = Math.round(s.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (s.position.y = Math.round(s.position.y / this.translationSnap) * this.translationSnap), t.search("Z") !== -1 && (s.position.z = Math.round(s.position.z / this.translationSnap) * this.translationSnap), s.parent && s.position.sub(u.setFromMatrixPosition(s.parent.matrixWorld))));
|
|
63
|
-
else if (n === "scale") {
|
|
64
|
-
if (t.search("XYZ") !== -1) {
|
|
65
|
-
let p = this.pointEnd.length() / this.pointStart.length();
|
|
66
|
-
this.pointEnd.dot(this.pointStart) < 0 && (p *= -1), T.set(p, p, p);
|
|
67
|
-
} else
|
|
68
|
-
u.copy(this.pointStart), T.copy(this.pointEnd), u.applyQuaternion(this._worldQuaternionInv), T.applyQuaternion(this._worldQuaternionInv), T.divide(u), t.search("X") === -1 && (T.x = 1), t.search("Y") === -1 && (T.y = 1), t.search("Z") === -1 && (T.z = 1);
|
|
69
|
-
s.scale.copy(this._scaleStart).multiply(T), this.scaleSnap && (t.search("X") !== -1 && (s.scale.x = Math.round(s.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (s.scale.y = Math.round(s.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (s.scale.z = Math.round(s.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
70
|
-
} else if (n === "rotate") {
|
|
71
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
72
|
-
const p = 20 / this.worldPosition.distanceTo(u.setFromMatrixPosition(this.camera.matrixWorld));
|
|
73
|
-
let g = !1;
|
|
74
|
-
t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(u.copy(this.rotationAxis).cross(this.eye)) * p) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(ut[t]), u.copy(ut[t]), l === "local" && u.applyQuaternion(this.worldQuaternion), u.cross(this.eye), u.length() === 0 ? g = !0 : this.rotationAngle = this._offset.dot(u.normalize()) * p), (t === "E" || g) && (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), l === "local" && t !== "E" && t !== "XYZE" ? (s.quaternion.copy(this._quaternionStart), s.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this._parentQuaternionInv), s.quaternion.copy(d.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), s.quaternion.multiply(this._quaternionStart).normalize());
|
|
75
|
-
}
|
|
76
|
-
this.dispatchEvent(it), this.dispatchEvent(_t);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
pointerUp(i) {
|
|
80
|
-
i !== null && i.button !== 0 || (this.dragging && this.axis !== null && (ft.mode = this.mode, this.dispatchEvent(ft)), this.dragging = !1, this.axis = null);
|
|
81
|
-
}
|
|
82
|
-
dispose() {
|
|
83
|
-
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(i) {
|
|
84
|
-
i.geometry && i.geometry.dispose(), i.material && i.material.dispose();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
// Set current object
|
|
88
|
-
attach(i) {
|
|
89
|
-
return this.object = i, this.visible = !0, this;
|
|
90
|
-
}
|
|
91
|
-
// Detach from object
|
|
92
|
-
detach() {
|
|
93
|
-
return this.object = void 0, this.visible = !1, this.axis = null, this;
|
|
94
|
-
}
|
|
95
|
-
reset() {
|
|
96
|
-
this.enabled && this.dragging && (this.object.position.copy(this._positionStart), this.object.quaternion.copy(this._quaternionStart), this.object.scale.copy(this._scaleStart), this.dispatchEvent(it), this.dispatchEvent(_t), this.pointStart.copy(this.pointEnd));
|
|
97
|
-
}
|
|
98
|
-
getRaycaster() {
|
|
99
|
-
return j;
|
|
100
|
-
}
|
|
101
|
-
// TODO: deprecate
|
|
102
|
-
getMode() {
|
|
103
|
-
return this.mode;
|
|
104
|
-
}
|
|
105
|
-
setMode(i) {
|
|
106
|
-
this.mode = i;
|
|
107
|
-
}
|
|
108
|
-
setTranslationSnap(i) {
|
|
109
|
-
this.translationSnap = i;
|
|
110
|
-
}
|
|
111
|
-
setRotationSnap(i) {
|
|
112
|
-
this.rotationSnap = i;
|
|
113
|
-
}
|
|
114
|
-
setScaleSnap(i) {
|
|
115
|
-
this.scaleSnap = i;
|
|
116
|
-
}
|
|
117
|
-
setSize(i) {
|
|
118
|
-
this.size = i;
|
|
119
|
-
}
|
|
120
|
-
setSpace(i) {
|
|
121
|
-
this.space = i;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function Rt(r) {
|
|
125
|
-
if (this.domElement.ownerDocument.pointerLockElement)
|
|
126
|
-
return {
|
|
127
|
-
x: 0,
|
|
128
|
-
y: 0,
|
|
129
|
-
button: r.button
|
|
130
|
-
};
|
|
131
|
-
{
|
|
132
|
-
const i = this.domElement.getBoundingClientRect();
|
|
133
|
-
return {
|
|
134
|
-
x: (r.clientX - i.left) / i.width * 2 - 1,
|
|
135
|
-
y: -(r.clientY - i.top) / i.height * 2 + 1,
|
|
136
|
-
button: r.button
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function Gt(r) {
|
|
141
|
-
if (this.enabled)
|
|
142
|
-
switch (r.pointerType) {
|
|
143
|
-
case "mouse":
|
|
144
|
-
case "pen":
|
|
145
|
-
this.pointerHover(this._getPointer(r));
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function qt(r) {
|
|
150
|
-
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(r.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(r)), this.pointerDown(this._getPointer(r)));
|
|
151
|
-
}
|
|
152
|
-
function Wt(r) {
|
|
153
|
-
this.enabled && this.pointerMove(this._getPointer(r));
|
|
154
|
-
}
|
|
155
|
-
function Ft(r) {
|
|
156
|
-
this.enabled && (this.domElement.releasePointerCapture(r.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(r)));
|
|
157
|
-
}
|
|
158
|
-
function nt(r, i, t) {
|
|
159
|
-
const n = i.intersectObject(r, !0);
|
|
160
|
-
for (let s = 0; s < n.length; s++)
|
|
161
|
-
if (n[s].object.visible || t)
|
|
162
|
-
return n[s];
|
|
163
|
-
return !1;
|
|
164
|
-
}
|
|
165
|
-
const N = new Zt(), h = new a(0, 1, 0), wt = new a(0, 0, 0), gt = new vt(), K = new E(), $ = new E(), P = new a(), yt = new vt(), R = new a(1, 0, 0), X = new a(0, 1, 0), G = new a(0, 0, 1), J = new a(), k = new a(), L = new a();
|
|
166
|
-
class Ut extends st {
|
|
167
|
-
constructor() {
|
|
168
|
-
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
169
|
-
const i = new St({
|
|
170
|
-
depthTest: !1,
|
|
171
|
-
depthWrite: !1,
|
|
172
|
-
fog: !1,
|
|
173
|
-
toneMapped: !1,
|
|
174
|
-
transparent: !0
|
|
175
|
-
}), t = new Yt({
|
|
176
|
-
depthTest: !1,
|
|
177
|
-
depthWrite: !1,
|
|
178
|
-
fog: !1,
|
|
179
|
-
toneMapped: !1,
|
|
180
|
-
transparent: !0
|
|
181
|
-
}), n = i.clone();
|
|
182
|
-
n.opacity = 0.15;
|
|
183
|
-
const s = t.clone();
|
|
184
|
-
s.opacity = 0.5;
|
|
185
|
-
const l = i.clone();
|
|
186
|
-
l.color.setHex(16711680);
|
|
187
|
-
const e = i.clone();
|
|
188
|
-
e.color.setHex(65280);
|
|
189
|
-
const p = i.clone();
|
|
190
|
-
p.color.setHex(255);
|
|
191
|
-
const g = i.clone();
|
|
192
|
-
g.color.setHex(16711680), g.opacity = 0.5;
|
|
193
|
-
const z = i.clone();
|
|
194
|
-
z.color.setHex(65280), z.opacity = 0.5;
|
|
195
|
-
const Y = i.clone();
|
|
196
|
-
Y.color.setHex(255), Y.opacity = 0.5;
|
|
197
|
-
const H = i.clone();
|
|
198
|
-
H.opacity = 0.25;
|
|
199
|
-
const O = i.clone();
|
|
200
|
-
O.color.setHex(16776960), O.opacity = 0.25, i.clone().color.setHex(16776960);
|
|
201
|
-
const q = i.clone();
|
|
202
|
-
q.color.setHex(7895160);
|
|
203
|
-
const M = new w(0, 0.04, 0.1, 12);
|
|
204
|
-
M.translate(0, 0.05, 0);
|
|
205
|
-
const x = new f(0.08, 0.08, 0.08);
|
|
206
|
-
x.translate(0, 0.04, 0);
|
|
207
|
-
const v = new lt();
|
|
208
|
-
v.setAttribute("position", new ht([0, 0, 0, 1, 0, 0], 3));
|
|
209
|
-
const m = new w(75e-4, 75e-4, 0.5, 3);
|
|
210
|
-
m.translate(0, 0.25, 0);
|
|
211
|
-
function b(y, W) {
|
|
212
|
-
const S = new C(y, 75e-4, 3, 64, W * Math.PI * 2);
|
|
213
|
-
return S.rotateY(Math.PI / 2), S.rotateX(Math.PI / 2), S;
|
|
214
|
-
}
|
|
215
|
-
function Q() {
|
|
216
|
-
const y = new lt();
|
|
217
|
-
return y.setAttribute("position", new ht([0, 0, 0, 1, 1, 1], 3)), y;
|
|
218
|
-
}
|
|
219
|
-
const A = {
|
|
220
|
-
X: [
|
|
221
|
-
[new o(M, l), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
222
|
-
[new o(M, l), [-0.5, 0, 0], [0, 0, Math.PI / 2]],
|
|
223
|
-
[new o(m, l), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
224
|
-
],
|
|
225
|
-
Y: [
|
|
226
|
-
[new o(M, e), [0, 0.5, 0]],
|
|
227
|
-
[new o(M, e), [0, -0.5, 0], [Math.PI, 0, 0]],
|
|
228
|
-
[new o(m, e)]
|
|
229
|
-
],
|
|
230
|
-
Z: [
|
|
231
|
-
[new o(M, p), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
232
|
-
[new o(M, p), [0, 0, -0.5], [-Math.PI / 2, 0, 0]],
|
|
233
|
-
[new o(m, p), null, [Math.PI / 2, 0, 0]]
|
|
234
|
-
],
|
|
235
|
-
XYZ: [
|
|
236
|
-
[new o(new B(0.1, 0), H.clone()), [0, 0, 0]]
|
|
237
|
-
],
|
|
238
|
-
XY: [
|
|
239
|
-
[new o(new f(0.15, 0.15, 0.01), Y.clone()), [0.15, 0.15, 0]]
|
|
240
|
-
],
|
|
241
|
-
YZ: [
|
|
242
|
-
[new o(new f(0.15, 0.15, 0.01), g.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
243
|
-
],
|
|
244
|
-
XZ: [
|
|
245
|
-
[new o(new f(0.15, 0.15, 0.01), z.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
246
|
-
]
|
|
247
|
-
}, Pt = {
|
|
248
|
-
X: [
|
|
249
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
250
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
251
|
-
],
|
|
252
|
-
Y: [
|
|
253
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0.3, 0]],
|
|
254
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
255
|
-
],
|
|
256
|
-
Z: [
|
|
257
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
258
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
259
|
-
],
|
|
260
|
-
XYZ: [
|
|
261
|
-
[new o(new B(0.2, 0), n)]
|
|
262
|
-
],
|
|
263
|
-
XY: [
|
|
264
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0.15, 0.15, 0]]
|
|
265
|
-
],
|
|
266
|
-
YZ: [
|
|
267
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
268
|
-
],
|
|
269
|
-
XZ: [
|
|
270
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
271
|
-
]
|
|
272
|
-
}, Et = {
|
|
273
|
-
START: [
|
|
274
|
-
[new o(new B(0.01, 2), s), null, null, null, "helper"]
|
|
275
|
-
],
|
|
276
|
-
END: [
|
|
277
|
-
[new o(new B(0.01, 2), s), null, null, null, "helper"]
|
|
278
|
-
],
|
|
279
|
-
DELTA: [
|
|
280
|
-
[new I(Q(), s), null, null, null, "helper"]
|
|
281
|
-
],
|
|
282
|
-
X: [
|
|
283
|
-
[new I(v, s.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
284
|
-
],
|
|
285
|
-
Y: [
|
|
286
|
-
[new I(v, s.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
287
|
-
],
|
|
288
|
-
Z: [
|
|
289
|
-
[new I(v, s.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
290
|
-
]
|
|
291
|
-
}, Mt = {
|
|
292
|
-
XYZE: [
|
|
293
|
-
[new o(b(0.5, 1), q), null, [0, Math.PI / 2, 0]]
|
|
294
|
-
],
|
|
295
|
-
X: [
|
|
296
|
-
[new o(b(0.5, 0.5), l)]
|
|
297
|
-
],
|
|
298
|
-
Y: [
|
|
299
|
-
[new o(b(0.5, 0.5), e), null, [0, 0, -Math.PI / 2]]
|
|
300
|
-
],
|
|
301
|
-
Z: [
|
|
302
|
-
[new o(b(0.5, 0.5), p), null, [0, Math.PI / 2, 0]]
|
|
303
|
-
],
|
|
304
|
-
E: [
|
|
305
|
-
[new o(b(0.75, 1), O), null, [0, Math.PI / 2, 0]]
|
|
306
|
-
]
|
|
307
|
-
}, xt = {
|
|
308
|
-
AXIS: [
|
|
309
|
-
[new I(v, s.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
310
|
-
]
|
|
311
|
-
}, Dt = {
|
|
312
|
-
XYZE: [
|
|
313
|
-
[new o(new Qt(0.25, 10, 8), n)]
|
|
314
|
-
],
|
|
315
|
-
X: [
|
|
316
|
-
[new o(new C(0.5, 0.1, 4, 24), n), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
317
|
-
],
|
|
318
|
-
Y: [
|
|
319
|
-
[new o(new C(0.5, 0.1, 4, 24), n), [0, 0, 0], [Math.PI / 2, 0, 0]]
|
|
320
|
-
],
|
|
321
|
-
Z: [
|
|
322
|
-
[new o(new C(0.5, 0.1, 4, 24), n), [0, 0, 0], [0, 0, -Math.PI / 2]]
|
|
323
|
-
],
|
|
324
|
-
E: [
|
|
325
|
-
[new o(new C(0.75, 0.1, 2, 24), n)]
|
|
326
|
-
]
|
|
327
|
-
}, It = {
|
|
328
|
-
X: [
|
|
329
|
-
[new o(x, l), [0.5, 0, 0], [0, 0, -Math.PI / 2]],
|
|
330
|
-
[new o(m, l), [0, 0, 0], [0, 0, -Math.PI / 2]],
|
|
331
|
-
[new o(x, l), [-0.5, 0, 0], [0, 0, Math.PI / 2]]
|
|
332
|
-
],
|
|
333
|
-
Y: [
|
|
334
|
-
[new o(x, e), [0, 0.5, 0]],
|
|
335
|
-
[new o(m, e)],
|
|
336
|
-
[new o(x, e), [0, -0.5, 0], [0, 0, Math.PI]]
|
|
337
|
-
],
|
|
338
|
-
Z: [
|
|
339
|
-
[new o(x, p), [0, 0, 0.5], [Math.PI / 2, 0, 0]],
|
|
340
|
-
[new o(m, p), [0, 0, 0], [Math.PI / 2, 0, 0]],
|
|
341
|
-
[new o(x, p), [0, 0, -0.5], [-Math.PI / 2, 0, 0]]
|
|
342
|
-
],
|
|
343
|
-
XY: [
|
|
344
|
-
[new o(new f(0.15, 0.15, 0.01), Y), [0.15, 0.15, 0]]
|
|
345
|
-
],
|
|
346
|
-
YZ: [
|
|
347
|
-
[new o(new f(0.15, 0.15, 0.01), g), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
348
|
-
],
|
|
349
|
-
XZ: [
|
|
350
|
-
[new o(new f(0.15, 0.15, 0.01), z), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
351
|
-
],
|
|
352
|
-
XYZ: [
|
|
353
|
-
[new o(new f(0.1, 0.1, 0.1), H.clone())]
|
|
354
|
-
]
|
|
355
|
-
}, Tt = {
|
|
356
|
-
X: [
|
|
357
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
358
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
359
|
-
],
|
|
360
|
-
Y: [
|
|
361
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0.3, 0]],
|
|
362
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, -0.3, 0], [0, 0, Math.PI]]
|
|
363
|
-
],
|
|
364
|
-
Z: [
|
|
365
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0, 0.3], [Math.PI / 2, 0, 0]],
|
|
366
|
-
[new o(new w(0.2, 0, 0.6, 4), n), [0, 0, -0.3], [-Math.PI / 2, 0, 0]]
|
|
367
|
-
],
|
|
368
|
-
XY: [
|
|
369
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0.15, 0.15, 0]]
|
|
370
|
-
],
|
|
371
|
-
YZ: [
|
|
372
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0, 0.15, 0.15], [0, Math.PI / 2, 0]]
|
|
373
|
-
],
|
|
374
|
-
XZ: [
|
|
375
|
-
[new o(new f(0.2, 0.2, 0.01), n), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
376
|
-
],
|
|
377
|
-
XYZ: [
|
|
378
|
-
[new o(new f(0.2, 0.2, 0.2), n), [0, 0, 0]]
|
|
379
|
-
]
|
|
380
|
-
}, zt = {
|
|
381
|
-
X: [
|
|
382
|
-
[new I(v, s.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
383
|
-
],
|
|
384
|
-
Y: [
|
|
385
|
-
[new I(v, s.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]
|
|
386
|
-
],
|
|
387
|
-
Z: [
|
|
388
|
-
[new I(v, s.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]
|
|
389
|
-
]
|
|
390
|
-
};
|
|
391
|
-
function D(y) {
|
|
392
|
-
const W = new st();
|
|
393
|
-
for (const S in y)
|
|
394
|
-
for (let Z = y[S].length; Z--; ) {
|
|
395
|
-
const _ = y[S][Z][0].clone(), F = y[S][Z][1], U = y[S][Z][2], V = y[S][Z][3], At = y[S][Z][4];
|
|
396
|
-
_.name = S, _.tag = At, F && _.position.set(F[0], F[1], F[2]), U && _.rotation.set(U[0], U[1], U[2]), V && _.scale.set(V[0], V[1], V[2]), _.updateMatrix();
|
|
397
|
-
const rt = _.geometry.clone();
|
|
398
|
-
rt.applyMatrix4(_.matrix), _.geometry = rt, _.renderOrder = 1 / 0, _.position.set(0, 0, 0), _.rotation.set(0, 0, 0), _.scale.set(1, 1, 1), W.add(_);
|
|
399
|
-
}
|
|
400
|
-
return W;
|
|
401
|
-
}
|
|
402
|
-
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = D(A)), this.add(this.gizmo.rotate = D(Mt)), this.add(this.gizmo.scale = D(It)), this.add(this.picker.translate = D(Pt)), this.add(this.picker.rotate = D(Dt)), this.add(this.picker.scale = D(Tt)), this.add(this.helper.translate = D(Et)), this.add(this.helper.rotate = D(xt)), this.add(this.helper.scale = D(zt)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
403
|
-
}
|
|
404
|
-
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
405
|
-
updateMatrixWorld(i) {
|
|
406
|
-
const n = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : $;
|
|
407
|
-
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";
|
|
408
|
-
let s = [];
|
|
409
|
-
s = s.concat(this.picker[this.mode].children), s = s.concat(this.gizmo[this.mode].children), s = s.concat(this.helper[this.mode].children);
|
|
410
|
-
for (let l = 0; l < s.length; l++) {
|
|
411
|
-
const e = s[l];
|
|
412
|
-
e.visible = !0, e.rotation.set(0, 0, 0), e.position.copy(this.worldPosition);
|
|
413
|
-
let p;
|
|
414
|
-
if (this.camera.isOrthographicCamera ? p = (this.camera.top - this.camera.bottom) / this.camera.zoom : p = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), e.scale.set(1, 1, 1).multiplyScalar(p * this.size / 4), e.tag === "helper") {
|
|
415
|
-
e.visible = !1, e.name === "AXIS" ? (e.visible = !!this.axis, this.axis === "X" && (d.setFromEuler(N.set(0, 0, 0)), e.quaternion.copy(n).multiply(d), Math.abs(h.copy(R).applyQuaternion(n).dot(this.eye)) > 0.9 && (e.visible = !1)), this.axis === "Y" && (d.setFromEuler(N.set(0, 0, Math.PI / 2)), e.quaternion.copy(n).multiply(d), Math.abs(h.copy(X).applyQuaternion(n).dot(this.eye)) > 0.9 && (e.visible = !1)), this.axis === "Z" && (d.setFromEuler(N.set(0, Math.PI / 2, 0)), e.quaternion.copy(n).multiply(d), Math.abs(h.copy(G).applyQuaternion(n).dot(this.eye)) > 0.9 && (e.visible = !1)), this.axis === "XYZE" && (d.setFromEuler(N.set(0, Math.PI / 2, 0)), h.copy(this.rotationAxis), e.quaternion.setFromRotationMatrix(gt.lookAt(wt, h, X)), e.quaternion.multiply(d), e.visible = this.dragging), this.axis === "E" && (e.visible = !1)) : e.name === "START" ? (e.position.copy(this.worldPositionStart), e.visible = this.dragging) : e.name === "END" ? (e.position.copy(this.worldPosition), e.visible = this.dragging) : e.name === "DELTA" ? (e.position.copy(this.worldPositionStart), e.quaternion.copy(this.worldQuaternionStart), u.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), u.applyQuaternion(this.worldQuaternionStart.clone().invert()), e.scale.copy(u), e.visible = this.dragging) : (e.quaternion.copy(n), this.dragging ? e.position.copy(this.worldPositionStart) : e.position.copy(this.worldPosition), this.axis && (e.visible = this.axis.search(e.name) !== -1));
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
e.quaternion.copy(n), this.mode === "translate" || this.mode === "scale" ? (e.name === "X" && Math.abs(h.copy(R).applyQuaternion(n).dot(this.eye)) > 0.99 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1), e.name === "Y" && Math.abs(h.copy(X).applyQuaternion(n).dot(this.eye)) > 0.99 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1), e.name === "Z" && Math.abs(h.copy(G).applyQuaternion(n).dot(this.eye)) > 0.99 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1), e.name === "XY" && Math.abs(h.copy(G).applyQuaternion(n).dot(this.eye)) < 0.2 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1), e.name === "YZ" && Math.abs(h.copy(R).applyQuaternion(n).dot(this.eye)) < 0.2 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1), e.name === "XZ" && Math.abs(h.copy(X).applyQuaternion(n).dot(this.eye)) < 0.2 && (e.scale.set(1e-10, 1e-10, 1e-10), e.visible = !1)) : this.mode === "rotate" && (K.copy(n), h.copy(this.eye).applyQuaternion(d.copy(n).invert()), e.name.search("E") !== -1 && e.quaternion.setFromRotationMatrix(gt.lookAt(this.eye, wt, X)), e.name === "X" && (d.setFromAxisAngle(R, Math.atan2(-h.y, h.z)), d.multiplyQuaternions(K, d), e.quaternion.copy(d)), e.name === "Y" && (d.setFromAxisAngle(X, Math.atan2(h.x, h.z)), d.multiplyQuaternions(K, d), e.quaternion.copy(d)), e.name === "Z" && (d.setFromAxisAngle(G, Math.atan2(h.y, h.x)), d.multiplyQuaternions(K, d), e.quaternion.copy(d))), e.visible = e.visible && (e.name.indexOf("X") === -1 || this.showX), e.visible = e.visible && (e.name.indexOf("Y") === -1 || this.showY), e.visible = e.visible && (e.name.indexOf("Z") === -1 || this.showZ), e.visible = e.visible && (e.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), e.material._color = e.material._color || e.material.color.clone(), e.material._opacity = e.material._opacity || e.material.opacity, e.material.color.copy(e.material._color), e.material.opacity = e.material._opacity, this.enabled && this.axis && (e.name === this.axis || this.axis.split("").some(function(g) {
|
|
419
|
-
return e.name === g;
|
|
420
|
-
})) && (e.material.color.setHex(16776960), e.material.opacity = 1);
|
|
421
|
-
}
|
|
422
|
-
super.updateMatrixWorld(i);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
class Vt extends o {
|
|
426
|
-
constructor() {
|
|
427
|
-
super(
|
|
428
|
-
new Ht(1e5, 1e5, 2, 2),
|
|
429
|
-
new St({ visible: !1, wireframe: !0, side: Ot, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
430
|
-
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
431
|
-
}
|
|
432
|
-
updateMatrixWorld(i) {
|
|
433
|
-
let t = this.space;
|
|
434
|
-
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), J.copy(R).applyQuaternion(t === "local" ? this.worldQuaternion : $), k.copy(X).applyQuaternion(t === "local" ? this.worldQuaternion : $), L.copy(G).applyQuaternion(t === "local" ? this.worldQuaternion : $), h.copy(k), this.mode) {
|
|
435
|
-
case "translate":
|
|
436
|
-
case "scale":
|
|
437
|
-
switch (this.axis) {
|
|
438
|
-
case "X":
|
|
439
|
-
h.copy(this.eye).cross(J), P.copy(J).cross(h);
|
|
440
|
-
break;
|
|
441
|
-
case "Y":
|
|
442
|
-
h.copy(this.eye).cross(k), P.copy(k).cross(h);
|
|
443
|
-
break;
|
|
444
|
-
case "Z":
|
|
445
|
-
h.copy(this.eye).cross(L), P.copy(L).cross(h);
|
|
446
|
-
break;
|
|
447
|
-
case "XY":
|
|
448
|
-
P.copy(L);
|
|
449
|
-
break;
|
|
450
|
-
case "YZ":
|
|
451
|
-
P.copy(J);
|
|
452
|
-
break;
|
|
453
|
-
case "XZ":
|
|
454
|
-
h.copy(L), P.copy(k);
|
|
455
|
-
break;
|
|
456
|
-
case "XYZ":
|
|
457
|
-
case "E":
|
|
458
|
-
P.set(0, 0, 0);
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
break;
|
|
462
|
-
case "rotate":
|
|
463
|
-
default:
|
|
464
|
-
P.set(0, 0, 0);
|
|
465
|
-
}
|
|
466
|
-
P.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (yt.lookAt(u.set(0, 0, 0), P, h), this.quaternion.setFromRotationMatrix(yt)), super.updateMatrixWorld(i);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
class Bt {
|
|
470
|
-
constructor(i, t) {
|
|
471
|
-
c(this, "POINTER_DRAG_THRESHOLD", 1e-3);
|
|
472
|
-
c(this, "name");
|
|
473
|
-
c(this, "_canvas");
|
|
474
|
-
c(this, "_scene");
|
|
475
|
-
c(this, "_controller");
|
|
476
|
-
// general pointer members
|
|
477
|
-
c(this, "_pointer");
|
|
478
|
-
c(this, "_pointerPrimaryDown");
|
|
479
|
-
c(this, "_pointerMiddleDown");
|
|
480
|
-
c(this, "_pointerSecondaryDown");
|
|
481
|
-
c(this, "_lastPointerDown");
|
|
482
|
-
c(this, "_lastPointerUp");
|
|
483
|
-
// raycast members
|
|
484
|
-
c(this, "_raycaster");
|
|
485
|
-
c(this, "_intersects");
|
|
486
|
-
// hovering members
|
|
487
|
-
c(this, "_hovered");
|
|
488
|
-
// dragging members
|
|
489
|
-
c(this, "_dragging");
|
|
490
|
-
c(this, "_dragStart");
|
|
491
|
-
c(this, "_dragCurrent");
|
|
492
|
-
c(this, "_dragEnd");
|
|
493
|
-
c(this, "_dragDelta");
|
|
494
|
-
c(this, "_draggable");
|
|
495
|
-
c(this, "_dragRaycastOnObjects");
|
|
496
|
-
this.name = "BaseTool", this._canvas = t.domElement, this._scene = i, this._controller = t, this._pointer = new tt(), this._pointerPrimaryDown = !1, this._pointerMiddleDown = !1, this._pointerSecondaryDown = !1, this._lastPointerDown = new tt(), this._lastPointerUp = new tt(), this._raycaster = new bt(), this._raycaster.layers.mask = Ct | kt, this._intersects = [], this._hovered = null, this._dragging = !1, this._dragStart = new a(), this._dragCurrent = new a(), this._dragEnd = new a(), this._dragDelta = new a(), this._draggable = null, this._dragRaycastOnObjects = null;
|
|
497
|
-
}
|
|
498
|
-
get _pointerAnyDown() {
|
|
499
|
-
return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
|
|
500
|
-
}
|
|
501
|
-
activate() {
|
|
502
|
-
}
|
|
503
|
-
deactivate() {
|
|
504
|
-
}
|
|
505
|
-
onPointerDown(i) {
|
|
506
|
-
var t;
|
|
507
|
-
switch (i.button) {
|
|
508
|
-
case 0: {
|
|
509
|
-
this._pointerPrimaryDown = !0;
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
case 1: {
|
|
513
|
-
this._pointerMiddleDown = !0;
|
|
514
|
-
break;
|
|
515
|
-
}
|
|
516
|
-
case 2: {
|
|
517
|
-
this._pointerSecondaryDown = !0;
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
default:
|
|
521
|
-
console.warn(
|
|
522
|
-
"DIVEBaseTool.onPointerDown: Unknown button: " + i.button
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
this._lastPointerDown.copy(this._pointer), this._draggable = ot(
|
|
526
|
-
(t = this._intersects[0]) == null ? void 0 : t.object,
|
|
527
|
-
"isDraggable"
|
|
528
|
-
) || null;
|
|
529
|
-
}
|
|
530
|
-
onDragStart(i) {
|
|
531
|
-
this._draggable && (this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
532
|
-
this._dragRaycastOnObjects,
|
|
533
|
-
!0
|
|
534
|
-
)), 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({
|
|
535
|
-
dragStart: this._dragStart,
|
|
536
|
-
dragCurrent: this._dragCurrent,
|
|
537
|
-
dragEnd: this._dragEnd,
|
|
538
|
-
dragDelta: this._dragDelta
|
|
539
|
-
}), this._dragging = !0, this._controller.enabled = !1)));
|
|
540
|
-
}
|
|
541
|
-
onPointerMove(i) {
|
|
542
|
-
var n;
|
|
543
|
-
this._pointer.x = i.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(i.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object), this._intersects = this.raycast(this._scene.children);
|
|
544
|
-
const t = ot(
|
|
545
|
-
(n = this._intersects[0]) == null ? void 0 : n.object,
|
|
546
|
-
"isHoverable"
|
|
547
|
-
);
|
|
548
|
-
if (this._intersects[0] && t) {
|
|
549
|
-
if (!this._hovered) {
|
|
550
|
-
t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
if (this._hovered.uuid !== t.uuid) {
|
|
554
|
-
this._hovered.onPointerLeave && this._hovered.onPointerLeave(), t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
t.onPointerOver && t.onPointerOver(this._intersects[0]), this._hovered = t;
|
|
558
|
-
} else
|
|
559
|
-
this._hovered && this._hovered.onPointerLeave && this._hovered.onPointerLeave(), this._hovered = null;
|
|
560
|
-
this._pointerAnyDown && (this._dragging || this.onDragStart(i), this.onDrag(i));
|
|
561
|
-
}
|
|
562
|
-
onDrag(i) {
|
|
563
|
-
this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
564
|
-
this._dragRaycastOnObjects,
|
|
565
|
-
!0
|
|
566
|
-
));
|
|
567
|
-
const t = this._intersects[0];
|
|
568
|
-
t && (this._dragCurrent.copy(t.point.clone()), this._dragEnd.copy(t.point.clone()), this._dragDelta.subVectors(
|
|
569
|
-
this._dragCurrent.clone(),
|
|
570
|
-
this._dragStart.clone()
|
|
571
|
-
), this._draggable && this._draggable.onDrag && this._draggable.onDrag({
|
|
572
|
-
dragStart: this._dragStart,
|
|
573
|
-
dragCurrent: this._dragCurrent,
|
|
574
|
-
dragEnd: this._dragEnd,
|
|
575
|
-
dragDelta: this._dragDelta
|
|
576
|
-
}));
|
|
577
|
-
}
|
|
578
|
-
onPointerUp(i) {
|
|
579
|
-
switch (this.pointerWasDragged() || this._dragging ? this._draggable && this.onDragEnd(i) : this.onClick(i), i.button) {
|
|
580
|
-
case 0:
|
|
581
|
-
this._pointerPrimaryDown = !1;
|
|
582
|
-
break;
|
|
583
|
-
case 1:
|
|
584
|
-
this._pointerMiddleDown = !1;
|
|
585
|
-
break;
|
|
586
|
-
case 2:
|
|
587
|
-
this._pointerSecondaryDown = !1;
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
this._lastPointerUp.copy(this._pointer);
|
|
591
|
-
}
|
|
592
|
-
onClick(i) {
|
|
593
|
-
}
|
|
594
|
-
onDragEnd(i) {
|
|
595
|
-
const t = this._intersects[0];
|
|
596
|
-
t && (this._dragEnd.copy(t.point.clone()), this._dragCurrent.copy(t.point.clone()), this._dragDelta.subVectors(
|
|
597
|
-
this._dragCurrent.clone(),
|
|
598
|
-
this._dragStart.clone()
|
|
599
|
-
)), this._draggable && this._draggable.onDragEnd && this._draggable.onDragEnd({
|
|
600
|
-
dragStart: this._dragStart,
|
|
601
|
-
dragCurrent: this._dragCurrent,
|
|
602
|
-
dragEnd: this._dragEnd,
|
|
603
|
-
dragDelta: this._dragDelta
|
|
604
|
-
}), 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;
|
|
605
|
-
}
|
|
606
|
-
onWheel(i) {
|
|
607
|
-
}
|
|
608
|
-
raycast(i) {
|
|
609
|
-
return i !== void 0 ? this._raycaster.intersectObjects(i, !0).filter((t) => t.object.visible) : this._raycaster.intersectObjects(this._scene.children, !0).filter((t) => t.object.visible);
|
|
610
|
-
}
|
|
611
|
-
pointerWasDragged() {
|
|
612
|
-
return this._lastPointerDown.distanceTo(this._pointer) > this.POINTER_DRAG_THRESHOLD;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
const ne = (r) => r.isTransformTool !== void 0;
|
|
616
|
-
class Nt extends Bt {
|
|
617
|
-
constructor(t, n) {
|
|
618
|
-
super(t, n);
|
|
619
|
-
c(this, "isTransformTool", !0);
|
|
620
|
-
c(this, "_scaleLinked");
|
|
621
|
-
c(this, "_gizmo");
|
|
622
|
-
this.name = "DIVETransformTool", this._scaleLinked = !1, this._gizmo = this.initGizmo(), this._scene.add(this._gizmo);
|
|
623
|
-
}
|
|
624
|
-
activate() {
|
|
625
|
-
}
|
|
626
|
-
setGizmoMode(t) {
|
|
627
|
-
this._gizmo.mode = t;
|
|
628
|
-
}
|
|
629
|
-
setGizmoVisible(t) {
|
|
630
|
-
const n = this._scene.children.includes(this._gizmo);
|
|
631
|
-
t && !n ? (this._scene.add(this._gizmo), "isTransformControls" in this._gizmo && this._gizmo.getRaycaster().layers.enableAll()) : !t && n && (this._scene.remove(this._gizmo), "isTransformControls" in this._gizmo && this._gizmo.getRaycaster().layers.disableAll());
|
|
632
|
-
}
|
|
633
|
-
setGizmoScaleLinked(t) {
|
|
634
|
-
this._scaleLinked = t;
|
|
635
|
-
}
|
|
636
|
-
// only used for optimizing pointer events with DIVEGizmo
|
|
637
|
-
// public onPointerDown(e: PointerEvent): void {
|
|
638
|
-
// super.onPointerDown(e);
|
|
639
|
-
// if (this._hovered) {
|
|
640
|
-
// this._dragRaycastOnObjects = (
|
|
641
|
-
// this._gizmo as DIVEGizmo
|
|
642
|
-
// ).gizmoPlane?.children;
|
|
643
|
-
// }
|
|
644
|
-
// }
|
|
645
|
-
// only used for optimizing pointer events with DIVEGizmo
|
|
646
|
-
// protected raycast(): Intersection[] {
|
|
647
|
-
// return super.raycast((this._gizmo as DIVEGizmo).gizmoNode.children);
|
|
648
|
-
// }
|
|
649
|
-
initGizmo() {
|
|
650
|
-
const t = new Lt(
|
|
651
|
-
// this._controller,
|
|
652
|
-
this._controller.object,
|
|
653
|
-
this._controller.domElement
|
|
654
|
-
);
|
|
655
|
-
return t.mode = "translate", t.traverse((n) => {
|
|
656
|
-
if (!("isMesh" in n)) return;
|
|
657
|
-
const s = n.material;
|
|
658
|
-
n.name === "X" && s.color.set(ct), n.name === "Y" && s.color.set(dt), n.name === "Z" && s.color.set(pt), n.name === "XY" && s.color.set(pt), n.name === "YZ" && s.color.set(ct), n.name === "XZ" && s.color.set(dt);
|
|
659
|
-
}), t.addEventListener("mouseDown", () => {
|
|
660
|
-
this._controller.enabled = !1, et(t.object, "isMovable") && t.object.onMoveStart && t.object.onMoveStart();
|
|
661
|
-
}), t.addEventListener("objectChange", () => {
|
|
662
|
-
if (et(t.object, "isMovable") && t.object.onMove && (t.object.onMove(), this._scaleLinked)) {
|
|
663
|
-
const n = t.object.scale, s = (n.x + n.y + n.z) / 3;
|
|
664
|
-
t.object.scale.set(s, s, s);
|
|
665
|
-
}
|
|
666
|
-
}), t.addEventListener("mouseUp", () => {
|
|
667
|
-
this._controller.enabled = !0, et(t.object, "isMovable") && t.object.onMoveEnd && t.object.onMoveEnd();
|
|
668
|
-
}), t;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
const se = (r) => r.isSelectTool !== void 0;
|
|
672
|
-
class oe extends Nt {
|
|
673
|
-
constructor(t, n) {
|
|
674
|
-
super(t, n);
|
|
675
|
-
c(this, "isSelectTool", !0);
|
|
676
|
-
this.name = "SelectTool";
|
|
677
|
-
}
|
|
678
|
-
activate() {
|
|
679
|
-
}
|
|
680
|
-
select(t) {
|
|
681
|
-
this.attachGizmo(t), t.onSelect && t.onSelect();
|
|
682
|
-
}
|
|
683
|
-
deselect(t) {
|
|
684
|
-
this.detachGizmo(), t.onDeselect && t.onDeselect();
|
|
685
|
-
}
|
|
686
|
-
attachGizmo(t) {
|
|
687
|
-
if ("isMovable" in t) {
|
|
688
|
-
const n = t;
|
|
689
|
-
this._gizmo.attach(n), this.setGizmoVisible(n.visible);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
detachGizmo() {
|
|
693
|
-
this._gizmo.detach();
|
|
694
|
-
}
|
|
695
|
-
onClick(t) {
|
|
696
|
-
super.onClick(t);
|
|
697
|
-
const n = this._raycaster.intersectObjects(this._scene.root.children, !0).filter((l) => l.object.visible)[0], s = ot(
|
|
698
|
-
n == null ? void 0 : n.object,
|
|
699
|
-
"isSelectable"
|
|
700
|
-
);
|
|
701
|
-
if (!n || !s) {
|
|
702
|
-
this._gizmo.object && this.deselect(this._gizmo.object);
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
if (this._gizmo.object) {
|
|
706
|
-
if (this._gizmo.object.uuid === s.uuid) return;
|
|
707
|
-
this.deselect(this._gizmo.object);
|
|
708
|
-
}
|
|
709
|
-
this.select(s);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
export {
|
|
713
|
-
oe as D,
|
|
714
|
-
Bt as a,
|
|
715
|
-
ne as b,
|
|
716
|
-
Nt as c,
|
|
717
|
-
se as i
|
|
718
|
-
};
|