Skip to content

Commit

Permalink
simplify offerSession implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
cabanier committed Dec 11, 2023
1 parent ac29977 commit e173bb9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/components/scene/xr-mode-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ module.exports.Component = registerComponent('xr-mode-ui', {

this.orientationModalEl = createOrientationModal(this.onModalClick);
sceneEl.appendChild(this.orientationModalEl);

this.updateEnterInterfaces();
},

remove: function () {
Expand Down
6 changes: 0 additions & 6 deletions src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class AScene extends AEntity {

// Don't enter VR if already in VR.
if (navigator.xr.offerSession === undefined) { return Promise.resolve('OfferSession is not supported.'); }
if (this.is('has-offer-session')) { return Promise.resolve('Already has offerSession.'); }
if (this.is('vr-mode')) { return Promise.resolve('Already in VR.'); }

// Has VR.
Expand All @@ -297,13 +296,9 @@ class AScene extends AEntity {
xrInit = this.sceneEl.systems.webxr.sessionConfiguration;
return new Promise(function (resolve, reject) {
var requestFunction = useOfferSession ? navigator.xr.offerSession.bind(navigator.xr) : navigator.xr.requestSession.bind(navigator.xr);
if (useOfferSession) {
self.addState('has-offer-session');
}
requestFunction(xrMode, xrInit).then(
function requestSuccess (xrSession) {
self.xrSession = xrSession;
self.removeState('has-offer-session');

vrManager.layersEnabled = xrInit.requiredFeatures.indexOf('layers') !== -1;
vrManager.setSession(xrSession).then(function () {
Expand All @@ -314,7 +309,6 @@ class AScene extends AEntity {
enterVRSuccess(resolve);
},
function requestFail (error) {
self.removeState('has-offer-session');
var useAR = xrMode === 'immersive-ar';
var mode = useAR ? 'AR' : 'VR';
reject(new Error('Failed to enter ' + mode + ' mode (`requestSession`)', { cause: error }));
Expand Down

0 comments on commit e173bb9

Please sign in to comment.