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,
#[arg(long)]
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)]
output_dir: Option<String>,
#[arg(long)]
@@ -73,6 +77,8 @@ fn main() {
Subcommands::Scene {
scene_dir,
orbit,
orbit_speed,
orbit_radius,
skybox,
output_dir,
output_resolution,
@@ -95,9 +101,11 @@ fn main() {
frames,
output_res,
);
let orbit_speed = orbit_speed.unwrap_or(1.0);
let orbit_radius = orbit_radius.unwrap_or(8.0);
if orbit {
app.insert_resource(OrbitSettings { radius: 5.0 })
app.insert_resource(OrbitSettings { radius: orbit_radius, speed: orbit_speed})
.add_systems(Update, orbit_scene);
}
@@ -161,6 +169,7 @@ fn main() {
#[derive(Resource)]
struct OrbitSettings {
radius: f32,
speed : f32
}
fn orbit_scene(
@@ -173,9 +182,9 @@ fn orbit_scene(
};
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,
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);
}