use bevy::{prelude::*, render::mesh::PlaneMeshBuilder}; use smooth_bevy_cameras::{LookTransform, LookTransformBundle, LookTransformPlugin, Smoother}; fn main() { App::new() .insert_resource(Msaa::Sample4) .add_plugins(DefaultPlugins) .add_plugins(LookTransformPlugin) .add_systems(Startup, setup) .run(); } /// setup a simple 3D scene fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { // plane commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(PlaneMeshBuilder::from_size(Vec2::splat(5.0)))), material: materials.add(Color::srgb(0.3, 0.5, 0.3)), ..Default::default() }); // cube commands.spawn(PbrBundle { mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::splat(1.0)))), material: materials.add(Color::srgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() }); // light commands.spawn(PointLightBundle { transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }); commands .spawn(LookTransformBundle { transform: LookTransform { eye: Vec3::new(-2.0, 2.5, 5.0), target: Vec3::new(0.0, 0.5, 0.0), up: Vec3::Y, }, smoother: Smoother::new(0.9), }) .insert(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::new(0.0, 0.5, 0.0), Vec3::Y), ..default() }); }