FPS Controls for Three.js
A 3D platformer game made with Three.js. The aim of the game is to the get to the top of the crates, at which point they will back to their rightful place on the moons surface in an orderly fashion.
The controls and demo are based on the PointerLockControls given in the three.js examples page/repo. The controls add additional benefits:
- Double Jump (Optional)
- Elementary collision detection with specified objects
- Improved collision detection
- Refactoring to improve code readability and control robustness
- Strafe jumping (long term)
Import three.js, then import FPSControls.js. You can then do something like this:
camera = new THREE.PerspectiveCamera( 80, window.innerWidth / window.innerHeight, 1, 9000 ); controls = new THREE.PointerLockControls( camera, 100, 30, true, objects ); scene.add( controls.getPlayer() );
Then in your animation loop you just need to call the update controls method:
I would love contributions! Both in the form of issues, feature requests, usage examples and of course pull requests.