Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/composables/useLoad3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,20 @@ export const useLoad3d = (nodeOrRef: MaybeRef<LGraphNode | null>) => {
return modelPath
}

const [subfolder, filename] = Load3dUtils.splitFilePath(modelPath)
let cleanPath = modelPath.trim()
let forcedType: 'output' | 'input' | undefined

if (cleanPath.endsWith('[output]')) {
cleanPath = cleanPath.replace(/\s*\[output\]$/, '').trim()
forcedType = 'output'
}

const [subfolder, filename] = Load3dUtils.splitFilePath(cleanPath)
return api.apiURL(
Load3dUtils.getResourceURL(
subfolder,
filename,
isPreview.value ? 'output' : 'input'
forcedType ?? (isPreview.value ? 'output' : 'input')
)
)
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ const specDescriptor = computed<{
allowUpload: boolean
folder: ResultItemType | undefined
}>(() => {
const isLoad3DMesh =
props.nodeType === 'Load3D' && props.widget.name === 'model_file'

const spec = comboSpec.value
if (!spec) {
if (!spec && !isLoad3DMesh) {
return {
kind: 'unknown',
allowUpload: false,
Expand All @@ -74,7 +77,7 @@ const specDescriptor = computed<{
video_upload,
image_folder,
audio_upload
} = spec
} = spec || {}

let kind: AssetKind = 'unknown'
if (video_upload) {
Expand All @@ -83,18 +86,27 @@ const specDescriptor = computed<{
kind = 'image'
} else if (audio_upload) {
kind = 'audio'
} else if (isLoad3DMesh) {
kind = 'mesh'
}

// TODO: add support for models (checkpoints, VAE, LoRAs, etc.) -- get widgetType from spec

const allowUpload =
image_upload === true ||
animated_image_upload === true ||
video_upload === true ||
audio_upload === true
audio_upload === true ||
isLoad3DMesh

const subfolder = isLoad3DMesh ? '3d' : undefined
const folder = isLoad3DMesh ? 'input' : image_folder

return {
kind,
allowUpload,
folder: image_folder
folder,
subfolder
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const inputItems = computed<DropdownItem[]>(() => {
}))
})
const outputItems = computed<DropdownItem[]>(() => {
if (!['image', 'video'].includes(props.assetKind ?? '')) return []
if (!['image', 'video', 'mesh'].includes(props.assetKind ?? '')) return []

const outputs = new Set<string>()

Expand All @@ -123,7 +123,8 @@ const outputItems = computed<DropdownItem[]>(() => {
task.flatOutputs.forEach((output) => {
const isTargetType =
(props.assetKind === 'image' && output.mediaType === 'images') ||
(props.assetKind === 'video' && output.mediaType === 'video')
(props.assetKind === 'video' && output.mediaType === 'video') ||
(props.assetKind === 'mesh' && output.is3D)

if (output.type === 'output' && isTargetType) {
const path = output.subfolder
Expand Down Expand Up @@ -182,7 +183,7 @@ const mediaPlaceholder = computed(() => {
return t('widgets.uploadSelect.placeholderVideo')
case 'audio':
return t('widgets.uploadSelect.placeholderAudio')
case 'model':
case 'mesh':
return t('widgets.uploadSelect.placeholderModel')
case 'unknown':
return t('widgets.uploadSelect.placeholderUnknown')
Expand All @@ -206,6 +207,8 @@ const acceptTypes = computed(() => {
return 'video/*'
case 'audio':
return 'audio/*'
case 'mesh':
return '.obj,.stl,.ply,.spz'
default:
return undefined // model or unknown
}
Expand Down
8 changes: 7 additions & 1 deletion src/types/widgetTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { InjectionKey } from 'vue'

export type AssetKind = 'image' | 'video' | 'audio' | 'model' | 'unknown'
export type AssetKind =
| 'image'
| 'video'
| 'audio'
| 'model'
| 'mesh'
| 'unknown'

export const OnCloseKey: InjectionKey<() => void> = Symbol()