engine
engine copied to clipboard
camera.FlyControl for highly configurable FPS or flight-sim style camera control
Finally following up to #124 on my ancient promises of an alternative camera control to Orbit. I see there is also PR #196 and #262 for something similar.
I used a series of maps to allow the user to configure the keys, mouse, speeds, and constraints. Translation, Yaw, Pitch, Roll, FoV Zoom are available, and pitching is not restricted to [-90, 90] from world up.
I tried to describe the use of FlyControl
as succinctly as possible in its documentation:
FlyControl provides a camera controller that allows looking at the scene
from a first person style view. It allows for translation in the
Forward/Backward, Right/Left, and Up/Down directions, and rotation in the
Yaw/Pitch/Roll directions from the camera's point of view. The camera's
field of view can also be modified to allow ZoomOut/ZoomIn.
For maximum flexibility, the FlyControl is very configurable, but two main
modes of operation exist: "manual" and "automatic".
"Manual" mode requires the user to directly make adjustments to the
FlyControl's position and orientation by using the Forward(), Right(),
Yaw(), Pitch() and other similar methods. Manual mode does not subscribe to
key or mouse events, nor does it use the FlyControl's member maps "Speeds",
"Keys", or "Mouse" ("Constraints" is used). A FlyControl created (eg with
NewFlyControl()) with no options defaults to "manual" mode.
"Automatic" mode subscribes to key and mouse events, and handles position
and orientation adjustments according to parameters specified in the "Keys",
"Mouse", "Speed", and "Constraint" maps. Generally, methods such as
Forward() will not be used. Some preconfigured options are available with
FPSStyle() and FlightSimStyle(), and can be further configured by the
With*() options, and by modifying the FlyControl's Keys (etc) maps directly.
One thing to add would be a way to use the constraints to restrict translational movement to a plane (eg XY).