@aixa-transformation/pptx-viewer 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/CHANGELOG.md +369 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/README.md +249 -0
- package/dist/GLTFLoader-CV33YWNT.js +2613 -0
- package/dist/GLTFLoader-FQJ2I67K.mjs +2611 -0
- package/dist/Model3DScene-5ODZLKJM.mjs +49 -0
- package/dist/Model3DScene-VLHFNN5B.js +51 -0
- package/dist/OrbitControls-HI6CI76Z.mjs +3 -0
- package/dist/OrbitControls-XGY7XEC6.js +12 -0
- package/dist/SmartArt3DScene-3FL5JELA.mjs +333 -0
- package/dist/SmartArt3DScene-7IZ3IJYV.js +335 -0
- package/dist/SurfaceChart3DScene-C6GQQQB7.mjs +77 -0
- package/dist/SurfaceChart3DScene-KHMGQAGP.js +79 -0
- package/dist/chunk-2TOLRBFU.js +27629 -0
- package/dist/chunk-2X72MOPZ.mjs +2796 -0
- package/dist/chunk-6DZX6EAA.mjs +33 -0
- package/dist/chunk-AD2CLKY6.js +92338 -0
- package/dist/chunk-CUUYYYC5.js +2800 -0
- package/dist/chunk-DAKELFNP.js +915 -0
- package/dist/chunk-F2HFXS2Z.mjs +19063 -0
- package/dist/chunk-F3LO2NKI.mjs +913 -0
- package/dist/chunk-HNI6JYAI.js +34591 -0
- package/dist/chunk-IKBO6CZC.js +2 -0
- package/dist/chunk-KVM4DBEU.mjs +91768 -0
- package/dist/chunk-MOEXMRVK.js +19220 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/chunk-SQY54X47.js +43506 -0
- package/dist/chunk-T5U6P2JH.mjs +1 -0
- package/dist/chunk-TB5ZWNMX.mjs +34577 -0
- package/dist/chunk-W5V6CEFL.mjs +43064 -0
- package/dist/chunk-XAVVR6OX.mjs +27204 -0
- package/dist/chunk-Y6FQDUJU.js +1160 -0
- package/dist/chunk-YI3G35EC.mjs +1076 -0
- package/dist/dist-LQJHTLHL.mjs +2 -0
- package/dist/dist-NVA3FEUV.js +2275 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +19 -0
- package/dist/i18n.mjs +2 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +135 -0
- package/dist/index.mjs +6 -0
- package/dist/internals.d.ts +1 -0
- package/dist/internals.js +311 -0
- package/dist/internals.mjs +6 -0
- package/dist/pptx-viewer.css +2 -0
- package/dist/presentation.d.ts +1 -0
- package/dist/presentation.js +11 -0
- package/dist/presentation.mjs +2 -0
- package/dist/three.module-HOXVV2KF.mjs +2 -0
- package/dist/three.module-QSJWIYNI.js +1771 -0
- package/dist/viewer/index.d.ts +1 -0
- package/dist/viewer/index.js +76 -0
- package/dist/viewer/index.mjs +7 -0
- package/dist/y-webrtc-DFUKFWCA.mjs +4279 -0
- package/dist/y-webrtc-RRACJ6WX.js +4284 -0
- package/dist/y-websocket-T5R5YGVE.mjs +378 -0
- package/dist/y-websocket-WMSHYIGX.js +384 -0
- package/package.json +141 -0
|
@@ -0,0 +1,915 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSQY54X47_js = require('./chunk-SQY54X47.js');
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/three/examples/jsm/controls/OrbitControls.js
|
|
6
|
+
var _changeEvent = { type: "change" };
|
|
7
|
+
var _startEvent = { type: "start" };
|
|
8
|
+
var _endEvent = { type: "end" };
|
|
9
|
+
var _ray = new chunkSQY54X47_js.Ray();
|
|
10
|
+
var _plane = new chunkSQY54X47_js.Plane();
|
|
11
|
+
var _TILT_LIMIT = Math.cos(70 * chunkSQY54X47_js.MathUtils.DEG2RAD);
|
|
12
|
+
var _v = new chunkSQY54X47_js.Vector3();
|
|
13
|
+
var _twoPI = 2 * Math.PI;
|
|
14
|
+
var _STATE = {
|
|
15
|
+
NONE: -1,
|
|
16
|
+
ROTATE: 0,
|
|
17
|
+
DOLLY: 1,
|
|
18
|
+
PAN: 2,
|
|
19
|
+
TOUCH_ROTATE: 3,
|
|
20
|
+
TOUCH_PAN: 4,
|
|
21
|
+
TOUCH_DOLLY_PAN: 5,
|
|
22
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
23
|
+
};
|
|
24
|
+
var _EPS = 1e-6;
|
|
25
|
+
var OrbitControls = class extends chunkSQY54X47_js.Controls {
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new controls instance.
|
|
28
|
+
*
|
|
29
|
+
* @param {Object3D} object - The object that is managed by the controls.
|
|
30
|
+
* @param {?HTMLElement} domElement - The HTML element used for event listeners.
|
|
31
|
+
*/
|
|
32
|
+
constructor(object, domElement = null) {
|
|
33
|
+
super(object, domElement);
|
|
34
|
+
this.state = _STATE.NONE;
|
|
35
|
+
this.target = new chunkSQY54X47_js.Vector3();
|
|
36
|
+
this.cursor = new chunkSQY54X47_js.Vector3();
|
|
37
|
+
this.minDistance = 0;
|
|
38
|
+
this.maxDistance = Infinity;
|
|
39
|
+
this.minZoom = 0;
|
|
40
|
+
this.maxZoom = Infinity;
|
|
41
|
+
this.minTargetRadius = 0;
|
|
42
|
+
this.maxTargetRadius = Infinity;
|
|
43
|
+
this.minPolarAngle = 0;
|
|
44
|
+
this.maxPolarAngle = Math.PI;
|
|
45
|
+
this.minAzimuthAngle = -Infinity;
|
|
46
|
+
this.maxAzimuthAngle = Infinity;
|
|
47
|
+
this.enableDamping = false;
|
|
48
|
+
this.dampingFactor = 0.05;
|
|
49
|
+
this.enableZoom = true;
|
|
50
|
+
this.zoomSpeed = 1;
|
|
51
|
+
this.enableRotate = true;
|
|
52
|
+
this.rotateSpeed = 1;
|
|
53
|
+
this.keyRotateSpeed = 1;
|
|
54
|
+
this.enablePan = true;
|
|
55
|
+
this.panSpeed = 1;
|
|
56
|
+
this.screenSpacePanning = true;
|
|
57
|
+
this.keyPanSpeed = 7;
|
|
58
|
+
this.zoomToCursor = false;
|
|
59
|
+
this.autoRotate = false;
|
|
60
|
+
this.autoRotateSpeed = 2;
|
|
61
|
+
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
62
|
+
this.mouseButtons = { LEFT: chunkSQY54X47_js.MOUSE.ROTATE, MIDDLE: chunkSQY54X47_js.MOUSE.DOLLY, RIGHT: chunkSQY54X47_js.MOUSE.PAN };
|
|
63
|
+
this.touches = { ONE: chunkSQY54X47_js.TOUCH.ROTATE, TWO: chunkSQY54X47_js.TOUCH.DOLLY_PAN };
|
|
64
|
+
this.target0 = this.target.clone();
|
|
65
|
+
this.position0 = this.object.position.clone();
|
|
66
|
+
this.zoom0 = this.object.zoom;
|
|
67
|
+
this._cursorStyle = "auto";
|
|
68
|
+
this._domElementKeyEvents = null;
|
|
69
|
+
this._lastPosition = new chunkSQY54X47_js.Vector3();
|
|
70
|
+
this._lastQuaternion = new chunkSQY54X47_js.Quaternion();
|
|
71
|
+
this._lastTargetPosition = new chunkSQY54X47_js.Vector3();
|
|
72
|
+
this._quat = new chunkSQY54X47_js.Quaternion().setFromUnitVectors(object.up, new chunkSQY54X47_js.Vector3(0, 1, 0));
|
|
73
|
+
this._quatInverse = this._quat.clone().invert();
|
|
74
|
+
this._spherical = new chunkSQY54X47_js.Spherical();
|
|
75
|
+
this._sphericalDelta = new chunkSQY54X47_js.Spherical();
|
|
76
|
+
this._scale = 1;
|
|
77
|
+
this._panOffset = new chunkSQY54X47_js.Vector3();
|
|
78
|
+
this._rotateStart = new chunkSQY54X47_js.Vector2();
|
|
79
|
+
this._rotateEnd = new chunkSQY54X47_js.Vector2();
|
|
80
|
+
this._rotateDelta = new chunkSQY54X47_js.Vector2();
|
|
81
|
+
this._panStart = new chunkSQY54X47_js.Vector2();
|
|
82
|
+
this._panEnd = new chunkSQY54X47_js.Vector2();
|
|
83
|
+
this._panDelta = new chunkSQY54X47_js.Vector2();
|
|
84
|
+
this._dollyStart = new chunkSQY54X47_js.Vector2();
|
|
85
|
+
this._dollyEnd = new chunkSQY54X47_js.Vector2();
|
|
86
|
+
this._dollyDelta = new chunkSQY54X47_js.Vector2();
|
|
87
|
+
this._dollyDirection = new chunkSQY54X47_js.Vector3();
|
|
88
|
+
this._mouse = new chunkSQY54X47_js.Vector2();
|
|
89
|
+
this._performCursorZoom = false;
|
|
90
|
+
this._pointers = [];
|
|
91
|
+
this._pointerPositions = {};
|
|
92
|
+
this._controlActive = false;
|
|
93
|
+
this._onPointerMove = onPointerMove.bind(this);
|
|
94
|
+
this._onPointerDown = onPointerDown.bind(this);
|
|
95
|
+
this._onPointerUp = onPointerUp.bind(this);
|
|
96
|
+
this._onContextMenu = onContextMenu.bind(this);
|
|
97
|
+
this._onMouseWheel = onMouseWheel.bind(this);
|
|
98
|
+
this._onKeyDown = onKeyDown.bind(this);
|
|
99
|
+
this._onTouchStart = onTouchStart.bind(this);
|
|
100
|
+
this._onTouchMove = onTouchMove.bind(this);
|
|
101
|
+
this._onMouseDown = onMouseDown.bind(this);
|
|
102
|
+
this._onMouseMove = onMouseMove.bind(this);
|
|
103
|
+
this._interceptControlDown = interceptControlDown.bind(this);
|
|
104
|
+
this._interceptControlUp = interceptControlUp.bind(this);
|
|
105
|
+
if (this.domElement !== null) {
|
|
106
|
+
this.connect(this.domElement);
|
|
107
|
+
}
|
|
108
|
+
this.update();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Defines the visual representation of the cursor.
|
|
112
|
+
*
|
|
113
|
+
* @type {('auto'|'grab')}
|
|
114
|
+
* @default 'auto'
|
|
115
|
+
*/
|
|
116
|
+
set cursorStyle(type) {
|
|
117
|
+
this._cursorStyle = type;
|
|
118
|
+
if (type === "grab") {
|
|
119
|
+
this.domElement.style.cursor = "grab";
|
|
120
|
+
} else {
|
|
121
|
+
this.domElement.style.cursor = "auto";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
get cursorStyle() {
|
|
125
|
+
return this._cursorStyle;
|
|
126
|
+
}
|
|
127
|
+
connect(element) {
|
|
128
|
+
super.connect(element);
|
|
129
|
+
this.domElement.addEventListener("pointerdown", this._onPointerDown);
|
|
130
|
+
this.domElement.addEventListener("pointercancel", this._onPointerUp);
|
|
131
|
+
this.domElement.addEventListener("contextmenu", this._onContextMenu);
|
|
132
|
+
this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: false });
|
|
133
|
+
const document = this.domElement.getRootNode();
|
|
134
|
+
document.addEventListener("keydown", this._interceptControlDown, { passive: true, capture: true });
|
|
135
|
+
this.domElement.style.touchAction = "none";
|
|
136
|
+
}
|
|
137
|
+
disconnect() {
|
|
138
|
+
this.domElement.removeEventListener("pointerdown", this._onPointerDown);
|
|
139
|
+
this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove);
|
|
140
|
+
this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp);
|
|
141
|
+
this.domElement.removeEventListener("pointercancel", this._onPointerUp);
|
|
142
|
+
this.domElement.removeEventListener("wheel", this._onMouseWheel);
|
|
143
|
+
this.domElement.removeEventListener("contextmenu", this._onContextMenu);
|
|
144
|
+
this.stopListenToKeyEvents();
|
|
145
|
+
const document = this.domElement.getRootNode();
|
|
146
|
+
document.removeEventListener("keydown", this._interceptControlDown, { capture: true });
|
|
147
|
+
this.domElement.style.touchAction = "";
|
|
148
|
+
}
|
|
149
|
+
dispose() {
|
|
150
|
+
this.disconnect();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the current vertical rotation, in radians.
|
|
154
|
+
*
|
|
155
|
+
* @return {number} The current vertical rotation, in radians.
|
|
156
|
+
*/
|
|
157
|
+
getPolarAngle() {
|
|
158
|
+
return this._spherical.phi;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the current horizontal rotation, in radians.
|
|
162
|
+
*
|
|
163
|
+
* @return {number} The current horizontal rotation, in radians.
|
|
164
|
+
*/
|
|
165
|
+
getAzimuthalAngle() {
|
|
166
|
+
return this._spherical.theta;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Returns the distance from the camera to the target.
|
|
170
|
+
*
|
|
171
|
+
* @return {number} The distance from the camera to the target.
|
|
172
|
+
*/
|
|
173
|
+
getDistance() {
|
|
174
|
+
return this.object.position.distanceTo(this.target);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Adds key event listeners to the given DOM element.
|
|
178
|
+
* `window` is a recommended argument for using this method.
|
|
179
|
+
*
|
|
180
|
+
* @param {HTMLElement} domElement - The DOM element
|
|
181
|
+
*/
|
|
182
|
+
listenToKeyEvents(domElement) {
|
|
183
|
+
domElement.addEventListener("keydown", this._onKeyDown);
|
|
184
|
+
this._domElementKeyEvents = domElement;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Removes the key event listener previously defined with `listenToKeyEvents()`.
|
|
188
|
+
*/
|
|
189
|
+
stopListenToKeyEvents() {
|
|
190
|
+
if (this._domElementKeyEvents !== null) {
|
|
191
|
+
this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown);
|
|
192
|
+
this._domElementKeyEvents = null;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Save the current state of the controls. This can later be recovered with `reset()`.
|
|
197
|
+
*/
|
|
198
|
+
saveState() {
|
|
199
|
+
this.target0.copy(this.target);
|
|
200
|
+
this.position0.copy(this.object.position);
|
|
201
|
+
this.zoom0 = this.object.zoom;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Reset the controls to their state from either the last time the `saveState()`
|
|
205
|
+
* was called, or the initial state.
|
|
206
|
+
*/
|
|
207
|
+
reset() {
|
|
208
|
+
this.target.copy(this.target0);
|
|
209
|
+
this.object.position.copy(this.position0);
|
|
210
|
+
this.object.zoom = this.zoom0;
|
|
211
|
+
this.object.updateProjectionMatrix();
|
|
212
|
+
this.dispatchEvent(_changeEvent);
|
|
213
|
+
this.update();
|
|
214
|
+
this.state = _STATE.NONE;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Programmatically pan the camera.
|
|
218
|
+
*
|
|
219
|
+
* @param {number} deltaX - The horizontal pan amount in pixels.
|
|
220
|
+
* @param {number} deltaY - The vertical pan amount in pixels.
|
|
221
|
+
*/
|
|
222
|
+
pan(deltaX, deltaY) {
|
|
223
|
+
this._pan(deltaX, deltaY);
|
|
224
|
+
this.update();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Programmatically dolly in (zoom in for perspective camera).
|
|
228
|
+
*
|
|
229
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
230
|
+
*/
|
|
231
|
+
dollyIn(dollyScale) {
|
|
232
|
+
this._dollyIn(dollyScale);
|
|
233
|
+
this.update();
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Programmatically dolly out (zoom out for perspective camera).
|
|
237
|
+
*
|
|
238
|
+
* @param {number} dollyScale - The dolly scale factor.
|
|
239
|
+
*/
|
|
240
|
+
dollyOut(dollyScale) {
|
|
241
|
+
this._dollyOut(dollyScale);
|
|
242
|
+
this.update();
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Programmatically rotate the camera left (around the vertical axis).
|
|
246
|
+
*
|
|
247
|
+
* @param {number} angle - The rotation angle in radians.
|
|
248
|
+
*/
|
|
249
|
+
rotateLeft(angle) {
|
|
250
|
+
this._rotateLeft(angle);
|
|
251
|
+
this.update();
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Programmatically rotate the camera up (around the horizontal axis).
|
|
255
|
+
*
|
|
256
|
+
* @param {number} angle - The rotation angle in radians.
|
|
257
|
+
*/
|
|
258
|
+
rotateUp(angle) {
|
|
259
|
+
this._rotateUp(angle);
|
|
260
|
+
this.update();
|
|
261
|
+
}
|
|
262
|
+
update(deltaTime = null) {
|
|
263
|
+
const position = this.object.position;
|
|
264
|
+
_v.copy(position).sub(this.target);
|
|
265
|
+
_v.applyQuaternion(this._quat);
|
|
266
|
+
this._spherical.setFromVector3(_v);
|
|
267
|
+
if (this.autoRotate && this.state === _STATE.NONE) {
|
|
268
|
+
this._rotateLeft(this._getAutoRotationAngle(deltaTime));
|
|
269
|
+
}
|
|
270
|
+
if (this.enableDamping) {
|
|
271
|
+
this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor;
|
|
272
|
+
this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor;
|
|
273
|
+
} else {
|
|
274
|
+
this._spherical.theta += this._sphericalDelta.theta;
|
|
275
|
+
this._spherical.phi += this._sphericalDelta.phi;
|
|
276
|
+
}
|
|
277
|
+
let min = this.minAzimuthAngle;
|
|
278
|
+
let max = this.maxAzimuthAngle;
|
|
279
|
+
if (isFinite(min) && isFinite(max)) {
|
|
280
|
+
if (min < -Math.PI) min += _twoPI;
|
|
281
|
+
else if (min > Math.PI) min -= _twoPI;
|
|
282
|
+
if (max < -Math.PI) max += _twoPI;
|
|
283
|
+
else if (max > Math.PI) max -= _twoPI;
|
|
284
|
+
if (min <= max) {
|
|
285
|
+
this._spherical.theta = Math.max(min, Math.min(max, this._spherical.theta));
|
|
286
|
+
} else {
|
|
287
|
+
this._spherical.theta = this._spherical.theta > (min + max) / 2 ? Math.max(min, this._spherical.theta) : Math.min(max, this._spherical.theta);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi));
|
|
291
|
+
this._spherical.makeSafe();
|
|
292
|
+
if (this.enableDamping === true) {
|
|
293
|
+
this.target.addScaledVector(this._panOffset, this.dampingFactor);
|
|
294
|
+
} else {
|
|
295
|
+
this.target.add(this._panOffset);
|
|
296
|
+
}
|
|
297
|
+
this.target.sub(this.cursor);
|
|
298
|
+
this.target.clampLength(this.minTargetRadius, this.maxTargetRadius);
|
|
299
|
+
this.target.add(this.cursor);
|
|
300
|
+
let zoomChanged = false;
|
|
301
|
+
if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera) {
|
|
302
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius);
|
|
303
|
+
} else {
|
|
304
|
+
const prevRadius = this._spherical.radius;
|
|
305
|
+
this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale);
|
|
306
|
+
zoomChanged = prevRadius != this._spherical.radius;
|
|
307
|
+
}
|
|
308
|
+
_v.setFromSpherical(this._spherical);
|
|
309
|
+
_v.applyQuaternion(this._quatInverse);
|
|
310
|
+
position.copy(this.target).add(_v);
|
|
311
|
+
this.object.lookAt(this.target);
|
|
312
|
+
if (this.enableDamping === true) {
|
|
313
|
+
this._sphericalDelta.theta *= 1 - this.dampingFactor;
|
|
314
|
+
this._sphericalDelta.phi *= 1 - this.dampingFactor;
|
|
315
|
+
this._panOffset.multiplyScalar(1 - this.dampingFactor);
|
|
316
|
+
} else {
|
|
317
|
+
this._sphericalDelta.set(0, 0, 0);
|
|
318
|
+
this._panOffset.set(0, 0, 0);
|
|
319
|
+
}
|
|
320
|
+
if (this.zoomToCursor && this._performCursorZoom) {
|
|
321
|
+
let newRadius = null;
|
|
322
|
+
if (this.object.isPerspectiveCamera) {
|
|
323
|
+
const prevRadius = _v.length();
|
|
324
|
+
newRadius = this._clampDistance(prevRadius * this._scale);
|
|
325
|
+
const radiusDelta = prevRadius - newRadius;
|
|
326
|
+
this.object.position.addScaledVector(this._dollyDirection, radiusDelta);
|
|
327
|
+
this.object.updateMatrixWorld();
|
|
328
|
+
zoomChanged = !!radiusDelta;
|
|
329
|
+
} else if (this.object.isOrthographicCamera) {
|
|
330
|
+
const mouseBefore = new chunkSQY54X47_js.Vector3(this._mouse.x, this._mouse.y, 0);
|
|
331
|
+
mouseBefore.unproject(this.object);
|
|
332
|
+
const prevZoom = this.object.zoom;
|
|
333
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale));
|
|
334
|
+
this.object.updateProjectionMatrix();
|
|
335
|
+
zoomChanged = prevZoom !== this.object.zoom;
|
|
336
|
+
const mouseAfter = new chunkSQY54X47_js.Vector3(this._mouse.x, this._mouse.y, 0);
|
|
337
|
+
mouseAfter.unproject(this.object);
|
|
338
|
+
this.object.position.sub(mouseAfter).add(mouseBefore);
|
|
339
|
+
this.object.updateMatrixWorld();
|
|
340
|
+
newRadius = _v.length();
|
|
341
|
+
} else {
|
|
342
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.");
|
|
343
|
+
this.zoomToCursor = false;
|
|
344
|
+
}
|
|
345
|
+
if (newRadius !== null) {
|
|
346
|
+
if (this.screenSpacePanning) {
|
|
347
|
+
this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(newRadius).add(this.object.position);
|
|
348
|
+
} else {
|
|
349
|
+
_ray.origin.copy(this.object.position);
|
|
350
|
+
_ray.direction.set(0, 0, -1).transformDirection(this.object.matrix);
|
|
351
|
+
if (Math.abs(this.object.up.dot(_ray.direction)) < _TILT_LIMIT) {
|
|
352
|
+
this.object.lookAt(this.target);
|
|
353
|
+
} else {
|
|
354
|
+
_plane.setFromNormalAndCoplanarPoint(this.object.up, this.target);
|
|
355
|
+
_ray.intersectPlane(_plane, this.target);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
} else if (this.object.isOrthographicCamera) {
|
|
360
|
+
const prevZoom = this.object.zoom;
|
|
361
|
+
this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale));
|
|
362
|
+
if (prevZoom !== this.object.zoom) {
|
|
363
|
+
this.object.updateProjectionMatrix();
|
|
364
|
+
zoomChanged = true;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
this._scale = 1;
|
|
368
|
+
this._performCursorZoom = false;
|
|
369
|
+
if (zoomChanged || this._lastPosition.distanceToSquared(this.object.position) > _EPS || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > _EPS || this._lastTargetPosition.distanceToSquared(this.target) > _EPS) {
|
|
370
|
+
this.dispatchEvent(_changeEvent);
|
|
371
|
+
this._lastPosition.copy(this.object.position);
|
|
372
|
+
this._lastQuaternion.copy(this.object.quaternion);
|
|
373
|
+
this._lastTargetPosition.copy(this.target);
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
_getAutoRotationAngle(deltaTime) {
|
|
379
|
+
if (deltaTime !== null) {
|
|
380
|
+
return _twoPI / 60 * this.autoRotateSpeed * deltaTime;
|
|
381
|
+
} else {
|
|
382
|
+
return _twoPI / 60 / 60 * this.autoRotateSpeed;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
_getZoomScale(delta) {
|
|
386
|
+
const normalizedDelta = Math.abs(delta * 0.01);
|
|
387
|
+
return Math.pow(0.95, this.zoomSpeed * normalizedDelta);
|
|
388
|
+
}
|
|
389
|
+
_rotateLeft(angle) {
|
|
390
|
+
this._sphericalDelta.theta -= angle;
|
|
391
|
+
}
|
|
392
|
+
_rotateUp(angle) {
|
|
393
|
+
this._sphericalDelta.phi -= angle;
|
|
394
|
+
}
|
|
395
|
+
_panLeft(distance, objectMatrix) {
|
|
396
|
+
_v.setFromMatrixColumn(objectMatrix, 0);
|
|
397
|
+
_v.multiplyScalar(-distance);
|
|
398
|
+
this._panOffset.add(_v);
|
|
399
|
+
}
|
|
400
|
+
_panUp(distance, objectMatrix) {
|
|
401
|
+
if (this.screenSpacePanning === true) {
|
|
402
|
+
_v.setFromMatrixColumn(objectMatrix, 1);
|
|
403
|
+
} else {
|
|
404
|
+
_v.setFromMatrixColumn(objectMatrix, 0);
|
|
405
|
+
_v.crossVectors(this.object.up, _v);
|
|
406
|
+
}
|
|
407
|
+
_v.multiplyScalar(distance);
|
|
408
|
+
this._panOffset.add(_v);
|
|
409
|
+
}
|
|
410
|
+
// deltaX and deltaY are in pixels; right and down are positive
|
|
411
|
+
_pan(deltaX, deltaY) {
|
|
412
|
+
const element = this.domElement;
|
|
413
|
+
if (this.object.isPerspectiveCamera) {
|
|
414
|
+
const position = this.object.position;
|
|
415
|
+
_v.copy(position).sub(this.target);
|
|
416
|
+
let targetDistance = _v.length();
|
|
417
|
+
targetDistance *= Math.tan(this.object.fov / 2 * Math.PI / 180);
|
|
418
|
+
this._panLeft(2 * deltaX * targetDistance / element.clientHeight, this.object.matrix);
|
|
419
|
+
this._panUp(2 * deltaY * targetDistance / element.clientHeight, this.object.matrix);
|
|
420
|
+
} else if (this.object.isOrthographicCamera) {
|
|
421
|
+
this._panLeft(deltaX * (this.object.right - this.object.left) / this.object.zoom / element.clientWidth, this.object.matrix);
|
|
422
|
+
this._panUp(deltaY * (this.object.top - this.object.bottom) / this.object.zoom / element.clientHeight, this.object.matrix);
|
|
423
|
+
} else {
|
|
424
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
425
|
+
this.enablePan = false;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
_dollyOut(dollyScale) {
|
|
429
|
+
if (this.object.isPerspectiveCamera || this.object.isOrthographicCamera) {
|
|
430
|
+
this._scale /= dollyScale;
|
|
431
|
+
} else {
|
|
432
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
433
|
+
this.enableZoom = false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
_dollyIn(dollyScale) {
|
|
437
|
+
if (this.object.isPerspectiveCamera || this.object.isOrthographicCamera) {
|
|
438
|
+
this._scale *= dollyScale;
|
|
439
|
+
} else {
|
|
440
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
441
|
+
this.enableZoom = false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
_updateZoomParameters(x, y) {
|
|
445
|
+
if (!this.zoomToCursor) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this._performCursorZoom = true;
|
|
449
|
+
const rect = this.domElement.getBoundingClientRect();
|
|
450
|
+
const dx = x - rect.left;
|
|
451
|
+
const dy = y - rect.top;
|
|
452
|
+
const w = rect.width;
|
|
453
|
+
const h = rect.height;
|
|
454
|
+
this._mouse.x = dx / w * 2 - 1;
|
|
455
|
+
this._mouse.y = -(dy / h) * 2 + 1;
|
|
456
|
+
this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
|
|
457
|
+
}
|
|
458
|
+
_clampDistance(dist) {
|
|
459
|
+
return Math.max(this.minDistance, Math.min(this.maxDistance, dist));
|
|
460
|
+
}
|
|
461
|
+
//
|
|
462
|
+
// event callbacks - update the object state
|
|
463
|
+
//
|
|
464
|
+
_handleMouseDownRotate(event) {
|
|
465
|
+
this._rotateStart.set(event.clientX, event.clientY);
|
|
466
|
+
}
|
|
467
|
+
_handleMouseDownDolly(event) {
|
|
468
|
+
this._updateZoomParameters(event.clientX, event.clientX);
|
|
469
|
+
this._dollyStart.set(event.clientX, event.clientY);
|
|
470
|
+
}
|
|
471
|
+
_handleMouseDownPan(event) {
|
|
472
|
+
this._panStart.set(event.clientX, event.clientY);
|
|
473
|
+
}
|
|
474
|
+
_handleMouseMoveRotate(event) {
|
|
475
|
+
this._rotateEnd.set(event.clientX, event.clientY);
|
|
476
|
+
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
477
|
+
const element = this.domElement;
|
|
478
|
+
this._rotateLeft(_twoPI * this._rotateDelta.x / element.clientHeight);
|
|
479
|
+
this._rotateUp(_twoPI * this._rotateDelta.y / element.clientHeight);
|
|
480
|
+
this._rotateStart.copy(this._rotateEnd);
|
|
481
|
+
this.update();
|
|
482
|
+
}
|
|
483
|
+
_handleMouseMoveDolly(event) {
|
|
484
|
+
this._dollyEnd.set(event.clientX, event.clientY);
|
|
485
|
+
this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart);
|
|
486
|
+
if (this._dollyDelta.y > 0) {
|
|
487
|
+
this._dollyOut(this._getZoomScale(this._dollyDelta.y));
|
|
488
|
+
} else if (this._dollyDelta.y < 0) {
|
|
489
|
+
this._dollyIn(this._getZoomScale(this._dollyDelta.y));
|
|
490
|
+
}
|
|
491
|
+
this._dollyStart.copy(this._dollyEnd);
|
|
492
|
+
this.update();
|
|
493
|
+
}
|
|
494
|
+
_handleMouseMovePan(event) {
|
|
495
|
+
this._panEnd.set(event.clientX, event.clientY);
|
|
496
|
+
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed);
|
|
497
|
+
this._pan(this._panDelta.x, this._panDelta.y);
|
|
498
|
+
this._panStart.copy(this._panEnd);
|
|
499
|
+
this.update();
|
|
500
|
+
}
|
|
501
|
+
_handleMouseWheel(event) {
|
|
502
|
+
this._updateZoomParameters(event.clientX, event.clientY);
|
|
503
|
+
if (event.deltaY < 0) {
|
|
504
|
+
this._dollyIn(this._getZoomScale(event.deltaY));
|
|
505
|
+
} else if (event.deltaY > 0) {
|
|
506
|
+
this._dollyOut(this._getZoomScale(event.deltaY));
|
|
507
|
+
}
|
|
508
|
+
this.update();
|
|
509
|
+
}
|
|
510
|
+
_handleKeyDown(event) {
|
|
511
|
+
let needsUpdate = false;
|
|
512
|
+
switch (event.code) {
|
|
513
|
+
case this.keys.UP:
|
|
514
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
515
|
+
if (this.enableRotate) {
|
|
516
|
+
this._rotateUp(_twoPI * this.keyRotateSpeed / this.domElement.clientHeight);
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
if (this.enablePan) {
|
|
520
|
+
this._pan(0, this.keyPanSpeed);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
needsUpdate = true;
|
|
524
|
+
break;
|
|
525
|
+
case this.keys.BOTTOM:
|
|
526
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
527
|
+
if (this.enableRotate) {
|
|
528
|
+
this._rotateUp(-_twoPI * this.keyRotateSpeed / this.domElement.clientHeight);
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
if (this.enablePan) {
|
|
532
|
+
this._pan(0, -this.keyPanSpeed);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
needsUpdate = true;
|
|
536
|
+
break;
|
|
537
|
+
case this.keys.LEFT:
|
|
538
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
539
|
+
if (this.enableRotate) {
|
|
540
|
+
this._rotateLeft(_twoPI * this.keyRotateSpeed / this.domElement.clientHeight);
|
|
541
|
+
}
|
|
542
|
+
} else {
|
|
543
|
+
if (this.enablePan) {
|
|
544
|
+
this._pan(this.keyPanSpeed, 0);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
needsUpdate = true;
|
|
548
|
+
break;
|
|
549
|
+
case this.keys.RIGHT:
|
|
550
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
551
|
+
if (this.enableRotate) {
|
|
552
|
+
this._rotateLeft(-_twoPI * this.keyRotateSpeed / this.domElement.clientHeight);
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
if (this.enablePan) {
|
|
556
|
+
this._pan(-this.keyPanSpeed, 0);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
needsUpdate = true;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
if (needsUpdate) {
|
|
563
|
+
event.preventDefault();
|
|
564
|
+
this.update();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
_handleTouchStartRotate(event) {
|
|
568
|
+
if (this._pointers.length === 1) {
|
|
569
|
+
this._rotateStart.set(event.pageX, event.pageY);
|
|
570
|
+
} else {
|
|
571
|
+
const position = this._getSecondPointerPosition(event);
|
|
572
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
573
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
574
|
+
this._rotateStart.set(x, y);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
_handleTouchStartPan(event) {
|
|
578
|
+
if (this._pointers.length === 1) {
|
|
579
|
+
this._panStart.set(event.pageX, event.pageY);
|
|
580
|
+
} else {
|
|
581
|
+
const position = this._getSecondPointerPosition(event);
|
|
582
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
583
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
584
|
+
this._panStart.set(x, y);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
_handleTouchStartDolly(event) {
|
|
588
|
+
const position = this._getSecondPointerPosition(event);
|
|
589
|
+
const dx = event.pageX - position.x;
|
|
590
|
+
const dy = event.pageY - position.y;
|
|
591
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
592
|
+
this._dollyStart.set(0, distance);
|
|
593
|
+
}
|
|
594
|
+
_handleTouchStartDollyPan(event) {
|
|
595
|
+
if (this.enableZoom) this._handleTouchStartDolly(event);
|
|
596
|
+
if (this.enablePan) this._handleTouchStartPan(event);
|
|
597
|
+
}
|
|
598
|
+
_handleTouchStartDollyRotate(event) {
|
|
599
|
+
if (this.enableZoom) this._handleTouchStartDolly(event);
|
|
600
|
+
if (this.enableRotate) this._handleTouchStartRotate(event);
|
|
601
|
+
}
|
|
602
|
+
_handleTouchMoveRotate(event) {
|
|
603
|
+
if (this._pointers.length == 1) {
|
|
604
|
+
this._rotateEnd.set(event.pageX, event.pageY);
|
|
605
|
+
} else {
|
|
606
|
+
const position = this._getSecondPointerPosition(event);
|
|
607
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
608
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
609
|
+
this._rotateEnd.set(x, y);
|
|
610
|
+
}
|
|
611
|
+
this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
|
|
612
|
+
const element = this.domElement;
|
|
613
|
+
this._rotateLeft(_twoPI * this._rotateDelta.x / element.clientHeight);
|
|
614
|
+
this._rotateUp(_twoPI * this._rotateDelta.y / element.clientHeight);
|
|
615
|
+
this._rotateStart.copy(this._rotateEnd);
|
|
616
|
+
}
|
|
617
|
+
_handleTouchMovePan(event) {
|
|
618
|
+
if (this._pointers.length === 1) {
|
|
619
|
+
this._panEnd.set(event.pageX, event.pageY);
|
|
620
|
+
} else {
|
|
621
|
+
const position = this._getSecondPointerPosition(event);
|
|
622
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
623
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
624
|
+
this._panEnd.set(x, y);
|
|
625
|
+
}
|
|
626
|
+
this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed);
|
|
627
|
+
this._pan(this._panDelta.x, this._panDelta.y);
|
|
628
|
+
this._panStart.copy(this._panEnd);
|
|
629
|
+
}
|
|
630
|
+
_handleTouchMoveDolly(event) {
|
|
631
|
+
const position = this._getSecondPointerPosition(event);
|
|
632
|
+
const dx = event.pageX - position.x;
|
|
633
|
+
const dy = event.pageY - position.y;
|
|
634
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
635
|
+
this._dollyEnd.set(0, distance);
|
|
636
|
+
this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed));
|
|
637
|
+
this._dollyOut(this._dollyDelta.y);
|
|
638
|
+
this._dollyStart.copy(this._dollyEnd);
|
|
639
|
+
const centerX = (event.pageX + position.x) * 0.5;
|
|
640
|
+
const centerY = (event.pageY + position.y) * 0.5;
|
|
641
|
+
this._updateZoomParameters(centerX, centerY);
|
|
642
|
+
}
|
|
643
|
+
_handleTouchMoveDollyPan(event) {
|
|
644
|
+
if (this.enableZoom) this._handleTouchMoveDolly(event);
|
|
645
|
+
if (this.enablePan) this._handleTouchMovePan(event);
|
|
646
|
+
}
|
|
647
|
+
_handleTouchMoveDollyRotate(event) {
|
|
648
|
+
if (this.enableZoom) this._handleTouchMoveDolly(event);
|
|
649
|
+
if (this.enableRotate) this._handleTouchMoveRotate(event);
|
|
650
|
+
}
|
|
651
|
+
// pointers
|
|
652
|
+
_addPointer(event) {
|
|
653
|
+
this._pointers.push(event.pointerId);
|
|
654
|
+
}
|
|
655
|
+
_removePointer(event) {
|
|
656
|
+
delete this._pointerPositions[event.pointerId];
|
|
657
|
+
for (let i = 0; i < this._pointers.length; i++) {
|
|
658
|
+
if (this._pointers[i] == event.pointerId) {
|
|
659
|
+
this._pointers.splice(i, 1);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
_isTrackingPointer(event) {
|
|
665
|
+
for (let i = 0; i < this._pointers.length; i++) {
|
|
666
|
+
if (this._pointers[i] == event.pointerId) return true;
|
|
667
|
+
}
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
_trackPointer(event) {
|
|
671
|
+
let position = this._pointerPositions[event.pointerId];
|
|
672
|
+
if (position === void 0) {
|
|
673
|
+
position = new chunkSQY54X47_js.Vector2();
|
|
674
|
+
this._pointerPositions[event.pointerId] = position;
|
|
675
|
+
}
|
|
676
|
+
position.set(event.pageX, event.pageY);
|
|
677
|
+
}
|
|
678
|
+
_getSecondPointerPosition(event) {
|
|
679
|
+
const pointerId = event.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
|
|
680
|
+
return this._pointerPositions[pointerId];
|
|
681
|
+
}
|
|
682
|
+
//
|
|
683
|
+
_customWheelEvent(event) {
|
|
684
|
+
const mode = event.deltaMode;
|
|
685
|
+
const newEvent = {
|
|
686
|
+
clientX: event.clientX,
|
|
687
|
+
clientY: event.clientY,
|
|
688
|
+
deltaY: event.deltaY
|
|
689
|
+
};
|
|
690
|
+
switch (mode) {
|
|
691
|
+
case 1:
|
|
692
|
+
newEvent.deltaY *= 16;
|
|
693
|
+
break;
|
|
694
|
+
case 2:
|
|
695
|
+
newEvent.deltaY *= 100;
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
if (event.ctrlKey && !this._controlActive) {
|
|
699
|
+
newEvent.deltaY *= 10;
|
|
700
|
+
}
|
|
701
|
+
return newEvent;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
function onPointerDown(event) {
|
|
705
|
+
if (this.enabled === false) return;
|
|
706
|
+
if (this._pointers.length === 0) {
|
|
707
|
+
this.domElement.setPointerCapture(event.pointerId);
|
|
708
|
+
this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove);
|
|
709
|
+
this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp);
|
|
710
|
+
}
|
|
711
|
+
if (this._isTrackingPointer(event)) return;
|
|
712
|
+
this._addPointer(event);
|
|
713
|
+
if (event.pointerType === "touch") {
|
|
714
|
+
this._onTouchStart(event);
|
|
715
|
+
} else {
|
|
716
|
+
this._onMouseDown(event);
|
|
717
|
+
}
|
|
718
|
+
if (this._cursorStyle === "grab") {
|
|
719
|
+
this.domElement.style.cursor = "grabbing";
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function onPointerMove(event) {
|
|
723
|
+
if (this.enabled === false) return;
|
|
724
|
+
if (event.pointerType === "touch") {
|
|
725
|
+
this._onTouchMove(event);
|
|
726
|
+
} else {
|
|
727
|
+
this._onMouseMove(event);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function onPointerUp(event) {
|
|
731
|
+
this._removePointer(event);
|
|
732
|
+
switch (this._pointers.length) {
|
|
733
|
+
case 0:
|
|
734
|
+
this.domElement.releasePointerCapture(event.pointerId);
|
|
735
|
+
this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove);
|
|
736
|
+
this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp);
|
|
737
|
+
this.dispatchEvent(_endEvent);
|
|
738
|
+
this.state = _STATE.NONE;
|
|
739
|
+
if (this._cursorStyle === "grab") {
|
|
740
|
+
this.domElement.style.cursor = "grab";
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
743
|
+
case 1:
|
|
744
|
+
const pointerId = this._pointers[0];
|
|
745
|
+
const position = this._pointerPositions[pointerId];
|
|
746
|
+
this._onTouchStart({ pointerId, pageX: position.x, pageY: position.y });
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function onMouseDown(event) {
|
|
751
|
+
let mouseAction;
|
|
752
|
+
switch (event.button) {
|
|
753
|
+
case 0:
|
|
754
|
+
mouseAction = this.mouseButtons.LEFT;
|
|
755
|
+
break;
|
|
756
|
+
case 1:
|
|
757
|
+
mouseAction = this.mouseButtons.MIDDLE;
|
|
758
|
+
break;
|
|
759
|
+
case 2:
|
|
760
|
+
mouseAction = this.mouseButtons.RIGHT;
|
|
761
|
+
break;
|
|
762
|
+
default:
|
|
763
|
+
mouseAction = -1;
|
|
764
|
+
}
|
|
765
|
+
switch (mouseAction) {
|
|
766
|
+
case chunkSQY54X47_js.MOUSE.DOLLY:
|
|
767
|
+
if (this.enableZoom === false) return;
|
|
768
|
+
this._handleMouseDownDolly(event);
|
|
769
|
+
this.state = _STATE.DOLLY;
|
|
770
|
+
break;
|
|
771
|
+
case chunkSQY54X47_js.MOUSE.ROTATE:
|
|
772
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
773
|
+
if (this.enablePan === false) return;
|
|
774
|
+
this._handleMouseDownPan(event);
|
|
775
|
+
this.state = _STATE.PAN;
|
|
776
|
+
} else {
|
|
777
|
+
if (this.enableRotate === false) return;
|
|
778
|
+
this._handleMouseDownRotate(event);
|
|
779
|
+
this.state = _STATE.ROTATE;
|
|
780
|
+
}
|
|
781
|
+
break;
|
|
782
|
+
case chunkSQY54X47_js.MOUSE.PAN:
|
|
783
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
784
|
+
if (this.enableRotate === false) return;
|
|
785
|
+
this._handleMouseDownRotate(event);
|
|
786
|
+
this.state = _STATE.ROTATE;
|
|
787
|
+
} else {
|
|
788
|
+
if (this.enablePan === false) return;
|
|
789
|
+
this._handleMouseDownPan(event);
|
|
790
|
+
this.state = _STATE.PAN;
|
|
791
|
+
}
|
|
792
|
+
break;
|
|
793
|
+
default:
|
|
794
|
+
this.state = _STATE.NONE;
|
|
795
|
+
}
|
|
796
|
+
if (this.state !== _STATE.NONE) {
|
|
797
|
+
this.dispatchEvent(_startEvent);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
function onMouseMove(event) {
|
|
801
|
+
switch (this.state) {
|
|
802
|
+
case _STATE.ROTATE:
|
|
803
|
+
if (this.enableRotate === false) return;
|
|
804
|
+
this._handleMouseMoveRotate(event);
|
|
805
|
+
break;
|
|
806
|
+
case _STATE.DOLLY:
|
|
807
|
+
if (this.enableZoom === false) return;
|
|
808
|
+
this._handleMouseMoveDolly(event);
|
|
809
|
+
break;
|
|
810
|
+
case _STATE.PAN:
|
|
811
|
+
if (this.enablePan === false) return;
|
|
812
|
+
this._handleMouseMovePan(event);
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function onMouseWheel(event) {
|
|
817
|
+
if (this.enabled === false || this.enableZoom === false || this.state !== _STATE.NONE) return;
|
|
818
|
+
event.preventDefault();
|
|
819
|
+
this.dispatchEvent(_startEvent);
|
|
820
|
+
this._handleMouseWheel(this._customWheelEvent(event));
|
|
821
|
+
this.dispatchEvent(_endEvent);
|
|
822
|
+
}
|
|
823
|
+
function onKeyDown(event) {
|
|
824
|
+
if (this.enabled === false) return;
|
|
825
|
+
this._handleKeyDown(event);
|
|
826
|
+
}
|
|
827
|
+
function onTouchStart(event) {
|
|
828
|
+
this._trackPointer(event);
|
|
829
|
+
switch (this._pointers.length) {
|
|
830
|
+
case 1:
|
|
831
|
+
switch (this.touches.ONE) {
|
|
832
|
+
case chunkSQY54X47_js.TOUCH.ROTATE:
|
|
833
|
+
if (this.enableRotate === false) return;
|
|
834
|
+
this._handleTouchStartRotate(event);
|
|
835
|
+
this.state = _STATE.TOUCH_ROTATE;
|
|
836
|
+
break;
|
|
837
|
+
case chunkSQY54X47_js.TOUCH.PAN:
|
|
838
|
+
if (this.enablePan === false) return;
|
|
839
|
+
this._handleTouchStartPan(event);
|
|
840
|
+
this.state = _STATE.TOUCH_PAN;
|
|
841
|
+
break;
|
|
842
|
+
default:
|
|
843
|
+
this.state = _STATE.NONE;
|
|
844
|
+
}
|
|
845
|
+
break;
|
|
846
|
+
case 2:
|
|
847
|
+
switch (this.touches.TWO) {
|
|
848
|
+
case chunkSQY54X47_js.TOUCH.DOLLY_PAN:
|
|
849
|
+
if (this.enableZoom === false && this.enablePan === false) return;
|
|
850
|
+
this._handleTouchStartDollyPan(event);
|
|
851
|
+
this.state = _STATE.TOUCH_DOLLY_PAN;
|
|
852
|
+
break;
|
|
853
|
+
case chunkSQY54X47_js.TOUCH.DOLLY_ROTATE:
|
|
854
|
+
if (this.enableZoom === false && this.enableRotate === false) return;
|
|
855
|
+
this._handleTouchStartDollyRotate(event);
|
|
856
|
+
this.state = _STATE.TOUCH_DOLLY_ROTATE;
|
|
857
|
+
break;
|
|
858
|
+
default:
|
|
859
|
+
this.state = _STATE.NONE;
|
|
860
|
+
}
|
|
861
|
+
break;
|
|
862
|
+
default:
|
|
863
|
+
this.state = _STATE.NONE;
|
|
864
|
+
}
|
|
865
|
+
if (this.state !== _STATE.NONE) {
|
|
866
|
+
this.dispatchEvent(_startEvent);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function onTouchMove(event) {
|
|
870
|
+
this._trackPointer(event);
|
|
871
|
+
switch (this.state) {
|
|
872
|
+
case _STATE.TOUCH_ROTATE:
|
|
873
|
+
if (this.enableRotate === false) return;
|
|
874
|
+
this._handleTouchMoveRotate(event);
|
|
875
|
+
this.update();
|
|
876
|
+
break;
|
|
877
|
+
case _STATE.TOUCH_PAN:
|
|
878
|
+
if (this.enablePan === false) return;
|
|
879
|
+
this._handleTouchMovePan(event);
|
|
880
|
+
this.update();
|
|
881
|
+
break;
|
|
882
|
+
case _STATE.TOUCH_DOLLY_PAN:
|
|
883
|
+
if (this.enableZoom === false && this.enablePan === false) return;
|
|
884
|
+
this._handleTouchMoveDollyPan(event);
|
|
885
|
+
this.update();
|
|
886
|
+
break;
|
|
887
|
+
case _STATE.TOUCH_DOLLY_ROTATE:
|
|
888
|
+
if (this.enableZoom === false && this.enableRotate === false) return;
|
|
889
|
+
this._handleTouchMoveDollyRotate(event);
|
|
890
|
+
this.update();
|
|
891
|
+
break;
|
|
892
|
+
default:
|
|
893
|
+
this.state = _STATE.NONE;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function onContextMenu(event) {
|
|
897
|
+
if (this.enabled === false) return;
|
|
898
|
+
event.preventDefault();
|
|
899
|
+
}
|
|
900
|
+
function interceptControlDown(event) {
|
|
901
|
+
if (event.key === "Control") {
|
|
902
|
+
this._controlActive = true;
|
|
903
|
+
const document = this.domElement.getRootNode();
|
|
904
|
+
document.addEventListener("keyup", this._interceptControlUp, { passive: true, capture: true });
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function interceptControlUp(event) {
|
|
908
|
+
if (event.key === "Control") {
|
|
909
|
+
this._controlActive = false;
|
|
910
|
+
const document = this.domElement.getRootNode();
|
|
911
|
+
document.removeEventListener("keyup", this._interceptControlUp, { passive: true, capture: true });
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
exports.OrbitControls = OrbitControls;
|