Applying two angles to a 3D rotation

Godot Version

4.3

Question

I’m a beginner!
I have two angles that I want to rotate my Node3D around. One for the X axis and the other for the Y axis. Both work correctly if applied independently, without the other. However, when applying both of them, the result is wrong. Pseudo code:

# Works
my_node.rotation.x = angle_x
#my_node.rotation.y = angle_y

# Works too
#my_node.rotation.x = angle_x
my_node.rotation.y = angle_y

# Does not work: the final rotation is wrong
my_node.rotation.x = angle_x
my_node.rotation.y = angle_y

I thought maybe I need to multiply two quats to have one single rotation, so I’ve tried this:

var x = Quaternion(Vector3(1, 0, 0), angle_x)
var y = Quaternion(Vector3(0, 1, 0), angle_y)
my_node.quaternion = y * x

…but it leads to the exact same result.

It looks like the two rotations influence each other in a way that the second rotation rotates the node with the first rotation already applied. But I think I need the opposite: I want to apply the rotation from some kind of global or world perspective where it does not matter if and how much the node is already rotated.

But being a beginner I lack the correct terms to express what I want in order to find the correct functionality. Therefore I’ll ask in the simplest way possible for me:
How can I apply those two angles in a way that they don’t influence each other?

Thanks a lot!

Are you sure you chose the correct angles?
If you’re applying the rotation direction to the rotation property, then the order of rotation, Quaternions and all that lovely stuff shouldn’t matter.
Can you show a screenshot with a cube or something that shows your desired effect vs what you get with your code?

I’ve fixed the rotation by making the object a child of a parent and rotate this parent using look_at() instead. This leads to the results I was expecting.

Yes, the angles are correct, because when viewed from orthogonal perspective, both of them are precisely aligned with the grid, when applied isolated. Only when both of them are applied, regardless the order, the results are slightly wrong in that they aren’t exactly on the grid anymore. The look_at() method however does.

Therefore my problem is solved but I still don’t know how two “2D” angles can be applied in a way that they don’t affect each other. Maybe they can’t after all because that just not how rotations in 3D work.