From 8bc6ca2fa1db01238e1a4e8dc436bdfa9ed97703 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 17 Aug 2016 15:08:43 -0700 Subject: [PATCH] demo changes --- interface/resources/controllers/vive.json | 2 - scripts/defaultScripts.js | 1 + .../system/controllers/advancedMovement.js | 53 +++++++++++++++++++ scripts/system/controllers/teleport.js | 40 +++++++++++--- 4 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 scripts/system/controllers/advancedMovement.js diff --git a/interface/resources/controllers/vive.json b/interface/resources/controllers/vive.json index 79114b8141..27230b3b7e 100644 --- a/interface/resources/controllers/vive.json +++ b/interface/resources/controllers/vive.json @@ -1,8 +1,6 @@ { "name": "Vive to Standard", "channels": [ - { "from": "Vive.LY", "when": "Vive.LSY", "filters": ["invert"], "to": "Standard.LY" }, - { "from": "Vive.LX", "when": "Vive.LSX", "to": "Standard.LX" }, { "from": "Vive.LT", "to": "Standard.LT", "filters": [ diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index cf707c4d19..e39c424521 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -26,5 +26,6 @@ Script.load("system/controllers/handControllerPointer.js"); Script.load("system/controllers/squeezeHands.js"); Script.load("system/controllers/grab.js"); Script.load("system/controllers/teleport.js"); +Script.load("system/controllers/advancedMovement.js") Script.load("system/dialTone.js"); Script.load("system/firstPersonHMD.js"); diff --git a/scripts/system/controllers/advancedMovement.js b/scripts/system/controllers/advancedMovement.js new file mode 100644 index 0000000000..0968edc7f6 --- /dev/null +++ b/scripts/system/controllers/advancedMovement.js @@ -0,0 +1,53 @@ +var mappingName, advancedMapping; + +function addAdvancedMovementItemToSettingsMenu() { + Menu.addMenuItem({ + menuName: "Settings", + menuItemName: "Advanced Movement", + isCheckable: true, + isChecked: false + }); + +} + +function addTranslationToLeftStick() { + Controller.enableMapping(mappingName); +} + +function registerMappings() { + mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random(); + advancedMapping = Controller.newMapping(mappingName); + advancedMapping.from(Controller.Vive.LY).invert().to(Controller.Standard.LY); + advancedMapping.from(Controller.Vive.LX).to(Controller.Standard.LX); +} + +function removeTranslationFromLeftStick() { + Controller.disableMapping(mappingName); +} + +function scriptEnding() { + Menu.removeMenuItem("Settings", "Advanced Movement"); + removeTranslationFromLeftStick(); +} + +function menuItemEvent(menuItem) { + if (menuItem == "Advanced Movement") { + print(" checked=" + Menu.isOptionChecked("Advanced Movement")); + var isChecked = Menu.isOptionChecked("Advanced Movement"); + if (isChecked === true) { + addTranslationToLeftStick(); + } else if (isChecked === false) { + removeTranslationFromLeftStick(); + } + } + +} + +addAdvancedMovementItemToSettingsMenu(); + +// register our scriptEnding callback +Script.scriptEnding.connect(scriptEnding); + +Menu.menuItemEvent.connect(menuItemEvent); + +registerMappings(); \ No newline at end of file diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 5a1ae7e5ee..d1dd5b6348 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -38,6 +38,8 @@ var COLORS_TELEPORT_TOO_CLOSE = { }; var TELEPORT_CANCEL_RANGE = 1.5; +var USE_COOL_IN = true; +var COOL_IN_DURATION = 1750; function ThumbPad(hand) { this.hand = hand; @@ -81,6 +83,7 @@ function Teleporter() { this.smoothArrivalInterval = null; this.teleportHand = null; this.tooClose = false; + this.inCoolIn = false; this.initialize = function() { this.createMappings(); @@ -99,6 +102,7 @@ function Teleporter() { }; this.enterTeleportMode = function(hand) { + if (inTeleportMode === true) { return; } @@ -119,6 +123,10 @@ function Teleporter() { this.initialize(); Script.update.connect(this.update); this.updateConnected = true; + this.inCoolIn = true; + Script.setTimeout(function() { + _this.inCoolIn = false; + }, COOL_IN_DURATION) }; this.createTargetOverlay = function() { @@ -189,16 +197,16 @@ function Teleporter() { if (this.updateConnected === true) { Script.update.disconnect(this.update); } + this.disableMappings(); this.turnOffOverlayBeams(); - this.updateConnected = null; Script.setTimeout(function() { inTeleportMode = false; _this.enableGrab(); - }, 100); + }, 200); }; @@ -214,7 +222,13 @@ function Teleporter() { } teleporter.leftRay(); if ((leftPad.buttonValue === 0) && inTeleportMode === true) { - _this.teleport(); + if (_this.inCoolIn === true) { + _this.exitTeleportMode(); + _this.deleteTargetOverlay(); + _this.deleteCancelOverlay(); + } else { + _this.teleport(); + } return; } @@ -224,7 +238,13 @@ function Teleporter() { } teleporter.rightRay(); if ((rightPad.buttonValue === 0) && inTeleportMode === true) { - _this.teleport(); + if (_this.inCoolIn === true) { + _this.exitTeleportMode(); + _this.deleteTargetOverlay(); + _this.deleteCancelOverlay(); + } else { + _this.teleport(); + } return; } } @@ -235,7 +255,11 @@ function Teleporter() { var pose = Controller.getPoseValue(Controller.Standard.RightHand); var rightPosition = pose.valid ? Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position) : MyAvatar.getHeadPosition(); var rightRotation = pose.valid ? Quat.multiply(MyAvatar.orientation, pose.rotation) : - Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, {x: 1, y: 0, z: 0})); + Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, { + x: 1, + y: 0, + z: 0 + })); var rightPickRay = { origin: rightPosition, @@ -283,7 +307,11 @@ function Teleporter() { var pose = Controller.getPoseValue(Controller.Standard.LeftHand); var leftPosition = pose.valid ? Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation), MyAvatar.position) : MyAvatar.getHeadPosition(); var leftRotation = pose.valid ? Quat.multiply(MyAvatar.orientation, pose.rotation) : - Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, {x: 1, y: 0, z: 0})); + Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, { + x: 1, + y: 0, + z: 0 + })); var leftPickRay = { origin: leftPosition,