mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Use more complex view positions
This commit is contained in:
parent
167ea556ce
commit
745ed51172
2 changed files with 8 additions and 8 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue