Skip to content

Photoreal Blender scenes from a one-paragraph brief, built by AI agents: image→3D props on fal, scripted layout, lighting, camera and grade.

Python

Studio: mock builds, and the sample plates in a floating picker

Apekshik Panigrahi314eaab1c1ec
diff --git a/web/app/globals.css b/web/app/globals.css
index 7917fd2..f5b48e1 100644
--- a/web/app/globals.css
+++ b/web/app/globals.css
@@ -139,11 +139,18 @@ button:disabled { cursor: default; }
.drop-empty { display: flex; flex-direction: column; gap: 6px; padding: 16px; text-align: center; }
.drop-title { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 15px; }
.drop-hint { color: var(--dim-text); font-size: 12px; }
-.samples { display: flex; flex-direction: column; gap: 8px; }
-.samples-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
+.mock-switch { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.35; cursor: pointer; }
+.mock-switch input { margin-top: 2px; accent-color: var(--red); }
+.mock-switch .dim { color: var(--dim-text); }
+.sample-open { align-self: flex-start; }
+.sample-panel { position: fixed; z-index: 40; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 24px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--card); border: 2px solid var(--ink); box-shadow: 6px 6px 0 rgba(31, 29, 26, 0.18); }
+.sample-panel.docked { left: 16px; right: 16px; top: 12px; width: auto; }
+.sample-panel-head { display: flex; justify-content: space-between; align-items: center; }
+.samples-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
+@media (max-width: 480px) { .samples-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sample { display: flex; flex-direction: column; gap: 3px; padding: 0; background: none; border: 0; text-align: left; color: var(--ink); cursor: pointer; }
.sample img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid var(--rule); transition: border-color 0.15s var(--ease); }
-.sample span { font-size: 11px; line-height: 1.25; color: var(--dim-text); }
+.sample span { font-size: 12px; line-height: 1.25; color: var(--dim-text); }
.sample:hover img, .sample:focus-visible img { border-color: var(--ink); }
.sample.on img { border: 2px solid var(--red); }
.sample.on span { color: var(--ink); }
diff --git a/web/components/BuilderInputs.tsx b/web/components/BuilderInputs.tsx
index 14591e3..0858e67 100644
--- a/web/components/BuilderInputs.tsx
+++ b/web/components/BuilderInputs.tsx
@@ -3,7 +3,7 @@
import { useRef, useState } from "react";
import Dials, { type DialValues } from "./Dials";
import InfoTip, { HELP } from "./InfoTip";
-import { SAMPLES, sampleFile, sampleThumb } from "@/lib/samples";
+import SamplePicker from "./SamplePicker";
export interface BuilderInputsState {
file: File | null;
@@ -23,13 +23,14 @@ interface Props {
onBuild: () => void;
/** Under the button: what a build costs, how many are left today. */
note?: React.ReactNode;
+ /** Mock build: replay a recorded build instead of calling fal. Undefined hides the switch (plain replays). */
+ mock?: boolean;
+ onMock?: (on: boolean) => void;
}
-export default function BuilderInputs({ value, onChange, disabled, canBuild, building, onBuild, note }: Props) {
+export default function BuilderInputs({ value, onChange, disabled, canBuild, building, onBuild, note, mock, onMock }: Props) {
const fileRef = useRef<HTMLInputElement>(null);
const [over, setOver] = useState(false);
- const [loading, setLoading] = useState<string | null>(null);
- const [sampleError, setSampleError] = useState("");
const set = (patch: Partial<BuilderInputsState>) => onChange({ ...value, ...patch });
const take = (f: File | undefined) => {
if (!f || !f.type.startsWith("image/")) return;
@@ -74,37 +75,7 @@ export default function BuilderInputs({ value, onChange, disabled, canBuild, bui
{value.previewUrl ? `plate 1 of 1: ${value.file ? value.file.name : "recorded reference"}` : "no plate loaded"}
</p>
- <div className="samples">
- <span className="field-label">Or try one of ours</span>
- <div className="samples-grid">
- {SAMPLES.map((s) => (
- <button
- key={s.id}
- type="button"
- className={`sample ${value.file?.name === `${s.id}.jpg` ? "on" : ""}`}
- disabled={disabled || loading !== null}
- title={s.label}
- aria-label={`Use the sample reference: ${s.label}`}
- onClick={async () => {
- setLoading(s.id);
- setSampleError("");
- try {
- take(await sampleFile(s));
- } catch (err) {
- setSampleError(err instanceof Error ? err.message : String(err));
- } finally {
- setLoading(null);
- }
- }}
- >
- {/* eslint-disable-next-line @next/next/no-img-element */}
- <img src={sampleThumb(s.id)} alt="" loading="lazy" />
- <span>{loading === s.id ? "Loading" : s.label}</span>
- </button>
- ))}
- </div>
- {sampleError && <p className="error-note">{sampleError}</p>}
- </div>
+ <SamplePicker current={value.file?.name} disabled={disabled} onPick={take} />
<label className="field">
<span className="field-label">
@@ -147,10 +118,22 @@ export default function BuilderInputs({ value, onChange, disabled, canBuild, bui
))}
</select>
</label>
+ {mock !== undefined && (
+ <label className="mock-switch">
+ <input type="checkbox" checked={mock} disabled={disabled} onChange={(e) => onMock?.(e.target.checked)} />
+ <span>
+ <b>Mock build</b> <span className="dim">free: replays a recorded build through the UI, nothing runs on fal</span>
+ </span>
+ </label>
+ )}
<button className="primary" disabled={!canBuild} onClick={onBuild}>
- {building ? "Building" : "Build the scene"}
+ {building ? "Building" : mock ? "Build the scene (mock)" : "Build the scene"}
</button>
- <p className="fine">One agent builds it end to end and loops with a critic. Up to 2 hours.{note ? <> {note}</> : null}</p>
+ <p className="fine">
+ {mock
+ ? "Plays at 16x; change the speed in the toolbar. The frames and results are from a recorded build, not your plate."
+ : <>One agent builds it end to end and loops with a critic. Up to 2 hours.{note ? <> {note}</> : null}</>}
+ </p>
</div>
);
}
diff --git a/web/components/BuilderStudio.tsx b/web/components/BuilderStudio.tsx
index 07735d8..7c11ea8 100644
--- a/web/components/BuilderStudio.tsx
+++ b/web/components/BuilderStudio.tsx
@@ -35,7 +35,10 @@ export default function BuilderStudio() {
const galleryHref = `/?${new URLSearchParams({ view: "gallery", ...(openKind === "kit" ? { kind: "kit" } : {}), ...(galleryOverride ? { gallery_app: galleryOverride } : {}) })}`;
const [opened, setOpened] = useState<GalleryItem | null>(null);
const auto = params.get("auto") === "1";
- const initialSpeed = Math.max(0.25, Math.min(256, Number(params.get("speed")) || 1));
+ // ?mock=1 (or the Mock switch by the Build button): Build replays the recorded builder fixture through every UI state,
+ // with no confirm card and nothing sent to fal
+ const [mock, setMock] = useState(params.get("mock") === "1");
+ const initialSpeed = Math.max(0.25, Math.min(256, Number(params.get("speed")) || (mock ? 16 : 1)));
const [source, setSource] = useState<Source | null>(null);
const [sourceError, setSourceError] = useState("");
@@ -63,11 +66,13 @@ export default function BuilderStudio() {
useEffect(() => {
let cancelled = false;
- if (replayName) {
- ReplaySource.load(replayName, initialSpeed)
+ if (replayName || mock) {
+ ReplaySource.load(replayName || "builder", initialSpeed)
.then((s) => {
if (cancelled) return;
setSource(s);
+ // a mock keeps the plate you picked; a plain replay shows the recorded one
+ if (mock) return;
setInputs((i) => ({ ...i, previewUrl: s.referenceUrl }));
refUrl.current = s.referenceUrl;
})
@@ -76,9 +81,9 @@ export default function BuilderStudio() {
return () => {
cancelled = true;
};
- }, [replayName, initialSpeed]);
+ }, [replayName, mock, initialSpeed]);
- const live = !replayName;
+ const live = !replayName && !mock;
useEffect(() => {
if (!live) return;
if (!getWho()) return setWhoOpen("first");
@@ -123,6 +128,7 @@ export default function BuilderStudio() {
url = await source.uploadReference(inputs.file);
refUrl.current = url;
}
+ if (!url && source instanceof ReplaySource) url = inputs.previewUrl || source.referenceUrl;
if (!url) throw new Error("Add a reference image first.");
const floorPlanUrl = inputs.floorPlan && source.mode === "live" ? await source.uploadReference(inputs.floorPlan) : undefined;
const r = await source.builder(
@@ -331,7 +337,7 @@ export default function BuilderStudio() {
<div className="toolbar">
{replay ? (
<div className="replay-ctl" title="Replaying a recorded build">
- <span>Replay: {replay.manifest.name}</span>
+ <span>{mock ? "Mock build (free)" : `Replay: ${replay.manifest.name}`}</span>
<div className="speeds" role="group" aria-label="Replay speed">
{SPEEDS.map((s) => (
<button key={s} className={speed === s ? "on" : ""} onClick={() => setSpeed(s)} aria-pressed={speed === s}>
@@ -347,7 +353,7 @@ export default function BuilderStudio() {
</span>
)
)}
- {!replay && (
+ {(!replay || mock) && (
<a className="text-btn" href={galleryHref}>
{openId ? "Back to gallery" : "Gallery"}
</a>
@@ -366,7 +372,7 @@ export default function BuilderStudio() {
{copied ? "Link copied" : "Copy link"}
</button>
)}
- {!replay && (
+ {(!replay || mock) && (
<button className={`text-btn ${needsKey ? "bad" : ""}`} onClick={() => setWhoOpen("edit")} title={me?.owner || undefined}>
{needsKey ? "Password needed" : me?.owner ? `${ownerName(me.owner)}${me.admin ? " (admin)" : ""}` : "Sign in"}
</button>
@@ -385,10 +391,16 @@ export default function BuilderStudio() {
setInputs(v);
}}
disabled={running}
- canBuild={!!(inputs.file || refUrl.current) && !running && !!source}
+ canBuild={!!(inputs.file || refUrl.current || (mock && inputs.previewUrl)) && !running && !!source}
building={running || checking}
onBuild={requestBuild}
note={live ? <CostNote me={me} /> : null}
+ mock={replayName ? undefined : mock}
+ onMock={(on) => {
+ setMock(on);
+ if (on && speed === 1) setSpeed(16);
+ if (!on) setSpeed(1);
+ }}
/>
{res && res.build_id && openKind === "scene" && <ShotsOrder res={res} source={source instanceof LiveSource ? source : null} />}
<BuilderSchedule run={run} now={serverNow} />
@@ -420,7 +432,7 @@ export default function BuilderStudio() {
<CriticPanel run={run} />
</aside>
- {whoOpen && (
+ {whoOpen && !(mock && whoOpen === "first") && (
<WhoAmI
reason={whoOpen === "build" ? (me?.error ?? "Tell AnyScene who you are before starting a build.") : undefined}
onCancel={whoOpen === "first" ? undefined : () => setWhoOpen("")}
diff --git a/web/components/SamplePicker.tsx b/web/components/SamplePicker.tsx
new file mode 100644
index 0000000..95437f0
--- /dev/null
+++ b/web/components/SamplePicker.tsx
@@ -0,0 +1,110 @@
+"use client";
+
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
+import { SAMPLES, sampleFile, sampleThumb, type Sample } from "@/lib/samples";
+
+const narrow = () => typeof window !== "undefined" && window.innerWidth < 760;
+
+/** "Try a sample plate": one button in the sidebar; the plates open in a panel floating just right of the sidebar
+ * (full width on a phone), so the inputs below stay in view. Closes on a pick, Escape or a click outside. */
+export default function SamplePicker({ current, disabled, onPick }: { current?: string; disabled: boolean; onPick: (f: File) => void }) {
+ const [open, setOpen] = useState(false);
+ const [pos, setPos] = useState<{ top: number; left: number } | null>(null);
+ const [loading, setLoading] = useState<string | null>(null);
+ const [error, setError] = useState("");
+ const btn = useRef<HTMLButtonElement>(null);
+ const panel = useRef<HTMLDivElement>(null);
+
+ // anchor beside the sidebar, level with the button, kept inside the window
+ useLayoutEffect(() => {
+ if (!open) return;
+ const place = () => {
+ const b = btn.current?.getBoundingClientRect();
+ const side = btn.current?.closest("aside")?.getBoundingClientRect();
+ if (!b) return;
+ if (narrow()) return setPos(null);
+ const h = panel.current?.offsetHeight ?? 0;
+ setPos({ top: Math.max(12, Math.min(b.top - 12, window.innerHeight - h - 12)), left: (side?.right ?? b.right) + 12 });
+ };
+ place();
+ // again whenever its size changes (floating width applied, thumbnails loaded)
+ const ro = new ResizeObserver(place);
+ if (panel.current) ro.observe(panel.current);
+ window.addEventListener("resize", place);
+ window.addEventListener("scroll", place, true);
+ return () => {
+ ro.disconnect();
+ window.removeEventListener("resize", place);
+ window.removeEventListener("scroll", place, true);
+ };
+ }, [open]);
+
+ useEffect(() => {
+ if (!open) return;
+ const down = (e: PointerEvent) => {
+ const t = e.target as Node;
+ if (!panel.current?.contains(t) && !btn.current?.contains(t)) setOpen(false);
+ };
+ const key = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false);
+ document.addEventListener("pointerdown", down);
+ document.addEventListener("keydown", key);
+ return () => {
+ document.removeEventListener("pointerdown", down);
+ document.removeEventListener("keydown", key);
+ };
+ }, [open]);
+
+ const pick = async (s: Sample) => {
+ setLoading(s.id);
+ setError("");
+ try {
+ onPick(await sampleFile(s));
+ setOpen(false);
+ } catch (err) {
+ setError(err instanceof Error ? err.message : String(err));
+ } finally {
+ setLoading(null);
+ }
+ };
+
+ return (
+ <>
+ <button ref={btn} type="button" className="secondary sample-open" disabled={disabled} aria-expanded={open} onClick={() => setOpen((o) => !o)}>
+ Try a sample plate <span aria-hidden>{open ? "◂" : "▸"}</span>
+ </button>
+ {open && (
+ <div
+ ref={panel}
+ className={`sample-panel ${pos || !narrow() ? "" : "docked"}`}
+ style={pos ? { top: pos.top, left: pos.left } : undefined}
+ role="dialog"
+ aria-label="Sample reference plates"
+ >
+ <div className="sample-panel-head">
+ <span className="field-label">Sample plates</span>
+ <button type="button" className="text-btn" onClick={() => setOpen(false)}>
+ Close
+ </button>
+ </div>
+ <div className="samples-grid">
+ {SAMPLES.map((s) => (
+ <button
+ key={s.id}
+ type="button"
+ className={`sample ${current === `${s.id}.jpg` ? "on" : ""}`}
+ disabled={loading !== null}
+ aria-label={`Use the sample reference: ${s.label}`}
+ onClick={() => pick(s)}
+ >
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+ <img src={sampleThumb(s.id)} alt="" />
+ <span>{loading === s.id ? "Loading" : s.label}</span>
+ </button>
+ ))}
+ </div>
+ {error && <p className="error-note">{error}</p>}
+ </div>
+ )}
+ </>
+ );
+}