Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard Movement Does Not Follow Direction You Are Facing #24

Open
refactornator opened this issue Mar 5, 2014 · 3 comments
Open

Keyboard Movement Does Not Follow Direction You Are Facing #24

refactornator opened this issue Mar 5, 2014 · 3 comments

Comments

@refactornator
Copy link

I've noticed in the "Three.js Floating Boxes Demo" that your perspective follows the oculus rift, but movement with the keyboard does not. So, for instance, when you first open the demo if you don't move your head, UP on the keyboard will move you forward, but if you rotate your head to the left or right, UP on the keyboard still moves the same direction even though you are facing a different direction. This should work similar to the Three.js Pointer Lock Demo http://threejs.org/examples/#misc_controls_pointerlock where UP on the keyboard will move you in the direction you are facing.

@Maksims
Copy link

Maksims commented May 22, 2014

That is very arguable point, as a lot of players prefer independent movement direction from view direction.
Same way as in real life you are able to walk forward and by turning your head to the right wont change direction of your movement.

@jhclaura
Copy link

jhclaura commented Oct 5, 2014

If I want the movement as @wlindner described, what should I do to achieve that?

I tried to cooperate the original PointerLockerControl.js method, adding back pitchObject and yawObject, as below
......
pitchObject.add( camera );
.......
yawObject.add( pitchObject );
.......

and in update() function, adding
.......
var qq = new THREE.Quaternion(vrstate.hmd.rotation[0], vrstate.hmd.rotation[1], vrstate.hmd.rotation[2], vrstate.hmd.rotation[3]);
var roTemp = new THREE.Object3D();
roTemp.rotation.setFromQuaternion( qq );
yawObject.rotation.y = roTemp.rotation.y;
.....

but it doesn't really work. I guess I messed it up with the OculusRiftEffect.js, thus view doesn't really follow the oculus(0 and 360 degree the same, but weird transition between), and the movement doesn't 100% follow the rotation as well. Does anyone know the right way to do this? Sorry for the awful description and hope it makes sense.. Thanks!

@jhclaura
Copy link

jhclaura commented Oct 5, 2014

Ohhh I found the solution :D

@OculusRiftControls.js
I) Use the PointerLockerControl.js method, with pitchObject and yawObject.
2) Update yawObject.rotation with vrstate.hmd.rotation in undate()

@OculusRiftEffect.js
3) Command out "eyeWorldMatrix.multiply(rotMat);" in THREE.OculusRiftEffect.prototype.render()

see the changes of OculusRiftControls.js here http://jsfiddle.net/jhclaura/abnjvfyc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants