Sample Klein edits from source and bind Studio 2 extensions correctly
This commit is contained in:
@@ -7,21 +7,28 @@ export function resolveSize(aspect, source, fallback = {width:1344,height:768})
|
||||
const factor = Math.min(1344/Math.max(source.width,source.height),768/Math.min(source.width,source.height))
|
||||
return {width:Math.max(256,Math.round(source.width*factor/32)*32),height:Math.max(256,Math.round(source.height*factor/32)*32)}
|
||||
}
|
||||
export function bindClip(form, clip) {
|
||||
export function bindClip(form, clip, xaigen = false) {
|
||||
if (!clip?.id) return form
|
||||
const saved = clip.studio2 || {}, settings = saved.settings || clip.settings || clip
|
||||
const saved = clip.studio2 || clip.job || {}, settings = saved.settings || clip.settings || clip
|
||||
const next = {...form, startClipId:clip.id, settings:{...form.settings}}
|
||||
next.settings.aspect=['auto','16:9','9:16','1:1'].includes(settings.aspect)?settings.aspect:'auto'
|
||||
for (const key of ['duration','aspect','width','height','fps','loraStack','turbo','steps','cfg']) {
|
||||
if (settings[key] != null && key!=='aspect') next.settings[key] = structuredClone(settings[key])
|
||||
}
|
||||
next.engine = saved.engine || clip.engine || 'minimax'
|
||||
next.engine = xaigen && (saved.engine || clip.engine)==='ltx' ? 'ltx' : 'minimax'
|
||||
if (saved.identityStillId) next.identityStillId = saved.identityStillId
|
||||
// Missing legacy metadata must not reset a user's current choice.
|
||||
for (const key of ['lockFace','lockOutfit']) if (typeof saved[key] === 'boolean') next[key] = saved[key]
|
||||
return next
|
||||
}
|
||||
export function restoreAsset(form, item) {
|
||||
if (item.kind==='clip' || item.studio2?.kind==='video') {
|
||||
const next=bindClip(form,item,form.engine==='ltx')
|
||||
const seed=item.studio2?.settings?.seed ?? item.settings?.seed ?? item.seed
|
||||
if (seed != null) next.settings.seed=seed
|
||||
next.settings.seedMode='random'
|
||||
return {...next,mode:'extend'}
|
||||
}
|
||||
const restored = restoreInput(item)
|
||||
const next = {...form,...restored,settings:{...form.settings,...restored.settings}}
|
||||
next.settings.seedMode='random'
|
||||
@@ -31,7 +38,11 @@ export function restoreAsset(form, item) {
|
||||
next.settings.aspect=item.studio2?.settings?.aspect || item.settings?.aspect || 'auto'
|
||||
return next
|
||||
}
|
||||
export function extendSelected(form, clip) {
|
||||
export function extendSelected(form, clip, xaigen = false) {
|
||||
// Switching task on the already bound clip must preserve the user's overrides.
|
||||
return {...(clip?.id && form.startClipId !== clip.id ? bindClip(form,clip) : form),mode:'extend'}
|
||||
const next=clip?.id && form.startClipId !== clip.id ? bindClip(form,clip,xaigen) : form
|
||||
return {...next,mode:'extend',engine:xaigen && next.engine==='ltx'?'ltx':'minimax'}
|
||||
}
|
||||
export function changeSource(form) {
|
||||
return form.mode==='extend' ? form : {...form,startClipId:'',settings:{...form.settings,aspect:'auto'}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user