Skip to content

Commit

Permalink
Merge pull request #46 from overte-org/fix/emocam_formatting
Browse files Browse the repository at this point in the history
Reformatted tabulation in emocam index.html
  • Loading branch information
ksuprynowicz authored Oct 27, 2023
2 parents 8948944 + d35459d commit 33ba6b8
Show file tree
Hide file tree
Showing 2 changed files with 922 additions and 894 deletions.
184 changes: 96 additions & 88 deletions applications/emocam/emocam1.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
//



(function() {
(function () {
var jsMainFileName = "emocam1.js";
var ROOT = Script.resolvePath('').split(jsMainFileName)[0];
var channel = "org.overte.application.emocam";

var TABLET_BUTTON_NAME = "EMOTIONS";
var TRANSITION_TIME_SECONDS = 0.25;
var onEmoteScreen = false;
Expand All @@ -26,7 +25,7 @@
var icon = "face.png";
var activeIcon = "face.png";
var isActive = true;
var EMOTE_APP_BASE = "index.html?"+Date.now();
var EMOTE_APP_BASE = "index.html?" + Date.now();
var EMOTE_APP_URL = Script.resolvePath(EMOTE_APP_BASE);
var EMOTE_APP_SORT_ORDER = 12;
var EMOTE_LABEL = "FACE";
Expand Down Expand Up @@ -59,14 +58,22 @@

function onScreenChanged(type, url) {
onEmoteScreen = type === "Web" && (url.indexOf(EMOTE_APP_BASE) === url.length - EMOTE_APP_BASE.length);
button.editProperties({ isActive: onEmoteScreen });
button.editProperties({isActive: onEmoteScreen});
}

var mapping = Controller.newMapping();
var yawBinding = mapping.from(function() { return yawValue; }).to(Controller.Actions.DeltaYaw);
var pitchBinding = mapping.from(function() { return pitchValue; }).to(Controller.Actions.DeltaPitch);
var forwardBinding = mapping.from(function() { return forwardValue; }).to(Controller.Actions.TranslateZ);
var sideBinding = mapping.from(function() { return sideValue; }).to(Controller.Actions.TranslateX);
var yawBinding = mapping.from(function () {
return yawValue;
}).to(Controller.Actions.DeltaYaw);
var pitchBinding = mapping.from(function () {
return pitchValue;
}).to(Controller.Actions.DeltaPitch);
var forwardBinding = mapping.from(function () {
return forwardValue;
}).to(Controller.Actions.TranslateZ);
var sideBinding = mapping.from(function () {
return sideValue;
}).to(Controller.Actions.TranslateX);
mapping.enable();

var propList = ["headRotation", "headType"];
Expand All @@ -86,103 +93,103 @@

var parsed = JSON.parse(event);
if (parsed.channel === channel) {
if (parsed.type === "tracking" || parsed.type === "trackingmotion"){
if (parsed.type === "tracking" || parsed.type === "trackingmotion") {
var emotion = parsed.data;
MyAvatar.hasScriptedBlendshapes = true;
var bend ={
"EyeOpen_L": emotion["eyeWideLeft"]*4,
"EyeOpen_R": emotion["eyeWideRight"]*4,
"EyeBlink_L": emotion["eyeBlinkLeft"],
"EyeBlink_R": emotion["eyeBlinkRight"],
"EyeSquint_L": emotion["eyeSquintLeft"],
"EyeSquint_R": emotion["eyeSquintRight"],
"BrowsD_L": emotion["browDownLeft"],
"BrowsD_R": emotion["browDownRight"],
"BrowsU_C": emotion["browInnerUp"],
"BrowsU_L": emotion["browOuterUpLeft"],
"BrowsU_R": emotion["browOuterUpRight"],
"JawOpen": emotion["jawOpen"],
"MouthOpen": emotion["jawOpen"],
"JawFwd": emotion["jawForward"],
"MouthFrown_L": emotion["mouthFrownLeft"],
"MouthFrown_R": emotion["mouthFrownRight"],
"MouthSmile_L": emotion["mouthSmileLeft"]*0.8,
"MouthSmile_R": emotion["mouthSmileRight"]*0.8,
"MouthDimple_L": emotion["mouthStretchLeft"],
"MouthDimple_R": emotion["mouthStretchRight"],
"NoseSneer_L": emotion["noseSneerLeft"],
"NoseSneer_R": emotion["noseSneerRight"],
"Puff": emotion["cheekPuff"]*1.3,
"CheekSquint_L": emotion["cheekSquintLeft"],
"CheekSquint_R": emotion["cheekSquintRight"],
"EyeDown_L": emotion["eyeLookDownLeft"]*1.2,
"EyeDown_R": emotion["eyeLookDownRight"]*1.2,
"EyeIn_L": emotion["eyeLookInLeft"],
"EyeIn_R": emotion["eyeLookInRight"],
"EyeOut_L": emotion["eyeLookOutLeft"],
"EyeOut_R": emotion["eyeLookOutRight"],
"EyeUp_L": emotion["eyeLookUpLeft"],
"EyeUp_R": emotion["eyeLookUpRight"],
"EyeSquint_L": emotion["eyeSquintLeft"],
"EyeSquint_R": emotion["eyeSquintRight"],
"TongueOut": emotion["jawForward"],
"JawLeft": emotion["jawLeft"]*3,
"JawRight": emotion["jawRight"]*3,
"MouthClose": emotion["mouthClose"],
"MouthDimple_L": emotion["mouthDimpleLeft"],
"MouthDimple_R": emotion["mouthDimpleRight"],
"LipsFunnel": emotion["mouthFunnel"],
"MouthLeft": emotion["mouthLeft"],
"MouthLowerDown_L": emotion["mouthLowerDownLeft"],
"MouthLowerDown_R": emotion["mouthLowerDownRight"],
"MouthPress_L": emotion["mouthPressLeft"],
"MouthPress_L": emotion["mouthPressRight"],
"LipsPucker": emotion["mouthPucker"],
"MouthRight": emotion["mouthRight"],
"MouthRollLower": emotion["mouthRollLower"],
"MouthRollUpper": emotion["mouthRollUpper"],
"MouthShrugLower": emotion["mouthShrugLower"],
"MouthShrugUpper": emotion["mouthShrugUpper"],
"MouthUpperUp_L": emotion["mouthUpperUpLeft"],
"MouthUpperUp_R": emotion["mouthUpperUpRight"]
var bend = {
"EyeOpen_L": emotion["eyeWideLeft"] * 4,
"EyeOpen_R": emotion["eyeWideRight"] * 4,
"EyeBlink_L": emotion["eyeBlinkLeft"],
"EyeBlink_R": emotion["eyeBlinkRight"],
"EyeSquint_L": emotion["eyeSquintLeft"],
"EyeSquint_R": emotion["eyeSquintRight"],
"BrowsD_L": emotion["browDownLeft"],
"BrowsD_R": emotion["browDownRight"],
"BrowsU_C": emotion["browInnerUp"],
"BrowsU_L": emotion["browOuterUpLeft"],
"BrowsU_R": emotion["browOuterUpRight"],
"JawOpen": emotion["jawOpen"],
"MouthOpen": emotion["jawOpen"],
"JawFwd": emotion["jawForward"],
"MouthFrown_L": emotion["mouthFrownLeft"],
"MouthFrown_R": emotion["mouthFrownRight"],
"MouthSmile_L": emotion["mouthSmileLeft"] * 0.8,
"MouthSmile_R": emotion["mouthSmileRight"] * 0.8,
"MouthDimple_L": emotion["mouthStretchLeft"],
"MouthDimple_R": emotion["mouthStretchRight"],
"NoseSneer_L": emotion["noseSneerLeft"],
"NoseSneer_R": emotion["noseSneerRight"],
"Puff": emotion["cheekPuff"] * 1.3,
"CheekSquint_L": emotion["cheekSquintLeft"],
"CheekSquint_R": emotion["cheekSquintRight"],
"EyeDown_L": emotion["eyeLookDownLeft"] * 1.2,
"EyeDown_R": emotion["eyeLookDownRight"] * 1.2,
"EyeIn_L": emotion["eyeLookInLeft"],
"EyeIn_R": emotion["eyeLookInRight"],
"EyeOut_L": emotion["eyeLookOutLeft"],
"EyeOut_R": emotion["eyeLookOutRight"],
"EyeUp_L": emotion["eyeLookUpLeft"],
"EyeUp_R": emotion["eyeLookUpRight"],
"EyeSquint_L": emotion["eyeSquintLeft"],
"EyeSquint_R": emotion["eyeSquintRight"],
"TongueOut": emotion["jawForward"],
"JawLeft": emotion["jawLeft"] * 3,
"JawRight": emotion["jawRight"] * 3,
"MouthClose": emotion["mouthClose"],
"MouthDimple_L": emotion["mouthDimpleLeft"],
"MouthDimple_R": emotion["mouthDimpleRight"],
"LipsFunnel": emotion["mouthFunnel"],
"MouthLeft": emotion["mouthLeft"],
"MouthLowerDown_L": emotion["mouthLowerDownLeft"],
"MouthLowerDown_R": emotion["mouthLowerDownRight"],
"MouthPress_L": emotion["mouthPressLeft"],
"MouthPress_L": emotion["mouthPressRight"],
"LipsPucker": emotion["mouthPucker"],
"MouthRight": emotion["mouthRight"],
"MouthRollLower": emotion["mouthRollLower"],
"MouthRollUpper": emotion["mouthRollUpper"],
"MouthShrugLower": emotion["mouthShrugLower"],
"MouthShrugUpper": emotion["mouthShrugUpper"],
"MouthUpperUp_L": emotion["mouthUpperUpLeft"],
"MouthUpperUp_R": emotion["mouthUpperUpRight"]
};
if (parsed.type === "trackingmotion"){
print("pitch: "+ parsed.pitch + "yaw: " +parsed.yaw);
if (parsed.pitch <= -15 || parsed.pitch >= 5){
if (parsed.type === "trackingmotion") {
print("pitch: " + parsed.pitch + "yaw: " + parsed.yaw);
if (parsed.pitch <= -15 || parsed.pitch >= 5) {
forwardValue = 0;
yawValue = 0;
if (parsed.pitch > 5){
yawValue = 0;
if (parsed.pitch > 5) {
pitchValue = 0.3;
}
if (parsed.pitch < -15){
pitchValue = -0.3;
}
if (parsed.pitch >= -15 && parsed.pitch <= 5){
if (parsed.pitch < -15) {
pitchValue = -0.3;
}
if (parsed.pitch >= -15 && parsed.pitch <= 5) {
pitchValue = 0;
}
} else {
pitchValue = 0;
if (parsed.yaw <= - 10 || parsed.yaw >= 10){
if (parsed.yaw <= -10 || parsed.yaw >= 10) {
forwardValue = 0;

if (parsed.yaw > 10){
yawValue = parsed.yaw /20;

if (parsed.yaw > 10) {
yawValue = parsed.yaw / 20;
}
if (parsed.yaw < -10) {
yawValue = parsed.yaw / 20;
}
if (parsed.yaw < -10){
yawValue = parsed.yaw /20;
}
if (parsed.yaw >= - 10 && parsed.yaw <= 10){
if (parsed.yaw >= -10 && parsed.yaw <= 10) {
yawValue = 0;
}
} else {
yawValue = 0;
if (emotion["browInnerUp"]>0.1){
yawValue = 0;
if (emotion["browInnerUp"] > 0.1) {
forwardValue = -1;
}
if (emotion["browDownLeft"]>0.4){
if (emotion["browDownLeft"] > 0.4) {
forwardValue = 1;
}
if (emotion["browInnerUp"] <= 0.1 && emotion["browDownLeft"] <= 0.4){
if (emotion["browInnerUp"] <= 0.1 && emotion["browDownLeft"] <= 0.4) {
forwardValue = 0;
}
}
Expand All @@ -199,6 +206,7 @@
}
}
}

function setEmotion(currentEmotion) {
if (emotion !== lastEmotionUsed) {
lastEmotionUsed = emotion;
Expand Down Expand Up @@ -229,6 +237,6 @@
}

MyAvatar.restoreAnimation();
mapping.disable();
mapping.disable();
});
}());
Loading

0 comments on commit 33ba6b8

Please sign in to comment.