VR on mobilephones - non stereoscopic

Hi there

I’m using the universal and the arc rotate camera in my project. Its a multibe floor building to walk around. Now i would like to implement a VR button, visible only if you are using it on a mobile device.

Question: Is it possible to use the WebVR camera in a non-stereoscopic way? Only control the direction of the target by the devices motion, the rest will stay the same. (Or implement this control to the universal camera) Did anybody do this so far?

I think it would make it way more useful as most people don’t have a cardboard with them.


You are asking about the device orientation camera, which uses the, well, device orientation to control its rotation - this is not VR related, but mobile-phone related -



ah ok - thank you

i have tried to implement it but it alway says:
“DeviceOrientationEvent.requestPermission is not a function”


On my iphone it does not prompt any request -

What iOS version are you using? what iPhone version?


Just wanted to say - it feels quite weird, as we are checking before running the function:

if (typeof(DeviceOrientationEvent) !== "undefined" && typeof (<any>DeviceOrientationEvent).requestPermission === 'function') 

What version of babylon are you using?

iPhone Xr, iOs 13.5.1

Babylon.js v4.1.0-beta.8

Please use the latest beta or the latest stable 4.1, as this issue was fixed already

1 Like

But the playground should be up to date - why is it throwing an error there?:


made a different request - result stays the same:


Yes, the playground should be working correctly.

What is the result you see when you use your iPhone? Can any iPhone user provide an input here as well?

Using this https://playground.babylonjs.com/#6MVYD5#3

It says NotAllowedError, Requesting device orientation or motion access requires a user gesture to prompt.

Ok, this is the expected behavior in that case. I think @ueli doesn’t have the rtequestPermission function defined (or at least not as a function), which is odd.

hmm - that’s bizarre - shouldn’t that be a standart working in all browsers?

Like this…


…it says: “Requesting device orientation or motion acces requires a user gesture to prompt”

grrrr :wink:

That’s the expected behavior. You need to ask the user (using a button, for example) if they want to enable the feature.

i’ve tried that - but it’s not working. same message:


“Requesting device orientation or motion acces requires a user gesture to prompt”

Could it be possible that this user gesture is only allowed on a DOM element?

i’ve been looking for VR examples in the babylonjs docs - but i can’t find any example that is working on iOS (sadly i can’t test android here) with the devices sensor

Usually a screen rotation event is more than enough, unless apple has changed something. I have no iphone to test with, but any user event should work correctly. It might be the pointer masking that prevents it from happening, but I am not entirely sure.

I will check with a team member that has an iphone and see what’s up. Try this example - after licking, no exception should be thrown and the device orientation should kick in - https://playground.babylonjs.com/#6MVYD5#8

it responds with the same error: “Requesting device orientation or motion access requires a user gesture to prompt”

i will search for a solution the next days and post it here if i find something

If somebody is finding this thread by search, it works like this for me:

if (typeof DeviceMotionEvent.requestPermission === ‘function’) {
.then(permissionState => {
if (permissionState === ‘granted’) {
window.addEventListener(‘devicemotion’, () => {
alert(“permission granted!”);
} else {
// handle regular non iOS 13+ devices
if (typeof DeviceOrientationEvent !== ‘function’) {
alert(‘DeviceOrientationEvent not detected’);
if (typeof DeviceOrientationEvent.requestPermission !== ‘function’) {
alert(‘DeviceOrientationEvent.requestPermission not detected’);
DeviceOrientationEvent.requestPermission().then(function (result) {
}).catch(function (result) {

…android i can’t test right now

1 Like

the pg for it:

another a bit stupid question - please forgive my noop-ness:

If i create the new device oriented camera (camera3) i would love to use it as the universal camera (camera2). Is there a way to just swap names of two cameras? or to replace one camera with another? I got so much code working with the “camera2”, it would be so much easier if i could call the new camera the same way (OR if i could handle the universal cameras orientation over the devices orientation, but for that i would probably need to implement it to the universal cameras type script code - i think that’s too much for me now… pfff)