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.
raea
A composition is a React component that is rendered once per frame. Every frame is worked out from the frame number alone, with nothing carried over between frames. The engine decodes the footage, paints the page, draws the 3D and mixes the sound, so your job is to say what each frame looks and sounds like.
Write it in the object's own files: edit.tsx, cuts.ts (raea cut writes it) and components/ (raea component add copies
parts in). AGENTS.md lists the whole API. These files say how to use it well.
Which file to read
Read the files a task needs with raea guide motion/NAME, one or two at a time, and drop them when you move on.
| You are... | Read |
|---|---|
| starting a file, sizing it, picking compositions | motion/compositions |
| deciding when things happen, cutting into scenes | motion/timing |
| planning how shots cut into each other: hooks on the thirds, the eye carried through each cut | motion/match-cuts |
| moving anything: entrances, exits, counters, push-ins | motion/animating |
| cutting takes, framing a face, trimming, clip sound | motion/footage |
| what each scene is heard as, effects and foley, gains, fades, the master | motion/sound (the music itself: motion/music) |
| where sounds come from: the local models and their setup, sample libraries, effect packs, MIDI | motion/sources |
| captions, or anything cued to what someone says | motion/words |
| putting parts over a face, platform zones, the proof | motion/placement |
| cards, stacks, type sizes, fonts | motion/layout |
| colours, faces and sizes from the brand | motion/brand (every piece needs it) |
| media files, logos, generated sound, imports | motion/assets |
| meshes, lights, cameras, modelled solids | motion/3d, then bevy (the 3D library: lights, materials, models, effects, 3D games) |
| input, rules, scores, sound on game events | motion/games |
| rendering stills or the video, and checking them | motion/rendering |
| the shapes, lengths and platforms it ships to, the files, posting deliverables | motion/delivery |
| an app's interface (its own window, not a composition): every state, built and checked by walking it | motion/interface |
The core rules
- Frames, not seconds.
useCurrentFrame()is the frame counted from the start of the nearestSequence, and time isframe / fps. Convert seconds once withMath.round(s * fps). Media trims (startFrom,endAt) are in source frames at the composition's fps. - Frame-pure. The renderer can ask for any frame in any order, so derive everything from the frame number.
useState,useEffectand timers don't animate a render.Math.random()is seeded for each frame: a render repeats, but every frame draws new numbers, so it suits grain or a flicker, and something that should hold still (a scatter, a layout) is seeded from an index:random("star" + i)from raea is the same number on every frame, run and machine.interpolateColors(frame, [0, 30], ["#f00", "#00f"])eases between colours asinterpolatedoes between numbers, and<OffthreadVideo>is<Video>under the name code moved from another React video tool uses.Date(Date.now(),new Date()) is the frame's time. A frame that needs one more step before it's taken (text measured in an effect, a fetch) holds it withdelayRender("what it waits for")and releases it withcontinueRender(handle)(raea/hold); a hold never released fails the render after 30 s, naming its label. Components written for a web page measure as they do in Chrome: a ref'sgetBoundingClientRect,offsetWidthandstyle,querySelector,document.createElement(a hidden copy to measure),document.createRange, an svg<text>'sgetComputedTextLength, a canvas'smeasureText,ResizeObserver,requestAnimationFrame,new Image()and an<img>'sonLoadanswer from the page that draws the frame (installed for you:raea/dom-reads,raea/dom-tree,raea/dom-style,raea/dom-document,raea/dom-range,raea/dom-svgtext,raea/canvas2d,raea/dom-observers,raea/frame-globalsandraea/dom-load). Load a web font withloadFont(raea/text) so it's measured in its own faces.MutationObserverandIntersectionObservernever call back. - Clamp every interpolate. The default extrapolation extends the line forever, so use
{extrapolateLeft: "clamp", extrapolateRight: "clamp"}unless you mean otherwise. Inputs must strictly increase. - Settle with
Easing.out(Easing.cubic). The plain curves (Easing.cubic,Easing.quad) ease in, andEasing.easeis an ease-in too. Don't reach for bounce or elastic by reflex. - Cue on words, not on guessed frames.
word("phrase")returns the frame where the phrase is said, anduseWords()gives the words that captions are built from.raea renderpasses the cut's words.json for you. - Place from perception. Put text over a person in a
<Region>, which keeps clear of the face and inside the platform's safe area.raea check --perception perception.jsonflags text over more than 8% of the face. - Theme from the brand.
<style>{css}</style>(from./styles.gen, whichraea renderwrites from brand/brand.css) loads the brand's variables and the project's Tailwind. Style with the brand classes (text-brand-accent,bg-brand-surface,font-brand,text-title,rounded-brandand the rest in AGENTS.md), orvar(--brand-*)where a class can't reach. Never write a hex palette of your own. A role the kit leaves empty is yours to decide from the brand's own colours (motion/brand). - Sound is part of the edit. Decide what each scene is heard as (silence, its own sound, source music, score,
effects) before placing any; music is composed for the cut, never a bed by default. Each sound goes in its own
<Sequence from layout="none">. UsegainDbfor levels, Tone.js for music (motion/music: sample-library or TokenSynth instruments in a Sampler, playing a motif, chords that move and a rhythm) andsao()for foley, and put one<Mix lufs={-14} />in the composition. Put the sounds in the tree in time order. - Keep animated styles present on every frame. The engine keeps a style property that React stops sending.
Write
transform: scale(1)andopacity: 1rather than leaving them out when an animation settles. Always setfontFamily, because the engine's default face is a serif. - Render it and look.
raea checkmeasures the export (motion/rendering);raea render edit.tsx --at 15,63,144 -o stills/renders the frames that matter (each cut, each entrance, the hook at 0.5 s, the end card) to look at. Look at the stills in one batch, fix everything they show, then look again.
The craft rules decide what the piece should be (the router and the floor). These files say how to write it. When a floor lint flags something you keep on purpose, write the reason in DIRECTION.md. Defects (a clipped word, unreadable text, the wrong loudness) and bans (invented claims, generated imagery, redrawn logos) always win.
A whole composition, small
import { AbsoluteFill, Composition, Easing, Mix, Sequence, Audio, interpolate, registerRoot, sao, staticFile, useCurrentFrame, useVideoConfig } from "raea";
import * as Tone from "raea/tone";
import { css } from "./styles.gen";
// the music: a chord on the title and a two-note lift after it, on a library piano (`raea sounds get
// salamander/piano`: roots a minor third apart, D#4 as Ds4.mp3); a sting, not a bed (motion/music)
const ROOTS = ["C4", "D#4", "F#4", "A4", "C5", "D#5"];
const piano = new Tone.Sampler({ urls: Object.fromEntries(ROOTS.map((n) => [n, staticFile(`sounds/salamander-piano/${n.replace("#", "s")}.mp3`)])), release: 1, volume: -10 }).connect(Tone.buses.music);
new Tone.Part((t, n) => piano.triggerAttackRelease(n.notes, n.dur, t, n.vel), [
{ time: "0:0", notes: ["C4", "E4", "G4", "C5"], dur: "2n", vel: 0.8 },
{ time: "0:2", notes: ["D5"], dur: "8n", vel: 0.55 },
{ time: "0:2:2", notes: ["E5"], dur: "4n", vel: 0.65 },
]).start(0);
Tone.getTransport().start();
const WHOOSH = sao("soft airy whoosh, short, clean, no music", { seconds: 0.8 });
const OUT = Easing.out(Easing.cubic);
const clamp = { extrapolateLeft: "clamp", extrapolateRight: "clamp" } as const;
function Title({ text }: { text: string }) {
const f = useCurrentFrame();
const y = interpolate(f, [0, 8], [40, 0], { ...clamp, easing: OUT });
const opacity = interpolate(f, [0, 6], [0, 1], clamp);
return (
<div style={{
position: "absolute", left: 90, right: 90, top: 760, textAlign: "center",
lineHeight: 1, fontWeight: 800, transform: `translateY(${y}px)`, opacity,
}} className="font-brand text-display text-brand-on-surface">{text}</div>
);
}
export default function Piece() {
const { fps } = useVideoConfig();
return (
<AbsoluteFill className="bg-brand-bg">
<style>{css}</style>
<Sequence from={0} durationInFrames={2 * fps} name="title"><Title text="Ship it" /></Sequence>
<Sequence from={0} name="whoosh" layout="none">
<Audio src={WHOOSH} gainDb={-18} />
</Sequence>
<Mix lufs={-14} ceiling={-1.5} />
</AbsoluteFill>
);
}
registerRoot(() => <Composition id="piece" component={Piece} width={1080} height={1920} fps={30} durationInFrames={90} />);