Mini tablet button actions

This commit is contained in:
David Rowe 2018-08-21 09:17:53 +12:00
parent 6791d3f1b6
commit 4268297769
2 changed files with 61 additions and 17 deletions

View file

@ -19,11 +19,13 @@
READY_MESSAGE = "ready", // Engine <== Dialog READY_MESSAGE = "ready", // 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
muteButton, muteButton,
muteImage, muteImage,
bubbleButton, bubbleButton,
bubbleImage; bubbleImage,
expandButton;
// #region Communications ================================================================================================== // #region Communications ==================================================================================================
@ -49,6 +51,24 @@
} }
} }
function onMuteButtonClick() {
EventBridge.emitWebEvent(JSON.stringify({
type: MUTE_MESSAGE
}));
}
function onBubbleButtonClick() {
EventBridge.emitWebEvent(JSON.stringify({
type: BUBBLE_MESSAGE
}));
}
function onExpandButtonClick() {
EventBridge.emitWebEvent(JSON.stringify({
type: EXPAND_MESSAGE
}));
}
function connectEventBridge() { function connectEventBridge() {
EventBridge.scriptEventReceived.connect(onScriptEventReceived); EventBridge.scriptEventReceived.connect(onScriptEventReceived);
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
@ -73,9 +93,14 @@
muteImage = document.getElementById("mute-img"); muteImage = document.getElementById("mute-img");
bubbleButton = document.getElementById("bubble"); bubbleButton = document.getElementById("bubble");
bubbleImage = document.getElementById("bubble-img"); bubbleImage = document.getElementById("bubble-img");
expandButton = document.getElementById("expand");
connectEventBridge(); connectEventBridge();
muteButton.addEventListener("click", onMuteButtonClick, true);
bubbleButton.addEventListener("click", onBubbleButtonClick, true);
expandButton.addEventListener("click", onExpandButtonClick, true);
document.body.onunload = function () { document.body.onunload = function () {
onUnload(); onUnload();
}; };

View file

@ -68,13 +68,14 @@
STATE_MACHINE, STATE_MACHINE,
rezzerState = PROXY_DISABLED, rezzerState = PROXY_DISABLED,
proxyHand, proxyHand,
PROXY_GRAB_HANDLES = [ PROXY_EXPAND_HANDLES = [
{ x: 0.5, y: -0.4, z: 0 }, { x: 0.5, y: -0.4, z: 0 },
{ x: -0.5, y: -0.4, z: 0 } { x: -0.5, y: -0.4, z: 0 },
{ x: 0, y: -0.4, z: 0 }
], ],
proxyGrabHand, proxyExpandHand,
proxyGrabHandleLocalPosition, proxyExpandLocalPosition,
proxyGrabLocalRotation = Quat.IDENTITY, proxyExpandLocalRotation = Quat.IDENTITY,
PROXY_EXPAND_DURATION = 250, PROXY_EXPAND_DURATION = 250,
PROXY_EXPAND_TIMEOUT = 25, PROXY_EXPAND_TIMEOUT = 25,
proxyExpandTimer = null, proxyExpandTimer = null,
@ -87,6 +88,7 @@
READY_MESSAGE = "ready", // Engine <== Dialog READY_MESSAGE = "ready", // 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
// Events // Events
MIN_HAND_CAMERA_ANGLE = 30, MIN_HAND_CAMERA_ANGLE = 30,
@ -97,8 +99,10 @@
HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation", HIFI_OBJECT_MANIPULATION_CHANNEL = "Hifi-Object-Manipulation",
avatarScale = 1, avatarScale = 1,
LEFT_HAND = 0, LEFT_HAND = 0,
RIGHT_HAND = 1, RIGHT_HAND = 1,
NO_HAND = 2,
HAND_NAMES = ["LeftHand", "RightHand"], HAND_NAMES = ["LeftHand", "RightHand"],
DEBUG = false; DEBUG = false;
@ -183,6 +187,18 @@
updateMutedStatus(); updateMutedStatus();
updateBubbleStatus(); updateBubbleStatus();
break; break;
case MUTE_MESSAGE:
// Toggle mute.
Audio.muted = !Audio.muted;
break;
case BUBBLE_MESSAGE:
// Toggle bubble.
Users.toggleIgnoreRadius();
break;
case EXPAND_MESSAGE:
// Expand tablet;
setState(PROXY_EXPANDING, NO_HAND);
break;
} }
} }
@ -196,6 +212,7 @@
dimensions: Vec3.multiply(avatarScale, PROXY_DIMENSIONS), dimensions: Vec3.multiply(avatarScale, PROXY_DIMENSIONS),
solid: true, solid: true,
grabbable: true, grabbable: true,
showKeyboardFocusHighlight: false,
displayInFront: true, displayInFront: true,
visible: false visible: false
}); });
@ -208,6 +225,7 @@
dpi: PROXY_UI_DPI / avatarScale, dpi: PROXY_UI_DPI / avatarScale,
alpha: 0, // Hide overlay while its content is being created. alpha: 0, // Hide overlay while its content is being created.
grabbable: false, grabbable: false,
showKeyboardFocusHighlight: false,
displayInFront: true, displayInFront: true,
visible: false visible: false
}); });
@ -247,10 +265,10 @@
function sizeUI(scaleFactor) { function sizeUI(scaleFactor) {
Overlays.editOverlay(proxyOverlay, { Overlays.editOverlay(proxyOverlay, {
localPosition: localPosition:
Vec3.sum(proxyGrabHandleLocalPosition, Vec3.sum(proxyExpandLocalPosition,
Vec3.multiplyQbyV(proxyGrabLocalRotation, Vec3.multiplyQbyV(proxyExpandLocalRotation,
Vec3.multiply(-scaleFactor, Vec3.multiply(-scaleFactor,
Vec3.multiplyVbyV(PROXY_GRAB_HANDLES[proxyGrabHand], PROXY_DIMENSIONS))) Vec3.multiplyVbyV(PROXY_EXPAND_HANDLES[proxyExpandHand], PROXY_DIMENSIONS)))
), ),
dimensions: Vec3.multiply(scaleFactor, PROXY_DIMENSIONS) dimensions: Vec3.multiply(scaleFactor, PROXY_DIMENSIONS)
}); });
@ -383,13 +401,14 @@
setState(TABLET_OPEN); setState(TABLET_OPEN);
} }
function enterProxyExpanding() { function enterProxyExpanding(hand) {
// Grab details. // Grab details.
var properties = Overlays.getProperties(proxyOverlay, ["localPosition", "localRotation"]); var properties = Overlays.getProperties(proxyOverlay, ["localPosition", "localRotation"]);
proxyGrabLocalRotation = properties.localRotation; proxyExpandHand = hand;
proxyGrabHandleLocalPosition = Vec3.sum(properties.localPosition, proxyExpandLocalRotation = properties.localRotation;
Vec3.multiplyQbyV(proxyGrabLocalRotation, proxyExpandLocalPosition = Vec3.sum(properties.localPosition,
Vec3.multiplyVbyV(PROXY_GRAB_HANDLES[proxyGrabHand], PROXY_DIMENSIONS))); Vec3.multiplyQbyV(proxyExpandLocalRotation,
Vec3.multiplyVbyV(PROXY_EXPAND_HANDLES[proxyExpandHand], PROXY_DIMENSIONS)));
// Start expanding. // Start expanding.
proxyInitialWidth = PROXY_DIMENSIONS.x; proxyInitialWidth = PROXY_DIMENSIONS.x;
@ -488,7 +507,7 @@
} }
function onMessageReceived(channel, data, senderID, localOnly) { function onMessageReceived(channel, data, senderID, localOnly) {
var message; var message, hand;
if (channel !== HIFI_OBJECT_MANIPULATION_CHANNEL) { if (channel !== HIFI_OBJECT_MANIPULATION_CHANNEL) {
return; return;
@ -500,8 +519,8 @@
} }
if (message.action === "grab" && rezzerState === PROXY_VISIBLE) { if (message.action === "grab" && rezzerState === PROXY_VISIBLE) {
proxyGrabHand = message.joint === HAND_NAMES[proxyHand] ? proxyHand : otherHand(proxyHand); hand = message.joint === HAND_NAMES[proxyHand] ? proxyHand : otherHand(proxyHand);
setState(PROXY_EXPANDING); setState(PROXY_EXPANDING, hand);
} }
} }