index.js 25 KB

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