xrView_oneframeupdate.https.html (3159B)
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 10 let testName = "XRView projection matrices update near and far depths on the " 11 + "next frame"; 12 13 const fakeViews = [{ 14 eye:"left", 15 viewOffset: LEFT_OFFSET, 16 resolution: VALID_RESOLUTION, 17 fieldOfView: VALID_FIELD_OF_VIEW, 18 // The webxr-test-api requires that we still set this for now, but it is 19 // supposed to be ignored. 20 projectionMatrix: IDENTITY_MATRIX 21 }, { 22 eye:"right", 23 viewOffset: RIGHT_OFFSET, 24 resolution: VALID_RESOLUTION, 25 fieldOfView: VALID_FIELD_OF_VIEW, 26 // The webxr-test-api requires that we still set this for now, but it is 27 // supposed to be ignored. 28 projectionMatrix: IDENTITY_MATRIX 29 }, 30 ]; 31 32 let fakeDeviceInitParams = { 33 supportsImmersive: true, 34 supportedModes: ["inline", "immersive-vr"], 35 views: fakeViews, 36 viewerOrigin: IDENTITY_TRANSFORM, 37 supportedFeatures: ALL_FEATURES 38 }; 39 40 let testFunction = function(session, fakeDeviceController, t) { 41 return session.requestReferenceSpace('local') 42 .then((referenceSpace) => new Promise((resolve) =>{ 43 let counter = 0; 44 45 function onFrame(time, xrFrame) { 46 let pose = xrFrame.getViewerPose(referenceSpace); 47 assert_not_equals(pose, null); 48 assert_not_equals(pose.views, null); 49 assert_equals(pose.views.length, 2); 50 if (counter == 0) { 51 session.requestAnimationFrame(onFrame); 52 53 assert_matrix_approx_equals(pose.views[0].projectionMatrix, VALID_PROJECTION_MATRIX); 54 assert_matrix_approx_equals(pose.views[1].projectionMatrix, VALID_PROJECTION_MATRIX); 55 56 // Update the near and far depths for the session. 57 session.updateRenderState({ 58 depthNear: 1.0, 59 depthFar: 10.0 }); 60 61 // The projection matrices the views report should not take into 62 // account the new session depth values this frame. 63 assert_matrix_approx_equals(pose.views[0].projectionMatrix, VALID_PROJECTION_MATRIX); 64 assert_matrix_approx_equals(pose.views[1].projectionMatrix, VALID_PROJECTION_MATRIX); 65 } else { 66 // New depth values should be retained between frames. 67 assert_equals(session.renderState.depthNear, 1.0); 68 assert_equals(session.renderState.depthFar, 10.0); 69 70 // Projection matricies should now reflect the new depth values, i.e. 71 // have changed. 72 assert_matrix_significantly_not_equals(pose.views[0].projectionMatrix, VALID_PROJECTION_MATRIX); 73 assert_matrix_significantly_not_equals(pose.views[1].projectionMatrix, VALID_PROJECTION_MATRIX); 74 resolve(); 75 } 76 counter++; 77 } 78 79 session.requestAnimationFrame(t.step_func(onFrame)); 80 })); 81 }; 82 83 xr_session_promise_test( 84 testName, testFunction, fakeDeviceInitParams, 'immersive-vr'); 85 86 </script>