The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(create-3d): pick the local 3D model on a Mac, licence before the setup
purple8d918839c468
diff --git a/src/api/mlx-3d.ts b/src/api/mlx-3d.tsindex de02336d..cb541f06 100644--- a/src/api/mlx-3d.ts+++ b/src/api/mlx-3d.ts@@ -6,11 +6,12 @@* Public API, for `useCreate.ts`:** getMesh3dStatus() -> Mesh3dStatus installed, running, model card- * installMesh3d() -> starts engine + source + weights, one slot+ * installMesh3d(model?) -> starts engine + source + weights, one slot+ * for every model ('triposr' or 'sf3d')* getMesh3dInstallStatus() -> MlxInstallStatus (poll like the music install)* cancelMesh3dInstall() -> stops it; what was fetched stays- * deleteMesh3dModel() -> removes the weights, the engine stays- * generateMesh3d({ run, imagePath, resolution?, cutout? }) -> Mesh3dStarted+ * deleteMesh3dModel(model?) -> removes the weights, the engine stays+ * generateMesh3d({ run, imagePath, model?, resolution?, texture?, cutout? }) -> Mesh3dStarted* getMesh3dProgress() -> Mesh3dProgress (phase, percent, error, ...)* cancelMesh3d(run) -> ends that run and its process*@@ -33,9 +34,10 @@import { invokeMedia } from './mlx-invoke'import type { MlxInstallStatus } from './mlx-image'import { MESH3D_NO_OBJECT, mesh3dRunLine } from '../lib/mac-3d'+import type { Mac3dModelId } from '../lib/mac-3d'-export { MAC_3D_MODEL_ID, MAC_3D_MODEL_NAME, MAC_3D_RESOLUTION, MESH3D_PHASE_TEXT, mac3dResolution, mesh3dRunLine } from '../lib/mac-3d'-export type { Mac3dDetail, Mesh3dPhase } from '../lib/mac-3d'+export { MAC_3D_MODEL_ID, MAC_3D_MODEL_NAME, MAC_3D_MODELS, MAC_3D_RESOLUTION, MAC_3D_TEXTURE, MESH3D_PHASE_TEXT, mac3dModel, mac3dResolution, mac3dTexture, mesh3dRunLine } from '../lib/mac-3d'+export type { Mac3dDetail, Mac3dModelId, Mesh3dPhase } from '../lib/mac-3d'/** The one catalogue entry, in the fields `mesh3d_status` sends. */export interface Mesh3dModel {@@ -47,6 +49,15 @@ export interface Mesh3dModel {unfiltered: booleandescription: stringinstalled: boolean+ /** Stable Fast 3D: the weights are gated on Hugging Face. */+ gated?: boolean+ /** Whether a Hugging Face token is stored (gated models only). */+ hasToken?: boolean+ license?: string+ /** The licence in a few plain sentences, shown before the setup. */+ licenseText?: string+ /** The model's page, where the licence is accepted. */+ licenseUrl?: string}export interface Mesh3dStatus {@@ -58,7 +69,17 @@ export interface Mesh3dStatus {installed: booleanrunning: booleanoutputsRoot: string+ /** TripoSR, as before the second model. */model: Mesh3dModel+ /** Every model of the lane, each with its own setup. */+ models?: Mesh3dModel[]+ /** The model the install slot works or worked on. */+ installing?: string | null+}++/** The card of one model out of a status answer. TripoSR's is `model`. */+export function mesh3dModelOf(status: Mesh3dStatus, id: Mac3dModelId): Mesh3dModel | null {+ return status.models?.find((m) => m.id === id) ?? (status.model?.id === id ? status.model : null)}export interface Mesh3dProgress {@@ -87,7 +108,12 @@ export interface Mesh3dProgress {export interface Mesh3dRequest {/** A picture staged by Create. */imagePath: string+ /** TripoSR when left out. */+ model?: Mac3dModelId+ /** TripoSR's grid side. */resolution?: number+ /** Stable Fast 3D's texture side. */+ texture?: numbercutout?: boolean}@@ -96,7 +122,9 @@ export interface Mesh3dStarted {jobId: stringrun: stringoutput: string+ model?: Mac3dModelIdresolution: number+ texture?: numbercutout: boolean}@@ -104,8 +132,8 @@ export async function getMesh3dStatus(): Promise<Mesh3dStatus> {return invokeMedia<Mesh3dStatus>('mlx_mesh3d_status')}-export async function installMesh3d(): Promise<{ ok: boolean; status: string; id?: string }> {- return invokeMedia('mlx_mesh3d_install')+export async function installMesh3d(model: Mac3dModelId = 'triposr'): Promise<{ ok: boolean; status: string; id?: string }> {+ return invokeMedia('mlx_mesh3d_install', { model })}export async function getMesh3dInstallStatus(): Promise<MlxInstallStatus> {@@ -116,13 +144,15 @@ export async function cancelMesh3dInstall(): Promise<{ ok: boolean; cancelled: breturn invokeMedia('mlx_mesh3d_cancel_install')}-export async function deleteMesh3dModel(): Promise<{ ok: boolean; id: string }> {- return invokeMedia('mlx_mesh3d_delete')+export async function deleteMesh3dModel(model: Mac3dModelId = 'triposr'): Promise<{ ok: boolean; id: string }> {+ return invokeMedia('mlx_mesh3d_delete', { model })}export async function generateMesh3d(request: Mesh3dRequest & { run: string }): Promise<Mesh3dStarted> {const args: Record<string, unknown> = { run: request.run, imagePath: request.imagePath }+ if (request.model !== undefined) args.model = request.modelif (request.resolution !== undefined) args.resolution = request.resolution+ if (request.texture !== undefined) args.texture = request.textureif (request.cutout !== undefined) args.cutout = request.cutoutreturn invokeMedia<Mesh3dStarted>('mlx_mesh3d_generate', args)}diff --git a/src/components/create/experimental/ModelChip.tsx b/src/components/create/experimental/ModelChip.tsxindex 354bab82..c639fcd5 100644--- a/src/components/create/experimental/ModelChip.tsx+++ b/src/components/create/experimental/ModelChip.tsx@@ -1,4 +1,5 @@-import { MAC_3D_MODEL, PC_3D_MODEL } from '../../../lib/three/run-local-3d'+import { PC_3D_MODEL } from '../../../lib/three/run-local-3d'+import { MAC_3D_MODELS } from '../../../lib/mac-3d'import { useCreateStore } from '../../../stores/createStore'import {useCloudCatalogStore, cloudModelById, defaultCloudModel, opPickerModels, modelCostHint, shortCount,@@ -74,14 +75,15 @@ export function ModelChip() {const backend = useCreateStore((s) => s.backend)const intent = useCreateStore((s) => s.intent())if (backend === 'cloud') return <CloudModelChip />- // Local 3D has one model per machine (TripoSR on a Mac, TRELLIS.2 in- // ComfyUI): it is named, there is nothing to pick.+ // Local 3D: on a Mac a pick of its own models (TripoSR, Stable Fast 3D),+ // each with its own setup; in ComfyUI the one model, TRELLIS.2, named.if (intent === '3d') return <LocalThreeDChip />return <LocalModelChip />}function LocalThreeDChip() {- const name = isMlxImageHost() ? MAC_3D_MODEL : PC_3D_MODEL+ if (isMlxImageHost()) return <MacThreeDPicker />+ const name = PC_3D_MODELreturn (<spanclassName="inline-flex items-center gap-1.5 h-[var(--control-h-md)] px-3 rounded-lg border border-white/[0.08] t-control text-gray-300"@@ -93,6 +95,32 @@ function LocalThreeDChip() {)}+/** The local 3D models of a Mac. Picking one that is not set up shows its+ * setup card on the Stage (ThreeDStage), with the licence where it has one. */+function MacThreeDPicker() {+ const value = useCreateStore((s) => s.threeDMacModel)+ const setModel = useCreateStore((s) => s.setThreeDMacModel)+ const options: SelectOption[] = MAC_3D_MODELS.map((m) => ({+ value: m.id,+ label: m.name,+ sublabel: m.line,+ title: `${m.name} on this Mac`,+ }))+ return (+ <span data-testid="model-chip-3d-mac">+ <Select+ size="sm"+ align="right"+ className="min-w-[150px] max-w-[230px]"+ options={options}+ value={value}+ onChange={(v) => setModel(v === 'sf3d' ? 'sf3d' : 'triposr')}+ ariaLabel="3D model"+ />+ </span>+ )+}+function CloudModelChip() {const mode = useCreateStore((s) => s.mode)const intent = useCreateStore((s) => s.intent())diff --git a/src/components/create/experimental/ThreeDStage.tsx b/src/components/create/experimental/ThreeDStage.tsxindex 159aa19c..60e6167d 100644--- a/src/components/create/experimental/ThreeDStage.tsx+++ b/src/components/create/experimental/ThreeDStage.tsx@@ -2,13 +2,20 @@// one-time setup of the local engine, and the hint for a video.//// Local 3D has its own setup, not the starter-bundle gate of requiresModels:-// on a Mac it is an engine of its own (TripoSR, commands/mesh3d.rs, through+// on a Mac it is an engine of its own per model (TripoSR in+// commands/mesh3d.rs, Stable Fast 3D in commands/mesh3d_sf3d.rs, through// api/mlx-3d.ts), on Windows and Linux a ComfyUI bundle (TRELLIS.2,-// lib/local-3d-comfy.ts).+// lib/local-3d-comfy.ts). A model with a licence to accept (Stable Fast 3D)+// says it on the card before anything is downloaded.import { useCallback, useEffect, useRef, useState } from 'react'import { Box, Film } from 'lucide-react'import { isMlxImageHost } from '../../../api/mlx-image'+import { openExternal } from '../../../api/backend'+import type { Mesh3dModel } from '../../../api/mlx-3d'+import { mac3dModel } from '../../../lib/mac-3d'import { THREE_D_TEXT as T } from '../../../lib/three/three-d-text'+import { useCreateStore } from '../../../stores/createStore'+import { useUIStore } from '../../../stores/uiStore'import { useCreateExp } from './CreateContext'import { Button } from '../ui/Button'@@ -17,6 +24,11 @@ export const SETUP_TEXT = {macBody: 'This sets up the 3D engine and the TripoSR model, about 1.7 GB. It turns one picture into a 3D model on this Mac. Local 3D is never filtered.',pcTitle: 'Local 3D needs a one-time download',pcBody: 'This sets up ComfyUI itself if it is missing, plus the TRELLIS.2 model files, about 9 GB. Local 3D is never filtered.',+ sf3dTitle: 'Stable Fast 3D needs a one-time download',+ sf3dBody: 'This sets up its own 3D engine and the Stable Fast 3D model, about 4 GB. It turns one picture into a 3D model with a painted texture, on this Mac.',+ licenseLink: 'Open the model page',+ tokenNeeded: 'Add your Hugging Face token first. Accept the licence on the model page with the same account.',+ tokenButton: 'Open Settings',install: 'Download & install',cancel: 'Cancel',checking: 'Checking for the 3D engine…',@@ -25,6 +37,8 @@ export const SETUP_TEXT = {export interface ThreeDSetup {/** null while the check runs. */ready: boolean | null+ /** The Mac model the card is for, with its licence when it has one. */+ card: Mesh3dModel | nullneedsSetup: booleaninstalling: booleanline: string | null@@ -37,8 +51,10 @@ export interface ThreeDSetup {* set it up. Asks nothing while `active` is false. */export function useThreeDLocal(active: boolean): ThreeDSetup {const mac = isMlxImageHost()+ const macModel = mac3dModel(useCreateStore((s) => s.threeDMacModel)).idconst { installModelBundle } = useCreateExp()const [ready, setReady] = useState<boolean | null>(null)+ const [card, setCard] = useState<Mesh3dModel | null>(null)const [installing, setInstalling] = useState(false)const [line, setLine] = useState<string | null>(null)const [error, setError] = useState<string | null>(null)@@ -47,20 +63,23 @@ export function useThreeDLocal(active: boolean): ThreeDSetup {const check = useCallback(async () => {try {if (mac) {- const { getMesh3dStatus } = await import('../../../api/mlx-3d')+ const { getMesh3dStatus, mesh3dModelOf } = await import('../../../api/mlx-3d')const st = await getMesh3dStatus()- return !!st.installed+ const model = mesh3dModelOf(st, macModel)+ setCard(model)+ return !!model?.installed}const { comfyThreeDReady } = await import('../../../lib/local-3d-comfy')return await comfyThreeDReady()} catch {return false}- }, [mac])+ }, [mac, macModel])useEffect(() => {if (!active) returnlet alive = true+ setReady(null)void check().then((ok) => { if (alive) setReady(ok) })return () => { alive = false }}, [active, check])@@ -75,7 +94,7 @@ export function useThreeDLocal(active: boolean): ThreeDSetup {try {if (mac) {const api = await import('../../../api/mlx-3d')- await api.installMesh3d()+ await api.installMesh3d(macModel)for (;;) {if (controller.signal.aborted) {await api.cancelMesh3dInstall().catch(() => undefined)@@ -99,11 +118,11 @@ export function useThreeDLocal(active: boolean): ThreeDSetup {abort.current = null}})()- }, [installing, mac, check, installModelBundle])+ }, [installing, mac, macModel, check, installModelBundle])const cancel = useCallback(() => abort.current?.abort(), [])- return { ready, needsSetup: active && ready === false, installing, line, error, install, cancel }+ return { ready, card, needsSetup: active && ready === false, installing, line, error, install, cancel }}function installLine(st: { status: string; download_progress?: number; download_total?: number; logs?: string[] }): string | null {@@ -116,18 +135,40 @@ function installLine(st: { status: string; download_progress?: number; download_export function ThreeDSetupCard({ setup }: { setup: ThreeDSetup }) {const mac = isMlxImageHost()+ const openSettingsAt = useUIStore((s) => s.openSettingsAt)+ const gated = mac && !!setup.card?.gated+ const title = !mac ? SETUP_TEXT.pcTitle : gated ? SETUP_TEXT.sf3dTitle : SETUP_TEXT.macTitle+ const body = !mac ? SETUP_TEXT.pcBody : gated ? SETUP_TEXT.sf3dBody : SETUP_TEXT.macBody+ const tokenMissing = gated && !setup.card?.hasToken+ const licenseUrl = setup.card?.licenseUrlreturn (<div className="m-auto flex flex-col items-center gap-3 max-w-[440px] text-center p-6" data-testid="three-d-setup"><Box size={30} className="text-gray-400" />- <h3 className="t-title text-gray-100">{mac ? SETUP_TEXT.macTitle : SETUP_TEXT.pcTitle}</h3>- <p className="t-body text-gray-400">{mac ? SETUP_TEXT.macBody : SETUP_TEXT.pcBody}</p>+ <h3 className="t-title text-gray-100">{title}</h3>+ <p className="t-body text-gray-400">{body}</p>+ {gated && setup.card?.licenseText && (+ <div className="flex flex-col items-center gap-1.5 rounded-lg border border-white/[0.08] px-3 py-2" data-testid="three-d-license">+ <p className="t-meta text-gray-400 text-left">{setup.card.licenseText}</p>+ {licenseUrl && (+ <button type="button" className="t-meta text-gray-300 underline" onClick={() => void openExternal(licenseUrl)}>+ {SETUP_TEXT.licenseLink}+ </button>+ )}+ </div>+ )}+ {tokenMissing && !setup.installing && (+ <>+ <p className="t-meta text-gray-300" data-testid="three-d-token-needed">{SETUP_TEXT.tokenNeeded}</p>+ <Button variant="secondary" onClick={() => openSettingsAt({ tab: 'backends' })}>{SETUP_TEXT.tokenButton}</Button>+ </>+ )}{setup.installing ? (<><p className="t-meta text-gray-300" data-testid="three-d-setup-line">{setup.line ?? T.phases.ready}</p><Button variant="secondary" onClick={setup.cancel}>{SETUP_TEXT.cancel}</Button></>) : (- <Button variant="primary" onClick={setup.install} data-testid="three-d-setup-install">{SETUP_TEXT.install}</Button>+ <Button variant="primary" onClick={setup.install} disabled={tokenMissing} data-testid="three-d-setup-install">{SETUP_TEXT.install}</Button>)}{setup.error && <p className="t-meta text-red-300" role="alert">{setup.error}</p>}</div>diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.tsindex b4492533..fb41e3d7 100644--- a/src/hooks/useCreate.ts+++ b/src/hooks/useCreate.ts@@ -1,7 +1,7 @@import { useState, useCallback, useRef, useEffect } from 'react'import { blobFromUrl } from '../lib/render/data-url'import { THREE_D_TEXT } from '../lib/three/three-d-text'-import { MAC_3D_MODEL, PC_3D_MODEL, threeDGalleryItem, threeDPicturePrompt, threeDProvenance } from '../lib/three/run-local-3d'+import { PC_3D_MODEL, threeDGalleryItem, threeDPicturePrompt, threeDProvenance } from '../lib/three/run-local-3d'import { coverCropBlob } from '../lib/cover-crop'import { videoRunGivenUp, videoRunProgress, videoRunStatus } from '../lib/mlx-video-progress'import { featherMaskBlob } from '../lib/mask-feather'@@ -212,13 +212,16 @@ async function runLocalThreeD(state: CreateState, seed: number, abortRef: { currif (mac) {const api = await import('../api/mlx-3d')const staged = source.filename || await stageStartImage(await blobFromUrl(source.url))+ const macModel = api.mac3dModel(state.threeDMacModel)const made = await api.runMacMesh3d(- { imagePath: staged, resolution: api.mac3dResolution(state.threeDDetail), cutout: state.threeDCutout },+ macModel.id === 'sf3d'+ ? { imagePath: staged, model: 'sf3d', texture: api.mac3dTexture(state.threeDDetail), cutout: state.threeDCutout }+ : { imagePath: staged, resolution: api.mac3dResolution(state.threeDDetail), cutout: state.threeDCutout },{ signal: own.signal, onProgress: (percent, text) => onProgress(percent, text) },)if (own.signal.aborted) returnaddToGallery(threeDGalleryItem({- id: uuid(), way, model: MAC_3D_MODEL, prompt, seed, localPath: made.path, sourceName: source.name,+ id: uuid(), way, model: macModel.name, prompt, seed, localPath: made.path, sourceName: source.name,}))} else {const { runComfyThreeD } = await import('../lib/local-3d-comfy')diff --git a/src/lib/__tests__/mac-3d.test.ts b/src/lib/__tests__/mac-3d.test.tsindex e0db1f1e..9cb87fd6 100644--- a/src/lib/__tests__/mac-3d.test.ts+++ b/src/lib/__tests__/mac-3d.test.ts@@ -38,10 +38,12 @@ import {cancelMesh3dInstall,deleteMesh3dModel,cancelMesh3d,+ mesh3dModelOf,+ type Mesh3dStatus,Mesh3dRunCancelled,Mesh3dNoObject,} from '../../api/mlx-3d'-import { mesh3dRunLine, mac3dResolution, MESH3D_PHASE_TEXT, MAC_3D_MODEL_NAME, MESH3D_NO_OBJECT } from '../mac-3d'+import { mesh3dRunLine, mac3dResolution, mac3dTexture, mac3dModel, MAC_3D_MODELS, MESH3D_PHASE_TEXT, MAC_3D_MODEL_NAME, MESH3D_NO_OBJECT } from '../mac-3d'function poll(status: string, extra: Record<string, unknown> = {}) {return { job: 'j1', run: 'r', status, phase: 'shape', detail: '', percent: 40, error: null, errorCode: null, output: '/c/3d/r.glb', triangles: null, vertices: null, device: 'mps', logs: [], running: status === 'running', pid: 7, ...extra }@@ -112,6 +114,12 @@ describe('the commands', () => {const names = rust.calls.map((c) => c.cmd)expect(names).toEqual(['mlx_mesh3d_status', 'mlx_mesh3d_install', 'mlx_mesh3d_install_status', 'mlx_mesh3d_cancel_install', 'mlx_mesh3d_delete', 'mlx_mesh3d_cancel'])expect(rust.calls.at(-1)!.args).toEqual({ run: 'r9' })+ // Install and remove name their model; TripoSR when the caller names none.+ expect(rust.calls[1].args).toEqual({ model: 'triposr' })+ expect(rust.calls[4].args).toEqual({ model: 'triposr' })+ await installMesh3d('sf3d')+ await deleteMesh3dModel('sf3d')+ expect(rust.calls.slice(-2).map((c) => c.args)).toEqual([{ model: 'sf3d' }, { model: 'sf3d' }])const media = readFileSync(join(__dirname, '../../../src-tauri/src/commands/media_cmds.rs'), 'utf8')const lib = readFileSync(join(__dirname, '../../../src-tauri/src/lib.rs'), 'utf8')for (const name of [...names, 'mlx_mesh3d_generate', 'mlx_mesh3d_progress']) {@@ -125,6 +133,39 @@ describe('the commands', () => {expect(rust.calls[0].args).toEqual({ run: 'r', imagePath: '/s/start-images/a.png' })await generateMesh3d({ run: 'r', imagePath: '/s/a.png', resolution: 128, cutout: false })expect(rust.calls[1].args).toEqual({ run: 'r', imagePath: '/s/a.png', resolution: 128, cutout: false })+ await generateMesh3d({ run: 'r', imagePath: '/s/a.png', model: 'sf3d', texture: 2048 })+ expect(rust.calls[2].args).toEqual({ run: 'r', imagePath: '/s/a.png', model: 'sf3d', texture: 2048 })+ })+})++describe('the models of the lane', () => {+ it('lists TripoSR first and Stable Fast 3D as gated, under the ids and names Rust uses', () => {+ expect(MAC_3D_MODELS.map((m) => m.id)).toEqual(['triposr', 'sf3d'])+ expect(MAC_3D_MODELS.map((m) => m.gated)).toEqual([false, true])+ expect(mac3dModel('sf3d').name).toBe('Stable Fast 3D')+ expect(mac3dModel('nonsense').id).toBe('triposr')+ expect(mac3dModel(undefined).id).toBe('triposr')+ const rs = readFileSync(join(__dirname, '../../../src-tauri/src/commands/mesh3d_sf3d.rs'), 'utf8')+ expect(rs).toContain('pub(crate) const MODEL_ID: &str = "sf3d";')+ expect(rs).toContain(`pub(crate) const MODEL_NAME: &str = "${mac3dModel('sf3d').name}";`)+ for (const m of MAC_3D_MODELS) {+ expect(m.line).not.toMatch(new RegExp(`[${String.fromCharCode(0x2013, 0x2014)}]| - `))+ }+ })++ it('maps Detail to the texture sides Rust takes', () => {+ expect([mac3dTexture('draft'), mac3dTexture('standard'), mac3dTexture('fine'), mac3dTexture(undefined)]).toEqual([512, 1024, 2048, 1024])+ const rs = readFileSync(join(__dirname, '../../../src-tauri/src/commands/mesh3d_sf3d.rs'), 'utf8')+ expect(rs).toContain('const TEXTURES: [u32; 3] = [512, 1024, 2048];')+ })++ it('finds a card in the list and TripoSR in the old field', () => {+ const triposr = { id: 'triposr', name: 'TripoSR', installed: true } as Mesh3dStatus['model']+ const sf3d = { id: 'sf3d', name: 'Stable Fast 3D', installed: false, gated: true } as Mesh3dStatus['model']+ const both = { model: triposr, models: [triposr, sf3d] } as Mesh3dStatus+ expect(mesh3dModelOf(both, 'sf3d')?.gated).toBe(true)+ expect(mesh3dModelOf({ model: triposr } as Mesh3dStatus, 'triposr')?.installed).toBe(true)+ expect(mesh3dModelOf({ model: triposr } as Mesh3dStatus, 'sf3d')).toBeNull()})})diff --git a/src/lib/mac-3d.ts b/src/lib/mac-3d.tsindex ec1a103a..44a9207f 100644--- a/src/lib/mac-3d.ts+++ b/src/lib/mac-3d.ts@@ -1,14 +1,45 @@-// The 3D lane on a Mac, as Create sees it: one model of the 3D engine-// (TripoSR, src-tauri/src/commands/mesh3d.rs). Kept free of imports, so the-// store, the intent rules and the stage can read it without pulling the-// engine's commands along (api/mlx-3d.ts has those).+// The 3D lane on a Mac, as Create sees it: the models of the 3D engine+// (TripoSR in src-tauri/src/commands/mesh3d.rs, Stable Fast 3D in+// mesh3d_sf3d.rs). Kept free of imports, so the store, the intent rules and+// the stage can read it without pulling the engine's commands along+// (api/mlx-3d.ts has those).-/** The name the picker and the gallery give the one model (`MODEL_NAME`). */+/** The name the picker and the gallery give the first model (`MODEL_NAME`). */export const MAC_3D_MODEL_NAME = 'TripoSR'-/** The id of the one model (`MODEL_ID`). */+/** The id of the first model (`MODEL_ID`), the one a run takes when none is named. */export const MAC_3D_MODEL_ID = 'triposr'+export type Mac3dModelId = 'triposr' | 'sf3d'++/** What the picker says about each model before anything is asked of Rust. */+export interface Mac3dModelInfo {+ id: Mac3dModelId+ name: string+ /** One short line for the picker. */+ line: string+ /** The weights are gated: the user accepts a licence and needs a Hugging Face token. */+ gated: boolean+}++/** Every local 3D model of a Mac, in the order the picker shows them. */+export const MAC_3D_MODELS: readonly Mac3dModelInfo[] = [+ { id: 'triposr', name: 'TripoSR', line: 'Fast, colours on the surface. 1.7 GB.', gated: false },+ { id: 'sf3d', name: 'Stable Fast 3D', line: 'Sharper, with a painted texture. 4 GB, needs a Hugging Face token.', gated: true },+]++export function mac3dModel(id: string | null | undefined): Mac3dModelInfo {+ return MAC_3D_MODELS.find((m) => m.id === id) ?? MAC_3D_MODELS[0]+}++/** The texture side of Stable Fast 3D per step of Detail. Rust takes these+ * three (`texture_for` in mesh3d_sf3d.rs). */+export const MAC_3D_TEXTURE = { draft: 512, standard: 1024, fine: 2048 } as const++export function mac3dTexture(detail: keyof typeof MAC_3D_TEXTURE | undefined): number {+ return MAC_3D_TEXTURE[detail ?? 'standard'] ?? MAC_3D_TEXTURE.standard+}+/** The grid side per step of Detail. Rust takes 64 to 384 on steps of 32* (`resolution_for` in mesh3d.rs); 256 is TripoSR's own default. */export const MAC_3D_RESOLUTION = { draft: 128, standard: 256, fine: 384 } as constdiff --git a/src/stores/createStore.ts b/src/stores/createStore.tsindex 8e94bcd8..248f5cc8 100644--- a/src/stores/createStore.ts+++ b/src/stores/createStore.ts@@ -116,6 +116,8 @@ export type CloudOp = 'character' | 'lipsync' | 'music' | 'extend' | 'motion' |export type ThreeDWay = 'text' | 'image' | 'video'/** The Detail step of the 3D tab. Each model maps it onto its own field. */export type ThreeDDetail = 'draft' | 'standard' | 'fine'+/** The local 3D models of a Mac (lib/mac-3d.ts, MAC_3D_MODELS). */+export type ThreeDMacModel = 'triposr' | 'sf3d'/** Which of the specialized categories ALSO run on the local ComfyUI backend* (2.5.8 local lanes: ACE music, Wan S2V talking character, last-frame-chain@@ -446,6 +448,8 @@ export interface CreateState {threeDCutout: boolean/** 3D: how fine the model gets, where the picked model offers a choice. */threeDDetail: ThreeDDetail+ /** 3D on a Mac: which local model makes it. Each has its own setup. */+ threeDMacModel: ThreeDMacModel/** 3D: the further sides (left, back, right) for a model that takes several* views, or the still frames picked from a video. Front is the Stage* source. Runtime-only like every ImageRef. */@@ -730,6 +734,7 @@ export interface CreateState {setThreeDWay: (way: ThreeDWay) => voidsetThreeDCutout: (on: boolean) => voidsetThreeDDetail: (detail: ThreeDDetail) => void+ setThreeDMacModel: (model: ThreeDMacModel) => voidsetThreeDViews: (views: ImageRef[]) => voidaddTrainImages: (imgs: MediaRef[]) => voidremoveTrainImage: (name: string) => void@@ -1227,6 +1232,7 @@ export const useCreateStore = create<CreateState>()(threeDWay: 'image' as ThreeDWay,threeDCutout: true,threeDDetail: 'standard' as ThreeDDetail,+ threeDMacModel: 'triposr' as ThreeDMacModel,threeDViews: [] as ImageRef[],trainImages: [] as MediaRef[],triggerWord: '',@@ -1546,6 +1552,7 @@ export const useCreateStore = create<CreateState>()(setThreeDWay: (threeDWay) => set((s) => withOwnStudioOptions(s, { threeDWay, threeDViews: [] })),setThreeDCutout: (threeDCutout) => set({ threeDCutout }),setThreeDDetail: (threeDDetail) => set({ threeDDetail }),+ setThreeDMacModel: (threeDMacModel) => set({ threeDMacModel }),setThreeDViews: (threeDViews) => set({ threeDViews: threeDViews.slice(0, 4) }),// Cap at the backend's photo limit (lib/train-image-cap) and skip a// re-drop of a file already in the set, so the same folder twice does@@ -2082,6 +2089,7 @@ export const useCreateStore = create<CreateState>()(threeDWay: state.threeDWay,threeDCutout: state.threeDCutout,threeDDetail: state.threeDDetail,+ threeDMacModel: state.threeDMacModel,videoBackend: state.videoBackend,videoBackendInitialized: state.videoBackendInitialized,imageModel: state.imageModel,@@ -2223,6 +2231,7 @@ export const useCreateStore = create<CreateState>()(if ('threeDWay' in safe && !['text', 'image', 'video'].includes(safe.threeDWay as string)) safe.threeDWay = 'image'if ('threeDDetail' in safe && !['draft', 'standard', 'fine'].includes(safe.threeDDetail as string)) safe.threeDDetail = 'standard'if ('threeDCutout' in safe && typeof safe.threeDCutout !== 'boolean') safe.threeDCutout = true+ if ('threeDMacModel' in safe && !['triposr', 'sf3d'].includes(safe.threeDMacModel as string)) safe.threeDMacModel = 'triposr'// The persisted slice is ~30 independent scalar preferences (see// partialize). They are adopted as written, which is what the store// has always done; the fields that could actually do damage — the