Skip to content

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.

fix(create-3d): the Detail step follows the price, not the schema's order

purpleb07a5f25daa0
diff --git a/src/lib/three/__tests__/three-d-wave2.test.ts b/src/lib/three/__tests__/three-d-wave2.test.ts
index d9c07e54..0241cc91 100644
--- a/src/lib/three/__tests__/three-d-wave2.test.ts
+++ b/src/lib/three/__tests__/three-d-wave2.test.ts
@@ -81,3 +81,18 @@ describe('3D, second cloud wave', () => {
expect(studioCredits('meshy-7.1-image', studioOptions('meshy-7.1-image', '', { should_texture: false }, false))).toBe(80_000)
})
})
+
+describe('the Detail step follows the price, whatever order the schema lists', () => {
+ it('Tripo: Draft is the plain texture, Fine the 8K one, never the quick one', () => {
+ for (const id of ['tripo-h3.1-image', 'tripo-p1-image', 'tripo-p2-text']) {
+ const f = threeDDetailField(id)!
+ expect(f.values, id).toEqual({ draft: 'standard', standard: 'standard', fine: 'extreme' })
+ }
+ })
+
+
+ it('TRELLIS.2 keeps its resolutions in order', () => {
+ const f = threeDDetailField('trellis-2')!
+ expect(Number(f.values.draft)).toBeLessThan(Number(f.values.fine))
+ })
+})
diff --git a/src/lib/three/three-d-models.ts b/src/lib/three/three-d-models.ts
index 9ed8f73a..98d1884d 100644
--- a/src/lib/three/three-d-models.ts
+++ b/src/lib/three/three-d-models.ts
@@ -38,13 +38,29 @@ export function threeDDetailField(studioId: string | undefined): { field: string
const field = m.price.resolutionField ?? (m.price.rates && Object.keys(m.price.rates).length > 1 ? 'resolution' : undefined)
if (!field) return null
let choices: unknown[] | undefined
+ let fallback: unknown
try {
- choices = studioSchema(studioId!).properties?.[field]?.enum
+ const prop = studioSchema(studioId!).properties?.[field]
+ choices = prop?.enum
+ fallback = prop?.default
} catch {
return null
}
if (!choices || choices.length < 2) return null
- const mid = choices[Math.floor((choices.length - 1) / 2)]
+ // A schema lists its choices in any order (Tripo: standard, detailed,
+ // extreme, fast; Meshy: texture on, off). When the price runs over the
+ // field, cheapest is Draft and dearest is Fine; of equal prices the first
+ // listed stays. Standard is the model's own default, else the middle one.
+ const rates = m.price.rates ?? {}
+ const priced = choices.every((c) => typeof rates[String(c)] === 'number')
+ if (priced) {
+ const seen = new Set<number>()
+ choices = [...choices]
+ .sort((a, b) => rates[String(a)] - rates[String(b)])
+ .filter((c) => (seen.has(rates[String(c)]) ? false : (seen.add(rates[String(c)]), true)))
+ if (choices.length < 2) return null
+ }
+ const mid = priced && choices.includes(fallback) ? fallback : choices[Math.floor((choices.length - 1) / 2)]
return { field, values: { draft: choices[0], standard: mid, fine: choices[choices.length - 1] } }
}