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
Fold two new copies into shared readers: keyed_vec (a camera's up, a 2D part's quat) and the sprite Tiled flags
shinyobjectzced8fe55a22f
diff --git a/runtime/look/src/camera.rs b/runtime/look/src/camera.rsindex 09bf882a..672abfae 100644--- a/runtime/look/src/camera.rs+++ b/runtime/look/src/camera.rs@@ -64,12 +64,7 @@ fn one(all: &[Vec<Item>], p: &mut Program, row: &mut BTreeMap<String, V>, k: usicolumn(p, row, id, "ortho", &its.iter().map(|c| n(&c.props, "ortho", 0.0)).collect::<Vec<_>>());}// which way is up (`up`; +Y by default): a camera that rolls, as a solved one does (raea-render's up_x/y/z, Matchmove)- if its.iter().any(|c| c.props.get("up").is_some()) {- let up: Vec<[f64; 3]> = its.iter().map(|c| vec3(&c.props, "up", [0.0, 1.0, 0.0])).collect();- for (k, name) in ["up_x", "up_y", "up_z"].iter().enumerate() {- column(p, row, id, name, &up.iter().map(|v| v[k]).collect::<Vec<_>>());- }- }+ keyed_vec(p, row, id, &its, "up", &["up_x", "up_y", "up_z"], &[0.0, 1.0, 0.0]);// a window on a larger view (`view`: its full size and this frame's offset, in frame pixels): a crop of// footage keeps its lens's centre (raea-render's camera view_*, Matchmove's 9:16 from 16:9)if its.iter().any(|c| c.props.get("view").is_some_and(Value::is_object)) {diff --git a/runtime/look/src/parts.rs b/runtime/look/src/parts.rsindex 374df4b8..2ad018d3 100644--- a/runtime/look/src/parts.rs+++ b/runtime/look/src/parts.rs@@ -29,3 +29,15 @@ pub fn tint(p: &mut Program, row: &mut BTreeMap<String, V>, id: &str, its: &[Iteexact(p, row, id, name, &colors.iter().map(|v| v[c]).collect::<Vec<_>>());}}++/// A vector prop keyed as one column per component (a camera's `up` as up_x/y/z, a 2D part's `quat` as q_x..q_w),+/// written only when some frame sets it; a frame without it (or with the wrong length) takes `d`+pub fn keyed_vec(p: &mut Program, row: &mut BTreeMap<String, V>, id: &str, its: &[Item], key: &str, names: &[&str], d: &[f64]) {+ if !its.iter().any(|i| i.props.contains_key(key)) {+ return;+ }+ for (k, name) in names.iter().enumerate() {+ let at = |i: &Item| i.props.get(key).and_then(Value::as_array).filter(|a| a.len() == names.len()).and_then(|a| a[k].as_f64());+ column(p, row, id, name, &its.iter().map(|i| at(i).unwrap_or(d[k])).collect::<Vec<_>>());+ }+}diff --git a/runtime/scene2d/src/lib.rs b/runtime/scene2d/src/lib.rsindex cbf089e6..80c12453 100644--- a/runtime/scene2d/src/lib.rs+++ b/runtime/scene2d/src/lib.rs@@ -28,12 +28,7 @@ fn place2d(p: &mut Program, row: &mut BTreeMap<String, V>, id: &str, its: &[Itemcolumn(p, row, id, col, &its.iter().map(|i| scale(i, k)).collect::<Vec<_>>());}// `quat`: Bevy's rotation as given, in place of `rot` (q_x q_y q_z q_w, as a 3D part's)- if its.iter().any(|i| i.props.get("quat").is_some()) {- let q = |i: &Item, k: usize| i.props.get("quat").and_then(|q| q.get(k)).and_then(Value::as_f64).unwrap_or(if k == 3 { 1.0 } else { 0.0 });- for (k, col) in ["q_x", "q_y", "q_z", "q_w"].iter().enumerate() {- column(p, row, id, col, &its.iter().map(|i| q(i, k)).collect::<Vec<_>>());- }- }+ keyed_vec(p, row, id, its, "quat", &["q_x", "q_y", "q_z", "q_w"], &[0.0, 0.0, 0.0, 1.0]);tint(p, row, id, its, color);}diff --git a/systems/sprite/src/lib.rs b/systems/sprite/src/lib.rsindex 408896f4..742a3f43 100644--- a/systems/sprite/src/lib.rs+++ b/systems/sprite/src/lib.rs@@ -251,8 +251,8 @@ fn image_mode(json: &str) -> SpriteImageMode {return SpriteImageMode::Sliced(TextureSlicer { border, center_scale_mode: slice(s.get("center_scale_mode")), sides_scale_mode: slice(s.get("sides_scale_mode")), max_corner_scale: f(s, "max_corner_scale", 1.0) });}if let Some(t) = v.get("Tiled") {- let b = |k: &str| t.get(k).and_then(|x| x.as_bool()).unwrap_or(false);- return SpriteImageMode::Tiled { tile_x: b("tile_x"), tile_y: b("tile_y"), stretch_value: f(t, "stretch_value", 1.0) };+ let on = |k: &str| t.get(k) == Some(&serde_json::Value::Bool(true));+ return SpriteImageMode::Tiled { tile_x: on("tile_x"), tile_y: on("tile_y"), stretch_value: f(t, "stretch_value", 1.0) };}default()}