mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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]]
|
||||
name = "webxr"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/webxr#7656508fdcda194997cdaa751f2b98797d963867"
|
||||
source = "git+https://github.com/servo/webxr#1a2186a5b33ae9e2e0b4fc15e9dc6095ae2e5fd0"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"euclid",
|
||||
|
@ -7800,7 +7800,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webxr-api"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/webxr#7656508fdcda194997cdaa751f2b98797d963867"
|
||||
source = "git+https://github.com/servo/webxr#1a2186a5b33ae9e2e0b4fc15e9dc6095ae2e5fd0"
|
||||
dependencies = [
|
||||
"euclid",
|
||||
"ipc-channel",
|
||||
|
|
|
@ -17,8 +17,8 @@ use webxr_api::{
|
|||
|
||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{
|
||||
FakeXRDeviceMethods, FakeXRRegionType, FakeXRRigidTransformInit, FakeXRViewInit,
|
||||
FakeXRWorldInit,
|
||||
FakeXRBoundsPoint, FakeXRDeviceMethods, FakeXRRegionType, FakeXRRigidTransformInit,
|
||||
FakeXRViewInit, FakeXRWorldInit,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit;
|
||||
use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{
|
||||
|
@ -183,10 +183,15 @@ impl From<FakeXRRegionType> for EntityType {
|
|||
|
||||
impl FakeXRDeviceMethods for FakeXRDevice {
|
||||
/// <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
|
||||
.sender
|
||||
.send(MockDeviceMsg::SetViews(get_views(&views)?));
|
||||
// TODO: Support setting secondary views for mock backend
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -309,6 +314,25 @@ impl FakeXRDeviceMethods for FakeXRDevice {
|
|||
self.disconnect(sender);
|
||||
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 {
|
||||
|
|
|
@ -6,29 +6,31 @@
|
|||
|
||||
[Exposed=Window, Pref="dom.webxr.test"]
|
||||
interface FakeXRDevice {
|
||||
// Sets the values to be used for subsequent
|
||||
// requestAnimationFrame() callbacks.
|
||||
[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);
|
||||
// Sets the values to be used for subsequent requestAnimationFrame() callbacks.
|
||||
[Throws] undefined setViews(sequence<FakeXRViewInit> views, optional sequence<FakeXRViewInit> secondaryViews);
|
||||
|
||||
// behaves as if device was disconnected
|
||||
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:
|
||||
[Throws] undefined setWorld(FakeXRWorldInit world);
|
||||
undefined clearWorld();
|
||||
|
||||
// Depth sensing extensions:
|
||||
// undefined setDepthSensingData(FakeXRDepthSensingDataInit depthSensingData);
|
||||
// undefined clearDepthSensingData();
|
||||
};
|
||||
|
||||
// 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>
|
||||
fn BoundsGeometry(&self, cx: JSContext) -> JSVal {
|
||||
if let Some(bounds) = self.xrspace.get_bounds() {
|
||||
let point1 = DOMPointReadOnly::new(
|
||||
&self.global(),
|
||||
bounds.min.x.into(),
|
||||
0.0,
|
||||
bounds.min.y.into(),
|
||||
1.0,
|
||||
);
|
||||
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,
|
||||
);
|
||||
let points: Vec<DomRoot<DOMPointReadOnly>> = bounds
|
||||
.into_iter()
|
||||
.map(|point| {
|
||||
DOMPointReadOnly::new(&self.global(), point.x.into(), 0.0, point.y.into(), 1.0)
|
||||
})
|
||||
.collect();
|
||||
|
||||
to_frozen_array(&[point1, point2, point3, point4], cx)
|
||||
to_frozen_array(&points, cx)
|
||||
} else {
|
||||
to_frozen_array::<DomRoot<DOMPointReadOnly>>(&[], cx)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::{Box2D, RigidTransform3D};
|
||||
use euclid::{Point2D, RigidTransform3D};
|
||||
use webxr_api::{self, Floor, Frame, Space};
|
||||
|
||||
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>()
|
||||
.session()
|
||||
.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