mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:29:56 +02:00
Clean up script, go away when putting HMD (not just on startup), and clear stopper properly.
This commit is contained in:
parent
aef8b7639d
commit
8f65ee87bc
1 changed files with 34 additions and 21 deletions
|
@ -32,6 +32,7 @@ function playAwayAnimation() {
|
||||||
}
|
}
|
||||||
if (stopper) {
|
if (stopper) {
|
||||||
Script.clearTimeout(stopper);
|
Script.clearTimeout(stopper);
|
||||||
|
stopper = false;
|
||||||
MyAvatar.removeAnimationStateHandler(activeAnimationHandlerId); // do it now, before making new assignment
|
MyAvatar.removeAnimationStateHandler(activeAnimationHandlerId); // do it now, before making new assignment
|
||||||
}
|
}
|
||||||
awayAnimationHandlerId = MyAvatar.addAnimationStateHandler(animateAway, null);
|
awayAnimationHandlerId = MyAvatar.addAnimationStateHandler(animateAway, null);
|
||||||
|
@ -79,8 +80,8 @@ hideOverlay();
|
||||||
|
|
||||||
// MAIN CONTROL
|
// MAIN CONTROL
|
||||||
var wasMuted, isAway;
|
var wasMuted, isAway;
|
||||||
function goAway(event) {
|
function goAway() {
|
||||||
if (isAway || event.isAutoRepeat) { // isAutoRepeat is true when held down (or when Windows feels like it)
|
if (isAway) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isAway = true;
|
isAway = true;
|
||||||
|
@ -93,24 +94,36 @@ function goAway(event) {
|
||||||
playAwayAnimation(); // animation is still seen by others
|
playAwayAnimation(); // animation is still seen by others
|
||||||
showOverlay();
|
showOverlay();
|
||||||
}
|
}
|
||||||
function switchActiveState(event) {
|
function goActive() {
|
||||||
if (!isAway || event.isAutoRepeat) {
|
if (!isAway) {
|
||||||
if (event.text === '.') {
|
return;
|
||||||
goAway(event);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isAway = false;
|
|
||||||
print('going "active"');
|
|
||||||
if (!wasMuted) {
|
|
||||||
AudioDevice.toggleMute();
|
|
||||||
}
|
|
||||||
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
|
||||||
stopAwayAnimation();
|
|
||||||
hideOverlay();
|
|
||||||
}
|
}
|
||||||
|
isAway = false;
|
||||||
|
print('going "active"');
|
||||||
|
if (!wasMuted) {
|
||||||
|
AudioDevice.toggleMute();
|
||||||
|
}
|
||||||
|
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
|
||||||
|
stopAwayAnimation();
|
||||||
|
hideOverlay();
|
||||||
}
|
}
|
||||||
Controller.keyPressEvent.connect(switchActiveState);
|
Script.scriptEnding.connect(goActive);
|
||||||
Script.scriptEnding.connect(switchActiveState);
|
Controller.keyPressEvent.connect(function (event) {
|
||||||
if (HMD.active) {
|
if (event.isAutoRepeat) { // isAutoRepeat is true when held down (or when Windows feels like it)
|
||||||
goAway({}); // give a dummy event object
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isAway && (event.text === '.')) {
|
||||||
|
goAway();
|
||||||
|
} else {
|
||||||
|
goActive();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var wasHmdActive = false;
|
||||||
|
Script.update.connect(function () {
|
||||||
|
if (HMD.active !== wasHmdActive) {
|
||||||
|
wasHmdActive = !wasHmdActive;
|
||||||
|
if (wasHmdActive) {
|
||||||
|
goAway();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue