diff --git a/__pycache__/iframe_view.cpython-312.pyc b/__pycache__/iframe_view.cpython-312.pyc index 0b6c23e..dd3152d 100644 Binary files a/__pycache__/iframe_view.cpython-312.pyc and b/__pycache__/iframe_view.cpython-312.pyc differ diff --git a/iframe_view.py b/iframe_view.py index e85085a..14575ec 100644 --- a/iframe_view.py +++ b/iframe_view.py @@ -137,22 +137,13 @@ class IframeView: }, "hidden": { "unique_id": "UNIQUE_ID", - "color": "TEXTURE", - "canny": "TEXTURE", - "depth": "TEXTURE", - "normal": "TEXTURE", "animationFrames": "TEXTURE_SEQUENCE", }, } - RETURN_TYPES = ( - "IMAGE", "IMAGE", "IMAGE", "IMAGE", # base outputs - "IMAGE", "IMAGE", "IMAGE", "IMAGE", # animation outputs (one per channel) - ) - RETURN_NAMES = ( - "color", "canny", "depth", "normal", - "animation_color", "animation_canny", "animation_depth", "animation_normal", - ) + # Only return animation textures now. + RETURN_TYPES = ("IMAGE", "IMAGE", "IMAGE", "IMAGE") + RETURN_NAMES = ("animation_color", "animation_canny", "animation_depth", "animation_normal") FUNCTION = "process_iframe" CATEGORY = "lth" @@ -164,32 +155,19 @@ class IframeView: scene_state, frame_count, unique_id, - color=None, - canny=None, - depth=None, - normal=None, animationFrames=None, ): start_time = time.time() print("[process_iframe] Starting asynchronous processing at", start_time) - print("frame_count:", frame_count) - unique_id = str(unique_id) - # Process base textures first. - color_tensor = process_texture_data(color) - canny_tensor = process_texture_data(canny) - depth_tensor = process_texture_data(depth) - normal_tensor = process_texture_data(normal) - - # Use provided hidden animation frames if available; otherwise, use fallback. if animationFrames is not None and len(animationFrames) >= frame_count: print("[process_iframe] Using provided animationFrames from hidden data.") else: print("[process_iframe] Animation frames not provided or incomplete; using fallback.") animationFrames = await wait_for_capture_completion(unique_id, frame_count) - # Process each frame's texture into a tensor. + # Process each frame's texture into a tensor for animation outputs. color_frames = [ process_texture_data(frame["textures"]["color"]) for frame in animationFrames @@ -211,22 +189,17 @@ class IframeView: if "textures" in frame and "normal" in frame["textures"] ] - # Convert the processed frames into batched tensors. animation_color = torch.stack(color_frames, dim=0) if color_frames else None animation_canny = torch.stack(canny_frames, dim=0) if canny_frames else None animation_depth = torch.stack(depth_frames, dim=0) if depth_frames else None animation_normal = torch.stack(normal_frames, dim=0) if normal_frames else None - # Clear the local reference to the heavy animationFrames data. - # This lets garbage-collection release the base64 strings from memory. + # Clear the heavy animationFrames data. animationFrames = None elapsed = time.time() - start_time print(f"[process_iframe] Asynchronous processing completed in {elapsed:.4f} seconds.") - return ( - color_tensor, canny_tensor, depth_tensor, normal_tensor, - animation_color, animation_canny, animation_depth, animation_normal, - ) + return (animation_color, animation_canny, animation_depth, animation_normal) def process_iframe( self, @@ -236,10 +209,6 @@ class IframeView: scene_state, frame_count, unique_id, - color=None, - canny=None, - depth=None, - normal=None, animationFrames=None, ): return asyncio.run( @@ -250,10 +219,6 @@ class IframeView: scene_state, frame_count, unique_id, - color, - canny, - depth, - normal, animationFrames, ) ) diff --git a/js/iframe_view.js b/js/iframe_view.js index 7f6023e..cfc6f94 100644 --- a/js/iframe_view.js +++ b/js/iframe_view.js @@ -130,16 +130,6 @@ async function widgetIframe(node, nodeData, inputData, app) { } } - window.addEventListener("message", (event) => { - if (event.data && event.data.type === "TEXTURE_OUTPUT") { - console.log( - "[iframe_view] Received TEXTURE_OUTPUT message:", - event.data.data - ); - handleTextureOutput(event.data.data); - } - }); - // Updated handleTextureOutput: Capture frames until target is reached, then aggregate them. function handleTextureOutput(data) { if (node.isCaptureComplete) return; @@ -246,10 +236,11 @@ async function widgetIframe(node, nodeData, inputData, app) { sendParamsToIframe(); }; - // Override the default setHiddenWidgetValue to also update our global TEXTURE_STORE. + // Modified setHiddenWidgetValue to only handle "unique_id" and "animationFrames" node.setHiddenWidgetValue = function (name, value) { + if (name !== "unique_id" && name !== "animationFrames") return; console.log( - "[setHiddenWidgetValue] Setting texture data for", + "[setHiddenWidgetValue] Setting hidden widget for", name, "at", Date.now() @@ -259,7 +250,6 @@ async function widgetIframe(node, nodeData, inputData, app) { widgetEntry.value = value; console.log(`[setHiddenWidgetValue] Updated widget '${name}' to:`, value); } else { - // Create the widget if it does not exist. widgetEntry = { name, value, isHidden: true }; this.widgets.push(widgetEntry); console.log( @@ -294,25 +284,13 @@ async function widgetIframe(node, nodeData, inputData, app) { console.log("[cleanup] Cleaned up resources for node:", node.unique_id); }; - // Updated onSerialize: Strip out the heavy "data" field to avoid localStorage quota problems. + // Updated onSerialize: Only serialize the animationFrames hidden widget. node.onSerialize = (nodeData) => { - // Always ensure a hidden data object exists nodeData.hidden = nodeData.hidden || {}; - - // Serialize the basic texture keys (keep any properties like base64 data) - const textureKeys = ["color", "canny", "depth", "normal"]; - textureKeys.forEach((key) => { - const widgetEntry = node.widgets.find((w) => w.name === key); - if (widgetEntry && widgetEntry.value) { - nodeData.hidden[key] = widgetEntry.value; - } - }); - - // Serialize the animation frames in full. const animWidget = node.widgets.find((w) => w.name === "animationFrames"); nodeData.hidden["animationFrames"] = animWidget && animWidget.value ? animWidget.value : []; - console.log("[onSerialize] Serialized animation frames:", nodeData.hidden); + console.log("[onSerialize] Serialized hidden data:", nodeData.hidden); }; // Update triggerCapture to reset the frame buffer state and cache the dynamic frame count.