All Projects → brianpeiris → three-firstperson-vr-controls

brianpeiris / three-firstperson-vr-controls

Licence: MIT license
First-person controls for VR based on three.js

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

THREE.FirstPersonVRControls

npm

First-person keyboard 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 (if enabled).
  • Shift to boost movement speed temporarily.
  • QE for snap turns.
  • RF for vertical movement (if enabled).
  • Forward/backward movement is always in the direction that you're looking.

Usage

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

Demo

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

Animated demo of the controls in action

Credits

Based on code from THREE.FirstPersonControls and its contributors.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].