mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Hide mini tablet immediately upon near grabbing an entity
This commit is contained in:
parent
b31af8c9c6
commit
c9919ff69d
1 changed files with 63 additions and 30 deletions
|
@ -23,12 +23,17 @@
|
||||||
miniState = null,
|
miniState = null,
|
||||||
|
|
||||||
// Hands.
|
// Hands.
|
||||||
|
NO_HAND = -1,
|
||||||
LEFT_HAND = 0,
|
LEFT_HAND = 0,
|
||||||
RIGHT_HAND = 1,
|
RIGHT_HAND = 1,
|
||||||
HAND_NAMES = ["LeftHand", "RightHand"],
|
HAND_NAMES = ["LeftHand", "RightHand"],
|
||||||
|
|
||||||
// Miscellaneous.
|
// Track controller grabbing state.
|
||||||
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
|
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
|
||||||
|
grabbingHand = NO_HAND,
|
||||||
|
grabbedItem = null,
|
||||||
|
|
||||||
|
// Miscellaneous.
|
||||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"),
|
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"),
|
||||||
DEBUG = false;
|
DEBUG = false;
|
||||||
|
|
||||||
|
@ -737,37 +742,11 @@
|
||||||
setState(MINI_VISIBLE);
|
setState(MINI_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterMiniShowing(hand) {
|
function checkMiniVisibility() {
|
||||||
miniHand = hand;
|
|
||||||
ui.show(miniHand);
|
|
||||||
miniScaleStart = Date.now();
|
|
||||||
miniScaleTimer = Script.setTimeout(scaleMiniUp, MINI_SCALE_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateMiniShowing() {
|
|
||||||
if (HMD.showTablet) {
|
|
||||||
setState(MINI_HIDDEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exitMiniShowing() {
|
|
||||||
if (miniScaleTimer) {
|
|
||||||
Script.clearTimeout(miniScaleTimer);
|
|
||||||
miniScaleTimer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateMiniVisible() {
|
|
||||||
var showLeft,
|
var showLeft,
|
||||||
showRight;
|
showRight;
|
||||||
|
|
||||||
// Hide mini tablet if tablet proper has been displayed by other means.
|
// Check that the mini tablet should still be visible and if so then ensure it's on the hand that the camera is
|
||||||
if (HMD.showTablet) {
|
|
||||||
setState(MINI_HIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that the mini tablet should still be visible and if so then ensure it's on the hand that the camera is
|
|
||||||
// gazing at.
|
// gazing at.
|
||||||
showLeft = shouldShowMini(LEFT_HAND);
|
showLeft = shouldShowMini(LEFT_HAND);
|
||||||
showRight = shouldShowMini(RIGHT_HAND);
|
showRight = shouldShowMini(RIGHT_HAND);
|
||||||
|
@ -790,8 +769,47 @@
|
||||||
setState(MINI_HIDING);
|
setState(MINI_HIDING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(MINI_HIDING);
|
if (grabbedItem === null || grabbingHand !== miniHand) {
|
||||||
|
setState(MINI_HIDING);
|
||||||
|
} else {
|
||||||
|
setState(MINI_HIDDEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function enterMiniShowing(hand) {
|
||||||
|
miniHand = hand;
|
||||||
|
ui.show(miniHand);
|
||||||
|
miniScaleStart = Date.now();
|
||||||
|
miniScaleTimer = Script.setTimeout(scaleMiniUp, MINI_SCALE_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateMiniShowing() {
|
||||||
|
// Hide mini tablet if tablet proper has been displayed by other means.
|
||||||
|
if (HMD.showTablet) {
|
||||||
|
setState(MINI_HIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide mini tablet if it should no longer be visible.
|
||||||
|
checkMiniVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
function exitMiniShowing() {
|
||||||
|
if (miniScaleTimer) {
|
||||||
|
Script.clearTimeout(miniScaleTimer);
|
||||||
|
miniScaleTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateMiniVisible() {
|
||||||
|
// Hide mini tablet if tablet proper has been displayed by other means.
|
||||||
|
if (HMD.showTablet) {
|
||||||
|
setState(MINI_HIDDEN);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide mini tablet if it should no longer be visible.
|
||||||
|
checkMiniVisibility();
|
||||||
|
|
||||||
// If state hasn't changed, update mini tablet rotation.
|
// If state hasn't changed, update mini tablet rotation.
|
||||||
if (miniState === MINI_VISIBLE) {
|
if (miniState === MINI_VISIBLE) {
|
||||||
|
@ -973,6 +991,21 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Track grabbed state and item.
|
||||||
|
switch (message.action) {
|
||||||
|
case "grab":
|
||||||
|
grabbingHand = HAND_NAMES.indexOf(message.joint);
|
||||||
|
grabbedItem = message.grabbedEntity;
|
||||||
|
break;
|
||||||
|
case "release":
|
||||||
|
grabbingHand = NO_HAND;
|
||||||
|
grabbedItem = null;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error("Unexpected grab message!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.grabbedEntity !== HMD.tabletID && message.grabbedEntity !== ui.getMiniTabletID()) {
|
if (message.grabbedEntity !== HMD.tabletID && message.grabbedEntity !== ui.getMiniTabletID()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue