getEulerAngles returning strange result

I’m trying to get the Euler angles of a camera placed in the scene, but it’s giving me back a strange result.

The Euler angles on the entity in the scene are: {9.35, 180, 0}

If I write getEulerAngles() to the console I get this result: {-170.65, 7.016, 180}

Here’s the test project showing the issue: https://playcanvas.com/editor/scene/1157301

What’s going on here?

Euler Angles are not store as is, but instead derived from the transformation matrix through trigonometry. What you set is not necessary will get back out because of this.

The same rotation can be represented two different ways. For example, something that rotated 190 on the Y axis looks the same as being rotated -170 degrees on the Y axis.

I get what you’re saying, and it wouldn’t be an issue if it amounted to the same rotation represented in different ways, but if I use the result of getEulerAngles to set another camera’s rotation, it’s a different result - the camera is looking in a different direction.
I can hack my way around it, so it’s not a deal-breaker, just strange.

Oh that’s a different issue. If you can supply a reproducible of the issue, the forum community can take a look.

The project above doesn’t show this issue.