Game Development Reference
In-Depth Information
If you've ever written event-driven JavaScript before, most of this should look pretty
familiar, and it's not hard to see how this could be extended in different ways to
support different control mechanisms. Luckily, most applications are controlled
pretty similarly, so Three.js provides a number of default control handlers that take
care of most of this for you. These controllers are located in examples/js/controls
and not in the main library, so you need to make sure to include them separately in
your HTML file if you want to use them. Feel free to copy and extend an existing
controller if you want a slightly different behavior, rather than writing your own
controller from scratch every time.
The available controllers are:
Constructor
Important properties
Explanation
FirstPersonControls
movementSpeed =
1.0
lookSpeed = 0.005
constrainVertical
= false
freeze = false
Keyboard movement ( WASD or
arrow keys for forward/back/
strafe; up/down with R or F )
and look around by following
the mouse.
FlyControls
movementSpeed =
1.0
rollSpeed = 0.005
Press keys to move ( WASD ),
tilt ( QE ), and look around
(up/down/left/right).
OculusControls
freeze = false
Use the Oculus Rift virtual
reality headset.
OrbitControls
enabled = true
target = new
THREE.Vector3()
zoomSpeed = 1.0
minDistance = 0
maxDistance =
Infinity
rotateSpeed = 1.0
keyPanSpeed = 7.0
autoRotateSpeed =
2.0
Rotate, pan, and zoom with
mouse or touch controls,
maintaining the up direction
along the positive y axis.
Search WWH ::




Custom Search