Click an emotion to Emote:
-
+
Choose an emote:
+
-
-
-+
+
+-
-
++
++
diff --git a/scripts/system/assets/animations/Cheering.fbx b/scripts/system/assets/animations/Cheer.fbx similarity index 100% rename from scripts/system/assets/animations/Cheering.fbx rename to scripts/system/assets/animations/Cheer.fbx diff --git a/scripts/system/assets/animations/Clapping.fbx b/scripts/system/assets/animations/Clap.fbx similarity index 100% rename from scripts/system/assets/animations/Clapping.fbx rename to scripts/system/assets/animations/Clap.fbx diff --git a/scripts/system/assets/animations/Crying.fbx b/scripts/system/assets/animations/Cry.fbx similarity index 67% rename from scripts/system/assets/animations/Crying.fbx rename to scripts/system/assets/animations/Cry.fbx index 2e60ba2450..7ecd6415a5 100644 Binary files a/scripts/system/assets/animations/Crying.fbx and b/scripts/system/assets/animations/Cry.fbx differ diff --git a/scripts/system/assets/animations/Dancing.fbx b/scripts/system/assets/animations/Dance.fbx similarity index 100% rename from scripts/system/assets/animations/Dancing.fbx rename to scripts/system/assets/animations/Dance.fbx diff --git a/scripts/system/assets/animations/Love.fbx b/scripts/system/assets/animations/Love.fbx new file mode 100644 index 0000000000..159ccafd04 Binary files /dev/null and b/scripts/system/assets/animations/Love.fbx differ diff --git a/scripts/system/assets/animations/Pointing.fbx b/scripts/system/assets/animations/Point.fbx similarity index 100% rename from scripts/system/assets/animations/Pointing.fbx rename to scripts/system/assets/animations/Point.fbx diff --git a/scripts/system/assets/animations/Sit1.fbx b/scripts/system/assets/animations/Sit1.fbx new file mode 100644 index 0000000000..db75219980 Binary files /dev/null and b/scripts/system/assets/animations/Sit1.fbx differ diff --git a/scripts/system/assets/animations/Sit2.fbx b/scripts/system/assets/animations/Sit2.fbx new file mode 100644 index 0000000000..400b599794 Binary files /dev/null and b/scripts/system/assets/animations/Sit2.fbx differ diff --git a/scripts/system/assets/animations/Sit3.fbx b/scripts/system/assets/animations/Sit3.fbx new file mode 100644 index 0000000000..174fd75c4e Binary files /dev/null and b/scripts/system/assets/animations/Sit3.fbx differ diff --git a/scripts/system/assets/animations/Waving.fbx b/scripts/system/assets/animations/Wave.fbx similarity index 100% rename from scripts/system/assets/animations/Waving.fbx rename to scripts/system/assets/animations/Wave.fbx diff --git a/scripts/system/emote.js b/scripts/system/emote.js index 139870fd63..87fc86d569 100644 --- a/scripts/system/emote.js +++ b/scripts/system/emote.js @@ -16,9 +16,11 @@ (function() { // BEGIN LOCAL_SCOPE -var EMOTE_ANIMATIONS = ['Crying', 'Surprised', 'Dancing', 'Cheering', 'Waving', 'Fall', 'Pointing', 'Clapping']; +var EMOTE_ANIMATIONS = ['Cry', 'Surprised', 'Dance', 'Cheer', 'Wave', 'Fall', 'Point', 'Clap', 'Sit1', 'Sit2', 'Sit3', 'Love']; var ANIMATIONS = Array(); +var eventMappingName = "io.highfidelity.away"; // restoreAnimation on hand controller button events, too +var eventMapping = Controller.newMapping(eventMappingName); EMOTE_ANIMATIONS.forEach(function (name) { var animationURL = Script.resolvePath("assets/animations/" + name + ".fbx"); @@ -31,16 +33,15 @@ EMOTE_ANIMATIONS.forEach(function (name) { var EMOTE_APP_BASE = "html/EmoteApp.html"; var EMOTE_APP_URL = Script.resolvePath(EMOTE_APP_BASE); var EMOTE_LABEL = "EMOTE"; -var EMOTE_APP_SORT_ORDER = 11; +var EMOTE_APP_SORT_ORDER = 12; var FPS = 60; var MSEC_PER_SEC = 1000; -var FINISHED = 3; // see ScriptableResource::State var onEmoteScreen = false; var button; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); -var activeTimer = false; // used to cancel active timer if a user plays an amimation while another animation is playing -var activeEmote = false; // to keep track of the currently playing emote +var activeTimer = false; // Used to cancel active timer if a user plays an animation while another animation is playing +var activeEmote = false; // To keep track of the currently playing emote button = tablet.addButton({ icon: "icons/tablet-icons/EmoteAppIcon.svg", @@ -58,7 +59,7 @@ function onClicked() { } function onScreenChanged(type, url) { - onEmoteScreen = type === "Web" && (url.indexOf(EMOTE_APP_BASE) == url.length - EMOTE_APP_BASE.length); + onEmoteScreen = type === "Web" && (url.indexOf(EMOTE_APP_BASE) === url.length - EMOTE_APP_BASE.length); button.editProperties({ isActive: onEmoteScreen }); } @@ -71,34 +72,79 @@ function onWebEventReceived(event) { } if (event.type === "click") { + var emoteName = event.data; - - if (ANIMATIONS[emoteName].resource.state == FINISHED) { - if (activeTimer !== false) { - Script.clearTimeout(activeTimer); + + if (activeTimer !== false) { + Script.clearTimeout(activeTimer); + } + + // If the activeEmote is different from the chosen emote, then play the new emote. Other wise, + // This is a second click on the same emote as the activeEmote, and we will just stop it. + if (activeEmote !== emoteName) { + activeEmote = emoteName; + + // Allow for a random sitting animation when a user selects sit + var randSit = Math.floor(Math.random() * 3) + 1; + if (emoteName === "Sit"){ + emoteName = event.data + randSit; // "Sit1, Sit2, Sit3" } - - // if the activeEmote is different from the chosen emote, then play the new emote. Other wise, - // this is a second click on the same emote as the activeEmote, and we will just stop it. - if (activeEmote !== emoteName) { - activeEmote = emoteName; - var frameCount = ANIMATIONS[emoteName].animation.frames.length; + + var frameCount = ANIMATIONS[emoteName].animation.frames.length; + + // Three types of emotes (non-looping end, non-looping return, looping) + if (emoteName.match(/^Sit.*$/) || emoteName === "Fall") { // non-looping end + + MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, false, 0, frameCount); + + // Non-looping return + } else if (emoteName === "Love" || emoteName === "Surprised" || emoteName === "Cry" || emoteName === "Point"){ + MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, false, 0, frameCount); - var timeOut = MSEC_PER_SEC * frameCount / FPS; activeTimer = Script.setTimeout(function () { MyAvatar.restoreAnimation(); activeTimer = false; activeEmote = false; }, timeOut); - } else { - activeEmote = false; - MyAvatar.restoreAnimation(); + + } else { // Looping + + MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, true, 0, frameCount); + } + + } else { + activeEmote = false; + MyAvatar.restoreAnimation(); } + + } } +// If a user provides input, end the emote animation and restore the navigation animation states (idle, walk, run) +function restoreAnimation() { + MyAvatar.restoreAnimation(); +} + +Controller.keyPressEvent.connect(restoreAnimation); + +// Note peek() so as to not interfere with other mappings. +eventMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.LB).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.LS).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.LeftGrip).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.RB).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.RS).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.RightGrip).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.Back).peek().to(restoreAnimation); +eventMapping.from(Controller.Standard.Start).peek().to(restoreAnimation); +Controller.enableMapping(eventMappingName); + button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); tablet.webEventReceived.connect(onWebEventReceived); diff --git a/scripts/system/html/EmoteApp.html b/scripts/system/html/EmoteApp.html index 0a423b9b6c..16dee490a9 100644 --- a/scripts/system/html/EmoteApp.html +++ b/scripts/system/html/EmoteApp.html @@ -38,7 +38,7 @@ .content { margin-top: 90px; - padding: 30px; + padding: 10px 30px; } input[type=button] { @@ -47,9 +47,9 @@ font-size: 20px; text-transform: uppercase; vertical-align: top; - height: 105px; + height: 90px; min-width: 190px; - padding: 0px 18px; + padding: 0px 10px; margin-right: 6px; border-radius: 5px; border: none; @@ -97,15 +97,17 @@
Click an emotion to Emote:
-
+
Choose an emote:
+
-
-
-+
+
+-
-
++
++