Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - How to detect when user enters VR mode?

Tags:

aframe

webvr

Is there any JavaScript event triggered when the user enters VR mode while viewing the VR scene on a webpage?

Or is there any function which returns whether the user is viewing the webpage in VR mode or not?

like image 973
Ram Avatar asked Aug 09 '16 23:08

Ram


1 Answers

Use the enter-vr and exit-vr events:

https://aframe.io/docs/0.5.0/core/scene.html#events

document.querySelector('a-scene').addEventListener('enter-vr', function () {
   console.log("ENTERED VR");
});
like image 143
ngokevin Avatar answered Sep 20 '22 09:09

ngokevin