Skip to content

Commit

Permalink
fix(playcanvas): correct usage of fromEulerYXZ
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Sep 29, 2019
1 parent 431901f commit 7d33e4b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/adapter/playcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,26 @@ export function hijackPlayCanvas(pc) {
return new Quat().setFromMat4(new Mat4().setLookAt(Vec3.ZERO, x, y || Vec3.UP));
});

Quat.prototype.multiplyQuaternion = function (other) {
return this.clone().mul(other);
};

const LEFT90 = pc.quat(Vec3.LEFT, 90);

Quat.prototype.setFromOrientation = function ({ alpha, beta, gamma }, orientation) {
const x = beta * math.DEG_TO_RAD;
const y = alpha * math.DEG_TO_RAD;
const z = -gamma * math.DEG_TO_RAD;
let rot = pc.quat(fromEulerYXZ(x, y, z));
rot.mul(LEFT90);
let rot = pc.quat(...fromEulerYXZ(x, y, z));
rot = rot.multiplyQuaternion(LEFT90);

if (orientation) {
const { dir } = rot;
const local = pc.quat(dir, orientation);
rot = local.mul(rot);
rot = local.multiplyQuaternion(rot);
}
this.copy(rot);
return this;
};
}

Expand Down

0 comments on commit 7d33e4b

Please sign in to comment.