Skip to content

Commit

Permalink
Merge pull request #54 from overte-org/fix/emocam_eye_blink
Browse files Browse the repository at this point in the history
Disable procedural eye blinking when face tracking is running
  • Loading branch information
ksuprynowicz authored Nov 19, 2023
2 parents fab88f5 + 488a1de commit 7e96b35
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions applications/emocam/emocam1.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ var webWindow;
var yaw = 0;
var roll = 0;
var headTransform = null;
var lastDataArrived = Date.now();
var lastDataArrived = 0;
const POSE_TIMEOUT_MS = 2000;
var proceduralBlinkingPreviousState = MyAvatar.hasProceduralBlinkFaceMovement;
// Caching this value is a good idea because API calls are expensive
var isProceduralBlinkingAllowed = true;

button = tablet.addButton({
icon: ROOT + "images/face.png",
Expand Down Expand Up @@ -83,12 +87,21 @@ var webWindow;

var propList = ["headRotation", "headType"];
handlerId = MyAvatar.addAnimationStateHandler(function (props) {
if (Date.now() - lastDataArrived < 2000) {
// Just pass through the animation state without modifying it when pose times out
if (Date.now() - lastDataArrived < POSE_TIMEOUT_MS) {
if (isProceduralBlinkingAllowed) {
MyAvatar.hasProceduralBlinkFaceMovement = false;
isProceduralBlinkingAllowed = false;
}
return {
headRotation: headTransform,
headType: 4
};
} else {
if (!isProceduralBlinkingAllowed) {
MyAvatar.hasProceduralBlinkFaceMovement = proceduralBlinkingPreviousState;
isProceduralBlinkingAllowed = true;
}
return props;
}
}, propList);
Expand Down Expand Up @@ -222,18 +235,6 @@ var webWindow;
}
}

function setEmotion(currentEmotion) {
if (emotion !== lastEmotionUsed) {
lastEmotionUsed = emotion;
}
if (currentEmotion !== lastEmotionUsed) {
changingEmotionPercentage = 0.0;
emotion = currentEmotion;
isChangingEmotion = true;
MyAvatar.hasScriptedBlendshapes = true;
}
}

function onWindowClosed() {
webWindow = null;
button.editProperties({isActive: false});
Expand All @@ -252,6 +253,7 @@ var webWindow;
tablet.removeButton(button);
}

MyAvatar.hasProceduralBlinkFaceMovement = proceduralBlinkingPreviousState;
MyAvatar.restoreAnimation();
mapping.disable();
});
Expand Down

0 comments on commit 7e96b35

Please # to comment.