mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 06:04:06 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into discovery
This commit is contained in:
commit
7428eb2635
6 changed files with 230 additions and 29 deletions
|
@ -11,7 +11,7 @@
|
|||
[
|
||||
{ "type": "deadZone", "min": 0.15 },
|
||||
"constrainToInteger",
|
||||
{ "type": "pulse", "interval": 0.5 },
|
||||
{ "type": "pulse", "interval": 0.25 },
|
||||
{ "type": "scale", "scale": 22.5 }
|
||||
]
|
||||
},
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
{ "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": [
|
||||
"from": "Vive.LT", "to": "Standard.LT",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 }
|
||||
]
|
||||
},
|
||||
|
@ -18,8 +18,8 @@
|
|||
{ "from": "Vive.RY", "when": "Vive.RSY", "filters": ["invert"], "to": "Standard.RY" },
|
||||
{ "from": "Vive.RX", "when": "Vive.RSX", "to": "Standard.RX" },
|
||||
{
|
||||
"from": "Vive.RT", "to": "Standard.RT",
|
||||
"filters": [
|
||||
"from": "Vive.RT", "to": "Standard.RT",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 }
|
||||
]
|
||||
},
|
||||
|
@ -37,4 +37,4 @@
|
|||
{ "from": "Vive.LeftHand", "to": "Standard.LeftHand" },
|
||||
{ "from": "Vive.RightHand", "to": "Standard.RightHand" }
|
||||
]
|
||||
}
|
||||
}
|
|
@ -15,7 +15,6 @@ Script.load("system/users.js");
|
|||
Script.load("system/mute.js");
|
||||
Script.load("system/goto.js");
|
||||
Script.load("system/hmd.js");
|
||||
Script.load("system/steam.js");
|
||||
Script.load("system/marketplace.js");
|
||||
Script.load("system/edit.js");
|
||||
Script.load("system/mod.js");
|
||||
|
@ -26,6 +25,8 @@ 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/toggleAdvancedMovementForHandControllers.js")
|
||||
Script.load("system/dialTone.js");
|
||||
Script.load("system/firstPersonHMD.js");
|
||||
Script.load("system/snapshot.js");
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@ var COLORS_TELEPORT_TOO_CLOSE = {
|
|||
blue: 73
|
||||
};
|
||||
|
||||
var TELEPORT_CANCEL_RANGE = 1.5;
|
||||
var TELEPORT_CANCEL_RANGE = 1;
|
||||
var USE_COOL_IN = true;
|
||||
var COOL_IN_DURATION = 500;
|
||||
|
||||
function ThumbPad(hand) {
|
||||
this.hand = hand;
|
||||
|
@ -70,6 +72,8 @@ function Trigger(hand) {
|
|||
};
|
||||
}
|
||||
|
||||
var coolInTimeout = null;
|
||||
|
||||
function Teleporter() {
|
||||
var _this = this;
|
||||
this.intersection = null;
|
||||
|
@ -81,6 +85,8 @@ function Teleporter() {
|
|||
this.smoothArrivalInterval = null;
|
||||
this.teleportHand = null;
|
||||
this.tooClose = false;
|
||||
this.inCoolIn = false;
|
||||
|
||||
|
||||
this.initialize = function() {
|
||||
this.createMappings();
|
||||
|
@ -99,6 +105,7 @@ function Teleporter() {
|
|||
};
|
||||
|
||||
this.enterTeleportMode = function(hand) {
|
||||
|
||||
if (inTeleportMode === true) {
|
||||
return;
|
||||
}
|
||||
|
@ -107,6 +114,14 @@ function Teleporter() {
|
|||
}
|
||||
|
||||
inTeleportMode = true;
|
||||
this.inCoolIn = true;
|
||||
if (coolInTimeout !== null) {
|
||||
Script.clearTimeout(coolInTimeout);
|
||||
|
||||
}
|
||||
coolInTimeout = Script.setTimeout(function() {
|
||||
_this.inCoolIn = false;
|
||||
}, COOL_IN_DURATION)
|
||||
|
||||
if (this.smoothArrivalInterval !== null) {
|
||||
Script.clearInterval(this.smoothArrivalInterval);
|
||||
|
@ -119,6 +134,9 @@ function Teleporter() {
|
|||
this.initialize();
|
||||
Script.update.connect(this.update);
|
||||
this.updateConnected = true;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
this.createTargetOverlay = function() {
|
||||
|
@ -189,20 +207,19 @@ function Teleporter() {
|
|||
if (this.updateConnected === true) {
|
||||
Script.update.disconnect(this.update);
|
||||
}
|
||||
|
||||
this.disableMappings();
|
||||
this.turnOffOverlayBeams();
|
||||
|
||||
|
||||
this.updateConnected = null;
|
||||
this.inCoolIn = false;
|
||||
inTeleportMode = false;
|
||||
|
||||
Script.setTimeout(function() {
|
||||
inTeleportMode = false;
|
||||
_this.enableGrab();
|
||||
}, 100);
|
||||
}, 200);
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.update = function() {
|
||||
if (isDisabled === 'both') {
|
||||
return;
|
||||
|
@ -214,7 +231,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 +247,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 +264,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,
|
||||
|
@ -260,15 +293,26 @@ function Teleporter() {
|
|||
this.createCancelOverlay();
|
||||
}
|
||||
} else {
|
||||
this.deleteCancelOverlay();
|
||||
|
||||
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(rightIntersection);
|
||||
if (this.inCoolIn === true) {
|
||||
this.deleteTargetOverlay();
|
||||
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
|
||||
if (this.cancelOverlay !== null) {
|
||||
this.updateCancelOverlay(rightIntersection);
|
||||
} else {
|
||||
this.createCancelOverlay();
|
||||
}
|
||||
} else {
|
||||
this.createTargetOverlay();
|
||||
this.deleteCancelOverlay();
|
||||
|
||||
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(rightIntersection);
|
||||
} else {
|
||||
this.createTargetOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -283,7 +327,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,
|
||||
|
@ -308,15 +356,26 @@ function Teleporter() {
|
|||
this.createCancelOverlay();
|
||||
}
|
||||
} else {
|
||||
this.deleteCancelOverlay();
|
||||
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(leftIntersection);
|
||||
if (this.inCoolIn === true) {
|
||||
this.deleteTargetOverlay();
|
||||
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_TOO_CLOSE);
|
||||
if (this.cancelOverlay !== null) {
|
||||
this.updateCancelOverlay(leftIntersection);
|
||||
} else {
|
||||
this.createCancelOverlay();
|
||||
}
|
||||
} else {
|
||||
this.createTargetOverlay();
|
||||
this.deleteCancelOverlay();
|
||||
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(leftIntersection);
|
||||
} else {
|
||||
this.createTargetOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
// Created by james b. pollack @imgntn on 8/18/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
//advanced movements settings are in individual controller json files
|
||||
//what we do is check the status of the 'advance movement' checkbox when you enter HMD mode
|
||||
//if 'advanced movement' is checked...we give you the defaults that are in the json.
|
||||
//if 'advanced movement' is not checked... we override the advanced controls with basic ones.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var mappingName, basicMapping, isChecked;
|
||||
|
||||
var TURN_RATE = 1000;
|
||||
var MENU_ITEM_NAME = "Advanced Movement For Hand Controllers";
|
||||
var SETTINGS_KEY = 'advancedMovementForHandControllersIsChecked';
|
||||
var previousSetting = Settings.getValue(SETTINGS_KEY);
|
||||
if (previousSetting === '' || previousSetting === false || previousSetting === 'false') {
|
||||
previousSetting = false;
|
||||
isChecked = false;
|
||||
}
|
||||
|
||||
if (previousSetting === true || previousSetting === 'true') {
|
||||
previousSetting = true;
|
||||
isChecked = true;
|
||||
}
|
||||
|
||||
function addAdvancedMovementItemToSettingsMenu() {
|
||||
Menu.addMenuItem({
|
||||
menuName: "Settings",
|
||||
menuItemName: MENU_ITEM_NAME,
|
||||
isCheckable: true,
|
||||
isChecked: previousSetting
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function rotate180() {
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.angleAxis(180, {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
}))
|
||||
MyAvatar.orientation = newOrientation
|
||||
}
|
||||
|
||||
var inFlipTurn = false;
|
||||
|
||||
function registerBasicMapping() {
|
||||
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
|
||||
basicMapping = Controller.newMapping(mappingName);
|
||||
basicMapping.from(Controller.Standard.LY).to(function(value) {
|
||||
var stick = Controller.getValue(Controller.Standard.LS);
|
||||
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
|
||||
rotate180();
|
||||
} else if (Controller.Hardware.Vive !== undefined) {
|
||||
if (value > 0.75 && inFlipTurn === false) {
|
||||
inFlipTurn = true;
|
||||
rotate180();
|
||||
Script.setTimeout(function() {
|
||||
inFlipTurn = false;
|
||||
}, TURN_RATE)
|
||||
}
|
||||
}
|
||||
return;
|
||||
});
|
||||
basicMapping.from(Controller.Standard.LX).to(Controller.Standard.RX);
|
||||
basicMapping.from(Controller.Standard.RY).to(function(value) {
|
||||
var stick = Controller.getValue(Controller.Standard.RS);
|
||||
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
|
||||
rotate180();
|
||||
} else if (Controller.Hardware.Vive !== undefined) {
|
||||
if (value > 0.75 && inFlipTurn === false) {
|
||||
inFlipTurn = true;
|
||||
rotate180();
|
||||
Script.setTimeout(function() {
|
||||
inFlipTurn = false;
|
||||
}, TURN_RATE)
|
||||
}
|
||||
}
|
||||
return;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function enableMappings() {
|
||||
Controller.enableMapping(mappingName);
|
||||
}
|
||||
|
||||
function disableMappings() {
|
||||
Controller.disableMapping(mappingName);
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
Menu.removeMenuItem("Settings", MENU_ITEM_NAME);
|
||||
disableMappings();
|
||||
}
|
||||
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
if (menuItem == MENU_ITEM_NAME) {
|
||||
isChecked = Menu.isOptionChecked(MENU_ITEM_NAME);
|
||||
if (isChecked === true) {
|
||||
Settings.setValue(SETTINGS_KEY, true);
|
||||
disableMappings();
|
||||
} else if (isChecked === false) {
|
||||
Settings.setValue(SETTINGS_KEY, false);
|
||||
enableMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addAdvancedMovementItemToSettingsMenu();
|
||||
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
||||
registerBasicMapping();
|
||||
|
||||
Script.setTimeout(function() {
|
||||
if (previousSetting === true) {
|
||||
disableMappings();
|
||||
} else {
|
||||
enableMappings();
|
||||
}
|
||||
}, 100)
|
||||
|
||||
|
||||
HMD.displayModeChanged.connect(function(isHMDMode) {
|
||||
if (isHMDMode) {
|
||||
if (Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) {
|
||||
if (isChecked === true) {
|
||||
disableMappings();
|
||||
} else if (isChecked === false) {
|
||||
enableMappings();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue