Validate the position passed to XRRigidTransform

Added in https://github.com/immersive-web/webxr/pull/568
This commit is contained in:
Manish Goregaokar 2019-04-03 00:25:44 -07:00
parent e296185c53
commit 1f3f37225f

View file

@ -5,6 +5,7 @@
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods;
use crate::dom::bindings::error::Error;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
@ -54,7 +55,13 @@ impl XRRigidTransform {
position: &DOMPointInit,
orientation: &DOMPointInit,
) -> 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 rotate = Rotation3D::unit_quaternion(
orientation.x as f64,