#camera-control #camera #fly #bevy #orbit #gamedev #mouse-position

bevy_blendy_cameras

Bevy editor like cameras controls for Pan/Orbit/Zoom and Fly mode. Switch mode, set camera viewpoint and frame view around entities

9 releases (5 breaking)

0.6.0 Dec 2, 2024
0.5.1 Oct 27, 2024
0.4.1 Sep 17, 2024
0.4.0 Aug 12, 2024
0.1.0 Jul 26, 2024

#478 in Game dev

Download history 1/week @ 2024-09-02 145/week @ 2024-09-16 20/week @ 2024-09-23 22/week @ 2024-09-30 6/week @ 2024-10-07 8/week @ 2024-10-14 189/week @ 2024-10-21 82/week @ 2024-10-28 45/week @ 2024-11-04 15/week @ 2024-11-11 10/week @ 2024-11-18 13/week @ 2024-11-25 148/week @ 2024-12-02

189 downloads per month

MIT/Apache

81KB
1.5K SLoC

Bevy Blendy Cameras

Summary

Editor like cameras controls and features inspired by Blender's viewport camera controls.

Features

  • Pan/orbit/zoom camera controls with "zoom to mouse position" and "auto depth" options
  • Fly camera controls
  • Move to viewpoints (top, bottom, front, back, left, right)
  • Frame entities into view
  • Grab cursor or wrap cursor around the viewport during orbit and fly rotation
  • Egui support

TODO

  • Clean code
  • Make fly mode works with orthographic projection
  • Support "Auto depth" for pan movement. So that the result of the raycast under the mouse coursor always stays under the mouse cursor during pan, if no cursor grab/wrap.
  • Make the raycast used for "Auto depth" respect the materials backface culling setting. Maybe optionally because this might conflict with other raycast options used for other uses by the user.

Default Controls

OrbitCameraController

  • Middle mouse drag - Orbit
  • Shift + Middle mouse drag - Pan
  • Scroll wheel - Zoom

FlyCameraController

  • Middle mouse drag - Rotate
  • Scroll wheel - Change movement speed
  • E - Move forward (zoom)
  • D - Move backward (unzoom)
  • S - Move to the left
  • F - Move to the right
  • W - Move to the bottom
  • R - Move to the top

Quick Start

Add the plugin:

.add_plugins(BlendyCamerasPlugin)

Add the controllers components to a camera:

commands.spawn((
    Camera3d::default() ,
    Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
    OrbitCameraController::default(),
    FlyCameraController {
        is_enabled: false,
        ..default()
    },
));

Adding both controller is not required. If you need just one, only add this one. If you want to switch from one to another, adding both before the switch is OK, just make sure only one is enabled. Otherwise both will react to inputs.

Check out the basic example to see more functionalities.

Cargo Features

  • bevy_egui (optional): Ignore input when egui has the focus

Version Compatibility

bevy bevy_blendy_cameras
0.15 0.6
0.14 0.2-0.5
0.13 0.1

Credits

Disclaimer

I am a bit new to both Rust and Bevy and this plugin is in early stages. Help is welcomed.

Dependencies

~42–79MB
~1.5M SLoC