First-person keyboard controls for VR based on three.js with look-based movement and "comfort mode" snap turning.
$ npm install three-firstperson-vr-controls
...
// Create a rig and add the camera to it.
// FirstPersonVRControls will move the rig, instead of moving the camera directly.
// If you don't provide a rig, FirstPersonVRControls will create one for you.
const rig = new THREE.Object3D();
rig.add(camera);
scene.add(rig);
const fpVrControls = new THREE.FirstPersonVRControls(camera, scene, rig);
// Optionally enable vertical movement.
fpVrControls.verticalMovement = true;
// You can also enable strafing, set movementSpeed, snapAngle and boostFactor.
fpVrControls.strafing = true;
...
const clock = new THREE.Clock();
function animate () {
...
// FirstPersonControls requires a time delta.
fpVrControls.update(clock.getDelta());
renderer.render(scene, camera);
}
renderer.animate(animate);
http://brian.peiris.io/three-firstperson-vr-controls/demo/browser-demo.html
Based on code from THREE.FirstPersonControls and its contributors.