CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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