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/xrFrame_getViewerPose_getPose.https.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/xrFrame_getViewerPose_getPose.https.html')
-rw-r--r-- | testing/web-platform/tests/webxr/xrFrame_getViewerPose_getPose.https.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrFrame_getViewerPose_getPose.https.html b/testing/web-platform/tests/webxr/xrFrame_getViewerPose_getPose.https.html new file mode 100644 index 0000000000..05cbf78523 --- /dev/null +++ b/testing/web-platform/tests/webxr/xrFrame_getViewerPose_getPose.https.html @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<body> + <script src=/resources/testharness.js></script> + <script src=/resources/testharnessreport.js></script> + <script src="resources/webxr_util.js"></script> + <script src="resources/webxr_test_constants.js"></script> + <script src="resources/webxr_test_asserts.js"></script> + + <script> + + let testName = "XRFrame getViewerPose(refSpace) matches getPose(viewer, refSpace)."; + + // Used for viewer origin, the actual values should not matter for the test. + const poseTransform = { + position: [1, 2, 3], + orientation: [0.5, 0.5, 0.5, 0.5] // 120 degrees around [1, 1, 1] axis + }; + + // Use the same device as tracked immersive device, but modify the viewer origin. + const deviceInitParams = Object.assign({}, TRACKED_IMMERSIVE_DEVICE, {viewerOrigin: poseTransform}); + + // Used when creating a reference space that is offset from local space. + // Actual values should not matter for the test. + const offsetSpaceTransform = new XRRigidTransform( + { x: 1.00, y: -1.50, z: 10.00, w: 1.0 }, + { x: 0.27, y: 0.00, z: 0.27, w: 0.92}, // 45 degrees around [1, 0, 1] axis + ); + + const testFunction = function(session, fakeDeviceController, t) { + return Promise.all([ + session.requestReferenceSpace('local'), + session.requestReferenceSpace('viewer'), + ]).then(([referenceSpace, viewerRefSpace]) => new Promise((resolve, reject) => { + const offsetRefSpace = referenceSpace.getOffsetReferenceSpace(offsetSpaceTransform); + + function onFrame(time, frame){ + t.step(() => { + const pose1 = frame.getViewerPose(referenceSpace); + const pose2 = frame.getPose(viewerRefSpace, referenceSpace); + assert_not_equals(pose1, null); + assert_not_equals(pose2, null); + assert_matrix_approx_equals(pose1.transform.matrix, pose2.transform.matrix); + + const pose3 = frame.getViewerPose(offsetRefSpace); + const pose4 = frame.getPose(viewerRefSpace, offsetRefSpace); + assert_not_equals(pose3, null); + assert_not_equals(pose4, null); + assert_matrix_approx_equals(pose3.transform.matrix, pose4.transform.matrix); + }); + + resolve(); + } + + session.requestAnimationFrame(onFrame); + })); + }; + + xr_session_promise_test(testName, testFunction, + deviceInitParams, 'immersive-vr'); + + </script> +</body> |