Skip to content

Commit

Permalink
Fix WebXR depth sensing on quest 3 (#6774)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims authored and willeastcott committed Jul 2, 2024
1 parent d577fd5 commit c89e232
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/framework/xr/xr-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,19 +478,24 @@ class XrManager extends EventHandler {
if (options && options.depthSensing && this.depthSensing.supported) {
opts.optionalFeatures.push('depth-sensing');

const usagePreference = [XRDEPTHSENSINGUSAGE_CPU];
const dataFormatPreference = [XRDEPTHSENSINGFORMAT_L8A8];

if (options.depthSensing.usagePreference) {
const ind = usagePreference.indexOf(options.depthSensing.usagePreference);
if (ind !== -1) usagePreference.splice(ind, 1);
usagePreference.unshift(options.depthSensing.usagePreference);
}

if (options.depthSensing.dataFormatPreference) {
const ind = dataFormatPreference.indexOf(options.depthSensing.dataFormatPreference);
if (ind !== -1) dataFormatPreference.splice(ind, 1);
dataFormatPreference.unshift(options.depthSensing.dataFormatPreference);
const usagePreference = [];
const dataFormatPreference = [];

if (!navigator.userAgent.includes('OculusBrowser')) {
usagePreference.push(XRDEPTHSENSINGUSAGE_CPU);
dataFormatPreference.push(XRDEPTHSENSINGFORMAT_L8A8);

if (options.depthSensing.usagePreference) {
const ind = usagePreference.indexOf(options.depthSensing.usagePreference);
if (ind !== -1) usagePreference.splice(ind, 1);
usagePreference.unshift(options.depthSensing.usagePreference);
}

if (options.depthSensing.dataFormatPreference) {
const ind = dataFormatPreference.indexOf(options.depthSensing.dataFormatPreference);
if (ind !== -1) dataFormatPreference.splice(ind, 1);
dataFormatPreference.unshift(options.depthSensing.dataFormatPreference);
}
}

opts.depthSensing = {
Expand Down

0 comments on commit c89e232

Please sign in to comment.