repo: janusweb action: commit revision: path_from: revision_from: 6584e90da85d24b80af8a177b33005ee4ef679ea: path_to: revision_to:
commit 6584e90da85d24b80af8a177b33005ee4ef679ea Author: James BaicoianuDate: Thu Jan 26 05:18:01 2017 -0800 Fix for offset remoteplayer faces diff --git a/scripts/janusghost.js b/scripts/janusghost.js
--- a/scripts/janusghost.js
+++ b/scripts/janusghost.js
@@ -105,28 +105,30 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
var objects = this.getGhostObjects();
if (headid && this.head) {
var assetid = headid;
- if (objects && objects[headid]) {
- assetid = this.id + '_head_model';
- var asset = elation.engine.assets.get({
- assettype: 'model',
- name: assetid,
- src: objects[headid].src,
- mtl: objects[headid].mtl
+ if (!this.face || this.face.janusid != assetid) {
+ if (objects && objects[headid]) {
+ assetid = this.id + '_head_model';
+ var asset = elation.engine.assets.get({
+ assettype: 'model',
+ name: assetid,
+ src: objects[headid].src,
+ mtl: objects[headid].mtl
+ });
+ }
+ if (headpos) {
+ this.head.properties.position.copy(headpos);
+ }
+
+ this.face = this.head.spawn('janusobject', null, {
+ janus: this.janus,
+ room: this.room,
+ janusid: assetid,
+ position: headpos.clone().negate(),
+ orientation: new THREE.Quaternion().setFromEuler(new THREE.Euler(0, Math.PI, 0)),
+ lighting: this.lighting,
+ cull_face: 'none'
});
}
- if (headpos) {
- this.head.properties.position.copy(headpos);
- }
-
- this.face = this.head.spawn('janusobject', null, {
- janus: this.janus,
- room: this.room,
- janusid: assetid,
- position: headpos.clone().negate(),
- orientation: new THREE.Quaternion().setFromEuler(new THREE.Euler(0, Math.PI, 0)),
- lighting: this.lighting,
- cull_face: 'none'
- });
//this.head.properties.position.copy(headpos);
}
}
@@ -197,8 +199,8 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
if (movedata.view_dir && movedata.up_dir) {
if (this.head) {
- ydir.fromArray(parser.getVectorValue(movedata.up_dir, [0,1,0])),
- zdir.fromArray(parser.getVectorValue(movedata.view_dir, [0,0,1])),
+ ydir.fromArray(parser.getVectorValue(movedata.up_dir, [0,1,0]));
+ zdir.fromArray(parser.getVectorValue(movedata.view_dir, [0,0,1]));
xdir.crossVectors(zdir, ydir);
xdir.crossVectors(zdir, ydir).normalize();
@@ -207,15 +209,11 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
matrix.makeBasis(xdir, ydir, zdir);
this.head.properties.orientation.setFromRotationMatrix(matrix);
if (movedata.head_pos && this.face) {
- var headpos = this.face.properties.position;
+ var headpos = this.head.properties.position;
+ var facepos = this.face.properties.position;
var newpos = parser.getVectorValue(movedata.head_pos);
-/*
- headpos.copy(this.properties.head_pos).negate();
- headpos.x += newpos[0];
- headpos.y += newpos[1];
- headpos.z += newpos[2];
-*/
headpos.fromArray(newpos);
+ facepos.fromArray([-newpos[0], -newpos[1], -newpos[2]]).sub(this.properties.head_pos);
}
}
}
diff --git a/scripts/janusweb.js b/scripts/janusweb.js
--- a/scripts/janusweb.js
+++ b/scripts/janusweb.js
@@ -574,7 +574,9 @@ elation.require(['janusweb.config', 'engine.things.generic','janusweb.remoteplay
//console.log('movedata update', moveData);
if (opts.first || this.sentUpdates == this.updateRate) {
- moveData["avatar"] = " ";
+ // FIXME - don't hardcode this!
+ var head_pos = '0 1.4 0';
+ moveData["avatar"] = " ";
this.sentUpdates = 0;
}
diff --git a/scripts/remoteplayer.js b/scripts/remoteplayer.js
--- a/scripts/remoteplayer.js
+++ b/scripts/remoteplayer.js
@@ -29,10 +29,10 @@ elation.component.add('engine.things.remoteplayer', function() {
'position': [0,0.6,-0.0]
});
this.neck = this.torso.spawn('generic', this.properties.player_name + '_neck', {
- 'position': [0,0.4,0]
+ 'position': [0,0.4,0],
});
this.head = this.neck.spawn('generic', this.properties.player_name + '_head', {
- 'position': [0,0,0],
+ 'position': [0,1.4,0],
});
/*
this.face = this.head.spawn('maskgenerator', this.properties.player_name + '_mask', {
-----END OF PAGE-----