Skip to content

Commit e73efa1

Browse files
Manishearthd3vsanchez
authored andcommitted
Validate the position passed to XRRigidTransform
Added in immersive-web/webxr#568
1 parent b5efa78 commit e73efa1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/script/dom/xrrigidtransform.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit;
66
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding;
77
use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods;
8+
use crate::dom::bindings::error::Error;
89
use crate::dom::bindings::error::Fallible;
910
use crate::dom::bindings::reflector::DomObject;
1011
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
@@ -54,7 +55,13 @@ impl XRRigidTransform {
5455
position: &DOMPointInit,
5556
orientation: &DOMPointInit,
5657
) -> Fallible<DomRoot<Self>> {
57-
let global = window.global();
58+
if position.w != 1.0 {
59+
return Err(Error::Type(format!(
60+
"XRRigidTransform must be constructed with a position that has a w value of of 1.0, not {}",
61+
position.w
62+
)));
63+
}
64+
5865
let translate = Vector3D::new(position.x as f64, position.y as f64, position.z as f64);
5966
let rotate = Rotation3D::unit_quaternion(
6067
orientation.x as f64,

0 commit comments

Comments
 (0)