summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrFrame_getPose.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webxr/xrFrame_getPose.https.html
parentInitial commit. (diff)
downloadfirefox-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/xrFrame_getPose.https.html')
-rw-r--r--testing/web-platform/tests/webxr/xrFrame_getPose.https.html101
1 files changed, 101 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrFrame_getPose.https.html b/testing/web-platform/tests/webxr/xrFrame_getPose.https.html
new file mode 100644
index 0000000000..9cd7922f64
--- /dev/null
+++ b/testing/web-platform/tests/webxr/xrFrame_getPose.https.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/webxr_test_constants.js"></script>
+<script src="resources/webxr_util.js"></script>
+<script src="resources/webxr_test_asserts.js"></script>
+
+<script>
+
+let immersiveTestName = "XRFrame.getPose works for immersive sessions";
+let nonImmersiveTestName = "XRFrame.getPose works for non-immersive sessions";
+
+let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
+
+let testFunction = function(session, fakeDeviceController, t) {
+ return Promise.all([
+ session.requestReferenceSpace('local'),
+ session.requestReferenceSpace('local')
+ ]).then((spaces) => new Promise((resolve) => {
+ function onFrame(time, xrFrame) {
+ const radians = Math.PI / 2.0; // 90 degrees
+
+ // Both eye-level spaces start out with originOffset = identity matrix.
+ let space1 = spaces[0];
+ let space2 = spaces[1];
+
+ let offset = new XRRigidTransform(
+ DOMPointReadOnly.fromPoint({
+ x: 2,
+ y: 3,
+ z: 4,
+ w: 1,
+ }));
+
+ let translatedSpace1 = space1.getOffsetReferenceSpace(offset);
+ let translated_from_base = xrFrame.getPose(translatedSpace1, space1);
+
+ // Getting the transform of an offset space from the space it was based on
+ // should be the same as the initially applied offset.
+ t.step(() => {
+ assert_matrix_approx_equals(translated_from_base.transform.matrix, offset.matrix, FLOAT_EPSILON);
+ });
+
+ // Rotate 90 degrees about x axis, then move 1 meter along y axis.
+ space1 = space1.getOffsetReferenceSpace(new XRRigidTransform(
+ DOMPointReadOnly.fromPoint({
+ x : 0,
+ y : 1,
+ z : 0,
+ w : 1
+ }),
+ DOMPointReadOnly.fromPoint({
+ x : Math.sin(radians / 2),
+ y : 0,
+ z : 0,
+ w : Math.cos(radians / 2)
+ })
+ ));
+
+ // Rotate 90 degrees about z axis, then move 1 meter along x axis.
+ space2 = space2.getOffsetReferenceSpace(new XRRigidTransform(
+ DOMPointReadOnly.fromPoint({
+ x : 1,
+ y : 0,
+ z : 0,
+ w : 1
+ }),
+ DOMPointReadOnly.fromPoint({
+ x : 0,
+ y : 0,
+ z : Math.sin(radians / 2),
+ w : Math.cos(radians / 2)
+ })
+ ));
+
+ let space2_from_space1 = xrFrame.getPose(space1, space2);
+ const EXPECTED_POSE_MATRIX = [
+ 0, -1, 0, 0, // 1st column
+ 0, 0, 1, 0, // 2nd column
+ -1, 0, 0, 0, // 3rd column
+ 1, 1, 0, 1 // 4th column
+ ];
+
+ t.step(() => {
+ assert_matrix_approx_equals(space2_from_space1.transform.matrix, EXPECTED_POSE_MATRIX, FLOAT_EPSILON);
+ });
+
+ // Finished test.
+ resolve();
+ }
+
+ session.requestAnimationFrame(onFrame);
+ }));
+};
+
+xr_session_promise_test(immersiveTestName, testFunction,
+ fakeDeviceInitParams, 'immersive-vr');
+xr_session_promise_test(nonImmersiveTestName, testFunction,
+ fakeDeviceInitParams, 'inline', { 'requiredFeatures': ['local'] });
+
+</script>