repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 96a5ab86137c5e122aaa685724406c3b1d5d6907:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 96a5ab86137c5e122aaa685724406c3b1d5d6907
Author: James Baicoianu 
Date:   Mon Oct 4 00:21:59 2021 -0700

    Use morph targets to blink and flap mouth

diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
index 9d92ecbaf2e3ee365c2e515acc7f7fad73a71f29..
index ..346784c0471fb4e70eb31fb613eae8895b7f3456 100644
--- a/scripts/remoteplayer.js
+++ b/scripts/remoteplayer.js
@@ -169,6 +169,25 @@ elation.component.add('engine.things.remoteplayer', function() {
       this.mouth.audio.gain.gain.value = volume;
     }
   }
+  this.setSpeakingVolume = function(volume) {
+    // FIXME - Quick hack to flap our mouth based on our speaking volume if we have blendshapes
+    // Probably only works with Ready Player Me avatars
+
+    if (this.body) {
+      this.body.setMorphTargetInfluence('mouthOpen', volume);
+    }
+  }
+  this.blink = function() {
+    if (this.body) {
+      this.body.setMorphTargetInfluence('eyesClosed', 1);
+      setTimeout(() => {
+        this.body.setMorphTargetInfluence('eyesClosed', 0);
+      }, 100);
+    }
+    setTimeout(() => {
+      this.blink();
+    }, 2500 + Math.random() * 8500);
+  }
 }, elation.engine.things.janusghost);

 });

-----END OF PAGE-----