Skip to content

Commit

Permalink
Makes avatar move based on the matrixWorld of the camera, in case the…
Browse files Browse the repository at this point in the history
… camera is a child object
  • Loading branch information
AlbertoElias committed Aug 24, 2018
1 parent cc84f62 commit 5ca8384
Show file tree
Hide file tree
Showing 19 changed files with 142,826 additions and 901 deletions.
47,861 changes: 47,578 additions & 283 deletions build/simbol.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/simbol.cjs.js.map

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions build/simbol.cjs.nothree.js
Original file line number Diff line number Diff line change
Expand Up @@ -92275,7 +92275,7 @@ class VirtualPersona extends eventemitter3 {
* @returns {Promise} promise - Promise that resolves when the mesh loads
*/
init() {
return this.loadMesh(this.identity.avatarPath, true)
return this.loadMesh("assets/models/AnonymousVP.glb", true)
.then(() => {
if (this.config.signIn && !this.identity.signedIn) {
return this.signIn();
Expand Down Expand Up @@ -93096,7 +93096,7 @@ class Scene {
for (const child of mesh.children) {
this._setupMeshes(child, collidable, shadow);
}
} else if (mesh.isObject3D) {
} else if (mesh.isMesh) {
mesh.geometry && mesh.geometry.computeFaceNormals();
if (shadow) {
mesh.castShadow = true;
Expand Down Expand Up @@ -95688,6 +95688,9 @@ Simbol.prototype.animate = (function() {
const previousControllerQuaternion = new THREE.Quaternion();
previousControllerQuaternion.initialised = false;
const translationDirection = new THREE.Vector3();
const meshPosition = new THREE.Vector3();
const meshQuaternion = new THREE.Quaternion();
const meshRotation = new THREE.Euler();
let previousTime = 0;
let delta = 0;

Expand Down Expand Up @@ -95772,19 +95775,22 @@ Simbol.prototype.animate = (function() {
camera.rotation.order = 'YXZ';
camera.position.add(this.virtualPersona.fakeCamera.position);
camera.quaternion.copy(this.virtualPersona.fakeCamera.quaternion);

this.vpMesh.rotation.y = camera.rotation.y + Math.PI;
} else if (this.locomotion) {
this.vpMesh.rotation.y = this.locomotion.orientation.euler.y + Math.PI;
camera.rotation.order = 'XYZ';
camera.rotation.copy(this.locomotion.orientation.euler);
}

// Adjust the mesh's position
this.vpMesh.position.copy(camera.position);
const meshYPosition = camera.position.y - this.virtualPersona._meshHeight;
// Adjust the mesh's position and rotation
camera.matrixWorld.decompose(meshPosition, meshQuaternion, {});
this.vpMesh.position.copy(meshPosition);
const meshYPosition = meshPosition.y - this.virtualPersona._meshHeight;
this.vpMesh.position.setY(meshYPosition);

meshRotation.setFromQuaternion(meshQuaternion, 'YXZ');
console.log(meshRotation.y, camera.rotation.y);
// this.vpMesh.rotation.y = camera.rotation.y + Math.PI;
this.vpMesh.rotation.y = meshRotation.y + Math.PI;

// MultiVP
if (this.virtualPersona.multiVP) {
this.virtualPersona.multiVP.sendData(this.vpMesh);
Expand Down
2 changes: 1 addition & 1 deletion build/simbol.cjs.nothree.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 5ca8384

Please sign in to comment.