Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update to use webxr_api::ViewerPose
  • Loading branch information
Manishearth committed May 18, 2020
1 parent 794624b commit a97dcd9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion components/script/dom/xrframe.rs
Expand Up @@ -85,11 +85,16 @@ impl XRFrameMethods for XRFrame {
} else {
return Ok(None);
};
let viewer_pose = if let Some(pose) = self.data.pose.as_ref() {
pose
} else {
return Ok(None);
};
Ok(Some(XRViewerPose::new(
&self.global(),
&self.session,
pose,
&self.data.views,
viewer_pose,
)))
}

Expand Down
8 changes: 5 additions & 3 deletions components/script/dom/xrreferencespace.rs
Expand Up @@ -113,7 +113,7 @@ impl XRReferenceSpace {
// get_viewer_pose(eye_level) = get_pose(eye_level).inverse() * get_pose(viewer_space)
// = I * viewer_pose
// = viewer_pose
let viewer_pose: ApiViewerPose = cast_transform(base_pose.transform?);
let viewer_pose: ApiViewerPose = cast_transform(base_pose.pose.as_ref()?.transform);

// we get viewer poses in eye-level space by default
Some(viewer_pose)
Expand All @@ -122,7 +122,7 @@ impl XRReferenceSpace {
// get_viewer_pose(floor_level) = get_pose(floor_level).inverse() * get_pose(viewer_space)
// = floor_to_native.inverse() * viewer_pose
// = native_to_floor * viewer_pose
let viewer_pose = base_pose.transform?;
let viewer_pose = base_pose.pose.as_ref()?.transform;
let native_to_floor = self
.upcast::<XRSpace>()
.session()
Expand Down Expand Up @@ -171,7 +171,9 @@ impl XRReferenceSpace {
.with_session(|s| s.floor_transform())?;
Some(cast_transform(native_to_floor.inverse()))
},
XRReferenceSpaceType::Viewer => base_pose.transform.map(cast_transform),
XRReferenceSpaceType::Viewer => {
Some(cast_transform(base_pose.pose.as_ref()?.transform))
},
_ => unimplemented!(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/xrviewerpose.rs
Expand Up @@ -17,7 +17,7 @@ use dom_struct::dom_struct;
use js::conversions::ToJSValConvertible;
use js::jsapi::Heap;
use js::jsval::{JSVal, UndefinedValue};
use webxr_api::Views;
use webxr_api::{ViewerPose, Views};

#[dom_struct]
pub struct XRViewerPose {
Expand All @@ -39,11 +39,11 @@ impl XRViewerPose {
global: &GlobalScope,
session: &XRSession,
pose: ApiViewerPose,
frame_views: &Views,
viewer_pose: &ViewerPose,
) -> DomRoot<XRViewerPose> {
let _ac = enter_realm(&*global);
rooted_vec!(let mut views);
match frame_views {
match &viewer_pose.views {
Views::Inline => views.push(XRView::new(
global,
session,
Expand Down

0 comments on commit a97dcd9

Please sign in to comment.