pptx-svelte-viewer 0.1.1 → 0.1.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.
@@ -0,0 +1,452 @@
1
+ import { Controls as S, MOUSE as _, MathUtils as M, Plane as w, Quaternion as g, Ray as O, Spherical as E, TOUCH as d, Vector2 as l, Vector3 as c } from "./three.module-BLwnGxzY.js";
2
+ var P = { type: "change" }, y = { type: "start" }, T = { type: "end" }, m = new O(), D = new w(), R = Math.cos(70 * M.DEG2RAD), a = new c(), h = 2 * Math.PI, s = {
3
+ NONE: -1,
4
+ ROTATE: 0,
5
+ DOLLY: 1,
6
+ PAN: 2,
7
+ TOUCH_ROTATE: 3,
8
+ TOUCH_PAN: 4,
9
+ TOUCH_DOLLY_PAN: 5,
10
+ TOUCH_DOLLY_ROTATE: 6
11
+ }, f = 1e-6, K = class extends S {
12
+ constructor(t, e = null) {
13
+ super(t, e), this.state = s.NONE, this.target = new c(), this.cursor = new c(), 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.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = {
14
+ LEFT: "ArrowLeft",
15
+ UP: "ArrowUp",
16
+ RIGHT: "ArrowRight",
17
+ BOTTOM: "ArrowDown"
18
+ }, this.mouseButtons = {
19
+ LEFT: _.ROTATE,
20
+ MIDDLE: _.DOLLY,
21
+ RIGHT: _.PAN
22
+ }, this.touches = {
23
+ ONE: d.ROTATE,
24
+ TWO: d.DOLLY_PAN
25
+ }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._cursorStyle = "auto", this._domElementKeyEvents = null, this._lastPosition = new c(), this._lastQuaternion = new g(), this._lastTargetPosition = new c(), this._quat = new g().setFromUnitVectors(t.up, new c(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new E(), this._sphericalDelta = new E(), this._scale = 1, this._panOffset = new c(), this._rotateStart = new l(), this._rotateEnd = new l(), this._rotateDelta = new l(), this._panStart = new l(), this._panEnd = new l(), this._panDelta = new l(), this._dollyStart = new l(), this._dollyEnd = new l(), this._dollyDelta = new l(), this._dollyDirection = new c(), this._mouse = new l(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = j.bind(this), this._onPointerDown = L.bind(this), this._onPointerUp = A.bind(this), this._onContextMenu = U.bind(this), this._onMouseWheel = C.bind(this), this._onKeyDown = N.bind(this), this._onTouchStart = Y.bind(this), this._onTouchMove = I.bind(this), this._onMouseDown = k.bind(this), this._onMouseMove = x.bind(this), this._interceptControlDown = Z.bind(this), this._interceptControlUp = z.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
26
+ }
27
+ set cursorStyle(t) {
28
+ this._cursorStyle = t, t === "grab" ? this.domElement.style.cursor = "grab" : this.domElement.style.cursor = "auto";
29
+ }
30
+ get cursorStyle() {
31
+ return this._cursorStyle;
32
+ }
33
+ connect(t) {
34
+ super.connect(t), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, {
35
+ passive: !0,
36
+ capture: !0
37
+ }), this.domElement.style.touchAction = "none";
38
+ }
39
+ disconnect() {
40
+ this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = "";
41
+ }
42
+ dispose() {
43
+ this.disconnect();
44
+ }
45
+ getPolarAngle() {
46
+ return this._spherical.phi;
47
+ }
48
+ getAzimuthalAngle() {
49
+ return this._spherical.theta;
50
+ }
51
+ getDistance() {
52
+ return this.object.position.distanceTo(this.target);
53
+ }
54
+ listenToKeyEvents(t) {
55
+ t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
56
+ }
57
+ stopListenToKeyEvents() {
58
+ this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
59
+ }
60
+ saveState() {
61
+ this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
62
+ }
63
+ reset() {
64
+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(P), this.update(), this.state = s.NONE;
65
+ }
66
+ pan(t, e) {
67
+ this._pan(t, e), this.update();
68
+ }
69
+ dollyIn(t) {
70
+ this._dollyIn(t), this.update();
71
+ }
72
+ dollyOut(t) {
73
+ this._dollyOut(t), this.update();
74
+ }
75
+ rotateLeft(t) {
76
+ this._rotateLeft(t), this.update();
77
+ }
78
+ rotateUp(t) {
79
+ this._rotateUp(t), this.update();
80
+ }
81
+ update(t = null) {
82
+ const e = this.object.position;
83
+ a.copy(e).sub(this.target), a.applyQuaternion(this._quat), this._spherical.setFromVector3(a), this.autoRotate && this.state === s.NONE && this._rotateLeft(this._getAutoRotationAngle(t)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi);
84
+ let i = this.minAzimuthAngle, o = this.maxAzimuthAngle;
85
+ isFinite(i) && isFinite(o) && (i < -Math.PI ? i += h : i > Math.PI && (i -= h), o < -Math.PI ? o += h : o > Math.PI && (o -= h), i <= o ? this._spherical.theta = Math.max(i, Math.min(o, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (i + o) / 2 ? Math.max(i, this._spherical.theta) : Math.min(o, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor);
86
+ let n = !1;
87
+ if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera) this._spherical.radius = this._clampDistance(this._spherical.radius);
88
+ else {
89
+ const r = this._spherical.radius;
90
+ this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), n = r != this._spherical.radius;
91
+ }
92
+ if (a.setFromSpherical(this._spherical), a.applyQuaternion(this._quatInverse), e.copy(this.target).add(a), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) {
93
+ let r = null;
94
+ if (this.object.isPerspectiveCamera) {
95
+ const p = a.length();
96
+ r = this._clampDistance(p * this._scale);
97
+ const u = p - r;
98
+ this.object.position.addScaledVector(this._dollyDirection, u), this.object.updateMatrixWorld(), n = !!u;
99
+ } else if (this.object.isOrthographicCamera) {
100
+ const p = new c(this._mouse.x, this._mouse.y, 0);
101
+ p.unproject(this.object);
102
+ const u = this.object.zoom;
103
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), n = u !== this.object.zoom;
104
+ const b = new c(this._mouse.x, this._mouse.y, 0);
105
+ b.unproject(this.object), this.object.position.sub(b).add(p), this.object.updateMatrixWorld(), r = a.length();
106
+ } else
107
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
108
+ r !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position) : (m.origin.copy(this.object.position), m.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(m.direction)) < R ? this.object.lookAt(this.target) : (D.setFromNormalAndCoplanarPoint(this.object.up, this.target), m.intersectPlane(D, this.target))));
109
+ } else if (this.object.isOrthographicCamera) {
110
+ const r = this.object.zoom;
111
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), r !== this.object.zoom && (this.object.updateProjectionMatrix(), n = !0);
112
+ }
113
+ return this._scale = 1, this._performCursorZoom = !1, n || this._lastPosition.distanceToSquared(this.object.position) > f || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > f || this._lastTargetPosition.distanceToSquared(this.target) > f ? (this.dispatchEvent(P), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
114
+ }
115
+ _getAutoRotationAngle(t) {
116
+ return t !== null ? h / 60 * this.autoRotateSpeed * t : h / 60 / 60 * this.autoRotateSpeed;
117
+ }
118
+ _getZoomScale(t) {
119
+ const e = Math.abs(t * 0.01);
120
+ return Math.pow(0.95, this.zoomSpeed * e);
121
+ }
122
+ _rotateLeft(t) {
123
+ this._sphericalDelta.theta -= t;
124
+ }
125
+ _rotateUp(t) {
126
+ this._sphericalDelta.phi -= t;
127
+ }
128
+ _panLeft(t, e) {
129
+ a.setFromMatrixColumn(e, 0), a.multiplyScalar(-t), this._panOffset.add(a);
130
+ }
131
+ _panUp(t, e) {
132
+ this.screenSpacePanning === !0 ? a.setFromMatrixColumn(e, 1) : (a.setFromMatrixColumn(e, 0), a.crossVectors(this.object.up, a)), a.multiplyScalar(t), this._panOffset.add(a);
133
+ }
134
+ _pan(t, e) {
135
+ const i = this.domElement;
136
+ if (this.object.isPerspectiveCamera) {
137
+ const o = this.object.position;
138
+ a.copy(o).sub(this.target);
139
+ let n = a.length();
140
+ n *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * n / i.clientHeight, this.object.matrix), this._panUp(2 * e * n / i.clientHeight, this.object.matrix);
141
+ } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / i.clientWidth, this.object.matrix), this._panUp(e * (this.object.top - this.object.bottom) / this.object.zoom / i.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
142
+ }
143
+ _dollyOut(t) {
144
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
145
+ }
146
+ _dollyIn(t) {
147
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
148
+ }
149
+ _updateZoomParameters(t, e) {
150
+ if (!this.zoomToCursor) return;
151
+ this._performCursorZoom = !0;
152
+ const i = this.domElement.getBoundingClientRect(), o = t - i.left, n = e - i.top, r = i.width, p = i.height;
153
+ this._mouse.x = o / r * 2 - 1, this._mouse.y = -(n / p) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
154
+ }
155
+ _clampDistance(t) {
156
+ return Math.max(this.minDistance, Math.min(this.maxDistance, t));
157
+ }
158
+ _handleMouseDownRotate(t) {
159
+ this._rotateStart.set(t.clientX, t.clientY);
160
+ }
161
+ _handleMouseDownDolly(t) {
162
+ this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
163
+ }
164
+ _handleMouseDownPan(t) {
165
+ this._panStart.set(t.clientX, t.clientY);
166
+ }
167
+ _handleMouseMoveRotate(t) {
168
+ this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
169
+ const e = this.domElement;
170
+ this._rotateLeft(h * this._rotateDelta.x / e.clientHeight), this._rotateUp(h * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
171
+ }
172
+ _handleMouseMoveDolly(t) {
173
+ this._dollyEnd.set(t.clientX, t.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update();
174
+ }
175
+ _handleMouseMovePan(t) {
176
+ this._panEnd.set(t.clientX, t.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update();
177
+ }
178
+ _handleMouseWheel(t) {
179
+ this._updateZoomParameters(t.clientX, t.clientY), t.deltaY < 0 ? this._dollyIn(this._getZoomScale(t.deltaY)) : t.deltaY > 0 && this._dollyOut(this._getZoomScale(t.deltaY)), this.update();
180
+ }
181
+ _handleKeyDown(t) {
182
+ let e = !1;
183
+ switch (t.code) {
184
+ case this.keys.UP:
185
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(h * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), e = !0;
186
+ break;
187
+ case this.keys.BOTTOM:
188
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-h * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), e = !0;
189
+ break;
190
+ case this.keys.LEFT:
191
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(h * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), e = !0;
192
+ break;
193
+ case this.keys.RIGHT:
194
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-h * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), e = !0;
195
+ break;
196
+ }
197
+ e && (t.preventDefault(), this.update());
198
+ }
199
+ _handleTouchStartRotate(t) {
200
+ if (this._pointers.length === 1) this._rotateStart.set(t.pageX, t.pageY);
201
+ else {
202
+ const e = this._getSecondPointerPosition(t), i = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
203
+ this._rotateStart.set(i, o);
204
+ }
205
+ }
206
+ _handleTouchStartPan(t) {
207
+ if (this._pointers.length === 1) this._panStart.set(t.pageX, t.pageY);
208
+ else {
209
+ const e = this._getSecondPointerPosition(t), i = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
210
+ this._panStart.set(i, o);
211
+ }
212
+ }
213
+ _handleTouchStartDolly(t) {
214
+ const e = this._getSecondPointerPosition(t), i = t.pageX - e.x, o = t.pageY - e.y, n = Math.sqrt(i * i + o * o);
215
+ this._dollyStart.set(0, n);
216
+ }
217
+ _handleTouchStartDollyPan(t) {
218
+ this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
219
+ }
220
+ _handleTouchStartDollyRotate(t) {
221
+ this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
222
+ }
223
+ _handleTouchMoveRotate(t) {
224
+ if (this._pointers.length == 1) this._rotateEnd.set(t.pageX, t.pageY);
225
+ else {
226
+ const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), n = 0.5 * (t.pageY + i.y);
227
+ this._rotateEnd.set(o, n);
228
+ }
229
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
230
+ const e = this.domElement;
231
+ this._rotateLeft(h * this._rotateDelta.x / e.clientHeight), this._rotateUp(h * this._rotateDelta.y / e.clientHeight), this._rotateStart.copy(this._rotateEnd);
232
+ }
233
+ _handleTouchMovePan(t) {
234
+ if (this._pointers.length === 1) this._panEnd.set(t.pageX, t.pageY);
235
+ else {
236
+ const e = this._getSecondPointerPosition(t), i = 0.5 * (t.pageX + e.x), o = 0.5 * (t.pageY + e.y);
237
+ this._panEnd.set(i, o);
238
+ }
239
+ this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
240
+ }
241
+ _handleTouchMoveDolly(t) {
242
+ const e = this._getSecondPointerPosition(t), i = t.pageX - e.x, o = t.pageY - e.y, n = Math.sqrt(i * i + o * o);
243
+ this._dollyEnd.set(0, n), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
244
+ const r = (t.pageX + e.x) * 0.5, p = (t.pageY + e.y) * 0.5;
245
+ this._updateZoomParameters(r, p);
246
+ }
247
+ _handleTouchMoveDollyPan(t) {
248
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
249
+ }
250
+ _handleTouchMoveDollyRotate(t) {
251
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
252
+ }
253
+ _addPointer(t) {
254
+ this._pointers.push(t.pointerId);
255
+ }
256
+ _removePointer(t) {
257
+ delete this._pointerPositions[t.pointerId];
258
+ for (let e = 0; e < this._pointers.length; e++) if (this._pointers[e] == t.pointerId) {
259
+ this._pointers.splice(e, 1);
260
+ return;
261
+ }
262
+ }
263
+ _isTrackingPointer(t) {
264
+ for (let e = 0; e < this._pointers.length; e++) if (this._pointers[e] == t.pointerId) return !0;
265
+ return !1;
266
+ }
267
+ _trackPointer(t) {
268
+ let e = this._pointerPositions[t.pointerId];
269
+ e === void 0 && (e = new l(), this._pointerPositions[t.pointerId] = e), e.set(t.pageX, t.pageY);
270
+ }
271
+ _getSecondPointerPosition(t) {
272
+ const e = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
273
+ return this._pointerPositions[e];
274
+ }
275
+ _customWheelEvent(t) {
276
+ const e = t.deltaMode, i = {
277
+ clientX: t.clientX,
278
+ clientY: t.clientY,
279
+ deltaY: t.deltaY
280
+ };
281
+ switch (e) {
282
+ case 1:
283
+ i.deltaY *= 16;
284
+ break;
285
+ case 2:
286
+ i.deltaY *= 100;
287
+ break;
288
+ }
289
+ return t.ctrlKey && !this._controlActive && (i.deltaY *= 10), i;
290
+ }
291
+ };
292
+ function L(t) {
293
+ this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(t.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(t) && (this._addPointer(t), t.pointerType === "touch" ? this._onTouchStart(t) : this._onMouseDown(t), this._cursorStyle === "grab" && (this.domElement.style.cursor = "grabbing")));
294
+ }
295
+ function j(t) {
296
+ this.enabled !== !1 && (t.pointerType === "touch" ? this._onTouchMove(t) : this._onMouseMove(t));
297
+ }
298
+ function A(t) {
299
+ switch (this._removePointer(t), this._pointers.length) {
300
+ case 0:
301
+ this.domElement.releasePointerCapture(t.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(T), this.state = s.NONE, this._cursorStyle === "grab" && (this.domElement.style.cursor = "grab");
302
+ break;
303
+ case 1:
304
+ const e = this._pointers[0], i = this._pointerPositions[e];
305
+ this._onTouchStart({
306
+ pointerId: e,
307
+ pageX: i.x,
308
+ pageY: i.y
309
+ });
310
+ break;
311
+ }
312
+ }
313
+ function k(t) {
314
+ let e;
315
+ switch (t.button) {
316
+ case 0:
317
+ e = this.mouseButtons.LEFT;
318
+ break;
319
+ case 1:
320
+ e = this.mouseButtons.MIDDLE;
321
+ break;
322
+ case 2:
323
+ e = this.mouseButtons.RIGHT;
324
+ break;
325
+ default:
326
+ e = -1;
327
+ }
328
+ switch (e) {
329
+ case _.DOLLY:
330
+ if (this.enableZoom === !1) return;
331
+ this._handleMouseDownDolly(t), this.state = s.DOLLY;
332
+ break;
333
+ case _.ROTATE:
334
+ if (t.ctrlKey || t.metaKey || t.shiftKey) {
335
+ if (this.enablePan === !1) return;
336
+ this._handleMouseDownPan(t), this.state = s.PAN;
337
+ } else {
338
+ if (this.enableRotate === !1) return;
339
+ this._handleMouseDownRotate(t), this.state = s.ROTATE;
340
+ }
341
+ break;
342
+ case _.PAN:
343
+ if (t.ctrlKey || t.metaKey || t.shiftKey) {
344
+ if (this.enableRotate === !1) return;
345
+ this._handleMouseDownRotate(t), this.state = s.ROTATE;
346
+ } else {
347
+ if (this.enablePan === !1) return;
348
+ this._handleMouseDownPan(t), this.state = s.PAN;
349
+ }
350
+ break;
351
+ default:
352
+ this.state = s.NONE;
353
+ }
354
+ this.state !== s.NONE && this.dispatchEvent(y);
355
+ }
356
+ function x(t) {
357
+ switch (this.state) {
358
+ case s.ROTATE:
359
+ if (this.enableRotate === !1) return;
360
+ this._handleMouseMoveRotate(t);
361
+ break;
362
+ case s.DOLLY:
363
+ if (this.enableZoom === !1) return;
364
+ this._handleMouseMoveDolly(t);
365
+ break;
366
+ case s.PAN:
367
+ if (this.enablePan === !1) return;
368
+ this._handleMouseMovePan(t);
369
+ break;
370
+ }
371
+ }
372
+ function C(t) {
373
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== s.NONE || (t.preventDefault(), this.dispatchEvent(y), this._handleMouseWheel(this._customWheelEvent(t)), this.dispatchEvent(T));
374
+ }
375
+ function N(t) {
376
+ this.enabled !== !1 && this._handleKeyDown(t);
377
+ }
378
+ function Y(t) {
379
+ switch (this._trackPointer(t), this._pointers.length) {
380
+ case 1:
381
+ switch (this.touches.ONE) {
382
+ case d.ROTATE:
383
+ if (this.enableRotate === !1) return;
384
+ this._handleTouchStartRotate(t), this.state = s.TOUCH_ROTATE;
385
+ break;
386
+ case d.PAN:
387
+ if (this.enablePan === !1) return;
388
+ this._handleTouchStartPan(t), this.state = s.TOUCH_PAN;
389
+ break;
390
+ default:
391
+ this.state = s.NONE;
392
+ }
393
+ break;
394
+ case 2:
395
+ switch (this.touches.TWO) {
396
+ case d.DOLLY_PAN:
397
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
398
+ this._handleTouchStartDollyPan(t), this.state = s.TOUCH_DOLLY_PAN;
399
+ break;
400
+ case d.DOLLY_ROTATE:
401
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
402
+ this._handleTouchStartDollyRotate(t), this.state = s.TOUCH_DOLLY_ROTATE;
403
+ break;
404
+ default:
405
+ this.state = s.NONE;
406
+ }
407
+ break;
408
+ default:
409
+ this.state = s.NONE;
410
+ }
411
+ this.state !== s.NONE && this.dispatchEvent(y);
412
+ }
413
+ function I(t) {
414
+ switch (this._trackPointer(t), this.state) {
415
+ case s.TOUCH_ROTATE:
416
+ if (this.enableRotate === !1) return;
417
+ this._handleTouchMoveRotate(t), this.update();
418
+ break;
419
+ case s.TOUCH_PAN:
420
+ if (this.enablePan === !1) return;
421
+ this._handleTouchMovePan(t), this.update();
422
+ break;
423
+ case s.TOUCH_DOLLY_PAN:
424
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
425
+ this._handleTouchMoveDollyPan(t), this.update();
426
+ break;
427
+ case s.TOUCH_DOLLY_ROTATE:
428
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
429
+ this._handleTouchMoveDollyRotate(t), this.update();
430
+ break;
431
+ default:
432
+ this.state = s.NONE;
433
+ }
434
+ }
435
+ function U(t) {
436
+ this.enabled !== !1 && t.preventDefault();
437
+ }
438
+ function Z(t) {
439
+ t.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, {
440
+ passive: !0,
441
+ capture: !0
442
+ }));
443
+ }
444
+ function z(t) {
445
+ t.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, {
446
+ passive: !0,
447
+ capture: !0
448
+ }));
449
+ }
450
+ export {
451
+ K as OrbitControls
452
+ };