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/scroll_and_overflow/scroll passes (SSIM 0.9972): a Scroll axis draws no scrollbar (bevy_ui draws none; Blitz's overlay thumb would show once scrolled), Node's scrollbar_width is the gutter taffy keeps beside a scrolling axis (right of a y scroller, below an x one, past the padding), and IgnoreScroll is taken (a page isn't scrolled yet, so it keeps nodes where they are). The parity host has accesskit, a Bevy dev-dependency the example imports. Most of the example lies past the window (the root is as wide as its content, the viewport grid's auto track, in Bevy as here); a 40% list fails
shinyobjectz3675c7a9f9a5
diff --git a/Cargo.lock b/Cargo.lockindex ff4ed747..5d6edce8 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -13771,6 +13771,7 @@ dependencies = [name = "raea-bevy-parity"version = "0.1.0"dependencies = [+ "accesskit 0.24.1","argh","bevy","chacha20 0.10.2",diff --git a/bench/bevy-parity/Cargo.toml b/bench/bevy-parity/Cargo.tomlindex f3808512..770e2540 100644--- a/bench/bevy-parity/Cargo.toml+++ b/bench/bevy-parity/Cargo.toml@@ -14,12 +14,13 @@ bevy = { version = "=0.20.0", default-features = false, features = ["std", "defaraea-sys-parity = { path = "../../systems/parity" }# Bevy's examples' own dependencies (bevy v0.20.0's dev-dependencies)argh = "0.1.12"+accesskit = "0.24"rand = "0.10.0"chacha20 = { version = "0.10.0", default-features = false, features = ["rng"] }# used by the ported examples, which build.rs copies in through include! where cargo-shear doesn't look[package.metadata.cargo-shear]-ignored = ["argh", "rand", "chacha20"]+ignored = ["argh", "accesskit", "rand", "chacha20"]# Bevy's examples ask cfg(feature = "default_font") of the crate they're built in: in Bevy's repo that's bevy's own# feature, on by default; here the host's, so it has one, on (ui/text/text builds only its default-font branch)diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.listindex 1252717c..5698be50 100644--- a/bench/bevy-parity/examples.list+++ b/bench/bevy-parity/examples.list@@ -83,3 +83,4 @@ ui/scroll_and_overflow/overflow_transformui/text/textui/text/text_debugui/ui_transform+ui/scroll_and_overflow/scrolldiff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsvindex 7984d09e..8424df12 100644--- a/bench/bevy-parity/runs.tsv+++ b/bench/bevy-parity/runs.tsv@@ -82,3 +82,4 @@ ui/scroll_and_overflow/overflow_transform - 10ui/text/text - 10ui/text/text_debug - 10ui/ui_transform - 10+ui/scroll_and_overflow/scroll - 10diff --git a/docs/bevy-parity.md b/docs/bevy-parity.mdindex c16031c4..16440269 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 **83**, passing **79**, excluded **16** (docs/bevy-parity/excluded.tsv), left **343**.+Examples: **438**, ported **84**, passing **80**, excluded **16** (docs/bevy-parity/excluded.tsv), left **342**.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.@@ -139,6 +139,7 @@ doesn't pay.| ui/text/text | 10 | 0.990913 | 8 | 0 / 0 | 459 / 492 | 5 / 7 | 1 / 1 | 34.947 / 1.446 = 1.446 + 0 | yes | || ui/text/text_debug | 10 | 0.984022 | 18 | 0 / 0 | 458 / 492 | 5 / 7 | 1 / 1 | 35.188 / 1.093 = 1.093 + 0 | yes | || ui/ui_transform | 10 | 0.999095 | 6 | 0 / 0 | 463 / 492 | 5 / 7 | 1 / 1 | 36.534 / 1.372 = 1.372 + 0 | yes | |+| ui/scroll_and_overflow/scroll | 10 | 0.997196 | 14 | 0 / 0 | 1988 / 492 | 5 / 7 | 1 / 1 | 35.528 / 1.129 = 1.129 + 0 | yes | |## Excludeddiff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonlindex 682ae4f0..18bdc3a6 100644--- a/docs/bevy-parity/results.jsonl+++ b/docs/bevy-parity/results.jsonl@@ -126,3 +126,4 @@{"example":"ui/text/text","frame":10,"ssim":0.990913,"tile":8,"bevy":{"batch_keys":0,"entities":459,"extents":[],"frame":10,"frame_ms":34.947,"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.446,"step_ms":null,"cost_ms":1.446},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/text/text_debug","frame":10,"ssim":0.984022,"tile":18,"bevy":{"batch_keys":0,"entities":458,"extents":[],"frame":10,"frame_ms":35.188,"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.093,"step_ms":null,"cost_ms":1.093},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}{"example":"ui/ui_transform","frame":10,"ssim":0.999095,"tile":6,"bevy":{"batch_keys":0,"entities":463,"extents":[],"frame":10,"frame_ms":36.534,"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.372,"step_ms":null,"cost_ms":1.372},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}+{"example":"ui/scroll_and_overflow/scroll","frame":10,"ssim":0.997196,"tile":14,"bevy":{"batch_keys":0,"entities":1988,"extents":[],"frame":10,"frame_ms":35.528,"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.129,"step_ms":null,"cost_ms":1.129},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}diff --git a/sdk/raea/bench/bevy-parity/ui/scroll_and_overflow/scroll.tsx b/sdk/raea/bench/bevy-parity/ui/scroll_and_overflow/scroll.tsxnew file mode 100644index 00000000..5bab0e58--- /dev/null+++ b/sdk/raea/bench/bevy-parity/ui/scroll_and_overflow/scroll.tsx@@ -0,0 +1,82 @@+// Bevy v0.20.0 examples/ui/scroll_and_overflow/scroll.rs in raea's TSX: a column spread down the window; at the top a+// heading and a horizontally scrolling 0.1 grey list 80% wide (10 px margin) of a hundred "Item i" texts at least+// 200 px wide; below, a row spread across of four 200 px columns, each a heading over a list half the window high:+// one scrolling on y with a 20 px scrollbar gutter (25 rows 21 px high), one scrolling both ways (25 rows of ten),+// a 30-column grid of "|y,x|" cells (black; the first row and column blue headers kept in place by IgnoreScroll, the+// corner red) and five nested lists, each scrolling on y, 40% to 200% of their parent's height. Nothing scrolls until+// the mouse wheel turns. All in FiraSans-Bold. Bevy's Camera2d over the default clear colour is the layered+// <Canvas3D>. In Bevy's default 1280 x 720 window.+import type { ReactNode } from "react";+import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea";+import { Canvas3D } from "raea/3d";+import { Node, Overflow, RepeatedGridTrack, Text, UiRect, percent, px } from "raea/ui";+import { Srgba } from "raea/color";++const FONT = staticFile("fonts/FiraSans-Bold.ttf");+const LINE_HEIGHT = 21;+const GREY = new Srgba(0.1, 0.1, 0.1);+const range = (n: number) => Array.from({ length: n }, (_, i) => i);++function Column({ title, children }: { title: string; children: ReactNode }) {+ return (+ <Node flex_direction="Column" justify_content="Center" align_items="Center" width={px(200)}>+ <Text font={FONT} font_size={{ Px: 20 }}>{title}</Text>+ {children}+ </Node>+ );+}++function Shot() {+ return (+ <AbsoluteFill>+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />+ <Node width={percent(100)} height={percent(100)} justify_content="SpaceBetween" flex_direction="Column">+ <Node width={percent(100)} flex_direction="Column">+ <Text font={FONT} font_size={{ Px: 20 }}>Horizontally Scrolling list (Ctrl + MouseWheel)</Text>+ <Node width={percent(80)} margin={UiRect.all(px(10))} flex_direction="Row" overflow={Overflow.scroll_x()} background_color={GREY}>+ {range(100).map((i) => <Text key={i} font={FONT} min_width={px(200)} align_content="Center">{`Item ${i}`}</Text>)}+ </Node>+ </Node>+ <Node width={percent(100)} height={percent(100)} flex_direction="Row" justify_content="SpaceBetween">+ <Column title="Vertically Scrolling List">+ <Node flex_direction="Column" align_self="Stretch" height={percent(50)} overflow={Overflow.scroll_y()} scrollbar_width={20} background_color={GREY}>+ {range(25).map((i) => (+ <Node key={i} min_height={px(LINE_HEIGHT)} max_height={px(LINE_HEIGHT)}>+ <Text font={FONT}>{`Item ${i}`}</Text>+ </Node>+ ))}+ </Node>+ </Column>+ <Column title="Bidirectionally Scrolling List">+ <Node flex_direction="Column" align_self="Stretch" height={percent(50)} overflow={Overflow.scroll()} background_color={GREY}>+ {range(25).map((oi) => (+ <Node key={oi} flex_direction="Row">+ {range(10).map((i) => <Text key={i} font={FONT}>{`Item ${oi * 10 + i}`}</Text>)}+ </Node>+ ))}+ </Node>+ </Column>+ <Column title="Bidirectionally Scrolling List With Sticky Nodes">+ <Node display="Grid" align_self="Stretch" height={percent(50)} overflow={Overflow.scroll()} grid_template_columns={[RepeatedGridTrack.auto(30)]}>+ {range(30).flatMap((y) => range(30).map((x) => {+ const [z, bg] = x === 0 && y === 0 ? [2, new Srgba(1, 0, 0)] : x === 0 || y === 0 ? [1, new Srgba(0, 0, 1)] : [0, new Srgba(0, 0, 0)];+ return <Text key={`${y},${x}`} font={FONT} linebreak="NoWrap" ignore_scroll={{ x: x === 0, y: y === 0 }} z_index={z} background_color={bg}>{`|${y},${x}|`}</Text>;+ }))}+ </Node>+ </Column>+ <Column title="Nested Scrolling Lists">+ <Node column_gap={px(20)} flex_direction="Row" align_self="Stretch" height={percent(50)} overflow={Overflow.scroll()} background_color={GREY}>+ {range(5).map((oi) => (+ <Node key={oi} flex_direction="Column" align_self="Stretch" height={percent((200 / 5) * (oi + 1))} overflow={Overflow.scroll_y()} background_color={new Srgba(0.05, 0.05, 0.05)}>+ {range(20).map((i) => <Text key={i} font={FONT}>{`Item ${oi * 20 + i}`}</Text>)}+ </Node>+ ))}+ </Node>+ </Column>+ </Node>+ </Node>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);diff --git a/sdk/raea/conformance/ui-transform.test.tsx b/sdk/raea/conformance/ui-transform.test.tsxindex 3c28a1bd..a17a0925 100644--- a/sdk/raea/conformance/ui-transform.test.tsx+++ b/sdk/raea/conformance/ui-transform.test.tsx@@ -1,7 +1,7 @@// docs/control.feature FC0a: bevy_ui's UiTransform and BoxShadow on the page (ui/scroll_and_overflow/overflow_transform),// and bevy_color's Luminance darker and lighter.import { describe, expect, test } from "bun:test";-import { BoxShadow, Node, Rot2, UiTransform, Val2, percent, px } from "raea/ui";+import { BoxShadow, Node, Overflow, Rot2, UiRect, UiTransform, Val2, percent, px } from "raea/ui";import { LinearRgba, Srgba } from "raea/color";import { renderFrame } from "../src/test";@@ -62,3 +62,21 @@ describe("Luminance: darker and lighter mix toward black or white in linear lighexpect([w.red, w.green, w.blue]).toEqual([1, 1, 1]);});});++describe("Scrolling: no scrollbar drawn, scrollbar_width a gutter beside a Scroll axis, IgnoreScroll", () => {+ test("a Scroll axis draws no scrollbar (bevy_ui draws none); Clip and Hidden leave it alone", () => {+ expect(html(<Node overflow={Overflow.scroll_y()} />)).toContain("scrollbar-width:none");+ expect(html(<Node overflow={Overflow.clip()} />)).not.toContain("scrollbar-width");+ });+ test("scrollbar_width is kept on the right of a y scroller and below an x scroller, past its padding", () => {+ expect(html(<Node overflow={Overflow.scroll_y()} scrollbar_width={20} />)).toContain("padding-right:20px");+ expect(html(<Node overflow={Overflow.scroll_x()} scrollbar_width={20} padding={UiRect.all(px(5))} />)).toMatch(/padding:5px 5px 5px 5px;[^"]*padding-bottom:25px/);+ expect(html(<Node overflow={Overflow.scroll()} scrollbar_width={8} padding={UiRect.all(percent(10))} />)).toMatch(/padding-right:calc\(10% \+ 8px\);padding-bottom:calc\(10% \+ 8px\)/);+ expect(html(<Node overflow={Overflow.clip_y()} scrollbar_width={20} />)).not.toContain("padding-right");+ expect(() => html(<Node overflow={Overflow.scroll()} scrollbar_width={-1} />)).toThrow(/scrollbar_width/);+ });+ test("IgnoreScroll is { x, y } booleans", () => {+ expect(() => html(<Node ignore_scroll={{ x: true, y: true }} />)).not.toThrow();+ expect(() => html(<Node ignore_scroll={{ x: 1 } as never} />)).toThrow(/ignore_scroll/);+ });+});diff --git a/sdk/raea/src/ui.ts b/sdk/raea/src/ui.tsindex a3d28304..f32b4d64 100644--- a/sdk/raea/src/ui.ts+++ b/sdk/raea/src/ui.ts@@ -11,3 +11,4 @@ export { LinearGradient, RadialGradient, ConicGradient, ColorStop, AngularColorSexport { GridTrack, RepeatedGridTrack, GridPlacement, type GridTrackRepetition, type GridAutoFlow, type MinTrackSizingFunction, type MaxTrackSizingFunction, FontSource, type GenericFontFamily } from "@raea/render/bevy3d";export { Rot2, Val2, UiTransform, BoxShadow, type ShadowStyle } from "@raea/render/bevy3d";export { FontFeatureTag } from "@raea/render/bevy3d";+export type { IgnoreScroll } from "@raea/render/bevy3d";diff --git a/sdk/render/src/bevy3d.tsx b/sdk/render/src/bevy3d.tsxindex 44ed90ed..24aca727 100644--- a/sdk/render/src/bevy3d.tsx+++ b/sdk/render/src/bevy3d.tsx@@ -35,4 +35,5 @@ export { LinearGradient, RadialGradient, ConicGradient, ColorStop, AngularColorSexport { GridTrack, RepeatedGridTrack, GridPlacement, type GridTrackRepetition, type GridAutoFlow, type MinTrackSizingFunction, type MaxTrackSizingFunction } from "./bevy3d/ui-grid";export { Rot2, Val2, UiTransform, BoxShadow, type ShadowStyle } from "./bevy3d/ui-transform";export { FontFeatureTag } from "./bevy3d/ui-features";+export type { IgnoreScroll } from "./bevy3d/ui-scroll";export { FontSource, type GenericFontFamily } from "./bevy3d/ui-font";diff --git a/sdk/render/src/bevy3d/ui-scroll.ts b/sdk/render/src/bevy3d/ui-scroll.tsnew file mode 100644index 00000000..dd16227c--- /dev/null+++ b/sdk/render/src/bevy3d/ui-scroll.ts@@ -0,0 +1,25 @@+// bevy_ui's scrolling as the page's CSS: a Scroll axis draws no scrollbar (bevy_ui draws none; Blitz would draw an+// overlay thumb), Node's scrollbar_width is the gutter taffy reserves beside it, and IgnoreScroll.+import { checkVal, type Overflow, type UiRect, type Val } from "./ui-val";++/** bevy_ui's IgnoreScroll: the axes on which a node keeps its place while its parent scrolls (BVec2).+ * @bevy bevy_ui::IgnoreScroll */+export interface IgnoreScroll { x: boolean; y: boolean }++const grow = (v: Val, w: number) => (v.endsWith("px") ? `${parseFloat(v) + w}px` : `calc(${v} + ${w}px)`);++/** A Node's scroll fields into its CSS, after its padding. taffy reserves scrollbar_width as an inset beside a+ * scrolling axis (on the right of one scrolling on y, below one scrolling on x), inside the border as padding is. A+ * page here is never scrolled (no ScrollPosition yet), so IgnoreScroll keeps every node where it already is. */+export function scrollCss(who: string, p: { overflow?: Overflow; padding?: UiRect; scrollbar_width?: number; ignore_scroll?: IgnoreScroll }, s: Record<string, unknown>) {+ const o = p.overflow;+ if (o && (o.x === "Scroll" || o.y === "Scroll")) s.scrollbarWidth = "none";+ if (p.ignore_scroll !== undefined && (typeof p.ignore_scroll?.x !== "boolean" || typeof p.ignore_scroll?.y !== "boolean")) throw new TypeError(`${who}: ignore_scroll is { x: boolean, y: boolean }, got ${JSON.stringify(p.ignore_scroll)}`);+ const w = p.scrollbar_width;+ if (w === undefined) return;+ if (!(Number.isFinite(w) && w >= 0)) throw new RangeError(`${who}: scrollbar_width is a number of px at least 0, got ${w}`);+ if (w === 0) return;+ const pad = (k: "right" | "bottom") => (p.padding ? checkVal(who, `padding.${k}`, p.padding[k]) : "0px");+ if (o?.y === "Scroll") s.paddingRight = grow(pad("right"), w);+ if (o?.x === "Scroll") s.paddingBottom = grow(pad("bottom"), w);+}diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsxindex 2cbb834d..6981b2a5 100644--- a/sdk/render/src/bevy3d/ui.tsx+++ b/sdk/render/src/bevy3d/ui.tsx@@ -14,6 +14,7 @@ import { gradientsCss, gradientsOpaque, type Gradient } from "./ui-gradient";import { gridCss, type GridAutoFlow, type GridPlacement, type GridTrack, type RepeatedGridTrack } from "./ui-grid";import { shadowCss, transformCss, type BoxShadow, type UiTransform } from "./ui-transform";import { featuresCss } from "./ui-features";+import { scrollCss, type IgnoreScroll } from "./ui-scroll";import type { TransformValue } from "./core";import { eulerOf } from "../3d/model";import { useVideoConfig } from "@raea/app/clock";@@ -43,6 +44,10 @@ export interface NodeProps {overflow?: Overflow;/** the box its overflow clip clips to, grown by a margin (OverflowClipMargin.border_box().with_margin(25)) */overflow_clip_margin?: OverflowClipMargin;+ /** the gutter taffy keeps beside a Scroll axis for its scrollbar, in px (0 by default) */+ scrollbar_width?: number;+ /** IgnoreScroll: the axes it keeps its place on while its parent scrolls */+ ignore_scroll?: IgnoreScroll;row_gap?: Val; column_gap?: Val;/** the grid's tracks (display Grid): RepeatedGridTracks (RepeatedGridTrack.fr(3, 1)) or GridTracks */grid_template_rows?: (RepeatedGridTrack | GridTrack)[]; grid_template_columns?: (RepeatedGridTrack | GridTrack)[];@@ -168,6 +173,7 @@ export function nodeCss(who: string, p: NodeProps, back?: Backdrop): { css: CSSPs.overflowX = o.x.toLowerCase();s.overflowY = o.y.toLowerCase();}+ scrollCss(who, p, s);const m = p.overflow_clip_margin;if (m !== undefined) {if (!["BorderBox", "PaddingBox", "ContentBox"].includes(m?.visual_box) || !(Number.isFinite(m.margin) && m.margin >= 0)) throw new TypeError(`${who}: overflow_clip_margin is OverflowClipMargin.border_box(), padding_box() or content_box(), with_margin(px >= 0), got ${JSON.stringify(m)}`);