5

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?

Sensei James
  • 2,617
  • 30
  • 36
Ram
  • 71
  • 1
  • 7

1 Answers1

9

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");
});
Cameron
  • 1,049
  • 12
  • 24
ngokevin
  • 12,980
  • 2
  • 38
  • 84