repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 729e2b547780b6e31690b359e1ce9699573a5c45:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 729e2b547780b6e31690b359e1ce9699573a5c45
Author: James Baicoianu 
Date:   Thu Jul 20 12:27:29 2017 -0700

    Handle avatar changes properly

diff --git a/scripts/janusghost.js b/scripts/janusghost.js
index 0b19299c94111e079769c8f5f155bc40991d25c5..
index ..ea937d2f152cee8544558e9a032f63fe0f69f60c 100644
--- a/scripts/janusghost.js
+++ b/scripts/janusghost.js
@@ -112,11 +112,16 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
     }
     this.setHead = function(headid, headpos, scale) {
       var objects = this.getGhostObjects();
+      if (this.face) {
+        this.face.die();
+        this.face = false;
+      }
       if (headid && this.head) {
         var assetid = headid;
         if (!this.face || this.face.janusid != assetid) {
           if (objects && objects[headid]) {
-            assetid = this.id + '_head_model';
+            assetid = this.id + '_head_' + objects[headid].src;
+            if (objects[headid].mtl) assetid += '_' + objects[headid].mtl;
             var asset = elation.engine.assets.get({
               assettype: 'model',
               name: assetid,
@@ -146,10 +151,15 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
     }
     this.setBody = function(bodyid, scale) {
       var objects = this.getGhostObjects();
+      if (this.body) {
+        this.body.die();
+        this.body = false;
+      }
       if (bodyid) {
         var assetid = bodyid;
         if (objects && objects[bodyid]) {
-          assetid = this.player_name + '_body_model';
+          assetid = this.player_name + '_body_' + objects[bodyid].src;
+          if (objects[bodyid].mtl) assetid += '_' + objects[bodyid].mtl;
           var asset = elation.engine.assets.get({
             assettype: 'model',
             name: assetid,

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