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.

A video with 3D makes its 3D live, stepping React once a frame (part of #38, #26)

shinyobjectzb36c58f95dbe
diff --git a/runtime/export/src/fed.rs b/runtime/export/src/fed.rs
index d232e252..80db4c05 100644
--- a/runtime/export/src/fed.rs
+++ b/runtime/export/src/fed.rs
@@ -153,7 +153,7 @@ pub fn live_scene(world: &mut World, ls: &mut LiveScene, engine: &mut Option<rae
None => {
let clear = scene_clear(world);
let p = ls.open(Shot { scene: &scene, clear: clear.as_deref() }, size.0, size.1, fps);
- let mut e = raea_render::engine::Engine::new_live(&p, &raea_render::inserted_of(&p), dir).map_err(|e| format!("the 3D didn't open: {e}"))?;
+ let mut e = aov_on(raea_render::engine::Engine::new_live(&p, &raea_render::inserted_of(&p), dir).map_err(|e| format!("the 3D didn't open: {e}"))?);
e.set_rows(&[])?;
*engine = Some(e);
}
@@ -170,7 +170,6 @@ pub fn live_scene(world: &mut World, ls: &mut LiveScene, engine: &mut Option<rae
Ok(())
}
-
/// The Engine's reads (docs/sdk.feature S2d; off with RAEA_ENGINE_READS=0): the Engine stepped through frame f - 1 and its pushes sent before React
/// is asked for frame f, so frame f's reads answer from frame f - 1's World in every render: a jump to f steps 0..f - 1
/// first (it laid out f with no answer), and in order it's the frame already drawn, left as it was.
@@ -253,6 +252,8 @@ pub(crate) fn render_fed(app: &mut App, js: &Path, w: u32, h: u32, fps: f64, tot
fr = bevy_fed(app.world_mut(), bevy, cx, &page, fps)?;
}
}
+ // a video's 3D made live keeps each frame's scene for the clipping check
+ if LIVE_CLIPS.load(std::sync::atomic::Ordering::Relaxed) { fr.scene = scene_of(app.world_mut()); }
if cx.scene3d.is_none() && cx.live3d.is_none() && !cx.scene.is_empty() && BEVY_3D_PROBE.load(std::sync::atomic::Ordering::Relaxed) {
return Err(FED_3D.into());
}
diff --git a/runtime/export/src/render.rs b/runtime/export/src/render.rs
index 9b4099b5..667528aa 100644
--- a/runtime/export/src/render.rs
+++ b/runtime/export/src/render.rs
@@ -186,16 +186,23 @@ pub fn render_bundle(js: &Path, dir: &Path, out: &Path, wanted: Option<Vec<i64>>
BEVY_3D_PROBE.store(false, std::sync::atomic::Ordering::Relaxed);
if video && r.as_ref().err().is_some_and(|e| e.contains(FED_3D)) {
raea_runtime_react::startup_mark("a 3D frame met: the render starts again with its 3D");
- if let Some(scene) = scene_program_checked(js, dir, 0, None)? {
- return render_bundle_with(js, dir, out, None, true, Some(scene), false);
+ // its 3D made live as each frame steps, React once a frame (#26, #38); RAEA_3D=program makes its rows first
+ if how != "program" {
+ LIVE_CLIPS.store(true, std::sync::atomic::Ordering::Relaxed);
+ let r = render_bundle_with(js, dir, out, None, true, None, true);
+ LIVE_CLIPS.store(false, std::sync::atomic::Ordering::Relaxed);
+ return r;
}
- return render_bundle_with(js, dir, out, None, false, None, false);
+ let scene = scene_program_checked(js, dir, 0, None)?;
+ return render_bundle_with(js, dir, out, None, scene.is_some(), scene, false);
}
r
}
/// The bevy_ui page's video render stops at the first frame with 3D (Err(FED_3D)), to start again fed with its 3D live.
pub(crate) static BEVY_3D_PROBE: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+/// A video's 3D made live (not a game's): each frame's scene kept in its Frame for the clipping check at the end.
+pub(crate) static LIVE_CLIPS: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// A game's bundle: it steps state with useGameState (bundles aren't minified, and what isn't used is left out).
pub(crate) fn is_game(js: &Path) -> bool {
@@ -374,7 +381,7 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti
}
/// An engine for the scene path, drawing the guide data when `--aov` asked for it.
-fn aov_on(mut e: raea_render::engine::Engine) -> raea_render::engine::Engine {
+pub(crate) fn aov_on(mut e: raea_render::engine::Engine) -> raea_render::engine::Engine {
if AOV.load(std::sync::atomic::Ordering::Relaxed) {
e.want_aov();
}