Skip to content
Merged
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
20 changes: 18 additions & 2 deletions comfy_extras/nodes_load_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from comfy.comfy_types import IO
from comfy_api.input_impl import VideoFromFile

from pathlib import Path


def normalize_path(path):
return path.replace('\\', '/')
Expand All @@ -16,7 +18,14 @@ def INPUT_TYPES(s):

os.makedirs(input_dir, exist_ok=True)

files = [normalize_path(os.path.join("3d", f)) for f in os.listdir(input_dir) if f.endswith(('.gltf', '.glb', '.obj', '.fbx', '.stl'))]
input_path = Path(input_dir)
base_path = Path(folder_paths.get_input_directory())

files = [
normalize_path(str(file_path.relative_to(base_path)))
for file_path in input_path.rglob("*")
if file_path.suffix.lower() in {'.gltf', '.glb', '.obj', '.fbx', '.stl'}
]

return {"required": {
"model_file": (sorted(files), {"file_upload": True}),
Expand Down Expand Up @@ -61,7 +70,14 @@ def INPUT_TYPES(s):

os.makedirs(input_dir, exist_ok=True)

files = [normalize_path(os.path.join("3d", f)) for f in os.listdir(input_dir) if f.endswith(('.gltf', '.glb', '.fbx'))]
input_path = Path(input_dir)
base_path = Path(folder_paths.get_input_directory())

files = [
normalize_path(str(file_path.relative_to(base_path)))
for file_path in input_path.rglob("*")
if file_path.suffix.lower() in {'.gltf', '.glb', '.fbx'}
]

return {"required": {
"model_file": (sorted(files), {"file_upload": True}),
Expand Down
Loading