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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
SG2: footage, splats, sequences, fog, fires and grass are rows by identity, and spawned again when what they are changes
shinyobjectz2aa85c456a5b
diff --git a/core/scene/src/kept.rs b/core/scene/src/kept.rsindex 95e87039..8674ab0d 100644--- a/core/scene/src/kept.rs+++ b/core/scene/src/kept.rs@@ -57,7 +57,9 @@ const PLACED: [&str; 16] = ["x", "y", "z", "q_x", "q_y", "q_z", "q_w", "scale_x"/// takes frame by frame (live_dynamic, PLACED), nor its identity. A mesh's and a glyph's colour and a mesh's glow are/// sent as columns once they change. A shader's uniforms ride in `three` and `shader`, which change on each frame an/// animated uniform does: those stay with their own fix (frozen uniforms), not a part spawned every frame. A model is-/// spawned again only for a new file, never for its animation's columns.+/// spawned again only for a new file, never for its animation's columns. The kinds a row takes whole from its first+/// frame (footage behind the 3D, a splat, a baked sequence, a fog's density texture, a fire's simulation, a field of+/// grass) keep what they are: a plate on another's row kept the old clip (SG2).pub fn kept_col(kind: &str, col: &str) -> bool {if matches!(col, "id" | "name") {return false;@@ -68,7 +70,7 @@ pub fn kept_col(kind: &str, col: &str) -> bool {"model" => col == "src","text" => !PLACED.contains(&col),"glyph" => matches!(col, "target" | "at" | "span" | "ch"),- _ => false,+ _ => WHOLE.iter().any(|(k, cols, _)| *k == kind && cols.contains(&col)),}}@@ -136,7 +138,11 @@ pub fn spawn_sig(it: &Item) -> u64 {"model" => hash_value(it.props.get("src").unwrap_or(&Value::Null), &mut h),// a picture's size and cut, a decal's maps and fade (panels_rows, decals_rows)"panel" | "decal" => hash_props(&it.props, &mut h, |k| if it.kind == "panel" { ["width", "height", "shadow", "cutout"] } else { ["src", "normalMap", "fade", "unlit"] }.contains(&k)),- _ => {}+ kind => {+ if let Some((_, _, props)) = WHOLE.iter().find(|(k, ..)| *k == kind) {+ hash_props(&it.props, &mut h, |k| props.contains(&k));+ }+ }}h.finish()}@@ -166,6 +172,17 @@ pub fn split_kept(tracks: Vec<(String, Vec<Option<Item>>)>) -> Vec<(String, Vec<out}+/// The kinds whose rows take what they are from their first frame: the kind, its row's columns that say it, the props+/// they're made from (plates_rows, fogs_rows, fires_rows, grass.rs, splat.rs, meshseq.rs).+const WHOLE: [(&str, &[&str], &[&str]); 6] = [+ ("plate", &["src", "k1"], &["src", "k1"]),+ ("splat", &["src", "morph_to"], &["src", "morphTo"]),+ ("meshseq", &["src", "map"], &["src", "map"]),+ ("fogvolume", &["density_texture"], &["density_texture"]),+ ("fire", &["sim", "seed", "steps"], &["sim", "seed", "steps"]),+ ("grass", &["grass"], &["spec"]),+];+/// A mesh's kept inputs as a live scene's row holds them, so a frame on the fast path can tell when one changed (then/// the full path, which spawns the part again). Its props are held, not copied: held, they are never changed in place/// (read3d's props_in_place takes only props nobody else holds), so the same Arc is the same props, and only a newdiff --git a/docs/stage-guards.feature b/docs/stage-guards.featureindex 8088ec93..8f3d536e 100644--- a/docs/stage-guards.feature+++ b/docs/stage-guards.feature@@ -108,10 +108,19 @@ Feature: Stage guards: a 3D render an agent can't breakGiven the plan| crate | file | lines | job || raea-runtime-scene | runtime/scene/src/live.rs | +3 | text blocks by identity, as the groups are; their glyphs follow their block's id |+ | raea-runtime-scene | runtime/scene/src/live.rs | +10 | plates, splats, sequences, fog, fires and grass by identity |+ | raea-runtime-scene | runtime/scene/src/lib.rs | 0 | their tracks cut where what they take whole changes (split_kept) |+ | raea-core-scene | core/scene/src/kept.rs | +18 | WHOLE: each kind's columns that say what it is, and the props they come from |+ | raea-runtime-live | runtime/live/tests/stage_guards.rs | +30 | a_new_plate_never_takes_an_old_ones_row |Then kept-props3.tsx passes: the new RichText draws its own words in its own colour, and the old one is goneAnd a part that unmounts while another mounts beside it changes nothing else's row# Status 11-21 (branch stage-guards): text blocks are rows by identity; a_new_text_never_takes_an_old_ones_row- # passes. Fires, fog volumes, plates and the other kinds a live frame diffs whole still take their frame's id.+ # passes. Branch stage-guards-6: plates, splats, mesh sequences, fog volumes, fires and grass are rows by identity+ # too, and what each takes whole from its first frame (a plate's clip, a splat's or a sequence's file, a fog's+ # density texture, a fire's simulation, a field's grids) spawns it again when it changes (core/scene kept.rs+ # WHOLE): a_new_plate_never_takes_an_old_ones_row. An unnamed fire or fog has only its order to be known by, so+ # name the ones that come and go. Sprites, 2D shapes and bare entities keep their render ids, which components+ # target.@doneScenario: SG3. The atlas allocates before it drawsdiff --git a/runtime/live/tests/stage_guards.rs b/runtime/live/tests/stage_guards.rsindex 3251c5eb..350ee433 100644--- a/runtime/live/tests/stage_guards.rs+++ b/runtime/live/tests/stage_guards.rs@@ -140,3 +140,30 @@ fn a_still_draws_its_own_frames_shape_and_words() {assert_eq!(spans.len(), 2);assert!(spans[0].contains("0.0 MB") && spans[1].contains("12.5 MB"));}++/// Footage behind the 3D (SG2): a Plate unmounting as another mounts, neither named. The new one is a row of its own+/// with its own clip; the old one's row is hidden, never handed on with the old clip. A fire whose simulation changes+/// is spawned again, as a mesh whose shape changes is.+#[test]+fn a_new_plate_never_takes_an_old_ones_row() {+ check_on();+ let plate = |src: &str| node("Plate", json!({ "src": src, "time": 0.0 }), vec![]);+ let mut ls = LiveScene::default();+ ls.open(Shot { scene: &[plate("/clips/street.mp4")], clear: None }, 64, 64, 30.0);+ let (set, _) = ls.frame(Shot { scene: &[plate("/clips/street.mp4")], clear: None });+ let old: Vec<String> = set.iter().map(|t| t.id.clone()).collect();+ let (set, _) = ls.frame(Shot { scene: &[plate("/clips/harbour.mp4")], clear: None });+ let new = spawned(&set, "plate", "src");+ assert_eq!(new.len(), 1, "{set:?}");+ assert!(s(new[0].vals.get("src")).ends_with("harbour.mp4"));+ assert!(!old.contains(&new[0].id), "a row of its own, not the old plate's");+ assert!(set.iter().any(|t| t.kind == "plate" && t.id != new[0].id && t.vals.get("visible") == Some(&V::N(0.0))), "{set:?}");++ let fire = |sim: &str| node("Fire", json!({ "sim": { "kind": sim }, "time": 0.0 }), vec![]);+ let mut ls = LiveScene::default();+ ls.open(Shot { scene: &[fire("smoke")], clear: None }, 64, 64, 30.0);+ ls.frame(Shot { scene: &[fire("smoke")], clear: None });+ let (set, gone) = ls.frame(Shot { scene: &[fire("cloud")], clear: None });+ assert_eq!(gone.len(), 1, "the old fire dropped");+ assert!(s(spawned(&set, "fire", "sim").first().and_then(|t| t.vals.get("sim"))).contains("cloud"), "{set:?}");+}diff --git a/runtime/scene/src/lib.rs b/runtime/scene/src/lib.rsindex df73de9e..711af13c 100644--- a/runtime/scene/src/lib.rs+++ b/runtime/scene/src/lib.rs@@ -291,14 +291,14 @@ impl Tracks {models: split_kept(tracks_of(all, &["model"])),panels: split_kept(tracks_of(all, &["panel"])),decals: split_kept(tracks_of(all, &["decal"])),- fogs: tracks_of(all, &["fogvolume"]),- fires: tracks_of(all, &["fire"]),- grasses: tracks_of(all, &["grass"]),- splats: tracks_of(all, &["splat"]),+ fogs: split_kept(tracks_of(all, &["fogvolume"])),+ fires: split_kept(tracks_of(all, &["fire"])),+ grasses: split_kept(tracks_of(all, &["grass"])),+ splats: split_kept(tracks_of(all, &["splat"])),sprites: tracks_of(all, &["sprite"]),shapes2d: tracks_of(all, &["shape2d"]),- plates: tracks_of(all, &["plate"]),- meshseqs: tracks_of(all, &["meshseq"]),+ plates: split_kept(tracks_of(all, &["plate"])),+ meshseqs: split_kept(tracks_of(all, &["meshseq"])),entities: tracks_of(all, &["entity"]),texts: split_kept(tracks_of(all, &["text"])),}diff --git a/runtime/scene/src/live.rs b/runtime/scene/src/live.rsindex 3b4e0460..567e3fba 100644--- a/runtime/scene/src/live.rs+++ b/runtime/scene/src/live.rs@@ -7,6 +7,9 @@ pub struct Shot<'a> {pub clear: Option<&'a str>,}+/// The kinds whose rows are known by their part's identity, not their place in the frame (SG2)+const BY_IDENTITY: [&str; 12] = ["light", "mesh", "model", "panel", "decal", "text", "plate", "fogvolume", "fire", "grass", "splat", "meshseq"];+/// A live game's 3D (live.rs): its rows made frame by frame from that frame's own scene, as play computed it, instead/// of from a scripted run stepped ahead (scene_program). Parts are matched across frames by the identity `tracks`/// gives them (a name, else kind and shape counted in tree order), so a part keeps its row as a render's does. The@@ -20,8 +23,8 @@ pub struct LiveScene {/// per row id: its kind, its first values, what was last sent, whether its colour has changed (a render keys/// col_r/g/b on every frame once it does), and the frames it has been missingpub(crate) rows: std::collections::HashMap<String, LiveRow>,- /// rows made per group (lights, meshes, models, panels, decals, texts): the next one's number- pub(crate) made: [usize; 6],+ /// rows made per kind of BY_IDENTITY: the next one's number+ pub(crate) made: [usize; 12],/// row id -> a part's kept inputs this frame (not a light's), for its row (the fast path's SG1 guard)pub(crate) kept_now: std::collections::HashMap<String, KeptInputs>,pub(crate) cam: BTreeMap<String, V>,@@ -129,30 +132,24 @@ impl LiveScene {let kind = track[0].as_ref().map(|i| i.kind).unwrap_or("directional");local.insert(if kind == "directional" { format!("sun{li}") } else { format!("{kind}{li}") }, key);}- // a text block too (SG2: by its frame's place, a block mounted as another went took that one's row and words)- for (prefix, group) in [("mesh", &tr.meshes), ("model", &tr.models), ("plane", &tr.panels), ("decal", &tr.decals), ("text", &tr.texts)] {+ // a text block too (SG2: by its frame's place, a block mounted as another went took that one's row and words), and+ // footage, splats, sequences, fog, fires and grass (a plate mounted as another went kept the other's clip)+ for (prefix, group) in [("mesh", &tr.meshes), ("model", &tr.models), ("plane", &tr.panels), ("decal", &tr.decals), ("text", &tr.texts), ("plate", &tr.plates), ("fog", &tr.fogs), ("fire", &tr.fires), ("grass", &tr.grasses), ("splat", &tr.splats), ("meshseq", &tr.meshseqs)] {for (k, (key, _)) in group.iter().enumerate() {local.insert(format!("{prefix}{k}"), key);}}let mut out = Vec::new();- // the other kinds (bare entities, Bevy components and resources, fires, fog volumes, splats, plates...): by- // the ids a render gives them, a component's target as the live rows name it (G15)+ // the other kinds (bare entities, Bevy components and resources, sprites, 2D shapes...): by the ids a render+ // gives them, a component's target as the live rows name it (G15)let mut others: Vec<(String, BTreeMap<String, V>)> = Vec::new();let mut live_id: std::collections::HashMap<String, String> = std::collections::HashMap::new();for (kind, rows) in p.spawns {- let group = match kind.as_str() {- "light" => 0,- "mesh" => 1,- "model" => 2,- "panel" => 3,- "decal" => 4,- "text" => 5,- "camera" => continue,- _ => {+ let Some(group) = BY_IDENTITY.iter().position(|g| *g == kind) else {+ if kind != "camera" {others.extend(rows.into_iter().map(|r| (kind.clone(), r)));- continue;}+ continue;};for mut row in rows {let Some(V::S(lid)) = row.get("id").cloned() else { continue };