mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Hook XRRenderState into XRSession
This commit is contained in:
parent
1dc7636135
commit
401b470e90
4 changed files with 12 additions and 41 deletions
|
@ -14,4 +14,4 @@ dictionary XRRenderStateInit {
|
||||||
readonly attribute double depthNear;
|
readonly attribute double depthNear;
|
||||||
readonly attribute double depthFar;
|
readonly attribute double depthFar;
|
||||||
readonly attribute XRLayer? baseLayer;
|
readonly attribute XRLayer? baseLayer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,9 +19,7 @@ interface XRSession : EventTarget {
|
||||||
// readonly attribute XRPresentationContext outputContext;
|
// readonly attribute XRPresentationContext outputContext;
|
||||||
readonly attribute XREnvironmentBlendMode environmentBlendMode;
|
readonly attribute XREnvironmentBlendMode environmentBlendMode;
|
||||||
|
|
||||||
attribute double depthNear;
|
readonly attribute XRRenderState renderState;
|
||||||
attribute double depthFar;
|
|
||||||
attribute XRLayer? baseLayer;
|
|
||||||
|
|
||||||
// // Methods
|
// // Methods
|
||||||
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options);
|
Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceOptions options);
|
||||||
|
|
|
@ -50,14 +50,17 @@ impl XRRenderState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XRRenderStateMethods for XRRenderState {
|
impl XRRenderStateMethods for XRRenderState {
|
||||||
|
/// https://immersive-web.github.io/webxr/#dom-xrrenderstate-depthnear
|
||||||
fn DepthNear(&self) -> Finite<f64> {
|
fn DepthNear(&self) -> Finite<f64> {
|
||||||
Finite::wrap(self.depth_near.get())
|
Finite::wrap(self.depth_near.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://immersive-web.github.io/webxr/#dom-xrrenderstate-depthfar
|
||||||
fn DepthFar(&self) -> Finite<f64> {
|
fn DepthFar(&self) -> Finite<f64> {
|
||||||
Finite::wrap(self.depth_far.get())
|
Finite::wrap(self.depth_far.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://immersive-web.github.io/webxr/#dom-xrrenderstate-baselayer
|
||||||
fn GetBaseLayer(&self) -> Option<DomRoot<XRLayer>> {
|
fn GetBaseLayer(&self) -> Option<DomRoot<XRLayer>> {
|
||||||
self.layer.get()
|
self.layer.get()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@ use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMe
|
||||||
use crate::dom::bindings::error::Error;
|
use crate::dom::bindings::error::Error;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::num::Finite;
|
use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
use crate::dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
@ -25,6 +24,7 @@ use crate::dom::xrlayer::XRLayer;
|
||||||
use crate::dom::xrreferencespace::XRReferenceSpace;
|
use crate::dom::xrreferencespace::XRReferenceSpace;
|
||||||
use crate::dom::xrstationaryreferencespace::XRStationaryReferenceSpace;
|
use crate::dom::xrstationaryreferencespace::XRStationaryReferenceSpace;
|
||||||
use crate::dom::xrwebgllayer::XRWebGLLayer;
|
use crate::dom::xrwebgllayer::XRWebGLLayer;
|
||||||
|
use crate::dom::xrrenderstate::XRRenderState;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -61,46 +61,16 @@ impl XRSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XRSessionMethods for XRSession {
|
impl XRSessionMethods for XRSession {
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-depthnear
|
|
||||||
fn DepthNear(&self) -> Finite<f64> {
|
|
||||||
self.display.DepthNear()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-depthfar
|
|
||||||
fn DepthFar(&self) -> Finite<f64> {
|
|
||||||
self.display.DepthFar()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-depthnear
|
|
||||||
fn SetDepthNear(&self, d: Finite<f64>) {
|
|
||||||
self.display.SetDepthNear(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-depthfar
|
|
||||||
fn SetDepthFar(&self, d: Finite<f64>) {
|
|
||||||
self.display.SetDepthFar(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-mode
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-mode
|
||||||
fn Mode(&self) -> XRSessionMode {
|
fn Mode(&self) -> XRSessionMode {
|
||||||
XRSessionMode::Immersive_vr
|
XRSessionMode::Immersive_vr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-baselayer
|
// https://immersive-web.github.io/webxr/#dom-xrsession-renderstate
|
||||||
fn SetBaseLayer(&self, layer: Option<&XRLayer>) {
|
fn RenderState(&self) -> DomRoot<XRRenderState> {
|
||||||
self.base_layer.set(layer);
|
// XXXManishearth maybe cache this
|
||||||
if let Some(layer) = layer {
|
XRRenderState::new(&self.global(), *self.display.DepthNear(), *self.display.DepthFar(),
|
||||||
let layer = layer.downcast::<XRWebGLLayer>().unwrap();
|
self.base_layer.get().as_ref().map(|l| &**l))
|
||||||
self.display.xr_present(&self, Some(&layer.Context()), None);
|
|
||||||
} else {
|
|
||||||
// steps unknown
|
|
||||||
// https://github.com/immersive-web/webxr/issues/453
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-baselayer
|
|
||||||
fn GetBaseLayer(&self) -> Option<DomRoot<XRLayer>> {
|
|
||||||
self.base_layer.get()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
|
/// https://immersive-web.github.io/webxr/#dom-xrsession-requestanimationframe
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue