| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script> |
| <script src="file:///gen/device/vr/public/mojom/vr_service.mojom.js"></script> |
| <script src="../external/wpt/resources/chromium/webxr-test.js"></script> |
| <script src="../external/wpt/webxr/resources/webxr_test_constants.js"></script> |
| <script src="../xr/resources/xr-internal-device-mocking.js"></script> |
| <script src="../xr/resources/xr-test-utils.js"></script> |
| <canvas id="webgl-canvas"></canvas> |
| |
| <script> |
| let testName = |
| "'floor-level' XRStationaryReferenceSpace updates properly when the transform changes"; |
| |
| let fakeDeviceInitParams = { supportsImmersive:true }; |
| |
| let requestSessionModes = [ |
| 'inline', |
| 'immersive-vr', |
| ]; |
| |
| let testFunction = function(session, t, fakeDeviceController) { |
| // Session must have a baseLayer or else frame requests will be ignored. |
| session.updateRenderState({ |
| baseLayer: new XRWebGLLayer(session, gl, { |
| compositionDisabled: session.mode == 'inline' }) |
| }); |
| |
| fakeDeviceController.setStageTransform(null); |
| fakeDeviceController.setXRPresentationFrameData(ORIGIN_POSE, [{ |
| eye:"left", |
| projectionMatrix: VALID_PROJECTION_MATRIX, |
| viewMatrix: VALID_VIEW_MATRIX |
| }, { |
| eye:"right", |
| projectionMatrix: VALID_PROJECTION_MATRIX, |
| viewMatrix: VALID_VIEW_MATRIX |
| }]); |
| |
| // Don't need to request a frame/allow the stage updates to propagate before |
| // requesting local-floor because if the stage transform is set it just won't |
| // be emulated on the first frame, and we wait a frame before checking. |
| return session.requestReferenceSpace('local-floor') |
| .then((referenceSpace) => new Promise((resolve, reject) => { |
| function onFirstFrame(time, xrFrame) { |
| // On the first frame where the pose has been initialized, the stage |
| // should be using an emulated frame of reference because it has no |
| // stageParameters yet. So the pose should be ~1.5 meters off the floor. |
| t.step( () => { |
| let pose = xrFrame.getViewerPose(referenceSpace); |
| |
| let poseMatrix = pose.transform.matrix; |
| assert_approx_equals(poseMatrix[12], 0.0, FLOAT_EPSILON); |
| assert_greater_than(poseMatrix[13], 1.0); |
| assert_approx_equals(poseMatrix[14], 0.0, FLOAT_EPSILON); |
| |
| fakeDeviceController.setStageTransform(VALID_STAGE_TRANSFORM); |
| |
| // Need to request one animation frame for the new stage transform to |
| // propagate before we check that it's what we expect. |
| session.requestAnimationFrame(() => { |
| session.requestAnimationFrame(onFrame); |
| }); |
| }); |
| } |
| |
| function onFrame(time, xrFrame) { |
| t.step( () => { |
| // Check that stage transform was updated. |
| let pose = xrFrame.getViewerPose(referenceSpace); |
| assert_not_equals(pose, null); |
| |
| let poseMatrix = pose.transform.matrix; |
| assert_matrices_approx_equal(poseMatrix, VALID_STAGE_TRANSFORM); |
| }); |
| |
| // Finished. |
| resolve(); |
| } |
| |
| // Need to wait one frame for the removal to propagate before we check that |
| // everything is at the expected emulated position. |
| session.requestAnimationFrame(() => { |
| session.requestAnimationFrame(onFirstFrame); |
| }); |
| })); |
| }; |
| |
| xr_session_promise_test( |
| testFunction, fakeDeviceInitParams, requestSessionModes, testName); |
| |
| </script> |