summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/webxr/xrRigidTransform_inverse.https.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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.html108
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>