js/OrbitControls.js

Thu, 06 Apr 2017 17:18:24 +0200

author
mdd
date
Thu, 06 Apr 2017 17:18:24 +0200
changeset 19
32de35694e56
parent 16
800e8da193a7
permissions
-rw-r--r--

finishing first release

16
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1 /**
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
2 * @author qiao / https://github.com/qiao
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
3 * @author mrdoob / http://mrdoob.com
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
4 * @author alteredq / http://alteredqualia.com/
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
5 * @author WestLangley / http://github.com/WestLangley
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
6 * @author erich666 / http://erichaines.com
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
7 */
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
8
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
9 // This set of controls performs orbiting, dollying (zooming), and panning.
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
10 // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
11 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
12 // Orbit - left mouse / touch: one finger move
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
13 // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
14 // Pan - right mouse, or arrow keys / touch: three finger swipe
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
15
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
16 THREE.OrbitControls = function ( object, domElement ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
17
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
18 this.object = object;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
19
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
20 this.domElement = ( domElement !== undefined ) ? domElement : document;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
21
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
22 // Set to false to disable this control
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
23 this.enabled = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
24
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
25 // "target" sets the location of focus, where the object orbits around
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
26 this.target = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
27
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
28 // How far you can dolly in and out ( PerspectiveCamera only )
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
29 this.minDistance = 0;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
30 this.maxDistance = Infinity;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
31
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
32 // How far you can zoom in and out ( OrthographicCamera only )
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
33 this.minZoom = 0;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
34 this.maxZoom = Infinity;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
35
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
36 // How far you can orbit vertically, upper and lower limits.
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
37 // Range is 0 to Math.PI radians.
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
38 this.minPolarAngle = 0; // radians
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
39 this.maxPolarAngle = Math.PI; // radians
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
40
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
41 // How far you can orbit horizontally, upper and lower limits.
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
42 // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
43 this.minAzimuthAngle = - Infinity; // radians
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
44 this.maxAzimuthAngle = Infinity; // radians
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
45
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
46 // Set to true to enable damping (inertia)
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
47 // If damping is enabled, you must call controls.update() in your animation loop
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
48 this.enableDamping = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
49 this.dampingFactor = 0.25;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
50
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
51 // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
52 // Set to false to disable zooming
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
53 this.enableZoom = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
54 this.zoomSpeed = 1.0;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
55
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
56 // Set to false to disable rotating
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
57 this.enableRotate = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
58 this.rotateSpeed = 1.0;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
59
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
60 // Set to false to disable panning
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
61 this.enablePan = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
62 this.keyPanSpeed = 7.0; // pixels moved per arrow key push
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
63
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
64 // Set to true to automatically rotate around the target
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
65 // If auto-rotate is enabled, you must call controls.update() in your animation loop
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
66 this.autoRotate = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
67 this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
68
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
69 // Set to false to disable use of the keys
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
70 this.enableKeys = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
71
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
72 // The four arrow keys
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
73 this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
74
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
75 // Mouse buttons
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
76 this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
77
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
78 // for reset
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
79 this.target0 = this.target.clone();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
80 this.position0 = this.object.position.clone();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
81 this.zoom0 = this.object.zoom;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
82
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
83 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
84 // public methods
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
85 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
86
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
87 this.getPolarAngle = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
88
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
89 return spherical.phi;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
90
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
91 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
92
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
93 this.getAzimuthalAngle = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
94
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
95 return spherical.theta;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
96
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
97 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
98
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
99 this.reset = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
100
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
101 scope.target.copy( scope.target0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
102 scope.object.position.copy( scope.position0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
103 scope.object.zoom = scope.zoom0;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
104
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
105 scope.object.updateProjectionMatrix();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
106 scope.dispatchEvent( changeEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
107
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
108 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
109
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
110 state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
111
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
112 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
113
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
114 // this method is exposed, but perhaps it would be better if we can make it private...
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
115 this.update = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
116
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
117 var offset = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
118
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
119 // so camera.up is the orbit axis
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
120 var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
121 var quatInverse = quat.clone().inverse();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
122
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
123 var lastPosition = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
124 var lastQuaternion = new THREE.Quaternion();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
125
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
126 return function update() {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
127
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
128 var position = scope.object.position;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
129
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
130 offset.copy( position ).sub( scope.target );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
131
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
132 // rotate offset to "y-axis-is-up" space
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
133 offset.applyQuaternion( quat );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
134
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
135 // angle from z-axis around y-axis
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
136 spherical.setFromVector3( offset );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
137
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
138 if ( scope.autoRotate && state === STATE.NONE ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
139
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
140 rotateLeft( getAutoRotationAngle() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
141
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
142 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
143
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
144 spherical.theta += sphericalDelta.theta;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
145 spherical.phi += sphericalDelta.phi;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
146
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
147 // restrict theta to be between desired limits
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
148 spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
149
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
150 // restrict phi to be between desired limits
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
151 spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
152
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
153 spherical.makeSafe();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
154
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
155
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
156 spherical.radius *= scale;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
157
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
158 // restrict radius to be between desired limits
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
159 spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
160
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
161 // move target to panned location
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
162 scope.target.add( panOffset );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
163
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
164 offset.setFromSpherical( spherical );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
165
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
166 // rotate offset back to "camera-up-vector-is-up" space
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
167 offset.applyQuaternion( quatInverse );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
168
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
169 position.copy( scope.target ).add( offset );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
170
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
171 scope.object.lookAt( scope.target );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
172
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
173 if ( scope.enableDamping === true ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
174
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
175 sphericalDelta.theta *= ( 1 - scope.dampingFactor );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
176 sphericalDelta.phi *= ( 1 - scope.dampingFactor );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
177
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
178 } else {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
179
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
180 sphericalDelta.set( 0, 0, 0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
181
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
182 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
183
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
184 scale = 1;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
185 panOffset.set( 0, 0, 0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
186
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
187 // update condition is:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
188 // min(camera displacement, camera rotation in radians)^2 > EPS
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
189 // using small-angle approximation cos(x/2) = 1 - x^2 / 8
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
190
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
191 if ( zoomChanged ||
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
192 lastPosition.distanceToSquared( scope.object.position ) > EPS ||
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
193 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
194
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
195 scope.dispatchEvent( changeEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
196
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
197 lastPosition.copy( scope.object.position );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
198 lastQuaternion.copy( scope.object.quaternion );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
199 zoomChanged = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
200
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
201 return true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
202
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
203 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
204
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
205 return false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
206
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
207 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
208
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
209 }();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
210
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
211 this.dispose = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
212
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
213 scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
214 scope.domElement.removeEventListener( 'mousedown', onMouseDown, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
215 scope.domElement.removeEventListener( 'wheel', onMouseWheel, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
216
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
217 scope.domElement.removeEventListener( 'touchstart', onTouchStart, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
218 scope.domElement.removeEventListener( 'touchend', onTouchEnd, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
219 scope.domElement.removeEventListener( 'touchmove', onTouchMove, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
220
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
221 document.removeEventListener( 'mousemove', onMouseMove, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
222 document.removeEventListener( 'mouseup', onMouseUp, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
223
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
224 window.removeEventListener( 'keydown', onKeyDown, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
225
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
226 //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
227
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
228 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
229
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
230 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
231 // internals
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
232 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
233
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
234 var scope = this;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
235
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
236 var changeEvent = { type: 'change' };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
237 var startEvent = { type: 'start' };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
238 var endEvent = { type: 'end' };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
239
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
240 var STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
241
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
242 var state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
243
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
244 var EPS = 0.000001;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
245
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
246 // current position in spherical coordinates
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
247 var spherical = new THREE.Spherical();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
248 var sphericalDelta = new THREE.Spherical();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
249
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
250 var scale = 1;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
251 var panOffset = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
252 var zoomChanged = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
253
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
254 var rotateStart = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
255 var rotateEnd = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
256 var rotateDelta = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
257
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
258 var panStart = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
259 var panEnd = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
260 var panDelta = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
261
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
262 var dollyStart = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
263 var dollyEnd = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
264 var dollyDelta = new THREE.Vector2();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
265
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
266 function getAutoRotationAngle() {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
267
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
268 return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
269
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
270 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
271
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
272 function getZoomScale() {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
273
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
274 return Math.pow( 0.95, scope.zoomSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
275
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
276 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
277
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
278 function rotateLeft( angle ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
279
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
280 sphericalDelta.theta -= angle;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
281
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
282 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
283
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
284 function rotateUp( angle ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
285
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
286 sphericalDelta.phi -= angle;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
287
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
288 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
289
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
290 var panLeft = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
291
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
292 var v = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
293
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
294 return function panLeft( distance, objectMatrix ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
295
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
296 v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
297 v.multiplyScalar( - distance );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
298
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
299 panOffset.add( v );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
300
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
301 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
302
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
303 }();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
304
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
305 var panUp = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
306
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
307 var v = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
308
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
309 return function panUp( distance, objectMatrix ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
310
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
311 v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
312 v.multiplyScalar( distance );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
313
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
314 panOffset.add( v );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
315
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
316 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
317
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
318 }();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
319
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
320 // deltaX and deltaY are in pixels; right and down are positive
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
321 var pan = function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
322
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
323 var offset = new THREE.Vector3();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
324
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
325 return function pan( deltaX, deltaY ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
326
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
327 var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
328
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
329 if ( scope.object instanceof THREE.PerspectiveCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
330
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
331 // perspective
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
332 var position = scope.object.position;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
333 offset.copy( position ).sub( scope.target );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
334 var targetDistance = offset.length();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
335
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
336 // half of the fov is center to top of screen
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
337 targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
338
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
339 // we actually don't use screenWidth, since perspective camera is fixed to screen height
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
340 panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
341 panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
342
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
343 } else if ( scope.object instanceof THREE.OrthographicCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
344
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
345 // orthographic
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
346 panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
347 panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
348
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
349 } else {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
350
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
351 // camera neither orthographic nor perspective
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
352 console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
353 scope.enablePan = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
354
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
355 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
356
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
357 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
358
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
359 }();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
360
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
361 function dollyIn( dollyScale ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
362
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
363 if ( scope.object instanceof THREE.PerspectiveCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
364
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
365 scale /= dollyScale;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
366
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
367 } else if ( scope.object instanceof THREE.OrthographicCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
368
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
369 scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
370 scope.object.updateProjectionMatrix();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
371 zoomChanged = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
372
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
373 } else {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
374
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
375 console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
376 scope.enableZoom = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
377
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
378 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
379
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
380 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
381
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
382 function dollyOut( dollyScale ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
383
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
384 if ( scope.object instanceof THREE.PerspectiveCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
385
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
386 scale *= dollyScale;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
387
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
388 } else if ( scope.object instanceof THREE.OrthographicCamera ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
389
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
390 scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
391 scope.object.updateProjectionMatrix();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
392 zoomChanged = true;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
393
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
394 } else {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
395
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
396 console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
397 scope.enableZoom = false;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
398
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
399 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
400
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
401 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
402
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
403 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
404 // event callbacks - update the object state
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
405 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
406
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
407 function handleMouseDownRotate( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
408
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
409 //console.log( 'handleMouseDownRotate' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
410
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
411 rotateStart.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
412
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
413 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
414
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
415 function handleMouseDownDolly( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
416
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
417 //console.log( 'handleMouseDownDolly' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
418
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
419 dollyStart.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
420
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
421 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
422
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
423 function handleMouseDownPan( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
424
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
425 //console.log( 'handleMouseDownPan' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
426
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
427 panStart.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
428
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
429 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
430
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
431 function handleMouseMoveRotate( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
432
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
433 //console.log( 'handleMouseMoveRotate' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
434
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
435 rotateEnd.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
436 rotateDelta.subVectors( rotateEnd, rotateStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
437
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
438 var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
439
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
440 // rotating across whole screen goes 360 degrees around
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
441 rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
442
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
443 // rotating up and down along whole screen attempts to go 360, but limited to 180
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
444 rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
445
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
446 rotateStart.copy( rotateEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
447
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
448 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
449
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
450 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
451
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
452 function handleMouseMoveDolly( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
453
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
454 //console.log( 'handleMouseMoveDolly' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
455
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
456 dollyEnd.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
457
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
458 dollyDelta.subVectors( dollyEnd, dollyStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
459
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
460 if ( dollyDelta.y > 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
461
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
462 dollyIn( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
463
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
464 } else if ( dollyDelta.y < 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
465
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
466 dollyOut( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
467
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
468 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
469
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
470 dollyStart.copy( dollyEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
471
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
472 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
473
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
474 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
475
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
476 function handleMouseMovePan( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
477
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
478 //console.log( 'handleMouseMovePan' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
479
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
480 panEnd.set( event.clientX, event.clientY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
481
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
482 panDelta.subVectors( panEnd, panStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
483
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
484 pan( panDelta.x, panDelta.y );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
485
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
486 panStart.copy( panEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
487
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
488 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
489
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
490 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
491
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
492 function handleMouseUp( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
493
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
494 // console.log( 'handleMouseUp' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
495
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
496 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
497
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
498 function handleMouseWheel( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
499
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
500 // console.log( 'handleMouseWheel' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
501
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
502 if ( event.deltaY < 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
503
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
504 dollyOut( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
505
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
506 } else if ( event.deltaY > 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
507
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
508 dollyIn( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
509
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
510 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
511
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
512 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
513
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
514 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
515
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
516 function handleKeyDown( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
517
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
518 //console.log( 'handleKeyDown' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
519
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
520 switch ( event.keyCode ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
521
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
522 case scope.keys.UP:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
523 pan( 0, scope.keyPanSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
524 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
525 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
526
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
527 case scope.keys.BOTTOM:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
528 pan( 0, - scope.keyPanSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
529 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
530 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
531
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
532 case scope.keys.LEFT:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
533 pan( scope.keyPanSpeed, 0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
534 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
535 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
536
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
537 case scope.keys.RIGHT:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
538 pan( - scope.keyPanSpeed, 0 );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
539 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
540 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
541
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
542 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
543
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
544 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
545
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
546 function handleTouchStartRotate( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
547
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
548 //console.log( 'handleTouchStartRotate' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
549
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
550 rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
551
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
552 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
553
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
554 function handleTouchStartDolly( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
555
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
556 //console.log( 'handleTouchStartDolly' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
557
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
558 var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
559 var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
560
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
561 var distance = Math.sqrt( dx * dx + dy * dy );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
562
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
563 dollyStart.set( 0, distance );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
564
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
565 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
566
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
567 function handleTouchStartPan( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
568
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
569 //console.log( 'handleTouchStartPan' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
570
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
571 panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
572
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
573 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
574
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
575 function handleTouchMoveRotate( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
576
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
577 //console.log( 'handleTouchMoveRotate' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
578
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
579 rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
580 rotateDelta.subVectors( rotateEnd, rotateStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
581
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
582 var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
583
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
584 // rotating across whole screen goes 360 degrees around
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
585 rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
586
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
587 // rotating up and down along whole screen attempts to go 360, but limited to 180
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
588 rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
589
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
590 rotateStart.copy( rotateEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
591
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
592 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
593
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
594 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
595
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
596 function handleTouchMoveDolly( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
597
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
598 //console.log( 'handleTouchMoveDolly' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
599
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
600 var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
601 var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
602
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
603 var distance = Math.sqrt( dx * dx + dy * dy );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
604
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
605 dollyEnd.set( 0, distance );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
606
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
607 dollyDelta.subVectors( dollyEnd, dollyStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
608
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
609 if ( dollyDelta.y > 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
610
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
611 dollyOut( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
612
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
613 } else if ( dollyDelta.y < 0 ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
614
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
615 dollyIn( getZoomScale() );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
616
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
617 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
618
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
619 dollyStart.copy( dollyEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
620
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
621 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
622
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
623 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
624
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
625 function handleTouchMovePan( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
626
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
627 //console.log( 'handleTouchMovePan' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
628
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
629 panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
630
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
631 panDelta.subVectors( panEnd, panStart );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
632
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
633 pan( panDelta.x, panDelta.y );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
634
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
635 panStart.copy( panEnd );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
636
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
637 scope.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
638
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
639 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
640
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
641 function handleTouchEnd( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
642
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
643 //console.log( 'handleTouchEnd' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
644
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
645 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
646
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
647 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
648 // event handlers - FSM: listen for events and reset state
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
649 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
650
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
651 function onMouseDown( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
652
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
653 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
654
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
655 event.preventDefault();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
656
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
657 if ( event.button === scope.mouseButtons.ORBIT ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
658
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
659 if ( scope.enableRotate === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
660
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
661 handleMouseDownRotate( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
662
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
663 state = STATE.ROTATE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
664
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
665 } else if ( event.button === scope.mouseButtons.ZOOM ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
666
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
667 if ( scope.enableZoom === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
668
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
669 handleMouseDownDolly( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
670
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
671 state = STATE.DOLLY;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
672
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
673 } else if ( event.button === scope.mouseButtons.PAN ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
674
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
675 if ( scope.enablePan === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
676
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
677 handleMouseDownPan( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
678
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
679 state = STATE.PAN;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
680
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
681 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
682
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
683 if ( state !== STATE.NONE ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
684
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
685 document.addEventListener( 'mousemove', onMouseMove, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
686 document.addEventListener( 'mouseup', onMouseUp, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
687
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
688 scope.dispatchEvent( startEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
689
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
690 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
691
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
692 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
693
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
694 function onMouseMove( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
695
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
696 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
697
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
698 event.preventDefault();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
699
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
700 if ( state === STATE.ROTATE ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
701
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
702 if ( scope.enableRotate === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
703
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
704 handleMouseMoveRotate( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
705
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
706 } else if ( state === STATE.DOLLY ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
707
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
708 if ( scope.enableZoom === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
709
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
710 handleMouseMoveDolly( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
711
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
712 } else if ( state === STATE.PAN ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
713
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
714 if ( scope.enablePan === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
715
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
716 handleMouseMovePan( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
717
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
718 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
719
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
720 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
721
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
722 function onMouseUp( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
723
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
724 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
725
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
726 handleMouseUp( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
727
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
728 document.removeEventListener( 'mousemove', onMouseMove, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
729 document.removeEventListener( 'mouseup', onMouseUp, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
730
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
731 scope.dispatchEvent( endEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
732
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
733 state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
734
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
735 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
736
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
737 function onMouseWheel( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
738
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
739 if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
740
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
741 event.preventDefault();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
742 event.stopPropagation();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
743
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
744 handleMouseWheel( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
745
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
746 scope.dispatchEvent( startEvent ); // not sure why these are here...
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
747 scope.dispatchEvent( endEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
748
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
749 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
750
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
751 function onKeyDown( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
752
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
753 if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
754
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
755 handleKeyDown( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
756
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
757 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
758
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
759 function onTouchStart( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
760
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
761 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
762
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
763 switch ( event.touches.length ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
764
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
765 case 1: // one-fingered touch: rotate
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
766
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
767 if ( scope.enableRotate === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
768
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
769 handleTouchStartRotate( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
770
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
771 state = STATE.TOUCH_ROTATE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
772
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
773 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
774
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
775 case 2: // two-fingered touch: dolly
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
776
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
777 if ( scope.enableZoom === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
778
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
779 handleTouchStartDolly( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
780
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
781 state = STATE.TOUCH_DOLLY;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
782
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
783 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
784
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
785 case 3: // three-fingered touch: pan
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
786
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
787 if ( scope.enablePan === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
788
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
789 handleTouchStartPan( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
790
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
791 state = STATE.TOUCH_PAN;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
792
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
793 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
794
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
795 default:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
796
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
797 state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
798
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
799 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
800
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
801 if ( state !== STATE.NONE ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
802
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
803 scope.dispatchEvent( startEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
804
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
805 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
806
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
807 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
808
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
809 function onTouchMove( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
810
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
811 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
812
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
813 event.preventDefault();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
814 event.stopPropagation();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
815
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
816 switch ( event.touches.length ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
817
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
818 case 1: // one-fingered touch: rotate
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
819
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
820 if ( scope.enableRotate === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
821 if ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?...
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
822
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
823 handleTouchMoveRotate( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
824
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
825 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
826
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
827 case 2: // two-fingered touch: dolly
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
828
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
829 if ( scope.enableZoom === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
830 if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?...
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
831
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
832 handleTouchMoveDolly( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
833
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
834 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
835
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
836 case 3: // three-fingered touch: pan
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
837
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
838 if ( scope.enablePan === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
839 if ( state !== STATE.TOUCH_PAN ) return; // is this needed?...
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
840
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
841 handleTouchMovePan( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
842
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
843 break;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
844
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
845 default:
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
846
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
847 state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
848
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
849 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
850
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
851 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
852
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
853 function onTouchEnd( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
854
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
855 if ( scope.enabled === false ) return;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
856
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
857 handleTouchEnd( event );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
858
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
859 scope.dispatchEvent( endEvent );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
860
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
861 state = STATE.NONE;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
862
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
863 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
864
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
865 function onContextMenu( event ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
866
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
867 event.preventDefault();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
868
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
869 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
870
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
871 //
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
872
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
873 scope.domElement.addEventListener( 'contextmenu', onContextMenu, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
874
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
875 scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
876 scope.domElement.addEventListener( 'wheel', onMouseWheel, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
877
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
878 scope.domElement.addEventListener( 'touchstart', onTouchStart, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
879 scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
880 scope.domElement.addEventListener( 'touchmove', onTouchMove, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
881
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
882 window.addEventListener( 'keydown', onKeyDown, false );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
883
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
884 // force an update at start
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
885
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
886 this.update();
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
887
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
888 };
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
889
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
890 THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
891 THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
892
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
893 Object.defineProperties( THREE.OrbitControls.prototype, {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
894
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
895 center: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
896
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
897 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
898
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
899 console.warn( 'THREE.OrbitControls: .center has been renamed to .target' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
900 return this.target;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
901
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
902 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
903
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
904 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
905
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
906 // backward compatibility
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
907
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
908 noZoom: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
909
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
910 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
911
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
912 console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
913 return ! this.enableZoom;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
914
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
915 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
916
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
917 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
918
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
919 console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
920 this.enableZoom = ! value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
921
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
922 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
923
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
924 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
925
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
926 noRotate: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
927
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
928 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
929
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
930 console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
931 return ! this.enableRotate;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
932
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
933 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
934
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
935 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
936
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
937 console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
938 this.enableRotate = ! value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
939
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
940 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
941
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
942 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
943
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
944 noPan: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
945
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
946 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
947
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
948 console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
949 return ! this.enablePan;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
950
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
951 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
952
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
953 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
954
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
955 console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
956 this.enablePan = ! value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
957
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
958 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
959
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
960 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
961
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
962 noKeys: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
963
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
964 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
965
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
966 console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
967 return ! this.enableKeys;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
968
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
969 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
970
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
971 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
972
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
973 console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
974 this.enableKeys = ! value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
975
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
976 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
977
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
978 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
979
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
980 staticMoving: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
981
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
982 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
983
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
984 console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
985 return ! this.enableDamping;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
986
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
987 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
988
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
989 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
990
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
991 console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
992 this.enableDamping = ! value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
993
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
994 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
995
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
996 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
997
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
998 dynamicDampingFactor: {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
999
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1000 get: function () {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1001
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1002 console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1003 return this.dampingFactor;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1004
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1005 },
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1006
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1007 set: function ( value ) {
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1008
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1009 console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1010 this.dampingFactor = value;
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1011
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1012 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1013
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1014 }
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1015
800e8da193a7 added dependencies to local repo
mdd
parents:
diff changeset
1016 } );

mercurial