repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 59d3bc52b13760664600da56423abec2053328ae:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 59d3bc52b13760664600da56423abec2053328ae
Author: James Baicoianu 
Date:   Thu Jul 20 22:12:00 2017 -0700

    Fixed ghost head position FINALLY

diff --git a/scripts/janusghost.js b/scripts/janusghost.js
index ea937d2f152cee8544558e9a032f63fe0f69f60c..
index ..3303f117ffc7df055620040806f777203d35d8c9 100644
--- a/scripts/janusghost.js
+++ b/scripts/janusghost.js
@@ -145,7 +145,9 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
         }
         //this.head.properties.position.copy(headpos);
         if (scale) {
-          this.head.scale.fromArray(scale);
+          this.face.scale.fromArray(scale);
+          this.label.scale.fromArray(scale);
+          this.label.properties.position.multiply(this.label.scale);
         }
       }
     }
@@ -276,11 +278,14 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
         if (movedata.dir && this.body) {
           this.body.properties.zdir.fromArray(parser.getVectorValue(movedata.dir)).normalize();
           this.body.properties.ydir.set(0,1,0);
-          this.body.properties.xdir.crossVectors(this.body.properties.ydir, this.body.properties.zdir);
-          this.body.properties.zdir.crossVectors(this.body.properties.xdir, this.body.properties.ydir);
+          this.body.properties.xdir.crossVectors(this.body.properties.ydir, this.body.properties.zdir).normalize();
+          this.body.properties.zdir.crossVectors(this.body.properties.xdir, this.body.properties.ydir).normalize();
           this.body.updateVectors(true);
         }

+        if (movedata.avatar) {
+          this.setAvatar(movedata.avatar.replace(/\^/g, '"'));
+        }
         if (movedata.view_dir && movedata.up_dir) {
           if (this.head) {
             ydir.fromArray(parser.getVectorValue(movedata.up_dir, [0,1,0]));
@@ -288,7 +293,7 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
             xdir.crossVectors(zdir, ydir);

             xdir.crossVectors(zdir, ydir).normalize();
-            zdir.crossVectors(xdir, ydir);
+            zdir.crossVectors(xdir, ydir).normalize();

             matrix.makeBasis(xdir, ydir, zdir);
             this.head.properties.orientation.setFromRotationMatrix(matrix);
@@ -296,14 +301,15 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
               var headpos = this.head.properties.position;
               var facepos = this.face.properties.position;
               var newpos = parser.getVectorValue(movedata.head_pos);
-              headpos.fromArray(newpos).add(this.head_pos);
-              facepos.fromArray([-newpos[0], -newpos[1], -newpos[2]]).sub(this.properties.head_pos);
+              headpos.copy(this.head_pos);
+              facepos.fromArray(newpos).sub(this.head_pos);
+              if (this.body) {
+                headpos.multiply(this.body.scale);
+                facepos.multiply(this.body.scale);
+              }
             }
           }
         }
-        if (movedata.avatar) {
-          this.setAvatar(movedata.avatar.replace(/\^/g, '"'));
-        }
         if (movedata.hand0 || movedata.hand1) {
           this.updateHands(movedata.hand0, movedata.hand1);
         }
diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
index 0acb60ccdf78d299e81c7a19bf57ad9c3d4404e0..
index ..0a4cfaf17e49bfa635a8b6d5027229611fae28a6 100644
--- a/scripts/remoteplayer.js
+++ b/scripts/remoteplayer.js
@@ -31,7 +31,7 @@ elation.component.add('engine.things.remoteplayer', function() {
     this.neck = this.torso.spawn('generic', this.properties.player_name + '_neck', {
       'position': [0,0.4,0],
     });
-    this.head = this.neck.spawn('generic', this.properties.player_name + '_head', {
+    this.head = this.spawn('generic', this.properties.player_name + '_head', {
       'position': [0,1.4,0],
     });
 /*

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