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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Image to 3D: Make it 3D's Idol switch and link hand-over checked in tests
Claudea7bc5faa6d50
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsxindex 41bbe6cc..f3698ae4 100644--- a/src/components/model3d/model3d-studio.tsx+++ b/src/components/model3d/model3d-studio.tsx@@ -32,6 +32,8 @@ import {MAKE_3D_HINT,model3dBlocker,readModel3dLink,+ linkedIdolQuality,+ linkedPicture,model3dFor,model3dRequest,type IdolQuality,@@ -239,7 +241,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {(m: Model3dMode, e: Engine, id: string, quality?: IdolQuality) => {setMode(m);setPicked((p) => ({ ...p, [`${m}:${e}`]: id }));- if (quality && isIdol(id)) setIdolQualities((p) => ({ ...p, [`${m}:${e}`]: quality }));+ setIdolQualities((p) => linkedIdolQuality(p, m, e, id, quality));setEngine(e);},[setEngine],@@ -248,7 +250,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {// crop starts off (the tighter crop suits a generated picture), or on for an upload (?photo=1).const [handed, setHanded] = useState<string | null>(null);const fromImage = useCallback((url: string, asPhoto: boolean) => {- const v: SlotValue = { id: "link", ref: url, preview: url, kind: "image", source: asPhoto ? "upload" : "generation" };+ const v: SlotValue = linkedPicture(url, asPhoto);lastPhoto.current = v;setPhoto(v);setIdolPhoto(asPhoto);diff --git a/src/lib/api.ts b/src/lib/api.tsindex 9e850d42..7420a8e5 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -4,7 +4,7 @@ import { keepPreviousData, useInfiniteQuery, useMutation, useQuery, useQueryClieimport { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";import { toast } from "sonner";import type { AssistThread, AssistThreadSummary, AssistThreadView } from "./assist";-import { openEngineReady, type OwnerGpuView, type TestProvider } from "./connections";+import { make3dOffered, type OwnerGpuView, type TestProvider } from "./connections";import type { ElementKind, StudioElement } from "./catalog/elements";import type { Engine, Generation, GenerationRequest, MediaKind, ReviewStatus } from "./catalog/types";import {@@ -29,7 +29,7 @@ import { cursorAfter, filterToSearch, type AssetUse, type FeedFilter, type Foldeimport { markRefusalShown, responseError } from "./refusals";import { postFile } from "./upload";import type { ShareCreated, ShareInfo, ShareListItem, SharePatch, ShareRequest } from "./share";-import { offered, type AccessSummary } from "./model-access";+import type { AccessSummary } from "./model-access";import { ADD_KEY_HEADER, isCloudProvider, type CloudProvider } from "./your-keys";import { BILLING_EVENT, BILLING_HEADER, type BillingAction, type BillingRefusalDetail, type HostedBalance } from "./hosted";@@ -1057,7 +1057,7 @@ export function useEngine(): [Engine, (e: Engine) => void, EngineMode] {export function useOpenEngine(): boolean {const hydrated = useHydrated();const status = useStatus().data;- return hydrated && openEngineReady(status) && offered(status?.access, "oss-idol", "open");+ return hydrated && make3dOffered(status);}/** Remember the engine the studios start on, before the mode allows it (an account that just added its own key: Cloud). */diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.tsindex 6f569b6a..37fc9116 100644--- a/src/lib/av/model3d.ts+++ b/src/lib/av/model3d.ts@@ -478,12 +478,6 @@ export function retextureRequest(o: { glb: string; prompt?: string; style?: stri};}-/**- * What an Image to 3D link asks for: ?model= (⌘K, Make it 3D) picks a model, its mode and its engine; ?model=meshy-rigging- * says where Rig & animate is; else ?mode= picks a mode. ?quality= is Idol 3D's Best or Quick look, ?image= a picture for- * the photo slot (a file Fuobe keeps, or an https link), and ?photo=1 says it is a photo (an upload), so Idol's looser- * photo crop starts on; a picture handed over from a result starts with it off (idol-5).- *//** What Make it 3D (quick) on an image result does: shown in the studio with the picture handed over (never "2 s"). */export const MAKE_3D_HINT = "Turns this picture into a 3D splat on your GPU and renders a turning preview. Takes tens of seconds on a consumer GPU.";@@ -496,6 +490,25 @@ export interface Model3dLink {photo?: boolean;}+/**+ * The photo slot's value for a picture handed over in an Image to 3D link: a result made here (so Idol's photo crop+ * starts off), or an upload with ?photo=1 (crop on).+ */+export function linkedPicture(url: string, asPhoto: boolean): { id: string; ref: string; preview: string; kind: "image"; source: "upload" | "generation" } {+ return { id: "link", ref: url, preview: url, kind: "image", source: asPhoto ? "upload" : "generation" };+}++/** Idol 3D's look per `${mode}:${engine}` after a link's ?quality=: set only when the linked model is Idol 3D. */+export function linkedIdolQuality(prev: Record<string, IdolQuality>, mode: Model3dMode, engine: Engine, id: string, quality?: IdolQuality): Record<string, IdolQuality> {+ return quality && isIdol(id) ? { ...prev, [`${mode}:${engine}`]: quality } : prev;+}++/**+ * What an Image to 3D link asks for: ?model= (⌘K, Make it 3D) picks a model, its mode and its engine; ?model=meshy-rigging+ * says where Rig & animate is; else ?mode= picks a mode. ?quality= is Idol 3D's Best or Quick look, ?image= a picture for+ * the photo slot (a file Fuobe keeps, or an https link), and ?photo=1 says it is a photo (an upload), so Idol's looser+ * photo crop starts on; a picture handed over from a result starts with it off (idol-5).+ */export function readModel3dLink(sp: Pick<URLSearchParams, "get">): Model3dLink {const id = sp.get("model");const mode = sp.get("mode");diff --git a/src/lib/connections.ts b/src/lib/connections.tsindex f2a14c9f..488dd2af 100644--- a/src/lib/connections.ts+++ b/src/lib/connections.ts@@ -4,6 +4,7 @@* address looks like, when to offer the first-run guide, and each connection's one-line status.*/import { LLM_PROVIDERS } from "./catalog/llm-providers";+import { offered, type AccessSummary } from "./model-access";export type TestProvider = "fal" | "replicate" | "comfyui" | "llm" | "civitai" | "huggingface" | "ai-toolkit";@@ -205,6 +206,14 @@ export function openEngineReady(s: (ConnectionState & { viewer?: unknown }) | unreturn s.demoMode === "on" || !!s.providers.comfyui?.configured || !!s.ownerGpu;}+/**+ * Whether an image result offers Make it 3D (quick): the open engine can run for the owner (openEngineReady) and Idol 3D+ * is switched on for it in Settings → Models & licences.+ */+export function make3dOffered(s: (ConnectionState & { viewer?: unknown; access?: AccessSummary }) | undefined): boolean {+ return openEngineReady(s) && offered(s?.access, "oss-idol", "open");+}+/** Nothing this install's engine mode uses is connected, so a run asks to connect one (or makes a placeholder, for a tour). */export function nothingConnected(s: ConnectionState): boolean {const c = connectedEngines(s);diff --git a/tests/make-3d.test.ts b/tests/make-3d.test.tsindex 7678ff39..7c8b39b3 100644--- a/tests/make-3d.test.ts+++ b/tests/make-3d.test.ts@@ -1,8 +1,8 @@import { describe, expect, it } from "vitest";import type { Generation } from "@/lib/catalog/types";import { make3dHref, nextSteps, outputActions } from "@/lib/output-actions";-import { MAKE_3D_HINT, idolPhotoFor, readModel3dLink } from "@/lib/av/model3d";-import { openEngineReady } from "@/lib/connections";+import { MAKE_3D_HINT, idolPhotoFor, linkedIdolQuality, linkedPicture, readModel3dLink } from "@/lib/av/model3d";+import { make3dOffered, openEngineReady } from "@/lib/connections";/*** Make it 3D (quick) on image results (idol-5, docs/research/idol-9.md §8, §9): a menu action that opens Image to 3D →@@ -152,3 +152,44 @@ describe("openEngineReady", () => {expect(openEngineReady(s({ demoMode: "on", viewer: { kind: "guest" } }))).toBe(false);});});++describe("make3dOffered", () => {+ const ready = { providers: { comfyui: { configured: true } }, engineMode: "both" as const };+ it("follows openEngineReady when every model is on", () => {+ expect(make3dOffered(ready)).toBe(true);+ expect(make3dOffered({ ...ready, access: { off: [] } })).toBe(true);+ expect(make3dOffered(undefined)).toBe(false);+ expect(make3dOffered({ ...ready, engineMode: "cloud" })).toBe(false);+ expect(make3dOffered({ ...ready, viewer: { kind: "account" } })).toBe(false);+ });+ it("is hidden when Idol 3D is switched off in Settings, or switched on for the cloud only", () => {+ expect(make3dOffered({ ...ready, access: { off: ["oss-idol"] } })).toBe(false);+ expect(make3dOffered({ ...ready, access: { off: [], engines: { "oss-idol": ["cloud"] } } })).toBe(false);+ expect(make3dOffered({ ...ready, access: { off: [], engines: { "oss-idol": ["open"] } } })).toBe(true);+ expect(make3dOffered({ ...ready, access: { off: ["oss-trellis2"] } })).toBe(true);+ });+});++describe("the studio's hand-over from a link", () => {+ it("puts a result's picture in the photo slot with the photo crop off, an upload's with it on", () => {+ const url = "/api/files/abc.png";+ const result = linkedPicture(url, false);+ expect(result).toMatchObject({ ref: url, preview: url, kind: "image", source: "generation" });+ expect(idolPhotoFor(result, null)).toBe(false);+ const upload = linkedPicture(url, true);+ expect(upload.source).toBe("upload");+ expect(idolPhotoFor(upload, null)).toBe(true);+ });+ it("sets Idol 3D's look for the linked mode and engine only, and only for Idol", () => {+ const prev = { "splat:cloud": "best" as const };+ expect(linkedIdolQuality(prev, "splat", "open", "oss-idol", "quick")).toEqual({ "splat:cloud": "best", "splat:open": "quick" });+ expect(linkedIdolQuality(prev, "splat", "open", "oss-idol")).toBe(prev);+ expect(linkedIdolQuality(prev, "image", "open", "oss-trellis2", "quick")).toBe(prev);+ });+ it("reads a Make it 3D link into exactly that state", () => {+ const link = readModel3dLink(new URLSearchParams(make3dHref("/api/files/abc.png").split("?")[1]));+ expect(link.model).toEqual({ mode: "splat", engine: "open", id: "oss-idol" });+ expect(linkedIdolQuality({}, link.model!.mode, link.model!.engine, link.model!.id, link.quality)).toEqual({ "splat:open": "quick" });+ expect(linkedPicture(link.image!, !!link.photo).source).toBe("generation");+ });+});