mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Validate the position passed to XRRigidTransform
Added in https://github.com/immersive-web/webxr/pull/568
This commit is contained in:
parent
e296185c53
commit
1f3f37225f
1 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
|
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods;
|
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods;
|
||||||
|
use crate::dom::bindings::error::Error;
|
||||||
use crate::dom::bindings::error::Fallible;
|
use crate::dom::bindings::error::Fallible;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||||
|
@ -54,7 +55,13 @@ impl XRRigidTransform {
|
||||||
position: &DOMPointInit,
|
position: &DOMPointInit,
|
||||||
orientation: &DOMPointInit,
|
orientation: &DOMPointInit,
|
||||||
) -> Fallible<DomRoot<Self>> {
|
) -> Fallible<DomRoot<Self>> {
|
||||||
let global = window.global();
|
if position.w != 1.0 {
|
||||||
|
return Err(Error::Type(format!(
|
||||||
|
"XRRigidTransform must be constructed with a position that has a w value of of 1.0, not {}",
|
||||||
|
position.w
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
let translate = Vector3D::new(position.x as f64, position.y as f64, position.z as f64);
|
let translate = Vector3D::new(position.x as f64, position.y as f64, position.z as f64);
|
||||||
let rotate = Rotation3D::unit_quaternion(
|
let rotate = Rotation3D::unit_quaternion(
|
||||||
orientation.x as f64,
|
orientation.x as f64,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue