Jump to content

VR camera to point to the z-axis by default


Recommended Posts


I have tried using FreeCamera to build a basic scene, and the camera was pointing in the z-axis direction (which is what I want).
now I used the VR camera, but I noticed as if the camera is pointing towards the Y-axis by default, but I want it to point towards the Z-axis just like the free camera, I checked in another post that this is a default behavior that is based on the orientation of the mobile device, but for me it makes sense to point to z-axis by default, since when someone is wearing the VR headset (Google cardboard,etc..), they will actually be looking directly to the z-axis if they are standing still without tilting or rotating their head.

so what do you think about that? and is there a way to make it look to the z-axis by default?

these are some basic samples:

Free camera: http://www.babylonjs-playground.com/#AOL4N#1
VR camera: http://www.babylonjs-playground.com/#AOL4N#0

Link to comment
Share on other sites

Hiya @Terminator.  I think the camera has a bug/problem.  That's what I think.   :)


Just goofin' around, using the camera's .cameraDirection, .rotation, .position, .lockedTarget... to try to get good results.  I have failed, so far.  Still thinking and testing.

How do you like my line 19?  I'm not much of a programmer, but... is that what is known as a "circular reference"? *shrug*  Maybe just called a "back-reference".  I should learn to program someday, huh?

All in all, line 19 is a darned-funny way of sending the camera object to console (where I click on the 'Object' portion, and my Firefox object inspector pops-open)... (where I can easily find seemingly-useless camera properties to set and methods to call).

Still, no joy.  hmm.  Something is whacky, somewhere.  Might need a matrix transformation, but that seems like the long/wrong solution.

Link to comment
Share on other sites

Thanks @Wingnut for trying to figure this out..

unfortunately it seems there is no solution so far.

I found a ThreeJS tutorial for VR here: https://www.sitepoint.com/bringing-vr-to-web-google-cardboard-three-js/ , if I can do something similar with the babylonJS camera (the z-axis thing), it would be great, and that's the end result of the tutorial: http://patcat.com/demos/VRWeatherParticles/

can anyone of BabylonJS developers confirm if this an expected behavior of the VR camera or if it is a bug? since I was learning BabylonJS just for the purpose of working on a VR game I have in mind, any help is appreciated.

Link to comment
Share on other sites

I have found a solution (easy, too), but I need to check with core programmers... about a possible minor issue, first.  Be right with ya.

update:  http://www.babylonjs-playground.com/#AOL4N#4

Line 25 seems to get the job done.  But I have a funny feeling that _constantTranform might have an 's' added, eventually.   But who knows?  :)  It wasn't fair to make you wait.  Just be prepared to add another 's', later (after the third 'n').

camera.inputs.attached.deviceOrientation._constantTranform.x had value -0.7071067811865476 by default.  I neutralized it with my Browning Model 172 "Value Eliminator" zapper gun. 

I don't guarantee that this is a good or proper solve, but it worked.  Let's hope it holds-up when the going gets tough (in actual use).  :)

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...