-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add load 3d node support * remove Preview3D from BE
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
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,95 @@ | ||
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, | ||
|
||
NODE_CLASS_MAPPINGS = { | ||
"Load3D": Load3D, | ||
"Load3DAnimation": Load3DAnimation | ||
} | ||
|
||
NODE_DISPLAY_NAME_MAPPINGS = { | ||
"Load3D": "Load 3D", | ||
"Load3DAnimation": "Load 3D - Animation" | ||
} |
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
bdf3937
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.
Can you provide an optional string path entry before the load node, so that I don't need to reconstruct a 3D model load nodel,just like below: