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.

BL36, GD11: <BlenderShot> and <GodotShot>'s native calls move to a crate of their own, raea-runtime-shots (runtime/shots), which raea-runtime-react registers: in runtime/react they took that crate to 2,202 lines, over the 2,000 limit. No change in what they do; the size and length a shot is asked for are whole numbers of 1 or more and its fps a number over 0, each said by name when it isn't. Tests: a_shot_is_keyed_by_what_it_is_made_from and the command's

shinyobjectz9ab4e05f864b
diff --git a/Cargo.lock b/Cargo.lock
index 5f62034e..e532e9e2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -15104,6 +15104,7 @@ dependencies = [
"raea-runtime-plugins",
"raea-runtime-scene",
"raea-runtime-shared",
+ "raea-runtime-shots",
"raea-runtime-twins",
"raea-runtime-view",
"raea-sys-animate",
@@ -15171,6 +15172,17 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "raea-runtime-shots"
+version = "0.1.0"
+dependencies = [
+ "raea-io-assets",
+ "raea-native",
+ "raea-runtime-calls",
+ "raea-sys-bake",
+ "serde_json",
+]
+
[[package]]
name = "raea-runtime-sound"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index ef52e061..214abb9a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -146,6 +146,7 @@ members = [
"runtime/bundle/lib",
"engine/shape-web",
"runtime/calls",
+ "runtime/shots",
"runtime/export",
"runtime/live",
"runtime/page",
diff --git a/runtime/react/Cargo.toml b/runtime/react/Cargo.toml
index f6ffdef3..44ad1fa6 100644
--- a/runtime/react/Cargo.toml
+++ b/runtime/react/Cargo.toml
@@ -72,6 +72,8 @@ raea-sys-animate = { path = "../../systems/animate" }
# Bevy plugins compiled into the engine, each behind a feature (sdk/raea/docs/bevy-plugins.md); none by default
raea-bevy-plugins = { path = "../../engine/bevy-plugins", optional = true }
raea-sys-bake = { path = "../../systems/bake" }
+# <BlenderShot> and <GodotShot>'s native calls (blender.shot, godot.shot)
+raea-runtime-shots = { path = "../shots" }
[package.metadata.cargo-shear]
# raea-io-media is here for its features (h264), which the platform decoders raea-render reads take
diff --git a/runtime/react/src/scene.rs b/runtime/react/src/scene.rs
index b9ee7d9c..8fd9a725 100644
--- a/runtime/react/src/scene.rs
+++ b/runtime/react/src/scene.rs
@@ -36,8 +36,6 @@ pub(crate) use contact::register as register_scene;
pub mod physics;
// matchmove: `track` and the matchmove.solve native call (scene/track.rs)
pub mod track;
-// shots drawn by Blender and Godot: <BlenderShot>, <GodotShot> as native calls made by `raea blender|godot shot` (scene/shots.rs)
-pub mod shots;
thread_local! {
/// each part's data-props as last parsed: its text and the props, and the scene it was last read in
diff --git a/runtime/react/src/thread.rs b/runtime/react/src/thread.rs
index f2bded95..c6cd901f 100644
--- a/runtime/react/src/thread.rs
+++ b/runtime/react/src/thread.rs
@@ -39,8 +39,8 @@ pub fn register_natives() {
native::register();
raea_native::register("page.viewBox", "{}", "[number, number, number, number] | null", "the box (x, y, w, h in frame px) a camera in a page element draws its view in, as last laid out; null when it draws under the whole frame (3D picking in the box, docs/sdk.feature S3a)", |_| Ok(serde_json::json!(*VIEW_BOX.lock().unwrap())));
// matchmove.solve (scene/track.rs), physics.* for <Physics> and <Goo> (systems/bake), scene.bounds and facing
- // (scene/contact.rs), blender.shot and godot.shot (scene/shots.rs)
- for register in [scene::track::register, scene::physics::register, scene::shots::register, scene::register_scene] {
+ // (scene/contact.rs), blender.shot and godot.shot (runtime/shots)
+ for register in [scene::track::register, scene::physics::register, raea_runtime_shots::register, scene::register_scene] {
register();
}
}
diff --git a/runtime/shots/Cargo.toml b/runtime/shots/Cargo.toml
new file mode 100644
index 00000000..20e73188
--- /dev/null
+++ b/runtime/shots/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "raea-runtime-shots"
+version = "0.1.0"
+edition = "2024"
+license = "FSL-1.1-ALv2"
+publish = false
+description = "<BlenderShot> and <GodotShot> as native calls: a shot's frames made once by `raea blender|godot shot` and kept in the composition's asset store"
+
+[dependencies]
+# the native-call registry, and the composition's folder the shot's paths are read from
+raea-native = { path = "../../engine/native", default-features = false }
+raea-runtime-calls = { path = "../calls" }
+# the composition's asset store, where the frames are kept
+raea-io-assets = { path = "../../io/assets" }
+# the bake's progress while another engine draws the frames
+raea-sys-bake = { path = "../../systems/bake" }
+serde_json = "1"
diff --git a/runtime/react/src/scene/shots.rs b/runtime/shots/src/lib.rs
similarity index 93%
rename from runtime/react/src/scene/shots.rs
rename to runtime/shots/src/lib.rs
index 72153d72..832bd489 100644
--- a/runtime/react/src/scene/shots.rs
+++ b/runtime/shots/src/lib.rs
@@ -14,7 +14,7 @@ type R<T> = Result<T, String>;
const GIVES: &str = "{ dir: string; frames: number }";
-pub(crate) fn register() {
+pub fn register() {
raea_native::register(
"blender.shot",
"{ script?: string; file?: string; engine?: string; samples?: number; transparent?: boolean; args?: string[]; fps: number; width: number; height: number; frames: number }",
@@ -83,15 +83,17 @@ fn identity(k: &mut Key, p: &Path) {
/// `raea blender shot` / `raea godot shot`'s arguments for this request, the source first.
fn command(engine: &str, v: &Value, dir: &Path, out: &Path) -> R<Vec<String>> {
let s = |k: &str| v.get(k).and_then(Value::as_str).map(str::to_string);
- let n = |k: &str| v.get(k).and_then(Value::as_f64).ok_or_else(|| format!("{engine}.shot: {k} is a number"));
+ // the size and length as whole counts, at least one
+ let whole = |k: &str| v[k].as_f64().filter(|x| *x >= 1.0).map(|x| x.round() as u32).ok_or_else(|| format!("{engine}.shot: {k} is a number of 1 or more"));
+ let fps = v["fps"].as_f64().filter(|f| *f > 0.0).ok_or_else(|| format!("{engine}.shot: fps is a number over 0"))?;
let at = |p: String| if p.starts_with("res://") { p } else { dir.join(p).to_string_lossy().into_owned() };
let src = match engine {
"blender" => s("script").or_else(|| s("file")).ok_or("BlenderShot: give script or file")?,
_ => s("script").or_else(|| s("scene")).ok_or("GodotShot: give script or scene")?,
};
- let (w, h) = (n("width")?.round() as u32, n("height")?.round() as u32);
+ let (w, h) = (whole("width")?, whole("height")?);
let mut a = vec![engine.to_string(), "shot".into(), at(src), "-o".into(), out.to_string_lossy().into_owned()];
- a.extend(["--frames".into(), (n("frames")?.round() as u32).to_string(), "--fps".into(), n("fps")?.to_string(), "--size".into(), format!("{w}x{h}")]);
+ a.extend(["--frames".into(), whole("frames")?.to_string(), "--fps".into(), fps.to_string(), "--size".into(), format!("{w}x{h}")]);
if engine == "blender" {
if let (Some(_), Some(f)) = (s("script"), s("file")) {
a.extend(["--file".into(), at(f)]);
@@ -122,7 +124,7 @@ fn command(engine: &str, v: &Value, dir: &Path, out: &Path) -> R<Vec<String>> {
}
fn shot(engine: &str, v: &Value) -> R<Value> {
- let dir = crate::native::composition_dir().unwrap_or_else(|| PathBuf::from("."));
+ let dir = raea_runtime_calls::composition_dir().unwrap_or_else(|| PathBuf::from("."));
let frames = v.get("frames").and_then(Value::as_u64).filter(|n| *n > 0).ok_or_else(|| format!("{engine}.shot: frames must be a whole number over 0"))?;
// what the frames are made from
let mut k = Key::new();
diff --git a/tools/layers.toml b/tools/layers.toml
index a90c8b0a..90d7a550 100644
--- a/tools/layers.toml
+++ b/tools/layers.toml
@@ -129,6 +129,7 @@ raea-runtime-bake = "runtime"
raea-runtime-bundle = "runtime"
raea-runtime-bundle-lib = "runtime"
raea-runtime-calls = "runtime"
+raea-runtime-shots = "runtime"
raea-runtime-export = "runtime"
raea-runtime-page = "runtime"
raea-runtime-sound = "runtime"