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
FC0a: ui/layout/grid passes (SSIM 0.995): a Node's visibility (Inherited, Hidden, Visible) as CSS's, and a wrapped bevy_text box as wide as its widest line with its trailing spaces (parley's full_width, as TextPipeline::compute_size measures it), which centres a justify_items Center paragraph where Bevy does
shinyobjectzc7530ccbdd10
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.listindex 89413b2f..fcb0cc1b 100644--- a/bench/bevy-parity/examples.list+++ b/bench/bevy-parity/examples.list@@ -75,3 +75,4 @@ ui/layout/ghost_nodesui/relative_cursor_positionui/ui_target_cameraui/text/text_wrap_debug+ui/layout/griddiff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsvindex 5a5b063f..6bbad3fd 100644--- a/bench/bevy-parity/runs.tsv+++ b/bench/bevy-parity/runs.tsv@@ -74,3 +74,4 @@ ui/layout/ghost_nodes - 10ui/relative_cursor_position - 10ui/ui_target_camera - 10ui/text/text_wrap_debug - 10+ui/layout/grid - 10diff --git a/docs/bevy-parity.md b/docs/bevy-parity.mdindex 0d70271a..309a5243 100644--- a/docs/bevy-parity.md+++ b/docs/bevy-parity.md@@ -4,7 +4,7 @@ Bevy v0.20.0's examples against their raea TSX ports (docs/control.feature FC0a)don't edit. An example passes when every probed frame passes pixels (SSIM 0.98 and no 32 px tile off by more than 24 of 255) and cost (batch keys andframe time at most 1.25x the example's). Wall time is one machine's, measured in the same run.-Examples: **438**, ported **75**, passing **71**, excluded **16** (docs/bevy-parity/excluded.tsv), left **351**.+Examples: **438**, ported **76**, passing **72**, excluded **16** (docs/bevy-parity/excluded.tsv), left **350**.raea's frame ms is its update's plus the time React takes to step a frame for its 3D (step), which the exampledoesn't pay.@@ -130,7 +130,8 @@ doesn't pay.| ui/layout/ghost_nodes | 10 | 0.998544 | 9 | 0 / 0 | 455 / 492 | 5 / 7 | 1 / 1 | 35.333 / 1.312 = 1.13 + 0.182 | yes | || ui/relative_cursor_position | 10 | 0.999907 | 2 | 0 / 0 | 443 / 492 | 5 / 7 | 1 / 1 | 52.279 / 3.978 = 3.723 + 0.255 | yes | || ui/ui_target_camera | 10 | 0.998769 | 7 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 39.413 / 1.71 = 1.71 + 0 | yes | |-| ui/text/text_wrap_debug | 10 | 0.986254 | 15 | 0 / 0 | 589 / 492 | 5 / 7 | 1 / 1 | 34.219 / 0.924 = 0.924 + 0 | yes | |+| ui/text/text_wrap_debug | 10 | 0.986254 | 15 | 0 / 0 | 589 / 492 | 5 / 7 | 1 / 1 | 32.74 / 1.068 = 1.068 + 0 | yes | |+| ui/layout/grid | 10 | 0.995059 | 14 | 0 / 0 | 482 / 492 | 5 / 7 | 1 / 1 | 34.457 / 1.496 = 1.496 + 0 | yes | |## Excludeddiff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonlindex 3add8323..22fdcb77 100644--- a/docs/bevy-parity/results.jsonl+++ b/docs/bevy-parity/results.jsonl@@ -117,4 +117,5 @@{"example":"ui/layout/ghost_nodes","frame":10,"ssim":0.998544,"tile":9,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":10,"frame_ms":35.333,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.13,"step_ms":0.182,"cost_ms":1.312},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/relative_cursor_position","frame":10,"ssim":0.999907,"tile":2,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":52.279,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":3.723,"step_ms":0.255,"cost_ms":3.978},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/ui_target_camera","frame":10,"ssim":0.998769,"tile":7,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":10,"frame_ms":39.413,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.71,"step_ms":null,"cost_ms":1.71},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}-{"example":"ui/text/text_wrap_debug","frame":10,"ssim":0.986254,"tile":15,"bevy":{"batch_keys":0,"entities":589,"extents":[],"frame":10,"frame_ms":34.219,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.924,"step_ms":null,"cost_ms":0.924},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}+{"example":"ui/text/text_wrap_debug","frame":10,"ssim":0.986254,"tile":15,"bevy":{"batch_keys":0,"entities":589,"extents":[],"frame":10,"frame_ms":32.74,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.068,"step_ms":null,"cost_ms":1.068},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}+{"example":"ui/layout/grid","frame":10,"ssim":0.995059,"tile":14,"bevy":{"batch_keys":0,"entities":482,"extents":[],"frame":10,"frame_ms":34.457,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.496,"step_ms":null,"cost_ms":1.496},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}diff --git a/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx b/sdk/raea/bench/bevy-parity/ui/layout/grid.tsxnew file mode 100644index 00000000..d86fcf63--- /dev/null+++ b/sdk/raea/bench/bevy-parity/ui/layout/grid.tsx@@ -0,0 +1,48 @@+// Bevy v0.20.0 examples/ui/layout/grid.rs in raea's TSX: an 800 x 600 window holding a white grid (columns+// min-content and flex 1; rows auto, flex 1 and 20 px): a header across both columns with "Bevy CSS Grid Layout+// Example" in black FiraSans-Bold; a square 0.25 grey grid as tall as its row (24 px padding, 4 x 4 flex tracks, 12 px+// gaps) of sixteen black-framed CSS colours; a black sidebar (rows auto, auto, fr 1; items at the start, centred) with+// "Sidebar" and a 13 px paragraph; a white footer across both columns; and a hidden absolute modal. Bevy's Camera2d+// over the default clear colour is the layered <Canvas3D>.+import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea";+import { Canvas3D } from "raea/3d";+import { GridPlacement, GridTrack, Node, RepeatedGridTrack, Text, UiRect, percent, px } from "raea/ui";+import { Srgba } from "raea/color";++const FONT = staticFile("fonts/FiraSans-Bold.ttf");+const css = (r: number, g: number, b: number) => new Srgba(r / 255, g / 255, b / 255);+const [WHITE, BLACK] = [css(255, 255, 255), css(0, 0, 0)];+const ITEMS = [+ css(255, 165, 0), css(255, 228, 196), css(0, 0, 255), css(220, 20, 60), css(0, 255, 255), css(255, 69, 0), css(0, 100, 0), css(255, 0, 255),+ css(0, 128, 128), css(240, 248, 255), css(220, 20, 60), css(250, 235, 215), css(255, 255, 0), css(255, 20, 147), css(154, 205, 50), css(250, 128, 114),+];+const PARAGRAPH = Array(7).fill("A paragraph of text which ought to wrap nicely.").join(" ");++function Shot() {+ return (+ <AbsoluteFill>+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />+ <Node display="Grid" width={percent(100)} height={percent(100)} grid_template_columns={[GridTrack.min_content(), GridTrack.flex(1)]} grid_template_rows={[GridTrack.auto(), GridTrack.flex(1), GridTrack.px(20)]} background_color={WHITE}>+ <Node display="Grid" grid_column={GridPlacement.span(2)} padding={UiRect.all(px(6))}>+ <Text font={FONT} color={BLACK}>Bevy CSS Grid Layout Example</Text>+ </Node>+ <Node height={percent(100)} aspect_ratio={1} display="Grid" padding={UiRect.all(px(24))} grid_template_columns={[RepeatedGridTrack.flex(4, 1)]} grid_template_rows={[RepeatedGridTrack.flex(4, 1)]} row_gap={px(12)} column_gap={px(12)} background_color={new Srgba(0.25, 0.25, 0.25)}>+ {ITEMS.map((c, i) => (+ <Node key={i} display="Grid" padding={UiRect.all(px(3))} background_color={BLACK}>+ <Node background_color={c} />+ </Node>+ ))}+ </Node>+ <Node display="Grid" align_items="Start" justify_items="Center" padding={UiRect.all(px(10))} grid_template_rows={[GridTrack.auto(), GridTrack.auto(), GridTrack.fr(1)]} row_gap={px(10)} background_color={BLACK}>+ <Text font={FONT}>Sidebar</Text>+ <Text font={FONT} font_size={{ Px: 13 }}>{PARAGRAPH}</Text>+ <Node />+ </Node>+ <Node grid_column={GridPlacement.span(2)} background_color={WHITE} />+ <Node position_type="Absolute" margin={UiRect.new("auto", "auto", px(100), "auto")} width={percent(60)} height={px(300)} max_width={px(600)} visibility="Hidden" background_color={new Srgba(1, 1, 1, 0.8)} />+ </Node>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={800} height={600} />);diff --git a/sdk/raea/conformance/ui.test.tsx b/sdk/raea/conformance/ui.test.tsxindex 8ce53a8d..6b965eb4 100644--- a/sdk/raea/conformance/ui.test.tsx+++ b/sdk/raea/conformance/ui.test.tsx@@ -254,6 +254,12 @@ describe("A sliced ImageNode, a sampled picture and UiScale", () => {expect(top.match(/data-raea-blend=\"linear\"/g)?.length).toBe(2);expect(top).not.toContain("display:contents");});+ test("Visibility: Hidden is laid out but not drawn, Visible draws under a hidden parent, Inherited is the parent's", () => {+ expect(html(<Node visibility="Hidden" />)).toContain("visibility:hidden");+ expect(html(<Node visibility="Visible" />)).toContain("visibility:visible");+ expect(html(<Node visibility="Inherited" />)).not.toContain("visibility");+ expect(() => html(<Node visibility={"Gone" as never} />)).toThrow(/visibility/);+ });test("Viewport is the region of the window the UI's roots lay out in, clipped to it", () => {const out = html(<Viewport physical_position={[200, 100]} physical_size={[600, 500]}><Node /></Viewport>);expect(out).toContain("position:absolute;left:200px;top:100px;width:600px;height:500px;overflow:hidden");diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsxindex 0d5b2430..27994354 100644--- a/sdk/render/src/bevy3d/ui.tsx+++ b/sdk/render/src/bevy3d/ui.tsx@@ -60,6 +60,9 @@ export interface NodeProps {z_index?: number;/** GlobalZIndex: ranked among the roots and every other GlobalZIndex instead (a non-zero one) */global_z_index?: number;+ /** Visibility: Inherited (its parent's, the default), Hidden (laid out, not drawn) or Visible (drawn under a hidden+ * parent), as CSS's visibility inherits */+ visibility?: "Inherited" | "Hidden" | "Visible";/** FixedNode: laid out as a root wherever it is in the tree (its own viewport, the window's), drawn with its parent */fixed?: boolean;children?: ReactNode;@@ -106,6 +109,7 @@ export function nodeCss(who: string, p: NodeProps, back?: Backdrop): { css: CSSPif (p.flex_shrink !== undefined) s.flexShrink = p.flex_shrink;if (p.aspect_ratio !== undefined) s.aspectRatio = p.aspect_ratio;gridCss(who, p, s);+ if (p.visibility !== undefined && p.visibility !== "Inherited") s.visibility = keyword(who, "visibility", p.visibility, ["Hidden", "Visible"]);// every node a stacking context, so a ZIndex ranks it among its siblings above their parent, as bevy_ui stacks// them; a GlobalZIndex ranks it in the root's (raea's Blitz hoists it past every other, layout/paint_tree.rs)s.zIndex = p.global_z_index ?? p.z_index ?? 0;diff --git a/vendor/blitz-dom/src/layout/inline.rs b/vendor/blitz-dom/src/layout/inline.rsindex 5f72e8dd..d914b316 100644--- a/vendor/blitz-dom/src/layout/inline.rs+++ b/vendor/blitz-dom/src/layout/inline.rs@@ -921,9 +921,10 @@ impl LayoutPassState<'_> {}// raea: a bevy_text box sized by its content (no width of its own), its lines broken in the space it was- // given: as wide as its widest line, as bevy_text measures it (TextPipeline's laid-out size), not that space+ // given: as wide as its widest line with its trailing spaces (parley's full_width), as bevy_text measures it+ // (TextPipeline::compute_size), not that spacelet width = if unit == 1.0 && known_dimensions.width.is_none() && node_size.width.is_none() && inline_layout.layout.len() > 1 {- let w = inline_layout.layout.width().ceil().min(width);+ let w = inline_layout.layout.full_width().ceil().min(width);inline_layout.layout.set_lines_max_advance(w);w} else {