jdurrant Posted October 17, 2017 Share Posted October 17, 2017 I've used camera.getTarget() to advance a character forward, as described here: It's worked well with a FreeCamera, but I can't get it to work with the WebVR camera. camera.getTarget().subtract(camera.position) always returns the same vector regardless of what I'm looking at through the VR headset. It was a bit tricky to demonstrate in the playground, but I managed: https://www.babylonjs-playground.com/#7DYN70#11 That demo starts with a FreeCamera attached to the canvas. Open up the JavaScript console, and you'll see that it's logging the camera.getTarget().subtract(camera.position) vector every second. If you move the camera looking direction with your mouse, you'll see that the "looking vector" changes in the console. Now the same code, but with a WebVR camera (HTC Vive): https://www.babylonjs-playground.com/#7DYN70#10 In the console, the "looking vector" is always the same, regardless of what I'm seeing in the HTC Vive headset. As always, thanks for your help! Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 17, 2017 Share Posted October 17, 2017 VR! One of my favorite topics. So... the WebVR camera is actually a simple parent camera with two "eyes" - left and right. Just like your eyes, those two cameras have a different "direction". This direction trick can be done on webVRCamera.leftCamera or webVRCamera.rightCamera (both are free cameras). You need to decide which eye to use. Hope this helps! davrous 1 Quote Link to comment Share on other sites More sharing options...
jdurrant Posted October 17, 2017 Author Share Posted October 17, 2017 Works great @RaananW ! Thanks for your help. If I'm not mistaken, camera.getTarget() is a defined function. Why not have it return the average of the two getTarget() values? In case it helps others, here's a working example: https://www.babylonjs-playground.com/#7DYN70#12 All the best. RaananW and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 18, 2017 Share Posted October 18, 2017 Yo! an interesting suggestion. I remember that when I implemented that I had a reason not to do that, but I honestly can't think of it right now. Let me make some calculations If you want to PR this suggestion to the WebVR camera, be my guest! I will comment on the PR itself. Quote Link to comment Share on other sites More sharing options...
davrous Posted October 18, 2017 Share Posted October 18, 2017 I remember also we had trouble with this approach while working with the people from Windows Mixed Reality but can't remember why neither. Maybe @Deltakosh will remember! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 18, 2017 Share Posted October 18, 2017 Yeah true but can't remember what was the issue ;D Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 19, 2017 Share Posted October 19, 2017 In general I think it had something to do with depth and focus. The eyes never really look straight, but the two cameras are practically parallel. But, again, I can't remember. I just know that I tried, and eventually always used the left eye. 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.