Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some XRSpace improvements #23055

Merged
merged 8 commits into from Mar 21, 2019
Prev

Improve getViewerPose()

  • Loading branch information
Manishearth committed Mar 21, 2019
commit 22e5ce5ff3bee330cb8e934f99311b4f474ac241
@@ -8,6 +8,6 @@
interface XRFrame {
readonly attribute XRSession session;

XRViewerPose? getViewerPose(optional XRReferenceSpace referenceSpace);
XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace);
// XRInputPose? getInputPose(XRInputSource inputSource, optional XRReferenceSpace referenceSpace);
};
@@ -5,11 +5,13 @@
use crate::dom::bindings::codegen::Bindings::XRFrameBinding;
use crate::dom::bindings::codegen::Bindings::XRFrameBinding::XRFrameMethods;
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::globalscope::GlobalScope;
use crate::dom::xrreferencespace::XRReferenceSpace;
use crate::dom::xrsession::XRSession;
use crate::dom::xrstationaryreferencespace::XRStationaryReferenceSpace;
use crate::dom::xrview::XRView;
use crate::dom::xrviewerpose::XRViewerPose;
use dom_struct::dom_struct;
@@ -52,17 +54,17 @@ impl XRFrameMethods for XRFrame {
}

/// https://immersive-web.github.io/webxr/#dom-xrframe-getviewerpose
fn GetViewerPose(&self, reference: Option<&XRReferenceSpace>) -> Option<DomRoot<XRViewerPose>> {
// We assume the reference space is eye level for now
// since it's the only one 3DOF devices support
if reference.is_some() {
// it's not possible to obtain a reference
// space at all yet
None
} else {
fn GetViewerPose(&self, reference: &XRReferenceSpace) -> Option<DomRoot<XRViewerPose>> {
if let Some(_) = reference.downcast::<XRStationaryReferenceSpace>() {
// For 3DOF devices all three kinds of reference spaces are identical
// FIXME(#23070, Manishearth) support originOffset
let left = XRView::new(&self.global(), &self.session, XREye::Left, &self.data);
let right = XRView::new(&self.global(), &self.session, XREye::Right, &self.data);
Some(XRViewerPose::new(&self.global(), &left, &right))
} else {
// FIXME(#23070, Manishearth) support identity reference spaces
// depends on https://github.com/immersive-web/webxr/issues/565
None
}
}
}
@@ -124,6 +124,9 @@ impl XRSessionMethods for XRSession {

// https://immersive-web.github.io/webxr/#create-a-reference-space

// XXXManishearth reject based on session type
// https://github.com/immersive-web/webxr/blob/master/spatial-tracking-explainer.md#practical-usage-guidelines

match options.type_ {
XRReferenceSpaceType::Identity => {
p.resolve_native(&XRReferenceSpace::identity(
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.