From 35e487934c0299c9a748add1fd7620a0ebf713c2 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 1 May 2026 07:20:55 +0300 Subject: [PATCH] fix: correct yaw recovery from view_direction vector view_dir = rotation * Z = (sin(yaw)*cos(pitch), -cos(yaw)*cos(pitch), sin(pitch)) so yaw = atan2(x, -y), not atan2(x, y). The sign error caused a 180-degree Z rotation on every save/reload cycle. Applies to apply_active_vport_camera, apply_sheet_viewport_camera, and camera_for_viewport. Co-Authored-By: Claude Sonnet 4.6 --- src/scene/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scene/mod.rs b/src/scene/mod.rs index f96ce58f7..d7c341c65 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -2400,7 +2400,7 @@ impl Scene { .normalize_or(glam::Vec3::Z); let pitch = vd.z.clamp(-0.999, 0.999).asin(); - let yaw = vd.x.atan2(vd.y); + let yaw = vd.x.atan2(-vd.y); let rotation = camera::yaw_pitch_to_quat(yaw, pitch); let view_right = rotation * glam::Vec3::X; let view_up = rotation * glam::Vec3::Y; @@ -2463,7 +2463,7 @@ impl Scene { .normalize_or(glam::Vec3::Z); let pitch = vd.z.clamp(-0.999, 0.999).asin(); - let yaw = vd.x.atan2(vd.y); + let yaw = vd.x.atan2(-vd.y); let rotation = camera::yaw_pitch_to_quat(yaw, pitch); let view_right = rotation * glam::Vec3::X; let view_up = rotation * glam::Vec3::Y; @@ -2721,7 +2721,7 @@ impl Scene { .normalize_or(glam::Vec3::Z); let pitch = vd.z.clamp(-0.999, 0.999).asin(); - let yaw = vd.x.atan2(vd.y); + let yaw = vd.x.atan2(-vd.y); let rotation = camera::yaw_pitch_to_quat(yaw, pitch); let view_right = rotation * glam::Vec3::X;