Skip to content

Commit

Permalink
Fix some browser compatibility issues with the shim
Browse files Browse the repository at this point in the history
  • Loading branch information
toji committed May 23, 2019
1 parent dde9a01 commit e7e4540
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions js/webxr-version-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,22 +372,24 @@ class WebXRVersionShim {
const NATIVE_GET_CONTEXT = HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.getContext = function(type, options) {
if (type == 'webgl' || type == 'webgl2') {
if (options.xrCompatible) {
if (options && options.xrCompatible) {
options.compatibleXRDevice = shim._defaultDevice;
}
}
return NATIVE_GET_CONTEXT.call(this, type, options);
};

const NATIVE_OFFSCREEN_GET_CONTEXT = OffscreenCanvas.prototype.getContext;
OffscreenCanvas.prototype.getContext = function(type, options) {
if (type == 'webgl' || type == 'webgl2') {
if (options.xrCompatible) {
options.compatibleXRDevice = shim._defaultDevice;
if ('OffscreenCanvas' in window) {
const NATIVE_OFFSCREEN_GET_CONTEXT = OffscreenCanvas.prototype.getContext;
OffscreenCanvas.prototype.getContext = function(type, options) {
if (type == 'webgl' || type == 'webgl2') {
if (options && options.xrCompatible) {
options.compatibleXRDevice = shim._defaultDevice;
}
}
}
return NATIVE_OFFSCREEN_GET_CONTEXT.call(this, type, options);
};
return NATIVE_OFFSCREEN_GET_CONTEXT.call(this, type, options);
};
}
}

//===========================
Expand Down

0 comments on commit e7e4540

Please sign in to comment.