I’m currently updating my WebVR projects to the WebXR-Polyfill.
The Stereo VR mode is no problem, but how could the magic window mode be integrated? In the old WebVR implementation it was a simple assignment of:
this.cameraEntity.camera.vrDisplay = this.app.vr.display;
Is there a similiar functionality within the xr-Implementation? Or do I have to write my own mapping of the device orientation to the camera?
I also have to note that I currently route all xr-Stuff to the WebXR-Polyfill (also native xr-capable devices -> android). The current code sections is this:
// enter stereo-vr
this.enterVRbutton.element.on('click', function() {
// check support -> currently bypassed to set all devices to webVRPolyfill
if (this.app.xr.isAvailable(pc.XRTYPE_VR && false)) {
// start session
this.cameraEntity.camera.startXr(pc.XRTYPE_VR, pc.XRSPACE_LOCAL);
} else {
//this.cameraEntity.camera.enterVr(()=>{});
this.cameraEntity.camera.startXr(pc.XRTYPE_VR, pc.XRSPACE_LOCAL);
this.vrPolyfillActive = true;
}
}, this);
// enter magic window vr
this.enterMirrorbutton.element.on('click', function() {
if(!this.app.vrMirror){
// Enable device orientation for iOS
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
DeviceOrientationEvent.requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
this.cameraEntity.camera.vrDisplay = this.app.xr.display;
this.app.vrMirror = true;
}
}).catch(console.error);
} else {
this.cameraEntity.camera.vrDisplay = this.app.xr.display;
this.app.vrMirror = true;
}
} else {
this.app.vrMirror = false;
}
},this);
As always thanks for any help.