WebVR: How to change the direction of the "body"?

I am simulating an electric wheelchair in WebVR,
controlled by the vrHelper.webVRCamera.rightController joystick.

To move its position, I just change vrHelper.position (Not the head but the body)
But I can’t find a way to change the direction / orientation.y


Hi D! Sorry for slow replies. I will try some ideas… but I am beginner to VR.

Let’s look at some things. First, a playground:


Take particular notice of line 15: createDeviceOrientationCamera: false

That means… use YOUR already-created scene camera, and don’t install/activate a new devOr camera. Depending upon WHICH camera you have as the scene camera, its .target might be important.

Next, have you been to THIS documentation? Use the WebVR experience helper - Babylon.js Documentation Pretty decent doc. Maybe the section titled “Accessing vr device position and rotation”? shrug

Lastly, notice lines 24-46 in that playground. Is there any assistance available in THAT code? Perhaps inside one of the other 312 playgrounds that use vrHelper?

Ok, that’s all I have. Maybe helpful, maybe not. Stay tuned for more/wiser comments.

Thank you for your ideas. I am new to WebVR to and may be wrong, but
line 15 is related to the NOT WebVR camera, I think, the webVRCamera is still created by the vrHelper.
Your playground and “Accessing vr device position and rotation”
does read the “head”-position/orientation of the webVRCamera.
But I need to set/write the orientation of the “body”.

The trouble of so many playgrounds is to find the one, doing what I intent do do. What keywords to use. I tried WebVR of course and rotation/orientation.


(Wingnut blindly experimenting more) :slight_smile:

Line 36 does SOMETHING. I don’t know what it does… but… maybe something useful. It’s not on the leftController or rightController like lines 43 and 47 deviceRotationQuaternion. Line 36 deviceRotationQuaternion is on the actual camera itself. shrug

I use various methods to set the rotation quaternions, but you can also set quaternions like this…

    vrHelper.webVRCamera.deviceRotationQuaternion = BABYLON.Quaternion.Identity();
    vrHelper.webVRCamera.rotationQuaternion = BABYLON.Quaternion.Zero();

More useless info, and you probably already knew-about Identity() and Zero(). Maybe we rotate the camera with standard .rotation (with Euler vector3)… and THEN set its rotationQuaternion or deviceRotationQuaternion to Identity() or Zero(). I dunno. I’m REALLY guessing, now. hehe.

The vrHelper itself has a pair of internal-use properties called ._workingQuaternion and ._workingVector, too… probably not for us… but test-able, I suppose. If it’s a rotation-related property, what the heck… worth looking-at. :slight_smile:

Sorry I’m a poor helper, here. If you want, I can delete all my posts on this subject and we can set your thread back to “0-replies” which MIGHT get more attention from better helpers than I. No problems. I’m just sort-of guessing, anyway. :slight_smile:

deviceRotationQuaternion changes the initial direction of th VR view, also usefull.
Cyclically rotationQuaternion works fine to set the orientation! I am happy.
Your FromEulerAngles(0, 1, 0) means y = +1 rad rotated. This way I could control all axis and even maneuver an X-Wing fighter “soon” :slight_smile:


Pinging @RaananW

If you change the vrcamera’s rotationQuaternion (which acts as a container for the VR experience) you can change the direction to which you are facing:

vrHelper.webVRCamera.rotationQuaternion = newValue;

The VRExperience helper has this function with animation enabled, you can find it here:

Sure, to set .rotationQuaternion cyclically gives you total control. (not .rotation, would be nice to)
I also saw the source of BJS you showed to me. But because it is done by an Animation there, I was not sure. Now I am.
Soon, I will add a video (link) here to show you all, what I did.

1 Like