mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-21 07:55:55 +00:00
Headless Mode fixes for the Backend (#65)
This PR brings some fixes that are needed for the backend to render scenes.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use bevy::render::render_resource::Extent3d;
|
||||
use bevy::{
|
||||
prelude::*, render::render_resource::Extent3d, transform::components::Transform,
|
||||
window::PrimaryWindow,
|
||||
};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use studio::headless::{start_headless, HeadlessMode};
|
||||
|
||||
@@ -19,6 +22,8 @@ struct StudioArgs {
|
||||
enum Subcommands {
|
||||
Scene {
|
||||
scene_dir: String,
|
||||
#[arg(long)]
|
||||
orbit: bool,
|
||||
#[arg(long, short)]
|
||||
output_dir: Option<String>,
|
||||
#[arg(long)]
|
||||
@@ -67,6 +72,7 @@ fn main() {
|
||||
let mut app = match args.subcommand {
|
||||
Subcommands::Scene {
|
||||
scene_dir,
|
||||
orbit,
|
||||
skybox,
|
||||
output_dir,
|
||||
output_resolution,
|
||||
@@ -82,13 +88,20 @@ fn main() {
|
||||
let fps = fps.unwrap_or(24);
|
||||
let frames = frames.unwrap_or(30);
|
||||
let skybox = skybox.unwrap_or("gum_trees_4k".to_string());
|
||||
start_headless(
|
||||
let mut app = start_headless(
|
||||
HeadlessMode::Scene(scene_dir, skybox),
|
||||
fps,
|
||||
&output_dir,
|
||||
frames,
|
||||
output_res,
|
||||
)
|
||||
);
|
||||
|
||||
if orbit {
|
||||
app.insert_resource(OrbitSettings { radius: 10.0 })
|
||||
.add_systems(Update, orbit_scene);
|
||||
}
|
||||
|
||||
app
|
||||
}
|
||||
Subcommands::Bvh {
|
||||
bvh_dir,
|
||||
@@ -145,6 +158,28 @@ fn main() {
|
||||
app.run();
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct OrbitSettings {
|
||||
radius: f32,
|
||||
}
|
||||
|
||||
fn orbit_scene(
|
||||
mut camera: Query<&mut Transform, With<PrimaryWindow>>,
|
||||
orbit_settings: Res<OrbitSettings>,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
let Ok(mut main_cam_transform) = camera.get_single_mut() else {
|
||||
return;
|
||||
};
|
||||
|
||||
main_cam_transform.translation = Vec3::new(
|
||||
orbit_settings.radius * time.elapsed_seconds().cos() * 10.0,
|
||||
orbit_settings.radius * time.elapsed_seconds().sin(),
|
||||
6.0,
|
||||
);
|
||||
main_cam_transform.look_at(Vec3::ZERO, Vec3::Y);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Parsers
|
||||
//==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user