From 0c132413b642b47820fe5e3bab5869cb2f595628 Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Wed, 18 Nov 2026 08:35:53 -0800 Subject: [PATCH] FC1c: live play keeps a material's animated fields and a shader's time moving past the first frame LT21 (a3fec64205) let live play's fast path keep component rows as they were sent while scene_sig, made of the lights and each part's s, stayed the same. A material's animate of a field past the row columns' four (material_fields) and a ThreeShaderMaterial's uniforms, time and textures (three_uniforms) are component rows too, but weren't in the sig, so after the first frame nothing sent them again: the glowing cube in bevy-ts's material-field-live stayed red where frame 25 is dark. v0.1.8-rc1's Windows release job failed on it, and the Mac does the same. scene_sig now takes every source of component rows: the components, a material's field: props and a shader's uniforms, time and textures. A frame where none of them changed keeps LT21's fast path. Measured on the Mac with the fix: bevy-ts's play cases 12 pass (material-field-live included); live-plugin needs the plugin build's avian, which the release zip has. raea-runtime-look's tests: 12 pass, one new. --- runtime/look/src/post.rs | 44 +++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/runtime/look/src/post.rs b/runtime/look/src/post.rs index 28334762..8f7e6bbd 100644 --- a/runtime/look/src/post.rs +++ b/runtime/look/src/post.rs @@ -303,6 +303,23 @@ mod tests { Item { kind, props: std::sync::Arc::new(props.as_object().cloned().unwrap_or_default()), shape: None, material: None, at: None, world: Default::default() } } + #[test] + fn the_scene_sig_changes_with_what_component_rows_are_made_from() { + let with = |m: Option<(&str, Value)>| { + let mut it = item("mesh", serde_json::json!({"components": [{"type": "Detail", "value": {"near": 10}}]})); + it.material = m.map(|(kind, props)| Node3 { kind: kind.into(), props: std::sync::Arc::new(props.as_object().cloned().unwrap_or_default()), shape: None, at: None, kids: Vec::new().into() }); + vec![it] + }; + let field = |w: f64| with(Some(("StandardMaterial", serde_json::json!({"color": "#000000", "field:emissive_exposure_weight": w})))); + let shader = |t: f64| with(Some(("ThreeShaderMaterial", serde_json::json!({"uniforms": {"u_k": 1}, "time": t})))); + // a material's animated field (FC1c) and a shader's time each change it: the fast path can't keep their rows + assert_ne!(scene_sig(&field(0.0)), scene_sig(&field(1.0))); + assert_ne!(scene_sig(&shader(0.0)), scene_sig(&shader(0.5))); + // still components the same and nothing animated: the same sig, so LT21's fast path holds + assert_eq!(scene_sig(&field(0.5)), scene_sig(&field(0.5))); + assert_eq!(scene_sig(&with(None)), scene_sig(&with(None))); + } + #[test] fn each_frame_takes_its_own_post_processing() { let sun = item("light", serde_json::json!({})); @@ -380,13 +397,30 @@ pub fn light_sig(its: &[Item]) -> String { s } -/// light_sig, and each part's Bevy components (its s, a Detail, its layer key): what a live frame's fast -/// path (raea-runtime-scene fast.rs) doesn't diff, so the frame where either changes goes the full way, and a frame -/// where neither did leaves the component rows as they were sent +/// light_sig, and everything a part's component rows are made from: its Bevy components (its s, a +/// Detail, its layer key), its material's animated fields (material_fields, docs/control.feature FC1c) and a three.js +/// shader's uniforms, time and textures (three_uniforms). A live frame's fast path (raea-runtime-scene fast.rs) doesn't +/// diff component rows, so the frame where any of these changes goes the full way, and a frame where none did leaves +/// the rows as they were sent. (11-18, v0.1.8-rc1: with the components alone, a material's animated field and a shader's +/// time stayed at the first frame in live play; bevy-ts's material-field-live failed on Windows and the Mac.) pub fn scene_sig(its: &[Item]) -> String { let mut s = light_sig(its); - for c in its.iter().filter_map(|i| i.props.get("components")) { - s.push_str(&c.to_string()); + for it in its { + if let Some(c) = it.props.get("components") { + s.push_str(&c.to_string()); + } + let Some(m) = it.material.as_ref() else { continue }; + for (k, v) in m.props.iter().filter(|(k, _)| k.starts_with("field:")) { + s.push_str(k); + s.push_str(&v.to_string()); + } + if &*m.kind == "ThreeShaderMaterial" { + for k in ["uniforms", "time", "textures"] { + if let Some(v) = m.props.get(k) { + s.push_str(&v.to_string()); + } + } + } } s }