Socket
Book a DemoInstallSign in
Socket

three-firstperson-vr-controls

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-firstperson-vr-controls

First-person controls for VR based on three.js

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

WebVR

FAQs

Package last updated on 22 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts