Added orbiting options

This commit is contained in:
Brooks Palin
2024-02-29 22:48:38 -07:00
parent 31dda4b777
commit da0d40aaa8
+12 -3
View File
@@ -24,6 +24,10 @@ enum Subcommands {
scene_dir: String, scene_dir: String,
#[arg(long)] #[arg(long)]
orbit: bool, orbit: bool,
#[arg(long, value_parser = clap::value_parser!(f32))]
orbit_radius: Option<f32>,
#[arg(long, value_parser = clap::value_parser!(f32))]
orbit_speed: Option<f32>,
#[arg(long, short)] #[arg(long, short)]
output_dir: Option<String>, output_dir: Option<String>,
#[arg(long)] #[arg(long)]
@@ -73,6 +77,8 @@ fn main() {
Subcommands::Scene { Subcommands::Scene {
scene_dir, scene_dir,
orbit, orbit,
orbit_speed,
orbit_radius,
skybox, skybox,
output_dir, output_dir,
output_resolution, output_resolution,
@@ -95,9 +101,11 @@ fn main() {
frames, frames,
output_res, output_res,
); );
let orbit_speed = orbit_speed.unwrap_or(1.0);
let orbit_radius = orbit_radius.unwrap_or(8.0);
if orbit { if orbit {
app.insert_resource(OrbitSettings { radius: 5.0 }) app.insert_resource(OrbitSettings { radius: orbit_radius, speed: orbit_speed})
.add_systems(Update, orbit_scene); .add_systems(Update, orbit_scene);
} }
@@ -161,6 +169,7 @@ fn main() {
#[derive(Resource)] #[derive(Resource)]
struct OrbitSettings { struct OrbitSettings {
radius: f32, radius: f32,
speed : f32
} }
fn orbit_scene( fn orbit_scene(
@@ -173,9 +182,9 @@ fn orbit_scene(
}; };
main_cam_transform.translation = Vec3::new( main_cam_transform.translation = Vec3::new(
orbit_settings.radius * time.elapsed_seconds().cos(), orbit_settings.radius * (time.elapsed_seconds() * orbit_settings.speed).cos(),
6.0, 6.0,
orbit_settings.radius * time.elapsed_seconds().sin(), orbit_settings.radius * (time.elapsed_seconds() * orbit_settings.speed).sin(),
); );
main_cam_transform.look_at(Vec3::ZERO, Vec3::Y); main_cam_transform.look_at(Vec3::ZERO, Vec3::Y);
} }