Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

The planned detail's end check finds the render's composition from the command line (plan::composition), so the export crate carries none of it and stays inside its planned size

shinyobjectz50a7e94f5e56
diff --git a/runtime/endchecks/src/lib.rs b/runtime/endchecks/src/lib.rs
index 2090f9a7..a998d792 100644
--- a/runtime/endchecks/src/lib.rs
+++ b/runtime/endchecks/src/lib.rs
@@ -5,9 +5,6 @@
//! With them, each part held to its planned detail (raea-runtime-lod-plan; RAEA_LOD_CHECK=0 skips it): its own `lod`, else
//! its name's on the plan above the composition (its plan.rs: `lod` on the brief's make objects, MK22).
-// where a render's composition is, for the plan above it (MK22)
-pub use raea_runtime_lod_plan::plan;
-
use raea_core_facts::Finding;
use raea_core_scene::Item;
use serde_json::Value;
@@ -25,7 +22,7 @@ impl EndChecks {
pub fn new(w: u32, h: u32, fps: f64) -> EndChecks {
let on = |k: &str| std::env::var(k).as_deref() != Ok("0");
let (clip, stage) = (on("RAEA_CLIP_CHECK").then(|| raea_sys_contact::Clipping::new(w, h, fps)), on("RAEA_STAGE_CHECK").then(|| raea_sys_stage::Staging::new(w, h, fps)));
- let lod = on("RAEA_LOD_CHECK").then(|| raea_runtime_lod_plan::Lods::new(w, h, fps, plan::here(), false));
+ let lod = on("RAEA_LOD_CHECK").then(|| raea_runtime_lod_plan::Lods::new(w, h, fps, raea_runtime_lod_plan::plan::here(), false));
EndChecks { clip, stage, lod, mounts: raea_sys_stage::Mounts::new(w, h), any: false, parts: 0 }
}
diff --git a/runtime/export/src/render.rs b/runtime/export/src/render.rs
index 1ad7ea35..94157e9f 100644
--- a/runtime/export/src/render.rs
+++ b/runtime/export/src/render.rs
@@ -267,8 +267,6 @@ pub(crate) fn is_game(js: &Path) -> bool {
}
pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Option<Vec<i64>>, fed: bool, scene: Option<raea_core_program::ir::Program>, live3d: bool) -> R<String> {
- // the end checks hold the parts to the plan above this composition (`lod` on brief.ts's make objects, MK22)
- raea_runtime_endchecks::plan::at(dir);
edit_dir(dir);
raea_gpu_device::check::scene_black(Some(false));
raea_runtime_react::native::rendering_in(dir);
diff --git a/runtime/export/src/run.rs b/runtime/export/src/run.rs
index dbea4958..da92c026 100644
--- a/runtime/export/src/run.rs
+++ b/runtime/export/src/run.rs
@@ -70,7 +70,6 @@ pub(crate) fn scene_program_to(js: &Path, dir: &Path, upto: i64) -> R<Option<rae
/// A render's 3D rows as `scene_program_to` makes them, and the 3D parts that pass through each other on screen in
/// `wanted` (one frame, a still; else all): said on stderr, and kept for the render's manifest (FED_CLIPPING).
pub(crate) fn scene_program_checked(js: &Path, dir: &Path, upto: i64, wanted: Option<&[i64]>) -> R<Option<raea_core_program::ir::Program>> {
- raea_runtime_endchecks::plan::at(dir);
// stills: the frames asked for looked at first, each on its own (frames are pure). When none of them shows 3D,
// their render needs no rows, and a 2D piece's still skips stepping its whole timeline (an 80 s film's still took
// 16 s here, all of it the rows' pass finding no 3D)
diff --git a/runtime/lod-plan/src/plan.rs b/runtime/lod-plan/src/plan.rs
index 9e426472..a035054a 100644
--- a/runtime/lod-plan/src/plan.rs
+++ b/runtime/lod-plan/src/plan.rs
@@ -10,19 +10,18 @@ use std::time::SystemTime;
use serde_json::Value;
-/// The composition's folder the next end checks plan from (`at`), and the last brief read: its path, when it last
-/// changed, and its levels.
-static DIR: Mutex<Option<PathBuf>> = Mutex::new(None);
+/// The last brief read: its path, when it last changed, and its levels.
static READ: Mutex<Option<(PathBuf, Option<SystemTime>, HashMap<String, u8>)>> = Mutex::new(None);
-/// Where the render's composition is: its end checks hold its parts to the plan above it.
-pub fn at(dir: &Path) {
- let _ = DIR.lock().map(|mut d| d.replace(dir.to_path_buf()));
+/// The composition a command was given: its first word naming a .tsx or .jsx file (`raea render EDIT.tsx ...`).
+pub fn composition(words: impl IntoIterator<Item = String>) -> Option<PathBuf> {
+ words.into_iter().map(PathBuf::from).find(|w| w.extension().is_some_and(|x| x == "tsx" || x == "jsx"))
}
-/// The plan's levels for the composition `at` named, none when no render said where it is.
+/// The plan's levels for the composition this process was asked to render, read from its own command line: a render's
+/// end checks are made deep in the export, which isn't told where the composition is. None when it names none.
pub fn here() -> HashMap<String, u8> {
- let dir = DIR.lock().unwrap().clone();
+ let dir = composition(std::env::args().skip(1)).and_then(|c| std::path::absolute(c).ok()).and_then(|c| c.parent().map(Path::to_path_buf));
dir.map(|d| lods(&d)).unwrap_or_default()
}
@@ -84,6 +83,13 @@ mod tests {
assert_eq!(of_brief(&printed), HashMap::from([("kiosk".to_string(), 3)]));
}
+ #[test]
+ fn the_composition_is_the_commands_first_tsx() {
+ let words = |w: &[&str]| composition(w.iter().map(|s| s.to_string()));
+ assert_eq!(words(&["render", "shots/walk.tsx", "-o", "out/walk.mp4"]), Some(PathBuf::from("shots/walk.tsx")));
+ assert_eq!(words(&["check", "out/walk.mp4"]), None);
+ }
+
#[test]
fn a_folder_with_no_brief_planning_a_level_plans_nothing() {
let d = std::env::temp_dir().join(format!("raea-lod-plan-{}", std::process::id()));