-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add load 3d node support #5564
Merged
+96
−0
Merged
add load 3d node support #5564
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import nodes | ||
import folder_paths | ||
import os | ||
|
||
def normalize_path(path): | ||
return path.replace('\\', '/') | ||
|
||
class Load3D(): | ||
@classmethod | ||
def INPUT_TYPES(s): | ||
input_dir = os.path.join(folder_paths.get_input_directory(), "3d") | ||
|
||
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', '.mtl', '.fbx', '.stl'))] | ||
|
||
return {"required": { | ||
"model_file": (sorted(files), {"file_upload": True}), | ||
"image": ("LOAD_3D", {}), | ||
"width": ("INT", {"default": 1024, "min": 1, "max": 4096, "step": 1}), | ||
"height": ("INT", {"default": 1024, "min": 1, "max": 4096, "step": 1}), | ||
"show_grid": ([True, False],), | ||
"camera_type": (["perspective", "orthographic"],), | ||
"view": (["front", "right", "top", "isometric"],), | ||
"material": (["original", "normal", "wireframe", "depth"],), | ||
"bg_color": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFF, "step": 1, "display": "color"}), | ||
"light_intensity": ("INT", {"default": 10, "min": 1, "max": 20, "step": 1}), | ||
"up_direction": (["original", "-x", "+x", "-y", "+y", "-z", "+z"],), | ||
}} | ||
|
||
RETURN_TYPES = ("IMAGE", "MASK", "STRING") | ||
RETURN_NAMES = ("image", "mask", "mesh_path") | ||
|
||
FUNCTION = "process" | ||
|
||
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, | ||
|
||
class Load3DAnimation(): | ||
@classmethod | ||
def INPUT_TYPES(s): | ||
input_dir = os.path.join(folder_paths.get_input_directory(), "3d") | ||
|
||
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'))] | ||
|
||
return {"required": { | ||
"model_file": (sorted(files), {"file_upload": True}), | ||
"image": ("LOAD_3D_ANIMATION", {}), | ||
"width": ("INT", {"default": 1024, "min": 1, "max": 4096, "step": 1}), | ||
"height": ("INT", {"default": 1024, "min": 1, "max": 4096, "step": 1}), | ||
"show_grid": ([True, False],), | ||
"camera_type": (["perspective", "orthographic"],), | ||
"view": (["front", "right", "top", "isometric"],), | ||
"material": (["original", "normal", "wireframe", "depth"],), | ||
"bg_color": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFF, "step": 1, "display": "color"}), | ||
"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"}), | ||
}} | ||
|
||
RETURN_TYPES = ("IMAGE", "MASK", "STRING") | ||
RETURN_NAMES = ("image", "mask", "mesh_path") | ||
|
||
FUNCTION = "process" | ||
|
||
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, | ||
|
||
class Preview3D(): | ||
@classmethod | ||
def INPUT_TYPES(s): | ||
return {"required": { | ||
"model_file": ("STRING", {"default": "", "multiline": False}), | ||
"image": ("PREVIEW_3D", {}), | ||
"show_grid": ([True, False],), | ||
"camera_type": (["perspective", "orthographic"],), | ||
"view": (["front", "right", "top", "isometric"],), | ||
"material": (["original", "normal", "wireframe", "depth"],), | ||
"bg_color": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFF, "step": 1, "display": "color"}), | ||
"light_intensity": ("INT", {"default": 10, "min": 1, "max": 20, "step": 1}), | ||
"up_direction": (["original", "-x", "+x", "-y", "+y", "-z", "+z"],), | ||
}} | ||
|
||
RETURN_TYPES = () | ||
|
||
CATEGORY = "3d" | ||
|
||
NODE_CLASS_MAPPINGS = { | ||
"Load3D": Load3D, | ||
"Load3DAnimation": Load3DAnimation, | ||
"Preview3D": Preview3D | ||
} | ||
|
||
NODE_DISPLAY_NAME_MAPPINGS = { | ||
"Load3D": "Load 3D", | ||
"Load3DAnimation": "Load 3D - Animation", | ||
"Preview3D": "Preview 3D" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this node need to be in the backend? Can it be a frontend only node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I think so.
let me check and give you back soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just remove that Preview3D node for now and get this PR merged. We can decide how to handle that Preview3D node later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, I will work on how to implement Preview3D on FE only