diff --git a/src/components/cursor-controller.js b/src/components/cursor-controller.js index d861ed107fb4bb35ab64dcad2b77ac0666e8d8f0..29de011d6934259cba3b8603e4d9611a199a1b8e 100644 --- a/src/components/cursor-controller.js +++ b/src/components/cursor-controller.js @@ -46,6 +46,7 @@ AFRAME.registerComponent("cursor-controller", { this.moveCursor = this.moveCursor.bind(this); this.endInteraction = this.endInteraction.bind(this); this.handleMouseWheel = this.handleMouseWheel.bind(this); + this._handleEnterVR = this._handleEnterVR.bind(this); this._handleExitVR = this._handleExitVR.bind(this); this._handleModelLoaded = this._handleModelLoaded.bind(this); @@ -214,6 +215,7 @@ AFRAME.registerComponent("cursor-controller", { return true; }, + moveCursor: function(e) { this.mousePos.set(e.clientX / window.innerWidth * 2 - 1, -(e.clientY / window.innerHeight) * 2 + 1); }, diff --git a/src/components/look-on-mobile.js b/src/components/look-on-mobile.js index e8047c92f491c62cb582df32a9b550955557de3a..d2eaa942540a0be923d8273fca21859e5ee43381 100644 --- a/src/components/look-on-mobile.js +++ b/src/components/look-on-mobile.js @@ -75,6 +75,7 @@ AFRAME.registerComponent("look-on-mobile", { const dX = THREE.Math.RAD2DEG * difference(hmdEuler.x, this.prevX); const dY = THREE.Math.RAD2DEG * difference(hmdEuler.y, this.prevY); + this.dXBuffer.push(Math.abs(dX) < 0.001 ? 0 : dX); this.dYBuffer.push(Math.abs(dY) < 0.001 ? 0 : dY); diff --git a/src/hub.js b/src/hub.js index a4ad2642a3e2d5c815feb424cbfee1a1db26445e..aa5ee6157e3066f348653c2fa42f42d4ed171429 100644 --- a/src/hub.js +++ b/src/hub.js @@ -129,6 +129,7 @@ import MouseEventsHandler from "./utils/mouse-events-handler.js"; import GearVRMouseEventsHandler from "./utils/gearvr-mouse-events-handler.js"; import PrimaryActionHandler from "./utils/primary-action-handler.js"; + function qsTruthy(param) { const val = qs[param]; // if the param exists but is not set (e.g. "?foo&bar"), its value is null. diff --git a/src/utils/mouse-events-handler.js b/src/utils/mouse-events-handler.js index 4463d76fb2b08c7e818de2b8146ada13a1b98030..0c153e72df5242b2c5c1874019c959cad1824caa 100644 --- a/src/utils/mouse-events-handler.js +++ b/src/utils/mouse-events-handler.js @@ -1,3 +1,4 @@ + // TODO: Make look speed adjustable by the user const HORIZONTAL_LOOK_SPEED = 0.1; const VERTICAL_LOOK_SPEED = 0.06; @@ -17,6 +18,7 @@ export default class MouseEventsHandler { this.onMouseDown = this.onMouseDown.bind(this); this.onLeftButtonDown = this.onLeftButtonDown.bind(this); this.onRightButtonDown = this.onRightButtonDown.bind(this); + this.onMouseMove = this.onMouseMove.bind(this); this.onMouseUp = this.onMouseUp.bind(this); this.onMouseWheel = this.onMouseWheel.bind(this); @@ -43,6 +45,7 @@ export default class MouseEventsHandler { isReady() { return this.cursor && this.cameraController; + } addEventListeners() { diff --git a/src/utils/touch-events-handler.js b/src/utils/touch-events-handler.js index 8effcc59152317471520c197605a2160e61d1042..d0dee13a62fa972502446a38a19f8ca6f9241b8f 100644 --- a/src/utils/touch-events-handler.js +++ b/src/utils/touch-events-handler.js @@ -6,6 +6,7 @@ export default class TouchEventsHandler { constructor() { this.cursor = null; this.cameraController = null; + this.pinchEmitter = null; this.touches = []; this.touchReservedForCursor = null; @@ -17,6 +18,7 @@ export default class TouchEventsHandler { this.registerCursor = this.registerCursor.bind(this); this.registerCameraController = this.registerCameraController.bind(this); + this.isReady = this.isReady.bind(this); this.addEventListeners = this.addEventListeners.bind(this); this.handleTouchStart = this.handleTouchStart.bind(this); @@ -63,6 +65,7 @@ export default class TouchEventsHandler { handleTouchStart(e) { this.cursor.setCursorVisibility(false); + Array.prototype.forEach.call(e.changedTouches, this.singleTouchStart); } @@ -71,6 +74,7 @@ export default class TouchEventsHandler { return; } if (!this.touchReservedForCursor && this.cursor.startInteractionAndForceCursorUpdate(touch)) { + this.touchReservedForCursor = touch; } this.touches.push(touch);