{
  "version": 1,
  "description": "A corridor wall: a framed plate, a row of panels fitted to hotspot rectangles, and a trim rail along the top, all on one sheet.",
  "params": {
    "width": { "type": "float", "default": 2, "min": 1.6, "max": 3, "step": 0.1, "label": "width", "desc": "width of the wall (m)" },
    "height": { "type": "float", "default": 2.5, "min": 2.2, "max": 3, "step": 0.1, "label": "height", "desc": "height of the wall (m)" },
    "columns": { "type": "int", "default": 3, "min": 2, "max": 4, "label": "columns", "desc": "panels across the wall" },
    "gap": { "type": "float", "default": 0.06, "min": 0.04, "max": 0.1, "step": 0.01, "label": "gap", "desc": "gap around and between the panels (m)" },
    "seed": { "type": "int", "default": 1, "min": 0, "max": 999, "label": "seed", "desc": "tie-break seed for the hotspot fit" }
  },
  "vars": { "width": 2, "height": 2.5, "columns": 3, "gap": 0.06, "seed": 1 },
  "meta": { "render": { "views": ["persp", "sheet"], "azimuth": -30, "elevation": 12, "size": "1400x800", "shading": "matcap", "color_by": "trim_band", "grid": false } },
  "nodes": {
    "sheet": { "type": "trim_sheet", "params": { "name": "corridor", "resolution": [1024, 2048], "texels_per_metre": 250, "bands": [
      { "name": "frame", "height": 1 },
      { "name": "rail", "height": 0.12, "kind": "edge" },
      { "name": "cap", "height": 0.08, "kind": "cap", "tile": false }
    ], "rects": [
      { "name": "panel", "rect": [0, 400, 130, 595] },
      { "name": "sign", "rect": [400, 400, 100, 50], "rotate": false }
    ] } },

    "plate": { "type": "box", "params": { "size": ["=width", "=height", 0.04], "center": ["=width / 2", "=height / 2", -0.02] } },
    "plate_uv": { "type": "trim_map", "in": ["plate", "sheet"], "params": { "band": "frame" } },
    "plate_named": { "type": "attrib_create", "in": ["plate_uv"], "params": { "name": "name", "class": "prim", "value": "frame" } },
    "plate_paint": { "type": "material", "in": ["plate_named"], "params": { "name": "frame", "base_color": [0.2, 0.22, 0.24], "metallic": 0.6, "roughness": 0.4 } },

    "panel": { "type": "box", "params": { "size": ["=(width - gap * (columns + 1)) / columns", "=height - 2 * gap", 0.03], "center": ["=gap + (width - gap * (columns + 1)) / columns / 2", "=height / 2", 0.005] } },
    "panels": { "type": "copy_xform", "in": ["panel"], "params": { "count": "=columns", "translate": ["=(width - gap * (columns + 1)) / columns + gap", 0, 0], "copy_attrib": "" } },
    "sign": { "type": "box", "params": { "size": [0.4, 0.2, 0.02], "center": ["=width - gap - 0.22", "=gap + 0.12", 0.025] } },
    "fronts": { "type": "merge", "in": ["panels", "sign"] },
    "fronts_n": { "type": "normal", "in": ["fronts"], "params": { "class": "prim" } },
    "fitted": { "type": "hotspot", "in": ["fronts_n", "sheet"], "params": { "group": "@N.z>0.5", "max_stretch": 4, "seed": "=seed" } },
    "sides": { "type": "trim_map", "in": ["fitted", "sheet"], "params": { "group": "@trim_band=\"\"", "band": "frame" } },
    "fronts_named": { "type": "attrib_create", "in": ["sides"], "params": { "name": "name", "class": "prim", "value": "panel" } },
    "sign_named": { "type": "attrib_create", "in": ["fronts_named"], "params": { "name": "name", "class": "prim", "value": "sign", "group": "@trim_band=sign" } },
    "frame_named": { "type": "attrib_create", "in": ["sign_named"], "params": { "name": "name", "class": "prim", "value": "frame", "group": "@trim_band=frame" } },
    "fronts_paint": { "type": "material", "in": ["frame_named"], "params": { "name": "panel", "base_color": [0.55, 0.58, 0.6], "metallic": 0.7, "roughness": 0.35 } },

    "rail_path": { "type": "line", "params": { "origin": [0, "=height - 0.06", 0.03], "direction": [1, 0, 0], "length": "=width", "points": 4 } },
    "rail": { "type": "polywire", "in": ["rail_path", "sheet"], "params": { "radius": 0.03, "divisions": 8, "trim_band": "rail", "trim_cap": "cap" } },
    "rail_named": { "type": "attrib_create", "in": ["rail"], "params": { "name": "name", "class": "prim", "value": "rail" } },
    "rail_paint": { "type": "material", "in": ["rail_named"], "params": { "name": "rail", "base_color": [0.15, 0.16, 0.18], "metallic": 0.85, "roughness": 0.3 } },

    "wall": { "type": "merge", "in": ["plate_paint", "fronts_paint", "rail_paint"] },

    "bounds": { "type": "assert", "in": ["wall"], "params": { "label": "wall", "tolerance": 0.002, "bbox_min": [-0.031, -0.001, -0.04], "bbox_max": ["=width + 0.031", "=height + 0.001", 0.061] } },
    "mapped": { "type": "assert", "in": ["bounds"], "params": { "label": "mapped", "attrib": "trim_band", "attrib_class": "prim" } },
    "sheet_carried": { "type": "assert", "in": ["mapped"], "params": { "label": "sheet", "attrib": "trim_sheets", "attrib_class": "detail" } },
    "uv": { "type": "assert", "in": ["sheet_carried"], "params": { "label": "uv", "attrib": "uv", "attrib_class": "vertex" } }
  },
  "output": "uv",
  "outputs": {
    "wall": {
      "node": "uv", "label": "Corridor wall", "kind": "mesh",
      "tags": ["corridor", "trim-sheet", "hotspot", "sci-fi"],
      "description": "A corridor wall on one trim sheet: a frame band, panels and a sign fitted to hotspot rectangles, and a rail band along the top."
    }
  }
}
