diff --git a/src/scene/pipeline/viewcube.rs b/src/scene/pipeline/viewcube.rs index e9868a215..f5d0e3c38 100644 --- a/src/scene/pipeline/viewcube.rs +++ b/src/scene/pipeline/viewcube.rs @@ -10,6 +10,7 @@ // with arcball orbit at all angles. use bytemuck::{Pod, Zeroable}; +use glam::camera::rh::proj::directx::orthographic; use glam::{Mat4, Vec3, Vec4}; use iced::wgpu; use iced::{Rectangle, Size}; @@ -208,7 +209,7 @@ impl CubeUniforms { let inset = cube_half * NAV_INSET_F; let cx = hw - inset - VIEWCUBE_PAD; let cy = hh - inset - VIEWCUBE_PAD; - let view_proj = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0) + let view_proj = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0) * Mat4::from_translation(Vec3::new(cx, cy, 0.0)) * Mat4::from_scale(Vec3::splat(cube_px as f32 * VIEWCUBE_SCALE)); Self { @@ -580,7 +581,7 @@ impl ViewCubeText { let cube_half = cube_px as f32 * VIEWCUBE_SCALE; let inset = cube_half * NAV_INSET_F; let (hw, hh) = (vw * 0.5, vh * 0.5); - let view_proj = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0) + let view_proj = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0) * Mat4::from_translation(Vec3::new( hw - inset - VIEWCUBE_PAD, hh - inset - VIEWCUBE_PAD, @@ -1349,7 +1350,7 @@ pub fn hit_test( } let (hw, hh) = (vp_w * 0.5, vp_h * 0.5); - let vp = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0) + let vp = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0) * Mat4::from_translation(Vec3::new( hw - inset - VIEWCUBE_PAD, hh - inset - VIEWCUBE_PAD, @@ -1431,7 +1432,7 @@ pub fn hit_test_cardinal( } let (hw, hh) = (vp_w * 0.5, vp_h * 0.5); - let vp = Mat4::orthographic_rh(-hw, hw, -hh, hh, -2000.0, 2000.0) + let vp = orthographic(-hw, hw, -hh, hh, -2000.0, 2000.0) * Mat4::from_translation(Vec3::new( hw - inset - VIEWCUBE_PAD, hh - inset - VIEWCUBE_PAD, diff --git a/src/scene/view/camera.rs b/src/scene/view/camera.rs index 6e098b6b8..bf5d2f3b9 100644 --- a/src/scene/view/camera.rs +++ b/src/scene/view/camera.rs @@ -11,6 +11,8 @@ // // Coordinate convention: Z-up world space (same as the rest of OpenCADStudio). +use glam::camera::rh::proj::directx::{orthographic, perspective}; +use glam::camera::rh::view::look_at_mat4; use glam::{DVec3, Mat4, Quat, Vec3}; use iced::{Point, Rectangle}; @@ -126,19 +128,19 @@ impl Camera { let aspect = bounds.width / bounds.height; let up_dir = self.rotation * Vec3::Y; - let mut view = Mat4::look_at_rh(self.eye().as_vec3(), self.target.as_vec3(), up_dir); + let mut view = look_at_mat4(self.eye().as_vec3(), self.target.as_vec3(), up_dir); // Zero the translation column → pure rotation (world→view basis). view.w_axis = glam::vec4(0.0, 0.0, 0.0, 1.0); let proj = match self.projection { Projection::Perspective => { - Mat4::perspective_rh(self.fov_y, aspect, self.distance * 0.001, self.distance * 1000.0) + perspective(self.fov_y, aspect, self.distance * 0.001, self.distance * 1000.0) } Projection::Orthographic => { let h = self.ortho_size(); let w = h * aspect; let (near, far) = self.ortho_depth_range(); - Mat4::orthographic_rh(-w, w, -h, h, near, far) + orthographic(-w, w, -h, h, near, far) } }; OPENGL_TO_WGPU * proj * view