demo changes

This commit is contained in:
James B. Pollack 2016-08-17 15:08:43 -07:00
parent f66b36ff07
commit 8bc6ca2fa1
4 changed files with 88 additions and 8 deletions

View file

@ -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": [

View file

@ -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");

View file

@ -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();

View file

@ -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,