Skip to content
Permalink
Browse files

Use more complex view positions

  • Loading branch information...
Manishearth committed Jun 12, 2019
1 parent 167ea55 commit 745ed51172b436e1b3a704a474de7c533f36df5a
@@ -12,7 +12,7 @@
let gl = canvas.getContext('webgl');
promise_test(async function() {
let mock = await navigator.xr.test.simulateDeviceConnection({supportsImmersive: true});
mock.setViewerOrigin({position: [0.5, 0, 0, 1], orientation: [0, 0, 0, 1] });
mock.setViewerOrigin({position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] });
mock.setViews(TEST_VIEWS);
let session = await navigator.xr.requestSession({mode: "immersive-vr"});
await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})});
@@ -28,18 +28,18 @@
assert_matrix_approx_equals(view.projectionMatrix, VALID_PROJECTION_MATRIX, 0.001, "left projection matrix");
if (view.eye == "left") {
assert_matrix_approx_equals(view.transform.matrix, [1,0,0,0, 0,1,0,0, 0,0,1,0, 0.4,0,0,1], 0.001, "left transform");
assert_matrix_approx_equals(view.transform.matrix, [1,0,0,0,0,0,1,0,0,-1,0,0,0.4,0.1,0.1,1], 0.001, "left transform");
let position = view.transform.position;
assert_approx_equals(position.x, 0.4, 0.001, "left x value");
assert_approx_equals(position.y, 0, 0.001, "left y value");
assert_approx_equals(position.z, 0, 0.001, "left z value");
assert_approx_equals(position.y, 0.1, 0.001, "left y value");
assert_approx_equals(position.z, 0.1, 0.001, "left z value");
assert_approx_equals(position.w, 1, 0.001, "left w value");
} else if (view.eye == "right") {
assert_matrix_approx_equals(view.transform.matrix, [1,0,0,0, 0,1,0,0, 0,0,1,0, 0.6,0,0,1], 0.001, "right transform");
assert_matrix_approx_equals(view.transform.matrix, [1,0,0,0,0,0,1,0,0,-1,0,0,0.6,0.1,0.1,1], 0.001, "right transform");
let position = view.transform.position;
assert_approx_equals(position.x, 0.6, 0.001, "left x value");
assert_approx_equals(position.y, 0, 0.001, "left y value");
assert_approx_equals(position.z, 0, 0.001, "left z value");
assert_approx_equals(position.y, 0.1, 0.001, "left y value");
assert_approx_equals(position.z, 0.1, 0.001, "left z value");
assert_approx_equals(position.w, 1, 0.001, "left w value");
} else {
throw "got unknown view";
@@ -7,7 +7,7 @@ const RIGHT_OFFSET = {position: [0.1, 0, 0], orientation: [0,0,0,0]};
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) {
assert_approx_equals(m1[i], m2[i], epsilon, m1 + prefix + "Component number " + i + " should match");
assert_approx_equals(m1[i], m2[i], epsilon, prefix + "Component number " + i + " should match");
}
}

0 comments on commit 745ed51

Please sign in to comment.
You can’t perform that action at this time.