Auto merge of #23731 - Manishearth:webxr-script, r=asajeffrey

Use new WebXR API in script

Todo:
 - [x] Hook new `Frame` information into `XRFrame`
 - [x] Make spaces use new transform info
 - [x] Hook up session view metadata correctly
 - [x] Get mocking working again
 - [x] Get inputs working

Optional todos:
 - [x] Add support for active and animationFrame bool on XRFrame
 - [x] Correctly handle viewer and offset spaces instead of casting
 - [x] Error on zero-length quaternions

<s>Not really ready for review yet, but you can go ahead and review what I have so far. It doesn't do anything yet, aside from crash horribly. I'm opening this PR early so i have a place to track progress.</s>

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23731)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-07-11 18:31:21 -04:00 committed by GitHub
commit 5fdc7c0d2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 703 additions and 486 deletions

View file

@ -19687,11 +19687,11 @@
"testharness"
],
"webxr/obtain_frame.html": [
"e2b4424d5779baedf6bdb50f1b3151336f31a4cb",
"063008c7ebc0df9997b8286296b4f7fe4663b331",
"testharness"
],
"webxr/resources/webxr-util.js": [
"554c1c183d3710e54dc60704dad0aac542ffd67c",
"f0c166e097271fd6a2709428fab2ccffea1eb08a",
"support"
]
},

View file

@ -54,9 +54,9 @@
pose = frame.getViewerPose(offset);
for (view of pose.views) {
if (view.eye == "left") {
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.4,-1.9,-0.9,1], 0.001, "left offset transform");
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.5 + 1/30,-1.9 + 2/30,-0.9 - 2/30,1], 0.001, "left offset transform");
} else if (view.eye == "right") {
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.6,-1.9,-0.9,1], 0.001, "right offset transform");
assert_matrix_approx_equals(view.transform.matrix, [-1/3,-2/3,2/3,0,-2/3,2/3,1/3,0,-2/3,-1/3,-2/3,0,3.5 - 1/30,-1.9 - 2/30,-0.9 + 2/30,1], 0.001, "right offset transform");
} else {
throw "got unknown view";
}

View file

@ -1,10 +1,9 @@
// pieced together from various things in wpt/webxr/resources
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};
const LEFT_OFFSET = {position: [-0.1, 0, 0], orientation: [0,0,0,1]};
const RIGHT_OFFSET = {position: [0.1, 0, 0], orientation: [0,0,0,1]};
const RESOLUTION = {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) {
@ -13,6 +12,6 @@ let assert_matrix_approx_equals = function(m1, m2, epsilon, prefix = "") {
}
const TEST_VIEWS = [
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, viewport: LEFT_VIEWPORT},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, viewport: RIGHT_VIEWPORT}
{eye: "left", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: LEFT_OFFSET, resolution: RESOLUTION},
{eye: "right", projectionMatrix: VALID_PROJECTION_MATRIX, viewOffset: RIGHT_OFFSET, resolution: RESOLUTION}
];