mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
fixed endless running bug
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -8,10 +8,7 @@ use space_editor::prelude::{EditorEvent, EditorPrefabPath};
|
||||
use wgpu::Extent3d;
|
||||
|
||||
use crate::{
|
||||
bvh::{BvhAnimCompleteEvent, TestBvh},
|
||||
screenshot::{ScreenCapture, ScreenShotPlugin},
|
||||
BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera,
|
||||
MixamoImportEvent, MixamoPlugin, SkyboxId, StudioMode, WorldGridPlugin,
|
||||
bvh::{BvhAnimCompleteEvent, TestBvh}, scene::SceneState, screenshot::{ScreenCapture, ScreenShotPlugin}, BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera, MixamoImportEvent, MixamoPlugin, SkyboxId, StudioMode, WorldGridPlugin
|
||||
};
|
||||
|
||||
#[derive(Debug, Resource, Clone)]
|
||||
@@ -64,7 +61,7 @@ pub fn start_headless(
|
||||
},
|
||||
);
|
||||
|
||||
app.add_systems(PostUpdate, check_for_bvh_capture_complete);
|
||||
app.add_systems(PostUpdate, check_for_bvh_capture_complete.run_if(in_state(SceneState::Active)));
|
||||
}
|
||||
HeadlessMode::Scene(scene, skybox) => {
|
||||
app.add_systems(
|
||||
@@ -87,7 +84,7 @@ pub fn start_headless(
|
||||
commands.insert_resource(SkyboxId(skybox.clone()));
|
||||
},
|
||||
);
|
||||
app.add_systems(PostUpdate, check_for_mixamo_capture_complete);
|
||||
app.add_systems(PostUpdate, check_for_mixamo_capture_complete.run_if(in_state(SceneState::Active)));
|
||||
|
||||
app.run();
|
||||
}
|
||||
@@ -135,7 +132,6 @@ fn check_for_bvh_capture_complete(
|
||||
return;
|
||||
};
|
||||
|
||||
println!("Frames captured {}", screen_capture.frames_captured());
|
||||
if !screen_capture.should_capture() || !bvh_event_reader.is_empty() {
|
||||
screen_capture.stop_capturing();
|
||||
close_app.send(AppExit);
|
||||
|
||||
@@ -7,6 +7,7 @@ use scene::ImportSceneEvent;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||
use space_editor::space_prefab::plugins::PrefabPlugin;
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
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 +19,8 @@ struct StudioArgs {
|
||||
enum Subcommands {
|
||||
Scene {
|
||||
scene_dir: String,
|
||||
#[arg(long)]
|
||||
orbit : bool,
|
||||
#[arg(long, short)]
|
||||
output_dir: Option<String>,
|
||||
#[arg(long)]
|
||||
@@ -67,6 +69,7 @@ fn main() {
|
||||
let mut app = match args.subcommand {
|
||||
Subcommands::Scene {
|
||||
scene_dir,
|
||||
orbit,
|
||||
skybox,
|
||||
output_dir,
|
||||
output_resolution,
|
||||
@@ -82,13 +85,23 @@ 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,22 @@ 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(), orbit_settings.radius * time.elapsed_seconds().sin(), 6.0);
|
||||
main_cam_transform.look_at(Vec3::ZERO, Vec3::Y);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Parsers
|
||||
//==============================================================================
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ use crate::{
|
||||
camera_controller::{CameraController, CameraControllerBundle},
|
||||
change_tracking::{ChangeTracker, ChangeTrackingPlugin},
|
||||
debug::DebugPoint,
|
||||
headless::{is_headless, is_not_headless, HeadlessSettings},
|
||||
headless::{self, is_headless, is_not_headless, HeadlessSettings},
|
||||
math::{Combinable, Extrema},
|
||||
screenshot::ScreenCapture,
|
||||
MainCamera,
|
||||
@@ -326,7 +326,7 @@ fn initialiaze_headless(
|
||||
..default()
|
||||
},
|
||||
CameraControllerBundle::new(focus, camera_xform.translation),
|
||||
ScreenCapture::from_out(&headless_settings.output_dir),
|
||||
ScreenCapture::from_out(&headless_settings.output_dir).with_max_frames(headless_settings.max_frames),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ fn extract_screen_capture_components(
|
||||
) {
|
||||
for (entity, screen_capture) in screen_capure_comps.iter() {
|
||||
if screen_capture.should_capture() {
|
||||
println!("Capturing Frame: {} / {}", screen_capture.frames, screen_capture.max_frames);
|
||||
commands.get_or_spawn(entity).insert(screen_capture.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user