First-person controls for VR based on three.js with look-based movement and "comfort mode" snap turning.
- WASD or ↑←↓→ for forward/backward movement and strafing.
- QE for snap turns.
- RF for vertical movement (if
verticalMovement
is set totrue
). - Forward/backward movement is always in the direction that you're looking.
$ npm install three-firstperson-vr-controls
...
// Create VRControls in addition to FirstPersonVRControls.
var vrControls = new THREE.VRControls(camera);
var fpVrControls = new THREE.FirstPersonVRControls(camera, scene);
// Optionally enable vertical movement.
fpVrControls.verticalMovement = true;
...
function animate (timestamp) {
...
// Update FirstPersonControls after VRControls.
// FirstPersonControls requires a timestamp.
vrControls.update();
fpVrControls.update(timestamp);
...
}
http://brian.peiris.io/three-firstperson-vr-controls/demo
Based on code from THREE.FirstPersonControls and its contributors.