repo: janusweb
action: commit
revision: 
path_from: 
revision_from: c89d804f7af3259e33a715ae453dcaa221db65b3:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit c89d804f7af3259e33a715ae453dcaa221db65b3
Author: James Baicoianu 
Date:   Sun Apr 24 00:22:40 2022 -0700

    Track morphtarget changes in memory

diff --git a/scripts/janusplayer.js b/scripts/janusplayer.js
index 6f78a92925ac037bca80f1d4ad8a3daf5e81d857..
index ..45588d4f0271f2ff86c0d6e49f727d83589697d9 100644
--- a/scripts/janusplayer.js
+++ b/scripts/janusplayer.js
@@ -131,6 +131,7 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
       this.party_mode = this.getSetting('partymode.enabled', false);
       this.currentavatar = '';
       this.getAvatarData().then(d => this.currentavatar = d);
+      this.morphtargetchanges = {};
     }
     this.createChildren = function() {
       elation.engine.things.janusplayer.extendclass.createChildren.call(this);
@@ -729,6 +730,29 @@ elation.require(['engine.things.player', 'janusweb.external.JanusVOIP', 'ui.butt
       } 
       return handData;
     }
+    this.hasMorphTargetData = function() {
+      return Object.keys(this.morphtargetchanges).length > 0;
+    }
+    this.setMorphTargetInfluence = function(morphtarget, value) {
+      if (this.ghost && this.ghost.body) {
+        this.ghost.body.setMorphTargetInfluence(morphtarget, value);
+        //if (this.morphtargetchanges.indexOf(morphtarget) == -1) {
+        this.morphtargetchanges[morphtarget] = value;
+        //}
+      }
+    }
+    this.getMorphTargetData = function() {
+      if (this.hasMorphTargetData()) {
+        let data = {};
+        let body = this.ghost.body;
+        for (let morphtarget in this.morphtargetchanges) {
+          data[morphtarget] = this.morphtargetchanges[morphtarget];
+          delete this.morphtargetchanges[morphtarget];
+        }
+        return data;
+      }
+      return false;
+    }
     this.getRandomUsername = function() {
       var adjectives = [
 				"Adorable", "Beautiful", "Clean", "Drab", "Elegant", "Fancy", "Glamorous", "Handsome", "Long", "Magnificent",

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