Controls
The two controls we use in this book are the fly controls and orbit controls.
Fly Controls
We used FlyControls.js to fly around space in both Chapter 5, âFunctions: Use and Use Againâ and Chapter 13, âProject: Phases of the Moonâ. We can create fly controls after the camera is defined with this:
â | âvarâ controls = ânewâ THREE.FlyControls(camera); |
Then the following keys let you fly through the scene:
Motion | Direction | Keys |
---|---|---|
Move | Forward / Backward | W / S |
Move | Left / Right | A / D |
Move | Up / Down | R / F |
Spin | Clockwise / Counterclockwise | Q / E |
Spin | Left / Right | Left Arrow / Right Arrow |
Spin | Up / Down | Up Arrow / Down Arrow |
The following options are available for fly controls:
â | controls.movementSpeed = 100; |
â | controls.rollSpeed = 0.5; |
â | controls.dragToLook ... |
Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.