File: getInputPose_pointer.https.html

package info (click to toggle)
firefox-esr 78.15.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,301,156 kB
  • sloc: cpp: 5,665,905; javascript: 4,798,386; ansic: 2,878,233; python: 977,004; asm: 270,347; xml: 181,456; java: 111,756; sh: 72,926; makefile: 21,819; perl: 13,380; cs: 4,725; yacc: 4,565; objc: 3,026; pascal: 1,787; lex: 1,720; ada: 1,681; exp: 505; php: 436; lisp: 260; awk: 152; ruby: 103; csh: 80; sed: 53; sql: 45
file content (97 lines) | stat: -rw-r--r-- 3,527 bytes parent folder | download | duplicates (4)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!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>
<canvas id="webgl-canvas"></canvas>

<script>

let testName = "XRInputSources with a target ray mode of 'tracked-pointer' "
  + "properly communicate their poses";

let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;

let testFunction =
  (session, fakeDeviceController, t) => new Promise((resolve) => {
    let input_source = fakeDeviceController.simulateInputSourceConnection({
      handedness: "right",
      targetRayMode: "tracked-pointer",
      pointerOrigin: IDENTITY_TRANSFORM,
      profiles: []
    });

    // Don't set a grip matrix yet

    // Must have a reference space to get input poses. eye-level doesn't apply
    // any transforms to the given matrix.
    session.requestReferenceSpace('local').then( (referenceSpace) => {

      function CheckInvalidGrip(time, xrFrame) {
        let source = session.inputSources[0];
        let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace);

        t.step( () => {
          // The input pose should be null when no grip matrix is provided.
          assert_equals(source.targetRayMode, "tracked-pointer");
          assert_equals(grip_pose, null);
        });

        input_source.setGripOrigin(VALID_GRIP_TRANSFORM);

        session.requestAnimationFrame(CheckValidGrip);
      }

      function CheckValidGrip(time, xrFrame) {
        let source = session.inputSources[0];

        let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace);

        let input_pose = xrFrame.getPose(source.targetRaySpace, referenceSpace);

        t.step( () => {
          // When a grip matrix is set, both the grip and pointer matrices
          // should yield their set values (i.e. the pointerOrigin is *not*
          // transformed by the gripOrigin).
          assert_not_equals(grip_pose, null);
          assert_matrix_approx_equals(grip_pose.transform.matrix, VALID_GRIP,
            FLOAT_EPSILON, "Grip matrix is not equal to input.");
          assert_matrix_approx_equals(input_pose.transform.matrix,
            IDENTITY_MATRIX, FLOAT_EPSILON,
            "Pointer matrix is not equal to its set value.");
        });

        input_source.setPointerOrigin(VALID_POINTER_TRANSFORM);

        session.requestAnimationFrame(CheckValidGripAndPointer);
      }

      function CheckValidGripAndPointer(time, xrFrame) {
        let source = session.inputSources[0];

        let grip_pose = xrFrame.getPose(source.gripSpace, referenceSpace);
        let input_pose = xrFrame.getPose(source.targetRaySpace, referenceSpace);

        t.step( () => {
          // Verify that changes to the pointer origin are properly reflected.
          assert_not_equals(grip_pose, null);
          assert_matrix_approx_equals(grip_pose.transform.matrix, VALID_GRIP,
            FLOAT_EPSILON, "Grip matrix is not equal to input valid grip.");
          assert_matrix_approx_equals(input_pose.transform.matrix,
            VALID_POINTER, FLOAT_EPSILON,
            "Pointer matrix not set properly.");
        });

        resolve();
      }

      // Can only request input poses in an xr frame.
      requestSkipAnimationFrame(session, CheckInvalidGrip);
    });
  });

xr_session_promise_test(
  testName, testFunction, fakeDeviceInitParams, 'immersive-vr');

</script>