diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html')
-rw-r--r-- | testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html b/testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html new file mode 100644 index 0000000000..d4fdc15396 --- /dev/null +++ b/testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html @@ -0,0 +1,108 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/webxr_util.js"></script> +<script src="resources/webxr_math_utils.js"></script> +<script src="resources/webxr_test_constants.js"></script> +<script src="resources/webxr_test_asserts.js"></script> +<script> + +let testName = "XRRigidTransform inverse works"; +let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; + +let testFunction = + (session, fakeDeviceController, t) => new Promise((resolve, reject) => { + + // An identity transform should be equal to it's inverse. + let identity_transform = new XRRigidTransform(); + t.step(() => { + assert_transform_approx_equals(identity_transform, identity_transform.inverse); + }); + + // Inversed transforms should yield the expected results + let transform = new XRRigidTransform( + { x: 1.0, y: 2.0, z: 3.0 }, + { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }); + let inverse_transform = transform.inverse; + let expected_inverse = new XRRigidTransform( + { x: -1.0, y: -2.0, z: -3.0 }, + { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }); + t.step(() => { + assert_transform_approx_equals(inverse_transform, expected_inverse); + }); + + transform = new XRRigidTransform( + { x: 0.0, y: 0.0, z: 0.0 }, + { x: 1.0, y: 0.0, z: 0.0, w: 1.0 }); + inverse_transform = transform.inverse; + expected_inverse = new XRRigidTransform( + { x: 0.0, y: 0.0, z: 0.0 }, + { x: -1.0, y: 0.0, z: 0.0, w: 1.0 }); + t.step(() => { + assert_transform_approx_equals(inverse_transform, expected_inverse); + }); + + transform = new XRRigidTransform( + { x: 1.0, y: 2.0, z: 3.0 }, + { x: 0.0, y: 1.0, z: 0.0, w: 1.0 }); + inverse_transform = transform.inverse; + expected_inverse = new XRRigidTransform( + { x: 3.0, y: -2.0, z: -1.0 }, + { x: 0.0, y: -1.0, z: 0.0, w: 1.0 }); + t.step(() => { + assert_transform_approx_equals(inverse_transform, expected_inverse); + }); + + // Transforms should be equal to the inverse of their inverse. + transform = new XRRigidTransform( + { x: 1.0, y: 2.0, z: 3.0 }, + { x: 1.0, y: 2.0, z: 3.0, w: 4.0 }); + inverse_transform = transform.inverse; + t.step(() => { + assert_transform_approx_equals(transform, inverse_transform.inverse); + }); + + transform = new XRRigidTransform( + { x: -9.0, y: 8.0, z: -7.0 }, + { x: 6.0, y: -5.0, z: 4.0, w: 3.0 }); + inverse_transform = transform.inverse; + t.step(() => { + assert_transform_approx_equals(transform, inverse_transform.inverse); + }); + + transform = new XRRigidTransform( + { x: -2.0, y: 1.0, z: -4.0 }, + { x: 0.0, y: 1.0, z: 0.0, w: 1.0 }); + inverse_transform = transform.inverse; + t.step(() => { + assert_transform_approx_equals(transform, inverse_transform.inverse); + }); + + transform = new XRRigidTransform( + { x: 2.0, y: -1.0, z: 4.0 }, + { x: 1.0, y: 0.0, z: 0.0, w: 1.0 }); + inverse_transform = transform.inverse; + t.step(() => { + assert_transform_approx_equals(transform, inverse_transform.inverse); + }); + + // Inverse should always return the same object, and calling inverse on that + // object should return the original object. + transform = new XRRigidTransform( + { x: 1.0, y: -2.0, z: 3.0 }, + { x: 0.0, y: 0.0, z: 1.0, w: 1.0 }); + inverse_transform = transform.inverse; + t.step(() => { + assert_equals(transform.inverse, inverse_transform); + assert_equals(inverse_transform.inverse, transform); + assert_equals(transform.inverse.inverse, transform); + assert_equals(transform.inverse.inverse.inverse, inverse_transform); + }); + + resolve(); +}); + +xr_session_promise_test(testName, testFunction, fakeDeviceInitParams, + 'immersive-vr'); + +</script> |