mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Update FakeXRDevice to support updating bounds (#33271)
* Update FakeXRDevice to support updating bounds Signed-off-by: Daniel Adams <msub2official@gmail.com> * Add missing spec link Signed-off-by: Daniel Adams <msub2official@gmail.com> * Mark secondaryViews as optional in FakeXRDevice.setViews Signed-off-by: Daniel Adams <msub2official@gmail.com> --------- Signed-off-by: Daniel Adams <msub2official@gmail.com>
This commit is contained in:
parent
3453d9fdad
commit
9fdaf9bf0c
7 changed files with 56 additions and 66 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -7783,7 +7783,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr"
|
name = "webxr"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#7656508fdcda194997cdaa751f2b98797d963867"
|
source = "git+https://github.com/servo/webxr#1a2186a5b33ae9e2e0b4fc15e9dc6095ae2e5fd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"euclid",
|
"euclid",
|
||||||
|
@ -7800,7 +7800,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webxr-api"
|
name = "webxr-api"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
source = "git+https://github.com/servo/webxr#7656508fdcda194997cdaa751f2b98797d963867"
|
source = "git+https://github.com/servo/webxr#1a2186a5b33ae9e2e0b4fc15e9dc6095ae2e5fd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid",
|
"euclid",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
|
|
|
@ -17,8 +17,8 @@ use webxr_api::{
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{
|
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{
|
||||||
FakeXRDeviceMethods, FakeXRRegionType, FakeXRRigidTransformInit, FakeXRViewInit,
|
FakeXRBoundsPoint, FakeXRDeviceMethods, FakeXRRegionType, FakeXRRigidTransformInit,
|
||||||
FakeXRWorldInit,
|
FakeXRViewInit, FakeXRWorldInit,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
|
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||||
|
@ -183,10 +183,15 @@ impl From<FakeXRRegionType> for EntityType {
|
||||||
|
|
||||||
impl FakeXRDeviceMethods for FakeXRDevice {
|
impl FakeXRDeviceMethods for FakeXRDevice {
|
||||||
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
|
/// <https://github.com/immersive-web/webxr-test-api/blob/master/explainer.md>
|
||||||
fn SetViews(&self, views: Vec<FakeXRViewInit>) -> Fallible<()> {
|
fn SetViews(
|
||||||
|
&self,
|
||||||
|
views: Vec<FakeXRViewInit>,
|
||||||
|
_secondary_views: Option<Vec<FakeXRViewInit>>,
|
||||||
|
) -> Fallible<()> {
|
||||||
let _ = self
|
let _ = self
|
||||||
.sender
|
.sender
|
||||||
.send(MockDeviceMsg::SetViews(get_views(&views)?));
|
.send(MockDeviceMsg::SetViews(get_views(&views)?));
|
||||||
|
// TODO: Support setting secondary views for mock backend
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +314,25 @@ impl FakeXRDeviceMethods for FakeXRDevice {
|
||||||
self.disconnect(sender);
|
self.disconnect(sender);
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrdevice-setboundsgeometry>
|
||||||
|
fn SetBoundsGeometry(&self, bounds_coodinates: Vec<FakeXRBoundsPoint>) -> Fallible<()> {
|
||||||
|
if bounds_coodinates.len() < 3 {
|
||||||
|
return Err(Error::Type(
|
||||||
|
"Bounds geometry must contain at least 3 points".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let coords = bounds_coodinates
|
||||||
|
.iter()
|
||||||
|
.map(|coord| {
|
||||||
|
let x = *coord.x.unwrap() as f32;
|
||||||
|
let y = *coord.z.unwrap() as f32;
|
||||||
|
Point2D::new(x, y)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let _ = self.sender.send(MockDeviceMsg::SetBoundsGeometry(coords));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<XRHandedness> for Handedness {
|
impl From<XRHandedness> for Handedness {
|
||||||
|
|
|
@ -6,29 +6,31 @@
|
||||||
|
|
||||||
[Exposed=Window, Pref="dom.webxr.test"]
|
[Exposed=Window, Pref="dom.webxr.test"]
|
||||||
interface FakeXRDevice {
|
interface FakeXRDevice {
|
||||||
// Sets the values to be used for subsequent
|
// Sets the values to be used for subsequent requestAnimationFrame() callbacks.
|
||||||
// requestAnimationFrame() callbacks.
|
[Throws] undefined setViews(sequence<FakeXRViewInit> views, optional sequence<FakeXRViewInit> secondaryViews);
|
||||||
[Throws] undefined setViews(sequence<FakeXRViewInit> views);
|
|
||||||
|
|
||||||
[Throws] undefined setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
|
|
||||||
undefined clearViewerOrigin();
|
|
||||||
|
|
||||||
[Throws] undefined setFloorOrigin(FakeXRRigidTransformInit origin);
|
|
||||||
undefined clearFloorOrigin();
|
|
||||||
|
|
||||||
// // Simulates devices focusing and blurring sessions.
|
|
||||||
undefined simulateVisibilityChange(XRVisibilityState state);
|
|
||||||
|
|
||||||
// void setBoundsGeometry(sequence<FakeXRBoundsPoint> boundsCoodinates);
|
|
||||||
|
|
||||||
[Throws] FakeXRInputController simulateInputSourceConnection(FakeXRInputSourceInit init);
|
|
||||||
|
|
||||||
// behaves as if device was disconnected
|
// behaves as if device was disconnected
|
||||||
Promise<undefined> disconnect();
|
Promise<undefined> disconnect();
|
||||||
|
|
||||||
|
[Throws] undefined setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
|
||||||
|
undefined clearViewerOrigin();
|
||||||
|
[Throws] undefined setFloorOrigin(FakeXRRigidTransformInit origin);
|
||||||
|
undefined clearFloorOrigin();
|
||||||
|
[Throws] undefined setBoundsGeometry(sequence<FakeXRBoundsPoint> boundsCoodinates);
|
||||||
|
// undefined simulateResetPose();
|
||||||
|
|
||||||
|
// Simulates devices focusing and blurring sessions.
|
||||||
|
undefined simulateVisibilityChange(XRVisibilityState state);
|
||||||
|
|
||||||
|
[Throws] FakeXRInputController simulateInputSourceConnection(FakeXRInputSourceInit init);
|
||||||
|
|
||||||
// Hit test extensions:
|
// Hit test extensions:
|
||||||
[Throws] undefined setWorld(FakeXRWorldInit world);
|
[Throws] undefined setWorld(FakeXRWorldInit world);
|
||||||
undefined clearWorld();
|
undefined clearWorld();
|
||||||
|
|
||||||
|
// Depth sensing extensions:
|
||||||
|
// undefined setDepthSensingData(FakeXRDepthSensingDataInit depthSensingData);
|
||||||
|
// undefined clearDepthSensingData();
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport
|
// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport
|
||||||
|
|
|
@ -61,36 +61,14 @@ impl XRBoundedReferenceSpaceMethods for XRBoundedReferenceSpace {
|
||||||
/// <https://www.w3.org/TR/webxr/#dom-xrboundedreferencespace-boundsgeometry>
|
/// <https://www.w3.org/TR/webxr/#dom-xrboundedreferencespace-boundsgeometry>
|
||||||
fn BoundsGeometry(&self, cx: JSContext) -> JSVal {
|
fn BoundsGeometry(&self, cx: JSContext) -> JSVal {
|
||||||
if let Some(bounds) = self.xrspace.get_bounds() {
|
if let Some(bounds) = self.xrspace.get_bounds() {
|
||||||
let point1 = DOMPointReadOnly::new(
|
let points: Vec<DomRoot<DOMPointReadOnly>> = bounds
|
||||||
&self.global(),
|
.into_iter()
|
||||||
bounds.min.x.into(),
|
.map(|point| {
|
||||||
0.0,
|
DOMPointReadOnly::new(&self.global(), point.x.into(), 0.0, point.y.into(), 1.0)
|
||||||
bounds.min.y.into(),
|
})
|
||||||
1.0,
|
.collect();
|
||||||
);
|
|
||||||
let point2 = DOMPointReadOnly::new(
|
|
||||||
&self.global(),
|
|
||||||
bounds.min.x.into(),
|
|
||||||
0.0,
|
|
||||||
bounds.max.y.into(),
|
|
||||||
1.0,
|
|
||||||
);
|
|
||||||
let point3 = DOMPointReadOnly::new(
|
|
||||||
&self.global(),
|
|
||||||
bounds.max.x.into(),
|
|
||||||
0.0,
|
|
||||||
bounds.max.y.into(),
|
|
||||||
1.0,
|
|
||||||
);
|
|
||||||
let point4 = DOMPointReadOnly::new(
|
|
||||||
&self.global(),
|
|
||||||
bounds.max.x.into(),
|
|
||||||
0.0,
|
|
||||||
bounds.min.y.into(),
|
|
||||||
1.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
to_frozen_array(&[point1, point2, point3, point4], cx)
|
to_frozen_array(&points, cx)
|
||||||
} else {
|
} else {
|
||||||
to_frozen_array::<DomRoot<DOMPointReadOnly>>(&[], cx)
|
to_frozen_array::<DomRoot<DOMPointReadOnly>>(&[], cx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use euclid::{Box2D, RigidTransform3D};
|
use euclid::{Point2D, RigidTransform3D};
|
||||||
use webxr_api::{self, Floor, Frame, Space};
|
use webxr_api::{self, Floor, Frame, Space};
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::{
|
use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::{
|
||||||
|
@ -136,7 +136,7 @@ impl XRReferenceSpace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bounds(&self) -> Option<Box2D<f32, Floor>> {
|
pub fn get_bounds(&self) -> Option<Vec<Point2D<f32, Floor>>> {
|
||||||
self.upcast::<XRSpace>()
|
self.upcast::<XRSpace>()
|
||||||
.session()
|
.session()
|
||||||
.with_session(|s| s.reference_space_bounds())
|
.with_session(|s| s.reference_space_bounds())
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
[xrBoundedReferenceSpace_updates.https.html]
|
|
||||||
expected: ERROR
|
|
||||||
['XRBoundedReferenceSpace updates properly when the changes are applied - webgl2]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
||||||
['XRBoundedReferenceSpace updates properly when the changes are applied - webgl]
|
|
||||||
expected: TIMEOUT
|
|
|
@ -1,7 +0,0 @@
|
||||||
[xrBoundedReferenceSpace_updates.https.html]
|
|
||||||
expected: ERROR
|
|
||||||
['XRBoundedReferenceSpace updates properly when the changes are applied - webgl2]
|
|
||||||
expected: NOTRUN
|
|
||||||
|
|
||||||
['XRBoundedReferenceSpace updates properly when the changes are applied - webgl]
|
|
||||||
expected: TIMEOUT
|
|
Loading…
Add table
Add a link
Reference in a new issue