mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
cargo format
This commit is contained in:
+19
-13
@@ -1,6 +1,9 @@
|
||||
use bevy::{prelude::*, render::render_resource::Extent3d, transform::components::Transform};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use studio::{headless::{start_headless, HeadlessMode}, scene::SceneState};
|
||||
use studio::{
|
||||
headless::{start_headless, HeadlessMode},
|
||||
scene::SceneState,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "StorytellerStudioHeadless")]
|
||||
@@ -20,7 +23,7 @@ enum Subcommands {
|
||||
Scene {
|
||||
scene_dir: String,
|
||||
#[arg(long)]
|
||||
camera_motion : Option<String>,
|
||||
camera_motion: Option<String>,
|
||||
#[arg(long, short)]
|
||||
output_dir: Option<String>,
|
||||
#[arg(long)]
|
||||
@@ -104,10 +107,13 @@ fn main() {
|
||||
"zoom" => {
|
||||
app.insert_resource(CameraMotion::Zoom);
|
||||
}
|
||||
_ => panic!("Unsupported camera motion type.")
|
||||
_ => panic!("Unsupported camera motion type."),
|
||||
}
|
||||
|
||||
app.add_systems(Update, update_camera_motion.run_if(in_state(SceneState::Active)));
|
||||
|
||||
app.add_systems(
|
||||
Update,
|
||||
update_camera_motion.run_if(in_state(SceneState::Active)),
|
||||
);
|
||||
}
|
||||
|
||||
app
|
||||
@@ -167,14 +173,14 @@ fn main() {
|
||||
app.run();
|
||||
}
|
||||
|
||||
pub const SPEED : f32 = 0.1;
|
||||
pub const SPEED: f32 = 0.1;
|
||||
|
||||
#[derive(Resource)]
|
||||
enum CameraMotion {
|
||||
Orbit,
|
||||
Pan,
|
||||
Zoom,
|
||||
Static
|
||||
Static,
|
||||
}
|
||||
|
||||
pub(crate) fn update_camera_motion(
|
||||
@@ -186,9 +192,9 @@ pub(crate) fn update_camera_motion(
|
||||
let Ok(mut main_cam_transform) = camera.get_single_mut() else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
println!("Updating camera motion");
|
||||
|
||||
|
||||
match *camera_motion {
|
||||
CameraMotion::Orbit => {
|
||||
orbit_camera(&mut main_cam_transform, &time);
|
||||
@@ -209,7 +215,7 @@ fn zoom_camera(main_cam_transform: &mut Transform, time: &Time<()>) {
|
||||
let normalized_cos = (-scaled_time.cos() + 1.0) / 2.0;
|
||||
let start_pos = Vec3::new(0.366, 1.1, 2.5);
|
||||
let end_pos = Vec3::new(0.366, 1.1, -0.5);
|
||||
|
||||
|
||||
main_cam_transform.translation = start_pos.lerp(end_pos, normalized_cos);
|
||||
main_cam_transform.rotation = Quat::from_euler(EulerRot::XYZ, 0.0, 0.0, 0.0);
|
||||
}
|
||||
@@ -219,7 +225,7 @@ fn pan_camera(main_cam_transform: &mut Transform, time: &Time<()>) {
|
||||
let normalized_cos = (scaled_time.cos() + 1.0) / 2.0;
|
||||
let start_pos = Vec3::new(1.617, 0.9, 2.177);
|
||||
let end_pos = Vec3::new(-0.365, 0.9, 2.323);
|
||||
|
||||
|
||||
main_cam_transform.translation = start_pos.lerp(end_pos, normalized_cos);
|
||||
main_cam_transform.rotation = Quat::from_euler(EulerRot::XYZ, 0.0, 0.0, 0.0);
|
||||
}
|
||||
@@ -229,9 +235,9 @@ fn orbit_camera(main_cam_transform: &mut Mut<'_, Transform>, time: &Res<'_, Time
|
||||
let max_angle = std::f32::consts::PI / 2.0;
|
||||
let normalized_cos = (scaled_time.cos() + 1.0) / 2.0;
|
||||
let angle = max_angle * normalized_cos;
|
||||
|
||||
|
||||
// let t = (time.elapsed().as_secs_f32() / 5.0) % 1.0;
|
||||
|
||||
|
||||
main_cam_transform.translation = Vec3::new(-2.2 * angle.cos(), 1.0, 2.5 * angle.sin());
|
||||
main_cam_transform.look_at(Vec3::new(0.347, 0.556, -1.0), Vec3::Y);
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,8 +1,11 @@
|
||||
use bevy::{
|
||||
app::Update, transform::components::Transform, window::{close_on_esc, Window}, prelude::*
|
||||
app::Update,
|
||||
prelude::*,
|
||||
transform::components::Transform,
|
||||
window::{close_on_esc, Window},
|
||||
};
|
||||
use clap::Parser;
|
||||
use studio::{scene::SceneState, screenshot::ScreenShotPlugin, InitAsset, InitParams, StudioMode };
|
||||
use studio::{scene::SceneState, screenshot::ScreenShotPlugin, InitAsset, InitParams, StudioMode};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "StorytellerStudio")]
|
||||
@@ -39,4 +42,4 @@ fn main() {
|
||||
// app.add_plugins(ScreenShotPlugin);
|
||||
|
||||
app.run();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user