mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add FakeXRDeviceController.setViewerOrigin()
This commit is contained in:
parent
4b930b9e30
commit
97df39fce1
2 changed files with 19 additions and 4 deletions
|
@ -7,7 +7,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 crate::dom::bindings::codegen::Bindings::FakeXRDeviceControllerBinding::{
|
use crate::dom::bindings::codegen::Bindings::FakeXRDeviceControllerBinding::{
|
||||||
self, FakeXRDeviceControllerMethods, FakeXRViewInit,
|
self, FakeXRDeviceControllerMethods, FakeXRRigidTransform, FakeXRViewInit,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye;
|
||||||
use crate::dom::bindings::error::{Error, Fallible};
|
use crate::dom::bindings::error::{Error, Fallible};
|
||||||
|
@ -42,7 +42,8 @@ impl FakeXRDeviceController {
|
||||||
.as_window()
|
.as_window()
|
||||||
.webvr_thread()
|
.webvr_thread()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.send(WebVRMsg::MessageMockDisplay(msg));
|
.send(WebVRMsg::MessageMockDisplay(msg))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ impl FakeXRDeviceControllerMethods for FakeXRDeviceController {
|
||||||
left.viewOffset.position.len() != 4 ||
|
left.viewOffset.position.len() != 4 ||
|
||||||
right.viewOffset.position.len() != 4
|
right.viewOffset.position.len() != 4
|
||||||
{
|
{
|
||||||
return Err(Error::Type("Incorrectly sized matrix".into()));
|
return Err(Error::Type("Incorrectly sized array".into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut proj_l = [0.; 16];
|
let mut proj_l = [0.; 16];
|
||||||
|
@ -85,4 +86,18 @@ impl FakeXRDeviceControllerMethods for FakeXRDeviceController {
|
||||||
self.send_msg(MockVRControlMsg::SetEyeParameters(params_l, params_r));
|
self.send_msg(MockVRControlMsg::SetEyeParameters(params_l, params_r));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn SetViewerOrigin(&self, origin: &FakeXRRigidTransform) -> Fallible<()> {
|
||||||
|
if origin.position.len() != 4 || origin.orientation.len() != 4 {
|
||||||
|
return Err(Error::Type("Incorrectly sized array".into()));
|
||||||
|
}
|
||||||
|
let mut position = [0.; 3];
|
||||||
|
let mut orientation = [0.; 4];
|
||||||
|
let v: Vec<_> = origin.position.iter().map(|x| **x).collect();
|
||||||
|
position.copy_from_slice(&v[0..3]);
|
||||||
|
let v: Vec<_> = origin.orientation.iter().map(|x| **x).collect();
|
||||||
|
orientation.copy_from_slice(&v);
|
||||||
|
self.send_msg(MockVRControlMsg::SetViewerPose(position, orientation));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ interface FakeXRDeviceController {
|
||||||
// // requestAnimationFrame() callbacks.
|
// // requestAnimationFrame() callbacks.
|
||||||
[Throws] void setViews(sequence<FakeXRViewInit> views);
|
[Throws] void setViews(sequence<FakeXRViewInit> views);
|
||||||
|
|
||||||
// void setViewerOrigin(FakeXRRigidTransform origin);
|
[Throws] void setViewerOrigin(FakeXRRigidTransform origin);
|
||||||
|
|
||||||
// Simulates the user activating the reset pose on a device.
|
// Simulates the user activating the reset pose on a device.
|
||||||
// void simulateResetPose();
|
// void simulateResetPose();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue