@shopware-ag/dive 2.2.29 → 2.2.31
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-5v3VEUpV.cjs → AssetCache-USoLeA8n.cjs} +1 -1
- package/build/chunks/{AssetCache-DUmXyTTh.mjs → AssetCache-Yaezy697.mjs} +1 -1
- package/build/chunks/{AssetLoader-CAboRD-N.mjs → AssetLoader-CWm-aunM.mjs} +984 -772
- package/build/chunks/AssetLoader-CxWzLiHn.cjs +5 -0
- package/build/chunks/{FileTypes-BQ2AN2gJ.cjs → FileTypes-D3vblaAa.cjs} +1 -1
- package/build/chunks/{FileTypes-OWYPzqcN.mjs → FileTypes-qgM3TaRh.mjs} +25 -9
- package/build/chunks/{isFileTypeSupported-BSpswPHU.mjs → isFileTypeSupported-CGTPFOhi.mjs} +6 -5
- package/build/chunks/isFileTypeSupported-uAFXvyzy.cjs +1 -0
- package/build/chunks/occt-import-js-BQ1yZHCj.cjs +1 -0
- package/build/chunks/occt-import-js-D-bjjBtk.mjs +4 -0
- package/build/chunks/occt-import-js-DdbbsFBH.cjs +1 -0
- package/build/chunks/occt-import-js-ekuHaP1Z.mjs +4 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +2 -2
- 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/assetexporter/src/AssetExporter.d.ts +4 -0
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/assetloader/src/loader/AssetLoader.d.ts +1 -0
- package/build/plugins/assetloader/src/step/STEPLoader.d.ts +29 -0
- 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 +1 -1
- package/build/plugins/state/index.mjs +1 -1
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +339 -313
- package/build/plugins/toolbox/src/transform/TransformTool.d.ts +18 -2
- package/build/types/file/FileTypes.d.ts +16 -0
- package/package.json +3 -2
- package/build/chunks/AssetLoader-tskoQtbb.cjs +0 -4
- package/build/chunks/isFileTypeSupported-CrEqYiv9.cjs +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
import { Object3D as
|
|
5
|
-
import "../../chunks/FileTypes-
|
|
1
|
+
var Ht = Object.defineProperty;
|
|
2
|
+
var Xt = (l, e, t) => e in l ? Ht(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var o = (l, e, t) => Xt(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Object3D as ht, Vector3 as h, Quaternion as E, Raycaster as ot, MeshBasicMaterial as Dt, LineBasicMaterial as kt, 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 Yt, Euler as Qt, Matrix4 as Et, PlaneGeometry as Ot, DoubleSide as Rt, EventDispatcher as Zt, Vector2 as F, Layers as _t } from "three";
|
|
5
|
+
import "../../chunks/FileTypes-qgM3TaRh.mjs";
|
|
6
6
|
import { P as G, U as W } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
|
|
7
7
|
import { f as B, i as O } from "../../chunks/findInterface-DbJ5qzbc.mjs";
|
|
8
8
|
import { A as ut, a as gt, b as ft } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
|
|
9
|
-
class
|
|
9
|
+
class Gt {
|
|
10
10
|
constructor() {
|
|
11
11
|
o(this, "_selected", null);
|
|
12
12
|
o(this, "_listeners", /* @__PURE__ */ new Set());
|
|
@@ -21,29 +21,29 @@ class Zt {
|
|
|
21
21
|
* Select an object. Deselects any previously selected object.
|
|
22
22
|
* Calls onSelect on the new object and onDeselect on the previous.
|
|
23
23
|
*/
|
|
24
|
-
select(
|
|
25
|
-
var
|
|
26
|
-
this._selected !==
|
|
24
|
+
select(e) {
|
|
25
|
+
var t, i, n;
|
|
26
|
+
this._selected !== e && (this._selected && ((i = (t = this._selected).onDeselect) == null || i.call(t)), this._selected = e, (n = e.onSelect) == null || n.call(e), this.notifyListeners());
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Deselect the currently selected object.
|
|
30
30
|
* Calls onDeselect on the object.
|
|
31
31
|
*/
|
|
32
32
|
deselect() {
|
|
33
|
-
var
|
|
34
|
-
this._selected && ((
|
|
33
|
+
var e, t;
|
|
34
|
+
this._selected && ((t = (e = this._selected).onDeselect) == null || t.call(e), this._selected = null, this.notifyListeners());
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Register a callback to be notified when selection changes.
|
|
38
38
|
*/
|
|
39
|
-
onChange(
|
|
40
|
-
this._listeners.add(
|
|
39
|
+
onChange(e) {
|
|
40
|
+
this._listeners.add(e);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Unregister a previously registered callback.
|
|
44
44
|
*/
|
|
45
|
-
offChange(
|
|
46
|
-
this._listeners.delete(
|
|
45
|
+
offChange(e) {
|
|
46
|
+
this._listeners.delete(e);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Dispose of the selection state and clear all listeners.
|
|
@@ -52,11 +52,11 @@ class Zt {
|
|
|
52
52
|
this._selected = null, this._listeners.clear();
|
|
53
53
|
}
|
|
54
54
|
notifyListeners() {
|
|
55
|
-
for (const
|
|
56
|
-
|
|
55
|
+
for (const e of this._listeners)
|
|
56
|
+
e(this._selected);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
class
|
|
59
|
+
class Wt {
|
|
60
60
|
constructor() {
|
|
61
61
|
o(this, "name", "hover");
|
|
62
62
|
o(this, "priority", 20);
|
|
@@ -72,37 +72,37 @@ class Gt {
|
|
|
72
72
|
this._hovered = null;
|
|
73
73
|
}
|
|
74
74
|
onDeactivate() {
|
|
75
|
-
var
|
|
76
|
-
this._hovered && ((
|
|
75
|
+
var e, t;
|
|
76
|
+
this._hovered && ((t = (e = this._hovered).onPointerLeave) == null || t.call(e), this._hovered = null);
|
|
77
77
|
}
|
|
78
|
-
onPointerMove(
|
|
78
|
+
onPointerMove(e) {
|
|
79
79
|
var n, a, s, c, u, P, M;
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const t = e.modelIntersects[0], i = B(
|
|
81
|
+
t == null ? void 0 : t.object,
|
|
82
82
|
"isHoverable"
|
|
83
83
|
);
|
|
84
|
-
if (
|
|
84
|
+
if (t && i) {
|
|
85
85
|
if (!this._hovered) {
|
|
86
|
-
(n = i.onPointerEnter) == null || n.call(i,
|
|
86
|
+
(n = i.onPointerEnter) == null || n.call(i, t), this._hovered = i;
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
if (this._hovered.uuid !== i.uuid) {
|
|
90
|
-
(s = (a = this._hovered).onPointerLeave) == null || s.call(a), (c = i.onPointerEnter) == null || c.call(i,
|
|
90
|
+
(s = (a = this._hovered).onPointerLeave) == null || s.call(a), (c = i.onPointerEnter) == null || c.call(i, t), this._hovered = i;
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
(u = i.onPointerOver) == null || u.call(i,
|
|
93
|
+
(u = i.onPointerOver) == null || u.call(i, t);
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
this._hovered && ((M = (P = this._hovered).onPointerLeave) == null || M.call(P), this._hovered = null);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
class
|
|
101
|
-
constructor(
|
|
99
|
+
const ce = (l) => l.name === "select";
|
|
100
|
+
class qt {
|
|
101
|
+
constructor(e) {
|
|
102
102
|
o(this, "name", "select");
|
|
103
103
|
o(this, "priority", 30);
|
|
104
104
|
o(this, "_selectionState");
|
|
105
|
-
this._selectionState =
|
|
105
|
+
this._selectionState = e;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Get the currently selected object.
|
|
@@ -114,12 +114,12 @@ class Wt {
|
|
|
114
114
|
}
|
|
115
115
|
onDeactivate() {
|
|
116
116
|
}
|
|
117
|
-
onClick(
|
|
118
|
-
const
|
|
119
|
-
|
|
117
|
+
onClick(e) {
|
|
118
|
+
const t = e.modelIntersects[0], i = B(
|
|
119
|
+
t == null ? void 0 : t.object,
|
|
120
120
|
"isSelectable"
|
|
121
121
|
);
|
|
122
|
-
if (!
|
|
122
|
+
if (!t || !i) {
|
|
123
123
|
this._selectionState.deselect();
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
@@ -129,8 +129,8 @@ class Wt {
|
|
|
129
129
|
/**
|
|
130
130
|
* Programmatically select an object.
|
|
131
131
|
*/
|
|
132
|
-
select(
|
|
133
|
-
this._selectionState.select(
|
|
132
|
+
select(e) {
|
|
133
|
+
this._selectionState.select(e);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Programmatically deselect the current selection.
|
|
@@ -139,87 +139,87 @@ class Wt {
|
|
|
139
139
|
this._selectionState.deselect();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
X: new
|
|
144
|
-
Y: new
|
|
145
|
-
Z: new
|
|
142
|
+
const j = new ot(), _ = new h(), C = new h(), p = new E(), mt = {
|
|
143
|
+
X: new h(1, 0, 0),
|
|
144
|
+
Y: new h(0, 1, 0),
|
|
145
|
+
Z: new h(0, 0, 1)
|
|
146
146
|
}, rt = { type: "change" }, wt = { type: "mouseDown" }, yt = { type: "mouseUp", mode: null }, bt = { type: "objectChange" };
|
|
147
|
-
class
|
|
148
|
-
constructor(
|
|
149
|
-
super(),
|
|
150
|
-
const i = new
|
|
147
|
+
class Ut extends ht {
|
|
148
|
+
constructor(e, t) {
|
|
149
|
+
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";
|
|
150
|
+
const i = new $t();
|
|
151
151
|
this._gizmo = i, this.add(i);
|
|
152
|
-
const n = new
|
|
152
|
+
const n = new Jt();
|
|
153
153
|
this._plane = n, this.add(n);
|
|
154
154
|
const a = this;
|
|
155
155
|
function s(g, b) {
|
|
156
|
-
let
|
|
156
|
+
let H = b;
|
|
157
157
|
Object.defineProperty(a, g, {
|
|
158
158
|
get: function() {
|
|
159
|
-
return
|
|
159
|
+
return H !== void 0 ? H : b;
|
|
160
160
|
},
|
|
161
161
|
set: function(z) {
|
|
162
|
-
|
|
162
|
+
H !== z && (H = z, n[g] = z, i[g] = z, a.dispatchEvent({ type: g + "-changed", value: z }), a.dispatchEvent(rt));
|
|
163
163
|
}
|
|
164
164
|
}), a[g] = b, n[g] = b, i[g] = b;
|
|
165
165
|
}
|
|
166
|
-
s("camera",
|
|
167
|
-
const c = new
|
|
168
|
-
s("worldPosition", c), s("worldPositionStart", u), s("worldQuaternion", P), s("worldQuaternionStart", M), s("cameraPosition",
|
|
166
|
+
s("camera", e), 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 h(), u = new h(), P = new E(), M = new E(), k = new h(), Y = new E(), lt = new h(), V = new h(), x = new h(), I = 0, S = new h();
|
|
168
|
+
s("worldPosition", c), s("worldPositionStart", u), s("worldQuaternion", P), s("worldQuaternionStart", M), s("cameraPosition", k), s("cameraQuaternion", Y), s("pointStart", lt), s("pointEnd", V), s("rotationAxis", x), s("rotationAngle", I), s("eye", S), this._offset = new h(), this._startNorm = new h(), this._endNorm = new h(), this._cameraScale = new h(), this._parentPosition = new h(), this._parentQuaternion = new E(), this._parentQuaternionInv = new E(), this._parentScale = new h(), this._worldScaleStart = new h(), this._worldQuaternionInv = new E(), this._worldScale = new h(), this._positionStart = new h(), this._quaternionStart = new E(), this._scaleStart = new h(), this._getPointer = Ft.bind(this), this._onPointerDown = Vt.bind(this), this._onPointerHover = Bt.bind(this), this._onPointerMove = Nt.bind(this), this._onPointerUp = Kt.bind(this), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointermove", this._onPointerHover), this.domElement.addEventListener("pointerup", this._onPointerUp);
|
|
169
169
|
}
|
|
170
170
|
// updateMatrixWorld updates key transformation variables
|
|
171
|
-
updateMatrixWorld(
|
|
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(
|
|
171
|
+
updateMatrixWorld(e) {
|
|
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(e);
|
|
173
173
|
}
|
|
174
|
-
pointerHover(
|
|
174
|
+
pointerHover(e) {
|
|
175
175
|
if (this.object === void 0 || this.dragging === !0) return;
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
pointerDown(
|
|
181
|
-
if (!(this.object === void 0 || this.dragging === !0 ||
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
176
|
+
e !== null && j.setFromCamera(e, this.camera);
|
|
177
|
+
const t = at(this._gizmo.picker[this.mode], j);
|
|
178
|
+
t ? this.axis = t.object.name : this.axis = null;
|
|
179
|
+
}
|
|
180
|
+
pointerDown(e) {
|
|
181
|
+
if (!(this.object === void 0 || this.dragging === !0 || e != null && e.button !== 0) && this.axis !== null) {
|
|
182
|
+
e !== null && j.setFromCamera(e, this.camera);
|
|
183
|
+
const t = at(this._plane, j, !0);
|
|
184
|
+
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, wt.mode = this.mode, this.dispatchEvent(wt);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
pointerMove(
|
|
188
|
-
const
|
|
187
|
+
pointerMove(e) {
|
|
188
|
+
const t = this.axis, i = this.mode, n = this.object;
|
|
189
189
|
let a = this.space;
|
|
190
|
-
if (i === "scale" ? a = "local" : (
|
|
191
|
-
|
|
192
|
-
const s = at(this._plane,
|
|
190
|
+
if (i === "scale" ? a = "local" : (t === "E" || t === "XYZE" || t === "XYZ") && (a = "world"), n === void 0 || t === null || this.dragging === !1 || e !== null && e.button !== -1) return;
|
|
191
|
+
e !== null && j.setFromCamera(e, this.camera);
|
|
192
|
+
const s = at(this._plane, j, !0);
|
|
193
193
|
if (s) {
|
|
194
194
|
if (this.pointEnd.copy(s.point).sub(this.worldPositionStart), i === "translate")
|
|
195
|
-
this._offset.copy(this.pointEnd).sub(this.pointStart), a === "local" &&
|
|
195
|
+
this._offset.copy(this.pointEnd).sub(this.pointStart), a === "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), a === "local" && t !== "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()), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.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)), t.search("X") !== -1 && (n.position.x = Math.round(n.position.x / this.translationSnap) * this.translationSnap), t.search("Y") !== -1 && (n.position.y = Math.round(n.position.y / this.translationSnap) * this.translationSnap), t.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
196
|
else if (i === "scale") {
|
|
197
|
-
if (
|
|
197
|
+
if (t.search("XYZ") !== -1) {
|
|
198
198
|
let c = this.pointEnd.length() / this.pointStart.length();
|
|
199
199
|
this.pointEnd.dot(this.pointStart) < 0 && (c *= -1), C.set(c, c, c);
|
|
200
200
|
} else
|
|
201
|
-
_.copy(this.pointStart), C.copy(this.pointEnd), _.applyQuaternion(this._worldQuaternionInv), C.applyQuaternion(this._worldQuaternionInv), C.divide(_),
|
|
202
|
-
n.scale.copy(this._scaleStart).multiply(C), this.scaleSnap && (
|
|
201
|
+
_.copy(this.pointStart), C.copy(this.pointEnd), _.applyQuaternion(this._worldQuaternionInv), C.applyQuaternion(this._worldQuaternionInv), C.divide(_), t.search("X") === -1 && (C.x = 1), t.search("Y") === -1 && (C.y = 1), t.search("Z") === -1 && (C.z = 1);
|
|
202
|
+
n.scale.copy(this._scaleStart).multiply(C), this.scaleSnap && (t.search("X") !== -1 && (n.scale.x = Math.round(n.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Y") !== -1 && (n.scale.y = Math.round(n.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), t.search("Z") !== -1 && (n.scale.z = Math.round(n.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
|
|
203
203
|
} else if (i === "rotate") {
|
|
204
204
|
this._offset.copy(this.pointEnd).sub(this.pointStart);
|
|
205
205
|
const c = 20 / this.worldPosition.distanceTo(_.setFromMatrixPosition(this.camera.matrixWorld));
|
|
206
206
|
let u = !1;
|
|
207
|
-
|
|
207
|
+
t === "XYZE" ? (this.rotationAxis.copy(this._offset).cross(this.eye).normalize(), this.rotationAngle = this._offset.dot(_.copy(this.rotationAxis).cross(this.eye)) * c) : (t === "X" || t === "Y" || t === "Z") && (this.rotationAxis.copy(mt[t]), _.copy(mt[t]), a === "local" && _.applyQuaternion(this.worldQuaternion), _.cross(this.eye), _.length() === 0 ? u = !0 : this.rotationAngle = this._offset.dot(_.normalize()) * c), (t === "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" && t !== "E" && t !== "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
208
|
}
|
|
209
209
|
this.dispatchEvent(rt), this.dispatchEvent(bt);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
pointerUp(
|
|
213
|
-
|
|
212
|
+
pointerUp(e) {
|
|
213
|
+
e !== null && e.button !== 0 || (this.dragging && this.axis !== null && (yt.mode = this.mode, this.dispatchEvent(yt)), this.dragging = !1, this.axis = null);
|
|
214
214
|
}
|
|
215
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(
|
|
217
|
-
|
|
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(e) {
|
|
217
|
+
e.geometry && e.geometry.dispose(), e.material && e.material.dispose();
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
// Set current object
|
|
221
|
-
attach(
|
|
222
|
-
return this.object =
|
|
221
|
+
attach(e) {
|
|
222
|
+
return this.object = e, this.visible = !0, this;
|
|
223
223
|
}
|
|
224
224
|
// Detach from object
|
|
225
225
|
detach() {
|
|
@@ -229,109 +229,109 @@ class qt extends lt {
|
|
|
229
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
230
|
}
|
|
231
231
|
getRaycaster() {
|
|
232
|
-
return
|
|
232
|
+
return j;
|
|
233
233
|
}
|
|
234
234
|
// TODO: deprecate
|
|
235
235
|
getMode() {
|
|
236
236
|
return this.mode;
|
|
237
237
|
}
|
|
238
|
-
setMode(
|
|
239
|
-
this.mode =
|
|
238
|
+
setMode(e) {
|
|
239
|
+
this.mode = e;
|
|
240
240
|
}
|
|
241
|
-
setTranslationSnap(
|
|
242
|
-
this.translationSnap =
|
|
241
|
+
setTranslationSnap(e) {
|
|
242
|
+
this.translationSnap = e;
|
|
243
243
|
}
|
|
244
|
-
setRotationSnap(
|
|
245
|
-
this.rotationSnap =
|
|
244
|
+
setRotationSnap(e) {
|
|
245
|
+
this.rotationSnap = e;
|
|
246
246
|
}
|
|
247
|
-
setScaleSnap(
|
|
248
|
-
this.scaleSnap =
|
|
247
|
+
setScaleSnap(e) {
|
|
248
|
+
this.scaleSnap = e;
|
|
249
249
|
}
|
|
250
|
-
setSize(
|
|
251
|
-
this.size =
|
|
250
|
+
setSize(e) {
|
|
251
|
+
this.size = e;
|
|
252
252
|
}
|
|
253
|
-
setSpace(
|
|
254
|
-
this.space =
|
|
253
|
+
setSpace(e) {
|
|
254
|
+
this.space = e;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function Ft(l) {
|
|
258
258
|
if (this.domElement.ownerDocument.pointerLockElement)
|
|
259
259
|
return {
|
|
260
260
|
x: 0,
|
|
261
261
|
y: 0,
|
|
262
|
-
button:
|
|
262
|
+
button: l.button
|
|
263
263
|
};
|
|
264
264
|
{
|
|
265
|
-
const
|
|
265
|
+
const e = this.domElement.getBoundingClientRect();
|
|
266
266
|
return {
|
|
267
|
-
x: (
|
|
268
|
-
y: -(
|
|
269
|
-
button:
|
|
267
|
+
x: (l.clientX - e.left) / e.width * 2 - 1,
|
|
268
|
+
y: -(l.clientY - e.top) / e.height * 2 + 1,
|
|
269
|
+
button: l.button
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function Bt(l) {
|
|
274
274
|
if (this.enabled)
|
|
275
|
-
switch (
|
|
275
|
+
switch (l.pointerType) {
|
|
276
276
|
case "mouse":
|
|
277
277
|
case "pen":
|
|
278
|
-
this.pointerHover(this._getPointer(
|
|
278
|
+
this.pointerHover(this._getPointer(l));
|
|
279
279
|
break;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(
|
|
282
|
+
function Vt(l) {
|
|
283
|
+
this.enabled && (document.pointerLockElement || this.domElement.setPointerCapture(l.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.pointerHover(this._getPointer(l)), this.pointerDown(this._getPointer(l)));
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
this.enabled && this.pointerMove(this._getPointer(
|
|
285
|
+
function Nt(l) {
|
|
286
|
+
this.enabled && this.pointerMove(this._getPointer(l));
|
|
287
287
|
}
|
|
288
|
-
function
|
|
289
|
-
this.enabled && (this.domElement.releasePointerCapture(
|
|
288
|
+
function Kt(l) {
|
|
289
|
+
this.enabled && (this.domElement.releasePointerCapture(l.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.pointerUp(this._getPointer(l)));
|
|
290
290
|
}
|
|
291
|
-
function at(
|
|
292
|
-
const i =
|
|
291
|
+
function at(l, e, t) {
|
|
292
|
+
const i = e.intersectObject(l, !0);
|
|
293
293
|
for (let n = 0; n < i.length; n++)
|
|
294
|
-
if (i[n].object.visible ||
|
|
294
|
+
if (i[n].object.visible || t)
|
|
295
295
|
return i[n];
|
|
296
296
|
return !1;
|
|
297
297
|
}
|
|
298
|
-
const et = new Qt(), d = new
|
|
299
|
-
class
|
|
298
|
+
const et = new Qt(), d = new h(0, 1, 0), vt = new h(0, 0, 0), Pt = new Et(), it = new E(), nt = new E(), D = new h(), St = new Et(), q = new h(1, 0, 0), L = new h(0, 1, 0), U = new h(0, 0, 1), st = new h(), R = new h(), Z = new h();
|
|
299
|
+
class $t extends ht {
|
|
300
300
|
constructor() {
|
|
301
301
|
super(), this.isTransformControlsGizmo = !0, this.type = "TransformControlsGizmo";
|
|
302
|
-
const
|
|
302
|
+
const e = new Dt({
|
|
303
303
|
depthTest: !1,
|
|
304
304
|
depthWrite: !1,
|
|
305
305
|
fog: !1,
|
|
306
306
|
toneMapped: !1,
|
|
307
307
|
transparent: !0
|
|
308
|
-
}),
|
|
308
|
+
}), t = new kt({
|
|
309
309
|
depthTest: !1,
|
|
310
310
|
depthWrite: !1,
|
|
311
311
|
fog: !1,
|
|
312
312
|
toneMapped: !1,
|
|
313
313
|
transparent: !0
|
|
314
|
-
}), i =
|
|
314
|
+
}), i = e.clone();
|
|
315
315
|
i.opacity = 0.15;
|
|
316
|
-
const n =
|
|
316
|
+
const n = t.clone();
|
|
317
317
|
n.opacity = 0.5;
|
|
318
|
-
const a =
|
|
318
|
+
const a = e.clone();
|
|
319
319
|
a.color.setHex(16711680);
|
|
320
|
-
const s =
|
|
320
|
+
const s = e.clone();
|
|
321
321
|
s.color.setHex(65280);
|
|
322
|
-
const c =
|
|
322
|
+
const c = e.clone();
|
|
323
323
|
c.color.setHex(255);
|
|
324
|
-
const u =
|
|
324
|
+
const u = e.clone();
|
|
325
325
|
u.color.setHex(16711680), u.opacity = 0.5;
|
|
326
|
-
const P =
|
|
326
|
+
const P = e.clone();
|
|
327
327
|
P.color.setHex(65280), P.opacity = 0.5;
|
|
328
|
-
const M =
|
|
328
|
+
const M = e.clone();
|
|
329
329
|
M.color.setHex(255), M.opacity = 0.5;
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
const V =
|
|
330
|
+
const k = e.clone();
|
|
331
|
+
k.opacity = 0.25;
|
|
332
|
+
const Y = e.clone();
|
|
333
|
+
Y.color.setHex(16776960), Y.opacity = 0.25, e.clone().color.setHex(16776960);
|
|
334
|
+
const V = e.clone();
|
|
335
335
|
V.color.setHex(7895160);
|
|
336
336
|
const x = new w(0, 0.04, 0.1, 12);
|
|
337
337
|
x.translate(0, 0.05, 0);
|
|
@@ -345,7 +345,7 @@ class Kt extends lt {
|
|
|
345
345
|
const v = new Q(y, 75e-4, 3, 64, N * Math.PI * 2);
|
|
346
346
|
return v.rotateY(Math.PI / 2), v.rotateX(Math.PI / 2), v;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function H() {
|
|
349
349
|
const y = new dt();
|
|
350
350
|
return y.setAttribute("position", new pt([0, 0, 0, 1, 1, 1], 3)), y;
|
|
351
351
|
}
|
|
@@ -366,7 +366,7 @@ class Kt extends lt {
|
|
|
366
366
|
[new r(g, c), null, [Math.PI / 2, 0, 0]]
|
|
367
367
|
],
|
|
368
368
|
XYZ: [
|
|
369
|
-
[new r(new tt(0.1, 0),
|
|
369
|
+
[new r(new tt(0.1, 0), k.clone()), [0, 0, 0]]
|
|
370
370
|
],
|
|
371
371
|
XY: [
|
|
372
372
|
[new r(new f(0.15, 0.15, 0.01), M.clone()), [0.15, 0.15, 0]]
|
|
@@ -410,7 +410,7 @@ class Kt extends lt {
|
|
|
410
410
|
[new r(new tt(0.01, 2), n), null, null, null, "helper"]
|
|
411
411
|
],
|
|
412
412
|
DELTA: [
|
|
413
|
-
[new A(
|
|
413
|
+
[new A(H(), n), null, null, null, "helper"]
|
|
414
414
|
],
|
|
415
415
|
X: [
|
|
416
416
|
[new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
@@ -435,7 +435,7 @@ class Kt extends lt {
|
|
|
435
435
|
[new r(b(0.5, 0.5), c), null, [0, Math.PI / 2, 0]]
|
|
436
436
|
],
|
|
437
437
|
E: [
|
|
438
|
-
[new r(b(0.75, 1),
|
|
438
|
+
[new r(b(0.75, 1), Y), null, [0, Math.PI / 2, 0]]
|
|
439
439
|
]
|
|
440
440
|
}, Tt = {
|
|
441
441
|
AXIS: [
|
|
@@ -443,7 +443,7 @@ class Kt extends lt {
|
|
|
443
443
|
]
|
|
444
444
|
}, At = {
|
|
445
445
|
XYZE: [
|
|
446
|
-
[new r(new
|
|
446
|
+
[new r(new Yt(0.25, 10, 8), i)]
|
|
447
447
|
],
|
|
448
448
|
X: [
|
|
449
449
|
[new r(new Q(0.5, 0.1, 4, 24), i), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]
|
|
@@ -483,7 +483,7 @@ class Kt extends lt {
|
|
|
483
483
|
[new r(new f(0.15, 0.15, 0.01), P), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
484
484
|
],
|
|
485
485
|
XYZ: [
|
|
486
|
-
[new r(new f(0.1, 0.1, 0.1),
|
|
486
|
+
[new r(new f(0.1, 0.1, 0.1), k.clone())]
|
|
487
487
|
]
|
|
488
488
|
}, zt = {
|
|
489
489
|
X: [
|
|
@@ -510,7 +510,7 @@ class Kt extends lt {
|
|
|
510
510
|
XYZ: [
|
|
511
511
|
[new r(new f(0.2, 0.2, 0.2), i), [0, 0, 0]]
|
|
512
512
|
]
|
|
513
|
-
},
|
|
513
|
+
}, jt = {
|
|
514
514
|
X: [
|
|
515
515
|
[new A(S, n.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]
|
|
516
516
|
],
|
|
@@ -522,20 +522,20 @@ class Kt extends lt {
|
|
|
522
522
|
]
|
|
523
523
|
};
|
|
524
524
|
function T(y) {
|
|
525
|
-
const N = new
|
|
525
|
+
const N = new ht();
|
|
526
526
|
for (const v in y)
|
|
527
|
-
for (let
|
|
528
|
-
const m = y[v][
|
|
529
|
-
m.name = v, m.tag =
|
|
527
|
+
for (let X = y[v].length; X--; ) {
|
|
528
|
+
const m = y[v][X][0].clone(), K = y[v][X][1], $ = y[v][X][2], J = y[v][X][3], Lt = y[v][X][4];
|
|
529
|
+
m.name = v, m.tag = Lt, 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
530
|
const ct = m.geometry.clone();
|
|
531
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
532
|
}
|
|
533
533
|
return N;
|
|
534
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(
|
|
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(jt)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
536
536
|
}
|
|
537
537
|
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
538
|
-
updateMatrixWorld(
|
|
538
|
+
updateMatrixWorld(e) {
|
|
539
539
|
const i = (this.mode === "scale" ? "local" : this.space) === "local" ? this.worldQuaternion : nt;
|
|
540
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
541
|
let n = [];
|
|
@@ -545,26 +545,26 @@ class Kt extends lt {
|
|
|
545
545
|
s.visible = !0, s.rotation.set(0, 0, 0), s.position.copy(this.worldPosition);
|
|
546
546
|
let c;
|
|
547
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(
|
|
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(L).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, L)), 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
549
|
continue;
|
|
550
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(
|
|
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(L).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(L).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, L)), 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(L, 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
552
|
return s.name === u;
|
|
553
553
|
})) && (s.material.color.setHex(16776960), s.material.opacity = 1);
|
|
554
554
|
}
|
|
555
|
-
super.updateMatrixWorld(
|
|
555
|
+
super.updateMatrixWorld(e);
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
class
|
|
558
|
+
class Jt extends r {
|
|
559
559
|
constructor() {
|
|
560
560
|
super(
|
|
561
561
|
new Ot(1e5, 1e5, 2, 2),
|
|
562
562
|
new Dt({ visible: !1, wireframe: !0, side: Rt, transparent: !0, opacity: 0.1, toneMapped: !1 })
|
|
563
563
|
), this.isTransformControlsPlane = !0, this.type = "TransformControlsPlane";
|
|
564
564
|
}
|
|
565
|
-
updateMatrixWorld(
|
|
566
|
-
let
|
|
567
|
-
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (
|
|
565
|
+
updateMatrixWorld(e) {
|
|
566
|
+
let t = this.space;
|
|
567
|
+
switch (this.position.copy(this.worldPosition), this.mode === "scale" && (t = "local"), st.copy(q).applyQuaternion(t === "local" ? this.worldQuaternion : nt), R.copy(L).applyQuaternion(t === "local" ? this.worldQuaternion : nt), Z.copy(U).applyQuaternion(t === "local" ? this.worldQuaternion : nt), d.copy(R), this.mode) {
|
|
568
568
|
case "translate":
|
|
569
569
|
case "scale":
|
|
570
570
|
switch (this.axis) {
|
|
@@ -596,12 +596,13 @@ class $t extends r {
|
|
|
596
596
|
default:
|
|
597
597
|
D.set(0, 0, 0);
|
|
598
598
|
}
|
|
599
|
-
D.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (St.lookAt(_.set(0, 0, 0), D, d), this.quaternion.setFromRotationMatrix(St)), super.updateMatrixWorld(
|
|
599
|
+
D.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (St.lookAt(_.set(0, 0, 0), D, d), this.quaternion.setFromRotationMatrix(St)), super.updateMatrixWorld(e);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
const
|
|
603
|
-
class
|
|
604
|
-
constructor(t,
|
|
602
|
+
const de = (l) => l.name === "transform";
|
|
603
|
+
class te extends Zt {
|
|
604
|
+
constructor(t, i, n) {
|
|
605
|
+
super();
|
|
605
606
|
o(this, "name", "transform");
|
|
606
607
|
o(this, "priority", 5);
|
|
607
608
|
o(this, "_scene");
|
|
@@ -611,7 +612,7 @@ class Jt {
|
|
|
611
612
|
o(this, "_scaleLinked", !1);
|
|
612
613
|
o(this, "_gizmoVisible", !0);
|
|
613
614
|
o(this, "_selectionChangeHandler");
|
|
614
|
-
this._scene = t, this._controller =
|
|
615
|
+
this._scene = t, this._controller = i, this._selectionState = n, this._gizmo = this.initGizmo(), this._scene.add(this._gizmo), this._selectionChangeHandler = this.onSelectionChange.bind(this);
|
|
615
616
|
}
|
|
616
617
|
/**
|
|
617
618
|
* Get the TransformControls gizmo.
|
|
@@ -635,7 +636,7 @@ class Jt {
|
|
|
635
636
|
}
|
|
636
637
|
onPointerMove(t) {
|
|
637
638
|
if (this._gizmo.dragging || t.uiIntersects.length > 0 && t.uiIntersects.some(
|
|
638
|
-
(
|
|
639
|
+
(n) => this.isGizmoChild(n.object)
|
|
639
640
|
))
|
|
640
641
|
return !0;
|
|
641
642
|
}
|
|
@@ -650,8 +651,8 @@ class Jt {
|
|
|
650
651
|
*/
|
|
651
652
|
setGizmoVisible(t) {
|
|
652
653
|
this._gizmoVisible = t;
|
|
653
|
-
const
|
|
654
|
-
t && !
|
|
654
|
+
const i = this._scene.children.includes(this._gizmo);
|
|
655
|
+
t && !i ? (this._scene.add(this._gizmo), this._gizmo.getRaycaster().layers.enableAll()) : !t && i && (this._scene.remove(this._gizmo), this._gizmo.getRaycaster().layers.disableAll());
|
|
655
656
|
}
|
|
656
657
|
/**
|
|
657
658
|
* Set whether scale operations are linked (uniform scaling).
|
|
@@ -673,40 +674,65 @@ class Jt {
|
|
|
673
674
|
O(t, "isMovable") && (this._gizmo.attach(t), this.setGizmoVisible(t.visible && this._gizmoVisible));
|
|
674
675
|
}
|
|
675
676
|
isGizmoChild(t) {
|
|
676
|
-
let
|
|
677
|
-
for (;
|
|
678
|
-
if (
|
|
679
|
-
|
|
677
|
+
let i = t;
|
|
678
|
+
for (; i; ) {
|
|
679
|
+
if (i === this._gizmo) return !0;
|
|
680
|
+
i = i.parent;
|
|
680
681
|
}
|
|
681
682
|
return !1;
|
|
682
683
|
}
|
|
683
684
|
initGizmo() {
|
|
684
|
-
const t = new
|
|
685
|
+
const t = new Ut(
|
|
685
686
|
this._controller.object,
|
|
686
687
|
this._controller.domElement
|
|
687
688
|
);
|
|
688
|
-
return t.mode = "translate", t.traverse((
|
|
689
|
-
if (!("isMesh" in
|
|
690
|
-
const
|
|
691
|
-
|
|
689
|
+
return t.mode = "translate", t.traverse((i) => {
|
|
690
|
+
if (!("isMesh" in i)) return;
|
|
691
|
+
const n = i.material;
|
|
692
|
+
i.name === "X" && n.color.set(ut), i.name === "Y" && n.color.set(gt), i.name === "Z" && n.color.set(ft), i.name === "XY" && n.color.set(ft), i.name === "YZ" && n.color.set(ut), i.name === "XZ" && n.color.set(gt);
|
|
692
693
|
}), t.addEventListener("mouseDown", () => {
|
|
693
|
-
var
|
|
694
|
-
this._controller.enabled = !1, O(t.object, "isMovable") && ((
|
|
694
|
+
var i, n;
|
|
695
|
+
this._controller.enabled = !1, O(t.object, "isMovable") && ((n = (i = t.object).onMoveStart) == null || n.call(i));
|
|
695
696
|
}), t.addEventListener("objectChange", () => {
|
|
696
|
-
var
|
|
697
|
-
if (O(t.object, "isMovable")
|
|
698
|
-
|
|
699
|
-
|
|
697
|
+
var i, n;
|
|
698
|
+
if (O(t.object, "isMovable")) {
|
|
699
|
+
if ((n = (i = t.object).onMove) == null || n.call(i), this._scaleLinked && t.object) {
|
|
700
|
+
const a = t.object.scale, s = (a.x + a.y + a.z) / 3;
|
|
701
|
+
t.object.scale.set(s, s, s);
|
|
702
|
+
}
|
|
703
|
+
switch (this.dispatchEvent({
|
|
704
|
+
type: "object-change",
|
|
705
|
+
object: t.object
|
|
706
|
+
}), t.mode) {
|
|
707
|
+
case "translate":
|
|
708
|
+
this.dispatchEvent({
|
|
709
|
+
type: "object-position-change",
|
|
710
|
+
object: t.object
|
|
711
|
+
});
|
|
712
|
+
break;
|
|
713
|
+
case "rotate":
|
|
714
|
+
this.dispatchEvent({
|
|
715
|
+
type: "object-rotation-change",
|
|
716
|
+
object: t.object
|
|
717
|
+
});
|
|
718
|
+
break;
|
|
719
|
+
case "scale":
|
|
720
|
+
this.dispatchEvent({
|
|
721
|
+
type: "object-scale-change",
|
|
722
|
+
object: t.object
|
|
723
|
+
});
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
700
726
|
}
|
|
701
727
|
}), t.addEventListener("mouseUp", () => {
|
|
702
|
-
var
|
|
703
|
-
this._controller.enabled = !0, O(t.object, "isMovable") && ((
|
|
728
|
+
var i, n;
|
|
729
|
+
this._controller.enabled = !0, O(t.object, "isMovable") && ((n = (i = t.object).onMoveEnd) == null || n.call(i));
|
|
704
730
|
}), t;
|
|
705
731
|
}
|
|
706
732
|
}
|
|
707
|
-
const
|
|
708
|
-
class
|
|
709
|
-
constructor(
|
|
733
|
+
const ee = 1e-3;
|
|
734
|
+
class ie {
|
|
735
|
+
constructor(e) {
|
|
710
736
|
o(this, "name", "drag");
|
|
711
737
|
o(this, "priority", 10);
|
|
712
738
|
o(this, "_controller");
|
|
@@ -714,13 +740,13 @@ class ee {
|
|
|
714
740
|
// Drag state
|
|
715
741
|
o(this, "_dragging", !1);
|
|
716
742
|
o(this, "_draggable", null);
|
|
717
|
-
o(this, "_dragStart", new
|
|
718
|
-
o(this, "_dragCurrent", new
|
|
719
|
-
o(this, "_dragEnd", new
|
|
720
|
-
o(this, "_dragDelta", new
|
|
743
|
+
o(this, "_dragStart", new h());
|
|
744
|
+
o(this, "_dragCurrent", new h());
|
|
745
|
+
o(this, "_dragEnd", new h());
|
|
746
|
+
o(this, "_dragDelta", new h());
|
|
721
747
|
// Custom raycast targets for drag plane
|
|
722
748
|
o(this, "_dragRaycastTargets", null);
|
|
723
|
-
this._controller =
|
|
749
|
+
this._controller = e, this._raycaster = new ot();
|
|
724
750
|
}
|
|
725
751
|
/**
|
|
726
752
|
* Whether a drag operation is currently in progress.
|
|
@@ -740,19 +766,19 @@ class ee {
|
|
|
740
766
|
onDeactivate() {
|
|
741
767
|
this._dragging && this._draggable && this.endDrag(), this.resetDragState();
|
|
742
768
|
}
|
|
743
|
-
onPointerDown(
|
|
744
|
-
var
|
|
745
|
-
|
|
746
|
-
(
|
|
769
|
+
onPointerDown(e) {
|
|
770
|
+
var t;
|
|
771
|
+
e.pointerPrimaryDown && (this._draggable = B(
|
|
772
|
+
(t = e.intersects[0]) == null ? void 0 : t.object,
|
|
747
773
|
"isDraggable"
|
|
748
774
|
) || null);
|
|
749
775
|
}
|
|
750
|
-
onPointerMove(
|
|
751
|
-
if (
|
|
752
|
-
return this.updateDrag(
|
|
776
|
+
onPointerMove(e) {
|
|
777
|
+
if (e.pointerPrimaryDown && this._draggable && (this._raycaster.setFromCamera(e.pointer, this._controller.object), this._dragging || e.lastPointerDown.distanceTo(e.pointer) > ee && this.startDrag(e), this._dragging))
|
|
778
|
+
return this.updateDrag(e), !0;
|
|
753
779
|
}
|
|
754
|
-
onPointerUp(
|
|
755
|
-
this._dragging && (this._raycaster.setFromCamera(
|
|
780
|
+
onPointerUp(e) {
|
|
781
|
+
this._dragging && (this._raycaster.setFromCamera(e.pointer, this._controller.object), this.endDrag()), this._draggable = null;
|
|
756
782
|
}
|
|
757
783
|
/**
|
|
758
784
|
* Set custom objects to raycast against during drag.
|
|
@@ -760,30 +786,30 @@ class ee {
|
|
|
760
786
|
*
|
|
761
787
|
* @param targets Objects to raycast against, or null to use scene objects
|
|
762
788
|
*/
|
|
763
|
-
setDragRaycastTargets(
|
|
764
|
-
this._dragRaycastTargets =
|
|
789
|
+
setDragRaycastTargets(e) {
|
|
790
|
+
this._dragRaycastTargets = e;
|
|
765
791
|
}
|
|
766
792
|
// ============ Private Methods ============
|
|
767
|
-
startDrag(
|
|
793
|
+
startDrag(e) {
|
|
768
794
|
var i, n;
|
|
769
|
-
const
|
|
770
|
-
|
|
795
|
+
const t = this.getDragIntersect(e);
|
|
796
|
+
t && (this._dragStart.copy(t.point), this._dragCurrent.copy(t.point), this._dragEnd.copy(t.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
797
|
}
|
|
772
|
-
updateDrag(
|
|
798
|
+
updateDrag(e) {
|
|
773
799
|
var i, n;
|
|
774
|
-
const
|
|
775
|
-
|
|
800
|
+
const t = this.getDragIntersect(e);
|
|
801
|
+
t && (this._dragCurrent.copy(t.point), this._dragEnd.copy(t.point), this._dragDelta.subVectors(this._dragCurrent, this._dragStart), (n = (i = this._draggable) == null ? void 0 : i.onDrag) == null || n.call(i, this.createDragEvent()));
|
|
776
802
|
}
|
|
777
803
|
endDrag() {
|
|
778
|
-
var
|
|
779
|
-
const
|
|
780
|
-
(i = (
|
|
804
|
+
var t, i;
|
|
805
|
+
const e = this.createDragEvent();
|
|
806
|
+
(i = (t = this._draggable) == null ? void 0 : t.onDragEnd) == null || i.call(t, e), this._dragging = !1, this._controller.enabled = !0, this.resetDragState();
|
|
781
807
|
}
|
|
782
|
-
getDragIntersect(
|
|
808
|
+
getDragIntersect(e) {
|
|
783
809
|
return this._dragRaycastTargets ? this._raycaster.intersectObjects(
|
|
784
810
|
this._dragRaycastTargets,
|
|
785
811
|
!0
|
|
786
|
-
)[0] || null :
|
|
812
|
+
)[0] || null : e.intersects[0] || null;
|
|
787
813
|
}
|
|
788
814
|
createDragEvent() {
|
|
789
815
|
return {
|
|
@@ -797,9 +823,9 @@ class ee {
|
|
|
797
823
|
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
824
|
}
|
|
799
825
|
}
|
|
800
|
-
const
|
|
801
|
-
class
|
|
802
|
-
constructor(
|
|
826
|
+
const se = 1e-3;
|
|
827
|
+
class pe {
|
|
828
|
+
constructor(e, t) {
|
|
803
829
|
o(this, "_scene");
|
|
804
830
|
o(this, "_controller");
|
|
805
831
|
o(this, "_canvas");
|
|
@@ -824,22 +850,22 @@ class de {
|
|
|
824
850
|
o(this, "_boundPointerDown");
|
|
825
851
|
o(this, "_boundPointerUp");
|
|
826
852
|
o(this, "_boundWheel");
|
|
827
|
-
this._scene =
|
|
853
|
+
this._scene = e, this._controller = t, this._canvas = t.domElement, this._selectionState = new Gt(), 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
854
|
[
|
|
829
855
|
"hover",
|
|
830
|
-
new
|
|
856
|
+
new Wt()
|
|
831
857
|
],
|
|
832
858
|
[
|
|
833
859
|
"select",
|
|
834
|
-
new
|
|
860
|
+
new qt(this._selectionState)
|
|
835
861
|
],
|
|
836
862
|
[
|
|
837
863
|
"transform",
|
|
838
|
-
new
|
|
864
|
+
new te(e, t, this._selectionState)
|
|
839
865
|
],
|
|
840
866
|
[
|
|
841
867
|
"drag",
|
|
842
|
-
new
|
|
868
|
+
new ie(t)
|
|
843
869
|
]
|
|
844
870
|
]), 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
871
|
}
|
|
@@ -849,30 +875,30 @@ class de {
|
|
|
849
875
|
/**
|
|
850
876
|
* Enable a tool by type.
|
|
851
877
|
*/
|
|
852
|
-
enableTool(
|
|
878
|
+
enableTool(e) {
|
|
853
879
|
var i;
|
|
854
|
-
const
|
|
855
|
-
|
|
880
|
+
const t = this._tools.get(e);
|
|
881
|
+
t && (this._activeTools.has(e) || (this._activeTools.set(e, t), this.updateSortedTools(), (i = t.onActivate) == null || i.call(t)));
|
|
856
882
|
}
|
|
857
883
|
/**
|
|
858
884
|
* Disable an active tool by type.
|
|
859
885
|
*/
|
|
860
|
-
disableTool(
|
|
886
|
+
disableTool(e) {
|
|
861
887
|
var i;
|
|
862
|
-
const
|
|
863
|
-
|
|
888
|
+
const t = this._activeTools.get(e);
|
|
889
|
+
t && ((i = t.onDeactivate) == null || i.call(t), this._activeTools.delete(e), this.updateSortedTools());
|
|
864
890
|
}
|
|
865
891
|
/**
|
|
866
892
|
* Check if a tool is currently enabled.
|
|
867
893
|
*/
|
|
868
|
-
isToolEnabled(
|
|
869
|
-
return this._activeTools.has(
|
|
894
|
+
isToolEnabled(e) {
|
|
895
|
+
return this._activeTools.has(e);
|
|
870
896
|
}
|
|
871
897
|
/**
|
|
872
898
|
* Get a tool by type.
|
|
873
899
|
*/
|
|
874
|
-
getTool(
|
|
875
|
-
return this._tools.get(
|
|
900
|
+
getTool(e) {
|
|
901
|
+
return this._tools.get(e);
|
|
876
902
|
}
|
|
877
903
|
/**
|
|
878
904
|
* Get all currently active tools.
|
|
@@ -884,57 +910,57 @@ class de {
|
|
|
884
910
|
* Dispose of the toolbox and clean up resources.
|
|
885
911
|
*/
|
|
886
912
|
dispose() {
|
|
887
|
-
var
|
|
888
|
-
for (const
|
|
889
|
-
(
|
|
913
|
+
var e;
|
|
914
|
+
for (const t of this._activeTools.values())
|
|
915
|
+
(e = t.onDeactivate) == null || e.call(t);
|
|
890
916
|
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
917
|
}
|
|
892
918
|
// ============ Event Handlers ============
|
|
893
|
-
onPointerMove(
|
|
919
|
+
onPointerMove(e) {
|
|
894
920
|
var i;
|
|
895
|
-
this.updatePointer(
|
|
896
|
-
const
|
|
921
|
+
this.updatePointer(e);
|
|
922
|
+
const t = this.createPointerContext(e);
|
|
897
923
|
for (const n of this._sortedActiveTools)
|
|
898
|
-
if ((i = n.onPointerMove) == null ? void 0 : i.call(n,
|
|
924
|
+
if ((i = n.onPointerMove) == null ? void 0 : i.call(n, t)) break;
|
|
899
925
|
}
|
|
900
|
-
onPointerDown(
|
|
926
|
+
onPointerDown(e) {
|
|
901
927
|
var i;
|
|
902
|
-
this.updatePointerState(
|
|
903
|
-
const
|
|
928
|
+
this.updatePointerState(e, !0), this.updatePointer(e), this._lastPointerDown.copy(this._pointer);
|
|
929
|
+
const t = this.createPointerContext(e);
|
|
904
930
|
for (const n of this._sortedActiveTools)
|
|
905
|
-
if ((i = n.onPointerDown) == null ? void 0 : i.call(n,
|
|
931
|
+
if ((i = n.onPointerDown) == null ? void 0 : i.call(n, t)) break;
|
|
906
932
|
}
|
|
907
|
-
onPointerUp(
|
|
933
|
+
onPointerUp(e) {
|
|
908
934
|
var n, a;
|
|
909
|
-
this.updatePointer(
|
|
910
|
-
const
|
|
935
|
+
this.updatePointer(e);
|
|
936
|
+
const t = this.createPointerContext(e), i = !this.pointerWasDragged();
|
|
911
937
|
for (const s of this._sortedActiveTools)
|
|
912
|
-
if ((n = s.onPointerUp) == null ? void 0 : n.call(s,
|
|
938
|
+
if ((n = s.onPointerUp) == null ? void 0 : n.call(s, t)) break;
|
|
913
939
|
if (i) {
|
|
914
940
|
for (const s of this._sortedActiveTools)
|
|
915
|
-
if ((a = s.onClick) == null ? void 0 : a.call(s,
|
|
941
|
+
if ((a = s.onClick) == null ? void 0 : a.call(s, t)) break;
|
|
916
942
|
}
|
|
917
|
-
this.updatePointerState(
|
|
943
|
+
this.updatePointerState(e, !1);
|
|
918
944
|
}
|
|
919
|
-
onWheel(
|
|
945
|
+
onWheel(e) {
|
|
920
946
|
var i;
|
|
921
|
-
const
|
|
947
|
+
const t = this.createWheelContext(e);
|
|
922
948
|
for (const n of this._sortedActiveTools)
|
|
923
|
-
if ((i = n.onWheel) == null ? void 0 : i.call(n,
|
|
949
|
+
if ((i = n.onWheel) == null ? void 0 : i.call(n, t)) break;
|
|
924
950
|
}
|
|
925
951
|
// ============ Context Creation ============
|
|
926
|
-
createPointerContext(
|
|
927
|
-
const
|
|
952
|
+
createPointerContext(e) {
|
|
953
|
+
const t = this.raycast();
|
|
928
954
|
return {
|
|
929
|
-
event:
|
|
955
|
+
event: e,
|
|
930
956
|
pointer: this._pointer.clone(),
|
|
931
|
-
intersects:
|
|
957
|
+
intersects: t,
|
|
932
958
|
modelIntersects: this.filterIntersectsByLayer(
|
|
933
|
-
|
|
959
|
+
t,
|
|
934
960
|
G
|
|
935
961
|
),
|
|
936
962
|
uiIntersects: this.filterIntersectsByLayer(
|
|
937
|
-
|
|
963
|
+
t,
|
|
938
964
|
W
|
|
939
965
|
),
|
|
940
966
|
pointerPrimaryDown: this._pointerPrimaryDown,
|
|
@@ -943,73 +969,73 @@ class de {
|
|
|
943
969
|
lastPointerDown: this._lastPointerDown.clone()
|
|
944
970
|
};
|
|
945
971
|
}
|
|
946
|
-
createWheelContext(
|
|
947
|
-
const
|
|
972
|
+
createWheelContext(e) {
|
|
973
|
+
const t = this.raycast();
|
|
948
974
|
return {
|
|
949
|
-
event:
|
|
975
|
+
event: e,
|
|
950
976
|
pointer: this._pointer.clone(),
|
|
951
|
-
intersects:
|
|
977
|
+
intersects: t,
|
|
952
978
|
modelIntersects: this.filterIntersectsByLayer(
|
|
953
|
-
|
|
979
|
+
t,
|
|
954
980
|
G
|
|
955
981
|
),
|
|
956
982
|
uiIntersects: this.filterIntersectsByLayer(
|
|
957
|
-
|
|
983
|
+
t,
|
|
958
984
|
W
|
|
959
985
|
)
|
|
960
986
|
};
|
|
961
987
|
}
|
|
962
988
|
// ============ Helper Methods ============
|
|
963
|
-
updatePointer(
|
|
964
|
-
this._pointer.x =
|
|
989
|
+
updatePointer(e) {
|
|
990
|
+
this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object);
|
|
965
991
|
}
|
|
966
|
-
updatePointerState(
|
|
967
|
-
switch (
|
|
992
|
+
updatePointerState(e, t) {
|
|
993
|
+
switch (e.button) {
|
|
968
994
|
case 0:
|
|
969
|
-
this._pointerPrimaryDown =
|
|
995
|
+
this._pointerPrimaryDown = t;
|
|
970
996
|
break;
|
|
971
997
|
case 1:
|
|
972
|
-
this._pointerMiddleDown =
|
|
998
|
+
this._pointerMiddleDown = t;
|
|
973
999
|
break;
|
|
974
1000
|
case 2:
|
|
975
|
-
this._pointerSecondaryDown =
|
|
1001
|
+
this._pointerSecondaryDown = t;
|
|
976
1002
|
break;
|
|
977
1003
|
}
|
|
978
1004
|
}
|
|
979
1005
|
raycast() {
|
|
980
1006
|
this._raycaster.layers.mask = G | W;
|
|
981
|
-
const
|
|
982
|
-
(
|
|
1007
|
+
const e = this._scene.children.filter(
|
|
1008
|
+
(t) => t.visible && "isMesh" in t && t.isMesh
|
|
983
1009
|
);
|
|
984
|
-
return this._raycaster.intersectObjects(
|
|
1010
|
+
return this._raycaster.intersectObjects(e, !0);
|
|
985
1011
|
}
|
|
986
|
-
filterIntersectsByLayer(
|
|
987
|
-
return
|
|
988
|
-
(i) => (i.object.layers.mask &
|
|
1012
|
+
filterIntersectsByLayer(e, t) {
|
|
1013
|
+
return e.filter(
|
|
1014
|
+
(i) => (i.object.layers.mask & t) !== 0
|
|
989
1015
|
);
|
|
990
1016
|
}
|
|
991
1017
|
updateSortedTools() {
|
|
992
1018
|
this._sortedActiveTools = [...this._activeTools.values()].sort(
|
|
993
|
-
(
|
|
1019
|
+
(e, t) => e.priority - t.priority
|
|
994
1020
|
);
|
|
995
1021
|
}
|
|
996
1022
|
pointerWasDragged() {
|
|
997
|
-
return this._lastPointerDown.distanceTo(this._pointer) >
|
|
1023
|
+
return this._lastPointerDown.distanceTo(this._pointer) > se;
|
|
998
1024
|
}
|
|
999
1025
|
// ============ Legacy API Compatibility ============
|
|
1000
1026
|
/**
|
|
1001
1027
|
* @deprecated Use enableTool/disableTool instead.
|
|
1002
1028
|
* Enable or disable a tool by type.
|
|
1003
1029
|
*/
|
|
1004
|
-
useTool(
|
|
1005
|
-
const
|
|
1030
|
+
useTool(e) {
|
|
1031
|
+
const t = [
|
|
1006
1032
|
"hover",
|
|
1007
1033
|
"select",
|
|
1008
1034
|
"transform",
|
|
1009
1035
|
"drag"
|
|
1010
1036
|
];
|
|
1011
|
-
for (const i of
|
|
1012
|
-
(i ===
|
|
1037
|
+
for (const i of t)
|
|
1038
|
+
(i === e || e === "select") && this.enableTool(i);
|
|
1013
1039
|
}
|
|
1014
1040
|
/**
|
|
1015
1041
|
* @deprecated Use getActiveTools instead.
|
|
@@ -1019,8 +1045,8 @@ class de {
|
|
|
1019
1045
|
return this._sortedActiveTools[0] || null;
|
|
1020
1046
|
}
|
|
1021
1047
|
}
|
|
1022
|
-
class
|
|
1023
|
-
constructor(
|
|
1048
|
+
class _e {
|
|
1049
|
+
constructor(e, t) {
|
|
1024
1050
|
o(this, "POINTER_DRAG_THRESHOLD", 1e-3);
|
|
1025
1051
|
o(this, "name");
|
|
1026
1052
|
o(this, "_canvas");
|
|
@@ -1046,7 +1072,7 @@ class pe {
|
|
|
1046
1072
|
o(this, "_dragDelta");
|
|
1047
1073
|
o(this, "_draggable");
|
|
1048
1074
|
o(this, "_dragRaycastOnObjects");
|
|
1049
|
-
this.name = "BaseTool", this._canvas =
|
|
1075
|
+
this.name = "BaseTool", this._canvas = t.domElement, this._scene = e, this._controller = t, 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 h(), this._dragCurrent = new h(), this._dragEnd = new h(), this._dragDelta = new h(), this._draggable = null, this._dragRaycastOnObjects = null;
|
|
1050
1076
|
}
|
|
1051
1077
|
get _pointerAnyDown() {
|
|
1052
1078
|
return this._pointerPrimaryDown || this._pointerMiddleDown || this._pointerSecondaryDown;
|
|
@@ -1055,9 +1081,9 @@ class pe {
|
|
|
1055
1081
|
}
|
|
1056
1082
|
deactivate() {
|
|
1057
1083
|
}
|
|
1058
|
-
onPointerDown(
|
|
1059
|
-
var
|
|
1060
|
-
switch (
|
|
1084
|
+
onPointerDown(e) {
|
|
1085
|
+
var t;
|
|
1086
|
+
switch (e.button) {
|
|
1061
1087
|
case 0: {
|
|
1062
1088
|
this._pointerPrimaryDown = !0;
|
|
1063
1089
|
break;
|
|
@@ -1072,15 +1098,15 @@ class pe {
|
|
|
1072
1098
|
}
|
|
1073
1099
|
default:
|
|
1074
1100
|
console.warn(
|
|
1075
|
-
"DIVEBaseTool.onPointerDown: Unknown button: " +
|
|
1101
|
+
"DIVEBaseTool.onPointerDown: Unknown button: " + e.button
|
|
1076
1102
|
);
|
|
1077
1103
|
}
|
|
1078
1104
|
this._lastPointerDown.copy(this._pointer), this._draggable = B(
|
|
1079
|
-
(
|
|
1105
|
+
(t = this._intersects[0]) == null ? void 0 : t.object,
|
|
1080
1106
|
"isDraggable"
|
|
1081
1107
|
) || null;
|
|
1082
1108
|
}
|
|
1083
|
-
onDragStart(
|
|
1109
|
+
onDragStart(e) {
|
|
1084
1110
|
this._draggable && (this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
1085
1111
|
this._dragRaycastOnObjects,
|
|
1086
1112
|
!0
|
|
@@ -1091,34 +1117,34 @@ class pe {
|
|
|
1091
1117
|
dragDelta: this._dragDelta
|
|
1092
1118
|
}), this._dragging = !0, this._controller.enabled = !1)));
|
|
1093
1119
|
}
|
|
1094
|
-
onPointerMove(
|
|
1120
|
+
onPointerMove(e) {
|
|
1095
1121
|
var i;
|
|
1096
|
-
this._pointer.x =
|
|
1097
|
-
const
|
|
1122
|
+
this._pointer.x = e.offsetX / this._canvas.clientWidth * 2 - 1, this._pointer.y = -(e.offsetY / this._canvas.clientHeight) * 2 + 1, this._raycaster.setFromCamera(this._pointer, this._controller.object), this._intersects = this.raycast(this._scene.children);
|
|
1123
|
+
const t = B(
|
|
1098
1124
|
(i = this._intersects[0]) == null ? void 0 : i.object,
|
|
1099
1125
|
"isHoverable"
|
|
1100
1126
|
);
|
|
1101
|
-
if (this._intersects[0] &&
|
|
1127
|
+
if (this._intersects[0] && t) {
|
|
1102
1128
|
if (!this._hovered) {
|
|
1103
|
-
|
|
1129
|
+
t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
|
|
1104
1130
|
return;
|
|
1105
1131
|
}
|
|
1106
|
-
if (this._hovered.uuid !==
|
|
1107
|
-
this._hovered.onPointerLeave && this._hovered.onPointerLeave(),
|
|
1132
|
+
if (this._hovered.uuid !== t.uuid) {
|
|
1133
|
+
this._hovered.onPointerLeave && this._hovered.onPointerLeave(), t.onPointerEnter && t.onPointerEnter(this._intersects[0]), this._hovered = t;
|
|
1108
1134
|
return;
|
|
1109
1135
|
}
|
|
1110
|
-
|
|
1136
|
+
t.onPointerOver && t.onPointerOver(this._intersects[0]), this._hovered = t;
|
|
1111
1137
|
} else
|
|
1112
1138
|
this._hovered && this._hovered.onPointerLeave && this._hovered.onPointerLeave(), this._hovered = null;
|
|
1113
|
-
this._pointerAnyDown && (this._dragging || this.onDragStart(
|
|
1139
|
+
this._pointerAnyDown && (this._dragging || this.onDragStart(e), this.onDrag(e));
|
|
1114
1140
|
}
|
|
1115
|
-
onDrag(
|
|
1141
|
+
onDrag(e) {
|
|
1116
1142
|
this._dragRaycastOnObjects !== null && (this._intersects = this._raycaster.intersectObjects(
|
|
1117
1143
|
this._dragRaycastOnObjects,
|
|
1118
1144
|
!0
|
|
1119
1145
|
));
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1146
|
+
const t = this._intersects[0];
|
|
1147
|
+
t && (this._dragCurrent.copy(t.point.clone()), this._dragEnd.copy(t.point.clone()), this._dragDelta.subVectors(
|
|
1122
1148
|
this._dragCurrent.clone(),
|
|
1123
1149
|
this._dragStart.clone()
|
|
1124
1150
|
), this._draggable && this._draggable.onDrag && this._draggable.onDrag({
|
|
@@ -1128,8 +1154,8 @@ class pe {
|
|
|
1128
1154
|
dragDelta: this._dragDelta
|
|
1129
1155
|
}));
|
|
1130
1156
|
}
|
|
1131
|
-
onPointerUp(
|
|
1132
|
-
switch (this.pointerWasDragged() || this._dragging ? this._draggable && this.onDragEnd(
|
|
1157
|
+
onPointerUp(e) {
|
|
1158
|
+
switch (this.pointerWasDragged() || this._dragging ? this._draggable && this.onDragEnd(e) : this.onClick(e), e.button) {
|
|
1133
1159
|
case 0:
|
|
1134
1160
|
this._pointerPrimaryDown = !1;
|
|
1135
1161
|
break;
|
|
@@ -1142,11 +1168,11 @@ class pe {
|
|
|
1142
1168
|
}
|
|
1143
1169
|
this._lastPointerUp.copy(this._pointer);
|
|
1144
1170
|
}
|
|
1145
|
-
onClick(
|
|
1171
|
+
onClick(e) {
|
|
1146
1172
|
}
|
|
1147
|
-
onDragEnd(
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1173
|
+
onDragEnd(e) {
|
|
1174
|
+
const t = this._intersects[0];
|
|
1175
|
+
t && (this._dragEnd.copy(t.point.clone()), this._dragCurrent.copy(t.point.clone()), this._dragDelta.subVectors(
|
|
1150
1176
|
this._dragCurrent.clone(),
|
|
1151
1177
|
this._dragStart.clone()
|
|
1152
1178
|
)), this._draggable && this._draggable.onDragEnd && this._draggable.onDragEnd({
|
|
@@ -1156,10 +1182,10 @@ class pe {
|
|
|
1156
1182
|
dragDelta: this._dragDelta
|
|
1157
1183
|
}), 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
1184
|
}
|
|
1159
|
-
onWheel(
|
|
1185
|
+
onWheel(e) {
|
|
1160
1186
|
}
|
|
1161
|
-
raycast(
|
|
1162
|
-
const i = (
|
|
1187
|
+
raycast(e) {
|
|
1188
|
+
const i = (e || this._scene.children).filter(
|
|
1163
1189
|
(n) => n.visible && "isMesh" in n && n.isMesh
|
|
1164
1190
|
);
|
|
1165
1191
|
return this._raycaster.intersectObjects(i, !0);
|
|
@@ -1169,15 +1195,15 @@ class pe {
|
|
|
1169
1195
|
}
|
|
1170
1196
|
}
|
|
1171
1197
|
export {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1198
|
+
_e as DIVEBaseTool,
|
|
1199
|
+
qt as DIVESelectTool,
|
|
1200
|
+
te as DIVETransformTool,
|
|
1201
|
+
ie as DragTool,
|
|
1202
|
+
Wt as HoverTool,
|
|
1203
|
+
qt as SelectTool,
|
|
1204
|
+
Gt as SelectionState,
|
|
1205
|
+
pe as Toolbox,
|
|
1206
|
+
te as TransformTool,
|
|
1207
|
+
ce as isSelectTool,
|
|
1208
|
+
de as isTransformTool
|
|
1183
1209
|
};
|