diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-08 17:17:13 -0700 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2019-07-11 11:12:59 -0700 |
commit | 8780edb16563ac7d519091023a9ecf894c21fd0f (patch) | |
tree | 0768b81fc7feaadbe8351d187335dfe87790e313 /components/script/dom/xrspace.rs | |
parent | 104a712a28beef693d727170bf25684bb618e5aa (diff) | |
download | servo-8780edb16563ac7d519091023a9ecf894c21fd0f.tar.gz servo-8780edb16563ac7d519091023a9ecf894c21fd0f.zip |
Hook webxr data into XRFrame/XRView/XRSpace
Diffstat (limited to 'components/script/dom/xrspace.rs')
-rw-r--r-- | components/script/dom/xrspace.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/components/script/dom/xrspace.rs b/components/script/dom/xrspace.rs index 1614db9f6d4..ad76be52518 100644 --- a/components/script/dom/xrspace.rs +++ b/components/script/dom/xrspace.rs @@ -10,10 +10,9 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::globalscope::GlobalScope; use crate::dom::xrinputsource::XRInputSource; use crate::dom::xrreferencespace::XRReferenceSpace; -use crate::dom::xrsession::XRSession; +use crate::dom::xrsession::{ApiPose, XRSession}; use dom_struct::dom_struct; -use euclid::{RigidTransform3D, Rotation3D, Vector3D}; -use webvr_traits::{WebVRFrameData, WebVRPose}; +use webxr_api::Frame; #[dom_struct] pub struct XRSpace { @@ -58,30 +57,16 @@ impl XRSpace { /// The reference origin used is common between all /// get_pose calls for spaces from the same device, so this can be used to compare /// with other spaces - pub fn get_pose(&self, base_pose: &WebVRFrameData) -> RigidTransform3D<f64> { + pub fn get_pose(&self, base_pose: &Frame) -> ApiPose { if let Some(reference) = self.downcast::<XRReferenceSpace>() { reference.get_pose(base_pose) } else if let Some(source) = self.input_source.get() { - XRSpace::pose_to_transform(&source.pose()) + source.pose() } else { unreachable!() } } - pub fn pose_to_transform(pose: &WebVRPose) -> RigidTransform3D<f64> { - let pos = pose.position.unwrap_or([0., 0., 0.]); - let translation = Vector3D::new(pos[0] as f64, pos[1] as f64, pos[2] as f64); - let orient = pose.orientation.unwrap_or([0., 0., 0., 0.]); - let rotation = Rotation3D::quaternion( - orient[0] as f64, - orient[1] as f64, - orient[2] as f64, - orient[3] as f64, - ) - .normalize(); - RigidTransform3D::new(rotation, translation) - } - pub fn session(&self) -> &XRSession { &self.session } |