@shopware-ag/dive 2.0.1-beta.9 → 2.0.2
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/README.md +7 -9
- package/build/chunks/AssetCache-CiC4wZkh.mjs +79 -0
- package/build/chunks/AssetCache-CuVztq_7.cjs +1 -0
- package/build/chunks/{AssetExporter-Ds2dAfxL.cjs → AssetExporter-DsbC2rqv.cjs} +18 -18
- package/build/chunks/{AssetExporter-CcSkkmZL.mjs → AssetExporter-brT7ogoM.mjs} +3 -4
- package/build/chunks/AssetLoader-DUhBw4FF.cjs +4 -0
- package/build/chunks/{AssetLoader-DjHz5xWK.mjs → AssetLoader-o_4syRGj.mjs} +32 -26
- package/build/chunks/FileTypes-B2VTJIm5.cjs +30 -0
- package/build/chunks/{FileTypes-Cu4s3c_0.mjs → FileTypes-C8pTXmiC.mjs} +155 -205
- package/build/chunks/OrbitController-BQ6SV1O_.mjs +1159 -0
- package/build/chunks/OrbitController-CpFQ3A1H.cjs +1 -0
- package/build/chunks/PerspectiveCamera-BByyG5R4.cjs +1 -0
- package/build/chunks/PerspectiveCamera-PMJPzAn3.mjs +34 -0
- package/build/chunks/{SelectTool-w7sF1obN.mjs → SelectTool-6ZRGPwYE.mjs} +4 -4
- package/build/chunks/SelectTool-B1awJ9PA.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-BI7jPKdx.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-CXgt1fJc.mjs +8 -0
- package/build/chunks/package-AmvzOXm_.cjs +1 -0
- package/build/chunks/package-BrpVRfq7.mjs +39 -0
- package/build/chunks/parse-error-DfOPyLWM.mjs +14 -0
- package/build/chunks/parse-error-Dy_EE4rL.cjs +1 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +293 -223
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +13 -13
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -0
- package/build/plugins/orientationdisplay/index.d.ts +2 -0
- package/build/plugins/orientationdisplay/index.mjs +5 -0
- package/build/plugins/state/index.cjs +6 -6
- package/build/plugins/state/index.mjs +728 -728
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +12 -12
- package/build/src/components/boundingbox/BoundingBox.d.ts +136 -0
- package/build/src/components/light/AmbientLight.d.ts +3 -1
- package/build/src/components/light/SceneLight.d.ts +3 -1
- package/build/src/core/Dive.d.ts +1 -1
- package/build/src/helpers/deepClone/deepClone.d.ts +34 -0
- package/build/src/helpers/index.d.ts +5 -4
- package/build/src/plugins/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +2 -2
- package/build/src/plugins/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +2 -2
- package/build/src/plugins/assetcache/src/cache/AssetCache.d.ts +5 -4
- package/build/src/plugins/assetcache/src/chunk/Chunk.d.ts +4 -7
- package/build/src/plugins/assetloader/src/loader/AssetLoader.d.ts +7 -0
- package/build/src/plugins/mediacreator/index.d.ts +1 -0
- package/build/src/plugins/mediacreator/src/MediaCreator.d.ts +2 -2
- package/build/src/plugins/mediacreator/types/MediaGenerationById.d.ts +5 -0
- package/build/src/plugins/mediacreator/types/MediaGenerationByPosition.d.ts +7 -0
- package/build/src/plugins/mediacreator/types/MediaGenerationResolution.d.ts +4 -0
- package/build/src/plugins/mediacreator/types/index.d.ts +3 -0
- package/build/src/plugins/orbitcontroller/src/OrbitController.d.ts +17 -2
- package/build/src/plugins/orientationdisplay/index.d.ts +2 -0
- package/build/src/plugins/{axiscamera/src/AxisCamera.d.ts → orientationdisplay/src/OrientationDisplay.d.ts} +5 -5
- package/build/src/plugins/orientationdisplay/src/axes/Axes.d.ts +6 -0
- package/build/src/plugins/state/src/actions/action.d.ts +4 -4
- package/build/src/plugins/state/src/actions/media/generatemedia.d.ts +2 -18
- package/build/src/plugins/state/src/actions/toolbox/setgizmovisible.d.ts +2 -2
- package/build/src/plugins/state/types/index.d.ts +2 -0
- package/build/src/plugins/toolbox/index.d.ts +1 -0
- package/build/src/plugins/toolbox/src/Toolbox.d.ts +2 -2
- package/build/src/plugins/toolbox/src/transform/TransformTool.d.ts +1 -1
- package/build/src/plugins/toolbox/types/ToolType.d.ts +1 -0
- package/build/src/plugins/toolbox/types/index.d.ts +1 -0
- package/package.json +7 -9
- package/build/chunks/AssetCache-CWeKL4PT.cjs +0 -1
- package/build/chunks/AssetCache-Y5G3mQU1.mjs +0 -84
- package/build/chunks/AssetLoader-CMKzMJ1u.cjs +0 -4
- package/build/chunks/FileTypes-CKOjpHjz.cjs +0 -30
- package/build/chunks/OrbitController-D-WNei2f.mjs +0 -940
- package/build/chunks/OrbitController-rMX8EHvJ.cjs +0 -1
- package/build/chunks/PerspectiveCamera-CONx93im.cjs +0 -1
- package/build/chunks/PerspectiveCamera-DUiWJJIj.mjs +0 -38
- package/build/chunks/SelectTool-BD6Ccy_2.cjs +0 -1
- package/build/chunks/file-type-error-BsK7IJt7.cjs +0 -1
- package/build/chunks/file-type-error-aWHfMumr.mjs +0 -8
- package/build/chunks/package-DXbIn_zz.mjs +0 -39
- package/build/chunks/package-DaKgG9tF.cjs +0 -1
- package/build/chunks/parse-error-IryNa_oq.mjs +0 -8
- package/build/chunks/parse-error-m5cNt1UV.cjs +0 -1
- package/build/plugins/axiscamera/index.cjs +0 -1
- package/build/plugins/axiscamera/index.d.ts +0 -2
- package/build/plugins/axiscamera/index.mjs +0 -4
- package/build/src/plugins/axiscamera/index.d.ts +0 -1
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var se = (S, e, i) => e in S ? ie(S, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : S[e] = i;
|
|
3
|
+
var z = (S, e, i) => se(S, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { Ray as ne, Plane as oe, MathUtils as ae, EventDispatcher as re, Vector3 as b, MOUSE as H, TOUCH as F, Spherical as St, Quaternion as ht, Vector2 as D, Object3D as he, Box3 as Rt, Box3Helper as ce, Sphere as le, SphereGeometry as ue, Mesh as pe, MeshBasicMaterial as me } from "three";
|
|
5
|
+
import { c as Nt, M as nt } from "./MathUtils-CFGjHuVF.mjs";
|
|
6
|
+
import { P as de } from "./VisibilityLayerMask-CXgt1fJc.mjs";
|
|
7
|
+
const At = { type: "change" }, ot = { type: "start" }, jt = { type: "end" }, G = new ne(), kt = new oe(), ye = Math.cos(70 * ae.DEG2RAD);
|
|
8
|
+
class xe extends re {
|
|
9
|
+
constructor(e, i) {
|
|
10
|
+
super(), this.object = e, this.domElement = i, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new b(), this.cursor = new b(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: H.ROTATE, MIDDLE: H.DOLLY, RIGHT: H.PAN }, this.touches = { ONE: F.ROTATE, TWO: F.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() {
|
|
11
|
+
return r.phi;
|
|
12
|
+
}, this.getAzimuthalAngle = function() {
|
|
13
|
+
return r.theta;
|
|
14
|
+
}, this.getDistance = function() {
|
|
15
|
+
return this.object.position.distanceTo(this.target);
|
|
16
|
+
}, this.listenToKeyEvents = function(s) {
|
|
17
|
+
s.addEventListener("keydown", st), this._domElementKeyEvents = s;
|
|
18
|
+
}, this.stopListenToKeyEvents = function() {
|
|
19
|
+
this._domElementKeyEvents.removeEventListener("keydown", st), this._domElementKeyEvents = null;
|
|
20
|
+
}, this.saveState = function() {
|
|
21
|
+
t.target0.copy(t.target), t.position0.copy(t.object.position), t.zoom0 = t.object.zoom;
|
|
22
|
+
}, this.reset = function() {
|
|
23
|
+
t.target.copy(t.target0), t.object.position.copy(t.position0), t.object.zoom = t.zoom0, t.object.updateProjectionMatrix(), t.dispatchEvent(At), t.update(), n = o.NONE;
|
|
24
|
+
}, this.update = function() {
|
|
25
|
+
const s = new b(), l = new ht().setFromUnitVectors(e.up, new b(0, 1, 0)), x = l.clone().invert(), _ = new b(), w = new ht(), L = new b(), T = 2 * Math.PI;
|
|
26
|
+
return function(ee = null) {
|
|
27
|
+
const Dt = t.object.position;
|
|
28
|
+
s.copy(Dt).sub(t.target), s.applyQuaternion(l), r.setFromVector3(s), t.autoRotate && n === o.NONE && B(It(ee)), t.enableDamping ? (r.theta += p.theta * t.dampingFactor, r.phi += p.phi * t.dampingFactor) : (r.theta += p.theta, r.phi += p.phi);
|
|
29
|
+
let j = t.minAzimuthAngle, k = t.maxAzimuthAngle;
|
|
30
|
+
isFinite(j) && isFinite(k) && (j < -Math.PI ? j += T : j > Math.PI && (j -= T), k < -Math.PI ? k += T : k > Math.PI && (k -= T), j <= k ? r.theta = Math.max(j, Math.min(k, r.theta)) : r.theta = r.theta > (j + k) / 2 ? Math.max(j, r.theta) : Math.min(k, r.theta)), r.phi = Math.max(t.minPolarAngle, Math.min(t.maxPolarAngle, r.phi)), r.makeSafe(), t.enableDamping === !0 ? t.target.addScaledVector(c, t.dampingFactor) : t.target.add(c), t.target.sub(t.cursor), t.target.clampLength(t.minTargetRadius, t.maxTargetRadius), t.target.add(t.cursor);
|
|
31
|
+
let X = !1;
|
|
32
|
+
if (t.zoomToCursor && N || t.object.isOrthographicCamera)
|
|
33
|
+
r.radius = et(r.radius);
|
|
34
|
+
else {
|
|
35
|
+
const O = r.radius;
|
|
36
|
+
r.radius = et(r.radius * a), X = O != r.radius;
|
|
37
|
+
}
|
|
38
|
+
if (s.setFromSpherical(r), s.applyQuaternion(x), Dt.copy(t.target).add(s), t.object.lookAt(t.target), t.enableDamping === !0 ? (p.theta *= 1 - t.dampingFactor, p.phi *= 1 - t.dampingFactor, c.multiplyScalar(1 - t.dampingFactor)) : (p.set(0, 0, 0), c.set(0, 0, 0)), t.zoomToCursor && N) {
|
|
39
|
+
let O = null;
|
|
40
|
+
if (t.object.isPerspectiveCamera) {
|
|
41
|
+
const K = s.length();
|
|
42
|
+
O = et(K * a);
|
|
43
|
+
const Q = K - O;
|
|
44
|
+
t.object.position.addScaledVector(R, Q), t.object.updateMatrixWorld(), X = !!Q;
|
|
45
|
+
} else if (t.object.isOrthographicCamera) {
|
|
46
|
+
const K = new b(f.x, f.y, 0);
|
|
47
|
+
K.unproject(t.object);
|
|
48
|
+
const Q = t.object.zoom;
|
|
49
|
+
t.object.zoom = Math.max(t.minZoom, Math.min(t.maxZoom, t.object.zoom / a)), t.object.updateProjectionMatrix(), X = Q !== t.object.zoom;
|
|
50
|
+
const Ct = new b(f.x, f.y, 0);
|
|
51
|
+
Ct.unproject(t.object), t.object.position.sub(Ct).add(K), t.object.updateMatrixWorld(), O = s.length();
|
|
52
|
+
} else
|
|
53
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), t.zoomToCursor = !1;
|
|
54
|
+
O !== null && (this.screenSpacePanning ? t.target.set(0, 0, -1).transformDirection(t.object.matrix).multiplyScalar(O).add(t.object.position) : (G.origin.copy(t.object.position), G.direction.set(0, 0, -1).transformDirection(t.object.matrix), Math.abs(t.object.up.dot(G.direction)) < ye ? e.lookAt(t.target) : (kt.setFromNormalAndCoplanarPoint(t.object.up, t.target), G.intersectPlane(kt, t.target))));
|
|
55
|
+
} else if (t.object.isOrthographicCamera) {
|
|
56
|
+
const O = t.object.zoom;
|
|
57
|
+
t.object.zoom = Math.max(t.minZoom, Math.min(t.maxZoom, t.object.zoom / a)), O !== t.object.zoom && (t.object.updateProjectionMatrix(), X = !0);
|
|
58
|
+
}
|
|
59
|
+
return a = 1, N = !1, X || _.distanceToSquared(t.object.position) > d || 8 * (1 - w.dot(t.object.quaternion)) > d || L.distanceToSquared(t.target) > d ? (t.dispatchEvent(At), _.copy(t.object.position), w.copy(t.object.quaternion), L.copy(t.target), !0) : !1;
|
|
60
|
+
};
|
|
61
|
+
}(), this.dispose = function() {
|
|
62
|
+
t.domElement.removeEventListener("contextmenu", Tt), t.domElement.removeEventListener("pointerdown", zt), t.domElement.removeEventListener("pointercancel", U), t.domElement.removeEventListener("wheel", bt), t.domElement.removeEventListener("pointermove", it), t.domElement.removeEventListener("pointerup", U), t.domElement.getRootNode().removeEventListener("keydown", Mt, { capture: !0 }), t._domElementKeyEvents !== null && (t._domElementKeyEvents.removeEventListener("keydown", st), t._domElementKeyEvents = null);
|
|
63
|
+
};
|
|
64
|
+
const t = this, o = {
|
|
65
|
+
NONE: -1,
|
|
66
|
+
ROTATE: 0,
|
|
67
|
+
DOLLY: 1,
|
|
68
|
+
PAN: 2,
|
|
69
|
+
TOUCH_ROTATE: 3,
|
|
70
|
+
TOUCH_PAN: 4,
|
|
71
|
+
TOUCH_DOLLY_PAN: 5,
|
|
72
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
73
|
+
};
|
|
74
|
+
let n = o.NONE;
|
|
75
|
+
const d = 1e-6, r = new St(), p = new St();
|
|
76
|
+
let a = 1;
|
|
77
|
+
const c = new b(), u = new D(), m = new D(), h = new D(), y = new D(), E = new D(), M = new D(), P = new D(), A = new D(), C = new D(), R = new b(), f = new D();
|
|
78
|
+
let N = !1;
|
|
79
|
+
const g = [], Z = {};
|
|
80
|
+
let $ = !1;
|
|
81
|
+
function It(s) {
|
|
82
|
+
return s !== null ? 2 * Math.PI / 60 * t.autoRotateSpeed * s : 2 * Math.PI / 60 / 60 * t.autoRotateSpeed;
|
|
83
|
+
}
|
|
84
|
+
function q(s) {
|
|
85
|
+
const l = Math.abs(s * 0.01);
|
|
86
|
+
return Math.pow(0.95, t.zoomSpeed * l);
|
|
87
|
+
}
|
|
88
|
+
function B(s) {
|
|
89
|
+
p.theta -= s;
|
|
90
|
+
}
|
|
91
|
+
function W(s) {
|
|
92
|
+
p.phi -= s;
|
|
93
|
+
}
|
|
94
|
+
const ct = function() {
|
|
95
|
+
const s = new b();
|
|
96
|
+
return function(x, _) {
|
|
97
|
+
s.setFromMatrixColumn(_, 0), s.multiplyScalar(-x), c.add(s);
|
|
98
|
+
};
|
|
99
|
+
}(), lt = function() {
|
|
100
|
+
const s = new b();
|
|
101
|
+
return function(x, _) {
|
|
102
|
+
t.screenSpacePanning === !0 ? s.setFromMatrixColumn(_, 1) : (s.setFromMatrixColumn(_, 0), s.crossVectors(t.object.up, s)), s.multiplyScalar(x), c.add(s);
|
|
103
|
+
};
|
|
104
|
+
}(), I = function() {
|
|
105
|
+
const s = new b();
|
|
106
|
+
return function(x, _) {
|
|
107
|
+
const w = t.domElement;
|
|
108
|
+
if (t.object.isPerspectiveCamera) {
|
|
109
|
+
const L = t.object.position;
|
|
110
|
+
s.copy(L).sub(t.target);
|
|
111
|
+
let T = s.length();
|
|
112
|
+
T *= Math.tan(t.object.fov / 2 * Math.PI / 180), ct(2 * x * T / w.clientHeight, t.object.matrix), lt(2 * _ * T / w.clientHeight, t.object.matrix);
|
|
113
|
+
} else t.object.isOrthographicCamera ? (ct(x * (t.object.right - t.object.left) / t.object.zoom / w.clientWidth, t.object.matrix), lt(_ * (t.object.top - t.object.bottom) / t.object.zoom / w.clientHeight, t.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), t.enablePan = !1);
|
|
114
|
+
};
|
|
115
|
+
}();
|
|
116
|
+
function v(s) {
|
|
117
|
+
t.object.isPerspectiveCamera || t.object.isOrthographicCamera ? a /= s : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), t.enableZoom = !1);
|
|
118
|
+
}
|
|
119
|
+
function ut(s) {
|
|
120
|
+
t.object.isPerspectiveCamera || t.object.isOrthographicCamera ? a *= s : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), t.enableZoom = !1);
|
|
121
|
+
}
|
|
122
|
+
function tt(s, l) {
|
|
123
|
+
if (!t.zoomToCursor)
|
|
124
|
+
return;
|
|
125
|
+
N = !0;
|
|
126
|
+
const x = t.domElement.getBoundingClientRect(), _ = s - x.left, w = l - x.top, L = x.width, T = x.height;
|
|
127
|
+
f.x = _ / L * 2 - 1, f.y = -(w / T) * 2 + 1, R.set(f.x, f.y, 1).unproject(t.object).sub(t.object.position).normalize();
|
|
128
|
+
}
|
|
129
|
+
function et(s) {
|
|
130
|
+
return Math.max(t.minDistance, Math.min(t.maxDistance, s));
|
|
131
|
+
}
|
|
132
|
+
function pt(s) {
|
|
133
|
+
u.set(s.clientX, s.clientY);
|
|
134
|
+
}
|
|
135
|
+
function Yt(s) {
|
|
136
|
+
tt(s.clientX, s.clientX), P.set(s.clientX, s.clientY);
|
|
137
|
+
}
|
|
138
|
+
function mt(s) {
|
|
139
|
+
y.set(s.clientX, s.clientY);
|
|
140
|
+
}
|
|
141
|
+
function Ht(s) {
|
|
142
|
+
m.set(s.clientX, s.clientY), h.subVectors(m, u).multiplyScalar(t.rotateSpeed);
|
|
143
|
+
const l = t.domElement;
|
|
144
|
+
B(2 * Math.PI * h.x / l.clientHeight), W(2 * Math.PI * h.y / l.clientHeight), u.copy(m), t.update();
|
|
145
|
+
}
|
|
146
|
+
function Ft(s) {
|
|
147
|
+
A.set(s.clientX, s.clientY), C.subVectors(A, P), C.y > 0 ? v(q(C.y)) : C.y < 0 && ut(q(C.y)), P.copy(A), t.update();
|
|
148
|
+
}
|
|
149
|
+
function Zt(s) {
|
|
150
|
+
E.set(s.clientX, s.clientY), M.subVectors(E, y).multiplyScalar(t.panSpeed), I(M.x, M.y), y.copy(E), t.update();
|
|
151
|
+
}
|
|
152
|
+
function Bt(s) {
|
|
153
|
+
tt(s.clientX, s.clientY), s.deltaY < 0 ? ut(q(s.deltaY)) : s.deltaY > 0 && v(q(s.deltaY)), t.update();
|
|
154
|
+
}
|
|
155
|
+
function Ut(s) {
|
|
156
|
+
let l = !1;
|
|
157
|
+
switch (s.code) {
|
|
158
|
+
case t.keys.UP:
|
|
159
|
+
s.ctrlKey || s.metaKey || s.shiftKey ? W(2 * Math.PI * t.rotateSpeed / t.domElement.clientHeight) : I(0, t.keyPanSpeed), l = !0;
|
|
160
|
+
break;
|
|
161
|
+
case t.keys.BOTTOM:
|
|
162
|
+
s.ctrlKey || s.metaKey || s.shiftKey ? W(-2 * Math.PI * t.rotateSpeed / t.domElement.clientHeight) : I(0, -t.keyPanSpeed), l = !0;
|
|
163
|
+
break;
|
|
164
|
+
case t.keys.LEFT:
|
|
165
|
+
s.ctrlKey || s.metaKey || s.shiftKey ? B(2 * Math.PI * t.rotateSpeed / t.domElement.clientHeight) : I(t.keyPanSpeed, 0), l = !0;
|
|
166
|
+
break;
|
|
167
|
+
case t.keys.RIGHT:
|
|
168
|
+
s.ctrlKey || s.metaKey || s.shiftKey ? B(-2 * Math.PI * t.rotateSpeed / t.domElement.clientHeight) : I(-t.keyPanSpeed, 0), l = !0;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
l && (s.preventDefault(), t.update());
|
|
172
|
+
}
|
|
173
|
+
function dt(s) {
|
|
174
|
+
if (g.length === 1)
|
|
175
|
+
u.set(s.pageX, s.pageY);
|
|
176
|
+
else {
|
|
177
|
+
const l = Y(s), x = 0.5 * (s.pageX + l.x), _ = 0.5 * (s.pageY + l.y);
|
|
178
|
+
u.set(x, _);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function yt(s) {
|
|
182
|
+
if (g.length === 1)
|
|
183
|
+
y.set(s.pageX, s.pageY);
|
|
184
|
+
else {
|
|
185
|
+
const l = Y(s), x = 0.5 * (s.pageX + l.x), _ = 0.5 * (s.pageY + l.y);
|
|
186
|
+
y.set(x, _);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function xt(s) {
|
|
190
|
+
const l = Y(s), x = s.pageX - l.x, _ = s.pageY - l.y, w = Math.sqrt(x * x + _ * _);
|
|
191
|
+
P.set(0, w);
|
|
192
|
+
}
|
|
193
|
+
function Xt(s) {
|
|
194
|
+
t.enableZoom && xt(s), t.enablePan && yt(s);
|
|
195
|
+
}
|
|
196
|
+
function Kt(s) {
|
|
197
|
+
t.enableZoom && xt(s), t.enableRotate && dt(s);
|
|
198
|
+
}
|
|
199
|
+
function _t(s) {
|
|
200
|
+
if (g.length == 1)
|
|
201
|
+
m.set(s.pageX, s.pageY);
|
|
202
|
+
else {
|
|
203
|
+
const x = Y(s), _ = 0.5 * (s.pageX + x.x), w = 0.5 * (s.pageY + x.y);
|
|
204
|
+
m.set(_, w);
|
|
205
|
+
}
|
|
206
|
+
h.subVectors(m, u).multiplyScalar(t.rotateSpeed);
|
|
207
|
+
const l = t.domElement;
|
|
208
|
+
B(2 * Math.PI * h.x / l.clientHeight), W(2 * Math.PI * h.y / l.clientHeight), u.copy(m);
|
|
209
|
+
}
|
|
210
|
+
function ft(s) {
|
|
211
|
+
if (g.length === 1)
|
|
212
|
+
E.set(s.pageX, s.pageY);
|
|
213
|
+
else {
|
|
214
|
+
const l = Y(s), x = 0.5 * (s.pageX + l.x), _ = 0.5 * (s.pageY + l.y);
|
|
215
|
+
E.set(x, _);
|
|
216
|
+
}
|
|
217
|
+
M.subVectors(E, y).multiplyScalar(t.panSpeed), I(M.x, M.y), y.copy(E);
|
|
218
|
+
}
|
|
219
|
+
function gt(s) {
|
|
220
|
+
const l = Y(s), x = s.pageX - l.x, _ = s.pageY - l.y, w = Math.sqrt(x * x + _ * _);
|
|
221
|
+
A.set(0, w), C.set(0, Math.pow(A.y / P.y, t.zoomSpeed)), v(C.y), P.copy(A);
|
|
222
|
+
const L = (s.pageX + l.x) * 0.5, T = (s.pageY + l.y) * 0.5;
|
|
223
|
+
tt(L, T);
|
|
224
|
+
}
|
|
225
|
+
function Vt(s) {
|
|
226
|
+
t.enableZoom && gt(s), t.enablePan && ft(s);
|
|
227
|
+
}
|
|
228
|
+
function qt(s) {
|
|
229
|
+
t.enableZoom && gt(s), t.enableRotate && _t(s);
|
|
230
|
+
}
|
|
231
|
+
function zt(s) {
|
|
232
|
+
t.enabled !== !1 && (g.length === 0 && (t.domElement.setPointerCapture(s.pointerId), t.domElement.addEventListener("pointermove", it), t.domElement.addEventListener("pointerup", U)), !te(s) && ($t(s), s.pointerType === "touch" ? Et(s) : Wt(s)));
|
|
233
|
+
}
|
|
234
|
+
function it(s) {
|
|
235
|
+
t.enabled !== !1 && (s.pointerType === "touch" ? Jt(s) : Qt(s));
|
|
236
|
+
}
|
|
237
|
+
function U(s) {
|
|
238
|
+
switch (vt(s), g.length) {
|
|
239
|
+
case 0:
|
|
240
|
+
t.domElement.releasePointerCapture(s.pointerId), t.domElement.removeEventListener("pointermove", it), t.domElement.removeEventListener("pointerup", U), t.dispatchEvent(jt), n = o.NONE;
|
|
241
|
+
break;
|
|
242
|
+
case 1:
|
|
243
|
+
const l = g[0], x = Z[l];
|
|
244
|
+
Et({ pointerId: l, pageX: x.x, pageY: x.y });
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function Wt(s) {
|
|
249
|
+
let l;
|
|
250
|
+
switch (s.button) {
|
|
251
|
+
case 0:
|
|
252
|
+
l = t.mouseButtons.LEFT;
|
|
253
|
+
break;
|
|
254
|
+
case 1:
|
|
255
|
+
l = t.mouseButtons.MIDDLE;
|
|
256
|
+
break;
|
|
257
|
+
case 2:
|
|
258
|
+
l = t.mouseButtons.RIGHT;
|
|
259
|
+
break;
|
|
260
|
+
default:
|
|
261
|
+
l = -1;
|
|
262
|
+
}
|
|
263
|
+
switch (l) {
|
|
264
|
+
case H.DOLLY:
|
|
265
|
+
if (t.enableZoom === !1) return;
|
|
266
|
+
Yt(s), n = o.DOLLY;
|
|
267
|
+
break;
|
|
268
|
+
case H.ROTATE:
|
|
269
|
+
if (s.ctrlKey || s.metaKey || s.shiftKey) {
|
|
270
|
+
if (t.enablePan === !1) return;
|
|
271
|
+
mt(s), n = o.PAN;
|
|
272
|
+
} else {
|
|
273
|
+
if (t.enableRotate === !1) return;
|
|
274
|
+
pt(s), n = o.ROTATE;
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case H.PAN:
|
|
278
|
+
if (s.ctrlKey || s.metaKey || s.shiftKey) {
|
|
279
|
+
if (t.enableRotate === !1) return;
|
|
280
|
+
pt(s), n = o.ROTATE;
|
|
281
|
+
} else {
|
|
282
|
+
if (t.enablePan === !1) return;
|
|
283
|
+
mt(s), n = o.PAN;
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
n = o.NONE;
|
|
288
|
+
}
|
|
289
|
+
n !== o.NONE && t.dispatchEvent(ot);
|
|
290
|
+
}
|
|
291
|
+
function Qt(s) {
|
|
292
|
+
switch (n) {
|
|
293
|
+
case o.ROTATE:
|
|
294
|
+
if (t.enableRotate === !1) return;
|
|
295
|
+
Ht(s);
|
|
296
|
+
break;
|
|
297
|
+
case o.DOLLY:
|
|
298
|
+
if (t.enableZoom === !1) return;
|
|
299
|
+
Ft(s);
|
|
300
|
+
break;
|
|
301
|
+
case o.PAN:
|
|
302
|
+
if (t.enablePan === !1) return;
|
|
303
|
+
Zt(s);
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function bt(s) {
|
|
308
|
+
t.enabled === !1 || t.enableZoom === !1 || n !== o.NONE || (s.preventDefault(), t.dispatchEvent(ot), Bt(Gt(s)), t.dispatchEvent(jt));
|
|
309
|
+
}
|
|
310
|
+
function Gt(s) {
|
|
311
|
+
const l = s.deltaMode, x = {
|
|
312
|
+
clientX: s.clientX,
|
|
313
|
+
clientY: s.clientY,
|
|
314
|
+
deltaY: s.deltaY
|
|
315
|
+
};
|
|
316
|
+
switch (l) {
|
|
317
|
+
case 1:
|
|
318
|
+
x.deltaY *= 16;
|
|
319
|
+
break;
|
|
320
|
+
case 2:
|
|
321
|
+
x.deltaY *= 100;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
return s.ctrlKey && !$ && (x.deltaY *= 10), x;
|
|
325
|
+
}
|
|
326
|
+
function Mt(s) {
|
|
327
|
+
s.key === "Control" && ($ = !0, t.domElement.getRootNode().addEventListener("keyup", wt, { passive: !0, capture: !0 }));
|
|
328
|
+
}
|
|
329
|
+
function wt(s) {
|
|
330
|
+
s.key === "Control" && ($ = !1, t.domElement.getRootNode().removeEventListener("keyup", wt, { passive: !0, capture: !0 }));
|
|
331
|
+
}
|
|
332
|
+
function st(s) {
|
|
333
|
+
t.enabled === !1 || t.enablePan === !1 || Ut(s);
|
|
334
|
+
}
|
|
335
|
+
function Et(s) {
|
|
336
|
+
switch (Pt(s), g.length) {
|
|
337
|
+
case 1:
|
|
338
|
+
switch (t.touches.ONE) {
|
|
339
|
+
case F.ROTATE:
|
|
340
|
+
if (t.enableRotate === !1) return;
|
|
341
|
+
dt(s), n = o.TOUCH_ROTATE;
|
|
342
|
+
break;
|
|
343
|
+
case F.PAN:
|
|
344
|
+
if (t.enablePan === !1) return;
|
|
345
|
+
yt(s), n = o.TOUCH_PAN;
|
|
346
|
+
break;
|
|
347
|
+
default:
|
|
348
|
+
n = o.NONE;
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
case 2:
|
|
352
|
+
switch (t.touches.TWO) {
|
|
353
|
+
case F.DOLLY_PAN:
|
|
354
|
+
if (t.enableZoom === !1 && t.enablePan === !1) return;
|
|
355
|
+
Xt(s), n = o.TOUCH_DOLLY_PAN;
|
|
356
|
+
break;
|
|
357
|
+
case F.DOLLY_ROTATE:
|
|
358
|
+
if (t.enableZoom === !1 && t.enableRotate === !1) return;
|
|
359
|
+
Kt(s), n = o.TOUCH_DOLLY_ROTATE;
|
|
360
|
+
break;
|
|
361
|
+
default:
|
|
362
|
+
n = o.NONE;
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
default:
|
|
366
|
+
n = o.NONE;
|
|
367
|
+
}
|
|
368
|
+
n !== o.NONE && t.dispatchEvent(ot);
|
|
369
|
+
}
|
|
370
|
+
function Jt(s) {
|
|
371
|
+
switch (Pt(s), n) {
|
|
372
|
+
case o.TOUCH_ROTATE:
|
|
373
|
+
if (t.enableRotate === !1) return;
|
|
374
|
+
_t(s), t.update();
|
|
375
|
+
break;
|
|
376
|
+
case o.TOUCH_PAN:
|
|
377
|
+
if (t.enablePan === !1) return;
|
|
378
|
+
ft(s), t.update();
|
|
379
|
+
break;
|
|
380
|
+
case o.TOUCH_DOLLY_PAN:
|
|
381
|
+
if (t.enableZoom === !1 && t.enablePan === !1) return;
|
|
382
|
+
Vt(s), t.update();
|
|
383
|
+
break;
|
|
384
|
+
case o.TOUCH_DOLLY_ROTATE:
|
|
385
|
+
if (t.enableZoom === !1 && t.enableRotate === !1) return;
|
|
386
|
+
qt(s), t.update();
|
|
387
|
+
break;
|
|
388
|
+
default:
|
|
389
|
+
n = o.NONE;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function Tt(s) {
|
|
393
|
+
t.enabled !== !1 && s.preventDefault();
|
|
394
|
+
}
|
|
395
|
+
function $t(s) {
|
|
396
|
+
g.push(s.pointerId);
|
|
397
|
+
}
|
|
398
|
+
function vt(s) {
|
|
399
|
+
delete Z[s.pointerId];
|
|
400
|
+
for (let l = 0; l < g.length; l++)
|
|
401
|
+
if (g[l] == s.pointerId) {
|
|
402
|
+
g.splice(l, 1);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function te(s) {
|
|
407
|
+
for (let l = 0; l < g.length; l++)
|
|
408
|
+
if (g[l] == s.pointerId) return !0;
|
|
409
|
+
return !1;
|
|
410
|
+
}
|
|
411
|
+
function Pt(s) {
|
|
412
|
+
let l = Z[s.pointerId];
|
|
413
|
+
l === void 0 && (l = new D(), Z[s.pointerId] = l), l.set(s.pageX, s.pageY);
|
|
414
|
+
}
|
|
415
|
+
function Y(s) {
|
|
416
|
+
const l = s.pointerId === g[0] ? g[1] : g[0];
|
|
417
|
+
return Z[l];
|
|
418
|
+
}
|
|
419
|
+
t.domElement.addEventListener("contextmenu", Tt), t.domElement.addEventListener("pointerdown", zt), t.domElement.addEventListener("pointercancel", U), t.domElement.addEventListener("wheel", bt, { passive: !1 }), t.domElement.getRootNode().addEventListener("keydown", Mt, { passive: !0, capture: !0 }), this.update();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
class _e {
|
|
423
|
+
constructor(e = 0, i = 0, t = 0, o = 1) {
|
|
424
|
+
this.isQuaternion = !0, this._x = e, this._y = i, this._z = t, this._w = o;
|
|
425
|
+
}
|
|
426
|
+
static slerpFlat(e, i, t, o, n, d, r) {
|
|
427
|
+
let p = t[o + 0], a = t[o + 1], c = t[o + 2], u = t[o + 3];
|
|
428
|
+
const m = n[d + 0], h = n[d + 1], y = n[d + 2], E = n[d + 3];
|
|
429
|
+
if (r === 0) {
|
|
430
|
+
e[i + 0] = p, e[i + 1] = a, e[i + 2] = c, e[i + 3] = u;
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (r === 1) {
|
|
434
|
+
e[i + 0] = m, e[i + 1] = h, e[i + 2] = y, e[i + 3] = E;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (u !== E || p !== m || a !== h || c !== y) {
|
|
438
|
+
let M = 1 - r;
|
|
439
|
+
const P = p * m + a * h + c * y + u * E, A = P >= 0 ? 1 : -1, C = 1 - P * P;
|
|
440
|
+
if (C > Number.EPSILON) {
|
|
441
|
+
const f = Math.sqrt(C), N = Math.atan2(f, P * A);
|
|
442
|
+
M = Math.sin(M * N) / f, r = Math.sin(r * N) / f;
|
|
443
|
+
}
|
|
444
|
+
const R = r * A;
|
|
445
|
+
if (p = p * M + m * R, a = a * M + h * R, c = c * M + y * R, u = u * M + E * R, M === 1 - r) {
|
|
446
|
+
const f = 1 / Math.sqrt(p * p + a * a + c * c + u * u);
|
|
447
|
+
p *= f, a *= f, c *= f, u *= f;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
e[i] = p, e[i + 1] = a, e[i + 2] = c, e[i + 3] = u;
|
|
451
|
+
}
|
|
452
|
+
static multiplyQuaternionsFlat(e, i, t, o, n, d) {
|
|
453
|
+
const r = t[o], p = t[o + 1], a = t[o + 2], c = t[o + 3], u = n[d], m = n[d + 1], h = n[d + 2], y = n[d + 3];
|
|
454
|
+
return e[i] = r * y + c * u + p * h - a * m, e[i + 1] = p * y + c * m + a * u - r * h, e[i + 2] = a * y + c * h + r * m - p * u, e[i + 3] = c * y - r * u - p * m - a * h, e;
|
|
455
|
+
}
|
|
456
|
+
get x() {
|
|
457
|
+
return this._x;
|
|
458
|
+
}
|
|
459
|
+
set x(e) {
|
|
460
|
+
this._x = e, this._onChangeCallback();
|
|
461
|
+
}
|
|
462
|
+
get y() {
|
|
463
|
+
return this._y;
|
|
464
|
+
}
|
|
465
|
+
set y(e) {
|
|
466
|
+
this._y = e, this._onChangeCallback();
|
|
467
|
+
}
|
|
468
|
+
get z() {
|
|
469
|
+
return this._z;
|
|
470
|
+
}
|
|
471
|
+
set z(e) {
|
|
472
|
+
this._z = e, this._onChangeCallback();
|
|
473
|
+
}
|
|
474
|
+
get w() {
|
|
475
|
+
return this._w;
|
|
476
|
+
}
|
|
477
|
+
set w(e) {
|
|
478
|
+
this._w = e, this._onChangeCallback();
|
|
479
|
+
}
|
|
480
|
+
set(e, i, t, o) {
|
|
481
|
+
return this._x = e, this._y = i, this._z = t, this._w = o, this._onChangeCallback(), this;
|
|
482
|
+
}
|
|
483
|
+
clone() {
|
|
484
|
+
return new this.constructor(this._x, this._y, this._z, this._w);
|
|
485
|
+
}
|
|
486
|
+
copy(e) {
|
|
487
|
+
return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
|
|
488
|
+
}
|
|
489
|
+
setFromEuler(e, i = !0) {
|
|
490
|
+
const t = e._x, o = e._y, n = e._z, d = e._order, r = Math.cos, p = Math.sin, a = r(t / 2), c = r(o / 2), u = r(n / 2), m = p(t / 2), h = p(o / 2), y = p(n / 2);
|
|
491
|
+
switch (d) {
|
|
492
|
+
case "XYZ":
|
|
493
|
+
this._x = m * c * u + a * h * y, this._y = a * h * u - m * c * y, this._z = a * c * y + m * h * u, this._w = a * c * u - m * h * y;
|
|
494
|
+
break;
|
|
495
|
+
case "YXZ":
|
|
496
|
+
this._x = m * c * u + a * h * y, this._y = a * h * u - m * c * y, this._z = a * c * y - m * h * u, this._w = a * c * u + m * h * y;
|
|
497
|
+
break;
|
|
498
|
+
case "ZXY":
|
|
499
|
+
this._x = m * c * u - a * h * y, this._y = a * h * u + m * c * y, this._z = a * c * y + m * h * u, this._w = a * c * u - m * h * y;
|
|
500
|
+
break;
|
|
501
|
+
case "ZYX":
|
|
502
|
+
this._x = m * c * u - a * h * y, this._y = a * h * u + m * c * y, this._z = a * c * y - m * h * u, this._w = a * c * u + m * h * y;
|
|
503
|
+
break;
|
|
504
|
+
case "YZX":
|
|
505
|
+
this._x = m * c * u + a * h * y, this._y = a * h * u + m * c * y, this._z = a * c * y - m * h * u, this._w = a * c * u - m * h * y;
|
|
506
|
+
break;
|
|
507
|
+
case "XZY":
|
|
508
|
+
this._x = m * c * u - a * h * y, this._y = a * h * u - m * c * y, this._z = a * c * y + m * h * u, this._w = a * c * u + m * h * y;
|
|
509
|
+
break;
|
|
510
|
+
default:
|
|
511
|
+
console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + d);
|
|
512
|
+
}
|
|
513
|
+
return i === !0 && this._onChangeCallback(), this;
|
|
514
|
+
}
|
|
515
|
+
setFromAxisAngle(e, i) {
|
|
516
|
+
const t = i / 2, o = Math.sin(t);
|
|
517
|
+
return this._x = e.x * o, this._y = e.y * o, this._z = e.z * o, this._w = Math.cos(t), this._onChangeCallback(), this;
|
|
518
|
+
}
|
|
519
|
+
setFromRotationMatrix(e) {
|
|
520
|
+
const i = e.elements, t = i[0], o = i[4], n = i[8], d = i[1], r = i[5], p = i[9], a = i[2], c = i[6], u = i[10], m = t + r + u;
|
|
521
|
+
if (m > 0) {
|
|
522
|
+
const h = 0.5 / Math.sqrt(m + 1);
|
|
523
|
+
this._w = 0.25 / h, this._x = (c - p) * h, this._y = (n - a) * h, this._z = (d - o) * h;
|
|
524
|
+
} else if (t > r && t > u) {
|
|
525
|
+
const h = 2 * Math.sqrt(1 + t - r - u);
|
|
526
|
+
this._w = (c - p) / h, this._x = 0.25 * h, this._y = (o + d) / h, this._z = (n + a) / h;
|
|
527
|
+
} else if (r > u) {
|
|
528
|
+
const h = 2 * Math.sqrt(1 + r - t - u);
|
|
529
|
+
this._w = (n - a) / h, this._x = (o + d) / h, this._y = 0.25 * h, this._z = (p + c) / h;
|
|
530
|
+
} else {
|
|
531
|
+
const h = 2 * Math.sqrt(1 + u - t - r);
|
|
532
|
+
this._w = (d - o) / h, this._x = (n + a) / h, this._y = (p + c) / h, this._z = 0.25 * h;
|
|
533
|
+
}
|
|
534
|
+
return this._onChangeCallback(), this;
|
|
535
|
+
}
|
|
536
|
+
setFromUnitVectors(e, i) {
|
|
537
|
+
let t = e.dot(i) + 1;
|
|
538
|
+
return t < Number.EPSILON ? (t = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = t) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = t)) : (this._x = e.y * i.z - e.z * i.y, this._y = e.z * i.x - e.x * i.z, this._z = e.x * i.y - e.y * i.x, this._w = t), this.normalize();
|
|
539
|
+
}
|
|
540
|
+
angleTo(e) {
|
|
541
|
+
return 2 * Math.acos(Math.abs(Nt(this.dot(e), -1, 1)));
|
|
542
|
+
}
|
|
543
|
+
rotateTowards(e, i) {
|
|
544
|
+
const t = this.angleTo(e);
|
|
545
|
+
if (t === 0) return this;
|
|
546
|
+
const o = Math.min(1, i / t);
|
|
547
|
+
return this.slerp(e, o), this;
|
|
548
|
+
}
|
|
549
|
+
identity() {
|
|
550
|
+
return this.set(0, 0, 0, 1);
|
|
551
|
+
}
|
|
552
|
+
invert() {
|
|
553
|
+
return this.conjugate();
|
|
554
|
+
}
|
|
555
|
+
conjugate() {
|
|
556
|
+
return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
|
|
557
|
+
}
|
|
558
|
+
dot(e) {
|
|
559
|
+
return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
|
|
560
|
+
}
|
|
561
|
+
lengthSq() {
|
|
562
|
+
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
|
|
563
|
+
}
|
|
564
|
+
length() {
|
|
565
|
+
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
|
|
566
|
+
}
|
|
567
|
+
normalize() {
|
|
568
|
+
let e = this.length();
|
|
569
|
+
return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;
|
|
570
|
+
}
|
|
571
|
+
multiply(e) {
|
|
572
|
+
return this.multiplyQuaternions(this, e);
|
|
573
|
+
}
|
|
574
|
+
premultiply(e) {
|
|
575
|
+
return this.multiplyQuaternions(e, this);
|
|
576
|
+
}
|
|
577
|
+
multiplyQuaternions(e, i) {
|
|
578
|
+
const t = e._x, o = e._y, n = e._z, d = e._w, r = i._x, p = i._y, a = i._z, c = i._w;
|
|
579
|
+
return this._x = t * c + d * r + o * a - n * p, this._y = o * c + d * p + n * r - t * a, this._z = n * c + d * a + t * p - o * r, this._w = d * c - t * r - o * p - n * a, this._onChangeCallback(), this;
|
|
580
|
+
}
|
|
581
|
+
slerp(e, i) {
|
|
582
|
+
if (i === 0) return this;
|
|
583
|
+
if (i === 1) return this.copy(e);
|
|
584
|
+
const t = this._x, o = this._y, n = this._z, d = this._w;
|
|
585
|
+
let r = d * e._w + t * e._x + o * e._y + n * e._z;
|
|
586
|
+
if (r < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, r = -r) : this.copy(e), r >= 1)
|
|
587
|
+
return this._w = d, this._x = t, this._y = o, this._z = n, this;
|
|
588
|
+
const p = 1 - r * r;
|
|
589
|
+
if (p <= Number.EPSILON) {
|
|
590
|
+
const h = 1 - i;
|
|
591
|
+
return this._w = h * d + i * this._w, this._x = h * t + i * this._x, this._y = h * o + i * this._y, this._z = h * n + i * this._z, this.normalize(), this;
|
|
592
|
+
}
|
|
593
|
+
const a = Math.sqrt(p), c = Math.atan2(a, r), u = Math.sin((1 - i) * c) / a, m = Math.sin(i * c) / a;
|
|
594
|
+
return this._w = d * u + this._w * m, this._x = t * u + this._x * m, this._y = o * u + this._y * m, this._z = n * u + this._z * m, this._onChangeCallback(), this;
|
|
595
|
+
}
|
|
596
|
+
slerpQuaternions(e, i, t) {
|
|
597
|
+
return this.copy(e).slerp(i, t);
|
|
598
|
+
}
|
|
599
|
+
random() {
|
|
600
|
+
const e = 2 * Math.PI * Math.random(), i = 2 * Math.PI * Math.random(), t = Math.random(), o = Math.sqrt(1 - t), n = Math.sqrt(t);
|
|
601
|
+
return this.set(
|
|
602
|
+
o * Math.sin(e),
|
|
603
|
+
o * Math.cos(e),
|
|
604
|
+
n * Math.sin(i),
|
|
605
|
+
n * Math.cos(i)
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
equals(e) {
|
|
609
|
+
return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
|
|
610
|
+
}
|
|
611
|
+
fromArray(e, i = 0) {
|
|
612
|
+
return this._x = e[i], this._y = e[i + 1], this._z = e[i + 2], this._w = e[i + 3], this._onChangeCallback(), this;
|
|
613
|
+
}
|
|
614
|
+
toArray(e = [], i = 0) {
|
|
615
|
+
return e[i] = this._x, e[i + 1] = this._y, e[i + 2] = this._z, e[i + 3] = this._w, e;
|
|
616
|
+
}
|
|
617
|
+
fromBufferAttribute(e, i) {
|
|
618
|
+
return this._x = e.getX(i), this._y = e.getY(i), this._z = e.getZ(i), this._w = e.getW(i), this._onChangeCallback(), this;
|
|
619
|
+
}
|
|
620
|
+
toJSON() {
|
|
621
|
+
return this.toArray();
|
|
622
|
+
}
|
|
623
|
+
_onChange(e) {
|
|
624
|
+
return this._onChangeCallback = e, this;
|
|
625
|
+
}
|
|
626
|
+
_onChangeCallback() {
|
|
627
|
+
}
|
|
628
|
+
*[Symbol.iterator]() {
|
|
629
|
+
yield this._x, yield this._y, yield this._z, yield this._w;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
class J {
|
|
633
|
+
constructor(e = 0, i = 0, t = 0) {
|
|
634
|
+
J.prototype.isVector3 = !0, this.x = e, this.y = i, this.z = t;
|
|
635
|
+
}
|
|
636
|
+
set(e, i, t) {
|
|
637
|
+
return t === void 0 && (t = this.z), this.x = e, this.y = i, this.z = t, this;
|
|
638
|
+
}
|
|
639
|
+
setScalar(e) {
|
|
640
|
+
return this.x = e, this.y = e, this.z = e, this;
|
|
641
|
+
}
|
|
642
|
+
setX(e) {
|
|
643
|
+
return this.x = e, this;
|
|
644
|
+
}
|
|
645
|
+
setY(e) {
|
|
646
|
+
return this.y = e, this;
|
|
647
|
+
}
|
|
648
|
+
setZ(e) {
|
|
649
|
+
return this.z = e, this;
|
|
650
|
+
}
|
|
651
|
+
setComponent(e, i) {
|
|
652
|
+
switch (e) {
|
|
653
|
+
case 0:
|
|
654
|
+
this.x = i;
|
|
655
|
+
break;
|
|
656
|
+
case 1:
|
|
657
|
+
this.y = i;
|
|
658
|
+
break;
|
|
659
|
+
case 2:
|
|
660
|
+
this.z = i;
|
|
661
|
+
break;
|
|
662
|
+
default:
|
|
663
|
+
throw new Error("index is out of range: " + e);
|
|
664
|
+
}
|
|
665
|
+
return this;
|
|
666
|
+
}
|
|
667
|
+
getComponent(e) {
|
|
668
|
+
switch (e) {
|
|
669
|
+
case 0:
|
|
670
|
+
return this.x;
|
|
671
|
+
case 1:
|
|
672
|
+
return this.y;
|
|
673
|
+
case 2:
|
|
674
|
+
return this.z;
|
|
675
|
+
default:
|
|
676
|
+
throw new Error("index is out of range: " + e);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
clone() {
|
|
680
|
+
return new this.constructor(this.x, this.y, this.z);
|
|
681
|
+
}
|
|
682
|
+
copy(e) {
|
|
683
|
+
return this.x = e.x, this.y = e.y, this.z = e.z, this;
|
|
684
|
+
}
|
|
685
|
+
add(e) {
|
|
686
|
+
return this.x += e.x, this.y += e.y, this.z += e.z, this;
|
|
687
|
+
}
|
|
688
|
+
addScalar(e) {
|
|
689
|
+
return this.x += e, this.y += e, this.z += e, this;
|
|
690
|
+
}
|
|
691
|
+
addVectors(e, i) {
|
|
692
|
+
return this.x = e.x + i.x, this.y = e.y + i.y, this.z = e.z + i.z, this;
|
|
693
|
+
}
|
|
694
|
+
addScaledVector(e, i) {
|
|
695
|
+
return this.x += e.x * i, this.y += e.y * i, this.z += e.z * i, this;
|
|
696
|
+
}
|
|
697
|
+
sub(e) {
|
|
698
|
+
return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
|
|
699
|
+
}
|
|
700
|
+
subScalar(e) {
|
|
701
|
+
return this.x -= e, this.y -= e, this.z -= e, this;
|
|
702
|
+
}
|
|
703
|
+
subVectors(e, i) {
|
|
704
|
+
return this.x = e.x - i.x, this.y = e.y - i.y, this.z = e.z - i.z, this;
|
|
705
|
+
}
|
|
706
|
+
multiply(e) {
|
|
707
|
+
return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
|
|
708
|
+
}
|
|
709
|
+
multiplyScalar(e) {
|
|
710
|
+
return this.x *= e, this.y *= e, this.z *= e, this;
|
|
711
|
+
}
|
|
712
|
+
multiplyVectors(e, i) {
|
|
713
|
+
return this.x = e.x * i.x, this.y = e.y * i.y, this.z = e.z * i.z, this;
|
|
714
|
+
}
|
|
715
|
+
applyEuler(e) {
|
|
716
|
+
return this.applyQuaternion(Ot.setFromEuler(e));
|
|
717
|
+
}
|
|
718
|
+
applyAxisAngle(e, i) {
|
|
719
|
+
return this.applyQuaternion(Ot.setFromAxisAngle(e, i));
|
|
720
|
+
}
|
|
721
|
+
applyMatrix3(e) {
|
|
722
|
+
const i = this.x, t = this.y, o = this.z, n = e.elements;
|
|
723
|
+
return this.x = n[0] * i + n[3] * t + n[6] * o, this.y = n[1] * i + n[4] * t + n[7] * o, this.z = n[2] * i + n[5] * t + n[8] * o, this;
|
|
724
|
+
}
|
|
725
|
+
applyNormalMatrix(e) {
|
|
726
|
+
return this.applyMatrix3(e).normalize();
|
|
727
|
+
}
|
|
728
|
+
applyMatrix4(e) {
|
|
729
|
+
const i = this.x, t = this.y, o = this.z, n = e.elements, d = 1 / (n[3] * i + n[7] * t + n[11] * o + n[15]);
|
|
730
|
+
return this.x = (n[0] * i + n[4] * t + n[8] * o + n[12]) * d, this.y = (n[1] * i + n[5] * t + n[9] * o + n[13]) * d, this.z = (n[2] * i + n[6] * t + n[10] * o + n[14]) * d, this;
|
|
731
|
+
}
|
|
732
|
+
applyQuaternion(e) {
|
|
733
|
+
const i = this.x, t = this.y, o = this.z, n = e.x, d = e.y, r = e.z, p = e.w, a = 2 * (d * o - r * t), c = 2 * (r * i - n * o), u = 2 * (n * t - d * i);
|
|
734
|
+
return this.x = i + p * a + d * u - r * c, this.y = t + p * c + r * a - n * u, this.z = o + p * u + n * c - d * a, this;
|
|
735
|
+
}
|
|
736
|
+
project(e) {
|
|
737
|
+
return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
|
|
738
|
+
}
|
|
739
|
+
unproject(e) {
|
|
740
|
+
return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
|
|
741
|
+
}
|
|
742
|
+
transformDirection(e) {
|
|
743
|
+
const i = this.x, t = this.y, o = this.z, n = e.elements;
|
|
744
|
+
return this.x = n[0] * i + n[4] * t + n[8] * o, this.y = n[1] * i + n[5] * t + n[9] * o, this.z = n[2] * i + n[6] * t + n[10] * o, this.normalize();
|
|
745
|
+
}
|
|
746
|
+
divide(e) {
|
|
747
|
+
return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;
|
|
748
|
+
}
|
|
749
|
+
divideScalar(e) {
|
|
750
|
+
return this.multiplyScalar(1 / e);
|
|
751
|
+
}
|
|
752
|
+
min(e) {
|
|
753
|
+
return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this;
|
|
754
|
+
}
|
|
755
|
+
max(e) {
|
|
756
|
+
return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this;
|
|
757
|
+
}
|
|
758
|
+
clamp(e, i) {
|
|
759
|
+
return this.x = Math.max(e.x, Math.min(i.x, this.x)), this.y = Math.max(e.y, Math.min(i.y, this.y)), this.z = Math.max(e.z, Math.min(i.z, this.z)), this;
|
|
760
|
+
}
|
|
761
|
+
clampScalar(e, i) {
|
|
762
|
+
return this.x = Math.max(e, Math.min(i, this.x)), this.y = Math.max(e, Math.min(i, this.y)), this.z = Math.max(e, Math.min(i, this.z)), this;
|
|
763
|
+
}
|
|
764
|
+
clampLength(e, i) {
|
|
765
|
+
const t = this.length();
|
|
766
|
+
return this.divideScalar(t || 1).multiplyScalar(Math.max(e, Math.min(i, t)));
|
|
767
|
+
}
|
|
768
|
+
floor() {
|
|
769
|
+
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
|
|
770
|
+
}
|
|
771
|
+
ceil() {
|
|
772
|
+
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
|
|
773
|
+
}
|
|
774
|
+
round() {
|
|
775
|
+
return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
|
|
776
|
+
}
|
|
777
|
+
roundToZero() {
|
|
778
|
+
return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
|
|
779
|
+
}
|
|
780
|
+
negate() {
|
|
781
|
+
return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
|
|
782
|
+
}
|
|
783
|
+
dot(e) {
|
|
784
|
+
return this.x * e.x + this.y * e.y + this.z * e.z;
|
|
785
|
+
}
|
|
786
|
+
// TODO lengthSquared?
|
|
787
|
+
lengthSq() {
|
|
788
|
+
return this.x * this.x + this.y * this.y + this.z * this.z;
|
|
789
|
+
}
|
|
790
|
+
length() {
|
|
791
|
+
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
792
|
+
}
|
|
793
|
+
manhattanLength() {
|
|
794
|
+
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
|
|
795
|
+
}
|
|
796
|
+
normalize() {
|
|
797
|
+
return this.divideScalar(this.length() || 1);
|
|
798
|
+
}
|
|
799
|
+
setLength(e) {
|
|
800
|
+
return this.normalize().multiplyScalar(e);
|
|
801
|
+
}
|
|
802
|
+
lerp(e, i) {
|
|
803
|
+
return this.x += (e.x - this.x) * i, this.y += (e.y - this.y) * i, this.z += (e.z - this.z) * i, this;
|
|
804
|
+
}
|
|
805
|
+
lerpVectors(e, i, t) {
|
|
806
|
+
return this.x = e.x + (i.x - e.x) * t, this.y = e.y + (i.y - e.y) * t, this.z = e.z + (i.z - e.z) * t, this;
|
|
807
|
+
}
|
|
808
|
+
cross(e) {
|
|
809
|
+
return this.crossVectors(this, e);
|
|
810
|
+
}
|
|
811
|
+
crossVectors(e, i) {
|
|
812
|
+
const t = e.x, o = e.y, n = e.z, d = i.x, r = i.y, p = i.z;
|
|
813
|
+
return this.x = o * p - n * r, this.y = n * d - t * p, this.z = t * r - o * d, this;
|
|
814
|
+
}
|
|
815
|
+
projectOnVector(e) {
|
|
816
|
+
const i = e.lengthSq();
|
|
817
|
+
if (i === 0) return this.set(0, 0, 0);
|
|
818
|
+
const t = e.dot(this) / i;
|
|
819
|
+
return this.copy(e).multiplyScalar(t);
|
|
820
|
+
}
|
|
821
|
+
projectOnPlane(e) {
|
|
822
|
+
return at.copy(this).projectOnVector(e), this.sub(at);
|
|
823
|
+
}
|
|
824
|
+
reflect(e) {
|
|
825
|
+
return this.sub(at.copy(e).multiplyScalar(2 * this.dot(e)));
|
|
826
|
+
}
|
|
827
|
+
angleTo(e) {
|
|
828
|
+
const i = Math.sqrt(this.lengthSq() * e.lengthSq());
|
|
829
|
+
if (i === 0) return Math.PI / 2;
|
|
830
|
+
const t = this.dot(e) / i;
|
|
831
|
+
return Math.acos(Nt(t, -1, 1));
|
|
832
|
+
}
|
|
833
|
+
distanceTo(e) {
|
|
834
|
+
return Math.sqrt(this.distanceToSquared(e));
|
|
835
|
+
}
|
|
836
|
+
distanceToSquared(e) {
|
|
837
|
+
const i = this.x - e.x, t = this.y - e.y, o = this.z - e.z;
|
|
838
|
+
return i * i + t * t + o * o;
|
|
839
|
+
}
|
|
840
|
+
manhattanDistanceTo(e) {
|
|
841
|
+
return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
|
|
842
|
+
}
|
|
843
|
+
setFromSpherical(e) {
|
|
844
|
+
return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
|
|
845
|
+
}
|
|
846
|
+
setFromSphericalCoords(e, i, t) {
|
|
847
|
+
const o = Math.sin(i) * e;
|
|
848
|
+
return this.x = o * Math.sin(t), this.y = Math.cos(i) * e, this.z = o * Math.cos(t), this;
|
|
849
|
+
}
|
|
850
|
+
setFromCylindrical(e) {
|
|
851
|
+
return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
|
|
852
|
+
}
|
|
853
|
+
setFromCylindricalCoords(e, i, t) {
|
|
854
|
+
return this.x = e * Math.sin(i), this.y = t, this.z = e * Math.cos(i), this;
|
|
855
|
+
}
|
|
856
|
+
setFromMatrixPosition(e) {
|
|
857
|
+
const i = e.elements;
|
|
858
|
+
return this.x = i[12], this.y = i[13], this.z = i[14], this;
|
|
859
|
+
}
|
|
860
|
+
setFromMatrixScale(e) {
|
|
861
|
+
const i = this.setFromMatrixColumn(e, 0).length(), t = this.setFromMatrixColumn(e, 1).length(), o = this.setFromMatrixColumn(e, 2).length();
|
|
862
|
+
return this.x = i, this.y = t, this.z = o, this;
|
|
863
|
+
}
|
|
864
|
+
setFromMatrixColumn(e, i) {
|
|
865
|
+
return this.fromArray(e.elements, i * 4);
|
|
866
|
+
}
|
|
867
|
+
setFromMatrix3Column(e, i) {
|
|
868
|
+
return this.fromArray(e.elements, i * 3);
|
|
869
|
+
}
|
|
870
|
+
setFromEuler(e) {
|
|
871
|
+
return this.x = e._x, this.y = e._y, this.z = e._z, this;
|
|
872
|
+
}
|
|
873
|
+
setFromColor(e) {
|
|
874
|
+
return this.x = e.r, this.y = e.g, this.z = e.b, this;
|
|
875
|
+
}
|
|
876
|
+
equals(e) {
|
|
877
|
+
return e.x === this.x && e.y === this.y && e.z === this.z;
|
|
878
|
+
}
|
|
879
|
+
fromArray(e, i = 0) {
|
|
880
|
+
return this.x = e[i], this.y = e[i + 1], this.z = e[i + 2], this;
|
|
881
|
+
}
|
|
882
|
+
toArray(e = [], i = 0) {
|
|
883
|
+
return e[i] = this.x, e[i + 1] = this.y, e[i + 2] = this.z, e;
|
|
884
|
+
}
|
|
885
|
+
fromBufferAttribute(e, i) {
|
|
886
|
+
return this.x = e.getX(i), this.y = e.getY(i), this.z = e.getZ(i), this;
|
|
887
|
+
}
|
|
888
|
+
random() {
|
|
889
|
+
return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
|
|
890
|
+
}
|
|
891
|
+
randomDirection() {
|
|
892
|
+
const e = Math.random() * Math.PI * 2, i = Math.random() * 2 - 1, t = Math.sqrt(1 - i * i);
|
|
893
|
+
return this.x = t * Math.cos(e), this.y = i, this.z = t * Math.sin(e), this;
|
|
894
|
+
}
|
|
895
|
+
*[Symbol.iterator]() {
|
|
896
|
+
yield this.x, yield this.y, yield this.z;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const at = /* @__PURE__ */ new J(), Ot = /* @__PURE__ */ new _e();
|
|
900
|
+
class fe extends he {
|
|
901
|
+
constructor() {
|
|
902
|
+
super();
|
|
903
|
+
z(this, "isSelectable", !0);
|
|
904
|
+
z(this, "isMovable", !0);
|
|
905
|
+
z(this, "isDIVENode", !0);
|
|
906
|
+
z(this, "gizmo", null);
|
|
907
|
+
z(this, "_positionWorldBuffer");
|
|
908
|
+
z(this, "_boundingBox");
|
|
909
|
+
this.layers.mask = de, this._positionWorldBuffer = new b(), this._boundingBox = new Rt();
|
|
910
|
+
}
|
|
911
|
+
setPosition(i) {
|
|
912
|
+
if (!this.parent) {
|
|
913
|
+
this.position.set(i.x, i.y, i.z);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const t = new b(i.x, i.y, i.z);
|
|
917
|
+
this.position.copy(this.parent.worldToLocal(t)), "isDIVEGroup" in this.parent && this.parent.updateLineTo(this);
|
|
918
|
+
}
|
|
919
|
+
setRotation(i) {
|
|
920
|
+
this.rotation.set(i.x, i.y, i.z);
|
|
921
|
+
}
|
|
922
|
+
setScale(i) {
|
|
923
|
+
this.scale.set(i.x, i.y, i.z);
|
|
924
|
+
}
|
|
925
|
+
setVisibility(i) {
|
|
926
|
+
this.visible = i;
|
|
927
|
+
}
|
|
928
|
+
setToWorldOrigin() {
|
|
929
|
+
this.position.set(0, 0, 0), import("../plugins/state/index.mjs").then(({ State: i }) => {
|
|
930
|
+
var t;
|
|
931
|
+
(t = i.get(this.userData.id)) == null || t.performAction("UPDATE_OBJECT", {
|
|
932
|
+
id: this.userData.id,
|
|
933
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
934
|
+
rotation: this.rotation,
|
|
935
|
+
scale: this.scale
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Can be called when the object is moved from a foreign object (gizmo, parent, etc.) to update the object's position.
|
|
941
|
+
*/
|
|
942
|
+
onMove() {
|
|
943
|
+
import("../plugins/state/index.mjs").then(({ State: i }) => {
|
|
944
|
+
var t;
|
|
945
|
+
(t = i.get(this.userData.id)) == null || t.performAction("UPDATE_OBJECT", {
|
|
946
|
+
id: this.userData.id,
|
|
947
|
+
position: this.getWorldPosition(this._positionWorldBuffer),
|
|
948
|
+
rotation: this.rotation,
|
|
949
|
+
scale: this.scale
|
|
950
|
+
});
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
onSelect() {
|
|
954
|
+
import("../plugins/state/index.mjs").then(({ State: i }) => {
|
|
955
|
+
var t;
|
|
956
|
+
(t = i.get(this.userData.id)) == null || t.performAction("SELECT_OBJECT", {
|
|
957
|
+
id: this.userData.id
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
onDeselect() {
|
|
962
|
+
import("../plugins/state/index.mjs").then(({ State: i }) => {
|
|
963
|
+
var t;
|
|
964
|
+
(t = i.get(this.userData.id)) == null || t.performAction("DESELECT_OBJECT", {
|
|
965
|
+
id: this.userData.id
|
|
966
|
+
});
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
class ge extends fe {
|
|
971
|
+
/**
|
|
972
|
+
* Creates a new BoundingBox instance for the specified 3D object.
|
|
973
|
+
*
|
|
974
|
+
* The constructor computes both a bounding box and bounding sphere for the given object.
|
|
975
|
+
* It handles complex objects with multiple meshes and nested transformations.
|
|
976
|
+
*
|
|
977
|
+
* @param object - The 3D object to compute bounding volumes for
|
|
978
|
+
* @param axisAligned - Whether to create an axis-aligned bounding box (true) or oriented bounding box (false). Defaults to false.
|
|
979
|
+
* @param wireframeColor - The color for the wireframe helpers. Can be a hex number or ColorRepresentation. Defaults to green (0x00ff00).
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* // Create an oriented bounding box (aligned with object's rotation)
|
|
984
|
+
* const obb = new BoundingBox(mesh, false, 0x00ff00);
|
|
985
|
+
*
|
|
986
|
+
* // Create an axis-aligned bounding box (aligned with world coordinates)
|
|
987
|
+
* const aabb = new BoundingBox(mesh, true, 0xff0000);
|
|
988
|
+
*
|
|
989
|
+
* // Use default green color
|
|
990
|
+
* const defaultBox = new BoundingBox(mesh);
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
constructor(i, t = !1, o = 65280) {
|
|
994
|
+
super();
|
|
995
|
+
/** The computed bounding box (Box3) */
|
|
996
|
+
z(this, "_box");
|
|
997
|
+
/** The computed bounding sphere (Sphere) */
|
|
998
|
+
z(this, "_sphere");
|
|
999
|
+
/** The center point of the bounding box */
|
|
1000
|
+
z(this, "_center");
|
|
1001
|
+
/** The radius of the bounding sphere */
|
|
1002
|
+
z(this, "_radius");
|
|
1003
|
+
/** Visual helper for the bounding box wireframe */
|
|
1004
|
+
z(this, "_boxHelper");
|
|
1005
|
+
/** Visual helper for the bounding sphere wireframe */
|
|
1006
|
+
z(this, "_sphereHelper");
|
|
1007
|
+
/** The dimensions (width, height, depth) of the bounding box */
|
|
1008
|
+
z(this, "_size");
|
|
1009
|
+
const n = new Rt();
|
|
1010
|
+
t ? n.setFromObject(i) : (i.updateWorldMatrix(!0, !0), i.traverse((r) => {
|
|
1011
|
+
if (r.isMesh) {
|
|
1012
|
+
const p = r, a = p.geometry.clone();
|
|
1013
|
+
a.applyMatrix4(p.matrixWorld);
|
|
1014
|
+
const c = p.getWorldQuaternion(new ht()).invert();
|
|
1015
|
+
a.applyQuaternion(c), a.computeBoundingBox(), a.boundingBox && n.union(a.boundingBox);
|
|
1016
|
+
}
|
|
1017
|
+
})), this.rotation.copy(i.rotation), this._box = n, this._size = n.getSize(new b()), this._center = n.getCenter(new b()), this._boxHelper = new ce(this._box, o), this._boxHelper.visible = !1, this.add(this._boxHelper), this._sphere = n.getBoundingSphere(new le()), this._radius = this._sphere.radius;
|
|
1018
|
+
const d = new ue(this._radius, 32, 32);
|
|
1019
|
+
d.translate(this._center.x, this._center.y, this._center.z), this._sphereHelper = new pe(
|
|
1020
|
+
d,
|
|
1021
|
+
new me({ color: o, wireframe: !0 })
|
|
1022
|
+
), this._sphereHelper.visible = !1, this.add(this._sphereHelper);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Gets the computed bounding box.
|
|
1026
|
+
* @returns The Box3 instance representing the bounding box
|
|
1027
|
+
*/
|
|
1028
|
+
get box() {
|
|
1029
|
+
return this._box;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Gets the computed bounding sphere.
|
|
1033
|
+
* @returns The Sphere instance representing the bounding sphere
|
|
1034
|
+
*/
|
|
1035
|
+
get sphere() {
|
|
1036
|
+
return this._sphere;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Gets the center point of the bounding box.
|
|
1040
|
+
* @returns A Vector3 representing the center coordinates
|
|
1041
|
+
*/
|
|
1042
|
+
get center() {
|
|
1043
|
+
return this._center;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Gets the radius of the bounding sphere.
|
|
1047
|
+
* @returns The radius as a number
|
|
1048
|
+
*/
|
|
1049
|
+
get radius() {
|
|
1050
|
+
return this._radius;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Gets the dimensions of the bounding box.
|
|
1054
|
+
* @returns A Vector3 representing width, height, and depth
|
|
1055
|
+
*/
|
|
1056
|
+
get size() {
|
|
1057
|
+
return this._size;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Sets the visibility of the bounding box wireframe helper.
|
|
1061
|
+
*
|
|
1062
|
+
* @param visible - Whether the box helper should be visible
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* ```typescript
|
|
1066
|
+
* const boundingBox = new BoundingBox(mesh);
|
|
1067
|
+
*
|
|
1068
|
+
* // Show the bounding box wireframe
|
|
1069
|
+
* boundingBox.setBoxHelperVisible(true);
|
|
1070
|
+
*
|
|
1071
|
+
* // Hide the bounding box wireframe
|
|
1072
|
+
* boundingBox.setBoxHelperVisible(false);
|
|
1073
|
+
* ```
|
|
1074
|
+
*/
|
|
1075
|
+
setBoxHelperVisible(i) {
|
|
1076
|
+
this._boxHelper.visible = i;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Sets the visibility of the bounding sphere wireframe helper.
|
|
1080
|
+
*
|
|
1081
|
+
* @param visible - Whether the sphere helper should be visible
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* const boundingBox = new BoundingBox(mesh);
|
|
1086
|
+
*
|
|
1087
|
+
* // Show the bounding sphere wireframe
|
|
1088
|
+
* boundingBox.setSphereHelperVisible(true);
|
|
1089
|
+
*
|
|
1090
|
+
* // Hide the bounding sphere wireframe
|
|
1091
|
+
* boundingBox.setSphereHelperVisible(false);
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
setSphereHelperVisible(i) {
|
|
1095
|
+
this._sphereHelper.visible = i;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
const rt = {
|
|
1099
|
+
enableDamping: !0,
|
|
1100
|
+
dampingFactor: 0.05
|
|
1101
|
+
}, V = class V extends xe {
|
|
1102
|
+
constructor(i, t, o = rt) {
|
|
1103
|
+
super(i, t);
|
|
1104
|
+
z(this, "uuid", nt.generateUUID());
|
|
1105
|
+
z(this, "object");
|
|
1106
|
+
this.domElement = t, this.domElement = t, this.object = i, this.enableDamping = o.enableDamping ?? rt.enableDamping, this.dampingFactor = o.dampingFactor ?? rt.dampingFactor, this.object.position.set(0, 2, 2), this.target.copy({ x: 0, y: 0.5, z: 0 }), this.update();
|
|
1107
|
+
}
|
|
1108
|
+
tick() {
|
|
1109
|
+
this.enabled && this.update();
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Computes the camera position and target to perfectly fit a bounding sphere into the camera's frustum.
|
|
1113
|
+
* This robust approach ensures the entire object is always visible, regardless of rotation or aspect ratio.
|
|
1114
|
+
*
|
|
1115
|
+
* @param bb - The bounding box to encompass
|
|
1116
|
+
* @param padding - Optional padding factor to add space around the object depending on the object's bounding sphere diameter (default: 0.0 = no padding)
|
|
1117
|
+
* @returns Object containing the calculated camera position and target
|
|
1118
|
+
*/
|
|
1119
|
+
computeEncompassingView(i, t = 0) {
|
|
1120
|
+
const o = i.center, d = i.sphere.radius, r = this.object.fov * Math.PI / 180, p = this.object.aspect, a = r / 2, c = Math.atan(Math.tan(a) * p), u = d / Math.sin(a), m = d / Math.sin(c), h = Math.max(u, m) * (1 + t), y = this.object.position.clone().sub(this.target).normalize(), E = y.length() > 1e-3 ? y : new J(0, 0, 1);
|
|
1121
|
+
return {
|
|
1122
|
+
position: o.clone().add(E.multiplyScalar(h)),
|
|
1123
|
+
target: o
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Focus the camera on a specific object by computing its bounding box
|
|
1128
|
+
* @param object - The object to focus on
|
|
1129
|
+
* @param padding - Optional padding factor to add space around the object depending on the object's bounding sphere diameter (default: 0.0 = no padding)
|
|
1130
|
+
*/
|
|
1131
|
+
focusOnObject(i, t = 0) {
|
|
1132
|
+
const o = new ge(i, !1, 65280), n = this.computeEncompassingView(o, t);
|
|
1133
|
+
this.object.position.copy(n.position), this.target.copy(n.target), this.update();
|
|
1134
|
+
}
|
|
1135
|
+
zoomIn(i) {
|
|
1136
|
+
const t = i || V.DEFAULT_ZOOM_FACTOR, { minDistance: o, maxDistance: n } = this;
|
|
1137
|
+
this.minDistance = this.maxDistance = nt.clamp(
|
|
1138
|
+
this.getDistance() - t,
|
|
1139
|
+
o + t,
|
|
1140
|
+
n - t
|
|
1141
|
+
), this.update(), this.minDistance = o, this.maxDistance = n;
|
|
1142
|
+
}
|
|
1143
|
+
zoomOut(i) {
|
|
1144
|
+
const t = i || V.DEFAULT_ZOOM_FACTOR, { minDistance: o, maxDistance: n } = this;
|
|
1145
|
+
this.minDistance = this.maxDistance = nt.clamp(
|
|
1146
|
+
this.getDistance() + t,
|
|
1147
|
+
o + t,
|
|
1148
|
+
n - t
|
|
1149
|
+
), this.update(), this.minDistance = o, this.maxDistance = n;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
z(V, "DEFAULT_ZOOM_FACTOR", 1);
|
|
1153
|
+
let Lt = V;
|
|
1154
|
+
export {
|
|
1155
|
+
ge as B,
|
|
1156
|
+
fe as D,
|
|
1157
|
+
rt as O,
|
|
1158
|
+
Lt as a
|
|
1159
|
+
};
|