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