Debian Codegraph @

index.js

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