From 4a49631007af4a471acf179d9a7a4bca19ea6afa Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Fri, 16 Sep 2022 22:29:02 -0400 Subject: [PATCH] Added HMD notifications dismissal Added a gestural way to dismiss the notifications in HMD. The notifications vanishes after 10 sec. But if for any reason we want to accelerate the process (mostly because it hide the view or it is going to appears in photo capture) In Desktop we can simply click on the notification to get rid of them. But in HMD, clicking was kinda a pain (assuming the if you want to dismiss the notification is often because they are already annoying you) have to aim and click is like pressing a button using a fishing pole, it's certainly adding more annoyance to this. To addressed that, I introduced the "Whoosh!": An easy gesture to dismiss any 3d UI, by simply move one of you controller over you eyes height. (a bit like making flee an annoying fly.) --- scripts/system/notifications.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index 914aa4e006..32f8c913ff 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -12,6 +12,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html (function () { + Script.include([ + "create/audioFeedback/audioFeedback.js" + ]); + var NOTIFICATIONS_MESSAGE_CHANNEL = "Hifi-Notifications"; var SETTING_ACTIVATION_SNAPSHOT_NOTIFICATIONS = "snapshotNotifications"; var NOTIFICATION_LIFE_DURATION = 10000; //10 seconds (in millisecond) before expiration. @@ -54,7 +58,7 @@ function mousePressEvent(event) { if (!isOnHMD) { var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y }); - for (i = 0; i < notifications.length; i += 1) { + for (var i = 0; i < notifications.length; i += 1) { if (clickedOverlay === notifications[i].overlayID || clickedOverlay === notifications[i].imageOverlayID) { deleteSpecificNotification(i); notifications.splice(i, 1); @@ -64,6 +68,19 @@ } } + function checkHands() { + var myLeftHand = Controller.getPoseValue(Controller.Standard.LeftHand); + var myRightHand = Controller.getPoseValue(Controller.Standard.RightHand); + var eyesPosition = MyAvatar.getEyePosition(); + var hipsPosition = MyAvatar.getJointPosition("Hips"); + var eyesRelativeHeight = eyesPosition.y - hipsPosition.y; + if (myLeftHand.translation.y > eyesRelativeHeight || myRightHand.translation.y > eyesRelativeHeight) { + deleteAllExistingNotificationsDisplayed(); + notifications = []; + audioFeedback.action(); + } + } + //DISPLAY function renderNotifications(remainingTime) { var alpha = NOTIFICATION_ALPHA; @@ -310,6 +327,9 @@ newEventDetected = false; } } + if (isOnHMD) { + checkHands(); + } } //NOTIFICATION EVENTS FUNCTIONS