agent (cont.)

+37:02
  • read_file{"EndLine":400,"Path":"~/work/sortie/kit/mech.py","StartLine":1}

    input

    {
      "EndLine": 400,
      "Path": "~/work/sortie/kit/mech.py",
      "StartLine": 1
    }

    result, 401 lines

    Showing lines 1-400 of 400
    1: """Mech frames. A frame is a tree of joint empties with rigid armour parented to them, so the game
    2: poses it by rotating joints (no skinning). Left is +X (the model faces -Y).
    3: 
    4: Joint tree (names are the contract with src/render/mech.ts):
    5:   frame > pelvis > waist > torso > neck > head
    6:                                    torso > shoulder.L > upperarm.L > forearm.L > hand.L > grip.L
    7:                                    torso > backpack > binder.L
    8:                                    torso > cockpit
    9:           pelvis > thigh.L > shin.L > foot.L
    10: Thruster exits are empties named nozzle.* with a "dir" extra (exhaust direction, glTF axes).
    11: 
    12: Proportions follow measured Gundam 00 line art (review/out/refs/proportions.md): head about a tenth
    13: of the height, hip joint at 60%, shoulder span about half the height on shells that stand off a
    14: compact chest, a waist a ninth of the height, every limb in layered shells over a dark inner frame.
    15: """
    16: from mathutils import Matrix, Vector
    17: 
    18: from lib import (circle, clip, copy, cylinder, empty, halves, loft, merge, mirror_x, nozzle, octo, piston, prism, rot, slats, solid,
    19:                  transform, two_view)
    20: 
    21: BEVEL = 0.05
    22: 
    23: 
    24: def gltf_dir(v):
    25:     v = Vector(v).normalized()
    26:     return [round(v.x, 4), round(v.z, 4), round(-v.y, 4)]
    27: 
    28: 
    29: def place(bm, at, direction):
    30:     """Turn a part built along -Z to point along `direction`, then move it to `at`."""
    31:     q = Vector((0, 0, -1)).rotation_difference(Vector(direction).normalized())
    32:     return transform(bm, Matrix.Translation(Vector(at)) @ q.to_matrix().to_4x4())
    33: 
    34: 
    35: def pair(name, bm_left, role, jl, jr, **kw):
    36:     """Make the left part and its mirror on the right."""
    37:     bm_right = mirror_x(bm_left)
    38:     return solid(f"{name}.L", bm_left, role, jl, **kw), solid(f"{name}.R", bm_right, role, jr, **kw)
    39: 
    40: 
    41: def nozzle_pair(name, at, direction, r, length, jl, jr, shell="frame", housing=True):
    42:     ex = Vector(at)
    43:     for side, j, sx in (("L", jl, 1), ("R", jr, -1)):
    44:         p = Vector((ex.x * sx, ex.y, ex.z))
    45:         d = Vector((direction[0] * sx, direction[1], direction[2]))
    46:         bell, glow = nozzle(r, length)
    47:         solid(f"{name}.{side}", place(bell, p, d), shell, j, smooth=True)
    48:         solid(f"{name}.{side}.glow", place(glow, p, d), "glow_thruster", j, outline=False)
    49:         # an armoured housing around the throat, so the nozzle reads as mounted, not floating
    50:         if housing:
    51:             house = loft([(length * .5, octo(r * 2.5, r * 2.5, r * .6)), (-length * .3, octo(r * 2.3, r * 2.3, r * .55))])
    52:             solid(f"{name}_housing.{side}", place(house, p, d), "main", j, bevel=.02, panels=False)
    53:         empty(f"nozzle.{name}.{side}", p + d.normalized() * length, j, dir=gltf_dir(d), radius=r)
    54: 
    55: 
    56: def seam(bm, a, b, gap=.05):
    57:     """Split a solid along the line a->b of the front view (x, z): two plates with a real seam."""
    58:     a, b = Vector((a[0], 0, a[1])), Vector((b[0], 0, b[1]))
    59:     d = (b - a).normalized()
    60:     n = Vector((-d.z, 0, d.x))
    61:     return halves(bm, a, n, gap)
    62: 
    63: 
    64: def pair_pieces(name, pieces, role, jl, jr, **kw):
    65:     for i, bm in enumerate(pieces):
    66:         pair(f"{name}{i}", bm, role, jl, jr, **kw)
    67: 
    68: 
    69: def joints():
    70:     J = {"frame": empty("frame", (0, 0, 0), frame="striker", height=17.6)}
    71:     J["pelvis"] = empty("pelvis", (0, 0, 10.6), J["frame"])
    72:     J["waist"] = empty("waist", (0, 0, 11.1), J["pelvis"])
    73:     J["torso"] = empty("torso", (0, 0, 11.9), J["waist"])
    74:     J["neck"] = empty("neck", (0, 0, 15.3), J["torso"])
    75:     J["head"] = empty("head", (0, 0, 15.85), J["neck"])
    76:     J["backpack"] = empty("backpack", (0, 1.5, 13.8), J["torso"])
    77:     J["cockpit"] = empty("cockpit", (0, -0.75, 13.7), J["torso"])
    78:     for s, sx in (("L", 1), ("R", -1)):
    79:         J["shoulder", s] = empty(f"shoulder.{s}", (2.0 * sx, 0, 14.6), J["torso"])
    80:         J["upperarm", s] = empty(f"upperarm.{s}", (2.45 * sx, 0, 14.4), J["shoulder", s])
    81:         J["forearm", s] = empty(f"forearm.{s}", (2.5 * sx, 0, 11.95), J["upperarm", s])
    82:         J["hand", s] = empty(f"hand.{s}", (2.5 * sx, 0, 9.6), J["forearm", s])
    83:         J["grip", s] = empty(f"grip.{s}", (2.36 * sx, -0.02, 9.12), J["hand", s])
    84:         J["thigh", s] = empty(f"thigh.{s}", (1.15 * sx, 0, 10.55), J["pelvis"])
    85:         J["shin", s] = empty(f"shin.{s}", (1.2 * sx, 0, 6.1), J["thigh", s])
    86:         J["foot", s] = empty(f"foot.{s}", (1.2 * sx, 0.1, 1.55), J["shin", s])
    87:         J["binder", s] = empty(f"binder.{s}", (0.9 * sx, 2.25, 14.7), J["backpack"])
    88:     return J
    89: 
    90: 
    91: def lr(J, part):
    92:     return J[part, "L"], J[part, "R"]
    93: 
    94: 
    95: def build_pelvis(J):
    96:     P = J["pelvis"]
    97:     solid("pelvis_core", loft([(9.95, octo(.9, 1.3, .25)), (10.4, octo(2.2, 1.7, .4)), (11.0, octo(2.3, 1.75, .45))]),
    98:           "frame", P, BEVEL)
    99:     # the waist belt flares from the abdomen out to hip width; everything below hangs from it
    100:     solid("belt", loft([(10.55, octo(3.2, 2.05, .5)), (10.98, octo(2.1, 1.7, .42))]), "main", P, BEVEL)
    101:     solid("belt_buckle", two_view([(-.3, 10.58), (.3, 10.58), (.18, 10.96), (-.18, 10.96)],
    102:                                   [(-1.14, 10.58), (-.96, 10.58), (-.86, 10.96), (-1.02, 10.96)]), "trim", P, .02)
    103:     pair("hip_block", loft([(10.2, octo(.42, .95, .1, x=1.74)), (10.72, octo(.42, .95, .1, x=1.74))]), "frame", P, P, bevel=.02)
    104:     solid("codpiece", two_view([(-.2, 9.62), (.2, 9.62), (.32, 10.2), (.3, 10.58), (-.3, 10.58), (-.32, 10.2)],
    105:                                [(-1.14, 9.68), (-.75, 9.68), (-.8, 10.58), (-1.08, 10.58), (-1.22, 10.2)]), "trim", P, BEVEL)
    106:     # front skirt: two blades sweeping out from the centre like an arrowhead
    107:     pair("skirt_front", two_view([(.45, 10.62), (1.45, 10.62), (2.05, 10.3), (1.65, 9.6), (.65, 9.9)],
    108:                                  [(-1.34, 9.55), (-1.02, 9.55), (-.94, 10.66), (-1.24, 10.66)]), "main", P, P, bevel=BEVEL)
    109:     pair("skirt_front_edge", two_view([(.68, 9.85), (1.64, 9.55), (1.74, 9.71), (.72, 9.99)],
    110:                                       [(-1.4, 9.47), (-1.06, 9.47), (-1.02, 10.05), (-1.36, 10.05)]), "accent", P, P, bevel=0.015)
    111:     # side skirts flare out toward the bottom, tips swept back
    112:     # side skirts hinge from the hip blocks: a cap plate over a ridged main plate
    113:     pair("skirt_side", two_view([(2.0, 9.5), (2.34, 9.5), (2.12, 10.5), (1.86, 10.52)],
    114:                                 [(-.6, 9.5), (1.05, 9.5), (.95, 10.54), (-.9, 10.54)],
    115:                                 top=[(1.8, -1.0), (2.17, -1.0), (2.42, .05), (2.17, 1.15), (1.8, 1.15)]), "main", P, P, bevel=BEVEL)
    116:     pair("skirt_side_cap", two_view([(1.86, 10.28), (2.3, 10.22), (2.22, 10.74), (1.86, 10.76)],
    117:                                     [(-.72, 10.22), (.92, 10.22), (.86, 10.76), (-.78, 10.76)]), "accent", P, P, bevel=0.025)
    118:     pair("skirt_side_plate", two_view([(2.26, 9.66), (2.4, 9.69), (2.26, 10.16), (2.12, 10.14)],
    119:                                       [(-.4, 9.66), (.85, 9.66), (.78, 10.16), (-.55, 10.16)]), "frame", P, P, bevel=0.015)
    120:     # rear skirt as two overlapping scales with a gap over the hip mechanism
    121:     # rear skirt: descending chevrons, a gap at the centre
    122:     pair("skirt_rear", two_view([(.14, 10.6), (1.26, 10.66), (1.61, 10.35), (1.46, 9.92), (.64, 9.82), (.18, 10.05)],
    123:                                 [(.92, 9.75), (1.26, 9.75), (1.32, 10.7), (.94, 10.7)]), "main", P, P, bevel=BEVEL)
    124:     pair("skirt_rear_low", two_view([(.14, 10.1), (.62, 9.93), (1.3, 10.02), (1.3, 9.63), (.6, 9.4), (.14, 9.6)],
    125:                                     [(1.02, 9.36), (1.36, 9.36), (1.36, 10.14), (1.02, 10.14)]), "main", P, P, bevel=0.03)
    126: 
    127: 
    128: def build_waist(J):
    129:     W = J["waist"]
    130:     solid("abdomen", loft([(10.9, octo(1.6, 1.4, .35)), (11.95, octo(1.85, 1.55, .38))]), "joint", W, 0.03)
    131:     # three stacked plates in front, each a little wider and further forward than the one below
    132:     for i, (z0, z1, hw, y) in enumerate(((10.98, 11.34, .64, -.84), (11.28, 11.64, .72, -.88), (11.58, 11.96, .8, -.92))):
    133:         solid(f"abs{i}", two_view([(-hw, z0), (hw, z0), (hw + .06, z1), (-hw - .06, z1)],
    134:                                   [(y + .02, z0), (y + .24, z0), (y + .24, z1), (y - .02, z1)],
    135:                                   top=[(-hw - .1, y + .3), (hw + .1, y + .3), (hw + .1, y + .1), (0, y - .06), (-hw - .1, y + .1)]),
    136:               "frame", W, 0.02)
    137:     pair("abs_side", two_view([(.72, 11.0), (.96, 11.05), (1.02, 11.92), (.78, 11.92)],
    138:                               [(-.5, 11.0), (.5, 11.0), (.56, 11.92), (-.56, 11.92)]), "frame", W, W, bevel=0.02)
    139: 
    140: 
    141: def build_torso(J):
    142:     T = J["torso"]
    143:     # a dark structural core; the armour is separate plates over it
    144:     solid("chest", loft([(11.9, octo(1.9, 1.6, .4, y=.05)), (12.6, octo(2.4, 2.05, .45)), (13.9, octo(3.0, 2.45, .55, y=-.05)),
    145:                          (14.9, octo(2.8, 2.25, .5)), (15.3, octo(1.8, 1.55, .4))]), "frame", T, BEVEL)
    146:     # central hatch: a ridged block down the chest front that carries the reactor lens
    147:     solid("hatch", two_view([(-.55, 12.75), (.55, 12.75), (.6, 14.5), (.4, 14.78), (-.4, 14.78), (-.6, 14.5)],
    148:                             [(-1.62, 12.75), (-1.2, 12.75), (-1.3, 14.78), (-1.66, 14.62), (-1.8, 13.8)],
    149:                             top=[(-.7, -1.0), (.7, -1.0), (.7, -1.55), (0, -1.84), (-.7, -1.55)]), "main", T, .03)
    150:     pair("chest_plate", two_view([(.58, 14.82), (1.18, 14.88), (1.55, 14.62), (1.78, 14.28), (1.55, 13.85), (.6, 14.08)],
    151:                                  [(-1.64, 13.6), (-1.1, 13.6), (-1.26, 14.88), (-1.5, 14.88), (-1.72, 13.85)]),
    152:          "accent", T, T, bevel=BEVEL)
    153:     rib = two_view([(.6, 12.7), (.9, 12.6), (1.6, 13.2), (1.62, 13.54), (.6, 13.88)],
    154:                    [(-1.49, 12.5), (-.95, 12.5), (-1.1, 13.92), (-1.35, 13.92), (-1.57, 13.55)])
    155:     pair_pieces("rib_plate", seam(rib, (.6, 13.22), (1.62, 13.05)), "accent", T, T, bevel=0.03)
    156:     pair("chest_strip", two_view([(.6, 14.84), (1.18, 14.9), (1.57, 14.64), (1.8, 14.28), (1.64, 14.2), (1.42, 14.5), (1.1, 14.7),
    157:                                   (.6, 14.64)],
    158:                                  [(-1.72, 13.9), (-1.22, 13.9), (-1.36, 14.96), (-1.6, 14.96), (-1.8, 14.2)]), "main", T, T, bevel=0.02)
    159:     pair("side_plate", two_view([(1.42, 12.9), (1.62, 12.9), (1.68, 14.4), (1.48, 14.6)],
    160:                                 [(-.95, 12.9), (.9, 12.9), (.95, 14.4), (-1.05, 14.45)]), "main", T, T, bevel=0.03)
    161:     solid("belly", two_view([(-.95, 11.92), (.95, 11.92), (1.22, 12.62), (-1.22, 12.62)],
    162:                             [(-1.34, 11.9), (-.98, 11.9), (-1.08, 12.66), (-1.4, 12.66)]), "main", T, BEVEL)
    163:     solid("belly_vent", slats(-.6, .6, 12.02, 12.48, -1.38, 3, depth=.08), "frame", T)
    164:     # the reactor lens in the chest
    165:     solid("lens_socket", prism(circle(.44, 12, 0, 13.62), -1.92, -1.5, "xz"), "frame", T, 0.03)
    166:     solid("lens", prism(circle(.33, 12, 0, 13.62), -1.97, -1.9, "xz"), "sensor", T, smooth=True)
    167:     solid("lens_core", prism(circle(.11, 8, 0, 13.62), -1.99, -1.95, "xz"), "glow_core", T)
    168:     # collar: thin folded plates (front and side) with room around the neck
    169:     pair("collar", two_view([(.55, 14.72), (1.46, 14.76), (1.55, 15.3), (1.1, 15.55), (.62, 15.45)],
    170:                             [(-1.0, 14.7), (-.84, 14.7), (-.68, 15.55), (-.84, 15.55)]), "main", T, T, bevel=0.025)
    171:     pair("collar_side", two_view([(1.36, 14.7), (1.52, 14.7), (1.42, 15.5), (1.26, 15.5)],
    172:                                  [(-.9, 14.7), (.7, 14.7), (.6, 15.5), (-.7, 15.5)]), "main", T, T, bevel=0.025)
    173:     pair("collar_vent", slats(.72, 1.26, 14.86, 15.2, -1.0, 3, depth=.06), "frame", T, T)
    174:     solid("neck_guard", two_view([(-.55, 15.2), (.55, 15.2), (.5, 15.86), (-.5, 15.86)],
    175:                                  [(.25, 15.2), (.72, 15.2), (.64, 15.86), (.36, 15.86)]), "main", T, .02)
    176:     solid("back_plate", two_view([(-.95, 12.35), (.95, 12.35), (1.62, 14.92), (-1.62, 14.92)],
    177:                                  [(1.14, 12.35), (1.46, 12.35), (1.52, 14.92), (1.24, 14.92)]), "accent", T, BEVEL)
    178: 
    179: 
    180: def build_head(J):
    181:     N, H = J["neck"], J["head"]
    182:     solid("neck_core", cylinder(.36, 15.25, 16.0, 10), "joint", N, smooth=True)
    183:     solid("neck_ring", loft([(15.5, octo(.95, .9, .2)), (15.68, octo(.86, .82, .18))]), "frame", N, .015)
    184:     # cranium: the top plate, tapered toward the back in plan
    185:     solid("cranium", two_view([(-.62, 16.66), (.62, 16.66), (.58, 17.05), (.36, 17.28), (-.36, 17.28), (-.58, 17.05)],
    186:                               [(-.86, 16.7), (-.5, 17.2), (.25, 17.3), (.72, 17.0), (.78, 16.66)],
    187:                               top=[(-.4, -.88), (.4, -.88), (.62, -.4), (.55, .6), (0, .86), (-.55, .6), (-.62, -.4)]), "main", H, .03)
    188:     solid("skull", loft([(15.95, octo(.9, 1.15, .25, y=.05)), (16.7, octo(1.1, 1.4, .3, y=.0))]), "frame", H, .02)
    189:     # side plates frame the face and run back past the ears
    190:     pair("helmet_side", two_view([(.48, 15.98), (.7, 16.28), (.77, 16.9), (.62, 17.04), (.55, 16.5), (.42, 16.06)],
    191:                                  [(-.72, 15.98), (.62, 15.98), (.74, 16.6), (.5, 17.04), (-.56, 17.0), (-.82, 16.52)]), "main", H, H, bevel=.025)
    192:     # sensor band under a broad, slightly peaked brow hood
    193:     solid("visor", two_view([(-.6, 16.48), (.6, 16.48), (.6, 16.64), (-.6, 16.64)],
    194:                             [(-.97, 16.46), (-.62, 16.46), (-.62, 16.66), (-.95, 16.66)]), "visor", H, 0.01)
    195:     solid("sensor_band", two_view([(-.5, 16.535), (.5, 16.535), (.5, 16.585), (-.5, 16.585)],
    196:                                   [(-.99, 16.5), (-.93, 16.5), (-.93, 16.62), (-.99, 16.62)]), "glow_eye", H)
    197:     solid("brow_hood", two_view([(-.68, 16.62), (.68, 16.62), (.62, 16.8), (.18, 16.88), (-.18, 16.88), (-.62, 16.8)],
    198:                                 [(-1.07, 16.62), (-.55, 16.62), (-.55, 16.88), (-.95, 16.86)],
    199:                                 top=[(-.7, -.5), (.7, -.5), (.7, -.92), (0, -1.1), (-.7, -.92)]), "main", H, 0.02)
    200:     # lower face: a dark recessed mask with vertical vents, two faceted plates over it
    201:     solid("mask", two_view([(-.3, 15.9), (.3, 15.9), (.42, 16.45), (-.42, 16.45)],
    202:                            [(-.72, 15.9), (-.5, 15.9), (-.55, 16.46), (-.8, 16.46)]), "frame", H, 0.015)
    203:     vents = [prism([(x - .025, 15.98), (x + .025, 15.98), (x + .025, 16.3), (x - .025, 16.3)], -.8, -.7, "xz") for x in (-.1, 0, .1)]
    204:     solid("mask_vents", merge(*vents), "joint", H)
    205:     pair("mask_plate", two_view([(.12, 15.92), (.36, 16.0), (.44, 16.42), (.16, 16.42)],
    206:                                 [(-.84, 15.95), (-.6, 15.95), (-.62, 16.44), (-.88, 16.44)]), "main", H, H, bevel=0.015)
    207:     # ear sensors: blocks with a lens on the outer face
    208:     pair("ear", two_view([(.7, 16.3), (.86, 16.33), (.86, 16.66), (.7, 16.7)],
    209:                          [(-.25, 16.3), (.22, 16.3), (.28, 16.66), (-.2, 16.7)]), "accent", H, H, bevel=.02)
    210:     pair("ear_lens", cylinder(.085, .85, .9, 12, axis="x", at=(-.01, 16.48)), "sensor", H, H, smooth=True)
    211:     solid("helmet_rear", two_view([(-.55, 16.08), (.55, 16.08), (.6, 16.7), (-.6, 16.7)],
    212:                                   [(.42, 16.04), (.8, 16.2), (.82, 16.7), (.52, 16.76)]), "main", H, .02)
    213:     solid("rear_fin", prism([(.45, 16.95), (.92, 16.86), (1.0, 17.0), (.62, 17.18)], -.05, .05, "yz"), "frame", H, .01)
    214:     solid("crest", two_view([(-.1, 16.9), (.1, 16.9), (.04, 17.62), (-.04, 17.62)],
    215:                             [(-.62, 16.98), (-.34, 17.25), (.48, 17.60), (.67, 17.54), (.15, 17.12), (-.32, 16.94)]), "trim", H, 0.01)
    216: 
    217: 
    218: def build_arms(J):
    219:     pair("shoulder_block", loft([(1.45, octo(1.5, 1.4, .35, y=14.55)), (2.62, octo(1.45, 1.35, .35, y=14.55))], axis="x"),
    220:          "frame", *lr(J, "shoulder"), bevel=BEVEL)
    221:     # the shoulder shell: a folded plate (top and outer drop) standing off the block
    222:     # shoulder shell: a swept roof and a separate outer blade, tapered in plan, open underneath
    223:     plan = [(1.85, -.65), (3.25, -1.05), (4.3, .10), (4.1, .75), (3.2, 1.1), (1.85, .60)]
    224:     side = [(-1.3, 14.2), (1.3, 14.2), (1.3, 15.95), (-1.3, 15.95)]
    225:     cap = [(-.90, 15.35), (.30, 15.65), (.95, 15.20), (.70, 14.55), (-.65, 14.65)]
    226:     roof = two_view([(1.90, 15.16), (3.38, 15.87), (3.72, 15.61), (3.45, 15.15), (2.12, 14.87)],
    227:                     [(-1.25, 14.75), (.4, 15.95), (1.15, 15.4), (.9, 14.8), (-.9, 14.75)], top=plan)
    228:     pair_pieces("shell", seam(roof, (2.78, 14.6), (2.62, 16.2), gap=.05), "accent", *lr(J, "shoulder"), bevel=0.03)
    229:     pair("shell_under", two_view([(2.1, 14.74), (3.3, 15.06), (3.36, 14.86), (2.2, 14.58)], cap, top=plan),
    230:          "frame", *lr(J, "shoulder"), bevel=0.02)
    231:     pair("trunnion", cylinder(.325, 2.25, 2.95, 12, axis="x", at=(0, 14.55)), "joint", *lr(J, "shoulder"), smooth=True)
    232:     for k, y in (("f", -.45), ("r", .45)):
    233:         pair(f"fork_{k}", two_view([(2.2, 14.1), (2.9, 14.2), (2.9, 14.95), (2.2, 15.0)],
    234:                                    [(y - .08, 14.1), (y + .08, 14.1), (y + .08, 15.0), (y - .08, 15.0)]), "frame",
    235:              *lr(J, "shoulder"), bevel=0.02)
    236:     pair("shell_blade", two_view([(3.62, 15.84), (4.2, 15.65), (3.98, 14.65), (3.72, 14.5), (3.55, 15.08)], side, top=plan),
    237:          "accent", *lr(J, "shoulder"), bevel=0.04)
    238:     pair("shell_edge", two_view([(2.0, 14.86), (3.55, 15.06), (3.55, 15.18), (1.95, 14.98)], side,
    239:                                 top=[(1.85, -.74), (3.25, -1.14), (3.42, -.9), (1.9, -.52)]),
    240:          "main", *lr(J, "shoulder"), bevel=0.012)
    241:     pair("shell_fin", prism([(-.6, 15.5), (1.0, 15.55), (.8, 16.05), (.05, 15.95)], 2.9, 3.05, "yz"), "main",
    242:          *lr(J, "shoulder"), bevel=0.02)
    243:     pair("upperarm_core", loft([(12.2, octo(.85, .9, .22, x=2.5)), (14.2, octo(.9, .95, .24, x=2.48))]), "joint",
    244:          *lr(J, "upperarm"), bevel=0.03)
    245:     # front and rear shells with channels down the sides that show the core
    246:     cuff = loft([(12.5, octo(.85, .95, .22, x=2.53)), (13.6, octo(1.1, 1.13, .28, x=2.54))])
    247:     cuff_b = copy(cuff)
    248:     pair("upperarm_front", clip(cuff, y=(-1, -.08)), "main", *lr(J, "upperarm"), bevel=0.03)
    249:     pair("upperarm_rear", clip(cuff_b, y=(.08, 1)), "main", *lr(J, "upperarm"), bevel=0.03)
    250:     pair("upperarm_band", loft([(13.62, octo(1.16, 1.18, .28, x=2.54)), (13.84, octo(1.16, 1.18, .28, x=2.54))]), "accent",
    251:          *lr(J, "upperarm"), bevel=0.02)
    252:     pair("elbow", cylinder(.48, 2.0, 3.0, 12, axis="x", at=(0, 11.95)), "joint", *lr(J, "upperarm"), smooth=True)
    253:     # a longer forearm, its armour split down its length into outer and inner halves over a dark core
    254:     pair("forearm_core", loft([(9.62, octo(.6, .7, .15, x=2.5)), (11.95, octo(.8, .9, .2, x=2.5))]), "frame",
    255:          *lr(J, "forearm"), bevel=0.02)
    256:     arm_side = [(-.45, 9.65), (.45, 9.65), (.65, 11.4), (.55, 12.1), (-.55, 12.1), (-.65, 11.4)]
    257:     out = two_view([(2.56, 11.86), (2.91, 12.08), (3.22, 11.43), (3.03, 10.45), (2.80, 9.68), (2.56, 9.78)], arm_side,
    258:                    top=[(2.5, -.7), (3.0, -.7), (3.26, 0), (3.0, .7), (2.5, .7)])
    259:     pair_pieces("forearm_out", seam(out, (2.56, 11.45), (3.18, 11.22)), "main", *lr(J, "forearm"), bevel=0.03)
    260:     pair("elbow_actuator", piston((2.5, .62, 12.35), (2.5, .56, 11.55), r=.09), "joint", *lr(J, "forearm"), smooth=True)
    261:     pair("forearm_in", two_view([(2.125, 9.65), (2.44, 9.65), (2.44, 12.0), (2.0, 12.0), (1.95, 11.4)], arm_side),
    262:          "main", *lr(J, "forearm"), bevel=0.04)
    263:     pair("forearm_plate", two_view([(2.98, 10.3), (3.12, 10.3), (3.26, 11.3), (3.12, 11.3)],
    264:                                    [(-.5, 10.25), (.5, 10.25), (.6, 11.35), (-.6, 11.35)]), "accent", *lr(J, "forearm"), bevel=0.02)
    265:     pair("elbow_guard", two_view([(2.1, 11.5), (3.0, 11.5), (3.0, 12.2), (2.55, 12.45), (2.1, 12.2)],
    266:                                  [(.45, 11.45), (.8, 11.55), (1.0, 11.95), (.8, 12.35), (.45, 12.4)]), "main",
    267:          *lr(J, "forearm"), bevel=0.03)
    268:     pair("wrist_guard", loft([(9.6, octo(.98, 1.04, .22, x=2.52)), (9.8, octo(1.02, 1.08, .24, x=2.52))]), "accent",
    269:          *lr(J, "forearm"), bevel=0.02)
    270:     pair("wrist", cylinder(.28, 9.4, 9.75, 10, at=(2.5, 0)), "joint", *lr(J, "hand"), smooth=True)
    271:     pair("palm", loft([(8.9, octo(.5, .82, .1, x=2.52)), (9.5, octo(.46, .8, .1, x=2.52))]), "frame", *lr(J, "hand"), bevel=0.02)
    272:     pair("fingers", loft([(8.75, octo(.42, .82, .13, x=2.27)), (9.35, octo(.44, .82, .13, x=2.27))]), "frame",
    273:          *lr(J, "hand"), bevel=0.025)
    274:     pair("thumb", loft([(9.02, octo(.24, .24, .06, x=2.32, y=-.5)), (9.4, octo(.26, .26, .06, x=2.38, y=-.46))]), "frame",
    275:          *lr(J, "hand"), bevel=0.02)
    276:     pair("hand_guard", two_view([(2.72, 9.0), (2.86, 9.05), (2.86, 9.55), (2.72, 9.55)],
    277:                                 [(-.4, 9.0), (.4, 9.0), (.42, 9.55), (-.42, 9.55)]), "main", *lr(J, "hand"), bevel=0.015)
    278: 
    279: 
    280: def build_legs(J):
    281:     pair("hip_ball", cylinder(.5, .55, 1.6, 12, axis="x", at=(0, 10.55)), "joint", *lr(J, "thigh"), smooth=True)
    282:     pair("thigh_core", loft([(6.7, octo(.8, .95, .22, x=1.2)), (9.0, octo(1.3, 1.45, .34, x=1.18)),
    283:                              (10.25, octo(1.15, 1.3, .3, x=1.15))]), "frame", *lr(J, "thigh"), bevel=BEVEL)
    284:     # thigh shells taper to the knee, with dark channels between them
    285:     tf = two_view([(.72, 9.95), (1.62, 9.95), (1.95, 9.32), (1.72, 8.58), (1.53, 7.36), (.91, 7.36), (.63, 8.40), (.49, 9.24)],
    286:                   [(-.96, 7.3), (-.55, 7.3), (-.55, 9.95), (-.86, 9.95), (-1.02, 8.6)],
    287:                   top=[(.4, -.5), (2.0, -.5), (2.0, -.8), (1.22, -1.12), (.4, -.8)])
    288:     pair_pieces("thigh_front", seam(tf, (.64, 8.72), (1.79, 8.94)), "main", *lr(J, "thigh"), bevel=0.04)
    289:     pair("thigh_panel", two_view([(1.0, 7.72), (1.36, 7.72), (1.4, 7.8), (1.4, 8.3), (1.34, 8.37), (1.02, 8.37), (.96, 8.3), (.96, 7.8)],
    290:                                  [(-1.04, 7.65), (-.94, 7.65), (-.94, 8.42), (-1.0, 8.42)]), "frame", *lr(J, "thigh"), bevel=0.01)
    291:     pair("thigh_outer", two_view([(1.66, 7.45), (1.8, 7.5), (2.12, 9.3), (1.96, 9.75)],
    292:                                  [(-.42, 7.45), (.5, 7.45), (.62, 9.6), (-.5, 9.6)]), "main", *lr(J, "thigh"), bevel=0.03)
    293:     pair("thigh_rear", two_view([(.82, 7.45), (1.58, 7.45), (1.86, 9.4), (.56, 9.4)],
    294:                                 [(.36, 7.45), (.55, 7.45), (.84, 9.4), (.62, 9.4)]), "main", *lr(J, "thigh"), bevel=0.03)
    295: 
    296:     pair("knee_joint", cylinder(.5, .65, 1.75, 12, axis="x", at=(0, 6.1)), "joint", *lr(J, "shin"), smooth=True)
    297:     pair("knee_disc", cylinder(.48, 1.78, 1.98, 16, axis="x", at=(.1, 6.15)), "accent", *lr(J, "shin"), smooth=True)
    298:     pair("knee_lens", cylinder(.3, 1.98, 2.04, 16, axis="x", at=(.1, 6.15)), "sensor", *lr(J, "shin"), smooth=True)
    299:     pair("kneecap", two_view([(.75, 5.85), (1.65, 5.85), (1.72, 6.5), (1.2, 6.95), (.68, 6.5)],
    300:                              [(-1.15, 5.85), (-.6, 5.85), (-.55, 6.7), (-.82, 6.95), (-1.15, 6.3)],
    301:                              top=[(.6, -.4), (1.8, -.4), (1.8, -.85), (1.2, -1.2), (.6, -.85)]), "main",
    302:          *lr(J, "shin"), bevel=0.04)
    303:     pair("shin_core", loft([(1.75, octo(.85, 1.0, .22, x=1.2, y=.1)), (5.8, octo(1.0, 1.15, .26, x=1.2))]), "frame",
    304:          *lr(J, "shin"), bevel=0.03)
    305:     # one envelope (narrow ankle, calf bulge high and back) cut into front, outer, inner and rear shells
    306:     env = loft([(1.85, octo(1.1, 1.3, .3, x=1.2, y=.05)), (3.0, octo(1.35, 1.6, .38, x=1.2, y=.15)),
    307:                 (4.3, octo(1.65, 2.0, .45, x=1.2, y=.3)), (5.6, octo(1.2, 1.45, .32, x=1.2, y=.05))])
    308:     parts = {"shin_front": dict(y=(-2, -.2)), "shin_outer": dict(x=(1.5, 3), y=(-.08, .62)),
    309:              "shin_inner": dict(x=(-1, .9), y=(-.08, .62)), "shin_rear": dict(y=(.74, 3))}
    310:     for name, box in parts.items():
    311:         pair(name, clip(copy(env), **box), "main", *lr(J, "shin"), bevel=0.03)
    312:     env.free()
    313:     sp = two_view([(.80, 5.42), (1.49, 5.42), (1.70, 4.55), (1.57, 3.40), (1.43, 2.08), (.96, 2.08), (.77, 3.45), (.65, 4.52)],
    314:                   [(-.8, 2.05), (-.62, 2.05), (-.68, 5.44), (-.86, 5.44), (-.92, 4.3)],
    315:                   top=[(.6, -.5), (1.75, -.5), (1.75, -.66), (1.17, -.98), (.6, -.66)])
    316:     pair_pieces("shin_plate", seam(sp, (.75, 3.60), (1.59, 3.25), gap=.06), "main", *lr(J, "shin"), bevel=0.03)
    317:     for k, x in (("i", .86), ("o", 1.54)):
    318:         pair(f"knee_rail_{k}", loft([(6.45, octo(.18, .25, .04, x=x, y=.18)), (7.4, octo(.18, .25, .04, x=x, y=.18))]), "frame",
    319:              *lr(J, "shin"), bevel=0.015)
    320:     pair("knee_actuator", piston((1.2, .62, 7.25), (1.2, .74, 5.55), r=.1), "joint", *lr(J, "shin"), smooth=True)
    321:     pair("calf_blister", two_view([(.78, 4.25), (1.62, 4.25), (1.62, 5.05), (.78, 5.05)],
    322:                                   [(.85, 4.3), (1.58, 4.55), (1.5, 5.05), (.85, 5.05)]), "main", *lr(J, "shin"), bevel=0.04)
    323:     pair("achilles", piston((1.2, .72, 2.4), (1.2, .86, 1.75), r=.07), "joint", *lr(J, "shin"), smooth=True)
    324:     pair("shin_side", two_view([(1.9, 2.8), (2.02, 2.85), (2.1, 4.4), (1.98, 4.45)],
    325:                                [(-.3, 2.8), (.6, 2.8), (.75, 4.4), (-.2, 4.4)]), "accent", *lr(J, "shin"), bevel=0.02)
    326:     pair("calf_vent", slats(.95, 1.45, 2.4, 3.1, 1.0, 3, depth=.08), "frame", *lr(J, "shin"))
    327:     nozzle_pair("calf", (1.2, 1.38, 4.4), (0, .5, -.85), .3, .5, *lr(J, "shin"), housing=False)
    328: 
    329: 
    330:     pair("ankle", cylinder(.42, .75, 1.65, 12, axis="x", at=(.1, 1.55)), "joint", *lr(J, "foot"), smooth=True)
    331:     foot_plan = [(.95, -2.3), (1.45, -2.3), (1.7, -2.05), (1.85, -1.0), (1.80, 1.2), (.60, 1.2), (.55, -1.0), (.7, -2.05)]
    332:     # the spat: a ridged guard over the front of the ankle, riding on the foot
    333:     pair("ankle_spat", two_view([(.62, 1.05), (1.78, 1.05), (1.7, 2.02), (1.2, 2.24), (.7, 2.02)],
    334:                                 [(-.98, 1.05), (-.5, 1.05), (-.45, 2.0), (-.7, 2.24), (-1.02, 1.6)],
    335:                                 top=[(.5, -.3), (1.9, -.3), (1.9, -.8), (1.2, -1.06), (.5, -.8)]), "main", *lr(J, "foot"), bevel=.03)
    336:     pair("instep", two_view([(.55, .15), (1.85, .15), (1.8, .9), (1.5, 1.12), (.9, 1.12), (.6, .9)],
    337:                             [(-.9, .15), (.9, .15), (.85, 1.0), (.2, 1.2), (-.85, 1.1)], top=foot_plan), "main", *lr(J, "foot"), bevel=.03)
    338:     pair("toe_base", two_view([(.58, .12), (1.82, .12), (1.78, .78), (.62, .78)],
    339:                               [(-1.55, .12), (-.98, .12), (-.95, 1.0), (-1.5, .86)], top=foot_plan), "main", *lr(J, "foot"), bevel=.03)
    340:     pair("toe", two_view([(.58, .1), (1.82, .1), (1.78, .74), (.62, .74)],
    341:                          [(-2.3, .1), (-1.62, .1), (-1.6, .84), (-2.0, .7), (-2.3, .3)], top=foot_plan), "trim", *lr(J, "foot"), bevel=.04)
    342:     pair("heel", two_view([(.62, .1), (1.8, .1), (1.76, .98), (.66, .98)],
    343:                           [(.86, .1), (1.62, .1), (1.66, .5), (1.36, .98), (.86, 1.08)]), "trim", *lr(J, "foot"), bevel=.04)
    344:     pair("ankle_guard", two_view([(1.8, .35), (1.96, .4), (1.96, 1.2), (1.8, 1.26)],
    345:                                  [(-.62, .35), (.72, .35), (.62, 1.2), (-.5, 1.2)]), "accent", *lr(J, "foot"), bevel=.02)
    346:     for k, (y0, y1) in (("front", (-2.15, -.95)), ("back", (-.85, 1.1))):
    347:         pad = [(x, min(max(y, y0), y1)) for x, y in [(.84, -2.15), (1.56, -2.15), (1.84, -1.0), (1.7, 1.08), (.7, 1.08), (.56, -1.0)]]
    348:         pair(f"sole_{k}", prism(pad, 0.0, 0.14, "xy"), "joint", *lr(J, "foot"), bevel=.02)
    349: 
    350: 
    351: def build_backpack(J):
    352:     B = J["backpack"]
    353:     solid("back_mount", loft([(1.2, octo(1.8, 2.2, .4, y=13.8)), (1.95, octo(1.7, 2.1, .4, y=13.8))], axis="y"), "frame", B, BEVEL)
    354:     solid("reactor", loft([(1.9, circle(.85, 12, 0, 13.9)), (2.85, circle(.5, 12, 0, 13.9))], axis="y"), "main", B, smooth=True)
    355:     solid("reactor_ring", loft([(2.0, circle(.95, 12, 0, 13.9)), (2.2, circle(.95, 12, 0, 13.9))], axis="y"), "accent", B,
    356:           smooth=True)
    357:     solid("reactor_tip", loft([(2.82, circle(.54, 12, 0, 13.9)), (3.0, circle(.46, 12, 0, 13.9))], axis="y"), "frame", B,
    358:           smooth=True)
    359:     solid("reactor_glow", loft([(2.92, circle(.22, 12, 0, 13.9)), (2.95, circle(.22, 12, 0, 13.9))], axis="y"), "glow_core", B)
    360:     for s, sx in (("L", 1), ("R", -1)):
    361:         m = Matrix.Translation((.9 * sx, 2.25, 14.7)) @ rot("Y", 32 * sx) @ rot("X", -28)
    362:         pivot = Vector((.9 * sx, 2.25, 14.7))
    363:         solid(f"binder_hinge.{s}", cylinder(.225, pivot.x - .25, pivot.x + .25, 12, axis="x", at=(pivot.y, pivot.z)), "joint",
    364:               J["binder", s], smooth=True)
    365:         for k, dy in (("a", -.2), ("b", .2)):
    366:             solid(f"binder_fork{k}.{s}", two_view([(pivot.x - .28, 14.35), (pivot.x + .28, 14.35), (pivot.x + .28, 14.95), (pivot.x - .28, 14.95)],
    367:                                                  [(2.0 + dy - .06, 14.35), (2.0 + dy + .06, 14.35), (2.25 + dy + .06, 14.95), (2.25 + dy - .06, 14.95)]),
    368:                   "frame", B, bevel=0.015)
    369:         # a dark spar between two thin blades
    370:         spar = loft([(-.7, octo(.22, .3, .06)), (2.3, octo(.16, .24, .04))])
    371:         solid(f"binder_spar.{s}", transform(spar, m), "frame", J["binder", s], bevel=0.015)
    372:         for k, bx in (("a", .12), ("b", -.12)):
    373:             blade = prism([(-.38, -.6), (.36, -.5), (.24, 2.1), (-.16, 2.25)], bx - .06, bx + .06, "yz")
    374:             solid(f"binder_blade{k}.{s}", transform(blade, m), "main", J["binder", s], bevel=0.02)
    375:         tip = loft([(1.9, octo(.32, .44, .08)), (2.6, octo(.2, .3, .05))])
    376:         solid(f"binder_tip.{s}", transform(tip, m), "accent", J["binder", s], bevel=0.015)
    377:         bell, glow = nozzle(.3, .55)
    378:         down = m.to_3x3() @ Vector((0, 0, -1))
    379:         at = m @ Vector((0, 0, -.7))
    380:         solid(f"binder_nozzle.{s}", place(bell, at, down), "frame", J["binder", s], smooth=True)
    381:         solid(f"binder_nozzle.{s}.glow", place(glow, at, down), "glow_thruster", J["binder", s])
    382:         empty(f"nozzle.binder.{s}", at + down * .55, J["binder", s], dir=gltf_dir(down), radius=.3)
    383:         hilt = transform(cylinder(.14, 0, 1.15, 8), Matrix.Translation((.62 * sx, 2.05, 14.85)) @ rot("X", -30))
    384:         solid(f"saber_hilt.{s}", hilt, "frame", B, smooth=True)
    385:         cap = transform(cylinder(.17, 1.0, 1.2, 8), Matrix.Translation((.62 * sx, 2.05, 14.85)) @ rot("X", -30))
    386:         solid(f"saber_cap.{s}", cap, "trim", B, smooth=True)
    387:     nozzle_pair("main", (.55, 2.05, 12.65), (0, .45, -.9), .42, .8, B, B)
    388: 
    389: 
    390: def build_striker():
    391:     J = joints()
    392:     build_pelvis(J)
    393:     build_waist(J)
    394:     build_torso(J)
    395:     build_head(J)
    396:     J["neck"].location.z -= .24  # the head sits down between the collar plates
    397:     build_arms(J)
    398:     build_legs(J)
    399:     build_backpack(J)

    1 more lines not shown.

agent

+37:11
reasoning

Examining kit/mech.py and kit/lib.py revealed the architectural foundation of striker, including design decisions and underlying construction principles. This analysis provides a complete understanding of striker’s architecture and identifies areas for improvement in a next-generation approach. Also reviewing src/render/eyes.ts.

  • read_file{"EndLine":120,"Path":"~/work/sortie/src/render/eyes.ts","StartLine":1}

    input

    {
      "EndLine": 120,
      "Path": "~/work/sortie/src/render/eyes.ts",
      "StartLine": 1
    }

    result, 121 lines

    Showing lines 1-120 of 139
    1: import * as THREE from 'three';
    2: 
    3: // How sensors and eyes give off light. Three treatments:
    4: //   bloom  the emitter is a bright surface and the bloom pass makes the halo (the original look)
    5: //   glass  a dimmer emitter under a tinted, reflective cover: the light reads as behind glass
    6: //   spill  glass, plus a small coloured light at each eye so the socket and brow catch the colour
    7: export type EyeMode = 'bloom' | 'glass' | 'spill' | EyeStyle;
    8: 
    9: /**
    10:  * Eye styles for the light study. Each restyles the two lamp roles: glow_eye (the rim, or the whole
    11:  * eye on older heads) and glow_hot (the core).
    12:  *   clear    no light: tinted translucent glass over a mirror backing, like a model kit's clear parts
    13:  *   led      thin cold white, no colour, no halo
    14:  *   amber    warm sodium amber, soft
    15:  *   threat   one hot red, the enemy read
    16:  *   scanner  a bright spot sweeping along the eye, the rest dim
    17:  *   lens     eyes dark: a glossy black lens with one small glint, lit only by its surroundings
    18:  *   phosphor CRT green with scanlines
    19:  *   pulse    the colour breathes slowly between dim and bright
    20:  */
    21: export type EyeStyle = 'clear' | 'led' | 'amber' | 'threat' | 'scanner' | 'lens' | 'phosphor' | 'pulse';
    22: export const EYE_STYLES: EyeStyle[] = ['clear', 'led', 'amber', 'threat', 'scanner', 'lens', 'phosphor', 'pulse'];
    23: 
    24: const t0 = performance.now();
    25: function lampShader(rim: THREE.Color, core: THREE.Color, kind: 'scanner' | 'phosphor' | 'pulse', box: THREE.Box3, freeze: number | null) {
    26:   const m = new THREE.ShaderMaterial({
    27:     uniforms: {
    28:       rim: { value: rim }, core: { value: core }, time: { value: 0 },
    29:       x0: { value: box.min.x }, x1: { value: box.max.x },
    30:     },
    31:     vertexShader: 'varying vec3 vP; void main() { vP = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }',
    32:     fragmentShader: `
    33:       uniform vec3 rim, core; uniform float time, x0, x1; varying vec3 vP;
    34:       void main() {
    35:         float u = (vP.x - x0) / max(x1 - x0, 1e-3);
    36:         vec3 c = rim;
    37:         ${kind === 'scanner' ? `
    38:         float p = 0.5 + 0.5 * sin(time * 2.2);
    39:         float spot = exp(-pow((u - p) * 9.0, 2.0));
    40:         c = rim * 0.25 + core * spot * 1.6;` : kind === 'phosphor' ? `
    41:         float line = 0.65 + 0.35 * step(0.5, fract(gl_FragCoord.y / 3.0));
    42:         c = rim * line;` : `
    43:         c = rim * (0.35 + 0.65 * (0.5 + 0.5 * sin(time * 1.6)));`}
    44:         gl_FragColor = vec4(c, 1.0);
    45:       }`,
    46:   });
    47:   const tick = () => { m.uniforms.time.value = freeze ?? (performance.now() - t0) / 1000; };
    48:   return { m, tick };
    49: }
    50: 
    51: function styleEyes(root: THREE.Object3D, style: EyeStyle, freeze: number | null) {
    52:   const meshes: THREE.Mesh[] = [];
    53:   root.traverse((o) => {
    54:     const m = o as THREE.Mesh;
    55:     if (m.isMesh && (m.userData.role === 'glow_eye' || m.userData.role === 'glow_hot') && !m.userData.treated) meshes.push(m);
    56:   });
    57:   const C = (hex: string, k: number) => new THREE.Color(hex).multiplyScalar(k);
    58:   for (const e of meshes) {
    59:     e.userData.treated = true;
    60:     const isCore = e.userData.role === 'glow_hot';
    61:     e.geometry.computeBoundingBox();
    62:     const box = e.geometry.boundingBox!;
    63:     switch (style) {
    64:       case 'clear':
    65:         e.material = new THREE.MeshPhysicalMaterial({
    66:           color: isCore ? '#bff7ee' : '#2fd4bd', metalness: 0.6, roughness: 0.08, clearcoat: 1, clearcoatRoughness: 0.02,
    67:           emissive: new THREE.Color(isCore ? '#2fd4bd' : '#0a5a50'), emissiveIntensity: isCore ? 0.6 : 0.35,
    68:         });
    69:         break;
    70:       case 'led':
    71:         e.material = new THREE.MeshBasicMaterial({ color: C(isCore ? '#ffffff' : '#dfe8ff', isCore ? 1.35 : 0.9) });
    72:         break;
    73:       case 'amber':
    74:         e.material = new THREE.MeshBasicMaterial({ color: C(isCore ? '#ffe2a8' : '#ff9a2e', isCore ? 1.3 : 1.0) });
    75:         break;
    76:       case 'threat':
    77:         e.material = new THREE.MeshBasicMaterial({ color: C(isCore ? '#ffd0c8' : '#ff2a20', isCore ? 1.5 : 1.2) });
    78:         break;
    79:       case 'lens':
    80:         e.material = new THREE.MeshPhysicalMaterial({ color: '#05070a', metalness: 0.2, roughness: 0.04, clearcoat: 1, clearcoatRoughness: 0.0 });
    81:         if (isCore) e.material = new THREE.MeshBasicMaterial({ color: C('#bfefff', 0.5) });
    82:         break;
    83:       case 'scanner': case 'phosphor': case 'pulse': {
    84:         const rim = style === 'phosphor' ? C('#6dff8a', 1.1) : style === 'pulse' ? C('#55e6d6', 1.4) : C('#ff3b30', 1.2);
    85:         const core = style === 'phosphor' ? C('#d8ffe0', 1.3) : style === 'pulse' ? C('#e6fffb', 1.6) : C('#ffe0dc', 1.6);
    86:         const { m, tick } = lampShader(isCore ? core : rim, core, style, box, freeze);
    87:         e.material = m;
    88:         e.onBeforeRender = tick;
    89:         break;
    90:       }
    91:     }
    92:   }
    93: }
    94: 
    95: const cover = new THREE.MeshPhysicalMaterial({
    96:   color: '#0b1418', roughness: 0.06, metalness: 0, clearcoat: 1, clearcoatRoughness: 0.04,
    97:   transparent: true, opacity: 0.28, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2,
    98: });
    99: const dimmed = new Map<THREE.Material, THREE.MeshBasicMaterial>();
    100: 
    101: function dim(m: THREE.MeshBasicMaterial, k: number) {
    102:   let d = dimmed.get(m);
    103:   if (!d) {
    104:     d = m.clone();
    105:     d.color.multiplyScalar(k);
    106:     dimmed.set(m, d);
    107:   }
    108:   return d;
    109: }
    110: 
    111: /** Apply an eye treatment to every glow_eye mesh under root. `freeze` pins animated styles to a moment. */
    112: export function treatEyes(root: THREE.Object3D, mode: EyeMode, freeze: number | null = null) {
    113:   if (mode === 'bloom') return;
    114:   if ((EYE_STYLES as string[]).includes(mode)) return styleEyes(root, mode as EyeStyle, freeze);
    115:   const eyes: THREE.Mesh[] = [];
    116:   root.traverse((o) => {
    117:     const m = o as THREE.Mesh;
    118:     if (m.isMesh && m.userData.role === 'glow_eye' && !m.userData.treated) eyes.push(m);
    119:   });
    120:   for (const e of eyes) {
  • read_file{"EndLine":150,"Path":"~/work/sortie/src/render/materials.ts","StartLine":1}

    input

    {
      "EndLine": 150,
      "Path": "~/work/sortie/src/render/materials.ts",
      "StartLine": 1
    }

    result, 131 lines

    Showing lines 1-130 of 130
    1: import * as THREE from 'three';
    2: import type { Palette, Role } from './palette';
    3: import { addPaintVariation, look } from './look';
    4: 
    5: /** Painted armour roles: their finish follows the look (matte field paint or gloss kit paint). */
    6: const PAINT = new Set<Role>(['main', 'accent', 'trim', 'hull', 'suit', 'donor_a', 'donor_b', 'donor_c', 'primer', 'handpaint',
    7:   'warpaint']);
    8: /** Unpainted roles: no wear, grime or ink lines from the detail pass (alien crystal). */
    9: export const BARE = new Set<Role>(['crystal', 'crystal_lit']);
    10: 
    11: // Physically based materials by role: painted armour, bare and dark metal, glass, and unlit glows
    12: // that feed the bloom.
    13: 
    14: /** Diagonal hazard stripes from world position, so no UVs are needed. */
    15: function addStripes(m: THREE.MeshStandardMaterial) {
    16:   m.onBeforeCompile = (shader) => {
    17:     shader.vertexShader = shader.vertexShader
    18:       .replace('#include <common>', '#include <common>\nvarying vec3 vStripePos;')
    19:       .replace('#include <worldpos_vertex>', '#include <worldpos_vertex>\nvStripePos = (modelMatrix * vec4(transformed, 1.0)).xyz;');
    20:     shader.fragmentShader = shader.fragmentShader
    21:       .replace('#include <common>', '#include <common>\nvarying vec3 vStripePos;')
    22:       .replace(
    23:         '#include <color_fragment>',
    24:         `#include <color_fragment>
    25:          float stripe = step(0.5, fract((vStripePos.x + vStripePos.y + vStripePos.z) * 0.6));
    26:          diffuseColor.rgb = mix(vec3(0.03, 0.03, 0.035), diffuseColor.rgb, stripe);`,
    27:       );
    28:   };
    29:   m.customProgramCacheKey = () => 'stripes';
    30: }
    31: 
    32: const cache = new Map<string, THREE.Material>();
    33: 
    34: let bands: THREE.DataTexture | null = null;
    35: /** Three lighting bands for the sketch look: shade, half-tone, lit. */
    36: function toonBands() {
    37:   if (bands) return bands;
    38:   const d = new Uint8Array([60, 60, 60, 140, 255, 255]);
    39:   bands = new THREE.DataTexture(d, d.length, 1, THREE.RedFormat);
    40:   bands.minFilter = bands.magFilter = THREE.NearestFilter;
    41:   bands.needsUpdate = true;
    42:   return bands;
    43: }
    44: 
    45: export function material(palette: Palette, role: Role, key: string): THREE.Material {
    46:   const l = look();
    47:   const id = `${key}:${role}:${l.name}`;
    48:   const hit = cache.get(id);
    49:   if (hit) return hit;
    50:   const p = palette[role] ?? { color: '#ff00ff' };
    51:   let m: THREE.Material;
    52:   if (p.glow) {
    53:     m = new THREE.MeshBasicMaterial({ color: new THREE.Color(p.color).multiplyScalar(p.glow) });
    54:   } else {
    55:     // A floor on roughness: a near-mirror catching the sun makes a highlight brighter than the
    56:     // half-float buffers can hold, and the bloom smears that across the whole screen.
    57:     const painted = PAINT.has(role);
    58:     // a lacquered livery keeps its own finish under a matte look: its roughness at most, and a clear coat
    59:     const lacquer = painted ? p.lacquer ?? 0 : 0;
    60:     const paintRough = lacquer ? Math.min(l.paintRough, p.rough ?? l.paintRough) : l.paintRough;
    61:     const roughness = Math.max(0.2, painted ? paintRough : p.rough ?? 0.5);
    62:     const coat = painted ? Math.max(l.gloss ? 0.6 : 0, lacquer) : p.coat ?? 0;
    63:     const color = new THREE.Color(p.color);
    64:     if (painted && l.desaturate > 0) {
    65:       // weathered paint: pulled toward grey and warmed slightly, less so under lacquer
    66:       const grey = color.r * 0.3 + color.g * 0.59 + color.b * 0.11;
    67:       color.lerp(new THREE.Color(grey, grey, grey), l.desaturate * (1 - lacquer * 0.6)).multiply(new THREE.Color(1.0, 0.98, 0.94));
    68:     }
    69:     if (l.toon) {
    70:       const t = new THREE.MeshToonMaterial({ color, gradientMap: toonBands() });
    71:       t.name = role;
    72:       if (role === 'hazard') addStripes(t as unknown as THREE.MeshStandardMaterial);
    73:       cache.set(id, t);
    74:       return t;
    75:     }
    76:     const s = coat >= 0.5
    77:       ? new THREE.MeshPhysicalMaterial({ color, roughness, metalness: p.metal ?? 0, clearcoat: coat, clearcoatRoughness: 0.25 })
    78:       : new THREE.MeshStandardMaterial({ color, roughness, metalness: p.metal ?? 0 });
    79:     if (p.emit) s.emissive.copy(color).multiplyScalar(p.emit);
    80:     if (role === 'hazard') addStripes(s);
    81:     else if (painted || role === 'frame' || role === 'joint' || role === 'rust') addPaintVariation(s, l.grime * (painted ? 1 : 0.6));
    82:     if (p.rust) addRust(s, p.rust);
    83:     m = s;
    84:   }
    85:   m.name = role;
    86:   cache.set(id, m);
    87:   return m;
    88: }
    89: 
    90: /** Rust from world position, so no UVs are needed: blotches that grow with `amount`, streaks running down
    91:  *  from them, rougher and duller where the paint has gone. */
    92: function addRust(m: THREE.MeshStandardMaterial, amount: number) {
    93:   const prev = m.onBeforeCompile;
    94:   m.onBeforeCompile = (shader, r) => {
    95:     prev?.call(m, shader, r);
    96:     shader.vertexShader = shader.vertexShader
    97:       .replace('#include <common>', '#include <common>\nvarying vec3 vRustPos;')
    98:       .replace('#include <worldpos_vertex>', '#include <worldpos_vertex>\nvRustPos = (modelMatrix * vec4(transformed, 1.0)).xyz;');
    99:     shader.fragmentShader = shader.fragmentShader
    100:       .replace('#include <common>', `#include <common>
    101:         varying vec3 vRustPos;
    102:         float rn(vec3 p) { vec3 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f);
    103:           vec3 k = vec3(12.9, 78.2, 37.7);
    104:           return mix(mix(mix(fract(sin(dot(i, k)) * 43758.5), fract(sin(dot(i + vec3(1,0,0), k)) * 43758.5), f.x),
    105:                          mix(fract(sin(dot(i + vec3(0,1,0), k)) * 43758.5), fract(sin(dot(i + vec3(1,1,0), k)) * 43758.5), f.x), f.y),
    106:                      mix(mix(fract(sin(dot(i + vec3(0,0,1), k)) * 43758.5), fract(sin(dot(i + vec3(1,0,1), k)) * 43758.5), f.x),
    107:                          mix(fract(sin(dot(i + vec3(0,1,1), k)) * 43758.5), fract(sin(dot(i + vec3(1,1,1), k)) * 43758.5), f.x), f.y), f.z); }
    108:         float rustMask(vec3 p) {
    109:           // patches where paint has gone, fine-grained, and thin streaks running down from them
    110:           float blot = rn(p * 1.3) * 0.6 + rn(p * 4.7) * 0.4;
    111:           float t = 1.0 - ${(0.7 * amount).toFixed(3)};
    112:           float streak = smoothstep(0.6, 0.82, rn(vec3(p.x * 9.0, p.y * 0.22, p.z * 9.0))) * smoothstep(t - 0.2, t, rn(p * 0.9));
    113:           return clamp(smoothstep(t, t + 0.06, blot) + streak * 0.6, 0.0, 1.0);
    114:         }`)
    115:       .replace('#include <color_fragment>', `#include <color_fragment>
    116:         float rm = rustMask(vRustPos);
    117:         vec3 rc = mix(vec3(0.15, 0.065, 0.03), vec3(0.34, 0.14, 0.055), rn(vRustPos * 6.0));
    118:         diffuseColor.rgb = mix(diffuseColor.rgb, rc, rm);`)
    119:       .replace('#include <roughnessmap_fragment>', `#include <roughnessmap_fragment>
    120:         roughnessFactor = mix(roughnessFactor, 0.92, rm);`)
    121:       .replace('#include <metalnessmap_fragment>', `#include <metalnessmap_fragment>
    122:         metalnessFactor = mix(metalnessFactor, 0.15, rm);`);
    123:   };
    124:   const key = m.customProgramCacheKey?.bind(m);
    125:   m.customProgramCacheKey = () => `${key ? key() : ''}rust${amount}`;
    126: }
    127: 
    128: export function isRole(name: string): name is Role {
    129:   return /^[a-z_]+$/.test(name);
    130: }

agent

+37:19
reasoning

The code suggests a possible issue in how 3D objects are merged or how decals are applied. Specifically, the mergeParts function processes the root object and the applyDecals function processes the decal. Further investigation is needed to determine how these functions interact and if there is a mismatch or error in object transformations or handling.

The code identifies a potential issue with meshes having multiple materials. The mergeParts function skips meshes with multiple materials, while the paint function in assets.ts attempts to assign a single material to each mesh based on a role or material name. This suggests a conflict where the merging process might be incompatible with how materials are handled during painting, particularly when boolean operations are involved. Further analysis is required to determine the exact impact of this conflict.

  • read_file{"EndLine":139,"Path":"~/work/sortie/src/render/eyes.ts","StartLine":115}

    input

    {
      "EndLine": 139,
      "Path": "~/work/sortie/src/render/eyes.ts",
      "StartLine": 115
    }

    result, 26 lines

    Showing lines 115-139 of 139
    115:   const eyes: THREE.Mesh[] = [];
    116:   root.traverse((o) => {
    117:     const m = o as THREE.Mesh;
    118:     if (m.isMesh && m.userData.role === 'glow_eye' && !m.userData.treated) eyes.push(m);
    119:   });
    120:   for (const e of eyes) {
    121:     e.userData.treated = true;
    122:     const base = e.material as THREE.MeshBasicMaterial;
    123:     e.material = dim(base, 0.8);
    124:     const glass = new THREE.Mesh(e.geometry, cover);
    125:     glass.renderOrder = 2;
    126:     e.add(glass);
    127:     if (mode === 'spill') {
    128:       e.geometry.computeBoundingBox();
    129:       const box = e.geometry.boundingBox!;
    130:       const c = box.getCenter(new THREE.Vector3());
    131:       const size = box.getSize(new THREE.Vector3()).length();
    132:       const colour = base.color.clone().multiplyScalar(1 / Math.max(base.color.r, base.color.g, base.color.b, 1e-3));
    133:       const light = new THREE.PointLight(colour, 0.35 * Math.max(0.4, size), Math.max(0.6, size * 1.6), 2);
    134:       light.position.copy(c);
    135:       light.userData.spill = true;
    136:       e.add(light);
    137:     }
    138:   }
    139: }

agent

+37:53
reasoning

The glow_eye mesh, responsible for emitting light, should be restricted to the head or weapon scopes, according to code in src/render/eyes.ts. This configuration suggests a specific lighting design where these meshes are the primary light sources.

The merging of dual eyes into a single mesh and light source seems efficient, promoting shader and light budget optimization by creating head:glow_eye. Reviewing existing mech implementations, specifically striker_a, striker_b in assembly.py and those in atelier_board.py, will inform a deviation strategy aligned with the project owner's goals. This will help understand existing best practices, identify areas for improvement, and validate the proposed approach against previous work.

  • read_file{"EndLine":100,"Path":"~/work/sortie/kit/blocks/dummy.py","StartLine":1}

    input

    {
      "EndLine": 100,
      "Path": "~/work/sortie/kit/blocks/dummy.py",
      "StartLine": 1
    }

    result, 10 lines

    Showing lines 1-9 of 9
    1: """Test fixture for the block tools: an automatic box on every bone, sized from the default joints.
    2: Not a design. Delete nothing here, copy it to start a real block file."""
    3: 
    4: 
    5: def build(Blocks):
    6:     b = Blocks()
    7:     b.mannequin()
    8:     pack = b.at("backpack")
    9:     b.nozzles("backpack", (.5, pack.y + .4, pack.z - .9), (0, .45, -.9))
  • read_file{"EndLine":100,"Path":"~/work/sortie/kit/lab/assembly.py","StartLine":1}

    input

    {
      "EndLine": 100,
      "Path": "~/work/sortie/kit/lab/assembly.py",
      "StartLine": 1
    }

    result, 101 lines

    Showing lines 1-100 of 209
    1: """Fit lab variants onto the full striker frame: its head, chest armour and feet are removed and
    2: variants built onto the same joints. This is part swapping, the way the game will do it."""
    3: import re
    4: 
    5: import bpy
    6: from mathutils import Matrix, Vector
    7: 
    8: import backkit
    9: import bodykit
    10: import chestkit
    11: import headkit
    12: from lib import attach, empty
    13: from mech import build_striker
    14: 
    15: # striker parts replaced by a chest variant (base names; Blender may add .001 suffixes)
    16: CHEST_PARTS = {"chest_plate.L", "chest_plate.R", "chest_strip.L", "chest_strip.R", "rib_plate0.L", "rib_plate0.R", "rib_plate1.L",
    17:                "rib_plate1.R", "side_plate.L", "side_plate.R", "belly", "belly_vent", "lens_socket", "lens", "lens_core", "hatch",
    18:                "collar.L", "collar.R", "collar_side.L", "collar_side.R", "collar_vent.L", "collar_vent.R", "back_plate", "neck_guard"}
    19: 
    20: 
    21: def base(name):
    22:     return re.sub(r"\.\d{3}$", "", name)
    23: 
    24: 
    25: def joint(frame, name):
    26:     for o in frame.children_recursive:
    27:         if o.type == "EMPTY" and base(o.name) == name:
    28:             return o
    29:     raise KeyError(name)
    30: 
    31: 
    32: def remove(objs):
    33:     for o in objs:
    34:         bpy.data.objects.remove(o, do_unlink=True)
    35: 
    36: 
    37: def fit(build, at, parent):
    38:     """Build a variant into a temporary empty at `at`, then hand its parts to a frame joint."""
    39:     tmp = empty("_fit", at)
    40:     build(tmp)
    41:     for ob in list(tmp.children):
    42:         ob.matrix_parent_inverse = Matrix.Identity(4)
    43:         ob.location = (0, 0, 0)
    44:     bpy.context.view_layer.update()
    45:     for ob in list(tmp.children):
    46:         attach(ob, parent)
    47:     bpy.data.objects.remove(tmp, do_unlink=True)
    48: 
    49: 
    50: def assemble(head_parts, chest, foot, n, extras=(), fold=0.0):
    51:     frame = build_striker()
    52:     bpy.context.view_layer.update()
    53:     head_j, torso_j = joint(frame, "head"), joint(frame, "torso")
    54:     remove([o for o in head_j.children_recursive if o.type == "MESH"])
    55:     remove([o for o in torso_j.children if o.type == "MESH" and base(o.name) in CHEST_PARTS])
    56:     for s in ("L", "R"):
    57:         remove([o for o in joint(frame, f"foot.{s}").children_recursive if o.type == "MESH" and base(o.name) != f"ankle.{s}"])
    58:     bodykit.CONTEXT = False
    59:     try:
    60:         fit(lambda r: headkit.head_gen4(r, f"{n}h", head_parts, extras, fold), (0, -.05, 15.55), head_j)
    61:         fit(lambda r: chest(r, f"{n}c"), (0, 0, 11.9), torso_j)
    62:         for s, sx in (("L", 1), ("R", -1)):
    63:             fit(lambda r, s=s: foot(r, f"{n}f{s}"), (1.2 * sx, .1, .15), joint(frame, f"foot.{s}"))
    64:     finally:
    65:         bodykit.CONTEXT = True
    66:     return frame
    67: 
    68: 
    69: H = dict(headkit.GEN4)
    70: COMBOS = [
    71:     ("A", "Mantle IV", lambda r, n: bodykit.chest_hatch3(r, n, diamond=True), bodykit.foot_claw3),
    72:     ("B", "Duelist IV", bodykit.chest_swept3, bodykit.foot_raptor),
    73:     ("C", "Sentinel IV", bodykit.chest_cuirass3, bodykit.foot_sabaton2),
    74:     ("D", "Warden IV", bodykit.chest_hatch3, bodykit.foot_talon),
    75:     ("E", "Tracker IV", bodykit.chest_swept3, bodykit.foot_skid),
    76:     ("F", "Lancer IV", bodykit.chest_cuirass3, bodykit.foot_boot2),
    77: ]
    78: 
    79: 
    80: def build_assembly_lab():
    81:     root = empty("lab", (0, 0, 0))
    82:     for i, (tag, head, chest, foot) in enumerate(COMBOS):
    83:         frame = assemble(H[head], chest, foot, f"a{i}")
    84:         slot = empty(f"slot{i}", (i * 11.0, 0, 0), root, label=f"{tag}: {head}")
    85:         attach(frame, slot)
    86:         frame.matrix_parent_inverse = Matrix.Identity(4)
    87:         frame.location = (0, 0, 0)
    88:         bpy.context.view_layer.update()
    89:     return root
    90: 
    91: 
    92: # striker shoulder-shell parts replaced by a shoulder variant (block, trunnion and forks stay)
    93: SHOULDER_PARTS = {"shell0", "shell1", "shell_under", "shell_blade", "shell_edge", "shell_fin"}
    94: 
    95: 
    96: def move(j, at):
    97:     j.location = j.parent.matrix_world.inverted() @ Vector(at)
    98:     bpy.context.view_layer.update()
    99: 
    100:
  • read_file{"EndLine":100,"Path":"~/work/sortie/kit/lab/atelier_board.py","StartLine":1}

    input

    {
      "EndLine": 100,
      "Path": "~/work/sortie/kit/lab/atelier_board.py",
      "StartLine": 1
    }

    result, 65 lines

    Showing lines 1-64 of 64
    1: """The atelier's four house lines, each in three grades, one lab per line (docs/study-atelier.md):
    2: 
    3:   lab_atelier_a  Harness  plate armour taken seriously     (board_plate)
    4:   lab_atelier_b  Estoc    sleek, few shapes, sharp points  (board_sleek)
    5:   lab_atelier_c  Blazon   bold heraldic, per pale          (board_heraldic)
    6:   lab_atelier_d  Tilt     lopsided tourney harness         (board_tourney)
    7: 
    8: Slots along X: slot1 light, slot2 medium, slot3 heavy. Round 1's medium for reference is lab_atelier's
    9: slot2 (kit/lab/atelier_lab.py). In the houses' livery:
    10: 
    11:     /?view=lab_atelier_c&only=slot2&tx=20&palette=houses&bg=studio
    12: 
    13: ATELIER_SLOTS=1,2 builds only those slots.
    14: """
    15: import os
    16: 
    17: import bpy
    18: from mathutils import Matrix
    19: 
    20: import board_heraldic
    21: import board_plate
    22: import board_sleek
    23: import board_tourney
    24: import frame_std
    25: from lib import attach, empty
    26: from makers import atelier
    27: from makers.shell import Plates
    28: 
    29: SPACING = 10.0
    30: GRADES = ("light", "medium", "heavy")
    31: KNEE = {"light": .41, "medium": .40, "heavy": .39}  # round 1's .43 left a tenth of a metre of thigh
    32: LINES = {"a": ("Harness", board_plate.plates), "b": ("Estoc", board_sleek.plates), "c": ("Blazon", board_heraldic.plates),
    33:          "d": ("Tilt", board_tourney.plates)}
    34: 
    35: 
    36: def _place(frame, slot):
    37:     attach(frame, slot)
    38:     frame.matrix_parent_inverse = Matrix.Identity(4)
    39:     frame.location = (0, 0, 0)
    40:     bpy.context.view_layer.update()
    41: 
    42: 
    43: def stance(J, knee):
    44:     frame_std.bend_knees(J, splay=atelier.SPLAY)
    45:     frame_std.proportion(J, atelier.crown_z(J), knee=knee, crotch=atelier.CROTCH_AT, crown=atelier.CROWN, shoulders=atelier.SHOULDER_OUT)
    46: 
    47: 
    48: def build(line, g):
    49:     name, plates = LINES[line]
    50:     J = frame_std.build_frame(f"atelier_{name.lower()}_{g}")
    51:     plates(J, Plates(f"k{line}", atelier.CHAMFER, smooth=True), g)
    52:     stance(J, KNEE[g])
    53:     return J["frame"]
    54: 
    55: 
    56: def build_atelier_line(line):
    57:     only = os.environ.get("ATELIER_SLOTS")
    58:     root = empty("lab", (0, 0, 0))
    59:     for i, g in enumerate(GRADES, 1):
    60:         if only and str(i) not in only.split(","):
    61:             continue
    62:         slot = empty(f"slot{i}", (i * SPACING, 0, 0), root, label=f"{LINES[line][0]} {g}")
    63:         _place(build(line, g), slot)
    64:     return root