Skip to main content
2 of 3
deleted 27 characters in body
Maik Semder
  • 4.7k
  • 1
  • 28
  • 24

LOOK_UP and LOOK_DOWN must rotate around the x-axis, not around the y-axis.

ROTATE_RIGHT and ROTATE_LEFT must rotate around the y-axis, not around the x-axis.

Immediately rotating around 90 degrees or initializing your angles with 90 degrees will bring your system into a Gimbal Lock state, resulting in weird rotations. You might want to use smaller angles and step-sizes for starters, particulary not 90 degrees or multiples of it.

Initialize all angles with 0 and start from there:

    // init your angles at startup, i.e. main or camera constructor
    player.camera.rotation.x = 0.0;
    player.camera.rotation.y = 0.0;
    player.camera.rotation.z = 0.0;

    // change the step-size and rotation-axis like this:
    case LOOK_UP:
        player.camera.rotation.x+=5.0;
        break;
    case ROTATE_LEFT:
        player.camera.rotation.y-=5.0;
        break;
    case LOOK_DOWN:
        player.camera.rotation.x-=5.0;
        break;
    case ROTATE_RIGHT:
        player.camera.rotation.y+=5.0;
        break;
Maik Semder
  • 4.7k
  • 1
  • 28
  • 24