Expand H3 scene image helpers to 9 slots

This commit is contained in:
2026-08-25 17:42:10 +00:00
parent 34e9bea6d9
commit 30c7128810
3 changed files with 67 additions and 16 deletions
+27 -8
View File
@@ -23,6 +23,7 @@ _H3_PLAN_TYPE = "H3_CHAIN_PLAN"
_H3_PLAN_IMAGE_BINDINGS_KEY = "_dumas_scene_image_bindings"
_H3_PLAN_IMAGE_BINDINGS = OrderedDict()
_H3_PLAN_IMAGE_BINDINGS_CAP = 128
_H3_PLAN_IMAGE_SLOTS = 9
_FOLDER_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif", ".tiff", ".tif")
_LOAD_IMAGES_FOLDER_DEFAULT_STATE = {
"version": 1,
@@ -192,8 +193,10 @@ def _scene_images_tuple(
image5=None,
image6=None,
image7=None,
image8=None,
image9=None,
):
return (image1, image2, image3, image4, image5, image6, image7)
return (image1, image2, image3, image4, image5, image6, image7, image8, image9)
def _connected_image_count(images):
@@ -907,7 +910,7 @@ class DumasLoadImagesFolderNode:
class DumasH3PlanAttachSceneImagesNode:
DESCRIPTION = (
"Attach up to seven optional IMAGE sockets to one H3 Chain Plan scene "
"Attach up to nine optional IMAGE sockets to one H3 Chain Plan scene "
"without breaking the upstream plan archive format. Chain multiple "
"copies of this node to bind different scene indexes."
)
@@ -919,7 +922,7 @@ class DumasH3PlanAttachSceneImagesNode:
@classmethod
def INPUT_TYPES(cls):
optional = {}
for slot in range(1, 8):
for slot in range(1, _H3_PLAN_IMAGE_SLOTS + 1):
optional[f"image{slot}"] = (
"IMAGE",
{
@@ -948,7 +951,7 @@ class DumasH3PlanAttachSceneImagesNode:
"step": 1,
"tooltip": (
"1-based scene index inside the H3 plan. Use one node per "
"scene that needs up to seven image sockets."
"scene that needs up to nine image sockets."
),
},
),
@@ -967,10 +970,22 @@ class DumasH3PlanAttachSceneImagesNode:
image5=None,
image6=None,
image7=None,
image8=None,
image9=None,
):
updated_plan = _clone_h3_plan(plan)
scene_index = _normalize_h3_scene_index(updated_plan, scene_index)
images = _scene_images_tuple(image1, image2, image3, image4, image5, image6, image7)
images = _scene_images_tuple(
image1,
image2,
image3,
image4,
image5,
image6,
image7,
image8,
image9,
)
connected_count = _connected_image_count(images)
token, scene_counts = _h3_plan_binding_entry(updated_plan)
@@ -1001,7 +1016,7 @@ class DumasH3PlanAttachSceneImagesNode:
class DumasH3PlanExtractSceneImagesNode:
DESCRIPTION = (
"Read back the seven optional image bindings for one H3 Chain Plan scene. "
"Read back the nine optional image bindings for one H3 Chain Plan scene. "
"Connect clip_index or another scene selector to recover the matching "
"scene images downstream."
)
@@ -1014,6 +1029,8 @@ class DumasH3PlanExtractSceneImagesNode:
"IMAGE",
"IMAGE",
"IMAGE",
"IMAGE",
"IMAGE",
"INT",
)
RETURN_NAMES = (
@@ -1025,6 +1042,8 @@ class DumasH3PlanExtractSceneImagesNode:
"image5",
"image6",
"image7",
"image8",
"image9",
"connected_images",
)
FUNCTION = "extract"
@@ -1063,11 +1082,11 @@ class DumasH3PlanExtractSceneImagesNode:
scene_index = _normalize_h3_scene_index(passthrough_plan, scene_index)
token, _scene_counts = _h3_plan_binding_entry(passthrough_plan)
if not token:
return (passthrough_plan, None, None, None, None, None, None, None, 0)
return (passthrough_plan, *(None for _ in range(_H3_PLAN_IMAGE_SLOTS)), 0)
registry = _H3_PLAN_IMAGE_BINDINGS.get(token) or {}
_touch_plan_image_binding(token)
images = registry.get(int(scene_index)) or (None, None, None, None, None, None, None)
images = registry.get(int(scene_index)) or (None,) * _H3_PLAN_IMAGE_SLOTS
return (passthrough_plan, *images, _connected_image_count(images))