mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #13003 from alexiamandeville/sittingUpdates
Adding sitting and love to emote app
This commit is contained in:
commit
4f561b00da
12 changed files with 78 additions and 30 deletions
Binary file not shown.
BIN
scripts/system/assets/animations/Love.fbx
Normal file
BIN
scripts/system/assets/animations/Love.fbx
Normal file
Binary file not shown.
BIN
scripts/system/assets/animations/Sit1.fbx
Normal file
BIN
scripts/system/assets/animations/Sit1.fbx
Normal file
Binary file not shown.
BIN
scripts/system/assets/animations/Sit2.fbx
Normal file
BIN
scripts/system/assets/animations/Sit2.fbx
Normal file
Binary file not shown.
BIN
scripts/system/assets/animations/Sit3.fbx
Normal file
BIN
scripts/system/assets/animations/Sit3.fbx
Normal file
Binary file not shown.
|
@ -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);
|
||||
|
|
|
@ -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 @@
|
|||
<h4>Emote App</h4>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Click an emotion to Emote:<p>
|
||||
<p><input type="button" class="emote-button white" value="Crying">
|
||||
<p>Choose an emote:<p>
|
||||
<p><input type="button" class="emote-button white" value="Cry">
|
||||
<input type="button" class="emote-button white" value="Surprised"></p>
|
||||
<p><input type="button" class="emote-button white" value="Dancing">
|
||||
<input type="button" class="emote-button white" value="Cheering"></p>
|
||||
<p><input type="button" class="emote-button white" value="Waving">
|
||||
<p><input type="button" class="emote-button white" value="Dance">
|
||||
<input type="button" class="emote-button white" value="Cheer"></p>
|
||||
<p><input type="button" class="emote-button white" value="Wave">
|
||||
<input type="button" class="emote-button white" value="Fall"></p>
|
||||
<p><input type="button" class="emote-button white" value="Pointing">
|
||||
<input type="button" class="emote-button white" value="Clapping"></p>
|
||||
<p><input type="button" class="emote-button white" value="Point">
|
||||
<input type="button" class="emote-button white" value="Clap"></p>
|
||||
<p><input type="button" class="emote-button white" value="Sit">
|
||||
<input type="button" class="emote-button white" value="Love"></p>
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
|
|
Loading…
Reference in a new issue