Skip to content
Permalink
Browse files

XRRigidTransform.inverse is now a lazy attribute

  • Loading branch information...
Manishearth committed Apr 3, 2019
1 parent fcec93a commit eb837d1ed79bac1d3e0e9552b149f7f289665eb1
@@ -10,5 +10,5 @@ interface XRRigidTransform {
readonly attribute DOMPointReadOnly position;
readonly attribute DOMPointReadOnly orientation;
// readonly attribute Float32Array matrix;
XRRigidTransform inverse();
readonly attribute XRRigidTransform inverse;
};
@@ -23,6 +23,7 @@ pub struct XRRigidTransform {
orientation: MutNullableDom<DOMPointReadOnly>,
#[ignore_malloc_size_of = "defined in euclid"]
transform: RigidTransform3D<f64>,
inverse: MutNullableDom<XRRigidTransform>,
}

impl XRRigidTransform {
@@ -32,6 +33,7 @@ impl XRRigidTransform {
position: MutNullableDom::default(),
orientation: MutNullableDom::default(),
transform,
inverse: MutNullableDom::default(),
}
}

@@ -93,7 +95,9 @@ impl XRRigidTransformMethods for XRRigidTransform {
}
// https://immersive-web.github.io/webxr/#dom-xrrigidtransform-inverse
fn Inverse(&self) -> DomRoot<XRRigidTransform> {
XRRigidTransform::new(&self.global(), self.transform.inverse())
self.inverse.or_init(|| {
XRRigidTransform::new(&self.global(), self.transform.inverse())
})
}
}

0 comments on commit eb837d1

Please sign in to comment.
You can’t perform that action at this time.