Skip to content

Commit

Permalink
createGraphicsDevice defautls options.xrCompatible to true (#5349)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <[email protected]>
  • Loading branch information
mvaligursky and Martin Valigursky committed May 25, 2023
1 parent 6e21e8a commit 44eec78
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/platform/graphics/graphics-device-create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Debug } from '../../core/debug.js';
import { platform } from '../../core/platform.js';

import { WebgpuGraphicsDevice } from './webgpu/webgpu-graphics-device.js';
import { DEVICETYPE_WEBGL2, DEVICETYPE_WEBGL1, DEVICETYPE_WEBGPU } from './constants.js';
Expand All @@ -24,6 +25,8 @@ import { WebglGraphicsDevice } from './webgl/webgl-graphics-device.js';
* {@link DEVICETYPE_WEBGPU} type is added to deviceTypes array. Not used for
* {@link DEVICETYPE_WEBGL} device type creation.
* @param {string} [options.twgslUrl] - An url to twgsl script, required if glslangUrl was specified.
* @param {boolean} [options.xrCompatible] - Boolean that hints to the user agent to use a
* compatible graphics adapter for an immersive XR device.
* @returns {Promise} - Promise object representing the created graphics device.
*/
function createGraphicsDevice(canvas, options = {}) {
Expand All @@ -38,6 +41,11 @@ function createGraphicsDevice(canvas, options = {}) {
deviceTypes.push(DEVICETYPE_WEBGL1);
}

// XR compatibility if not specified
if (platform.browser && !!navigator.xr) {
options.xrCompatible ??= true;
}

let device;
for (let i = 0; i < deviceTypes.length; i++) {
const deviceType = deviceTypes[i];
Expand Down

0 comments on commit 44eec78

Please sign in to comment.