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: Make it 3D's link sets the photo crop, Build the final's link leaves it as it is

Claude2f7d3db21d3a
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 25618068..bd886db5 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -35,6 +35,7 @@ import {
readModel3dLink,
linkedIdolQuality,
linkedPicture,
+ linkedPhoto,
model3dFor,
model3dRequest,
modeOf,
@@ -96,8 +97,7 @@ function UrlModel({
if (link.model) onModel(link.model.mode, link.model.engine, link.model.id, link.quality);
else if (link.rig) onRig();
else if (link.mode) onMode(link.mode);
- // Only Make it 3D's link (Idol 3D) says whether the picture is a photo; the others leave "It's a photo" as it is.
- if (link.image) onImage(link.image, link.model && isIdol(link.model.id) ? !!link.photo : undefined);
+ if (link.image) onImage(link.image, linkedPhoto(link));
}, [params, onModel, onMode, onRig, onImage]);
return null;
}
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index 468d61f1..3f20b49e 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -600,3 +600,11 @@ export function readModel3dLink(sp: Pick<URLSearchParams, "get">): Model3dLink {
}
return out;
}
+
+/**
+ * Whether an Image to 3D link's picture sets Idol's "It's a photo": only Make it 3D's link (it names Idol 3D) says what
+ * the picture is. Other links with ?image= (an Idol 3D result's "Build the final with TRELLIS.2") leave it as it is.
+ */
+export function linkedPhoto(link: Model3dLink): boolean | undefined {
+ return link.image && link.model && isIdol(link.model.id) ? !!link.photo : undefined;
+}
diff --git a/tests/idol-final.test.ts b/tests/idol-final.test.ts
index e47822f8..a4669a03 100644
--- a/tests/idol-final.test.ts
+++ b/tests/idol-final.test.ts
@@ -3,7 +3,8 @@ 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 { FINAL_3D, MODELS_3D, finalBuildHref, linkedPhoto, model3dView, modeOf, readModel3dLink } from "@/lib/av/model3d";
+import { make3dHref } from "@/lib/output-actions";
import { offered, type AccessSummary } from "@/lib/model-access";
/**
@@ -66,15 +67,27 @@ describe("Build the final with TRELLIS.2", () => {
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("readModel3dLink(params)");
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.
+ // The final's ?image= leaves Idol's "It's a photo" as it is: the picture is usually the user's own upload. Only Make it
+ // 3D's link (Idol 3D, idol-5) sets it.
+ expect(studio).toContain("onImage(link.image, linkedPhoto(link))");
const fromImage = studio.slice(studio.indexOf("const fromImage = useCallback"), studio.indexOf("const fromUrl = useCallback"));
expect(fromImage).toContain("setPhoto(v);");
- expect(fromImage).not.toContain("setIdolPhoto");
+ expect(fromImage.indexOf("if (asPhoto === undefined) return;")).toBeGreaterThan(-1);
+ expect(fromImage.indexOf("setIdolPhoto")).toBeGreaterThan(fromImage.indexOf("if (asPhoto === undefined) return;"));
+ });
+
+ it("hands the picture over without saying whether it is a photo; Make it 3D's link still does", () => {
+ const final = readModel3dLink(new URL(href(result("oss-idol"))!, "http://x").searchParams);
+ expect(final.image).toBe(PHOTO);
+ expect(linkedPhoto(final)).toBeUndefined();
+ const make3d = (photo: boolean) => readModel3dLink(new URL(make3dHref(PHOTO, photo), "http://x").searchParams);
+ expect(linkedPhoto(make3d(false))).toBe(false);
+ expect(linkedPhoto(make3d(true))).toBe(true);
});
});