Skip to content

Commit

Permalink
fix(quaternion): correct return type
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Sep 29, 2019
1 parent 3571dfa commit 431901f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/quaternion.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ class AQuaternion {
}

get left() {
return this.appyVector(LEFT);
return this.multiplyVector(LEFT);
}

get dir() {
return this.appyVector(FORWARD);
return this.multiplyVector(FORWARD);
}

get up() {
return this.appyVector(UP);
return this.multiplyVector(UP);
}

/**
Expand Down Expand Up @@ -328,15 +328,15 @@ function fromCache(scope, key, fn) {

export class IQuaternion extends AQuaternion {
get left() {
return fromCache(this, LEFT_CACHE, () => this.appyVector(LEFT));
return fromCache(this, LEFT_CACHE, () => this.multiplyVector(LEFT));
}

get dir() {
return fromCache(this, FORWARD_CACHE, () => this.appyVector(FORWARD));
return fromCache(this, FORWARD_CACHE, () => this.multiplyVector(FORWARD));
}

get up() {
return fromCache(this, UP_CACHE, () => this.appyVector(UP));
return fromCache(this, UP_CACHE, () => this.multiplyVector(UP));
}
}

Expand Down Expand Up @@ -392,15 +392,18 @@ const LEFT90 = new IQuaternion(LEFT, degree(90));
* @returns {IQuaternion}
*/
export function fromOrientation({ alpha, beta, gamma }, orientation) {
let rot = new IQuaternion(fromEulerYXZ(degree(beta), degree(alpha), degree(-gamma)));
rot.multiplyQuaternion(LEFT90);
const x = degree(beta);
const y = degree(alpha);
const z = degree(-gamma);
let rot = new IQuaternion(fromEulerYXZ(x, y, z));
rot = rot.multiplyQuaternion(LEFT90);

if (orientation) {
const { dir } = rot;
const local = new IQuaternion(dir, degree(orientation));
rot = local.multiplyQuaternion(rot);
}
return rot[AXES];
return rot;
}

export const Export = {
Expand Down

0 comments on commit 431901f

Please sign in to comment.