@@ -51,6 +51,14 @@ def define_schema(cls):
5151 ],
5252 )
5353
54+ @classmethod
55+ def validate_inputs (cls , model_file , ** kwargs ) -> bool | str :
56+ if not model_file or model_file == "none" :
57+ return True
58+ if not folder_paths .exists_annotated_filepath (model_file ):
59+ return f"Invalid 3D model file: { model_file } "
60+ return True
61+
5462 @classmethod
5563 def execute (cls , model_file , image , ** kwargs ) -> IO .NodeOutput :
5664 image_path = folder_paths .get_annotated_filepath (image ['image' ])
@@ -148,7 +156,7 @@ def define_schema(cls):
148156 ],
149157 tooltip = "3D model file from an upstream 3D node." ,
150158 ),
151- IO .Load3D .Input ("image " ),
159+ IO .Load3D .Input ("viewport_state " ),
152160 IO .Load3DCamera .Input ("camera_info" , optional = True , advanced = True ),
153161 IO .Load3DModelInfo .Input ("model_3d_info" , optional = True , advanced = True ),
154162 IO .Int .Input ("width" , default = 1024 , min = 1 , max = 4096 , step = 1 ),
@@ -164,14 +172,14 @@ def define_schema(cls):
164172 )
165173
166174 @classmethod
167- def execute (cls , model_3d : Types .File3D , image , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
175+ def execute (cls , model_3d : Types .File3D , viewport_state , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
168176 filename = f"preview3d_advanced_{ uuid .uuid4 ().hex } .{ model_3d .format } "
169- model_3d .save_to (os .path .join (folder_paths .get_output_directory (), filename ))
177+ model_3d .save_to (os .path .join (folder_paths .get_temp_directory (), filename ))
170178
171179 camera_info_input = kwargs .get ("camera_info" , None )
172- camera_info = camera_info_input if camera_info_input is not None else image ['camera_info' ]
180+ camera_info = camera_info_input if camera_info_input is not None else viewport_state ['camera_info' ]
173181 model_3d_info_input = kwargs .get ("model_3d_info" , None )
174- model_3d_info = model_3d_info_input if model_3d_info_input is not None else image .get ('model_3d_info' , [])
182+ model_3d_info = model_3d_info_input if model_3d_info_input is not None else viewport_state .get ('model_3d_info' , [])
175183 return IO .NodeOutput (
176184 model_3d ,
177185 camera_info ,
@@ -216,7 +224,7 @@ def define_schema(cls):
216224 ],
217225 tooltip = "A gaussian splat 3D file." ,
218226 ),
219- IO .Load3D .Input ("image " ),
227+ IO .Load3D .Input ("viewport_state " ),
220228 IO .Load3DCamera .Input ("camera_info" , optional = True , advanced = True ),
221229 IO .Load3DModelInfo .Input ("model_3d_info" , optional = True , advanced = True ),
222230 IO .Int .Input ("width" , default = 1024 , min = 1 , max = 4096 , step = 1 ),
@@ -232,14 +240,14 @@ def define_schema(cls):
232240 )
233241
234242 @classmethod
235- def execute (cls , model_3d : Types .File3D , image , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
243+ def execute (cls , model_3d : Types .File3D , viewport_state , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
236244 filename = f"preview_splat_{ uuid .uuid4 ().hex } .{ model_3d .format } "
237- model_3d .save_to (os .path .join (folder_paths .get_output_directory (), filename ))
245+ model_3d .save_to (os .path .join (folder_paths .get_temp_directory (), filename ))
238246
239247 camera_info_input = kwargs .get ("camera_info" , None )
240- camera_info = camera_info_input if camera_info_input is not None else image ['camera_info' ]
248+ camera_info = camera_info_input if camera_info_input is not None else viewport_state ['camera_info' ]
241249 model_3d_info_input = kwargs .get ("model_3d_info" , None )
242- model_3d_info = model_3d_info_input if model_3d_info_input is not None else image .get ('model_3d_info' , [])
250+ model_3d_info = model_3d_info_input if model_3d_info_input is not None else viewport_state .get ('model_3d_info' , [])
243251 return IO .NodeOutput (
244252 model_3d ,
245253 camera_info ,
@@ -275,7 +283,7 @@ def define_schema(cls):
275283 ],
276284 tooltip = "Point cloud file (.ply)" ,
277285 ),
278- IO .Load3D .Input ("image " ),
286+ IO .Load3D .Input ("viewport_state " ),
279287 IO .Load3DCamera .Input ("camera_info" , optional = True , advanced = True ),
280288 IO .Load3DModelInfo .Input ("model_3d_info" , optional = True , advanced = True ),
281289 IO .Int .Input ("width" , default = 1024 , min = 1 , max = 4096 , step = 1 ),
@@ -291,14 +299,14 @@ def define_schema(cls):
291299 )
292300
293301 @classmethod
294- def execute (cls , model_3d : Types .File3D , image , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
302+ def execute (cls , model_3d : Types .File3D , viewport_state , width : int , height : int , ** kwargs ) -> IO .NodeOutput :
295303 filename = f"preview_pointcloud_{ uuid .uuid4 ().hex } .{ model_3d .format } "
296- model_3d .save_to (os .path .join (folder_paths .get_output_directory (), filename ))
304+ model_3d .save_to (os .path .join (folder_paths .get_temp_directory (), filename ))
297305
298306 camera_info_input = kwargs .get ("camera_info" , None )
299- camera_info = camera_info_input if camera_info_input is not None else image ['camera_info' ]
307+ camera_info = camera_info_input if camera_info_input is not None else viewport_state ['camera_info' ]
300308 model_3d_info_input = kwargs .get ("model_3d_info" , None )
301- model_3d_info = model_3d_info_input if model_3d_info_input is not None else image .get ('model_3d_info' , [])
309+ model_3d_info = model_3d_info_input if model_3d_info_input is not None else viewport_state .get ('model_3d_info' , [])
302310 return IO .NodeOutput (
303311 model_3d ,
304312 camera_info ,
0 commit comments