Camera
2D
The 2D camera controls how objects are drawn in world space. You can get access
to the camera with get_camera_2d and get_camera_2d_mut, and use the methods
on the Camera2D object to move around, zoom in and out, rotate, and more.
The provided functions world_to_screen, and screen_to_world can be helpful,
for example to find the position of the cursor in world space, instead of screen space.
3D
You can get access to the camera with get_camera_2d and get_camera_2d_mut,
and use the methods on it to move around, change the FOV, and change between a
perspective and isometric projection.
Controllers
Camera controllers can be used to easily let the user controller the camera,
without having to implement it from scratch. Camera controllers are used by
creating a mutable instance of the struct once, and calling .update() on it
every frame.
#[main("Game")]
fn main() {
let mut controller = PanningCameraController::new();
loop {
controller.update();
// rest of game logic
}
}
2D
The 2D camera supports the following camera controllers:
PanningCameraController: Allows the user to (optionally) pan and zoom the camera using the scroll wheel, and a customizable button (defaults to left click).CameraShakeController: allows for easy shaking of the camera, by using.add_trauma(amount: f32).
3D
The 3D camera supports the following camera controllers:
OrbitCameraController: Allows the user to orbit the camera around a point and zoom in and out, with many configuration options.FirstPersonCameraController: Allows the user to look around in the first person, using the mouse.