Thanks for your solution. It’s the only one I’ve found to rotate an object around it’s y-axis correcly and get the right Euler Angle. I’m using this calculated yaw
angle now to create a quaternion rotation like this:
var rotQuat = pc.Quat();
rotQuat.setFromEulerAngles(0.0 , yaw, 0.0);
The code for setFromEulerAngles is:
/**
* @function
* @name pc.Quat#setFromEulerAngles
* @description Sets a quaternion from Euler angles specified in XYZ order.
* @param {Number} ex Angle to rotate around X axis in degrees.
* @param {Number} ey Angle to rotate around Y axis in degrees.
* @param {Number} ez Angle to rotate around Z axis in degrees.
* @returns {pc.Quat} Self for chaining.
* @example
* var q = new pc.Quat();
* q.setFromEulerAngles(45, 90, 180);
*/
function setFromEulerAngles(ex, ey, ez) {
var sx, cx, sy, cy, sz, cz, halfToRad;
halfToRad = 0.5 * pc.math.DEG_TO_RAD;
ex *= halfToRad;
ey *= halfToRad;
ez *= halfToRad;
sx = Math.sin(ex);
cx = Math.cos(ex);
sy = Math.sin(ey);
cy = Math.cos(ey);
sz = Math.sin(ez);
cz = Math.cos(ez);
this.x = sx * cy * cz - cx * sy * sz;
this.y = cx * sy * cz + sx * cy * sz;
this.z = cx * cy * sz - sx * sy * cz;
this.w = cx * cy * cz + sx * sy * sz;
return this;
}
I’ve found it in the forum somewhere, but it works!
I have to admit, that I don’t get it but thanks again for your code (I even don’t get the problem, cause i’ve never had this problem in other game engines before).