Skip to content
Permalink
Browse files

Expose targetRayMode

  • Loading branch information
Manishearth committed Jan 8, 2020
1 parent 11e8823 commit 7046f543a1875ab419d30fad8cc33333e92e4373
Showing with 12 additions and 3 deletions.
  1. +1 −1 components/script/dom/webidls/XRInputSource.webidl
  2. +11 −2 components/script/dom/xrinputsource.rs
@@ -19,7 +19,7 @@ enum XRTargetRayMode {
[SecureContext, Exposed=Window, Pref="dom.webxr.enabled"]
interface XRInputSource {
readonly attribute XRHandedness handedness;
// [SameObject] readonly attribute XRTargetRayMode targetRayMode;
readonly attribute XRTargetRayMode targetRayMode;
[SameObject] readonly attribute XRSpace targetRaySpace;
[SameObject] readonly attribute XRSpace? gripSpace;
// [SameObject] readonly attribute Gamepad? gamepad;
@@ -4,15 +4,15 @@

use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding;
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
XRHandedness, XRInputSourceMethods,
XRHandedness, XRInputSourceMethods, XRTargetRayMode,
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use crate::dom::globalscope::GlobalScope;
use crate::dom::xrsession::XRSession;
use crate::dom::xrspace::XRSpace;
use dom_struct::dom_struct;
use webxr_api::{Handedness, InputId, InputSource};
use webxr_api::{Handedness, InputId, InputSource, TargetRayMode};

#[dom_struct]
pub struct XRInputSource {
@@ -64,6 +64,15 @@ impl XRInputSourceMethods for XRInputSource {
}
}

/// https://immersive-web.github.io/webxr/#dom-xrinputsource-targetraymode
fn TargetRayMode(&self) -> XRTargetRayMode {
match self.info.target_ray_mode {
TargetRayMode::Gaze => XRTargetRayMode::Gaze,
TargetRayMode::TrackedPointer => XRTargetRayMode::Tracked_pointer,
TargetRayMode::Screen => XRTargetRayMode::Screen,
}
}

/// https://immersive-web.github.io/webxr/#dom-xrinputsource-targetrayspace
fn TargetRaySpace(&self) -> DomRoot<XRSpace> {
self.target_ray_space.or_init(|| {

0 comments on commit 7046f54

Please sign in to comment.
You can’t perform that action at this time.