/three-firstperson-vr-controls

First-person controls for VR based on three.js

Primary LanguageJavaScriptMIT LicenseMIT

THREE.FirstPersonVRControls

First-person controls for VR based on three.js with look-based movement and "comfort mode" snap turning.

Controls

  • WASD or for forward/backward movement and strafing.
  • QE for snap turns.
  • RF for vertical movement (if verticalMovement is set to true).
  • Forward/backward movement is always in the direction that you're looking.

Usage

$ 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);
  ...
}

Demo

http://brian.peiris.io/three-firstperson-vr-controls/demo

Animated demo of the controls in action

Credits

Based on code from THREE.FirstPersonControls and its contributors.