xrStationaryReferenceSpace_floorlevel_updates.https.html (2844B)
1 <!DOCTYPE html> 2 <script src=/resources/testharness.js></script> 3 <script src=/resources/testharnessreport.js></script> 4 <script src="resources/webxr_util.js"></script> 5 <script src="resources/webxr_test_constants.js"></script> 6 <script src="resources/webxr_test_asserts.js"></script> 7 8 <script> 9 let immersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " + 10 "the transform changes for immersive sessions"; 11 let nonImmersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " + 12 "the transform changes for non-immersive sessions"; 13 14 let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; 15 16 let testFunction = function(session, fakeDeviceController, t) { 17 // Don't need to request a frame/allow the stage updates to propagate before 18 // requesting local-floor because if the stage transform is set it just won't 19 // be emulated on the first frame, and we wait a frame before checking. 20 return session.requestReferenceSpace('local-floor') 21 .then((referenceSpace) => new Promise((resolve, reject) => { 22 function onFirstFrame(time, xrFrame) { 23 // On the first frame where the pose has been initialized, the stage 24 // should be using an emulated frame of reference because it has no 25 // stageParameters yet. So the pose should be ~1.5 meters off the floor. 26 t.step( () => { 27 let pose = xrFrame.getViewerPose(referenceSpace); 28 29 let poseMatrix = pose.transform.matrix; 30 assert_approx_equals(poseMatrix[12], 0.0, FLOAT_EPSILON); 31 assert_greater_than(poseMatrix[13], 1.0); 32 assert_approx_equals(poseMatrix[14], 0.0, FLOAT_EPSILON); 33 34 fakeDeviceController.setFloorOrigin(VALID_FLOOR_ORIGIN); 35 36 // Need to request one animation frame for the new stage transform to 37 // propagate before we check that it's what we expect. 38 requestSkipAnimationFrame(session, onFrame); 39 }); 40 } 41 42 function onFrame(time, xrFrame) { 43 t.step( () => { 44 // Check that stage transform was updated. 45 let pose = xrFrame.getViewerPose(referenceSpace); 46 assert_not_equals(pose, null); 47 48 let poseMatrix = pose.transform.matrix; 49 assert_matrix_approx_equals(poseMatrix, VALID_FLOOR_ORIGIN_MATRIX); 50 }); 51 52 // Finished. 53 resolve(); 54 } 55 56 // Need to wait one frame for the removal to propagate before we check that 57 // everything is at the expected emulated position. 58 requestSkipAnimationFrame(session, onFirstFrame); 59 })); 60 }; 61 62 xr_session_promise_test(immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr', { 'requiredFeatures': ['local-floor'] }); 63 xr_session_promise_test(nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline', { 'requiredFeatures': ['local-floor'] }); 64 65 </script>