Got it working @Rechi ! Yaustar’s reply was enough for me to dig and find more on magic window, thanks dude!
The page for webvr seems to not exist anymore but luckily google keeps a cache so I looked here and realized that look-camera.js in the webvr project is doing this on initialize
So I debugged the camera with the vrdisplay and found a way to get pose orientation data (way without VR)
if (this.app.vr && this.app.vr.display) {
if (self.vrEntered) {
pose = this.app.vr.display.getFrameData().pose.orientation;
//console.log('vr: ', this.app.vr.display);
this.camera.setLocalRotation(pose[0], pose[1], pose[2], pose[3]);
} else {
pose = this.camera.camera.vrDisplay.getFrameData().pose.orientation;
this.camera.setLocalRotation(pose[0], pose[1], pose[2], pose[3]);
}
}
The bottom “else” is for non split eye magic window support, works on android, to get it to work on iOS, simply add this to a button click or user interaction
// Enable device motion for iOS
if (typeof DeviceMotionEvent.requestPermission === 'function') {
DeviceMotionEvent.requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
window.addEventListener('devicemotion', () => {});
}
})
.catch(console.error);
} else {
}
// Enable device orientation for iOS
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
DeviceOrientationEvent.requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
window.addEventListener('deviceorientation', (e) => {
});
}
})
.catch(console.error);
} else {
// handle regular non iOS 13+ devices
}
If they accept permissions, the former code snippet will start receiving the orientation data needed.
One interesting thing is that android orientation is flipped on the Y by 180 degrees, so may need to add an offset otherwise you start in the opposite direction.
Here is the reference project I’ve been using with above scripts (look-camera.js), code above not included though.