blob: 6b1985ef56084a524e7eeb5f3773bb8183266f5f [file] [log] [blame]
<!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="../xr/resources/xr-test-utils.js"></script>
<script src="../xr/resources/test-constants.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let testName = "XRView projection matrices update near and far depths on the "
+ "next frame";
let fakeDeviceInitParams = { supportsImmersive:true };
let requestSessionOptions = [{ immersive: true }];
let testFunction = function(session, t, fakeDeviceController) {
// Session must have a baseLayer or frame requests will be ignored.
session.baseLayer = new XRWebGLLayer(session, gl);
// Need to have a valid pose or input event's don't process.
fakeDeviceController.setXRPresentationFrameData(VALID_POSE_MATRIX, [{
eye:"left",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewMatrix: VALID_VIEW_MATRIX
}, {
eye:"right",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewMatrix: VALID_VIEW_MATRIX
}]);
return session.requestFrameOfReference("eye-level")
.then((frameOfRef) => new Promise((resolve) =>{
let counter = 0;
function onFrame(time, xrFrame) {
if (counter == 0) {
session.requestAnimationFrame(onFrame);
assert_matrices_approx_equal(xrFrame.views[0].projectionMatrix, VALID_PROJECTION_MATRIX);
assert_matrices_approx_equal(xrFrame.views[1].projectionMatrix, VALID_PROJECTION_MATRIX);
// Update the near and far depths for the session.
session.depthNear = 1.0;
session.depthFar = 10.0;
// The projection matrices the views report should not take into
// account the new session depth values this frame.
assert_matrices_approx_equal(xrFrame.views[0].projectionMatrix, VALID_PROJECTION_MATRIX);
assert_matrices_approx_equal(xrFrame.views[1].projectionMatrix, VALID_PROJECTION_MATRIX);
} else {
// New depth values should be retained between frames.
assert_equals(session.depthNear, 1.0);
assert_equals(session.depthFar, 10.0);
// Projection matricies should now reflect the new depth values, i.e.
// have changed.
assert_matrices_significantly_not_equal(xrFrame.views[0].projectionMatrix, VALID_PROJECTION_MATRIX);
assert_matrices_significantly_not_equal(xrFrame.views[1].projectionMatrix, VALID_PROJECTION_MATRIX);
resolve();
}
counter++;
}
session.requestAnimationFrame(onFrame);
}));
};
xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionOptions, testName);
</script>