Skip to content

Commit

Permalink
Make WebXR WPT tests use viewOffset when appropriate
Browse files Browse the repository at this point in the history
Now that both position and orientation are used, some expected view
matrices had to be updated.

Bug: 1001733
Change-Id: I3dacd02ff724c0f173fae2c3473014df9fc6d8b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795492
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695308}
  • Loading branch information
Jacob DeWitt authored and chromium-wpt-export-bot committed Sep 10, 2019
1 parent 1af3e94 commit d550f11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
21 changes: 11 additions & 10 deletions resources/chromium/webxr-test.js
Expand Up @@ -45,12 +45,9 @@ function getMatrixFromTransform(transform) {
m14, m24, m34, 1];
}

function getGFXTransformFromPosition(x, y, z) {
function composeGFXTransform(fakeTransformInit) {
let transform = new gfx.mojom.Transform();
transform.matrix = getMatrixFromTransform({
position: [x, y, z],
orientation: [0, 0, 0, 1]
});
transform.matrix = getMatrixFromTransform(fakeTransformInit);
return transform;
}

Expand Down Expand Up @@ -378,7 +375,10 @@ class MockRuntime {
leftDegrees: 50.899,
rightDegrees: 35.197
},
headFromEye: getGFXTransformFromPosition(-0.032, 0, 0),
headFromEye: composeGFXTransform({
position: [-0.032, 0, 0],
orientation: [0, 0, 0, 1]
}),
renderWidth: 20,
renderHeight: 20
},
Expand All @@ -389,7 +389,10 @@ class MockRuntime {
leftDegrees: 50.899,
rightDegrees: 35.197
},
headFromEye: getGFXTransformFromPosition(0.032, 0, 0),
headFromEye: composeGFXTransform({
position: [0.032, 0, 0],
orientation: [0, 0, 0, 1]
}),
renderWidth: 20,
renderHeight: 20
},
Expand All @@ -415,16 +418,14 @@ class MockRuntime {
let upTan = (1 + m[9]) / m[5];
let downTan = (1 - m[9]) / m[5];

let offset = fakeXRViewInit.viewOffset.position;

return {
fieldOfView: {
upDegrees: toDegrees(upTan),
downDegrees: toDegrees(downTan),
leftDegrees: toDegrees(leftTan),
rightDegrees: toDegrees(rightTan)
},
headFromEye: getGFXTransformFromPosition(offset[0], offset[1], offset[2]),
headFromEye: composeGFXTransform(fakeXRViewInit.viewOffset),
renderWidth: fakeXRViewInit.resolution.width,
renderHeight: fakeXRViewInit.resolution.height
};
Expand Down
8 changes: 4 additions & 4 deletions webxr/xrReferenceSpace_originOffset.https.html
Expand Up @@ -11,7 +11,7 @@

const VIEW_OFFSET_WITH_ROTATION = {
position: [4, 3, 2],
orientation: [0, -0.71, 0, 0.71 ]
orientation: [0, -0.7071, 0, 0.7071 ]
};

const VIEWS_WITH_OFFSET = [{
Expand Down Expand Up @@ -55,15 +55,15 @@

const RADIANS_90D = Math.PI / 2;

const EXPECTED_VIEW_MATRIX_1 = [0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, -5, -4, -3, 1];
const EXPECTED_VIEW_MATRIX_1 = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, -3, -4, 5, 1];
const EXPECTED_GRIP_MATRIX_1 = [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 3, 1];
const EXPECTED_RAY_MATRIX_1 = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1];

const EXPECTED_VIEW_MATRIX_2 = [0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, -8, 1, 7, 1];
const EXPECTED_VIEW_MATRIX_2 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7, 1, 8, 1];
const EXPECTED_GRIP_MATRIX_2 = [0, -1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, -9, -2, -5, 1];
const EXPECTED_RAY_MATRIX_2 = [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, -8, -4, -5, 1];

const EXPECTED_VIEW_MATRIX_3 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -8, 3, 12, 1];
const EXPECTED_VIEW_MATRIX_3 = [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 12, 3, 8, 1];
const EXPECTED_GRIP_MATRIX_3 = [0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 5, -4, -14, 1];
const EXPECTED_RAY_MATRIX_3 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, -6, -13, 1];

Expand Down
6 changes: 3 additions & 3 deletions webxr/xrReferenceSpace_originOffsetBounded.https.html
Expand Up @@ -87,9 +87,9 @@
let grip_matrix = grip_pose.transform.matrix;
let ray_matrix = input_pose.transform.matrix;

assert_matrix_approx_equals(expected_view_matrix, view_matrix);
assert_matrix_approx_equals(expected_grip_matrix, grip_matrix);
assert_matrix_approx_equals(expected_ray_matrix, ray_matrix);
assert_matrix_approx_equals(view_matrix, expected_view_matrix);
assert_matrix_approx_equals(grip_matrix, expected_grip_matrix);
assert_matrix_approx_equals(ray_matrix, expected_ray_matrix);

assert_equals(reference_space.boundsGeometry.length, expected_bounds_geometry.length);
for (var i = 0; i < reference_space.boundsGeometry.length; ++i) {
Expand Down

0 comments on commit d550f11

Please sign in to comment.