allow setting base layer

This commit is contained in:
Manish Goregaokar 2018-12-20 15:44:26 -08:00
parent d5911816e1
commit 682c89a18c
3 changed files with 18 additions and 4 deletions

View file

@ -74,6 +74,8 @@ pub struct VRDisplay {
running_display_raf: Cell<bool>,
paused: Cell<bool>,
stopped_on_pause: Cell<bool>,
/// Whether or not this is XR mode
xr: Cell<bool>,
}
unsafe_no_jsmanaged_fields!(WebVRDisplayData);
@ -129,6 +131,7 @@ impl VRDisplay {
// This flag is set when the Display was presenting when it received a VR Pause event.
// When the VR Resume event is received and the flag is set, VR presentation automatically restarts.
stopped_on_pause: Cell::new(false),
xr: Cell::new(false),
}
}

View file

@ -18,7 +18,7 @@ enum XREnvironmentBlendMode {
attribute double depthNear;
attribute double depthFar;
// attribute XRLayer baseLayer;
attribute XRLayer? baseLayer;
// // Methods
// Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type, optional XRReferenceSpaceOptions options);

View file

@ -7,10 +7,11 @@ use crate::dom::bindings::codegen::Bindings::XRSessionBinding;
use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods;
use crate::dom::bindings::num::Finite;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::vrdisplay::VRDisplay;
use crate::dom::xrlayer::XRLayer;
use dom_struct::dom_struct;
use std::cell::Cell;
@ -20,6 +21,7 @@ pub struct XRSession {
display: Dom<VRDisplay>,
depth_near: Cell<f64>,
depth_far: Cell<f64>,
base_layer: MutNullableDom<XRLayer>,
}
impl XRSession {
@ -29,6 +31,7 @@ impl XRSession {
display: Dom::from_ref(display),
depth_near: Cell::new(0.1),
depth_far: Cell::new(1000.),
base_layer: Default::default(),
}
}
@ -61,4 +64,12 @@ impl XRSessionMethods for XRSession {
fn Mode(&self) -> XRSessionMode {
XRSessionMode::Immersive_vr
}
fn SetBaseLayer(&self, layer: Option<&XRLayer>) {
self.base_layer.set(layer)
}
fn GetBaseLayer(&self) -> Option<DomRoot<XRLayer>> {
self.base_layer.get()
}
}