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
PF4: a draft drawn at a fraction of its size, laid out at its own. <Composition edit={{ scale }}> registers the smaller size and draws the composition in a box laid out at its width and height (useVideoConfig still says them), scaled down, so a 3D view, whole-frame or in a page element's box, traces fewer pixels and a 2D layout in px keeps every place. The same 61-frame ray-traced 1080p shot warm: 2.75 s at full size, 1.6 to 1.7 s at 0.5. The app's drafts and a scene's kept frames write it in their throwaway source; what ships is never scaled. Registry tests: the smaller size, the declared size inside, scale 1 unchanged, out of range refused
shinyobjectzeed69c7bb2f7
diff --git a/docs/lightspeed.feature b/docs/lightspeed.featureindex acb698e8..a96b9bb1 100644--- a/docs/lightspeed.feature+++ b/docs/lightspeed.feature@@ -88,9 +88,20 @@ Feature: Lightspeed: raea as fast as anything could be, with the best quality, mway to draw a composition smaller than it says it is (--w and --h only fill in a size a composition leavesout: the same 61-frame ray-traced shot with --w 960 --h 540 came out 1920 by 1080 in 4.1 s, against 4.7 s),so a draft (the composition editor's, a 3D scene's kept frames in docs/timeline.feature TL10f) pays for- every pixel of the final. A render scale for drafts only (half the pixels each way, as the live stage's- quality steps already draw a scene) is the next lever, and is engine work not yet started. A render asked- for again with nothing changed is the export cache's: 0.3 s+ every pixel of the final. A render asked for again with nothing changed is the export cache's: 0.3 s+ And done 11-13 for drafts, in the SDK and not the engine: `<Composition edit={{ scale }}>` lays the composition+ out at its own size (useVideoConfig still says it) in a box drawn at that fraction, and registers the smaller+ size, so a 3D view, a whole-frame camera's or one in a page element's box, traces fewer pixels and a 2D layout+ written in px keeps every place (a title, a caption bar, a badge and a boxed 3D view drawn at 0.5 match the+ full-size frame but for softer type). The same 61-frame ray-traced 1080p shot, warm, three passes each: 2.75 s+ at full size, 1.6 to 1.7 s at 0.5 (1.7 times end to end, about twice on the frames once the start is taken+ out); the shot frames the same. The app's composition drafts and a scene's kept frames write it in their+ throwaway source (raea-feed host/edit.ts withDraftScale: the long side at 960 px, never larger, never under a+ quarter; RAEA_DRAFT_SCALE=1 draws them at full size). What ships is never scaled+ And open: the full-size render itself. Two to three times there is the cheaper trace upscaled (Solari at a+ lower main-pass resolution, Bevy's MainPassResolutionOverride, with MetalFX's denoised scaler taking it to+ full size: its input is the output's size today and it runs before the forward meshes), a rendering decision+ with its own picture checksScenario: PF5. What agents lose time onThen fixed in the lane check (tools/agents/check, on this Mac): the CLI surface step tests the raea it rebuildsdiff --git a/docs/manual/reference/sdk/app.md b/docs/manual/reference/sdk/app.mdindex 47857c95..80f06d09 100644--- a/docs/manual/reference/sdk/app.md+++ b/docs/manual/reference/sdk/app.md@@ -247,6 +247,7 @@ a split, a cut word or a moved span is a change to this list; the length becomes| Field | Type | What it is || --- | --- | --- || `segments` | `readonly (readonly [number, number])[]` | the composition's own frame ranges, [from, to), played one after another |+| `scale` | `number` | the composition drawn at this fraction of its size (above 0, at most 1), what is where kept: it is laid out at its width and height (useVideoConfig still says them) and the whole drawn smaller, so a 3D view traces fewer pixels. A draft's, where a smaller picture changes nothing that ships: the app's composition drafts and a scene's kept frames draw at 0.5 |### `OpenOptions`diff --git a/docs/manual/reference/sdk/raea.md b/docs/manual/reference/sdk/raea.mdindex c54fc147..5f3575ed 100644--- a/docs/manual/reference/sdk/raea.md+++ b/docs/manual/reference/sdk/raea.md@@ -1160,6 +1160,7 @@ a split, a cut word or a moved span is a change to this list; the length becomes| Field | Type | What it is || --- | --- | --- || `segments` | `readonly (readonly [number, number])[]` | the composition's own frame ranges, [from, to), played one after another |+| `scale` | `number` | the composition drawn at this fraction of its size (above 0, at most 1), what is where kept: it is laid out at its width and height (useVideoConfig still says them) and the whole drawn smaller, so a 3D view traces fewer pixels. A draft's, where a smaller picture changes nothing that ships: the app's composition drafts and a scene's kept frames draw at 0.5 |### `EffectKind`diff --git a/sdk/raea/conformance/registry.test.tsx b/sdk/raea/conformance/registry.test.tsxindex ee078158..8acc848c 100644--- a/sdk/raea/conformance/registry.test.tsx+++ b/sdk/raea/conformance/registry.test.tsx@@ -1,7 +1,7 @@// registerRoot, from spec/motion.feature ("Declaring and registering"), including a root with no Composition.import { beforeEach, expect, test } from "bun:test";-import { Composition, Sequence, getCompositions, registerRoot, useCurrentFrame } from "../src";-import { resetRegistry } from "../src/test";+import { Composition, Sequence, getCompositions, registerRoot, useCurrentFrame, useVideoConfig } from "../src";+import { renderFrame, resetRegistry } from "../src/test";beforeEach(() => resetRegistry());function Uses() { useCurrentFrame(); return null; }@@ -51,3 +51,27 @@ test("an edit plays its segments one after another, and the length is their sum"test("an edit's segment must sit inside the composition", () => {expect(() => registerRoot(() => <Composition id="cut" component={Uses} width={1920} height={1080} fps={30} durationInFrames={90} edit={{ segments: [[60, 120]] }} />)).toThrow(/edit.segments/);});++test("an edit's scale draws the composition smaller, laid out at its own size", () => {+ let cfg: any;+ function Reads() { cfg = useVideoConfig(); return <div>drawn</div>; }+ registerRoot(() => <Composition id="draft" component={Reads} width={1920} height={1080} fps={30} durationInFrames={90} edit={{ segments: [[0, 30]], scale: 0.5 }} />);+ const c = getCompositions()[0];+ expect(c).toMatchObject({ width: 960, height: 540, durationInFrames: 30 });+ const html = renderFrame(<c.component />, { frame: 0, fps: 30, width: c.width, height: c.height, durationInFrames: c.durationInFrames });+ // inside, the composition sees the size it says, in a box that size drawn at half+ expect(cfg).toMatchObject({ width: 1920, height: 1080 });+ expect(html).toContain("width:1920px");+ expect(html).toContain("transform:scale(0.5, 0.5)");+ expect(html).toContain("drawn");+});++test("an edit's scale of 1 changes nothing, and one outside (0, 1] fails", () => {+ registerRoot(() => <Composition id="same" component={Uses} width={1080} height={1920} fps={30} durationInFrames={9} edit={{ scale: 1 }} />);+ expect(getCompositions()[0]).toMatchObject({ width: 1080, height: 1920 });+ expect(getCompositions()[0].component).toBe(Uses);+ for (const scale of [0, 1.5, Number.NaN]) {+ resetRegistry();+ expect(() => registerRoot(() => <Composition id="bad" component={Uses} width={1080} height={1920} fps={30} durationInFrames={9} edit={{ scale }} />)).toThrow(/edit.scale/);+ }+});diff --git a/sdk/video/src/registry.tsx b/sdk/video/src/registry.tsxindex 2eb29b45..d72a15e5 100644--- a/sdk/video/src/registry.tsx+++ b/sdk/video/src/registry.tsx@@ -29,6 +29,11 @@ export interface CompositionProps<P extends Record<string, unknown> = Record<strexport interface Edit {/** the composition's own frame ranges, [from, to), played one after another */segments?: readonly (readonly [number, number])[];+ /** the composition drawn at this fraction of its size (above 0, at most 1), what is where kept: it is laid out at+ * its width and height (useVideoConfig still says them) and the whole drawn smaller, so a 3D view traces fewer+ * pixels. A draft's, where a smaller picture changes nothing that ships: the app's composition drafts and a scene's+ * kept frames draw at 0.5 (docs/lightspeed.feature PF4) */+ scale?: number;}export interface RegisteredComposition {@@ -94,11 +99,15 @@ function validate(props: CompositionProps<any>, taken: readonly RegisteredComposif (!ok) fail("edit.segments", `has ${JSON.stringify(seg)}: each is [from, to) with 0 <= from < to <= ${props.durationInFrames}`);}}+ const scale = props.edit?.scale;+ if (scale !== undefined && !(typeof scale === "number" && scale > 0 && scale <= 1)) fail("edit.scale", `must be a number above 0 and at most 1, got ${scale}`);+ const [w, h] = scale === undefined || scale === 1 ? [props.width, props.height] : [Math.max(1, Math.round(props.width * scale)), Math.max(1, Math.round(props.height * scale))];+ const cut = segments ? edited(props.component, segments) : props.component;return {id: props.id,- component: segments ? edited(props.component, segments) : props.component,- width: props.width,- height: props.height,+ component: w === props.width && h === props.height ? cut : scaled(cut, props.width, props.height, w, h),+ width: w,+ height: h,fps: props.fps,durationInFrames: segments ? segments.reduce((n, [a, b]) => n + b - a, 0) : props.durationInFrames,defaultProps,@@ -127,6 +136,23 @@ function edited(Component: ComponentType<any>, segments: readonly (readonly [numreturn Edited;}+/** The component laid out at its own size (`width` by `height`, which useVideoConfig reports inside it) in a box+ * drawn at `w` by `h`: an edit's scale. */+function scaled(Component: ComponentType<any>, width: number, height: number, w: number, h: number): ComponentType<any> {+ const style = { position: "absolute", left: 0, top: 0, width, height, transform: `scale(${w / width}, ${h / height})`, transformOrigin: "0 0" } as const;+ function Scaled(props: Record<string, unknown>) {+ return (+ <div style={style}>+ <Sequence layout="none" width={width} height={height}>+ <Component {...props} />+ </Sequence>+ </div>+ );+ }+ Scaled.displayName = `Scaled(${Component.displayName ?? Component.name ?? "Composition"})`;+ return Scaled;+}+/** Declares a composition inside the root. It draws nothing itself; a renderer finds it through registerRoot. */export function Composition<P extends Record<string, unknown>>(_props: CompositionProps<P>) {return null;