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: Build the final with TRELLIS.2 from an Idol 3D draft

Claude9ed6da4f9720
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsx
index b12a514b..624e0038 100644
--- a/src/components/model3d/model-card.tsx
+++ b/src/components/model3d/model-card.tsx
@@ -6,7 +6,7 @@ import { createElement, useCallback, useEffect, useEffectEvent, useRef, useState
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { uploadFile, useEngine, useHydrated } from "@/lib/api";
-import { animateSpinHref, animationName, model3dView, photorealAngle, photorealBody, stillOf, type Model3dView } from "@/lib/av/model3d";
+import { FINAL_3D, animateSpinHref, animationName, finalBuildHref, model3dView, photorealAngle, photorealBody, stillOf, type Model3dView } from "@/lib/av/model3d";
import { PATH_FPS, PATH_FRAMES } from "@/lib/camera-path";
import { useFlyAround } from "@/components/fly-around-run";
import type { Generation } from "@/lib/catalog/types";
@@ -41,9 +41,22 @@ function rigClips(g: Generation, view: Model3dView): { key: string; label: strin
* A finished 3D model. The card plays its turntable (or shows its poster or photo); the orbitable viewer, and with it
* the GLB, loads only when "View in 3D" opens it: the web GLB when the server made one, else the original (a rig
* plays its animation). A splat shows its orbit video or picture with the file to download. Then the turntable,
- * Animate the spin and Rig & animate.
+ * Animate the spin and Rig & animate; an Idol 3D draft on your GPU, "Build the final with TRELLIS.2".
*/
-export function ModelCard({ g, info, cloudAllowed, refineAllowed = false }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed?: boolean }) {
+export function ModelCard({
+ g,
+ info,
+ cloudAllowed,
+ refineAllowed = false,
+ finalAllowed = false,
+}: {
+ g: Generation;
+ info: Record<string, Model3dInfo>;
+ cloudAllowed: boolean;
+ refineAllowed?: boolean;
+ /** TRELLIS.2 runs here and is switched on: an Idol 3D draft offers "Build the final with TRELLIS.2". */
+ finalAllowed?: boolean;
+}) {
const view = model3dView(g);
// "preview": the turntable or the still (a splat with an orbit video: the video). "3d": the viewer (a splat: its picture).
const [show, setShow] = useState<"preview" | "3d">("preview");
@@ -196,6 +209,8 @@ export function ModelCard({ g, info, cloudAllowed, refineAllowed = false }: { g:
const canFilm = !!photoreal && !view.rigged && (engine === "cloud" || (view.glb ? canRecord && !failed : !!view.turntable));
const filmBusy = filming !== null || fly.run.isPending;
const spin = view.rigged ? null : animateSpinHref(view, recorded?.saved);
+ // Draft then final (idol-6): an Idol 3D splat's picture, rebuilt as a textured mesh with TRELLIS.2.
+ const final = finalBuildHref(g, view, finalAllowed);
// Hi3D's results: geometry only, and "Powered by Hi3D 1.0" (linked, as its licence asks) instead of the plain notice.
const refined = isRefined(g);
const notices = (info[g.modelId]?.notices ?? []).filter((n) => !(refined && n === HI3D_NOTICE));
@@ -420,6 +435,16 @@ export function ModelCard({ g, info, cloudAllowed, refineAllowed = false }: { g:
</Button>
)}
</div>
+ {final && (
+ <div className="space-y-1">
+ <Button asChild variant="outline" size="sm" className="rounded-full">
+ <Link href={final} prefetch={false}>
+ <Box className="size-3.5" /> {FINAL_3D.label}
+ </Link>
+ </Button>
+ <p className="text-[12px] text-muted-foreground">{FINAL_3D.note}</p>
+ </div>
+ )}
{refined && <p className="text-[12px] text-muted-foreground">Geometry only: no colour or texture. Set its real size in Print-ready.</p>}
{(notices.length > 0 || refined) && (
<p className="text-[11px] text-muted-foreground">
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index ce7acbf1..f17950d6 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -18,6 +18,7 @@ import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
import { SelfHostNote } from "@/components/self-host-note";
import { useCreateGeneration, useEngine, useGenerations, useHydrated, useLikelyVisitor, useModelAccess, useStatus } from "@/lib/api";
import {
+ FINAL_3D,
IDOL_QUALITIES,
MAX_3D_PROMPT,
MODEL3D_FEATURE,
@@ -71,18 +72,33 @@ const HINTS: Record<Model3dMode, string> = {
/**
* 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.
+ * (rigging works on a finished model) says where Rig & animate is; ?image= fills in the picture (an Idol 3D result's
+ * "Build the final with TRELLIS.2"). 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 }) {
+function UrlModel({
+ onModel,
+ onMode,
+ onRig,
+ onImage,
+}: {
+ onModel: (mode: Model3dMode, engine: Engine, id: string) => void;
+ onMode: (mode: Model3dMode) => void;
+ onRig: () => void;
+ onImage: (url: string) => void;
+}) {
const params = useSearchParams();
const id = params.get("model");
const mode = params.get("mode");
+ const image = params.get("image");
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, onRig]);
+ useEffect(() => {
+ if (image) onImage(image);
+ }, [image, onImage]);
return null;
}
@@ -225,6 +241,13 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
// Refine detail · Hi3D 1.0 (open engine, From an image and From several images): the resolution, or off.
const [refine, setRefine] = useState<Hi3dResolution | null>(null);
const showRigHint = useCallback(() => setRigHint(true), []);
+ // A picture handed over in the link (?image=): a Fuobe result's, so Idol's photo crop stays off.
+ const fromImage = useCallback((url: string) => {
+ const v: SlotValue = { ref: url, preview: url, kind: "image" };
+ lastPhoto.current = v;
+ setPhoto(v);
+ setIdolPhoto(false);
+ }, []);
const fromUrl = useCallback(
(m: Model3dMode, e: Engine, id: string) => {
setMode(m);
@@ -264,6 +287,8 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const cloudAllowed = engineMode !== "open";
// Hi3D runs on your GPU only: offered while the install runs open models and the model is switched on.
const refineAllowed = !visitor && engineMode !== "cloud" && offered(access, HI3D_MODEL, "open");
+ // "Build the final with TRELLIS.2" on an Idol 3D result: while TRELLIS.2 runs here and is switched on.
+ const finalAllowed = !visitor && engineMode !== "cloud" && offered(access, FINAL_3D.model, "open");
const refining = refineAllowed && engine === "open" && (mode === "image" || mode === "multi") && refine !== null ? refine : null;
const go = () => {
if (visitor) return;
@@ -282,7 +307,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
return (
<ToolShell title="Image to 3D" selfHostedOnly>
<Suspense fallback={null}>
- <UrlModel onModel={fromUrl} onMode={setMode} onRig={showRigHint} />
+ <UrlModel onModel={fromUrl} onMode={setMode} onRig={showRigHint} onImage={fromImage} />
</Suspense>
<ToolHero title="Your product, in 3D" subtitle={HINTS[mode]}>
{visitor && <SelfHostNote className="mt-3 max-w-xl">Image to 3D isn&apos;t available here.</SelfHostNote>}
@@ -451,7 +476,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
) : (
<div className="grid gap-3 sm:grid-cols-2">
{items.map((g) => (
- <ResultCard key={g.id} g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} />
+ <ResultCard key={g.id} g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} finalAllowed={finalAllowed} />
))}
</div>
)}
@@ -469,12 +494,12 @@ function retryOf(g: Generation): GenerationRequest {
return r;
}
-function ResultCard({ g, info, cloudAllowed, refineAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed: boolean }) {
+function ResultCard({ g, info, cloudAllowed, refineAllowed, finalAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed: boolean; finalAllowed: boolean }) {
const create = useCreateGeneration();
if (g.status === "queued" || g.status === "running") return <PendingTile g={g} ratio={4 / 3} />;
if (g.status !== "succeeded") return <FailedTile g={g} ratio={4 / 3} onRetry={() => create.mutate(retryOf(g), { onError: (e) => toastError(e) })} />;
if (g.kind === "video") return <FilmCard g={g} />;
- return <ModelCard g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} />;
+ return <ModelCard g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} finalAllowed={finalAllowed} />;
}
/** A photoreal orbit filmed from a model ("Film it photoreal"): the clip, to watch and download. */
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index 6b26793e..51f94a60 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -84,6 +84,22 @@ export const CLOUD_NOTICES: Record<string, string[]> = { triposplat: ["Built wit
export const IDOL_MODELS = { open: "oss-idol", cloud: "idol-3d" } as const;
export const isIdol = (id: string | null | undefined) => id === IDOL_MODELS.open || id === IDOL_MODELS.cloud;
+/**
+ * Draft then final (idol-6, docs/research/idol-9.md §8): an Idol 3D splat on your GPU is a quick look at the object's
+ * sides; the textured final is TRELLIS.2 from the same picture, an ordinary Image to 3D run (not an Idol substitute).
+ */
+export const FINAL_3D = { model: "oss-trellis2", label: "Build the final with TRELLIS.2", note: "A textured, riggable .glb · 16 GB GPU" } as const;
+
+/**
+ * Where "Build the final with TRELLIS.2" goes from a finished Idol 3D result on the open engine: Image to 3D with
+ * TRELLIS.2 picked and the result's own picture filled in. null on any other result, without the picture, or when
+ * TRELLIS.2 isn't offered here (`allowed`: switched on in Settings → Models & licences, open models run, not a visitor).
+ */
+export function finalBuildHref(g: Pick<Generation, "request">, view: Pick<Model3dView, "photo">, allowed: boolean): string | null {
+ if (!allowed || g.request.modelId !== IDOL_MODELS.open || !view.photo) return null;
+ return `/image-to-3d?${new URLSearchParams({ mode: "image", model: FINAL_3D.model, image: view.photo })}`;
+}
+
export type IdolQuality = "best" | "quick";
/**
diff --git a/tests/idol-final.test.ts b/tests/idol-final.test.ts
new file mode 100644
index 00000000..81bedd84
--- /dev/null
+++ b/tests/idol-final.test.ts
@@ -0,0 +1,72 @@
+import fs from "node:fs";
+import path from "node:path";
+import { describe, expect, it } from "vitest";
+import { getModel } from "@/lib/catalog";
+import type { Generation } from "@/lib/catalog/types";
+import { FINAL_3D, MODELS_3D, finalBuildHref, model3dView, modeOf } from "@/lib/av/model3d";
+import { offered, type AccessSummary } from "@/lib/model-access";
+
+/**
+ * Draft then final (idol-6, docs/research/idol-9.md §8): a finished Idol 3D splat on your GPU links to Image to 3D with
+ * TRELLIS.2 picked and the same picture filled in, while TRELLIS.2 is switched on and runs here.
+ */
+
+const PHOTO = "/api/files/abc123.png";
+
+function result(modelId: string, images: string[] = [PHOTO]): Pick<Generation, "outputs" | "request"> {
+ return {
+ request: { feature: "image-to-3d", modelId, op: modelId === "oss-idol" ? "splat" : "image-to-3d", inputs: { images } },
+ outputs: [{ kind: "model3d", url: "/api/files/out.spz", meta: { format: "spz" } }],
+ } as Pick<Generation, "outputs" | "request">;
+}
+
+const href = (g: Pick<Generation, "outputs" | "request">, allowed = true) => finalBuildHref(g, model3dView(g), allowed);
+
+describe("Build the final with TRELLIS.2", () => {
+ it("links an Idol 3D result on your GPU to Image to 3D with TRELLIS.2 and its own picture", () => {
+ const link = href(result("oss-idol"));
+ expect(link).toBe(`/image-to-3d?mode=image&model=oss-trellis2&image=${encodeURIComponent(PHOTO)}`);
+ const q = new URL(link!, "http://x").searchParams;
+ expect(Object.fromEntries(q)).toEqual({ mode: "image", model: "oss-trellis2", image: PHOTO });
+ // The studio reads ?model=oss-trellis2 as From an image on the open engine.
+ expect(modeOf(q.get("model")!)).toMatchObject({ mode: "image", engine: "open" });
+ });
+
+ it("shows only on Idol 3D results on your GPU that have a source picture", () => {
+ expect(href(result("oss-idol", []))).toBeNull();
+ // fal's Idol is not drafted into the open TRELLIS.2: no Idol draft on the cloud.
+ expect(href(result("idol-3d"))).toBeNull();
+ for (const other of ["oss-triposplat", "oss-trellis2", "oss-pixal3d", "triposplat", "trellis-2"]) expect(href(result(other))).toBeNull();
+ });
+
+ it("hides when TRELLIS.2 isn't offered here", () => {
+ expect(href(result("oss-idol"), false)).toBeNull();
+ });
+
+ it("respects Settings → Models & licences the way the studio's picker does", () => {
+ const off: AccessSummary = { off: ["oss-trellis2"] };
+ const otherOff: AccessSummary = { off: ["oss-pixal3d"] };
+ expect(offered(undefined, FINAL_3D.model, "open")).toBe(true);
+ expect(offered(otherOff, FINAL_3D.model, "open")).toBe(true);
+ expect(offered(off, FINAL_3D.model, "open")).toBe(false);
+ expect(href(result("oss-idol"), offered(off, FINAL_3D.model, "open"))).toBeNull();
+ });
+
+ it("names a real open model the studio offers, with its GPU need", () => {
+ expect(getModel(FINAL_3D.model)?.name).toBe("TRELLIS.2");
+ expect(MODELS_3D.image.open.map((m) => m.id)).toContain(FINAL_3D.model);
+ expect(getModel(FINAL_3D.model)?.tagline).toContain("16 GB GPU");
+ expect(FINAL_3D.note).toBe("A textured, riggable .glb · 16 GB GPU");
+ });
+
+ it("is wired into the card and the studio (model access, open models, no visitors; ?image= fills the picture)", () => {
+ const root = process.cwd();
+ const card = fs.readFileSync(path.join(root, "src/components/model3d/model-card.tsx"), "utf8");
+ const studio = fs.readFileSync(path.join(root, "src/components/model3d/model3d-studio.tsx"), "utf8");
+ expect(card).toContain("finalBuildHref(g, view, finalAllowed)");
+ expect(card).toContain("{FINAL_3D.note}");
+ expect(studio).toContain('const finalAllowed = !visitor && engineMode !== "cloud" && offered(access, FINAL_3D.model, "open");');
+ expect(studio).toContain('params.get("image")');
+ expect(studio).toContain("onImage={fromImage}");
+ });
+});