mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Update requiredness of some fields
This commit is contained in:
parent
c19240a454
commit
480a9988d1
6 changed files with 30 additions and 40 deletions
|
@ -54,16 +54,10 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)>
|
|||
_ => return Err(Error::NotSupported),
|
||||
};
|
||||
|
||||
// can be removed once https://github.com/servo/servo/issues/23640 is fixed
|
||||
let (position_l, position_r) = match (&left.viewOffset.position, &right.viewOffset.position) {
|
||||
(&Some(ref l), &Some(ref r)) => (l, r),
|
||||
_ => return Err(Error::Type("Must specify position".into())),
|
||||
};
|
||||
|
||||
if left.projectionMatrix.len() != 16 ||
|
||||
right.projectionMatrix.len() != 16 ||
|
||||
position_l.len() != 3 ||
|
||||
position_r.len() != 3
|
||||
left.viewOffset.position.len() != 3 ||
|
||||
right.viewOffset.position.len() != 3
|
||||
{
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
|
@ -77,9 +71,9 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)>
|
|||
|
||||
let mut offset_l = [0.; 3];
|
||||
let mut offset_r = [0.; 3];
|
||||
let v: Vec<_> = position_l.iter().map(|x| **x).collect();
|
||||
let v: Vec<_> = left.viewOffset.position.iter().map(|x| **x).collect();
|
||||
offset_l.copy_from_slice(&v);
|
||||
let v: Vec<_> = position_r.iter().map(|x| **x).collect();
|
||||
let v: Vec<_> = right.viewOffset.position.iter().map(|x| **x).collect();
|
||||
offset_r.copy_from_slice(&v);
|
||||
let left = MockVRView {
|
||||
projection: proj_l,
|
||||
|
@ -93,25 +87,14 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)>
|
|||
}
|
||||
|
||||
pub fn get_origin(origin: &FakeXRRigidTransformInit) -> Fallible<([f32; 3], [f32; 4])> {
|
||||
// can be removed once https://github.com/servo/servo/issues/23640 is fixed
|
||||
let position = if let Some(ref position) = origin.position {
|
||||
position
|
||||
} else {
|
||||
return Err(Error::Type("Missing position field".into()));
|
||||
};
|
||||
let orientation = if let Some(ref orientation) = origin.orientation {
|
||||
orientation
|
||||
} else {
|
||||
return Err(Error::Type("Missing orientation field".into()));
|
||||
};
|
||||
if position.len() != 4 || orientation.len() != 4 {
|
||||
if origin.position.len() != 3 || origin.orientation.len() != 4 {
|
||||
return Err(Error::Type("Incorrectly sized array".into()));
|
||||
}
|
||||
let mut p = [0.; 3];
|
||||
let mut o = [0.; 4];
|
||||
let v: Vec<_> = position.iter().map(|x| **x).collect();
|
||||
let v: Vec<_> = origin.position.iter().map(|x| **x).collect();
|
||||
p.copy_from_slice(&v[0..3]);
|
||||
let v: Vec<_> = orientation.iter().map(|x| **x).collect();
|
||||
let v: Vec<_> = origin.orientation.iter().map(|x| **x).collect();
|
||||
o.copy_from_slice(&v);
|
||||
|
||||
Ok((p, o))
|
||||
|
|
|
@ -14,8 +14,7 @@ interface FakeXRDevice {
|
|||
// Promise<void> disconnect();
|
||||
|
||||
// Sets the origin of the viewer
|
||||
// dict must be optional because of https://github.com/servo/servo/issues/23640
|
||||
[Throws] void setViewerOrigin(optional FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
|
||||
[Throws] void setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false);
|
||||
|
||||
// // Simulates devices focusing and blurring sessions.
|
||||
// void simulateVisibilityChange(XRVisibilityState);
|
||||
|
@ -53,7 +52,6 @@ dictionary FakeXRBoundsPoint {
|
|||
};
|
||||
|
||||
dictionary FakeXRRigidTransformInit {
|
||||
// should be required, see https://github.com/servo/servo/issues/23640
|
||||
sequence<float> position;
|
||||
sequence<float> orientation;
|
||||
required sequence<float> position;
|
||||
required sequence<float> orientation;
|
||||
};
|
||||
|
|
|
@ -52,12 +52,16 @@ impl XRTestMethods for XRTest {
|
|||
return p;
|
||||
}
|
||||
|
||||
let origin = match get_origin(&init.viewerOrigin) {
|
||||
let origin = if let Some(ref o) = init.viewerOrigin {
|
||||
match get_origin(&o) {
|
||||
Ok(origin) => origin,
|
||||
Err(e) => {
|
||||
p.reject_error(e);
|
||||
return p;
|
||||
},
|
||||
}
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
let views = match get_views(&init.views) {
|
||||
|
|
|
@ -19683,15 +19683,15 @@
|
|||
"testharness"
|
||||
],
|
||||
"webxr/create_session.html": [
|
||||
"306ab85d3b1b914d2dd7c11a3b03dccd990148ae",
|
||||
"ddec5add27b84e8e2febe3789d326f1e9fb7f508",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/obtain_frame.html": [
|
||||
"99d8fd1ef152e4030444c3ca42482d28c3e855d3",
|
||||
"e2b4424d5779baedf6bdb50f1b3151336f31a4cb",
|
||||
"testharness"
|
||||
],
|
||||
"webxr/resources/webxr-util.js": [
|
||||
"b644ba72ac801bc8f659e9678d31ab23db0b7281",
|
||||
"554c1c183d3710e54dc60704dad0aac542ffd67c",
|
||||
"support"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -2,11 +2,16 @@
|
|||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/webxr-util.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
navigator.xr.test.simulateDeviceConnection({supportsImmersive: true}).then((m) => {
|
||||
navigator.xr.test.simulateDeviceConnection({
|
||||
supportsImmersive: true,
|
||||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
}).then((m) => {
|
||||
return navigator.xr.requestSession({mode: "immersive-vr"})
|
||||
}).then(() => t.done());
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
let mock = await navigator.xr.test.simulateDeviceConnection({
|
||||
supportsImmersive: true,
|
||||
views: TEST_VIEWS,
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] }
|
||||
viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] }
|
||||
});
|
||||
let session = await navigator.xr.requestSession({mode: "immersive-vr"});
|
||||
await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue