Update to latest xrtest api

This commit is contained in:
Manish Goregaokar 2019-06-26 16:34:50 -07:00
parent faea7716cf
commit c19240a454
17 changed files with 269 additions and 190 deletions

View file

@ -11,9 +11,11 @@
let canvas = document.getElementById("canvas");
let gl = canvas.getContext('webgl');
promise_test(async function() {
let mock = await navigator.xr.test.simulateDeviceConnection({supportsImmersive: true});
mock.setViewerOrigin({position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] });
mock.setViews(TEST_VIEWS);
let mock = await navigator.xr.test.simulateDeviceConnection({
supportsImmersive: true,
views: TEST_VIEWS,
viewerOrigin: {position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] }
});
let session = await navigator.xr.requestSession({mode: "immersive-vr"});
await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})});
let resolve;

View file

@ -3,7 +3,8 @@
const VALID_PROJECTION_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
const LEFT_OFFSET = {position: [-0.1, 0, 0], orientation: [0,0,0,0]};
const RIGHT_OFFSET = {position: [0.1, 0, 0], orientation: [0,0,0,0]};
const LEFT_VIEWPORT = {x: 0, y: 0, width: 320, height: 480};
const RIGHT_VIEWPORT = {x: 320, y: 0, width: 320, height: 480};
let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
assert_equals(m1.length, m2.length, prefix + "Matrix lengths should match");
for(var i = 0; i < m1.length; ++i) {
@ -12,6 +13,6 @@ let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
}
const TEST_VIEWS = [
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET}
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, viewport: LEFT_VIEWPORT},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, viewport: RIGHT_VIEWPORT}
];