From 19c6a672d9743d75174b8fabe3390b4b0682dd8f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 6 Jan 2017 22:42:09 +0000 Subject: [PATCH 1/8] re-did tablet position --- scripts/system/libraries/WebTablet.js | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index c894642f80..09fe668080 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -22,24 +22,12 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // * position - position in front of the user // * rotation - rotation of entity so it faces the user. function calcSpawnInfo(hand) { - var pitchBackRotation = Quat.angleAxis(20.0, X_AXIS); - if (HMD.active) { - var handController = getControllerWorldLocation(hand, false); - var front = Quat.getFront(handController.orientation); - var up = Quat.getUp(handController.orientation); - var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up)); - var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front)); - return { - position: finalOffset, - rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS) - }; - } else { - var front = Quat.getFront(MyAvatar.orientation); - return { - position: Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}), - rotation: Quat.multiply(MyAvatar.orientation, pitchBackRotation) - }; - } + var front = Quat.getFront(MyAvatar.orientation); + var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) + return { + position: finalPosition, + rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) + }; } // ctor From 31e57a0dcde9805633862804e033fe722e37d893 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 6 Jan 2017 23:34:04 +0000 Subject: [PATCH 2/8] update branch --- scripts/system/libraries/WebTablet.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 09fe668080..5d9e54ffe8 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -22,12 +22,24 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // * position - position in front of the user // * rotation - rotation of entity so it faces the user. function calcSpawnInfo(hand) { - var front = Quat.getFront(MyAvatar.orientation); - var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) - return { - position: finalPosition, - rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) - }; + if (HMD.active && hand) { + var handController = getControllerWorldLocation(hand, false); + var front = Quat.getFront(handController.orientation); + var up = Quat.getUp(handController.orientation); + var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up)); + var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front)); + return { + position: finalOffset, + rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS) + }; + } else { + var front = Quat.getFront(MyAvatar.orientation); + var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) + return { + position: finalPosition, + rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) + }; + } } // ctor From 32938861cd055709a9ff7c8ff62fd39ad1cb8a5b Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:03:04 +0000 Subject: [PATCH 3/8] indentation fix --- scripts/system/libraries/WebTablet.js | 40 ++++++++++++--------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 5d9e54ffe8..5bea6d9923 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -23,23 +23,23 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // * rotation - rotation of entity so it faces the user. function calcSpawnInfo(hand) { if (HMD.active && hand) { - var handController = getControllerWorldLocation(hand, false); - var front = Quat.getFront(handController.orientation); - var up = Quat.getUp(handController.orientation); - var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up)); - var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front)); - return { - position: finalOffset, - rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS) - }; - } else { - var front = Quat.getFront(MyAvatar.orientation); - var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) - return { - position: finalPosition, - rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) - }; - } + var handController = getControllerWorldLocation(hand, false); + var front = Quat.getFront(handController.orientation); + var up = Quat.getUp(handController.orientation); + var frontOffset = Vec3.sum(handController.position, Vec3.multiply(0.4, up)); + var finalOffset = Vec3.sum(frontOffset, Vec3.multiply(-0.3, front)); + return { + position: finalOffset, + rotation: Quat.lookAt(finalOffset, HMD.position, Y_AXIS) + }; + } else { + var front = Quat.getFront(MyAvatar.orientation); + var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) + return { + position: finalPosition, + rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) + }; + } } // ctor @@ -97,7 +97,6 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { this.homeButtonEntity = Entities.addEntity({ name: "homeButton", type: "Sphere", - collisionless: true, localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, @@ -172,8 +171,3 @@ WebTablet.unpickle = function (string) { tablet.__proto__ = WebTablet.prototype; return tablet; }; - -WebTablet.prototype.getPosition = function () { - return Overlays.getProperty(this.webOverlayID, "position"); -} - From cec2692c77e3874fac44d0889c578ea3d846cc9c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:06:42 +0000 Subject: [PATCH 4/8] fixed issues --- scripts/system/libraries/WebTablet.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 5bea6d9923..27ab0000e6 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -97,6 +97,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { this.homeButtonEntity = Entities.addEntity({ name: "homeButton", type: "Sphere", + collisionless: true, localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, @@ -171,3 +172,8 @@ WebTablet.unpickle = function (string) { tablet.__proto__ = WebTablet.prototype; return tablet; }; + +-WebTablet.prototype.getPosition = function () { + return Overlays.getProperty(this.webOverlayID, "position"); + } + \ No newline at end of file From 55e7b4679034a17ce5ca3a1102901bff6cb9fefe Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:07:38 +0000 Subject: [PATCH 5/8] fixed issues 2.0 --- scripts/system/libraries/WebTablet.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 27ab0000e6..5fe55523ee 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -173,7 +173,6 @@ WebTablet.unpickle = function (string) { return tablet; }; --WebTablet.prototype.getPosition = function () { +WebTablet.prototype.getPosition = function () { return Overlays.getProperty(this.webOverlayID, "position"); - } - \ No newline at end of file +} \ No newline at end of file From 4ef5c76a65037e6b2297f200d455aa774c286a64 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:08:53 +0000 Subject: [PATCH 6/8] fixed issues 3.0 --- scripts/system/libraries/WebTablet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 5fe55523ee..8fba2590cc 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -175,4 +175,4 @@ WebTablet.unpickle = function (string) { WebTablet.prototype.getPosition = function () { return Overlays.getProperty(this.webOverlayID, "position"); -} \ No newline at end of file +} From 07079ad78dfd04a5e8009288b23459af1f1c8019 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:22:55 +0000 Subject: [PATCH 7/8] fixed bug --- scripts/system/controllers/handControllerPointer.js | 2 ++ scripts/system/libraries/WebTablet.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 62c0f62212..426980d015 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -469,6 +469,7 @@ clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (cl clickMapping.from(Controller.Standard.Start).peek().to(function (clicked) { if (clicked) { activeHudPoint2dGamePad(); + Messages.sendLocalMessage("toggleHand", -1); } wantsMenu = clicked; @@ -480,6 +481,7 @@ clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(func // We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove // after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse. Script.setTimeout(function () { + Messages.sendLocalMessage("toggleHand", -1); Reticle.setPosition(Reticle.position); }, 0); }); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 8fba2590cc..85f207d984 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -22,7 +22,7 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // * position - position in front of the user // * rotation - rotation of entity so it faces the user. function calcSpawnInfo(hand) { - if (HMD.active && hand) { + if (HMD.active && hand > 0) { var handController = getControllerWorldLocation(hand, false); var front = Quat.getFront(handController.orientation); var up = Quat.getUp(handController.orientation); From 7205215baa7e3d22e618b4655d10e6fe9c2b3117 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Sat, 7 Jan 2017 00:38:39 +0000 Subject: [PATCH 8/8] coding standard fix --- .../system/controllers/handControllerPointer.js | 6 ++++-- scripts/system/libraries/WebTablet.js | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/system/controllers/handControllerPointer.js b/scripts/system/controllers/handControllerPointer.js index 426980d015..6a4c71f2ee 100644 --- a/scripts/system/controllers/handControllerPointer.js +++ b/scripts/system/controllers/handControllerPointer.js @@ -469,7 +469,8 @@ clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (cl clickMapping.from(Controller.Standard.Start).peek().to(function (clicked) { if (clicked) { activeHudPoint2dGamePad(); - Messages.sendLocalMessage("toggleHand", -1); + var noHands = -1; + Messages.sendLocalMessage("toggleHand", noHands); } wantsMenu = clicked; @@ -481,7 +482,8 @@ clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(func // We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove // after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse. Script.setTimeout(function () { - Messages.sendLocalMessage("toggleHand", -1); + var noHands = -1; + Messages.sendLocalMessage("toggleHand", noHands); Reticle.setPosition(Reticle.position); }, 0); }); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 85f207d984..22ddedf637 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -22,7 +22,8 @@ var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1- // * position - position in front of the user // * rotation - rotation of entity so it faces the user. function calcSpawnInfo(hand) { - if (HMD.active && hand > 0) { + var noHands = -1; + if (HMD.active && hand != noHands) { var handController = getControllerWorldLocation(hand, false); var front = Quat.getFront(handController.orientation); var up = Quat.getUp(handController.orientation); @@ -34,7 +35,7 @@ function calcSpawnInfo(hand) { }; } else { var front = Quat.getFront(MyAvatar.orientation); - var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}) + var finalPosition = Vec3.sum(Vec3.sum(MyAvatar.position, Vec3.multiply(0.6, front)), {x: 0, y: 0.6, z: 0}); return { position: finalPosition, rotation: Quat.lookAt(finalPosition, MyAvatar.getHeadPosition(), Y_AXIS) @@ -118,13 +119,13 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet.gotoHomeScreen(); } - } + }; this.state = "idle"; this.getRoot = function() { return Entities.getWebViewRoot(_this.webEntityID); - } + }; this.getLocation = function() { return Entities.getEntityProperties(_this.tabletEntityID, ["localPosition", "localRotation"]); @@ -157,12 +158,12 @@ WebTablet.prototype.pickle = function () { WebTablet.prototype.register = function() { Messages.subscribe("home"); Messages.messageReceived.connect(this.receive); -} +}; WebTablet.prototype.unregister = function() { Messages.unsubscribe("home"); Messages.messageReceived.disconnect(this.receive); -} +}; WebTablet.unpickle = function (string) { if (!string) { @@ -175,4 +176,4 @@ WebTablet.unpickle = function (string) { WebTablet.prototype.getPosition = function () { return Overlays.getProperty(this.webOverlayID, "position"); -} +};