Skip to content

Commit

Permalink
add fov and mask for load 3d node (#6308)
Browse files Browse the repository at this point in the history
* add fov and mask for load 3d node

* some comments
  • Loading branch information
jtydhr88 authored Jan 3, 2025
1 parent a39ea87 commit 953693b
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions comfy_extras/nodes_load_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def INPUT_TYPES(s):
"bg_color": ("STRING", {"default": "#000000", "multiline": False}),
"light_intensity": ("INT", {"default": 10, "min": 1, "max": 20, "step": 1}),
"up_direction": (["original", "-x", "+x", "-y", "+y", "-z", "+z"],),
"fov": ("INT", {"default": 75, "min": 10, "max": 150, "step": 1}),
}}

RETURN_TYPES = ("IMAGE", "MASK", "STRING")
Expand All @@ -37,13 +38,22 @@ def INPUT_TYPES(s):
CATEGORY = "3d"

def process(self, model_file, image, **kwargs):
imagepath = folder_paths.get_annotated_filepath(image)

load_image_node = nodes.LoadImage()

output_image, output_mask = load_image_node.load_image(image=imagepath)

return output_image, output_mask, model_file,
if isinstance(image, dict):
image_path = folder_paths.get_annotated_filepath(image['image'])
mask_path = folder_paths.get_annotated_filepath(image['mask'])

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)

return output_image, output_mask, model_file,
else:
# to avoid the format is not dict which will happen the FE code is not compatibility to core,
# we need to this to double-check, it can be removed after merged FE into the core
image_path = folder_paths.get_annotated_filepath(image)
load_image_node = nodes.LoadImage()
output_image, output_mask = load_image_node.load_image(image=image_path)
return output_image, output_mask, model_file,

class Load3DAnimation():
@classmethod
Expand All @@ -67,6 +77,7 @@ def INPUT_TYPES(s):
"light_intensity": ("INT", {"default": 10, "min": 1, "max": 20, "step": 1}),
"up_direction": (["original", "-x", "+x", "-y", "+y", "-z", "+z"],),
"animation_speed": (["0.1", "0.5", "1", "1.5", "2"], {"default": "1"}),
"fov": ("INT", {"default": 75, "min": 10, "max": 150, "step": 1}),
}}

RETURN_TYPES = ("IMAGE", "MASK", "STRING")
Expand All @@ -78,13 +89,20 @@ def INPUT_TYPES(s):
CATEGORY = "3d"

def process(self, model_file, image, **kwargs):
imagepath = folder_paths.get_annotated_filepath(image)

load_image_node = nodes.LoadImage()
if isinstance(image, dict):
image_path = folder_paths.get_annotated_filepath(image['image'])
mask_path = folder_paths.get_annotated_filepath(image['mask'])

output_image, output_mask = load_image_node.load_image(image=imagepath)
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)

return output_image, output_mask, model_file,
return output_image, output_mask, model_file,
else:
image_path = folder_paths.get_annotated_filepath(image)
load_image_node = nodes.LoadImage()
output_image, output_mask = load_image_node.load_image(image=image_path)
return output_image, output_mask, model_file,

class Preview3D():
@classmethod
Expand All @@ -98,6 +116,7 @@ def INPUT_TYPES(s):
"bg_color": ("STRING", {"default": "#000000", "multiline": False}),
"light_intensity": ("INT", {"default": 10, "min": 1, "max": 20, "step": 1}),
"up_direction": (["original", "-x", "+x", "-y", "+y", "-z", "+z"],),
"fov": ("INT", {"default": 75, "min": 10, "max": 150, "step": 1}),
}}

OUTPUT_NODE = True
Expand Down

0 comments on commit 953693b

Please sign in to comment.