Short answer:
rotation()
takes up to three angles in Vector3 format. rotate_x()
takes one. So rotation()
is rotate_x()
, rotate_y()
, rotate_z()
combined.
As you used them, they're the same.
Long answer:
rotation()
contains 3 matrices (one for x, y and z). These matrices contain take the sine / cosine of your angle for that axis and multiply it by the obj's basis matrix, transforming it.
In English: it takes a Vector3 which isn't a vector but a container for the 3 angles you want to rotate. If you send Vector3(3, 2, 1)
then it'll rotate 3 radians on the x, 2 on the y, etc. (I'd encourage you to abandon degrees btw, expense for no gain) It'll multiply the result to the basis of you object. So if you have IDENTITY basis on head and you send PI on the y, it'll face the other way.
rotation.y = PI
and rotation(Vector3(0, PI, 0))
are equivalent.
You need this because the order you do Euler rotations in matters, rotating y then z will not leave you in the same position as z then y. Euler rotations can be like rubik's cubes, undoing what you've done can get tricky if you're not careful.
I'd strong recommend you read through this to understand the nuances of Euler transforms as it tackles your question:
https://docs.godotengine.org/en/stable/tutorials/3d/using_transforms.html
Hope it helps.