2024-12-13 18:13:52 -05:00
|
|
|
import nodes
|
|
|
|
|
import folder_paths
|
|
|
|
|
import os
|
2026-02-03 20:31:46 +02:00
|
|
|
import uuid
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
from typing_extensions import override
|
2026-02-03 20:31:46 +02:00
|
|
|
from comfy_api.latest import IO, UI, ComfyExtension, InputImpl, Types
|
2025-05-12 16:47:14 -04:00
|
|
|
|
2025-07-01 20:43:48 -04:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
2025-05-12 16:47:14 -04:00
|
|
|
|
2024-12-13 18:13:52 -05:00
|
|
|
def normalize_path(path):
|
|
|
|
|
return path.replace('\\', '/')
|
|
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
class Load3D(IO.ComfyNode):
|
2024-12-13 18:13:52 -05:00
|
|
|
@classmethod
|
2025-12-03 23:52:31 +02:00
|
|
|
def define_schema(cls):
|
2024-12-13 18:13:52 -05:00
|
|
|
input_dir = os.path.join(folder_paths.get_input_directory(), "3d")
|
|
|
|
|
|
|
|
|
|
os.makedirs(input_dir, exist_ok=True)
|
|
|
|
|
|
2025-07-01 20:43:48 -04:00
|
|
|
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("*")
|
2026-01-22 12:46:56 -05:00
|
|
|
if file_path.suffix.lower() in {'.gltf', '.glb', '.obj', '.fbx', '.stl', '.spz', '.splat', '.ply', '.ksplat'}
|
2025-07-01 20:43:48 -04:00
|
|
|
]
|
2025-12-03 23:52:31 +02:00
|
|
|
return IO.Schema(
|
|
|
|
|
node_id="Load3D",
|
|
|
|
|
display_name="Load 3D & Animation",
|
|
|
|
|
category="3d",
|
feat: add essentials_category (#12357)
* feat: add essentials_category field to node schema
Amp-Thread-ID: https://ampcode.com/threads/T-019c2b25-cd90-7218-9071-03cb46b351b3
* feat: add ESSENTIALS_CATEGORY to core nodes
Marked nodes:
- Basic: LoadImage, SaveImage, LoadVideo, SaveVideo, Load3D, CLIPTextEncode
- Image Tools: ImageScale, ImageInvert, ImageBatch, ImageCrop, ImageRotate, ImageBlur
- Image Tools/Preprocessing: Canny
- Image Generation: LoraLoader
- Audio: LoadAudio, SaveAudio
Amp-Thread-ID: https://ampcode.com/threads/T-019c2b25-cd90-7218-9071-03cb46b351b3
* Add ESSENTIALS_CATEGORY to more nodes
- SaveGLB (Basic)
- GetVideoComponents (Video Tools)
- TencentTextToModelNode, TencentImageToModelNode (3D)
- RecraftRemoveBackgroundNode (Image Tools)
- KlingLipSyncAudioToVideoNode (Video Generation)
- OpenAIChatNode (Text Generation)
- StabilityTextToAudio (Audio)
Amp-Thread-ID: https://ampcode.com/threads/T-019c2b69-81c1-71c3-8096-450a39e20910
* fix: correct essentials category for Canny node
Amp-Thread-ID: https://ampcode.com/threads/T-019c7303-ab53-7341-be76-a5da1f7a657e
Co-authored-by: Amp <amp@ampcode.com>
* refactor: replace essentials_category string literals with constants
Amp-Thread-ID: https://ampcode.com/threads/T-019c7303-ab53-7341-be76-a5da1f7a657e
Co-authored-by: Amp <amp@ampcode.com>
* refactor: revert constants, use string literals for essentials_category
Amp-Thread-ID: https://ampcode.com/threads/T-019c7303-ab53-7341-be76-a5da1f7a657e
Co-authored-by: Amp <amp@ampcode.com>
* fix: update basics
---------
Co-authored-by: bymyself <cbyrne@comfy.org>
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
2026-02-20 11:00:26 +08:00
|
|
|
essentials_category="Basics",
|
2025-12-03 23:52:31 +02:00
|
|
|
is_experimental=True,
|
|
|
|
|
inputs=[
|
|
|
|
|
IO.Combo.Input("model_file", options=sorted(files), upload=IO.UploadType.model),
|
|
|
|
|
IO.Load3D.Input("image"),
|
|
|
|
|
IO.Int.Input("width", default=1024, min=1, max=4096, step=1),
|
|
|
|
|
IO.Int.Input("height", default=1024, min=1, max=4096, step=1),
|
|
|
|
|
],
|
|
|
|
|
outputs=[
|
|
|
|
|
IO.Image.Output(display_name="image"),
|
|
|
|
|
IO.Mask.Output(display_name="mask"),
|
|
|
|
|
IO.String.Output(display_name="mesh_path"),
|
|
|
|
|
IO.Image.Output(display_name="normal"),
|
|
|
|
|
IO.Load3DCamera.Output(display_name="camera_info"),
|
|
|
|
|
IO.Video.Output(display_name="recording_video"),
|
2026-02-04 21:35:38 +02:00
|
|
|
IO.File3DAny.Output(display_name="model_3d"),
|
2025-12-03 23:52:31 +02:00
|
|
|
],
|
|
|
|
|
)
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
@classmethod
|
|
|
|
|
def execute(cls, model_file, image, **kwargs) -> IO.NodeOutput:
|
2025-02-15 15:34:36 -05:00
|
|
|
image_path = folder_paths.get_annotated_filepath(image['image'])
|
|
|
|
|
mask_path = folder_paths.get_annotated_filepath(image['mask'])
|
2025-03-21 16:24:13 -04:00
|
|
|
normal_path = folder_paths.get_annotated_filepath(image['normal'])
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-02-15 15:34:36 -05:00
|
|
|
load_image_node = nodes.LoadImage()
|
|
|
|
|
output_image, ignore_mask = load_image_node.load_image(image=image_path)
|
|
|
|
|
ignore_image, output_mask = load_image_node.load_image(image=mask_path)
|
2025-03-21 16:24:13 -04:00
|
|
|
normal_image, ignore_mask2 = load_image_node.load_image(image=normal_path)
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-05-12 16:47:14 -04:00
|
|
|
video = None
|
|
|
|
|
|
|
|
|
|
if image['recording'] != "":
|
|
|
|
|
recording_video_path = folder_paths.get_annotated_filepath(image['recording'])
|
|
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
video = InputImpl.VideoFromFile(recording_video_path)
|
2025-05-12 16:47:14 -04:00
|
|
|
|
2026-02-04 21:35:38 +02:00
|
|
|
file_3d = Types.File3D(folder_paths.get_annotated_filepath(model_file))
|
|
|
|
|
return IO.NodeOutput(output_image, output_mask, model_file, normal_image, image['camera_info'], video, file_3d)
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
process = execute # TODO: remove
|
2025-01-31 13:09:07 -05:00
|
|
|
|
|
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
class Preview3D(IO.ComfyNode):
|
|
|
|
|
@classmethod
|
|
|
|
|
def define_schema(cls):
|
|
|
|
|
return IO.Schema(
|
|
|
|
|
node_id="Preview3D",
|
add search aliases to all nodes (#12035)
* feat: Add search_aliases field to node schema
Adds `search_aliases` field to improve node discoverability. Users can define alternative search terms for nodes (e.g., "text concat" → StringConcatenate).
Changes:
- Add `search_aliases: list[str]` to V3 Schema
- Add `SEARCH_ALIASES` support for V1 nodes
- Include field in `/object_info` response
- Add aliases to high-priority core nodes
V1 usage:
```python
class MyNode:
SEARCH_ALIASES = ["alt name", "synonym"]
```
V3 usage:
```python
io.Schema(
node_id="MyNode",
search_aliases=["alt name", "synonym"],
...
)
```
## Related PRs
- Frontend: Comfy-Org/ComfyUI_frontend#XXXX (draft - merge after this)
- Docs: Comfy-Org/docs#XXXX (draft - merge after stable)
* Propagate search_aliases through V3 Schema.get_v1_info to NodeInfoV1
* feat: add SEARCH_ALIASES for core nodes (#12016)
Add search aliases to 22 core nodes in nodes.py to improve node discoverability:
- Checkpoint/model loaders: CheckpointLoader, DiffusersLoader
- Conditioning nodes: ConditioningAverage, ConditioningSetArea, ConditioningSetMask, ConditioningZeroOut
- Style nodes: StyleModelApply
- Image nodes: LoadImageMask, LoadImageOutput, ImageBatch, ImageInvert, ImagePadForOutpaint
- Latent nodes: LoadLatent, SaveLatent, LatentBlend, LatentComposite, LatentCrop, LatentFlip, LatentFromBatch, LatentUpscale, LatentUpscaleBy, RepeatLatentBatch
* feat: add SEARCH_ALIASES for image, mask, and string nodes (#12017)
Add search aliases to nodes in comfy_extras for better discoverability:
- nodes_mask.py: mask manipulation nodes
- nodes_images.py: image processing nodes
- nodes_post_processing.py: post-processing effect nodes
- nodes_string.py: string manipulation nodes
- nodes_compositing.py: compositing nodes
- nodes_morphology.py: morphological operation nodes
- nodes_latent.py: latent space nodes
Uses search_aliases parameter in io.Schema() for v3 nodes.
* feat: add SEARCH_ALIASES for audio and video nodes (#12018)
Add search aliases to audio and video nodes for better discoverability:
- nodes_audio.py: audio loading, saving, and processing nodes
- nodes_video.py: video loading and processing nodes
- nodes_wan.py: WAN model nodes
Uses search_aliases parameter in io.Schema() for v3 nodes.
* feat: add SEARCH_ALIASES for model and misc nodes (#12019)
Add search aliases to model-related and miscellaneous nodes:
- Model nodes: nodes_model_merging.py, nodes_model_advanced.py, nodes_lora_extract.py
- Sampler nodes: nodes_custom_sampler.py, nodes_align_your_steps.py
- Control nodes: nodes_controlnet.py, nodes_attention_multiply.py, nodes_hooks.py
- Training nodes: nodes_train.py, nodes_dataset.py
- Utility nodes: nodes_logic.py, nodes_canny.py, nodes_differential_diffusion.py
- Architecture-specific: nodes_sd3.py, nodes_pixart.py, nodes_lumina2.py, nodes_kandinsky5.py, nodes_hidream.py, nodes_fresca.py, nodes_hunyuan3d.py
- Media nodes: nodes_load_3d.py, nodes_webcam.py, nodes_preview_any.py, nodes_wanmove.py
Uses search_aliases parameter in io.Schema() for v3 nodes, SEARCH_ALIASES class attribute for legacy nodes.
2026-01-22 18:36:58 -08:00
|
|
|
search_aliases=["view mesh", "3d viewer"],
|
2025-12-03 23:52:31 +02:00
|
|
|
display_name="Preview 3D & Animation",
|
|
|
|
|
category="3d",
|
|
|
|
|
is_experimental=True,
|
|
|
|
|
is_output_node=True,
|
|
|
|
|
inputs=[
|
2026-02-03 20:31:46 +02:00
|
|
|
IO.MultiType.Input(
|
|
|
|
|
IO.String.Input("model_file", default="", multiline=False),
|
|
|
|
|
types=[
|
|
|
|
|
IO.File3DGLB,
|
|
|
|
|
IO.File3DGLTF,
|
|
|
|
|
IO.File3DFBX,
|
|
|
|
|
IO.File3DOBJ,
|
|
|
|
|
IO.File3DSTL,
|
|
|
|
|
IO.File3DUSDZ,
|
|
|
|
|
IO.File3DAny,
|
|
|
|
|
],
|
|
|
|
|
tooltip="3D model file or path string",
|
|
|
|
|
),
|
feat: mark 429 widgets as advanced for collapsible UI (#12197)
* feat: mark 429 widgets as advanced for collapsible UI
Mark widgets as advanced across core, comfy_extras, and comfy_api_nodes
to support the new collapsible advanced inputs section in the frontend.
Changes:
- 267 advanced markers in comfy_extras/
- 162 advanced markers in comfy_api_nodes/
- All files pass python3 -m py_compile verification
Widgets marked advanced (hidden by default):
- Scheduler internals: sigma_max, sigma_min, rho, mu, beta, alpha
- Sampler internals: eta, s_noise, order, rtol, atol, h_init, pcoeff, etc.
- Memory optimization: tile_size, overlap, temporal_size, temporal_overlap
- Pipeline controls: add_noise, start_at_step, end_at_step
- Timing controls: start_percent, end_percent
- Layer selection: stop_at_clip_layer, layers, block_number
- Video encoding: codec, crf, format
- Device/dtype: device, noise_device, dtype, weight_dtype
Widgets kept basic (always visible):
- Core params: strength, steps, cfg, denoise, seed, width, height
- Model selectors: ckpt_name, lora_name, vae_name, sampler_name
- Common controls: upscale_method, crop, batch_size, fps, opacity
Related: frontend PR #11939
Amp-Thread-ID: https://ampcode.com/threads/T-019c1734-6b61-702e-b333-f02c399963fc
* fix: remove advanced=True from DynamicCombo.Input (unsupported)
Amp-Thread-ID: https://ampcode.com/threads/T-019c1734-6b61-702e-b333-f02c399963fc
* fix: address review - un-mark model merge, video, image, and training node widgets as advanced
Per comfyanonymous review:
- Model merge arguments should not be advanced (all 14 model-specific merge classes)
- SaveAnimatedWEBP lossless/quality/method should not be advanced
- SaveWEBM/SaveVideo codec/crf/format should not be advanced
- TrainLoraNode options should not be advanced (7 inputs)
Amp-Thread-ID: https://ampcode.com/threads/T-019c322b-a3a8-71b7-9962-d44573ca6352
* fix: un-mark batch_size and webcam width/height as advanced (should stay basic)
Amp-Thread-ID: https://ampcode.com/threads/T-019c3236-1417-74aa-82a3-bcb365fbe9d1
---------
Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
2026-02-19 19:20:02 -08:00
|
|
|
IO.Load3DCamera.Input("camera_info", optional=True, advanced=True),
|
|
|
|
|
IO.Image.Input("bg_image", optional=True, advanced=True),
|
2025-12-03 23:52:31 +02:00
|
|
|
],
|
|
|
|
|
outputs=[],
|
|
|
|
|
)
|
2025-01-31 13:09:07 -05:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
@classmethod
|
2026-02-03 20:31:46 +02:00
|
|
|
def execute(cls, model_file: str | Types.File3D, **kwargs) -> IO.NodeOutput:
|
|
|
|
|
if isinstance(model_file, Types.File3D):
|
|
|
|
|
filename = f"preview3d_{uuid.uuid4().hex}.{model_file.format}"
|
|
|
|
|
model_file.save_to(os.path.join(folder_paths.get_output_directory(), filename))
|
|
|
|
|
else:
|
|
|
|
|
filename = model_file
|
2025-04-18 02:52:18 -04:00
|
|
|
camera_info = kwargs.get("camera_info", None)
|
2025-11-26 14:58:27 -05:00
|
|
|
bg_image = kwargs.get("bg_image", None)
|
2026-02-03 20:31:46 +02:00
|
|
|
return IO.NodeOutput(ui=UI.PreviewUI3D(filename, camera_info, bg_image=bg_image))
|
2025-04-18 02:52:18 -04:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
process = execute # TODO: remove
|
2024-12-17 13:42:24 -05:00
|
|
|
|
|
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
class Load3DExtension(ComfyExtension):
|
|
|
|
|
@override
|
|
|
|
|
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
|
|
|
|
|
return [
|
|
|
|
|
Load3D,
|
|
|
|
|
Preview3D,
|
|
|
|
|
]
|
2024-12-17 13:42:24 -05:00
|
|
|
|
2024-12-13 18:13:52 -05:00
|
|
|
|
2025-12-03 23:52:31 +02:00
|
|
|
async def comfy_entrypoint() -> Load3DExtension:
|
|
|
|
|
return Load3DExtension()
|