summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrReferenceSpace_relationships.https.html
blob: 5b680fb86182f9343da05b1842b77e182ae748a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!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_test_constants.js"></script>
<script src="resources/webxr_test_asserts.js"></script>
<script>
let testName =
  "Bounded space, viewer space, local and local-floor space have correct poses w.r.t. each other";
// 1m above world origin.
const VIEWER_ORIGIN_TRANSFORM = {
  position: [0, 1, 0],
  orientation: [0, 0, 0, 1],
};
// 0.25m above world origin.
const FLOOR_ORIGIN_TRANSFORM = {
  position: [0, 0.25, 0],
  orientation: [0, 0, 0, 1],
};
const fakeDeviceInitParams = {
    supportsImmersive: true,
    supportedModes: ["inline", "immersive-vr"],
    views: VALID_VIEWS,
    viewerOrigin: VIEWER_ORIGIN_TRANSFORM,
    floorOrigin: FLOOR_ORIGIN_TRANSFORM,
    supportedFeatures: ALL_FEATURES
};
let testFunction = function(session, fakeDeviceController, t) {
  return new Promise((resolve, reject) => {
    Promise.all([
      session.requestReferenceSpace('bounded-floor'),
      session.requestReferenceSpace('local'),
      session.requestReferenceSpace('local-floor'),
      session.requestReferenceSpace('viewer')
    ]).then(([boundedSpace, localSpace, localFloorSpace, viewerSpace]) => {
      t.step(() => {
      });
      const onFrame = function(time, xrFrame) {
        const localFloorPoseInLocalSpace = xrFrame.getPose(localFloorSpace, localSpace);
        const viewerPoseInLocalFloorSpace = xrFrame.getPose(viewerSpace, localFloorSpace);
        const boundedFloorPoseInLocalFloorSpace = xrFrame.getPose(boundedSpace, localFloorSpace);
        t.step(() => {
          // Local floor space is supposed to be 0.25m above local space (aka world space).
          assert_equals(localFloorPoseInLocalSpace.transform.position.y, 0.25);
          // Bounded floor space should be at the same height as local floor space.
          assert_equals(boundedFloorPoseInLocalFloorSpace.transform.position.y, 0.0);
          // Viewer space should be additional 0.75m above local-floor space.
          assert_equals(viewerPoseInLocalFloorSpace.transform.position.y, 0.75);
        });
        resolve();
      }
      session.requestAnimationFrame(onFrame);
    });
  });
};
xr_session_promise_test(testName, testFunction, fakeDeviceInitParams, 'immersive-vr', { 'requiredFeatures': ['local-floor', 'bounded-floor'] });
</script>