mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-10 14:38:32 +02:00
Add button sounds
This commit is contained in:
parent
4268297769
commit
f4a8dc49e9
4 changed files with 35 additions and 0 deletions
BIN
scripts/system/assets/sounds/button-click.wav
Normal file
BIN
scripts/system/assets/sounds/button-click.wav
Normal file
Binary file not shown.
BIN
scripts/system/assets/sounds/button-hover.wav
Normal file
BIN
scripts/system/assets/sounds/button-hover.wav
Normal file
Binary file not shown.
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
var // EventBridge
|
var // EventBridge
|
||||||
READY_MESSAGE = "ready", // Engine <== Dialog
|
READY_MESSAGE = "ready", // Engine <== Dialog
|
||||||
|
HOVER_MESSAGE = "hover", // Engine <== Dialog
|
||||||
MUTE_MESSAGE = "mute", // Engine <=> Dialog
|
MUTE_MESSAGE = "mute", // Engine <=> Dialog
|
||||||
BUBBLE_MESSAGE = "bubble", // Engine <=> Dialog
|
BUBBLE_MESSAGE = "bubble", // Engine <=> Dialog
|
||||||
EXPAND_MESSAGE = "expand", // Engine <== Dialog
|
EXPAND_MESSAGE = "expand", // Engine <== Dialog
|
||||||
|
@ -57,6 +58,12 @@
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onButtonHover() {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: HOVER_MESSAGE
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
function onBubbleButtonClick() {
|
function onBubbleButtonClick() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: BUBBLE_MESSAGE
|
type: BUBBLE_MESSAGE
|
||||||
|
@ -97,6 +104,9 @@
|
||||||
|
|
||||||
connectEventBridge();
|
connectEventBridge();
|
||||||
|
|
||||||
|
muteButton.addEventListener("mouseenter", onButtonHover, false);
|
||||||
|
bubbleButton.addEventListener("mouseenter", onButtonHover, false);
|
||||||
|
expandButton.addEventListener("mouseenter", onButtonHover, false);
|
||||||
muteButton.addEventListener("click", onMuteButtonClick, true);
|
muteButton.addEventListener("click", onMuteButtonClick, true);
|
||||||
bubbleButton.addEventListener("click", onBubbleButtonClick, true);
|
bubbleButton.addEventListener("click", onBubbleButtonClick, true);
|
||||||
expandButton.addEventListener("click", onExpandButtonClick, true);
|
expandButton.addEventListener("click", onExpandButtonClick, true);
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
|
|
||||||
// EventBridge
|
// EventBridge
|
||||||
READY_MESSAGE = "ready", // Engine <== Dialog
|
READY_MESSAGE = "ready", // Engine <== Dialog
|
||||||
|
HOVER_MESSAGE = "hover", // Engine <== Dialog
|
||||||
MUTE_MESSAGE = "mute", // Engine <=> Dialog
|
MUTE_MESSAGE = "mute", // Engine <=> Dialog
|
||||||
BUBBLE_MESSAGE = "bubble", // Engine <=> Dialog
|
BUBBLE_MESSAGE = "bubble", // Engine <=> Dialog
|
||||||
EXPAND_MESSAGE = "expand", // Engine <== Dialog
|
EXPAND_MESSAGE = "expand", // Engine <== Dialog
|
||||||
|
@ -99,11 +100,20 @@
|
||||||
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
|
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
|
||||||
avatarScale = 1,
|
avatarScale = 1,
|
||||||
|
|
||||||
|
// Sounds
|
||||||
|
HOVER_SOUND = "./assets/sounds/button-hover.wav",
|
||||||
|
HOVER_VOLUME = 0.5,
|
||||||
|
CLICK_SOUND = "./assets/sounds/button-click.wav",
|
||||||
|
CLICK_VOLUME = 0.8,
|
||||||
|
hoverSound = SoundCache.getSound(Script.resolvePath(HOVER_SOUND)),
|
||||||
|
clickSound = SoundCache.getSound(Script.resolvePath(CLICK_SOUND)),
|
||||||
|
|
||||||
|
// Hands
|
||||||
LEFT_HAND = 0,
|
LEFT_HAND = 0,
|
||||||
RIGHT_HAND = 1,
|
RIGHT_HAND = 1,
|
||||||
NO_HAND = 2,
|
NO_HAND = 2,
|
||||||
HAND_NAMES = ["LeftHand", "RightHand"],
|
HAND_NAMES = ["LeftHand", "RightHand"],
|
||||||
|
|
||||||
DEBUG = false;
|
DEBUG = false;
|
||||||
|
|
||||||
// #region Utilities =======================================================================================================
|
// #region Utilities =======================================================================================================
|
||||||
|
@ -149,6 +159,14 @@
|
||||||
return hand === LEFT_HAND ? RIGHT_HAND : LEFT_HAND;
|
return hand === LEFT_HAND ? RIGHT_HAND : LEFT_HAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function playSound(sound, volume) {
|
||||||
|
Audio.playSound(sound, {
|
||||||
|
position: proxyHand === LEFT_HAND ? MyAvatar.getLeftPalmPosition() : MyAvatar.getRightPalmPosition(),
|
||||||
|
volume: volume,
|
||||||
|
localOnly: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Communications ==================================================================================================
|
// #region Communications ==================================================================================================
|
||||||
|
@ -187,16 +205,23 @@
|
||||||
updateMutedStatus();
|
updateMutedStatus();
|
||||||
updateBubbleStatus();
|
updateBubbleStatus();
|
||||||
break;
|
break;
|
||||||
|
case HOVER_MESSAGE:
|
||||||
|
// Audio feedback.
|
||||||
|
playSound(hoverSound, HOVER_VOLUME);
|
||||||
|
break;
|
||||||
case MUTE_MESSAGE:
|
case MUTE_MESSAGE:
|
||||||
// Toggle mute.
|
// Toggle mute.
|
||||||
|
playSound(clickSound, CLICK_VOLUME);
|
||||||
Audio.muted = !Audio.muted;
|
Audio.muted = !Audio.muted;
|
||||||
break;
|
break;
|
||||||
case BUBBLE_MESSAGE:
|
case BUBBLE_MESSAGE:
|
||||||
// Toggle bubble.
|
// Toggle bubble.
|
||||||
|
playSound(clickSound, CLICK_VOLUME);
|
||||||
Users.toggleIgnoreRadius();
|
Users.toggleIgnoreRadius();
|
||||||
break;
|
break;
|
||||||
case EXPAND_MESSAGE:
|
case EXPAND_MESSAGE:
|
||||||
// Expand tablet;
|
// Expand tablet;
|
||||||
|
playSound(clickSound, CLICK_VOLUME);
|
||||||
setState(PROXY_EXPANDING, NO_HAND);
|
setState(PROXY_EXPANDING, NO_HAND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue