PavolHejný Posted May 3, 2018 Share Posted May 3, 2018 Hi, I am creating WebVR app with Babylon.js (using Firefox, SteamVR and HTC Vive). Can I somehow start VR without users initial click. When i create WebVRFreeCamera: const camera = new BABYLON.WebVRFreeCamera("camera", BABYLON.Vector3.Zero(), scene); I can start VR with: scene.onPointerDown = function () { camera.attachControl(document.getElementById('scene'), true); }; or scene.onPointerDown = function () { camera.getEngine().enableVR(); }; but when i do it without onPointerDown callback it does not work: const camera = new BABYLON.WebVRFreeCamera("camera", BABYLON.Vector3.Zero(), scene); camera.getEngine().enableVR(); Also when i wrap it with setTimeout it does not work: const camera = new BABYLON.WebVRFreeCamera("camera", BABYLON.Vector3.Zero(), scene); scene.onPointerDown = function () { setTimeout(()=>{ camera.getEngine().enableVR(); },100); }; Does enableVR method needs onPointerDown event context. Or where is the problem? Thanks a lot for your advice. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2018 Share Posted May 3, 2018 Hello this is a spec enforced limitation. Starting a VR sequence has to be done from a user initiated event (pointerDown then for instance) davrous and PavolHejný 1 1 Quote Link to comment Share on other sites More sharing options...
HoloLite Posted May 4, 2018 Share Posted May 4, 2018 If the user is actually wearing the headset, you can start webvr automatically by listening to the vrdisplayactive. The code looks like the following: window.addEventListener('vrdisplayactivate', () => { vrHelper.enterVR(); }); The supermedium browser will need you to automatically start webvr once the user puts on the headset. The behavior for each browser is different though. This is the observations I noticed: - Supermedium honors this event always. - Firefox honors this event but you do need to click that button (to give the permission) once in the beginning. Imo this is the correct behavior. - Edge seems to ignore it :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.