Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Image to 3D: side slots that fit, whose left is left, the still on the card, splats in the Library

Claude8d4199d1418b
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsx
index 22887e03..9d486d2a 100644
--- a/src/components/model3d/model-card.tsx
+++ b/src/components/model3d/model-card.tsx
@@ -1,12 +1,12 @@
"use client";
-import { Box, Clapperboard, Download, PersonStanding, Sparkles, Video } from "lucide-react";
+import { Box, Clapperboard, Download, ImageIcon, PersonStanding, Sparkles, Video } from "lucide-react";
import Link from "next/link";
import { createElement, useEffect, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { uploadFile, useHydrated } from "@/lib/api";
-import { animateSpinHref, animationName, model3dView, type Model3dView } from "@/lib/av/model3d";
+import { animateSpinHref, animationName, model3dView, stillOf, type Model3dView } from "@/lib/av/model3d";
import type { Generation } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
import type { Model3dInfo } from "./model3d-studio";
@@ -86,6 +86,8 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
// A rigged result rigs its source model again with another animation.
const rigSource = view.rigged ? (g.request.inputs?.model3d ?? view.glb) : view.glb;
const splatPicture = view.splat && !(show === "video" && clip);
+ // From words on the open engine: the Z-Image still the model was built from (a helper step the page hides).
+ const still = stillOf(g);
return (
<article className="overflow-hidden rounded-2xl border bg-background shadow-soft">
<div className="relative aspect-[4/3] bg-[radial-gradient(circle_at_50%_40%,var(--muted),var(--background))]">
@@ -201,6 +203,13 @@ export function ModelCard({ g, info, cloudAllowed }: { g: Generation; info: Reco
</a>
</Button>
))}
+ {still && (
+ <Button asChild variant="ghost" size="sm" className="rounded-full">
+ <a href={still} target="_blank" rel="noreferrer" aria-label="Open the still the model was built from">
+ <ImageIcon className="size-3.5" /> Still
+ </a>
+ </Button>
+ )}
{clip ? (
<Button asChild variant="outline" size="sm" className="rounded-full">
<a href={clip} download={`${name} turntable.${view.turntable ? "mp4" : "webm"}`} aria-label="Download the turntable video">
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 734da899..f445d3e0 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -1,6 +1,6 @@
"use client";
-import { Box, Loader2 } from "lucide-react";
+import { Box, Loader2, PersonStanding } from "lucide-react";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { Suspense, useCallback, useEffect, useRef, useState } from "react";
@@ -21,7 +21,9 @@ import {
MODEL3D_FEATURE,
MODEL3D_MODES,
MODELS_3D,
+ RIG_MODEL,
SIDE_LABELS,
+ SIDES_HINT,
VIEW_SIDES,
model3dBlocker,
model3dFor,
@@ -57,16 +59,20 @@ const HINTS: Record<Model3dMode, string> = {
splat: "One photo → a Gaussian splat of the subject: soft, photo-real detail, the background left out.",
};
-/** A link's ?model= (from ⌘K) picks that model, its mode and its engine; ?mode= picks a mode. Under its own Suspense: it reads the URL. */
-function UrlModel({ onModel, onMode }: { onModel: (mode: Model3dMode, engine: Engine, id: string) => void; onMode: (mode: Model3dMode) => void }) {
+/**
+ * A link's ?model= (from ⌘K) picks that model, its mode and its engine; ?mode= picks a mode; ?model=meshy-rigging
+ * (rigging works on a finished model) says where Rig & animate is. Under its own Suspense: it reads the URL.
+ */
+function UrlModel({ onModel, onMode, onRig }: { onModel: (mode: Model3dMode, engine: Engine, id: string) => void; onMode: (mode: Model3dMode) => void; onRig: () => void }) {
const params = useSearchParams();
const id = params.get("model");
const mode = params.get("mode");
useEffect(() => {
const found = id ? modeOf(id) : null;
if (found && id) onModel(found.mode, found.engine, id);
+ else if (id === RIG_MODEL) onRig();
else if (MODEL3D_MODES.some((m) => m.id === mode)) onMode(mode as Model3dMode);
- }, [id, mode, onModel, onMode]);
+ }, [id, mode, onModel, onMode, onRig]);
return null;
}
@@ -124,6 +130,8 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const [text, setText] = useState("");
const [object, setObject] = useState("");
const [picked, setPicked] = useState<Record<string, string>>({});
+ const [rigHint, setRigHint] = useState(false);
+ const showRigHint = useCallback(() => setRigHint(true), []);
const fromUrl = useCallback(
(m: Model3dMode, e: Engine, id: string) => {
setMode(m);
@@ -158,24 +166,43 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
return (
<ToolShell title="Image to 3D">
<Suspense fallback={null}>
- <UrlModel onModel={fromUrl} onMode={setMode} />
+ <UrlModel onModel={fromUrl} onMode={setMode} onRig={showRigHint} />
</Suspense>
<ToolHero title="Your product, in 3D" subtitle={HINTS[mode]} />
<ModePicker mode={mode} onChange={setMode} />
+ {rigHint && (
+ <p role="status" className="mx-auto mt-4 max-w-[880px] rounded-2xl border bg-brand-faint px-4 py-3 text-[13px] text-brand-text">
+ <PersonStanding className="mr-1.5 inline size-4 align-[-3px]" aria-hidden />
+ Rig &amp; animate works on a finished model: make one here
+ {items.length > 0 && (
+ <>
+ {" "}
+ or pick one under{" "}
+ <a href="#your-3d-models" className="font-medium underline underline-offset-2">
+ Your 3D models
+ </a>
+ </>
+ )}
+ , then press Rig &amp; animate on its card. Rigging runs on Meshy, in the cloud.
+ </p>
+ )}
<div className="mx-auto mt-6 grid max-w-[880px] gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
{mode === "multi" ? (
<Panel title="Photos of each side" aside={<span className="text-[12px] text-muted-foreground">{Object.keys(sides).length} of 4</span>}>
- <div className="grid grid-cols-4 gap-2">
- {VIEW_SIDES.map((s) => (
- <div key={s} className="flex flex-col items-center gap-1">
- <MediaSlot label={SIDE_LABELS[s]} kind="image" value={views[s] ?? null} onChange={setSide(s)} required={s === "front"} size="lg" caption />
- <span className="text-[11px] text-muted-foreground">{s === "front" ? "Needed" : "Optional"}</span>
- </div>
- ))}
+ {/* Four 80 px slots in a row when the panel has room for them (22rem), two by two when it doesn't. */}
+ <div className="@container">
+ <div className="grid grid-cols-2 justify-items-center gap-2 @[22rem]:grid-cols-4">
+ {VIEW_SIDES.map((s) => (
+ <div key={s} className="flex flex-col items-center gap-1">
+ <MediaSlot label={SIDE_LABELS[s]} kind="image" value={views[s] ?? null} onChange={setSide(s)} required={s === "front"} size="lg" caption />
+ <span className="text-[11px] text-muted-foreground">{s === "front" ? "Needed" : "Optional"}</span>
+ </div>
+ ))}
+ </div>
</div>
<p className="mt-3 text-[12px] text-muted-foreground">
The front and at least one more side. Same object, same distance and light in each; a plain background helps.
- {engine === "open" && " The open model puts each photo on the side you add it to."}
+ {engine === "open" && ` The open model puts each photo on the side you add it to. ${SIDES_HINT}`}
</p>
</Panel>
) : mode === "text" ? (
@@ -194,7 +221,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
className="min-h-28 rounded-xl"
/>
<p className="mt-2 text-[12px] text-muted-foreground">
- One object: what it is, its material and colours.{engine === "open" && " Z-Image Turbo draws it on a plain background first; that still is kept with the model."}
+ One object: what it is, its material and colours.{engine === "open" && " Z-Image Turbo draws it on a plain background first; the finished model's card links to that still."}
</p>
</Panel>
) : (
@@ -292,7 +319,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
)}
</Panel>
</div>
- <section className="mx-auto mt-12 max-w-[880px]" aria-labelledby="models3d">
+ <section id="your-3d-models" className="mx-auto mt-12 max-w-[880px] scroll-mt-6" aria-labelledby="models3d">
{(results.isLoading || items.length > 0) && (
<h3 id="models3d" className="mb-3 font-heading text-[22px]">
Your 3D models
diff --git a/src/components/studio/result-media.tsx b/src/components/studio/result-media.tsx
index ac1f576f..40394baa 100644
--- a/src/components/studio/result-media.tsx
+++ b/src/components/studio/result-media.tsx
@@ -1,8 +1,9 @@
"use client";
-import { AudioLines, Box, FileText, Film, Layers } from "lucide-react";
+import { AudioLines, Box, Download, FileText, Film, Layers } from "lucide-react";
import { createElement, useEffect, useState } from "react";
import { FORMAT_INFO } from "@/lib/av/formats";
+import { splatFormatOf } from "@/lib/av/model3d";
import type { Generation, OutputFile, VideoFormat } from "@/lib/catalog/types";
import { extensionOf } from "@/lib/library";
import { cuesOf, cueTime, editOnlyFormat, isLayered, layerInfo, modelPreview, textOf, videoPoster } from "@/lib/output-actions";
@@ -187,11 +188,17 @@ export function LayersStack({ g, className, bare }: { g: Generation; className?:
);
}
-/** A .glb in an orbitable viewer. @google/model-viewer (with three.js) loads only when one is opened. */
+/**
+ * A .glb in an orbitable viewer. @google/model-viewer (with three.js) loads only when one is opened. A Gaussian
+ * splat (.ply / .spz / .ksplat), which it can't load, shows its orbit video or picture and the file to download.
+ * A rigged character plays its animation instead of turning.
+ */
export function ModelViewer({ output, g }: { output: OutputFile; g: Generation }) {
const [ready, setReady] = useState(false);
const [failed, setFailed] = useState(false);
+ const splat = splatFormatOf(output);
useEffect(() => {
+ if (splat) return;
let live = true;
import("@google/model-viewer").then(
() => live && setReady(true),
@@ -200,8 +207,9 @@ export function ModelViewer({ output, g }: { output: OutputFile; g: Generation }
return () => {
live = false;
};
- }, []);
- const { poster } = modelPreview(g, output);
+ }, [splat]);
+ const { poster, video } = modelPreview(g, output);
+ if (splat) return <SplatPreview output={output} format={splat} poster={poster} video={video} />;
if (failed) return <p className="text-[13px] text-white/80">Couldn&apos;t load the 3D viewer. Download the .glb to open it.</p>;
if (!ready) {
return (
@@ -216,10 +224,32 @@ export function ModelViewer({ output, g }: { output: OutputFile; g: Generation }
poster,
alt: g.request.prompt || "3D model",
"camera-controls": "",
- "auto-rotate": "",
+ ...(output.meta?.rigged === true ? { autoplay: "" } : { "auto-rotate": "" }),
"shadow-intensity": "1",
exposure: "1",
"touch-action": "pan-y",
style: { width: "100%", height: "100%", background: "transparent" },
});
}
+
+/** A splat in the full-screen viewer: its orbit video or picture, what Fuobe can't do yet, and the file. */
+function SplatPreview({ output, format, poster, video }: { output: OutputFile; format: string; poster?: string; video?: string }) {
+ return (
+ <div className="flex size-full flex-col items-center justify-center gap-3 p-4 text-center text-white/80">
+ {video ? (
+ <video src={video} controls autoPlay loop muted playsInline aria-label="Orbit video of the splat" className="max-h-[70%] max-w-full" />
+ ) : poster ? (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img src={poster} alt="The subject the splat was made from" className="max-h-[70%] max-w-full object-contain" />
+ ) : (
+ <Box className="size-10" aria-hidden />
+ )}
+ <p className="max-w-md text-[13px]">
+ Fuobe doesn&apos;t draw Gaussian splats yet. Download the .{format} and open it in a splat viewer (SuperSplat, for one) to look around it.
+ </p>
+ <a href={output.url} download className="inline-flex h-9 items-center gap-1.5 rounded-full bg-white/15 px-4 text-[13px] font-medium text-white hover:bg-white/25">
+ <Download className="size-4" aria-hidden /> .{format}
+ </a>
+ </div>
+ );
+}
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index 52033d30..5d4ac046 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -1,4 +1,4 @@
-import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types";
+import type { Engine, Generation, GenerationRequest, OutputFile } from "@/lib/catalog/types";
/**
* Image to 3D / Product spin: the modes (from an image, from several images, from text, pick an object, a splat),
@@ -59,10 +59,12 @@ export const MODELS_3D: Record<Model3dMode, Record<Engine, Model3dChoice[]>> = {
};
/**
- * Notices cloud models need beside their results: TripoSplat encodes the photo with DINOv3 (its weights ship
- * dino_v3_vit_h), on fal too. Open models get theirs from their workflow's licence.
+ * Notices cloud models need beside their results. The rule is the open engine's: a model that encodes the photo
+ * with DINOv3 carries "Built with DINOv3" wherever it runs, fal included. TripoSplat (its weights ship
+ * dino_v3_vit_h) and TRELLIS.2 (a DINOv3 ViT-L encoder, dino_v3_L_naf in Comfy-Org's repackage) do; Hunyuan3D,
+ * Tripo, Meshy and SAM 3D don't. Open models get theirs from their workflow's licence.
*/
-export const CLOUD_NOTICES: Record<string, string[]> = { triposplat: ["Built with DINOv3"] };
+export const CLOUD_NOTICES: Record<string, string[]> = { triposplat: ["Built with DINOv3"], "trellis-2": ["Built with DINOv3"] };
/** Every model the page offers (⌘K's ?model= links land on its mode). */
export const ALL_MODELS_3D: Model3dChoice[] = Object.values(MODELS_3D).flatMap((m) => [...m.cloud, ...m.open]);
@@ -79,6 +81,11 @@ export function modeOf(id: string): { mode: Model3dMode; engine: Engine } | null
export const VIEW_SIDES = ["front", "left", "back", "right"] as const;
export type ViewSide = (typeof VIEW_SIDES)[number];
export const SIDE_LABELS: Record<ViewSide, string> = { front: "Front", left: "Left side", back: "Back", right: "Right side" };
+/**
+ * Left and right are the object's own, as Pixal3D's rig takes them (the left view's camera is 90° round from the
+ * front, on the side that is on your right as you face the front): said beside the slots.
+ */
+export const SIDES_HINT = "Left and right are the object's own: facing its front, walk round to your right for its left side.";
/** What the user filled in: the photo (or photos by side), the words. */
export interface Model3dInput {
@@ -183,6 +190,24 @@ export interface Model3dView {
const SPLAT_FORMATS = new Set(["ply", "spz", "ksplat", "splat"]);
+/**
+ * A Gaussian splat's format (ply, spz, ksplat), which no glTF viewer loads, else undefined. A splat says so
+ * (meta.format), or its file's extension does; the demo's "splat" is a GLB the viewer shows.
+ */
+export function splatFormatOf(o: Pick<OutputFile, "url" | "meta"> | undefined): string | undefined {
+ if (!o) return undefined;
+ const declared = typeof o.meta?.format === "string" && o.meta.format ? o.meta.format.toLowerCase() : undefined;
+ const ext = o.url.split("?")[0].split(".").pop()?.toLowerCase();
+ const format = declared ?? (ext && SPLAT_FORMATS.has(ext) ? ext : undefined);
+ return format && SPLAT_FORMATS.has(format) ? format : undefined;
+}
+
+/** The still the open text-to-3D route drew and built the model from (the 3D step's chained image), once it ran. */
+export function stillOf(g: Pick<Generation, "request">): string | undefined {
+ const r = g.request;
+ return r.chainFilled && r.op === "image-to-3d" && r.chain?.some((c) => c.slot === "images") ? r.inputs?.images?.[0] : undefined;
+}
+
export function model3dView(g: Pick<Generation, "outputs" | "request">): Model3dView {
const mesh = g.outputs.find((o) => o.kind === "model3d");
const meta = (mesh?.meta ?? {}) as Record<string, unknown>;
@@ -192,10 +217,8 @@ export function model3dView(g: Pick<Generation, "outputs" | "request">): Model3d
const formats: Record<string, string> = {};
const listed = meta.formats;
if (listed && typeof listed === "object") for (const [k, v] of Object.entries(listed as Record<string, unknown>)) if (typeof v === "string") formats[k.toLowerCase()] = v;
- // A splat says so (meta.format), or its file's extension does. The demo's "splat" is a GLB the viewer shows.
- const ext = mesh?.url.split("?")[0].split(".").pop()?.toLowerCase();
- const format = str(meta.format)?.toLowerCase() ?? (ext && SPLAT_FORMATS.has(ext) ? ext : undefined);
- const splat = mesh && format && SPLAT_FORMATS.has(format) ? { url: mesh.url, format } : undefined;
+ const format = splatFormatOf(mesh);
+ const splat = mesh && format ? { url: mesh.url, format } : undefined;
return {
glb: splat ? undefined : mesh?.url,
splat,
diff --git a/tests/model3d.test.ts b/tests/model3d.test.ts
index b29b5c6b..59fc5aec 100644
--- a/tests/model3d.test.ts
+++ b/tests/model3d.test.ts
@@ -69,9 +69,16 @@ describe("modes: which model and operation each runs, per engine", () => {
expect(getModel(m3d.RIG_MODEL)?.routes[0]).toMatchObject({ op: "rig-3d", provider: "fal", endpoint: "fal-ai/meshy/rigging" });
// TripoSplat encodes with DINOv3 on fal too: its results carry the notice.
expect(m3d.CLOUD_NOTICES.triposplat).toEqual(["Built with DINOv3"]);
+ // TRELLIS.2 encodes with DINOv3 ViT-L on fal too, as on the open engine.
+ expect(m3d.CLOUD_NOTICES["trellis-2"]).toEqual(["Built with DINOv3"]);
expect(Object.keys(m3d.CLOUD_NOTICES).every((id) => getModel(id)?.engine === "cloud")).toBe(true);
});
+ it("says which way round the sides go", () => {
+ expect(m3d.SIDES_HINT).toMatch(/object's own/);
+ expect(m3d.SIDES_HINT).toMatch(/your right for its left/);
+ });
+
it("says what is missing, and that Pick an object is cloud only", () => {
expect(m3d.model3dBlocker({ engine: "cloud", mode: "image" })).toBe("Add a photo");
expect(m3d.model3dBlocker({ engine: "cloud", mode: "multi", views: { left: "l.png", back: "b.png" } })).toBe("Add a photo of the front");
@@ -161,6 +168,22 @@ describe("what the cards show", () => {
expect(m3d.model3dView({ outputs: [{ url: "sample:demo-model.glb", kind: "model3d", meta: { splat: true, format: "glb" } }] as never, request: { feature: "x", modelId: "y", op: "splat" } as never })).toMatchObject({ glb: "sample:demo-model.glb", splat: undefined });
});
+ it("tells a splat from a GLB by its format or extension (the Library's viewer goes by it too)", () => {
+ expect(m3d.splatFormatOf({ url: "/api/files/outputs/a.spz" })).toBe("spz");
+ expect(m3d.splatFormatOf({ url: "https://fal.test/x.ply?sig=1" })).toBe("ply");
+ expect(m3d.splatFormatOf({ url: "/api/files/outputs/a.bin", meta: { format: "KSPLAT" } })).toBe("ksplat");
+ expect(m3d.splatFormatOf({ url: "/api/files/outputs/a.glb" })).toBeUndefined();
+ expect(m3d.splatFormatOf({ url: "sample:demo-model.glb", meta: { format: "glb", splat: true } })).toBeUndefined();
+ expect(m3d.splatFormatOf(undefined)).toBeUndefined();
+ });
+
+ it("a model made from words links to the still it was built from, once the step ran", () => {
+ const step = { feature: "image-to-3d", modelId: "oss-trellis2", op: "image-to-3d" as const, prompt: "a lantern", chain: [{ slot: "images" as const, position: "first" as const }] };
+ expect(m3d.stillOf({ request: { ...step, inputs: { images: ["/api/files/still.png"] }, chainFilled: true } })).toBe("/api/files/still.png");
+ expect(m3d.stillOf({ request: step })).toBeUndefined();
+ expect(m3d.stillOf({ request: m3d.model3dRequest({ engine: "open", mode: "image", photo }) })).toBeUndefined();
+ });
+
it("SAM 3D Objects: the GLB in the viewer, its splat as a download", () => {
const outs = extractOutputs({ model_glb: { url: "https://fal.test/o.glb" }, gaussian_splat: { url: "https://fal.test/o.ply" } }, "image-to-3d");
expect(view(outs, m3d.model3dRequest({ engine: "cloud", mode: "objects", photo, prompt: "lamp" }))).toMatchObject({ glb: "https://fal.test/o.glb", formats: { splat: "https://fal.test/o.ply" } });
@@ -339,6 +362,8 @@ describe("open engine: text to 3D as a Z-Image Turbo still, then TRELLIS.2", ()
expect(done.status).toBe("succeeded");
expect(done.outputs.some((o) => o.kind === "model3d")).toBe(true);
expect(done.request.inputs?.images?.length).toBe(1);
+ // Its card links to the still.
+ expect(m3d.stillOf(done)).toBe(done.request.inputs?.images?.[0]);
}, 60_000);
it("runs as the same two steps when the request leaves op out (Assist, MCP, the API)", () => {