OrbitControls.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. /**
  2. * @author qiao / https://github.com/qiao
  3. * @author mrdoob / http://mrdoob.com
  4. * @author alteredq / http://alteredqualia.com/
  5. * @author WestLangley / http://github.com/WestLangley
  6. * @author erich666 / http://erichaines.com
  7. */
  8. // This set of controls performs orbiting, dollying (zooming), and panning. It maintains
  9. // the "up" direction as +Y, unlike the TrackballControls.
  10. //
  11. // Orbit - left mouse / touch: one finger move
  12. // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
  13. // Pan - right mouse, or arrow keys / touch: three finter swipe
  14. THREE.OrbitControls = function ( object, domElement ) {
  15. this.object = object;
  16. this.domElement = ( domElement !== undefined ) ? domElement : document;
  17. // API - new
  18. // Set to false to disable this control
  19. this.enabled = true;
  20. // "target" sets the location of focus, where the object orbits around
  21. // and where it pans with respect to.
  22. this.target = new THREE.Vector3();
  23. // center is old, deprecated; use "target" instead
  24. this.center = this.target;
  25. // How far you can dolly in and out ( PerspectiveCamera only )
  26. this.minDistance = 0;
  27. this.maxDistance = Infinity;
  28. // How far you can zoom in and out ( OrthographicCamera only )
  29. this.minZoom = 0;
  30. this.maxZoom = Infinity;
  31. // How far you can orbit vertically, upper and lower limits.
  32. // Range is 0 to Math.PI radians.
  33. this.minPolarAngle = 0; // radians
  34. this.maxPolarAngle = Math.PI; // radians
  35. // How far you can orbit horizontally, upper and lower limits.
  36. // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
  37. this.minAzimuthAngle = - Infinity; // radians
  38. this.maxAzimuthAngle = Infinity; // radians
  39. // Set to true to enable damping (inertia)
  40. // If damping is enabled, you must call controls.update() in your animation loop
  41. this.enableDamping = false;
  42. this.dampingFactor = 0.25;
  43. // This option actually enables dollying in and out; left as "zoom" for
  44. // backwards compatibility.
  45. // Set to false to disable zooming
  46. this.enableZoom = true;
  47. this.zoomSpeed = 1.0;
  48. // Set to false to disable rotating
  49. this.enableRotate = true;
  50. this.rotateSpeed = 1.0;
  51. // Set to false to disable panning
  52. this.enablePan = true;
  53. this.keyPanSpeed = 7.0; // pixels moved per arrow key push
  54. // Set to true to automatically rotate around the target
  55. // If auto-rotate is enabled, you must call controls.update() in your animation loop
  56. this.autoRotate = false;
  57. this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
  58. // Set to false to disable use of the keys
  59. this.enableKeys = true;
  60. // The four arrow keys
  61. this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
  62. // Mouse buttons
  63. this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
  64. // for reset
  65. this.target0 = this.target.clone();
  66. this.position0 = this.object.position.clone();
  67. this.zoom0 = this.object.zoom;
  68. // internals
  69. var scope = this;
  70. var EPS = 0.000001;
  71. // Current position in spherical coordinate system.
  72. var theta;
  73. var phi;
  74. // Pending changes
  75. var phiDelta = 0;
  76. var thetaDelta = 0;
  77. var scale = 1;
  78. var panOffset = new THREE.Vector3();
  79. var zoomChanged = false;
  80. var rotateStart = new THREE.Vector2();
  81. var rotateEnd = new THREE.Vector2();
  82. var rotateDelta = new THREE.Vector2();
  83. var panStart = new THREE.Vector2();
  84. var panEnd = new THREE.Vector2();
  85. var panDelta = new THREE.Vector2();
  86. var dollyStart = new THREE.Vector2();
  87. var dollyEnd = new THREE.Vector2();
  88. var dollyDelta = new THREE.Vector2();
  89. var changeEvent = { type: 'change' };
  90. var startEvent = { type: 'start' };
  91. var endEvent = { type: 'end' };
  92. var STATE = { NONE : - 1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
  93. var state = STATE.NONE;
  94. //
  95. this.rotateLeft = function ( angle ) {
  96. // if ( angle === undefined ) {
  97. // angle = getAutoRotationAngle();
  98. // }
  99. thetaDelta -= angle;
  100. };
  101. this.rotateUp = function ( angle ) {
  102. // if ( angle === undefined ) {
  103. // angle = getAutoRotationAngle();
  104. // }
  105. phiDelta -= angle;
  106. };
  107. // pass in distance in world space to move left
  108. this.panLeft = function() {
  109. var v = new THREE.Vector3();
  110. return function panLeft( distance ) {
  111. var te = this.object.matrix.elements;
  112. // get X column of matrix
  113. v.set( te[ 0 ], te[ 1 ], te[ 2 ] );
  114. v.multiplyScalar( - distance );
  115. panOffset.add( v );
  116. };
  117. }();
  118. // pass in distance in world space to move up
  119. this.panUp = function() {
  120. var v = new THREE.Vector3();
  121. return function panUp( distance ) {
  122. var te = this.object.matrix.elements;
  123. // get Y column of matrix
  124. v.set( te[ 4 ], te[ 5 ], te[ 6 ] );
  125. v.multiplyScalar( distance );
  126. panOffset.add( v );
  127. };
  128. }();
  129. // pass in x,y of change desired in pixel space,
  130. // right and down are positive
  131. this.pan = function ( deltaX, deltaY /*, screenWidth, screenHeight */ ) {
  132. var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
  133. if ( scope.object instanceof THREE.PerspectiveCamera ) {
  134. // perspective
  135. var position = scope.object.position;
  136. var offset = position.clone().sub( scope.target );
  137. var targetDistance = offset.length();
  138. // half of the fov is center to top of screen
  139. targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
  140. // we actually don't use screenWidth, since perspective camera is fixed to screen height
  141. scope.panLeft( 2 * deltaX * targetDistance / element.clientHeight );
  142. scope.panUp( 2 * deltaY * targetDistance / element.clientHeight );
  143. } else if ( scope.object instanceof THREE.OrthographicCamera ) {
  144. // orthographic
  145. scope.panLeft( deltaX * ( scope.object.right - scope.object.left ) / element.clientWidth );
  146. scope.panUp( deltaY * ( scope.object.top - scope.object.bottom ) / element.clientHeight );
  147. } else {
  148. // camera neither orthographic or perspective
  149. console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
  150. }
  151. };
  152. this.dollyIn = function ( dollyScale ) {
  153. if ( scope.object instanceof THREE.PerspectiveCamera ) {
  154. scale /= dollyScale;
  155. } else if ( scope.object instanceof THREE.OrthographicCamera ) {
  156. scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom * dollyScale ) );
  157. scope.object.updateProjectionMatrix();
  158. zoomChanged = true;
  159. } else {
  160. console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
  161. }
  162. };
  163. this.dollyOut = function ( dollyScale ) {
  164. if ( scope.object instanceof THREE.PerspectiveCamera ) {
  165. scale *= dollyScale;
  166. } else if ( scope.object instanceof THREE.OrthographicCamera ) {
  167. scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom / dollyScale ) );
  168. scope.object.updateProjectionMatrix();
  169. zoomChanged = true;
  170. } else {
  171. console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
  172. }
  173. };
  174. this.update = function() {
  175. var offset = new THREE.Vector3();
  176. // so camera.up is the orbit axis
  177. var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
  178. var quatInverse = quat.clone().inverse();
  179. var lastPosition = new THREE.Vector3();
  180. var lastQuaternion = new THREE.Quaternion();
  181. return function () {
  182. var position = this.object.position;
  183. offset.copy( position ).sub( this.target );
  184. // rotate offset to "y-axis-is-up" space
  185. offset.applyQuaternion( quat );
  186. // angle from z-axis around y-axis
  187. theta = Math.atan2( offset.x, offset.z );
  188. // angle from y-axis
  189. phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
  190. if ( this.autoRotate && state === STATE.NONE ) {
  191. this.rotateLeft( getAutoRotationAngle() );
  192. }
  193. theta += thetaDelta;
  194. phi += phiDelta;
  195. // restrict theta to be between desired limits
  196. theta = Math.max( this.minAzimuthAngle, Math.min( this.maxAzimuthAngle, theta ) );
  197. // restrict phi to be between desired limits
  198. phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
  199. // restrict phi to be betwee EPS and PI-EPS
  200. phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
  201. var radius = offset.length() * scale;
  202. // restrict radius to be between desired limits
  203. radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
  204. // move target to panned location
  205. this.target.add( panOffset );
  206. offset.x = radius * Math.sin( phi ) * Math.sin( theta );
  207. offset.y = radius * Math.cos( phi );
  208. offset.z = radius * Math.sin( phi ) * Math.cos( theta );
  209. // rotate offset back to "camera-up-vector-is-up" space
  210. offset.applyQuaternion( quatInverse );
  211. position.copy( this.target ).add( offset );
  212. this.object.lookAt( this.target );
  213. if ( this.enableDamping === true ) {
  214. thetaDelta *= ( 1 - this.dampingFactor );
  215. phiDelta *= ( 1 - this.dampingFactor );
  216. } else {
  217. thetaDelta = 0;
  218. phiDelta = 0;
  219. }
  220. scale = 1;
  221. panOffset.set( 0, 0, 0 );
  222. // update condition is:
  223. // min(camera displacement, camera rotation in radians)^2 > EPS
  224. // using small-angle approximation cos(x/2) = 1 - x^2 / 8
  225. if ( zoomChanged ||
  226. lastPosition.distanceToSquared( this.object.position ) > EPS ||
  227. 8 * ( 1 - lastQuaternion.dot( this.object.quaternion ) ) > EPS ) {
  228. this.dispatchEvent( changeEvent );
  229. lastPosition.copy( this.object.position );
  230. lastQuaternion.copy( this.object.quaternion );
  231. zoomChanged = false;
  232. return true;
  233. }
  234. return false;
  235. };
  236. }();
  237. this.reset = function () {
  238. state = STATE.NONE;
  239. this.target.copy( this.target0 );
  240. this.object.position.copy( this.position0 );
  241. this.object.zoom = this.zoom0;
  242. this.object.updateProjectionMatrix();
  243. this.dispatchEvent( changeEvent );
  244. this.update();
  245. };
  246. this.getPolarAngle = function () {
  247. return phi;
  248. };
  249. this.getAzimuthalAngle = function () {
  250. return theta
  251. };
  252. function getAutoRotationAngle() {
  253. return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
  254. }
  255. function getZoomScale() {
  256. return Math.pow( 0.95, scope.zoomSpeed );
  257. }
  258. function onMouseDown( event ) {
  259. if ( scope.enabled === false ) return;
  260. event.preventDefault();
  261. if ( event.button === scope.mouseButtons.ORBIT ) {
  262. if ( scope.enableRotate === false ) return;
  263. state = STATE.ROTATE;
  264. rotateStart.set( event.clientX, event.clientY );
  265. } else if ( event.button === scope.mouseButtons.ZOOM ) {
  266. if ( scope.enableZoom === false ) return;
  267. state = STATE.DOLLY;
  268. dollyStart.set( event.clientX, event.clientY );
  269. } else if ( event.button === scope.mouseButtons.PAN ) {
  270. if ( scope.enablePan === false ) return;
  271. state = STATE.PAN;
  272. panStart.set( event.clientX, event.clientY );
  273. }
  274. if ( state !== STATE.NONE ) {
  275. document.addEventListener( 'mousemove', onMouseMove, false );
  276. document.addEventListener( 'mouseup', onMouseUp, false );
  277. document.addEventListener( 'mouseout', onMouseUp, false );
  278. scope.dispatchEvent( startEvent );
  279. }
  280. }
  281. function onMouseMove( event ) {
  282. if ( scope.enabled === false ) return;
  283. event.preventDefault();
  284. var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
  285. if ( state === STATE.ROTATE ) {
  286. if ( scope.enableRotate === false ) return;
  287. rotateEnd.set( event.clientX, event.clientY );
  288. rotateDelta.subVectors( rotateEnd, rotateStart );
  289. // rotating across whole screen goes 360 degrees around
  290. scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
  291. // rotating up and down along whole screen attempts to go 360, but limited to 180
  292. scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
  293. rotateStart.copy( rotateEnd );
  294. } else if ( state === STATE.DOLLY ) {
  295. if ( scope.enableZoom === false ) return;
  296. dollyEnd.set( event.clientX, event.clientY );
  297. dollyDelta.subVectors( dollyEnd, dollyStart );
  298. if ( dollyDelta.y > 0 ) {
  299. scope.dollyIn( getZoomScale() );
  300. } else if ( dollyDelta.y < 0 ) {
  301. scope.dollyOut( getZoomScale() );
  302. }
  303. dollyStart.copy( dollyEnd );
  304. } else if ( state === STATE.PAN ) {
  305. if ( scope.enablePan === false ) return;
  306. panEnd.set( event.clientX, event.clientY );
  307. panDelta.subVectors( panEnd, panStart );
  308. scope.pan( panDelta.x, panDelta.y );
  309. panStart.copy( panEnd );
  310. }
  311. if ( state !== STATE.NONE ) scope.update();
  312. }
  313. function onMouseUp( /* event */ ) {
  314. if ( scope.enabled === false ) return;
  315. document.removeEventListener( 'mousemove', onMouseMove, false );
  316. document.removeEventListener( 'mouseup', onMouseUp, false );
  317. document.removeEventListener( 'mouseout', onMouseUp, false );
  318. scope.dispatchEvent( endEvent );
  319. state = STATE.NONE;
  320. }
  321. function onMouseWheel( event ) {
  322. if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return;
  323. event.preventDefault();
  324. event.stopPropagation();
  325. var delta = 0;
  326. if ( event.wheelDelta !== undefined ) {
  327. // WebKit / Opera / Explorer 9
  328. delta = event.wheelDelta;
  329. } else if ( event.detail !== undefined ) {
  330. // Firefox
  331. delta = - event.detail;
  332. }
  333. if ( delta > 0 ) {
  334. scope.dollyOut( getZoomScale() );
  335. } else if ( delta < 0 ) {
  336. scope.dollyIn( getZoomScale() );
  337. }
  338. scope.update();
  339. scope.dispatchEvent( startEvent );
  340. scope.dispatchEvent( endEvent );
  341. }
  342. function onKeyDown( event ) {
  343. if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;
  344. switch ( event.keyCode ) {
  345. case scope.keys.UP:
  346. scope.pan( 0, scope.keyPanSpeed );
  347. scope.update();
  348. break;
  349. case scope.keys.BOTTOM:
  350. scope.pan( 0, - scope.keyPanSpeed );
  351. scope.update();
  352. break;
  353. case scope.keys.LEFT:
  354. scope.pan( scope.keyPanSpeed, 0 );
  355. scope.update();
  356. break;
  357. case scope.keys.RIGHT:
  358. scope.pan( - scope.keyPanSpeed, 0 );
  359. scope.update();
  360. break;
  361. }
  362. }
  363. function touchstart( event ) {
  364. if ( scope.enabled === false ) return;
  365. switch ( event.touches.length ) {
  366. case 1: // one-fingered touch: rotate
  367. if ( scope.enableRotate === false ) return;
  368. state = STATE.TOUCH_ROTATE;
  369. rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
  370. break;
  371. case 2: // two-fingered touch: dolly
  372. if ( scope.enableZoom === false ) return;
  373. state = STATE.TOUCH_DOLLY;
  374. var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
  375. var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
  376. var distance = Math.sqrt( dx * dx + dy * dy );
  377. dollyStart.set( 0, distance );
  378. break;
  379. case 3: // three-fingered touch: pan
  380. if ( scope.enablePan === false ) return;
  381. state = STATE.TOUCH_PAN;
  382. panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
  383. break;
  384. default:
  385. state = STATE.NONE;
  386. }
  387. if ( state !== STATE.NONE ) scope.dispatchEvent( startEvent );
  388. }
  389. function touchmove( event ) {
  390. if ( scope.enabled === false ) return;
  391. event.preventDefault();
  392. event.stopPropagation();
  393. var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
  394. switch ( event.touches.length ) {
  395. case 1: // one-fingered touch: rotate
  396. if ( scope.enableRotate === false ) return;
  397. if ( state !== STATE.TOUCH_ROTATE ) return;
  398. rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
  399. rotateDelta.subVectors( rotateEnd, rotateStart );
  400. // rotating across whole screen goes 360 degrees around
  401. scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
  402. // rotating up and down along whole screen attempts to go 360, but limited to 180
  403. scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
  404. rotateStart.copy( rotateEnd );
  405. scope.update();
  406. break;
  407. case 2: // two-fingered touch: dolly
  408. if ( scope.enableZoom === false ) return;
  409. if ( state !== STATE.TOUCH_DOLLY ) return;
  410. var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
  411. var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
  412. var distance = Math.sqrt( dx * dx + dy * dy );
  413. dollyEnd.set( 0, distance );
  414. dollyDelta.subVectors( dollyEnd, dollyStart );
  415. if ( dollyDelta.y > 0 ) {
  416. scope.dollyOut( getZoomScale() );
  417. } else if ( dollyDelta.y < 0 ) {
  418. scope.dollyIn( getZoomScale() );
  419. }
  420. dollyStart.copy( dollyEnd );
  421. scope.update();
  422. break;
  423. case 3: // three-fingered touch: pan
  424. if ( scope.enablePan === false ) return;
  425. if ( state !== STATE.TOUCH_PAN ) return;
  426. panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
  427. panDelta.subVectors( panEnd, panStart );
  428. scope.pan( panDelta.x, panDelta.y );
  429. panStart.copy( panEnd );
  430. scope.update();
  431. break;
  432. default:
  433. state = STATE.NONE;
  434. }
  435. }
  436. function touchend( /* event */ ) {
  437. if ( scope.enabled === false ) return;
  438. scope.dispatchEvent( endEvent );
  439. state = STATE.NONE;
  440. }
  441. function contextmenu( event ) {
  442. event.preventDefault();
  443. }
  444. this.dispose = function() {
  445. this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
  446. this.domElement.removeEventListener( 'mousedown', onMouseDown, false );
  447. this.domElement.removeEventListener( 'mousewheel', onMouseWheel, false );
  448. this.domElement.removeEventListener( 'MozMousePixelScroll', onMouseWheel, false ); // firefox
  449. this.domElement.removeEventListener( 'touchstart', touchstart, false );
  450. this.domElement.removeEventListener( 'touchend', touchend, false );
  451. this.domElement.removeEventListener( 'touchmove', touchmove, false );
  452. document.removeEventListener( 'mousemove', onMouseMove, false );
  453. document.removeEventListener( 'mouseup', onMouseUp, false );
  454. document.removeEventListener( 'mouseout', onMouseUp, false );
  455. window.removeEventListener( 'keydown', onKeyDown, false );
  456. }
  457. this.domElement.addEventListener( 'contextmenu', contextmenu, false );
  458. this.domElement.addEventListener( 'mousedown', onMouseDown, false );
  459. this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
  460. this.domElement.addEventListener( 'MozMousePixelScroll', onMouseWheel, false ); // firefox
  461. this.domElement.addEventListener( 'touchstart', touchstart, false );
  462. this.domElement.addEventListener( 'touchend', touchend, false );
  463. this.domElement.addEventListener( 'touchmove', touchmove, false );
  464. window.addEventListener( 'keydown', onKeyDown, false );
  465. // force an update at start
  466. this.update();
  467. };
  468. THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
  469. THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
  470. Object.defineProperties( THREE.OrbitControls.prototype, {
  471. // backward compatibility
  472. noZoom: {
  473. get: function () {
  474. console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
  475. return ! this.enableZoom;
  476. },
  477. set: function ( value ) {
  478. console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
  479. this.enableZoom = ! value;
  480. }
  481. },
  482. noRotate: {
  483. get: function () {
  484. console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
  485. return ! this.enableRotate;
  486. },
  487. set: function ( value ) {
  488. console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
  489. this.enableRotate = ! value;
  490. }
  491. },
  492. noPan: {
  493. get: function () {
  494. console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
  495. return ! this.enablePan;
  496. },
  497. set: function ( value ) {
  498. console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
  499. this.enablePan = ! value;
  500. }
  501. },
  502. noKeys: {
  503. get: function () {
  504. console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
  505. return ! this.enableKeys;
  506. },
  507. set: function ( value ) {
  508. console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
  509. this.enableKeys = ! value;
  510. }
  511. },
  512. staticMoving : {
  513. get: function () {
  514. console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
  515. return ! this.constraint.enableDamping;
  516. },
  517. set: function ( value ) {
  518. console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
  519. this.constraint.enableDamping = ! value;
  520. }
  521. },
  522. dynamicDampingFactor : {
  523. get: function () {
  524. console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
  525. return this.constraint.dampingFactor;
  526. },
  527. set: function ( value ) {
  528. console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
  529. this.constraint.dampingFactor = value;
  530. }
  531. }
  532. } );