mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 15:44:36 +00:00
Adds two new create pages for 3D generation, 3D Object (meshes) and 3D World (gaussian splats), wired up to the new omni-gen mesh/splat endpoints, plus the navigation, icons, and polish to go with them. ### New create pages - 3D Object (`/create-object`): turn a prompt or image into a 3D model. - 3D World (`/create-world`): turn a prompt or image into an explorable world. - Both mirror the existing Create Image/Video experience: prompt box with model selector and per-model options in the bottom bar, and a live feed of in-progress, completed, and failed generations. - Options adapt to the selected model, e.g. output type, polygon type, geometry/texture quality, face count, PBR and texture toggles, multi-view reference angles (front/back/left/right), mesh-file input, reference image/video, panorama, and prompt-only where supported. - Multi-view and reference slots support the same Upload / Pick-from-library flow (desktop hover and mobile) as the image rows. - Completed cards show the model's cover screenshot; clicking one opens it in the interactive 3D viewer. ### Navigation and discovery - Sidebar reorganized into two groups: Create (Image, Video, Audio, 3D Object, 3D World) and a new Studio group (Edit Image, Edit 3D, Edit Video, BG Change, Moodboard). - Added 3D Object and 3D World cards to the Home page. - Added breadcrumbs for the new pages. - Added a My Library button to the top bar, next to the credits and task-queue chips. ### Model icons - Restored the Hunyuan (Tencent) and World Labs provider icons. - Added Tripo, Meshy, and Rodin (Hyper3D) icons. - Applied to both the webapp and desktop app. ### Fixes and polish - Fixed the 3D-model icons showing a generic placeholder (missing cyan color plus creator mappings). - Fixed the Upload / Pick-from-library hover popover being clipped inside glass panels. - Reference-image rows in the 3D pages now align their fields to the right with the title on the left, matching the other create pages. - Prevented 3D-model cover screenshots from showing up as their own "3D object" cards across the 3D feeds, the Library page, and the gallery picker.
170 lines
4.9 KiB
TypeScript
170 lines
4.9 KiB
TypeScript
import { create } from "zustand";
|
|
import { persist } from "zustand/middleware";
|
|
import type { RecreatePayload } from "../../lib/recreate";
|
|
import type { RefImage } from "../../components/prompt-box";
|
|
|
|
// A generated 3D asset (mesh). Shape mirrors the image store's GeneratedImage so
|
|
// the shared polling helpers can be reused; `cdn_url` here is the .glb file.
|
|
export interface GeneratedAsset {
|
|
media_token: string;
|
|
cdn_url: string;
|
|
maybe_thumbnail_template?: string;
|
|
}
|
|
|
|
export type MeshBatch = {
|
|
id: string;
|
|
prompt: string;
|
|
status: "pending" | "complete" | "failed";
|
|
assets: GeneratedAsset[];
|
|
createdAt: number;
|
|
modelLabel: string;
|
|
jobToken?: string;
|
|
failureReason?: string;
|
|
};
|
|
|
|
export type MeshUiState = {
|
|
selectedModelId: string | null;
|
|
prompt: string;
|
|
meshOutputType: string | undefined;
|
|
polygonType: string | undefined;
|
|
faceCount: number | undefined;
|
|
enablePbr: boolean | undefined;
|
|
enableTexture: boolean | undefined;
|
|
textureQuality: string | undefined;
|
|
geometryQuality: string | undefined;
|
|
};
|
|
|
|
// Multi-view side inputs + a mesh-to-mesh input file. Not persisted (File
|
|
// handles + data URLs aren't serializable / can exceed the storage quota).
|
|
export type MeshInputsState = {
|
|
frontImage: RefImage | undefined;
|
|
backImage: RefImage | undefined;
|
|
leftImage: RefImage | undefined;
|
|
rightImage: RefImage | undefined;
|
|
inputMesh: RefImage | undefined;
|
|
};
|
|
|
|
type CreateObjectState = {
|
|
batches: MeshBatch[];
|
|
ui: MeshUiState;
|
|
referenceImages: RefImage[];
|
|
inputs: MeshInputsState;
|
|
pendingRecreate: RecreatePayload | null;
|
|
setUi: (patch: Partial<MeshUiState>) => void;
|
|
setReferenceImages: (images: RefImage[]) => void;
|
|
setInputs: (patch: Partial<MeshInputsState>) => void;
|
|
setPendingRecreate: (payload: RecreatePayload | null) => void;
|
|
consumePendingRecreate: () => RecreatePayload | null;
|
|
startBatch: (prompt: string, modelLabel: string) => string;
|
|
setBatchJobToken: (batchId: string, jobToken: string) => void;
|
|
completeBatch: (batchId: string, assets: GeneratedAsset[]) => void;
|
|
failBatch: (batchId: string, reason?: string) => void;
|
|
dismissBatch: (id: string) => void;
|
|
reset: () => void;
|
|
};
|
|
|
|
const DEFAULT_UI: MeshUiState = {
|
|
selectedModelId: null,
|
|
prompt: "",
|
|
meshOutputType: undefined,
|
|
polygonType: undefined,
|
|
faceCount: undefined,
|
|
enablePbr: undefined,
|
|
enableTexture: undefined,
|
|
textureQuality: undefined,
|
|
geometryQuality: undefined,
|
|
};
|
|
|
|
const DEFAULT_INPUTS: MeshInputsState = {
|
|
frontImage: undefined,
|
|
backImage: undefined,
|
|
leftImage: undefined,
|
|
rightImage: undefined,
|
|
inputMesh: undefined,
|
|
};
|
|
|
|
export const useCreateObjectStore = create<CreateObjectState>()(
|
|
persist(
|
|
(set, get) => ({
|
|
batches: [],
|
|
ui: { ...DEFAULT_UI },
|
|
referenceImages: [],
|
|
inputs: { ...DEFAULT_INPUTS },
|
|
pendingRecreate: null,
|
|
|
|
setUi: (patch) => set((s) => ({ ui: { ...s.ui, ...patch } })),
|
|
|
|
setReferenceImages: (images) => set({ referenceImages: images }),
|
|
|
|
setInputs: (patch) => set((s) => ({ inputs: { ...s.inputs, ...patch } })),
|
|
|
|
setPendingRecreate: (payload) => set({ pendingRecreate: payload }),
|
|
|
|
consumePendingRecreate: () => {
|
|
const payload = get().pendingRecreate;
|
|
if (payload) set({ pendingRecreate: null });
|
|
return payload;
|
|
},
|
|
|
|
startBatch: (prompt, modelLabel) => {
|
|
const id = crypto.randomUUID();
|
|
const batch: MeshBatch = {
|
|
id,
|
|
prompt,
|
|
status: "pending",
|
|
assets: [],
|
|
createdAt: Date.now(),
|
|
modelLabel,
|
|
};
|
|
set((s) => ({ batches: [...s.batches, batch] }));
|
|
return id;
|
|
},
|
|
|
|
setBatchJobToken: (batchId, jobToken) => {
|
|
set((s) => ({
|
|
batches: s.batches.map((b) =>
|
|
b.id === batchId ? { ...b, jobToken } : b,
|
|
),
|
|
}));
|
|
},
|
|
|
|
completeBatch: (batchId, assets) => {
|
|
set((s) => ({
|
|
batches: s.batches.map((b) =>
|
|
b.id === batchId
|
|
? { ...b, status: "complete" as const, assets }
|
|
: b,
|
|
),
|
|
}));
|
|
},
|
|
|
|
failBatch: (batchId, reason) => {
|
|
set((s) => ({
|
|
batches: s.batches.map((b) =>
|
|
b.id === batchId
|
|
? { ...b, status: "failed" as const, failureReason: reason }
|
|
: b,
|
|
),
|
|
}));
|
|
},
|
|
|
|
dismissBatch: (id) => {
|
|
set((s) => ({ batches: s.batches.filter((b) => b.id !== id) }));
|
|
},
|
|
|
|
reset: () => set({ batches: [] }),
|
|
}),
|
|
{
|
|
name: "artcraft-object-prompt",
|
|
// Persist only the lightweight settings; reference images / input files
|
|
// are excluded (not serializable, can exceed the localStorage quota).
|
|
partialize: (state) => ({ ui: state.ui }),
|
|
merge: (persisted, current) => {
|
|
const persistedUi = (persisted as { ui?: Partial<MeshUiState> } | null)
|
|
?.ui;
|
|
return { ...current, ui: { ...current.ui, ...(persistedUi ?? {}) } };
|
|
},
|
|
},
|
|
),
|
|
);
|