Crate bevy_panorbit_camera

Source
Expand description

Crates.io docs.rs Bevy tracking

Bevy Pan/Orbit Camera

A screen recording showing camera movement

§Summary

Bevy Pan/Orbit Camera provides orbit camera controls for Bevy Engine, designed with simplicity and flexibility in mind. Use it to quickly prototype, experiment, for model viewers, and more!

§Features:

  • Smoothed orbiting, panning, and zooming
  • Works with orthographic camera projection in addition to perspective
  • Customisable controls, sensitivity, and more
  • Touch support
  • Works with multiple viewports and/or windows
  • Easy to control manually, e.g. for keyboard control or animation
  • Can control cameras that render to a texture

§Controls

Default mouse controls:

  • Left Mouse - Orbit
  • Right Mouse - Pan
  • Scroll Wheel - Zoom

Default touch controls:

  • One finger - Orbit
  • Two fingers - Pan
  • Pinch - Zoom

§Quick Start

Add the plugin:

.add_plugins(PanOrbitCameraPlugin)

Add PanOrbitCamera (this will automatically add a Camera3d but you can add it manually if necessary):

commands.spawn((
    Transform::from_translation(Vec3::new(0.0, 1.5, 5.0)),
    PanOrbitCamera::default(),
));

This will set up a camera with good defaults.

Check out the advanced example to see all the possible configuration options.

§Cargo Features

  • bevy_egui (optional): Makes PanOrbitCamera ignore any input that egui uses, thus preventing moving the camera when interacting with egui windows

§Version Compatibility

bevybevy_panorbit_camera
0.150.21-0.25
0.140.19-0.20
0.130.14-0.18
0.120.9-0.13
0.110.6-0.8
0.100.1-0.5

§Credits

§License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.

Structs§

ActiveCameraData
Tracks which PanOrbitCamera is active (should handle input events), along with the window and viewport dimensions, which are used for scaling mouse motion. PanOrbitCameraPlugin manages this resource automatically, in order to support multiple viewports/windows. However, if this doesn’t work for you, you can take over and manage it yourself, e.g. when you want to control a camera that is rendering to a texture.
PanOrbitCamera
Tags an entity as capable of panning and orbiting, and provides a way to configure the camera’s behaviour and controls.
PanOrbitCameraPlugin
Bevy plugin that contains the systems for controlling PanOrbitCamera components.
PanOrbitCameraSystemSet
Base system set to allow ordering of PanOrbitCamera

Enums§

FocusBoundsShape
The shape to restrict the camera’s focus inside.
TouchControls
The control scheme to use for touch input. Given that some touch gestures don’t make sense being changed (e.g. pinch to zoom), there is just a set if different schemes rather than full customization.
TrackpadBehavior
Allows for changing the TrackpadBehavior from default to the way it works in Blender. In Blender the trackpad orbits when scrolling. If you hold down the ShiftLeft, it Pans and holding down ControlLeft will Zoom.