3 #include <glm/gtx/rotate_vector.hpp>
11 , orientation(0.52359877559829887307f, 0.0f) { // π/6
15 glm::mat4 Camera::View() const noexcept {
16 // zero yaw is into the screen, so -Z is the base view direction we're transforming from
17 // pitch needs to be inverted because we're projecting the distance back
18 const glm::vec3 position(focus - distance * rotateY(rotateX(glm::vec3(0.0f, 0.0f, -1.0f), -orientation.x), orientation.y));
19 return glm::lookAt(position, focus, glm::vec3(0.0f, 1.0f, 0.0f));
22 void Camera::Move(const glm::vec3 &delta) noexcept {
23 focus += rotateY(delta, orientation.y);
26 void Camera::Rotate(const glm::vec2 &delta) noexcept {
28 orientation.x = glm::clamp(orientation.x, -1.55f, 1.55f);
29 while (orientation.y > 3.14159265358979323844f) { // π
30 orientation.y -= 6.28318530717958647688f; // 2π
32 while (orientation.y < -3.14159265358979323844f) {
33 orientation.y += 6.28318530717958647688f;