• Godot Help
  • Vector3D transforms requires to be normalized, even when normalized

mesh.rotate(Vector3(-mouse_pos.y, -mouse_pos.x, 0).normalized(), 5 * delta)
This line gives this error in the console:

E 0:00:01:0983   MeshControl.gd:19 @ _process(): The axis Vector3 must be normalized.
  <C++ Error>    Condition "!p_axis.is_normalized()" is true.
  <C++ Source>   core/math/basis.cpp:829 @ set_axis_angle()
  <Stack Trace>  MeshControl.gd:19 @ _process()

It is required to be normalized but I'm already doing so. Just in case I also did orthonormalize the transform after the rotation is applied:
mesh.transform = mesh.transform.orthonormalized()
Is this error a bug or am I overlooking something?

  • Check if your axis vector is not zero using Vector3::is_zero_approx()

Check if your axis vector is not zero using Vector3::is_zero_approx()

Alright, that was the problem. So the rotate function sends an error when applying a 0 rotation. I didn't know that. Thanks!

  • xyz replied to this.

    Lasbelin It's not a 0 rotation. It's an undefined (zero length) axis vector. Without a proper axis vector, the engine doesn't know around which axis to perform the rotation, so it throws an error.