Skip to content

Commit 7d33e4b

Browse files
committed
fix(playcanvas): correct usage of fromEulerYXZ
1 parent 431901f commit 7d33e4b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/adapter/playcanvas.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,26 @@ export function hijackPlayCanvas(pc) {
7373
return new Quat().setFromMat4(new Mat4().setLookAt(Vec3.ZERO, x, y || Vec3.UP));
7474
});
7575

76+
Quat.prototype.multiplyQuaternion = function (other) {
77+
return this.clone().mul(other);
78+
};
79+
7680
const LEFT90 = pc.quat(Vec3.LEFT, 90);
7781

7882
Quat.prototype.setFromOrientation = function ({ alpha, beta, gamma }, orientation) {
7983
const x = beta * math.DEG_TO_RAD;
8084
const y = alpha * math.DEG_TO_RAD;
8185
const z = -gamma * math.DEG_TO_RAD;
82-
let rot = pc.quat(fromEulerYXZ(x, y, z));
83-
rot.mul(LEFT90);
86+
let rot = pc.quat(...fromEulerYXZ(x, y, z));
87+
rot = rot.multiplyQuaternion(LEFT90);
8488

8589
if (orientation) {
8690
const { dir } = rot;
8791
const local = pc.quat(dir, orientation);
88-
rot = local.mul(rot);
92+
rot = local.multiplyQuaternion(rot);
8993
}
9094
this.copy(rot);
95+
return this;
9196
};
9297
}
9398

0 commit comments

Comments
 (0)