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
#19: children of a preserve-3d parent follow its transform when a script sets it. blitz-dom's resolve_transforms returned an undamaged node's cached place unless it was seen through a perspective, so a node in its parent's 3D rendering context kept the projection from before the parent's new transform (the card under the issue's rig was drawn at its untransformed place, below the frame). A node in a 3D context, or holding a projection (which may have lost its context since), is now placed again on every resolve, as one under a perspective already was. Test: resolve::tests::a_child_follows_its_preserve_3d_parent_set_later (the card's projection with the transform set after the first resolve equals the one with it in the first style; it failed without the fix). The issue's page now renders pixel-identical to the same transform in the stylesheet, and a GSAP rig animating the world shows the card (0 yellow pixels before at t=0.5 and 0.95, 290k and 520k after). Cost, a static preserve-3d world of 300 cards over 300 frames, three runs each back to back, the raea before this against this one: 9.27-9.87 fps before, 9.38-9.63 after (no change past noise).
shinyobjectz6654b93639e8
diff --git a/vendor/blitz-dom/src/resolve.rs b/vendor/blitz-dom/src/resolve.rsindex 45df46c1..a283e98b 100644--- a/vendor/blitz-dom/src/resolve.rs+++ b/vendor/blitz-dom/src/resolve.rs@@ -239,8 +239,13 @@ impl BaseDocument {let scale = self.viewport.scale_f64();// raea: a child seen through its parent's perspective is placed again whenever the parent is, damaged or not:- // the perspective moves with the parent's size and scroll (perspective-origin-scroll), not the child's+ // the perspective moves with the parent's size and scroll (perspective-origin-scroll), not the child's. So is+ // one in a 3D rendering context, whose projection is its context's matrix times its own (a script setting the+ // preserve-3d parent's transform left its children at their old projection, #19), and one with a projection+ // now, which may have lost its context sinceif perspective.is_none()+ && context.is_none()+ && !self.projections.contains_key(&node_id)&& !self.nodes[node_id].damage().map(|d| d.contains(style::selector_parser::RestyleDamage::RECALCULATE_OVERFLOW))@@ -559,3 +564,41 @@ impl BaseDocument {// taffy::print_tree(self, root_node_id)}}++#[cfg(test)]+mod tests {+ use crate::{Attribute, BaseDocument, DocumentConfig, qual_name};+ use blitz_traits::shell::{ColorScheme, Viewport};++ /// `#root` (perspective) > `#world` (preserve-3d, `world` its style) > `#card`: the document and the card+ fn rig(world: &str) -> (BaseDocument, crate::NodeId, crate::NodeId) {+ let mut doc = BaseDocument::new(DocumentConfig { viewport: Some(Viewport::new(1920, 1080, 1.0, ColorScheme::Light)), ..Default::default() });+ let style = |v: &str| vec![Attribute { name: qual_name!("style"), value: v.to_string() }];+ let root_id = doc.root_node().id;+ let mut m = doc.mutate();+ let root = m.create_element(qual_name!("div"), style("position:relative;width:1920px;height:1080px;perspective:1000px"));+ let w = m.create_element(qual_name!("div"), style(&format!("position:absolute;inset:0;transform-style:preserve-3d;{world}")));+ let card = m.create_element(qual_name!("div"), style("position:absolute;left:600px;top:1200px;width:700px;height:427px"));+ m.append_children(w, &[card]);+ m.append_children(root, &[w]);+ m.append_children(root_id, &[root]);+ drop(m);+ doc.resolve(0.0);+ (doc, w, card)+ }++ const MOVE: &str = "translate3d(0px,-1000px,100px) rotateX(11deg)";++ /// raea #19: a preserve-3d parent's transform set after the first resolve (as a script sets it) places its children+ /// as the same transform in its first style does; they kept their old projection, and the card was drawn off-frame+ #[test]+ fn a_child_follows_its_preserve_3d_parent_set_later() {+ let (styled, _, card) = rig(&format!("transform:{MOVE}"));+ let want = styled.projections.get(&card).copied();+ assert!(want.is_some(), "the card has a projection in its parent's 3D context");+ let (mut doc, world, card) = rig("");+ doc.mutate().set_style_property(world, "transform", MOVE);+ doc.resolve(0.0);+ assert_eq!(doc.projections.get(&card).copied(), want);+ }+}diff --git a/vendor/vendor.toml b/vendor/vendor.tomlindex c1a0d71d..ecb4a362 100644--- a/vendor/vendor.toml+++ b/vendor/vendor.toml@@ -63,7 +63,7 @@ exit = "a Blitz release that draws these"path = "vendor/blitz-dom"upstream = "crates.io:0.3.0-beta.4"kind = "patch"-reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246; a node removed in a mutation batch dropped from the style, form and title nodes the batch flushes (raea #24)"+reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246; a node removed in a mutation batch dropped from the style, form and title nodes the batch flushes (raea #24); a node in a 3D rendering context (or with a projection) placed again on every resolve, so it follows a preserve-3d parent whose transform a script set (raea #19)"exit = "a Blitz release with #1244/#1246 and these"[parley_engine]