mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02: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
|
(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 ANIMATIONS = Array();
|
||||||
|
|
||||||
|
var eventMappingName = "io.highfidelity.away"; // restoreAnimation on hand controller button events, too
|
||||||
|
var eventMapping = Controller.newMapping(eventMappingName);
|
||||||
|
|
||||||
EMOTE_ANIMATIONS.forEach(function (name) {
|
EMOTE_ANIMATIONS.forEach(function (name) {
|
||||||
var animationURL = Script.resolvePath("assets/animations/" + name + ".fbx");
|
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_BASE = "html/EmoteApp.html";
|
||||||
var EMOTE_APP_URL = Script.resolvePath(EMOTE_APP_BASE);
|
var EMOTE_APP_URL = Script.resolvePath(EMOTE_APP_BASE);
|
||||||
var EMOTE_LABEL = "EMOTE";
|
var EMOTE_LABEL = "EMOTE";
|
||||||
var EMOTE_APP_SORT_ORDER = 11;
|
var EMOTE_APP_SORT_ORDER = 12;
|
||||||
var FPS = 60;
|
var FPS = 60;
|
||||||
var MSEC_PER_SEC = 1000;
|
var MSEC_PER_SEC = 1000;
|
||||||
var FINISHED = 3; // see ScriptableResource::State
|
|
||||||
|
|
||||||
var onEmoteScreen = false;
|
var onEmoteScreen = false;
|
||||||
var button;
|
var button;
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
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 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
|
var activeEmote = false; // To keep track of the currently playing emote
|
||||||
|
|
||||||
button = tablet.addButton({
|
button = tablet.addButton({
|
||||||
icon: "icons/tablet-icons/EmoteAppIcon.svg",
|
icon: "icons/tablet-icons/EmoteAppIcon.svg",
|
||||||
|
@ -58,7 +59,7 @@ function onClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
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 });
|
button.editProperties({ isActive: onEmoteScreen });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,34 +72,79 @@ function onWebEventReceived(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === "click") {
|
if (event.type === "click") {
|
||||||
|
|
||||||
var emoteName = event.data;
|
var emoteName = event.data;
|
||||||
|
|
||||||
if (ANIMATIONS[emoteName].resource.state == FINISHED) {
|
|
||||||
if (activeTimer !== false) {
|
if (activeTimer !== false) {
|
||||||
Script.clearTimeout(activeTimer);
|
Script.clearTimeout(activeTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the activeEmote is different from the chosen emote, then play the new emote. Other wise,
|
// 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.
|
// This is a second click on the same emote as the activeEmote, and we will just stop it.
|
||||||
if (activeEmote !== emoteName) {
|
if (activeEmote !== emoteName) {
|
||||||
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"
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
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;
|
var timeOut = MSEC_PER_SEC * frameCount / FPS;
|
||||||
activeTimer = Script.setTimeout(function () {
|
activeTimer = Script.setTimeout(function () {
|
||||||
MyAvatar.restoreAnimation();
|
MyAvatar.restoreAnimation();
|
||||||
activeTimer = false;
|
activeTimer = false;
|
||||||
activeEmote = false;
|
activeEmote = false;
|
||||||
}, timeOut);
|
}, timeOut);
|
||||||
|
|
||||||
|
} else { // Looping
|
||||||
|
|
||||||
|
MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, true, 0, frameCount);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
activeEmote = false;
|
activeEmote = false;
|
||||||
MyAvatar.restoreAnimation();
|
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);
|
button.clicked.connect(onClicked);
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
tablet.screenChanged.connect(onScreenChanged);
|
||||||
tablet.webEventReceived.connect(onWebEventReceived);
|
tablet.webEventReceived.connect(onWebEventReceived);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
margin-top: 90px;
|
margin-top: 90px;
|
||||||
padding: 30px;
|
padding: 10px 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=button] {
|
input[type=button] {
|
||||||
|
@ -47,9 +47,9 @@
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
height: 105px;
|
height: 90px;
|
||||||
min-width: 190px;
|
min-width: 190px;
|
||||||
padding: 0px 18px;
|
padding: 0px 10px;
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -97,15 +97,17 @@
|
||||||
<h4>Emote App</h4>
|
<h4>Emote App</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>Click an emotion to Emote:<p>
|
<p>Choose an emote:<p>
|
||||||
<p><input type="button" class="emote-button white" value="Crying">
|
<p><input type="button" class="emote-button white" value="Cry">
|
||||||
<input type="button" class="emote-button white" value="Surprised"></p>
|
<input type="button" class="emote-button white" value="Surprised"></p>
|
||||||
<p><input type="button" class="emote-button white" value="Dancing">
|
<p><input type="button" class="emote-button white" value="Dance">
|
||||||
<input type="button" class="emote-button white" value="Cheering"></p>
|
<input type="button" class="emote-button white" value="Cheer"></p>
|
||||||
<p><input type="button" class="emote-button white" value="Waving">
|
<p><input type="button" class="emote-button white" value="Wave">
|
||||||
<input type="button" class="emote-button white" value="Fall"></p>
|
<input type="button" class="emote-button white" value="Fall"></p>
|
||||||
<p><input type="button" class="emote-button white" value="Pointing">
|
<p><input type="button" class="emote-button white" value="Point">
|
||||||
<input type="button" class="emote-button white" value="Clapping"></p>
|
<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>
|
</div>
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue