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
Inside a Sequence, useVideoConfig().durationInFrames is the Sequence's length (#126): a subtree's LocalTime carries its length, the composition's at the root, a Sequence's own cut where its parent's ends (unbounded, what's left of its parent's), a Loop's one pass, and a Freeze keeps its parent's; useVideoConfig reports it as it reports a Sequence's width and height, and a Sequence's time is still the same object frame to frame. Written from the spec line and its conformance test (#128): conformance 615 pass, the same five failing as on main
shinyobjectze368a5dbcb8b
diff --git a/sdk/app/src/clock.tsx b/sdk/app/src/clock.tsxindex c4c19caf..4f0e4368 100644--- a/sdk/app/src/clock.tsx+++ b/sdk/app/src/clock.tsx@@ -87,6 +87,9 @@ export interface LocalTime {width: number;/** in px, what the Sequence gives its children */height: number;+ /** frames the subtree runs for from its frame 0, which useVideoConfig reports as durationInFrames: a Sequence's own+ * length cut where its parent's ends, a Loop's one pass, the composition's at the root */+ duration: number;}export const ClockContext = createContext<ClockState | null>(null);@@ -198,8 +201,9 @@ export function useLocalTime(caller: string): LocalTime {useClockTick(local ? null : clock);if (local) return local;let t = rootTimes.get(clock);- if (!t || t.frame !== clock.frame || t.width !== clock.config.width || t.height !== clock.config.height) {- t = { frame: clock.frame, origin: 0, width: clock.config.width, height: clock.config.height };+ const c = clock.config;+ if (!t || t.frame !== clock.frame || t.width !== c.width || t.height !== c.height || t.duration !== c.durationInFrames) {+ t = { frame: clock.frame, origin: 0, width: c.width, height: c.height, duration: c.durationInFrames };rootTimes.set(clock, t);}return t;@@ -210,12 +214,13 @@ export function useCurrentFrame(): number {return useLocalTime("useCurrentFrame").frame;}-/** The settings of the composition being rendered (a Sequence's width and height win inside it). */+/** The settings of the composition being rendered (inside a Sequence, its width, height and length win). */export function useVideoConfig(): VideoConfig {const clock = useClockState("useVideoConfig");const local = useContext(LocalTimeContext);- if (!local || (local.width === clock.config.width && local.height === clock.config.height)) return clock.config;- return { ...clock.config, width: local.width, height: local.height };+ const c = clock.config;+ if (!local || (local.width === c.width && local.height === c.height && local.duration === c.durationInFrames)) return c;+ return { ...c, width: local.width, height: local.height, durationInFrames: local.duration };}export interface ClockProps {@@ -303,7 +308,7 @@ export function Clock(props: ClockProps) {if (!LITE) return <ClockContext.Provider value={state}>{props.children}</ClockContext.Provider>;return (<ClockContext.Provider value={state}>- <LocalTimeContext.Provider value={{ frame, origin: 0, width, height }}>{props.children}</LocalTimeContext.Provider>+ <LocalTimeContext.Provider value={{ frame, origin: 0, width, height, duration: durationInFrames }}>{props.children}</LocalTimeContext.Provider></ClockContext.Provider>);}diff --git a/sdk/video/src/timeline.tsx b/sdk/video/src/timeline.tsxindex d61b3330..da40ecfb 100644--- a/sdk/video/src/timeline.tsx+++ b/sdk/video/src/timeline.tsx@@ -115,11 +115,11 @@ function StopsAt(props: { end: number; children?: ReactNode }) {}/** The same LocalTime object as last render when nothing in it changed (a Freeze's subtree, a held frame). */-function useStableTime(frame: number, origin: number, width: number, height: number): LocalTime {+function useStableTime(frame: number, origin: number, width: number, height: number, duration: number): LocalTime {const r = useRef<LocalTime | null>(null);const p = r.current;- if (p && p.frame === frame && p.origin === origin && p.width === width && p.height === height) return p;- return (r.current = { frame, origin, width, height });+ if (p && p.frame === frame && p.origin === origin && p.width === width && p.height === height && p.duration === duration) return p;+ return (r.current = { frame, origin, width, height, duration });}/** Shifts time by `from` and shows its children only for `durationInFrames` frames. */@@ -149,7 +149,12 @@ export function Sequence(props: SequenceProps) {const p = r.current;const w = width ?? parent.width;const h = height ?? parent.height;- const time: LocalTime = p && p.frame === f - from && p.origin === parent.origin + from && p.width === w && p.height === h ? p : (r.current = { frame: f - from, origin: parent.origin + from, width: w, height: h });+ // its length: its own, cut where its parent's ends (unbounded, what's left of the parent's)+ const d = Math.min(durationInFrames, parent.duration - from);+ const time: LocalTime =+ p && p.frame === f - from && p.origin === parent.origin + from && p.width === w && p.height === h && p.duration === d+ ? p+ : (r.current = { frame: f - from, origin: parent.origin + from, width: w, height: h, duration: d });const base = timeBase(pbase.origin + from, pbase.freeze === null ? null : pbase.freeze - from);// no box: the new time around the children here, as Shifted would put it (a game's sound cues, a component less each)if (layout === "none" && style === undefined && className === undefined) {@@ -259,7 +264,11 @@ export function Loop(props: LoopProps) {const lf = f - pass * durationInFrames;const lo = parent.origin + pass * durationInFrames;const p = r.current;- const time: LocalTime = p && p.frame === lf && p.origin === lo && p.width === parent.width && p.height === parent.height ? p : (r.current = { frame: lf, origin: lo, width: parent.width, height: parent.height });+ // its children's length is one pass+ const time: LocalTime =+ p && p.frame === lf && p.origin === lo && p.width === parent.width && p.height === parent.height && p.duration === durationInFrames+ ? p+ : (r.current = { frame: lf, origin: lo, width: parent.width, height: parent.height, duration: durationInFrames });const base = timeBase(pbase.origin + pass * durationInFrames, pbase.freeze === null ? null : pbase.freeze - pass * durationInFrames);return (<Shifted owner="Loop" time={time} base={base} layout={layout} style={style} className={className} label={name} stops={lo + durationInFrames}>@@ -280,7 +289,7 @@ export function Freeze(props: FreezeProps) {checkFinite("Freeze", "frame", props.frame);const parent = useLocalTime("Freeze");const pbase = useContext(TimeBaseContext);- const time = useStableTime(props.frame, parent.origin, parent.width, parent.height);+ const time = useStableTime(props.frame, parent.origin, parent.width, parent.height, parent.duration);return (<TimeBaseContext.Provider value={timeBase(pbase.origin, props.frame)}><LocalTimeContext.Provider value={time}>{props.children}</LocalTimeContext.Provider>