Allow setting near/far clip planes

This commit is contained in:
Manish Goregaokar 2019-08-20 16:18:40 -07:00
parent 17f423723c
commit 0d79b2beaf
2 changed files with 14 additions and 3 deletions

5
Cargo.lock generated
View file

@ -5608,7 +5608,7 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#17dcfc9dfd3b8b29caebe7cf022c1855d68920f1"
source = "git+https://github.com/servo/webxr#ee763bc2c579c72c1b1a0706e2876b1f1ddff34d"
dependencies = [
"bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5617,6 +5617,7 @@ dependencies = [
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"openxr 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5625,7 +5626,7 @@ dependencies = [
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#17dcfc9dfd3b8b29caebe7cf022c1855d68920f1"
source = "git+https://github.com/servo/webxr#ee763bc2c579c72c1b1a0706e2876b1f1ddff34d"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -175,7 +175,7 @@ impl XRSession {
}
/// https://immersive-web.github.io/webxr/#xr-animation-frame
fn raf_callback(&self, (time, frame): (f64, Frame)) {
fn raf_callback(&self, (time, mut frame): (f64, Frame)) {
// Step 1
if let Some(pending) = self.pending_render_state.take() {
// https://immersive-web.github.io/webxr/#apply-the-pending-render-state
@ -200,6 +200,10 @@ impl XRSession {
}
}
for event in frame.events.drain(..) {
self.session.borrow_mut().apply_event(event)
}
// Step 2
let base_layer = match self.active_render_state.get().GetBaseLayer() {
Some(layer) => layer,
@ -279,6 +283,12 @@ impl XRSessionMethods for XRSession {
if let Some(ref layer) = init.baseLayer {
pending.set_layer(Some(&layer))
}
if init.depthFar.is_some() || init.depthNear.is_some() {
self.session
.borrow_mut()
.update_clip_planes(*pending.DepthNear() as f32, *pending.DepthFar() as f32);
}
// XXXManishearth handle inlineVerticalFieldOfView
Ok(())
}