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 fills the form on every click

Claudee16347eaebb1
diff --git a/src/components/model3d/model-card.tsx b/src/components/model3d/model-card.tsx
index 624e0038..16bfc882 100644
--- a/src/components/model3d/model-card.tsx
+++ b/src/components/model3d/model-card.tsx
@@ -49,6 +49,7 @@ export function ModelCard({
cloudAllowed,
refineAllowed = false,
finalAllowed = false,
+ onFinal,
}: {
g: Generation;
info: Record<string, Model3dInfo>;
@@ -56,6 +57,8 @@ export function ModelCard({
refineAllowed?: boolean;
/** TRELLIS.2 runs here and is switched on: an Idol 3D draft offers "Build the final with TRELLIS.2". */
finalAllowed?: boolean;
+ /** Fills the form for the final every time it's clicked (the link alone does nothing when the URL is already its own). */
+ onFinal?: (photo: string) => void;
}) {
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).
@@ -438,7 +441,7 @@ export function ModelCard({
{final && (
<div className="space-y-1">
<Button asChild variant="outline" size="sm" className="rounded-full">
- <Link href={final} prefetch={false}>
+ <Link href={final} prefetch={false} onClick={() => view.photo && onFinal?.(view.photo)}>
<Box className="size-3.5" /> {FINAL_3D.label}
</Link>
</Button>
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index f17950d6..0c7581dc 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -241,12 +241,12 @@ 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.
+ // A picture handed over in the link (?image=). Idol's "It's a photo" is left as it is: the link doesn't say whether
+ // the picture is a photo (an Idol 3D draft's is usually the user's own upload).
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) => {
@@ -256,6 +256,15 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
},
[setEngine],
);
+ // "Build the final with TRELLIS.2" on a result card: fills the form on every click, also when the link is the URL already.
+ const toFinal = useCallback(
+ (url: string) => {
+ const found = modeOf(FINAL_3D.model);
+ if (found) fromUrl(found.mode, found.engine, FINAL_3D.model);
+ fromImage(url);
+ },
+ [fromUrl, fromImage],
+ );
// Models switched off in Settings → Models & licences leave the menu, and the pick falls back to one that is on.
const choices = keepOffered(MODELS_3D[mode][engine], (m) => offered(access, m.id, engine));
const wanted = picked[`${mode}:${engine}`];
@@ -476,7 +485,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} finalAllowed={finalAllowed} />
+ <ResultCard key={g.id} g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} finalAllowed={finalAllowed} onFinal={toFinal} />
))}
</div>
)}
@@ -494,12 +503,26 @@ function retryOf(g: Generation): GenerationRequest {
return r;
}
-function ResultCard({ g, info, cloudAllowed, refineAllowed, finalAllowed }: { g: Generation; info: Record<string, Model3dInfo>; cloudAllowed: boolean; refineAllowed: boolean; finalAllowed: boolean }) {
+function ResultCard({
+ g,
+ info,
+ cloudAllowed,
+ refineAllowed,
+ finalAllowed,
+ onFinal,
+}: {
+ g: Generation;
+ info: Record<string, Model3dInfo>;
+ cloudAllowed: boolean;
+ refineAllowed: boolean;
+ finalAllowed: boolean;
+ onFinal: (photo: string) => void;
+}) {
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} finalAllowed={finalAllowed} />;
+ return <ModelCard g={g} info={info} cloudAllowed={cloudAllowed} refineAllowed={refineAllowed} finalAllowed={finalAllowed} onFinal={onFinal} />;
}
/** A photoreal orbit filmed from a model ("Film it photoreal"): the clip, to watch and download. */
diff --git a/tests/e2e/idol-final.mjs b/tests/e2e/idol-final.mjs
index 6a8cdcf7..72188070 100644
--- a/tests/e2e/idol-final.mjs
+++ b/tests/e2e/idol-final.mjs
@@ -3,7 +3,7 @@
//
// At 1440 px and 390 px, in light and dark: an Idol 3D result on your GPU shows "Build the final with TRELLIS.2" with its
// note, a TRELLIS.2 result doesn't, and the link opens Image to 3D → From an image on TRELLIS.2 with the same picture
-// filled in. Nothing scrolls sideways; no page errors or console errors.
+// filled in, also on a second click of the same link. Nothing scrolls sideways; no page errors or console errors.
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
@@ -64,13 +64,17 @@ for (const phone of [false, true]) {
const cards = page.locator("#your-3d-models article");
await cards.first().waitFor({ timeout: 60_000 });
await sleep(800);
- const link = page.getByRole("link", { name: LABEL });
- assert.equal(await link.count(), 1, `${tag}: one Idol draft offers the final (the TRELLIS.2 card doesn't)`);
+ // Every Idol draft offers the final and nothing else does (an earlier run of this script leaves its own cards).
+ const links = page.getByRole("link", { name: LABEL });
+ const idolCards = await page.locator('#your-3d-models article:has(img[alt="The Idol 3D model"])').count();
+ assert.ok(idolCards > 0 && (await links.count()) === idolCards, `${tag}: only the Idol drafts offer the final (${await links.count()} of ${idolCards})`);
+ assert.equal(await page.locator(`#your-3d-models article:not(:has(img[alt="The Idol 3D model"]))`).getByRole("link", { name: LABEL }).count(), 0, `${tag}: the TRELLIS.2 card doesn't`);
+ const link = links.first();
const href = await link.getAttribute("href");
const q = new URL(href, app).searchParams;
assert.deepEqual(Object.fromEntries(q), { mode: "image", model: "oss-trellis2", image: photo.url }, `${tag}: the link`);
await link.scrollIntoViewIfNeeded();
- assert.ok(await page.getByText("A textured, riggable .glb · 16 GB GPU").isVisible(), `${tag}: the note under it`);
+ assert.ok(await link.locator("xpath=ancestor::article").getByText("A textured, riggable .glb · 16 GB GPU").isVisible(), `${tag}: the note under it`);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth), 0, `${tag}: nothing scrolls sideways`);
if (shots) await link.locator("xpath=ancestor::article").screenshot({ path: path.join(shots, `card-${phone ? "390" : "1440"}-${scheme}.png`) });
await link.click();
@@ -79,9 +83,16 @@ for (const phone of [false, true]) {
// From an image, on TRELLIS.2, with the picture filled in.
assert.equal(await page.getByRole("radio", { name: "From an image" }).getAttribute("aria-checked"), "true", `${tag}: From an image`);
assert.ok((await page.locator("main").innerText()).includes("TRELLIS.2"), `${tag}: TRELLIS.2 picked`);
- assert.ok((await page.locator(`img[src="${photo.url}"]`).count()) > 0, `${tag}: the picture is filled in`);
+ // The photo slot's picture (the Idol card shows the same picture, so it is told apart by its label).
+ const slotPhoto = page.locator(`img[alt="Add a photo of the object"][src="${photo.url}"]`);
+ assert.equal(await slotPhoto.count(), 1, `${tag}: the picture is filled in`);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth), 0, `${tag}: the studio doesn't scroll sideways`);
if (shots) await page.screenshot({ path: path.join(shots, `studio-${phone ? "390" : "1440"}-${scheme}.png`) });
+ // Clicked again with the URL already its own (the picture removed by hand): it fills the picture in again.
+ await page.getByRole("button", { name: "Remove the photo" }).click();
+ await until(async () => (await slotPhoto.count()) === 0, "the picture to go", 15_000);
+ await links.first().click();
+ await until(async () => (await slotPhoto.count()) === 1, `${tag}: the picture filled in again`, 15_000);
console.log(`ok ${tag}`);
} catch (e) {
failures.push(`${tag}: ${e.message}`);
diff --git a/tests/idol-final.test.ts b/tests/idol-final.test.ts
index 81bedd84..e47822f8 100644
--- a/tests/idol-final.test.ts
+++ b/tests/idol-final.test.ts
@@ -68,5 +68,13 @@ describe("Build the final with TRELLIS.2", () => {
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}");
+ // A second click on the same link still fills the form (the URL doesn't change, so UrlModel can't).
+ expect(card).toContain("onClick={() => view.photo && onFinal?.(view.photo)}");
+ expect(studio).toContain("onFinal={toFinal}");
+ expect(studio).toContain("if (found) fromUrl(found.mode, found.engine, FINAL_3D.model);");
+ // ?image= leaves Idol's "It's a photo" as it is: the picture is usually the user's own upload.
+ const fromImage = studio.slice(studio.indexOf("const fromImage = useCallback"), studio.indexOf("const fromUrl = useCallback"));
+ expect(fromImage).toContain("setPhoto(v);");
+ expect(fromImage).not.toContain("setIdolPhoto");
});
});