|
158 | 158 | this.object = this.el.object3D;
|
159 | 159 | this.target = this.sceneEl.querySelector(this.data.target).object3D.position;
|
160 | 160 |
|
161 |
| - console.log('enabled: ', this.data.enabled); |
| 161 | + // console.log('enabled: ', this.data.enabled); |
| 162 | + this.endFlag = false; |
| 163 | + this.startFlag = false; |
162 | 164 |
|
163 | 165 | // Find the look-controls component on this camera, or create if it doesn't exist.
|
164 | 166 | this.isRunning = false;
|
|
241 | 243 | * Generally modifies the entity based on the data.
|
242 | 244 | */
|
243 | 245 | update: function (oldData) {
|
244 |
| - console.log('component update'); |
| 246 | + // console.log('component update'); |
245 | 247 |
|
246 | 248 | if (this.data.rotateTo) {
|
247 | 249 | var rotateToVec3 = new THREE.Vector3(this.data.rotateTo.x, this.data.rotateTo.y, this.data.rotateTo.z);
|
|
313 | 315 | */
|
314 | 316 | pause: function () {
|
315 | 317 | // console.log("component pause");
|
316 |
| - this.isRunning = false; |
| 318 | + this.isRunning = false; |
317 | 319 | this.removeEventListeners();
|
318 | 320 | },
|
319 | 321 |
|
|
393 | 395 | * Remove event listeners
|
394 | 396 | */
|
395 | 397 | removeEventListeners: function () {
|
396 |
| - |
397 |
| - if(this.canvasEl){ |
398 |
| - this.canvasEl.removeEventListener('contextmenu', this.onContextMenu, false); |
399 |
| - this.canvasEl.removeEventListener('mousedown', this.onMouseDown, false); |
400 |
| - this.canvasEl.removeEventListener('mousewheel', this.onMouseWheel, false); |
401 |
| - this.canvasEl.removeEventListener('MozMousePixelScroll', this.onMouseWheel, false); // firefox |
402 |
| - |
403 |
| - this.canvasEl.removeEventListener('touchstart', this.onTouchStart, false); |
404 |
| - this.canvasEl.removeEventListener('touchend', this.onTouchEnd, false); |
405 |
| - this.canvasEl.removeEventListener('touchmove', this.onTouchMove, false); |
406 |
| - |
407 |
| - this.canvasEl.removeEventListener('mousemove', this.onMouseMove, false); |
408 |
| - this.canvasEl.removeEventListener('mouseup', this.onMouseUp, false); |
409 |
| - this.canvasEl.removeEventListener('mouseout', this.onMouseUp, false); |
| 398 | + if (this.canvasEl) { |
| 399 | + this.canvasEl.removeEventListener('contextmenu', this.onContextMenu, false); |
| 400 | + this.canvasEl.removeEventListener('mousedown', this.onMouseDown, false); |
| 401 | + this.canvasEl.removeEventListener('mousewheel', this.onMouseWheel, false); |
| 402 | + this.canvasEl.removeEventListener('MozMousePixelScroll', this.onMouseWheel, false); // firefox |
| 403 | + |
| 404 | + this.canvasEl.removeEventListener('touchstart', this.onTouchStart, false); |
| 405 | + this.canvasEl.removeEventListener('touchend', this.onTouchEnd, false); |
| 406 | + this.canvasEl.removeEventListener('touchmove', this.onTouchMove, false); |
| 407 | + |
| 408 | + this.canvasEl.removeEventListener('mousemove', this.onMouseMove, false); |
| 409 | + this.canvasEl.removeEventListener('mouseup', this.onMouseUp, false); |
| 410 | + this.canvasEl.removeEventListener('mouseout', this.onMouseUp, false); |
410 | 411 | }
|
411 | 412 |
|
412 | 413 | window.removeEventListener('keydown', this.onKeyDown, false);
|
|
499 | 500 |
|
500 | 501 | this.state = this.STATE.NONE;
|
501 | 502 |
|
502 |
| - this.el.emit('end-drag-orbit-controls', null, false); |
| 503 | + this.startFlag = true; |
503 | 504 | },
|
504 | 505 |
|
505 | 506 | /*
|
|
940 | 941 | var thetaDiff = desiredSpherical.theta - this.spherical.theta;
|
941 | 942 | this.sphericalDelta.set(this.spherical.radius, phiDiff * this.data.rotateToSpeed, thetaDiff * this.data.rotateToSpeed);
|
942 | 943 | }
|
943 |
| - |
| 944 | + // console.log("updating"); |
944 | 945 | var offset = new THREE.Vector3();
|
945 | 946 |
|
946 | 947 | var quat = new THREE.Quaternion().setFromUnitVectors(this.dolly.up, new THREE.Vector3(0, 1, 0)); // so camera.up is the orbit axis
|
|
974 | 975 | if (this.data.enableDamping === true) {
|
975 | 976 | this.sphericalDelta.theta *= (1 - this.data.dampingFactor);
|
976 | 977 | this.sphericalDelta.phi *= (1 - this.data.dampingFactor);
|
| 978 | + // console.log(this.sphericalDelta); |
977 | 979 | } else {
|
978 | 980 | this.sphericalDelta.set(0, 0, 0);
|
979 | 981 | }
|
|
985 | 987 | // min(camera displacement, camera rotation in radians)^2 > EPS
|
986 | 988 | // using small-angle approximation cos(x/2) = 1 - x^2 / 8
|
987 | 989 |
|
| 990 | + this.endFlag = true; |
| 991 | + |
988 | 992 | if (forceUpdate === true ||
|
989 | 993 | this.zoomChanged ||
|
990 | 994 | this.lastPosition.distanceToSquared(this.dolly.position) > this.EPS ||
|
991 | 995 | 8 * (1 - this.lastQuaternion.dot(this.dolly.quaternion)) > this.EPS) {
|
992 | 996 | // this.el.emit('change-drag-orbit-controls', null, false);
|
993 |
| - |
| 997 | + // console.log("updating"); |
994 | 998 | var hmdQuaternion = this.calculateHMDQuaternion();
|
995 | 999 | var hmdEuler = new THREE.Euler();
|
996 | 1000 | hmdEuler.setFromQuaternion(hmdQuaternion, 'YXZ');
|
|
1007 | 1011 | z: radToDeg(hmdEuler.z)
|
1008 | 1012 | });
|
1009 | 1013 |
|
| 1014 | + this.endFlag = false; |
| 1015 | + |
1010 | 1016 | this.lastPosition.copy(this.dolly.position);
|
1011 | 1017 | this.lastQuaternion.copy(this.dolly.quaternion);
|
1012 | 1018 |
|
|
1015 | 1021 | return true;
|
1016 | 1022 | }
|
1017 | 1023 |
|
| 1024 | + if (this.startFlag && this.endFlag) { |
| 1025 | + this.startFlag = false; |
| 1026 | + this.el.emit('end-drag-orbit-controls', null, false); |
| 1027 | + } |
| 1028 | + |
1018 | 1029 | return false;
|
1019 | 1030 | },
|
1020 | 1031 |
|
|
0 commit comments