Open psusset opened 3 years ago
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
It seems that the
DeviceOrientationEvent
permission is required for iOS devices. I'm not sure if it should be added inWebVRDevice
https://github.com/immersive-web/webxr-polyfill/blob/main/src/devices/WebVRDevice.js or inCardboardXRDevice
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
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); } });