Three.js First Person Camera Movement Issue

I am having more problems with my threejs code. I have got the camera working properly as an FPS camera, but the WASD movement is having some problems. I am using the camera.getWorldDirection to change the movement direction whilst the player is still trying to move.

    var direction = new THREE.Vector3();
    var direction = camera.getWorldDirection(direction);

    if(evt.keyCode == 87){ // W key

However, I do not want the players Z axis to be changed during this. Currently it is like a freecam mode, and is very jerky. I want to smooth this and not effect the z axis. The player cannot be able to fly!

Also, for the D key, how can i reverse this? If anyone has a better way of doing this pls let me know.

No one has answered in a day so I would appreciate if someone could help me out :smiley:

There are a couple of first person camera control plugins available, adapting one of them might be easier than creating your own from scratch.

Thanks for your reply. The only problem is that it might be difficult for me to implement this into socketio as well. I was planning on making custom movement such as bhopping, slide hopping walljumping. I guess I’ll have to do more research.

The smooth lerp if helpful thanks