pub struct Camera2dControl {
pub camera: Camera2d,
pub controller: Camera2dController,
}Expand description
A Camera2d and a Camera2dController as one CameraController:
each frame it applies pan and zoom from the resolved input, advances the
follow and the shake, and writes the view into the camera with
Camera2d::apply_to.
Hand it to a runner that drives a camera through CameraController
(ViewportApp’s CameraControl::Controller), and reach the 2D camera
through camera to follow, shake or set bounds. The runner
passes the size the scene draws at through
CameraController::set_viewport before each apply.
Fields§
§camera: Camera2dThe 2D view.
controller: Camera2dControllerThe pan and zoom policy, with no resolver of its own.
Implementations§
Source§impl Camera2dControl
impl Camera2dControl
Sourcepub fn new(camera: Camera2d) -> Self
pub fn new(camera: Camera2d) -> Self
Drive camera with a stateless Camera2dController.
Trait Implementations§
Source§impl CameraController for Camera2dControl
impl CameraController for Camera2dControl
Source§fn apply(&mut self, camera: &mut Camera, frame: &ActionFrame, dt: f32)
fn apply(&mut self, camera: &mut Camera, frame: &ActionFrame, dt: f32)
Apply one frame of resolved input to the camera.
dt is the frame time
in seconds, for input that is held rather than moved (a key held to fly,
a stick held over): such input moves the camera at a rate, and needs the
time to turn that rate into a distance. Drags and the wheel arrive in the
frame as deltas already.Source§fn set_viewport(&mut self, viewport_size: [f32; 2], pixels_per_point: f32)
fn set_viewport(&mut self, viewport_size: [f32; 2], pixels_per_point: f32)
The size the scene draws at, in logical pixels, and its device pixels
per point. A runner calls this before each
apply, for
controllers whose motion depends on the viewport (dragging by pixels,
zooming about the cursor). For a viewport presented at a reference
size it is the reference size with one pixel per point. The default
ignores it.Auto Trait Implementations§
impl Forget for Camera2dControl
impl Freeze for Camera2dControl
impl Move for Camera2dControl
impl RefUnwindSafe for Camera2dControl
impl Send for Camera2dControl
impl Sync for Camera2dControl
impl Unpin for Camera2dControl
impl UnsafeUnpin for Camera2dControl
impl UnwindSafe for Camera2dControl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more