Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceOrientationEvent.requestPermission() #161

Open
psusset opened this issue Jul 20, 2021 · 2 comments
Open

DeviceOrientationEvent.requestPermission() #161

psusset opened this issue Jul 20, 2021 · 2 comments

Comments

@psusset
Copy link

psusset commented Jul 20, 2021

Hello,

In order to make this plugin work on iOS, you need to ask user permission for device orientation capture.
To do that, we need to insert the following code in the requestSession action.

navigator.xr.requestSession('immersive-vr', {
requiredFeatures: thisXRMananger.gameModule.WebXR.Settings.VRRequiredReferenceSpace,
optionalFeatures: thisXRMananger.gameModule.WebXR.Settings.VROptionalFeatures
}).then(
async (session) => {
if (typeof(DeviceOrientationEvent) !== "undefined" && typeof(DeviceOrientationEvent).requestPermission === 'function')
{
DeviceOrientationEvent.requestPermission()
.then(response => {
if (response === 'granted') {

session.isImmersive = true;
session.isInSession = true;
session.isAR = false;
thisXRMananger.xrSession = session;
thisXRMananger.onSessionStarted(session);
}
}).catch(function (error) {
thisXRMananger.BrowserObject.resumeAsyncCallbacks();
thisXRMananger.BrowserObject.mainLoop.resume();
});

} else {
session.isImmersive = true;
session.isInSession = true;
session.isAR = false;
thisXRMananger.xrSession = session;
thisXRMananger.onSessionStarted(session);
}

});

@De-Panther
Copy link
Contributor

It seems that the DeviceOrientationEvent permission is required for iOS devices.
I'm not sure if it should be added in WebVRDevice
https://github.com/immersive-web/webxr-polyfill/blob/main/src/devices/WebVRDevice.js
or in CardboardXRDevice
https://github.com/immersive-web/webxr-polyfill/blob/main/src/devices/CardboardXRDevice.js

@jsantell
Copy link
Contributor

It seems that the DeviceOrientationEvent permission is required for iOS devices.
I'm not sure if it should be added in WebVRDevice
https://github.com/immersive-web/webxr-polyfill/blob/main/src/devices/WebVRDevice.js
or in CardboardXRDevice
https://github.com/immersive-web/webxr-polyfill/blob/main/src/devices/CardboardXRDevice.js

The src/devices/WebVRDevice wraps native WebVR 1.1 implementations, and src/devices/CardboardXRDevice uses the rendering polyfill, cardboard-vr-display -- confusing, I know.

There's an open issue for permission change request for iOS there that's related to this. I don't have an iOS device to test this FWIW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants