xrSession_viewer_referenceSpace.https.html (2639B)
1 <!DOCTYPE html> 2 <body> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src="resources/webxr_util.js"></script> 6 <script src="resources/webxr_test_constants.js"></script> 7 8 <script> 9 10 let immersiveTestName = 11 "Identity reference space provides correct poses for immersive sessions"; 12 let inlineTestName = 13 "Identity reference space provides correct poses for inline sessions"; 14 15 let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; 16 17 let testFunction = function(session, fakeDeviceController, t) { 18 return session.requestReferenceSpace('viewer') 19 .then((referenceSpace) => new Promise((resolve, reject) => { 20 let counter = 0; 21 function onFrame(time, xrFrame) { 22 session.requestAnimationFrame(onFrame); 23 if (counter == 0) { 24 t.step( () => { 25 // Expect to always get a pose, even if none has been supplied. 26 let pose = xrFrame.getViewerPose(referenceSpace); 27 assert_not_equals(pose, null); 28 29 let poseMatrix = pose.transform.matrix; 30 assert_not_equals(poseMatrix, null); 31 32 for(let i = 0; i < poseMatrix.length; i++) { 33 // "0 +" is to accept -0 which is equivalent to 0 in the 34 // matrix. 35 assert_equals(0 + poseMatrix[i], IDENTITY_MATRIX[i]); 36 } 37 38 fakeDeviceController.setViewerOrigin(VALID_POSE_TRANSFORM); 39 }); 40 } else { 41 t.step( () => { 42 // Assert that the identity matrix is always given as the pose 43 // even when a valid pose is set by the device. 44 let pose = xrFrame.getViewerPose(referenceSpace); 45 assert_not_equals(pose, null); 46 47 let poseMatrix = pose.transform.matrix; 48 assert_not_equals(poseMatrix, null); 49 50 for(let i = 0; i < poseMatrix.length; i++) { 51 // "0 +" is to accept -0 which is equivalent to 0 in the 52 // matrix. 53 assert_equals(0 + poseMatrix[i], IDENTITY_MATRIX[i]); 54 } 55 }); 56 57 // Finished. 58 resolve(); 59 } 60 counter++; 61 } 62 63 session.requestAnimationFrame(onFrame); 64 })); 65 }; 66 67 xr_session_promise_test(inlineTestName, testFunction, 68 fakeDeviceInitParams, 'inline'); 69 xr_session_promise_test(immersiveTestName, testFunction, 70 fakeDeviceInitParams, 'immersive-vr'); 71 72 </script> 73 </body>