Skip to content

Commit

Permalink
Make viewerSpace [SameObject]
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed May 4, 2019
1 parent d4a6a49 commit 0756923
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/webidls/XRSession.webidl
Expand Up @@ -20,7 +20,7 @@ interface XRSession : EventTarget {
readonly attribute XREnvironmentBlendMode environmentBlendMode;

readonly attribute XRRenderState renderState;
readonly attribute XRSpace viewerSpace;
[SameObject] readonly attribute XRSpace viewerSpace;

// // Methods
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options);
Expand Down
5 changes: 4 additions & 1 deletion components/script/dom/xrsession.rs
Expand Up @@ -34,6 +34,7 @@ pub struct XRSession {
display: Dom<VRDisplay>,
base_layer: MutNullableDom<XRLayer>,
blend_mode: XREnvironmentBlendMode,
viewer_space: MutNullableDom<XRSpace>,
}

impl XRSession {
Expand All @@ -44,6 +45,7 @@ impl XRSession {
base_layer: Default::default(),
// we don't yet support any AR devices
blend_mode: XREnvironmentBlendMode::Opaque,
viewer_space: Default::default(),
}
}

Expand Down Expand Up @@ -87,7 +89,8 @@ impl XRSessionMethods for XRSession {

// https://immersive-web.github.io/webxr/#dom-xrsession-viewerspace
fn ViewerSpace(&self) -> DomRoot<XRSpace> {
XRSpace::new_viewerspace(&self.global(), &self)
self.viewer_space
.or_init(|| XRSpace::new_viewerspace(&self.global(), &self))
}

/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
Expand Down

0 comments on commit 0756923

Please sign in to comment.