Skip to content

Commit

Permalink
Add XRFrame::getHitTestResults()
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Apr 20, 2020
1 parent 87bce8c commit f1d6a89
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/script/dom/webidls/XRFrame.webidl
Expand Up @@ -10,5 +10,5 @@ interface XRFrame {

[Throws] XRViewerPose? getViewerPose(XRReferenceSpace referenceSpace);
[Throws] XRPose? getPose(XRSpace space, XRSpace relativeTo);
// XRInputPose? getInputPose(XRInputSource inputSource, optional XRReferenceSpace referenceSpace);
sequence<XRHitTestResult> getHitTestResults(XRHitTestSource hitTestSource);
};
12 changes: 12 additions & 0 deletions components/script/dom/xrframe.rs
Expand Up @@ -8,6 +8,8 @@ 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::xrhittestresult::XRHitTestResult;
use crate::dom::xrhittestsource::XRHitTestSource;
use crate::dom::xrpose::XRPose;
use crate::dom::xrreferencespace::XRReferenceSpace;
use crate::dom::xrsession::{ApiPose, XRSession};
Expand Down Expand Up @@ -109,4 +111,14 @@ impl XRFrameMethods for XRFrame {
let pose = relative_to.inverse().pre_transform(&space);
Ok(Some(XRPose::new(&self.global(), pose)))
}

/// https://immersive-web.github.io/hit-test/#dom-xrframe-gethittestresults
fn GetHitTestResults(&self, source: &XRHitTestSource) -> Vec<DomRoot<XRHitTestResult>> {
self.data
.hit_test_results
.iter()
.filter(|r| r.id == source.id())
.map(|r| XRHitTestResult::new(&self.global(), *r, self))
.collect()
}
}
4 changes: 4 additions & 0 deletions components/script/dom/xrhittestsource.rs
Expand Up @@ -37,6 +37,10 @@ impl XRHitTestSource {
global,
)
}

pub fn id(&self) -> HitTestId {
self.id
}
}

impl XRHitTestSourceMethods for XRHitTestSource {
Expand Down

0 comments on commit f1d6a89

Please sign in to comment.