Commit 52e5e82f authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

Fix AR samples to work on ToT

This CL updates the uses of WebXR API in test pages.
Additionally, there is an update needed in webxr-version-shim.js.

Change-Id: If50624de7fed88c612751f709397755344e467c1
Reviewed-on: https://chromium-review.googlesource.com/c/1431915
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Auto-Submit: Piotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625430}
parent 127d9542
media/
\ No newline at end of file
......@@ -7,8 +7,16 @@ Date: 2019-01-15
License: MIT
License File: NOT_SHIPPED
Security Critical: no
Description:
A fork of the WebXR samples to be kept in sync with Chrome and used for testing Chrome.
Local Modifications:
Forked to provide a stable set of test pages in sync with Chrome.
Stripped out the media/ directory to minimize the size.
Instructions:
In order to serve the samples locally, few steps are required:
1. Copy contents of src/chrome/test/data/xr/webxr_samples/media into src/third_party/webxr_test_pages/webxr-samples/media
2. (optional) If editing cottontail code, run `npm install` and `npm run build-all` in src/third_party/webxr_test_pages/webxr-samples/js/cottontail
3. Serve files, for example by running `python -m SimpleHTTPServer <port number>` in src/third_party/webxr_test_pages/webxr-samples
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -24,7 +24,7 @@
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"gl-matrix": "^2.5.1",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1"
}
}
......@@ -25,10 +25,10 @@ import {Node} from '../core/node.js';
import {vec3, quat} from '../math/gl-matrix.js';
export class WebXRView extends RenderView {
constructor(view, pose, layer) {
constructor(view, layer) {
super(
view ? view.projectionMatrix : null,
(pose && view) ? pose.getViewMatrix(view) : null,
view ? view.viewMatrix : null,
(layer && view) ? layer.getViewport(view) : null,
view ? view.eye : 'left'
);
......@@ -253,8 +253,8 @@ export class Scene extends Node {
}
let views = [];
for (let view of xrFrame.views) {
views.push(new WebXRView(view, pose, layer));
for (let view of pose.views) {
views.push(new WebXRView(view, layer));
}
this.drawViewArray(views);
......
......@@ -108,25 +108,28 @@ class WebXRVersionShim {
// We can't test for the existence of the enums in question directly, so this code
// will just try to create the requested type and fall back if it fails.
const NATIVE_REQUEST_FRAME_OF_REFERENCE = XRSession.prototype.requestFrameOfReference;
XRSession.prototype.requestFrameOfReference = function(type, options) {
const NATIVE_REQUEST_FRAME_OF_REFERENCE = XRSession.prototype.requestReferenceSpace;
XRSession.prototype.requestFrameOfReference = function(type, options_original) {
let session = this;
let options = options_original || {};
options["type"] = "stationary";
options["subtype"] = type;
// Try the current type.
return NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, type, options).catch((error)=>{
return NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, options).catch((error)=>{
// FIXME: Should be checking for TypeError specifically. Requires a polyfill update.
if(error instanceof Error) {
// If the current type fails, switch to the other version.
switch(type) {
case 'eye-level':
type = 'eyeLevel';
options["subtype"] = 'eyeLevel';
break;
case 'head-model':
type = 'headModel';
options["subtype"] = 'headModel';
break;
default:
return Promise.reject(error);
}
return Promise.resolve(NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, type, options));
return Promise.resolve(NATIVE_REQUEST_FRAME_OF_REFERENCE.call(session, options));
} else {
return Promise.reject(error);
}
......
......@@ -144,7 +144,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if (!gl) {
gl = createWebGLContext({
compatibleXRDevice: session.device
compatibleXRDevice: session.device,
xrCompatible : true,
});
renderer = new Renderer(gl);
......@@ -226,7 +227,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Called every time a XRSession requests that a new frame be drawn.
function onXRFrame(t, frame) {
let session = frame.session;
let pose = frame.getDevicePose(xrFrameOfRef);
let pose = frame.getViewerPose(xrFrameOfRef);
// If requested, use the pose to cast a reticle into the scene using a
// continuous hit test. For the moment we're just using the flower
......
......@@ -139,7 +139,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if (!gl) {
gl = createWebGLContext({
compatibleXRDevice: session.device
compatibleXRDevice: session.device,
xrCompatible : true,
});
renderer = new Renderer(gl);
......@@ -168,7 +169,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Called every time a XRSession requests that a new frame be drawn.
function onXRFrame(t, frame) {
let session = frame.session;
let pose = frame.getDevicePose(xrFrameOfRef);
let pose = frame.getViewerPose(xrFrameOfRef);
scene.startFrame();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment