Bevy 相机控制器采用了酥脆的指数平滑。
A collection of exponentially-smoothed camera controllers for the Bevy Engine.
All controllers are based on a [LookTransform] component, which is just an
eye point that looks at a target point. By modifying this component, the
scene graph Transform will automatically be synchronized.
Any entities with all of Transform, LookTransform, and [Smoother]
components will automatically have their Transform smoothed. Smoothing
will have no effect on the LookTransform, only the final Transform in
the scene graph.
…When implementing a camera controller, it's often useful to work directly
with the angles (pitch and yaw) of your look direction. You can do this with
the [LookAngles] type:
use bevy::prelude::*;
use smooth_bevy_cameras::{
LookAngles,
LookTransform
};
fn look_angles(mut transform: LookTransform, delta: Vec2) {
let mut angles = LookAngles::from_vector(transform.look_direction().unwrap());
angles.add_pitch(delta.y);
angles.add_yaw(delta.x);
// Third-person.
transform.eye = transform.target + 1.0 * transform.radius() * angles.unit_vector();
// First-person.
// transform.target = transform.eye + 1.0 * transform.radius() * angles.unit_vector();
}This is how the built-in controllers implement rotation controls.
These plugins depend on the [LookTransformPlugin]:
FpsCameraPlugin +
FpsCameraBundle
OrbitCameraPlugin +
OrbitCameraBundle
UnrealCameraPlugin +
UnrealCameraBundle
Best use: hold Right mouse button to orbit the view while using WASD to navigate in the scene, using scroll wheel to accelerate/decelerate.
License: MIT
暂无开放 Issues,或尚未同步最近议题。