From a06c9eccca0d4dd1ea32e299fe515510e0137c60 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Fri, 1 Jun 2018 00:16:42 +0200 Subject: [PATCH 1/2] - fix create-app camera orbit to not jump around on secondary monitor - style fixes entityCameraTool.js --- scripts/system/libraries/entityCameraTool.js | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/system/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js index 0e52353dfb..579df8ed7d 100644 --- a/scripts/system/libraries/entityCameraTool.js +++ b/scripts/system/libraries/entityCameraTool.js @@ -91,7 +91,7 @@ CameraManager = function() { } var CAPTURED_KEYS = []; - for (key in keyToActionMapping) { + for (var key in keyToActionMapping) { CAPTURED_KEYS.push(key); } @@ -99,9 +99,9 @@ CameraManager = function() { var action = keyToActionMapping[event.text]; if (action !== undefined) { if (event.isShifted) { - if (action == "orbitForward") { + if (action === "orbitForward") { action = "orbitUp"; - } else if (action == "orbitBackward") { + } else if (action === "orbitBackward") { action = "orbitDown"; } } @@ -133,7 +133,7 @@ CameraManager = function() { }; that.enable = function() { - if (Camera.mode == "independent" || that.enabled || HMD.active) { + if (Camera.mode === "independent" || that.enabled || HMD.active) { return; } @@ -235,7 +235,7 @@ CameraManager = function() { } that.setFocalPoint = function(pos) { - that.targetFocalPoint = pos + that.targetFocalPoint = pos; that.updateCamera(); } @@ -276,7 +276,7 @@ CameraManager = function() { } that.mouseMoveEvent = function(event) { - if (that.enabled && that.mode != MODE_INACTIVE) { + if (that.enabled && that.mode !== MODE_INACTIVE) { var x = Reticle.getPosition().x; var y = Reticle.getPosition().y; if (!hasDragged) { @@ -284,11 +284,11 @@ CameraManager = function() { that.lastMousePosition.y = y; hasDragged = true; } - if (that.mode == MODE_ORBIT) { + if (that.mode === MODE_ORBIT) { var diffX = x - that.lastMousePosition.x; var diffY = y - that.lastMousePosition.y; - that.targetYaw -= MOUSE_SENSITIVITY * (diffX / 5.0) - that.targetPitch += MOUSE_SENSITIVITY * (diffY / 10.0) + that.targetYaw -= MOUSE_SENSITIVITY * (diffX / 5.0); + that.targetPitch += MOUSE_SENSITIVITY * (diffY / 10.0); while (that.targetYaw > 180.0) that.targetYaw -= 360; while (that.targetYaw < -180.0) that.targetYaw += 360; @@ -297,7 +297,7 @@ CameraManager = function() { if (that.targetPitch < -90) that.targetPitch = -90; that.updateCamera(); - } else if (that.mode == MODE_PAN) { + } else if (that.mode === MODE_PAN) { var diffX = x - that.lastMousePosition.x; var diffY = y - that.lastMousePosition.y; @@ -316,19 +316,19 @@ CameraManager = function() { var newY = y; var updatePosition = false; - if (x <= Window.x) { - newX = Window.x + Window.innerWidth; + if (x < 0) { + newX = Window.innerWidth; updatePosition = true; - } else if (x >= (Window.x + Window.innerWidth)) { - newX = Window.x; + } else if (x > Window.innerWidth) { + newX = 0; updatePosition = true; } - if (y <= Window.y) { - newY = Window.y + Window.innerHeight; + if (y < 0) { + newY = Window.innerHeight; updatePosition = true; - } else if (y >= (Window.y + Window.innerHeight)) { - newY = Window.y; + } else if (y > Window.innerHeight) { + newY = 0; updatePosition = true; } @@ -410,7 +410,7 @@ CameraManager = function() { } that.updateCamera = function() { - if (!that.enabled || Camera.mode != "independent") { + if (!that.enabled || Camera.mode !== "independent") { cameraTool.update(); return; } @@ -464,7 +464,7 @@ CameraManager = function() { // Ease the position and orbit of the camera that.update = function(dt) { - if (Camera.mode != "independent") { + if (Camera.mode !== "independent") { that.updateCamera(); return; } From 3779a4780e7ce59cda61eb4b36eabc714e571aed Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Fri, 1 Jun 2018 02:07:02 +0200 Subject: [PATCH 2/2] Prevent the cursor from being stuck on the most outer edges of the screen --- scripts/system/libraries/entityCameraTool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js index 579df8ed7d..fb808cc7ea 100644 --- a/scripts/system/libraries/entityCameraTool.js +++ b/scripts/system/libraries/entityCameraTool.js @@ -316,18 +316,18 @@ CameraManager = function() { var newY = y; var updatePosition = false; - if (x < 0) { + if (x <= 0) { newX = Window.innerWidth; updatePosition = true; - } else if (x > Window.innerWidth) { + } else if (x >= Window.innerWidth) { newX = 0; updatePosition = true; } - if (y < 0) { + if (y <= 0) { newY = Window.innerHeight; updatePosition = true; - } else if (y > Window.innerHeight) { + } else if (y >= Window.innerHeight) { newY = 0; updatePosition = true; }