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
SG0: the stage repros are a standing check: a 3D sequence's frames must match the same frames rendered alone
shinyobjectzc3dd6b7d52c5
diff --git a/docs/stage-guards.feature b/docs/stage-guards.featureindex 87f84db5..efded9d2 100644--- a/docs/stage-guards.feature+++ b/docs/stage-guards.feature@@ -61,14 +61,21 @@ Feature: Stage guards: a 3D render an agent can't breakRule: SG0. The bar first, before any fix+ @doneScenario: SG0. The repros become tests, and they fail todayGiven the plan| crate | file | lines | job |- | raea-render (test) | engine/render/tests/frame_pure_3d.rs | 160 | each repro rendered as one sequence and frame by frame alone; frame N of both compared (SSIM, per part); fails while any part differs |- | raea-render (test) | engine/render/tests/diag/*.tsx | 160 | kept-props, kept-props2, kept-props3, glyph-atlas-probe moved in from the project, with what each shows |+ | (script) | tools/frame-pure-3d.sh | 50 | each repro rendered as one sequence (PNGs, one process) and four frames alone (--frame N); frame N of both compared, SSIM 0.999 or more, lossless; fails naming the repro and frame |+ | raea-render (test) | engine/render/tests/diag/*.tsx | 110 | kept-props, kept-props2 (its brand-logo picture row left out), kept-props3 moved in from the project, with what each shows |+ | (L1) | tools/agents/check | +4 | the "3d frame purity" step, when core/scene, runtime/scene(3d), runtime/live, engine/render's engine, systems/text3d or sdk/render/src/3d changes |Then the test fails on main today on radius, half_size, Text3D letters, RichText words, colour and size, the rowtaken over, and the atlas's cut glyph, and passes on transform scale, material colour, pictures and the revealAnd every scenario below that the engine fixes turns one of its failures green+ # Status 11-21: built and green on main after SG1 and SG2 (f4b524f896): every sampled frame of the three repros+ # matches at SSIM 0.9998 or more. The bar is tight enough: a sequence's frame 28 against frame 29 alone scores+ # 0.986, so a part held since its first frame can't pass. Before SG1 the same repros showed frame 0's sphere,+ # box, words, colour and size in a sequence. The atlas's cut glyph is one frame, not a sequence: its repro and+ # test come with SG3.Rule: The engine stops doing itdiff --git a/engine/render/tests/diag/kept-props.tsx b/engine/render/tests/diag/kept-props.tsxnew file mode 100644index 00000000..2143da4e--- /dev/null+++ b/engine/render/tests/diag/kept-props.tsx@@ -0,0 +1,34 @@+// Diagnosis: does a 3D thing's shape follow its props from frame to frame in one render process? Five things grow over+// 30 frames. A: Sphere radius. B: Cuboid half_size. C: the same box grown by its transform's scale (control). D: a+// RichText whose words are the frame number. E: a Sphere whose React key changes every frame (remounted). Rendered as+// one sequence and as separate stills, the two should match frame for frame.+import React from "react";+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { Canvas3D, Entity, RichText } from "raea/3d";+import { Cuboid, Mesh3d, Sphere } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Srgba } from "raea/color";+import { Camera3d } from "raea/camera";+import { Transform } from "raea/transform";+import { AmbientLight } from "raea/light";++const M = ({ c }: { c: string }) => <StandardMaterial base_color={Srgba.hex(c)} unlit />;++function Kept() {+ const f = useCurrentFrame(), t = f / 29;+ return (+ <AbsoluteFill style={{ background: "#F1E9D8" }}>+ <Canvas3D>+ <Camera3d transform={Transform.fromXyz(0, 0, 6).lookingAt([0, 0, 0])} />+ <AmbientLight brightness={1000} />+ <Mesh3d name="a" transform={Transform.fromXyz(-2.4, 0, 0)}><Sphere radius={0.1 + 0.5 * t} /><M c="#E8402E" /></Mesh3d>+ <Mesh3d name="b" transform={Transform.fromXyz(-1.2, 0, 0)}><Cuboid half_size={[0.15, 0.1 + 0.5 * t, 0.15]} /><M c="#2F4BE0" /></Mesh3d>+ <Mesh3d name="c" transform={Transform.fromXyz(0, 0, 0).withScale([1, 0.2 + t, 1])}><Cuboid half_size={[0.15, 0.5, 0.15]} /><M c="#1A1A1A" /></Mesh3d>+ <Entity transform={Transform.fromXyz(1.2, 0, 0)}><RichText name="d" size={0.5} font="Space Mono" weight={700} color="#1A1A1A" unlit>{String(f)}</RichText></Entity>+ <Mesh3d key={f} name={`e${f}`} transform={Transform.fromXyz(2.4, 0, 0)}><Sphere radius={0.1 + 0.5 * t} /><M c="#F2B92B" /></Mesh3d>+ </Canvas3D>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="kept" component={Kept} width={640} height={360} fps={30} durationInFrames={30} />);diff --git a/engine/render/tests/diag/kept-props2.tsx b/engine/render/tests/diag/kept-props2.tsxnew file mode 100644index 00000000..d7f6a416--- /dev/null+++ b/engine/render/tests/diag/kept-props2.tsx@@ -0,0 +1,35 @@+// Diagnosis, part 2 (docs/stage-guards.feature SG0): which other 3D props follow the frame in one render process. Top+// row, left to right: RichText revealed by its own enter animation from frame 5; RichText whose colour changes at frame+// 15; RichText whose size grows; a box whose material colour changes at frame 15. Bottom row: a Text3D whose letters+// count the frame; RichText first mounted at frame 10, revealed from there. Before SG1, the colour, the size and the+// letters held their first frame's values in a sequence render (a picture's change, the material and the reveals+// followed the frame).+import React from "react";+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { Canvas3D, Entity, RichText, Text3D } from "raea/3d";+import { Cuboid, Mesh3d } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Srgba } from "raea/color";+import { Camera3d } from "raea/camera";+import { Transform } from "raea/transform";+import { AmbientLight } from "raea/light";++function Kept2() {+ const f = useCurrentFrame(), late = f >= 15;+ return (+ <AbsoluteFill style={{ background: "#F1E9D8" }}>+ <Canvas3D>+ <Camera3d transform={Transform.fromXyz(0, 0, 7).lookingAt([0, 0, 0])} />+ <AmbientLight brightness={1000} />+ <Entity transform={Transform.fromXyz(-2.7, 1, 0)}><RichText name="reveal" size={0.35} font="Space Mono" weight={700} color="#1A1A1A" unlit enter="rise" each={2} at={5}>REVEAL</RichText></Entity>+ <Entity transform={Transform.fromXyz(-0.9, 1, 0)}><RichText name="colour" size={0.35} font="Space Mono" weight={700} color={late ? "#2F4BE0" : "#E8402E"} unlit>INK</RichText></Entity>+ <Entity transform={Transform.fromXyz(0.9, 1, 0)}><RichText name="size" size={0.15 + 0.02 * f} font="Space Mono" weight={700} color="#1A1A1A" unlit>BIG</RichText></Entity>+ <Mesh3d name="mat" transform={Transform.fromXyz(2.7, 1, 0)}><Cuboid half_size={[0.4, 0.4, 0.1]} /><StandardMaterial base_color={Srgba.hex(late ? "#2F4BE0" : "#E8402E")} unlit /></Mesh3d>+ <Mesh3d name="t3d" transform={Transform.fromXyz(0, -1.2, 0)}><Text3D size={0.6} depth={0.1}>{String(f)}</Text3D><StandardMaterial base_color={Srgba.hex("#1A1A1A")} unlit /></Mesh3d>+ {f >= 10 && <Entity transform={Transform.fromXyz(2.4, -1, 0)}><RichText name="late" size={0.35} font="Space Mono" weight={700} color="#1A1A1A" unlit enter="rise" each={2} at={10}>LATE</RichText></Entity>}+ </Canvas3D>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="kept2" component={Kept2} width={640} height={360} fps={30} durationInFrames={30} />);diff --git a/engine/render/tests/diag/kept-props3.tsx b/engine/render/tests/diag/kept-props3.tsxnew file mode 100644index 00000000..bee6c195--- /dev/null+++ b/engine/render/tests/diag/kept-props3.tsx@@ -0,0 +1,34 @@+// Diagnosis, part 3: when one 3D thing unmounts and another mounts in its place in the tree (no names), does the new one+// draw as itself? Frames 0-9: "FOUR OPENINGS" top left and a small red ball bottom left. From frame 10: "FROM ITS STORE+// PAGE" top right and a big blue ball bottom right. Middle: a quote with maxWidth (the store card's missing quote).+import React from "react";+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { Canvas3D, Entity, RichText } from "raea/3d";+import { Mesh3d, Sphere } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Srgba } from "raea/color";+import { Camera3d } from "raea/camera";+import { Transform } from "raea/transform";+import { AmbientLight } from "raea/light";++function Kept3() {+ const f = useCurrentFrame();+ return (+ <AbsoluteFill style={{ background: "#F1E9D8" }}>+ <Canvas3D>+ <Camera3d transform={Transform.fromXyz(0, 0, 7).lookingAt([0, 0, 0])} />+ <AmbientLight brightness={1000} />+ {f < 10 ? <>+ <Entity transform={Transform.fromXyz(-2, 1.4, 0)}><RichText size={0.35} font="League Gothic" weight={400} color="#1A1A1A" unlit>FOUR OPENINGS</RichText></Entity>+ <Mesh3d transform={Transform.fromXyz(-2, -1.4, 0)}><Sphere radius={0.15} /><StandardMaterial base_color={Srgba.hex("#E8402E")} unlit /></Mesh3d>+ </> : <>+ <Entity transform={Transform.fromXyz(2, 1.4, 0)}><RichText size={0.2} font="Space Mono" weight={700} color="#E8402E" unlit>FROM ITS STORE PAGE</RichText></Entity>+ <Mesh3d transform={Transform.fromXyz(2, -1.4, 0)}><Sphere radius={0.5} /><StandardMaterial base_color={Srgba.hex("#2F4BE0")} unlit /></Mesh3d>+ </>}+ <Entity transform={Transform.fromXyz(-1, 0.2, 0)}><RichText size={0.2} font="League Gothic" weight={400} color="#1A1A1A" align="left" maxWidth={1.9} unlit>“an Exclusive Solitaire Puzzle Game for Senior Citizens”</RichText></Entity>+ </Canvas3D>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="kept3" component={Kept3} width={640} height={360} fps={30} durationInFrames={20} />);diff --git a/tools/frame-pure-3d.sh b/tools/frame-pure-3d.shnew file mode 100755index 00000000..6ed35186--- /dev/null+++ b/tools/frame-pure-3d.sh@@ -0,0 +1,39 @@+#!/bin/bash+# Frame purity for 3D (docs/stage-guards.feature SG0): each repro in engine/render/tests/diag is rendered as one+# sequence (a folder of PNGs: frame after frame in one process, as an mp4's live 3D is made) and four of its frames+# rendered alone (--frame N, each in its own process: a still's route), and frame N of both must match (SSIM 0.999 or+# more, lossless). A part that held an earlier frame's shape, words, size or colour (SG1), or drew in another part's row+# (SG2), fails here with the repro and the frame named. L1 runs it when the code that makes 3D rows changes.+# tools/frame-pure-3d.sh [REPRO.tsx...] (RAEA_BIN: the raea to render with; default target/release/raea)+set -uo pipefail+ROOT=$(cd "$(dirname "$0")/.." && pwd)+R=${RAEA_BIN:-$ROOT/target/release/raea}+BAR=${FRAME_PURE_BAR:-0.999}+[ -x "$R" ] || { echo "frame-pure-3d: no raea at $R (cargo build --release -p raea-cli)" >&2; exit 2; }+command -v ffmpeg >/dev/null || { echo "frame-pure-3d: needs ffmpeg on PATH" >&2; exit 2; }+W=$(mktemp -d "${TMPDIR:-/tmp}/frame-pure-3d.XXXX")+trap 'rm -rf "$W"' EXIT+[ $# -gt 0 ] || set -- "$ROOT"/engine/render/tests/diag/*.tsx+fail=0+for t in "$@"; do+ n=$(basename "$t" .tsx)+ len=$(grep -oE 'durationInFrames=\{[0-9]+\}' "$t" | head -1 | grep -oE '[0-9]+')+ [ "${len:-1}" -gt 1 ] || continue+ if ! "$R" render "$t" -o "$W/$n/" >"$W/$n.log" 2>&1; then+ echo "frame-pure-3d: $n: the sequence didn't render:"; tail -5 "$W/$n.log"; fail=1; continue+ fi+ for f in 0 $((len / 3)) $((2 * len / 3)) $((len - 1)); do+ if ! "$R" render "$t" --frame "$f" -o "$W/$n-alone-$f.png" >"$W/$n-$f.log" 2>&1; then+ echo "frame-pure-3d: $n: frame $f alone didn't render:"; tail -3 "$W/$n-$f.log"; fail=1; continue+ fi+ seq=$(printf '%s/%s/frame-%05d.png' "$W" "$n" "$f")+ s=$(ffmpeg -v info -i "$seq" -i "$W/$n-alone-$f.png" -lavfi "[0:v]format=rgb24[a];[1:v]format=rgb24[b];[a][b]ssim" -f null - 2>&1 | grep -oE 'All:[0-9.]+' | cut -d: -f2)+ if [ -z "$s" ] || awk -v s="$s" -v b="$BAR" 'BEGIN { exit !(s < b) }'; then+ echo "frame-pure-3d: $n frame $f: the sequence's frame differs from the frame rendered alone (SSIM ${s:-none}, bar $BAR): a 3D part kept an earlier frame's inputs or took another's row"+ fail=1+ else+ echo "frame-pure-3d: $n frame $f: SSIM $s"+ fi+ done+done+exit $fail