Quaternion's euler angles don't match the 'setFromEulerAngles' params

hi guys!

i have a serious problem when setting a rotation of my entities via eulerangles. this is easily reproducible. is there something i don’t get or is this a bug?

var requiredAngle = 100;
var x = new pc.Quat();
x.setFromEulerAngles(0, requiredAngle, 0):
x.getEulerAngles().y; //80

why would getEulerAngles().y return 80 if i set it to 100? i mean, if i look at the whole eulervector, it’s 180/80/180, but this doesn’t help me. especially if i set the y-rotation of an entity from eulerangles to 180°, the entity doesn’t rotate at!

Because you’re ignoring the other two Euler components. X and/or Z components may no longer be zero. But the returned Eulers will be the equivalent rotation…

yeah they are, but it in fact it isn’t really the same rotation, it just looks the same. if in the next update, i were to be using the very same y-rotation-value i used before, and calculate a difference, i would get a completely different result because i’d have to respect the other two axis too, although they have never been edited. this is kinda annoying if i have a top-down game where no x- and z- rotation exists and i do everything with the y-axis. all other rotation values should be 0

setFromEulerAngles doesn’t store the euler angles, it converts to the quaternion representation. So when getEulerAngles is called, it has to convert it back to euler angles which isn’t guaranteed to be the same values but is the same representation of orientation. It’s impossible to go euler -> quat -> euler and guarantee the same values in and out without it being stored internally.

If you need to only work with the y-axis, then I would store the y-rotation in the script and set the rotation of the entity every frame.