diff --git a/webxr-api/Cargo.toml b/webxr-api/Cargo.toml index 4e7388c..d1e3b67 100644 --- a/webxr-api/Cargo.toml +++ b/webxr-api/Cargo.toml @@ -22,7 +22,7 @@ path = "lib.rs" ipc = ["serde", "typetag", "ipc-channel", "euclid/serde"] [dependencies] -euclid = "0.19" +euclid = "0.20" gleam = "0.6" ipc-channel = { version = "0.11", optional = true } serde = { version = "1.0", optional = true } diff --git a/webxr-api/device.rs b/webxr-api/device.rs index a2c947a..a4829b0 100644 --- a/webxr-api/device.rs +++ b/webxr-api/device.rs @@ -15,9 +15,9 @@ use crate::SessionMode; use crate::Viewport; use crate::Views; +use euclid::default::Size2D as UntypedSize2D; +use euclid::RigidTransform3D; use euclid::Size2D; -use euclid::TypedRigidTransform3D; -use euclid::TypedSize2D; use gleam::gl::GLsync; @@ -30,19 +30,19 @@ pub trait Discovery: 'static { /// A trait for using an XR device pub trait Device: 'static { /// The transform from native coordinates to the floor. - fn floor_transform(&self) -> TypedRigidTransform3D; + fn floor_transform(&self) -> RigidTransform3D; /// The transforms from viewer coordinates to the eyes, and their associated viewports. fn views(&self) -> Views; /// A resolution large enough to contain all the viewports. /// https://immersive-web.github.io/webxr/#native-webgl-framebuffer-resolution - fn recommended_framebuffer_resolution(&self) -> TypedSize2D { + fn recommended_framebuffer_resolution(&self) -> Size2D { let viewport = match self.views() { Views::Mono(view) => view.viewport, Views::Stereo(left, right) => left.viewport.union(&right.viewport), }; - TypedSize2D::new(viewport.max_x(), viewport.max_y()) + Size2D::new(viewport.max_x(), viewport.max_y()) } /// This method should block waiting for the next frame, @@ -52,7 +52,7 @@ pub trait Device: 'static { /// This method should render a GL texture to the device. /// While this method is being called, the device has unique access /// to the texture. The texture should be sync'd using glWaitSync before being used. - fn render_animation_frame(&mut self, texture_id: u32, size: Size2D, sync: GLsync); + fn render_animation_frame(&mut self, texture_id: u32, size: UntypedSize2D, sync: GLsync); /// Inputs registered with the device on initialization. More may be added, which /// should be communicated through a yet-undecided event mechanism diff --git a/webxr-api/frame.rs b/webxr-api/frame.rs index f96d1ef..e05f3a5 100644 --- a/webxr-api/frame.rs +++ b/webxr-api/frame.rs @@ -6,7 +6,7 @@ use crate::InputFrame; use crate::Native; use crate::Viewer; -use euclid::TypedRigidTransform3D; +use euclid::RigidTransform3D; /// The per-frame data that is provided by the device. /// https://www.w3.org/TR/webxr/#xrframe @@ -18,7 +18,7 @@ pub struct Frame { /// /// This is equivalent to the pose of the viewer in native coordinates. /// This is the inverse of the view matrix. - pub transform: TypedRigidTransform3D, + pub transform: RigidTransform3D, /// Frame information for each connected input source pub inputs: Vec, diff --git a/webxr-api/input.rs b/webxr-api/input.rs index 00d0da7..50f6e03 100644 --- a/webxr-api/input.rs +++ b/webxr-api/input.rs @@ -5,7 +5,7 @@ use crate::Input; use crate::Native; -use euclid::TypedRigidTransform3D; +use euclid::RigidTransform3D; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "ipc", derive(serde::Serialize, serde::Deserialize))] @@ -39,5 +39,5 @@ pub struct InputSource { #[cfg_attr(feature = "ipc", derive(serde::Serialize, serde::Deserialize))] pub struct InputFrame { pub id: InputId, - pub target_ray_origin: TypedRigidTransform3D, + pub target_ray_origin: RigidTransform3D, } diff --git a/webxr-api/mock.rs b/webxr-api/mock.rs index 63f2bc2..af72078 100644 --- a/webxr-api/mock.rs +++ b/webxr-api/mock.rs @@ -10,7 +10,7 @@ use crate::Receiver; use crate::Viewer; use crate::Views; -use euclid::TypedRigidTransform3D; +use euclid::RigidTransform3D; #[cfg(feature = "ipc")] use serde::{Deserialize, Serialize}; @@ -27,17 +27,17 @@ pub trait MockDiscovery: 'static { #[derive(Clone, Debug)] #[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))] pub struct MockDeviceInit { - pub floor_origin: TypedRigidTransform3D, + pub floor_origin: RigidTransform3D, pub supports_immersive: bool, pub supports_unbounded: bool, - pub viewer_origin: TypedRigidTransform3D, + pub viewer_origin: RigidTransform3D, pub views: Views, } #[derive(Debug)] #[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))] pub enum MockDeviceMsg { - SetViewerOrigin(TypedRigidTransform3D), + SetViewerOrigin(RigidTransform3D), SetViews(Views), Focus, Blur, diff --git a/webxr-api/session.rs b/webxr-api/session.rs index 455b782..e720976 100644 --- a/webxr-api/session.rs +++ b/webxr-api/session.rs @@ -14,8 +14,8 @@ use crate::Viewport; use crate::Views; use crate::WebGLExternalImageApi; -use euclid::TypedRigidTransform3D; -use euclid::TypedSize2D; +use euclid::RigidTransform3D; +use euclid::Size2D; use std::thread; use std::time::Duration; @@ -58,15 +58,15 @@ enum SessionMsg { /// https://www.w3.org/TR/webxr/#xrsession-interface #[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))] pub struct Session { - floor_transform: TypedRigidTransform3D, + floor_transform: RigidTransform3D, views: Views, - resolution: TypedSize2D, + resolution: Size2D, sender: Sender, initial_inputs: Vec, } impl Session { - pub fn floor_transform(&self) -> TypedRigidTransform3D { + pub fn floor_transform(&self) -> RigidTransform3D { self.floor_transform.clone() } @@ -78,7 +78,7 @@ impl Session { self.views.clone() } - pub fn recommended_framebuffer_resolution(&self) -> TypedSize2D { + pub fn recommended_framebuffer_resolution(&self) -> Size2D { self.resolution } diff --git a/webxr-api/view.rs b/webxr-api/view.rs index b93a64f..c5f8b2e 100644 --- a/webxr-api/view.rs +++ b/webxr-api/view.rs @@ -4,9 +4,9 @@ //! This crate uses `euclid`'s typed units, and exposes different coordinate spaces. -use euclid::TypedRect; -use euclid::TypedRigidTransform3D; -use euclid::TypedTransform3D; +use euclid::Rect; +use euclid::RigidTransform3D; +use euclid::Transform3D; #[cfg(feature = "ipc")] use serde::{Deserialize, Serialize}; @@ -68,9 +68,9 @@ pub enum Input {} #[derive(Clone, Debug)] #[cfg_attr(feature = "ipc", derive(Serialize, Deserialize))] pub struct View { - pub transform: TypedRigidTransform3D, - pub projection: TypedTransform3D, - pub viewport: TypedRect, + pub transform: RigidTransform3D, + pub projection: Transform3D, + pub viewport: Rect, } /// Whether a device is mono or stereo, and the views it supports. diff --git a/webxr-api/webgl.rs b/webxr-api/webgl.rs index 235fb58..843a519 100644 --- a/webxr-api/webgl.rs +++ b/webxr-api/webgl.rs @@ -5,7 +5,7 @@ //! The WebGL functionality needed by WebXR. use crate::Error; -use euclid::Size2D; +use euclid::default::Size2D; use gleam::gl::GLsync; use gleam::gl::GLuint; diff --git a/webxr/Cargo.toml b/webxr/Cargo.toml index cfd4165..23c320b 100644 --- a/webxr/Cargo.toml +++ b/webxr/Cargo.toml @@ -25,7 +25,7 @@ ipc = ["webxr-api/ipc"] [dependencies] webxr-api = { path = "../webxr-api" } -euclid = "0.19" +euclid = "0.20" gleam = "0.6" glutin = { version = "0.21", optional = true } log = "0.4" diff --git a/webxr/glwindow/mod.rs b/webxr/glwindow/mod.rs index e7ba47a..d7e18bb 100644 --- a/webxr/glwindow/mod.rs +++ b/webxr/glwindow/mod.rs @@ -2,15 +2,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use euclid::default::Size2D as UntypedSize2D; use euclid::Angle; +use euclid::Point2D; +use euclid::Rect; +use euclid::RigidTransform3D; use euclid::Size2D; +use euclid::Transform3D; use euclid::Trig; -use euclid::TypedPoint2D; -use euclid::TypedRect; -use euclid::TypedRigidTransform3D; -use euclid::TypedSize2D; -use euclid::TypedTransform3D; -use euclid::TypedVector3D; +use euclid::Vector3D; use gleam::gl; use gleam::gl::GLsizei; @@ -45,7 +45,7 @@ const FAR: f32 = 100.0; pub trait GlWindow { fn make_current(&mut self); fn swap_buffers(&mut self); - fn size(&self) -> Size2D; + fn size(&self) -> UntypedSize2D; fn new_window(&self) -> Result, ()>; } @@ -86,9 +86,9 @@ pub struct GlWindowDevice { } impl Device for GlWindowDevice { - fn floor_transform(&self) -> TypedRigidTransform3D { - let translation = TypedVector3D::new(-HEIGHT, 0.0, 0.0); - TypedRigidTransform3D::from_translation(translation) + fn floor_transform(&self) -> RigidTransform3D { + let translation = Vector3D::new(-HEIGHT, 0.0, 0.0); + RigidTransform3D::from_translation(translation) } fn views(&self) -> Views { @@ -99,15 +99,15 @@ impl Device for GlWindowDevice { fn wait_for_animation_frame(&mut self) -> Frame { self.window.swap_buffers(); - let translation = TypedVector3D::new(0.0, 0.0, -5.0); - let transform = TypedRigidTransform3D::from_translation(translation); + let translation = Vector3D::new(0.0, 0.0, -5.0); + let transform = RigidTransform3D::from_translation(translation); Frame { transform, inputs: vec![], } } - fn render_animation_frame(&mut self, texture_id: u32, size: Size2D, sync: GLsync) { + fn render_animation_frame(&mut self, texture_id: u32, size: UntypedSize2D, sync: GLsync) { self.window.make_current(); let width = size.width as GLsizei; @@ -168,18 +168,18 @@ impl GlWindowDevice { fn view(&self, is_right: bool) -> View { let window_size = self.window.size(); - let viewport_size = TypedSize2D::new(window_size.width / 2, window_size.height); + let viewport_size = Size2D::new(window_size.width / 2, window_size.height); let viewport_x_origin = if is_right { viewport_size.width } else { 0 }; - let viewport_origin = TypedPoint2D::new(viewport_x_origin, 0); - let viewport = TypedRect::new(viewport_origin, viewport_size); + let viewport_origin = Point2D::new(viewport_x_origin, 0); + let viewport = Rect::new(viewport_origin, viewport_size); let projection = self.perspective(NEAR, FAR); let eye_distance = if is_right { EYE_DISTANCE } else { -EYE_DISTANCE }; - let translation = TypedVector3D::new(eye_distance, 0.0, 0.0); - let transform = TypedRigidTransform3D::from_translation(translation); + let translation = Vector3D::new(eye_distance, 0.0, 0.0); + let transform = RigidTransform3D::from_translation(translation); View { transform, projection, @@ -187,7 +187,7 @@ impl GlWindowDevice { } } - fn perspective(&self, near: f32, far: f32) -> TypedTransform3D { + fn perspective(&self, near: f32, far: f32) -> Transform3D { // https://github.com/toji/gl-matrix/blob/bd3307196563fbb331b40fc6ebecbbfcc2a4722c/src/mat4.js#L1271 let size = self.window.size(); let width = size.width as f32; @@ -201,7 +201,7 @@ impl GlWindowDevice { { #[rustfmt::skip] // Sigh, row-major vs column-major - return TypedTransform3D::row_major( + return Transform3D::row_major( f / aspect, 0.0, 0.0, 0.0, 0.0, f, 0.0, 0.0, 0.0, 0.0, (far + near) * nf, -1.0, diff --git a/webxr/headless/mod.rs b/webxr/headless/mod.rs index f408c20..f9692ee 100644 --- a/webxr/headless/mod.rs +++ b/webxr/headless/mod.rs @@ -19,8 +19,8 @@ use webxr_api::SessionMode; use webxr_api::Viewer; use webxr_api::Views; -use euclid::Size2D; -use euclid::TypedRigidTransform3D; +use euclid::default::Size2D; +use euclid::RigidTransform3D; use gleam::gl; use gleam::gl::GLsync; @@ -41,8 +41,8 @@ struct HeadlessDiscovery { struct HeadlessDevice { gl: Rc, - floor_transform: TypedRigidTransform3D, - viewer_origin: TypedRigidTransform3D, + floor_transform: RigidTransform3D, + viewer_origin: RigidTransform3D, views: Views, receiver: Receiver, } @@ -88,7 +88,7 @@ impl Discovery for HeadlessDiscovery { } impl Device for HeadlessDevice { - fn floor_transform(&self) -> TypedRigidTransform3D { + fn floor_transform(&self) -> RigidTransform3D { self.floor_transform.clone() }