repo: janusweb action: commit revision: path_from: revision_from: d4c22f975fe1081c6ea909b4f6431abc41e11860: path_to: revision_to:
commit d4c22f975fe1081c6ea909b4f6431abc41e11860 Author: James BaicoianuDate: Tue Sep 3 17:43:45 2024 -0700 Fixed player head orientation bugs (hopefully) diff --git a/scripts/janusghost.js b/scripts/janusghost.js
--- a/scripts/janusghost.js
+++ b/scripts/janusghost.js
@@ -286,7 +286,7 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
this.body = this.createObject('object', {
id: bodyid,
//orientation: new THREE.Quaternion().setFromEuler(new THREE.Euler(0,Math.PI,0)),
- //rotation: V(0, 180, 0),
+ rotation: V(0, 180, 0),
lighting: this.lighting,
//cull_face: 'none'
opacity: 0.9999,
@@ -446,7 +446,7 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
}
});
} else {
- let armature = sourcecontainer.getObjectByName('Armature');
+ let armature = sourcecontainer.getObjectByName('Armature') || sourcecontainer;
newclip.tracks.forEach(track => {
track.name = track.name.replace('mixamorig', '');
let p = track.name.split('.');
@@ -528,6 +528,8 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
var xdir = new THREE.Vector3(),
ydir = new THREE.Vector3(),
zdir = new THREE.Vector3(),
+ flip = new THREE.Quaternion().setFromEuler(new THREE.Euler(0, Math.PI, 0));
+ origin = new THREE.Vector3(),
matrix = new THREE.Matrix4(),
q1 = new THREE.Quaternion();
return function(movedata) {
@@ -550,16 +552,11 @@ elation.require(['janusweb.janusbase', 'engine.things.leapmotion'], function() {
if (this.head) {
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();
- zdir.crossVectors(xdir, ydir).normalize();
-
- matrix.makeBasis(xdir, ydir, zdir);
+ matrix.lookAt(origin, zdir, ydir);
q1.setFromRotationMatrix(matrix);
- this.head.properties.orientation.copy(this.orientation).invert().multiply(q1);
+ this.head.properties.orientation.copy(this.orientation).invert().multiply(q1).multiply(flip);
if (this.body && this.headaction) {
- this.setHeadOrientation(this.head.orientation);
+ this.setHeadOrientation(this.head.orientation, true);
}
if (movedata.head_pos && this.face) {
var headpos = this.head.properties.position;
@@ -863,7 +860,7 @@ return;
let track = headaction._clip.tracks[0];
if (track) {
track.values[0] = orientation.x * (invert ? -1 : 1);
- track.values[1] = orientation.y * (invert ? -1 : 1);
+ track.values[1] = orientation.y * (invert ? 1 : -1);
track.values[2] = orientation.z * (invert ? -1 : 1);
track.values[3] = orientation.w; // * (invert ? -1 : 1);
}
diff --git a/scripts/janusplayer.js b/scripts/janusplayer.js
--- a/scripts/janusplayer.js
+++ b/scripts/janusplayer.js
@@ -303,10 +303,10 @@ document.body.dispatchEvent(click);
}
}
if (this.ghost && !this.decouplehead) {
- this.ghost.setHeadOrientation(this.head.orientation, true);
+ this.ghost.setHeadOrientation(_tmpquat.multiplyQuaternions(this.neck.orientation._target, this.head.orientation._target), true);
if (this.ghost._target.head) {
//this.ghost._target.face.position.copy(this.head.position);
- this.ghost.head.orientation.copy(this.head.orientation).invert();
+ this.ghost.head.orientation.copy(this.head.orientation).multiply(this.neck.orientation);;
}
}
}
@@ -510,10 +510,10 @@ document.body.dispatchEvent(click);
avatar_src: 'data:text/plain,' + encodeURIComponent(avatar),
showlabel: false,
//pos: V(0, -this.fatness, 0),
- rotation: V(0, 180, 0),
+ //rotation: V(0, 180, 0),
renderorder: 101,
});
- this.ghost.orientation.set(0,1,0,0);
+ //this.ghost.orientation.set(0,1,0,0);
}
});
this.visible = true;
@@ -702,7 +702,7 @@ document.body.dispatchEvent(click);
avatar_src: 'data:text/plain,' + encodeURIComponent(avatar),
showlabel: false,
//pos: V(0, -this.fatness, 0),
- rotation: V(0, 180, 0),
+ //rotation: V(0, 180, 0),
renderorder: 101,
});
@@ -1142,7 +1142,7 @@ document.body.dispatchEvent(click);
if (otherpos) {
var dir = thispos.clone().sub(otherpos).normalize();
this.properties.orientation.setFromEuler(new THREE.Euler(0, Math.atan2(dir.x, dir.z), 0));
- this.head.properties.orientation.setFromEuler(new THREE.Euler(-Math.asin(dir.y), 0, 0));
+ //this.head.properties.orientation.setFromEuler(new THREE.Euler(-Math.asin(dir.y), 0, 0));
this.refresh();
room.refresh();
this.engine.systems.render.setdirty();
diff --git a/scripts/multiplayermanager.js b/scripts/multiplayermanager.js
--- a/scripts/multiplayermanager.js
+++ b/scripts/multiplayermanager.js
@@ -177,7 +177,7 @@ console.log('[MultiplayerManager] set active room:', room, this.activeroom);
tmpMat.makeRotationFromQuaternion(player.properties.orientation);
tmpMat.extractBasis(tmpVecX, tmpVecY, tmpVecZ);
var ret = {
- dir: (-tmpVecZ.x) + ' ' + (-tmpVecZ.y) + ' ' + (-tmpVecZ.z),
+ dir: (tmpVecZ.x) + ' ' + (tmpVecZ.y) + ' ' + (tmpVecZ.z),
up_dir: '0 1 0',
//view_dir: this.tmpVecZ.toArray().join(' ')
};
-----END OF PAGE-----