aframe: Document how to enter/exit VR

Description:

document.querySelector('a-scene').enterVR();
document.querySelector('a-scene').exitVR();

And also document how to when <iframe>-ing content.

  • A-Frame Version: any
  • Platform/Device: all

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 29 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Well, no one is against #705. Though I might also just recommend creating a scene component. They have the advantage that you don’t have to worry about query selecting, waiting for events. Just write JS and attach:

AFRAME.registerComponent('auto-enter-vr', {
  init: function () {
    this.el.sceneEl.enterVR();
  }
});
<a-scene auto-enter-vr>

Nice section here, but for some reason waiting for loaded doesn’t work. you have to add a setTimeout. gotta figure out why:

<script>
   (function () {
       // switch to stereoscopic mode directly on page load, this needs to be after the a-scene loads.
       var scene = document.querySelector('a-scene');
       if (scene.hasLoaded) {
           scene.enterVR();
       } else {
           scene.addEventListener('loaded', function () {
               setTimeout(function () {
                   scene.enterVR();
               }, 1000);
           });
       };
   })();
</script>

Also, not exactly specific to this issue, but still think we should support #705.