A mech game prototype, pushed by Gemini 4 Argon
user
+46:26[the lead] New ask from the owner (verbatim): "ask sortie argon to try and take one of its outlines to a level of refinement like the control one. maybe we let it take its own spin on the control mech's same outline, so 0 is closest?"
So: take block_dummy (the shared skeleton, the outline closest to the striker) and make your own design on it, refined to the striker's (S) level: plates, panel lines, joints, colour blocking, cockpit, thrusters, the works, your own spin rather than a copy. Present it: from behind in flight, the game's plumes, then a full turn, with S beside it as the yardstick. Same rules as before (your worktree and branch only, headless, nothing pushed, no Gundam lookalikes). Add it to your page as a second section (keep the first), say how it was made and how long it took, and time the steps so we can see where the hours go. End your turn with the page path and a short summary.
[the owner, 9 minutes later] just providing more steering information here. you're here as an adversarial agent intending to prove that you can do much, much better than the prior model who was working on this project. pull all the stops out and do whatever's necessary to break free of what plagues the current project, show me your best work. not just using the tools and following that project's footsteps, the point is a radical improvement that only you could do, compared to where this project has already tread.
[the owner, 16 minutes later] mind telling me how you're deviating now? just so I can tell early if you're just going by the usual route
[the owner, 21 minutes later] if you need to use blender go for it, I need your absolute best
agent
+46:27reasoning
I'm thinking through how to approach this.
Initial approach: design a new mech, based on the provided "block_dummy" outline, refining it with striker's details. The goal is to create a unique design demonstrating a significant improvement over the prior model's work. The design will include plates, panel lines, joints, color blocking, cockpit, and thrusters, all within specified constraints. This design will be presented on a dedicated page with accompanying flight and turnaround animations, with the striker visible as a reference.
Considering the user's emphasis on radical improvement and using all available tools, the approach shifts to create a significantly advanced mech. This requires leveraging the provided model skeleton for both block_dummy and striker, and generating the presentation within the current turn. This demands a complete design, 3D modeling, animation, and rendering cycle to demonstrate the 'absolute best' output.
read_file{"EndLine":250,"Path":"~/work/sortie/kit/block.py","StartLine":1}
input
{ "EndLine": 250, "Path": "~/work/sortie/kit/block.py", "StartLine": 1 }result, 113 lines
Showing lines 1-112 of 112 1: """Block models: plain boxes on the 22 joint rig, for judging mass and motion before any plate exists. 2: 3: A block model is one file, kit/blocks/<name>.py, with a build() that takes this module's Blocks class. 4: It builds in seconds, into a gitignored public/assets/block_<name>.glb: 5: 6: npm run kit -- block_dummy 7: npm run clip -- block_dummy 8: 9: Geometry is authored in world rest pose coordinates in metres, models facing -Y, Z up, left is +X, as 10: in the rest of the kit. Roles are the usual ones (main, accent, frame, joint). Nothing here is a design 11: rule: no maker, frame or grade carries over unless a block file asks for it. 12: """ 13: import importlib 14: 15: import bpy 16: from mathutils import Vector 17: 18: from lib import loft, merge, mirror_x, octo, solid 19: from mech import joints as striker_joints, nozzle_pair, pair 20: 21: SIDED = {"shoulder", "upperarm", "forearm", "hand", "grip", "thigh", "shin", "foot", "binder"} 22: BEVEL = .03 23: 24: 25: class Blocks: 26: """The rig plus block primitives. `joints` overrides rest positions: {"thigh": (1.1, 0, 9.5)} moves 27: both thighs (give the left, +X, the right mirrors), {"pelvis": (0, 0, 9.8)} moves one node. Other 28: joints stay where the striker has them, in world coordinates, so moving one moves nothing else.""" 29: 30: def __init__(self, joints=None, height=17.6): 31: J = striker_joints() 32: self.nodes = {o.name: o for o in J.values()} 33: self.n = 0 34: J["frame"]["frame"] = "block" 35: J["frame"]["height"] = height 36: place = {name: o.matrix_world.translation.copy() for name, o in self.nodes.items()} 37: for key, at in (joints or {}).items(): 38: if key in SIDED: 39: place[f"{key}.L"] = Vector(at) 40: place[f"{key}.R"] = Vector((-at[0], at[1], at[2])) 41: elif key in place: 42: place[key] = Vector(at) 43: else: 44: raise KeyError(f"block: no joint {key}") 45: for name, o in self.nodes.items(): # striker_joints() makes parents first 46: if o.parent is not None: 47: o.location = o.parent.matrix_world.inverted() @ place[name] 48: bpy.context.view_layer.update() 49: 50: def at(self, name): 51: return self.nodes[name].matrix_world.translation.copy() 52: 53: def _put(self, joint, bm, role, mirror): 54: self.n += 1 55: name = f"block{self.n}_{joint}" 56: if joint in SIDED: 57: pair(name, bm, role, self.nodes[f"{joint}.L"], self.nodes[f"{joint}.R"], bevel=BEVEL, panels=False) 58: elif mirror: 59: solid(name, merge(bm, mirror_x(bm)), role, self.nodes[joint], bevel=BEVEL, panels=False) 60: else: 61: solid(name, bm, role, self.nodes[joint], bevel=BEVEL, panels=False) 62: 63: def box(self, joint, x, y, z, role="main", mirror=False): 64: """A box from x, y, z ranges (lo, hi). A sided joint (thigh, shin, ...) takes the left's numbers 65: and mirrors to the right. `mirror` does the same for a box on a centre joint.""" 66: r = [(x[0], y[0]), (x[1], y[0]), (x[1], y[1]), (x[0], y[1])] 67: self._put(joint, loft([(z[0], r), (z[1], r)]), role, mirror) 68: 69: def taper(self, joint, rings, role="main", mirror=False, chamfer=.15): 70: """A lofted block through rings (z, width, depth, x, y), bottom to top.""" 71: self._put(joint, loft([(z, octo(w, d, chamfer, x=x, y=y)) for z, w, d, x, y in rings]), role, mirror) 72: 73: def bone(self, joint, a, b, w, d, role="main", chamfer=.1): 74: """A block from joint a to joint b, both named for the left side: bone("thigh", "thigh.L", "shin.L", 1, 1).""" 75: pa, pb = self.at(a), self.at(b) 76: lo, hi = (pa, pb) if pa.z < pb.z else (pb, pa) 77: self.taper(joint, [(lo.z, w, d, lo.x, lo.y), (hi.z, w, d, hi.x, hi.y)], role, chamfer=chamfer) 78: 79: def nozzles(self, joint, at, direction, r=.45, length=.9, kind="main"): 80: """A nozzle pair that fires plumes in the game. `kind`: main, binder or calf.""" 81: if joint in SIDED: 82: jl, jr = self.nodes[f"{joint}.L"], self.nodes[f"{joint}.R"] 83: else: 84: jl = jr = self.nodes[joint] 85: nozzle_pair(kind, at, direction, r, length, jl, jr, housing=False) 86: 87: def mannequin(self): 88: """A neutral box on every bone, sized from the joints alone. For testing tools, not a design.""" 89: for joint, a, b, w, d in (("thigh", "thigh.L", "shin.L", 1.0, 1.0), ("shin", "shin.L", "foot.L", 1.0, 1.0), 90: ("upperarm", "upperarm.L", "forearm.L", .7, .7), ("forearm", "forearm.L", "hand.L", .7, .7)): 91: self.bone(joint, a, b, w, d) 92: foot = self.at("foot.L") 93: self.box("foot", (foot.x - .5, foot.x + .5), (foot.y - 1.2, foot.y + .6), (0, foot.z)) 94: hand = self.at("hand.L") 95: self.box("hand", (hand.x - .3, hand.x + .3), (hand.y - .3, hand.y + .3), (hand.z - .8, hand.z)) 96: pelvis, torso, neck, head = self.at("pelvis"), self.at("torso"), self.at("neck"), self.at("head") 97: self.box("pelvis", (-1.3, 1.3), (-.8, .8), (pelvis.z - .8, pelvis.z + .4)) 98: self.box("waist", (-.8, .8), (-.6, .6), (pelvis.z + .4, torso.z)) 99: shoulder = self.at("shoulder.L") 100: self.box("torso", (-shoulder.x, shoulder.x), (-1, 1), (torso.z, neck.z)) 101: self.box("shoulder", (shoulder.x, shoulder.x + .9), (-.6, .6), (shoulder.z - .6, shoulder.z + .4)) 102: self.box("neck", (-.3, .3), (-.3, .3), (neck.z, head.z)) 103: self.box("head", (-.5, .5), (-.6, .6), (head.z, head.z + 1.1)) 104: pack = self.at("backpack") 105: self.box("backpack", (-.9, .9), (pack.y - .5, pack.y + .5), (pack.z - 1, pack.z + 1)) 106: 107: 108: def build_block(name): 109: """block_<name> from kit/blocks/<name>.py.""" 110: module = importlib.import_module(f"blocks.{name.removeprefix('block_')}") 111: importlib.reload(module) 112: module.build(Blocks)read_file{"EndLine":250,"Path":"~/work/sortie/kit/blocks/dummy.py","StartLine":1}
input
{ "EndLine": 250, "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":400,"Path":"~/work/sortie/kit/mech.py","StartLine":90}
input
{ "EndLine": 400, "Path": "~/work/sortie/kit/mech.py", "StartLine": 90 }result, 312 lines
Showing lines 90-400 of 400 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) 400: return J["frame"]
agent
+46:43reasoning
Examining the code reveals presentation logic for in-flight game elements. The focus is on how various visual components are rendered, including plumes and camera behavior, and likely how these elements are visually managed. Initial analysis suggests the project handles game visuals from a specific behind-the-scenes point of view.
read_file{"EndLine":120,"Path":"~/work/sortie/src/view/clip.ts","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/src/view/clip.ts", "StartLine": 1 }result, 121 lines
Showing lines 1-120 of 139 1: import * as THREE from 'three'; 2: import { model, type ModelName } from '../render/assets'; 3: import { STRIKER_DECALS, applyDecals } from '../render/decals'; 4: import { treatEyes } from '../render/eyes'; 5: import type { ThrustReading } from '../render/exhaust'; 6: import { setLook, look } from '../render/look'; 7: import { MechRig, POSES } from '../render/mech'; 8: import type { PaletteName } from '../render/palette'; 9: import { Pipeline } from '../render/pipeline'; 10: import { addSpaceLight, createBackdrop, followSun, spaceEnvironment } from '../render/space'; 11: import { BEND_POSE, SHOT_NAMES, clipFrames, mixPose, shotView, type ShotName } from './clip-plan'; 12: import { CameraRig } from './cameras'; 13: import { benchInput } from './thrusters'; 14: 15: /** 16: * A review clip of one model, rendered frame by frame so it comes out the same on any machine. Driven by 17: * tools/clip.mjs, which calls window.__clip.render(i) and pipes the frames into ffmpeg. 18: * /?view=clip&model=block_dummy&shots=chase,turn&fps=24&palette=merc&look=kit 19: * Any model with the 22 joint rig. Lab lineups hold many frames under slots, so they don't rig. 20: */ 21: export async function startClip(canvas: HTMLCanvasElement, q: URLSearchParams) { 22: setLook(q.get('look')); 23: await document.fonts.ready; 24: const w = Number(q.get('w') ?? 854), h = Number(q.get('h') ?? 480), fps = Number(q.get('fps') ?? 24); 25: const shots = (q.get('shots')?.split(',') ?? SHOT_NAMES) as ShotName[]; 26: const frames = clipFrames(shots, fps); 27: 28: const scene = new THREE.Scene(); 29: const camera = new THREE.PerspectiveCamera(35, w / h, 0.3, 2e5); 30: const backdrop = createBackdrop(); 31: const pipe = new Pipeline(canvas, scene, camera, backdrop); 32: pipe.resize(w, h); 33: const sun = addSpaceLight(scene); 34: scene.environment = spaceEnvironment(pipe.renderer, backdrop); 35: scene.environmentIntensity = 0.8 * look().fill; 36: 37: const name = (q.get('model') ?? 'striker') as ModelName; 38: const palette = (q.get('palette') ?? 'merc') as PaletteName; 39: const root = await model(name, palette); 40: if (name === 'striker') applyDecals(root, STRIKER_DECALS); 41: treatEyes(root, 'spill'); 42: scene.add(root); 43: const rig = new MechRig(root); 44: root.updateMatrixWorld(true); 45: rig.apply(POSES.stand); 46: root.updateMatrixWorld(true); 47: const box = new THREE.Box3().setFromObject(root); 48: const height = box.getSize(new THREE.Vector3()).y; 49: const footY = box.min.y; 50: const size = height / 17.6; 51: 52: const light = new THREE.PointLight('#ffffff', 0, 0, 2); 53: scene.add(light); 54: 55: // the pilot and deck for the scale shot: a person is the one thing everyone knows the size of 56: const ground = new THREE.Group(); 57: const deck = new THREE.Mesh(new THREE.CircleGeometry(height * 2, 48), new THREE.MeshStandardMaterial({ color: '#2a2f36', roughness: 0.85, metalness: 0.2 })); 58: deck.rotation.x = -Math.PI / 2; 59: deck.position.y = footY; 60: ground.add(deck); 61: const pilot = await model('lab_pilot' as ModelName, palette); 62: pilot.traverse((o) => { if (/^slot\d+$/.test(o.name) && o.name !== 'slot0') o.visible = false; }); 63: // lab slot 0 stands at x = -.55: bring the pilot beside the frame's foot, facing the camera 64: pilot.position.set(0.55 + height * 0.3, footY, height * 0.16); 65: pilot.rotation.y = 0.4; 66: ground.add(pilot); 67: scene.add(ground); 68: 69: // the game's chase camera, read for its numbers: this view moves its own camera 70: const chase = new CameraRig(); 71: const reading: ThrustReading = { x: 0, y: 0, z: 0, boosting: false }; 72: const centre = new THREE.Vector3(); 73: const offset = new THREE.Vector3(); 74: const look_ = new THREE.Vector3(); 75: const up = new THREE.Vector3(0, 1, 0); 76: const yawQ = new THREE.Quaternion(); 77: const DT = 1 / 120; 78: let clock = 0; 79: 80: const feed = (state: Parameters<typeof benchInput>[0], t: number, dt: number) => { 81: const f = benchInput(state, t); 82: reading.x = f.thrust.x; 83: reading.y = f.thrust.y; 84: reading.z = f.thrust.z; 85: reading.boosting = f.boosting; 86: reading.assault = f.assault; 87: reading.quick = f.quick; 88: rig.thrust(reading, clock, dt); 89: rig.lightExhaust(light); 90: }; 91: 92: const render = (i: number) => { 93: const f = frames[i]; 94: const v = shotView(f); 95: // thrusters step at 120 Hz whatever the clip's frame rate, as a game would 96: const dt = f.cut ? 0 : 1 / fps; 97: if (f.cut) for (let k = 0; k < 120; k++) { clock += DT; feed('idle', k * DT, DT); } 98: for (let s = 0; s < dt - 1e-9; s += DT) { 99: clock += DT; 100: feed(f.state, Math.max(0, f.stateT - dt + s), DT); 101: } 102: if (dt === 0) feed(f.state, f.stateT, 0); 103: 104: root.rotation.y = THREE.MathUtils.degToRad(v.mechYaw); 105: rig.apply(v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose]); 106: root.updateMatrixWorld(true); 107: ground.visible = v.ground; 108: centre.set(0, footY + height * v.lookAt, 0); 109: const fov = v.chase ? chase.camera.fov : 35; 110: if (camera.fov !== fov) { 111: camera.fov = fov; 112: camera.updateProjectionMatrix(); 113: } 114: if (v.chase) { 115: // where the game's chase camera sits (src/view/cameras.ts), over the shoulder, scaled to the frame 116: yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw)); 117: offset.set(chase.shoulder * size, chase.chaseOffset.y * size, chase.chaseOffset.z * size).applyQuaternion(yawQ); 118: camera.position.copy(centre).add(offset); 119: look_.set(chase.shoulder * size, (chase.chaseOffset.y - chase.lookDrop) * size, 400).applyQuaternion(yawQ).add(centre); 120: camera.up.copy(up);read_file{"EndLine":120,"Path":"~/work/sortie/src/view/clip-plan.ts","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/src/view/clip-plan.ts", "StartLine": 1 }result, 105 lines
Showing lines 1-104 of 104 1: import type { Pose } from '../render/mech'; 2: import type { BenchState } from './thrusters'; 3: 4: /** 5: * The timeline of a review clip (src/view/clip.ts), as a pure function of frame number, so a clip is the 6: * same every run whatever the machine's speed. Shots frame the model and nothing here is a design choice: 7: * the chase shot sits where the game's camera sits, the rest show it from all round, bending and to scale. 8: */ 9: export const SHOTS = { chase: 3.5, orbit: 3, turn: 4, bend: 3, scale: 2.5 } as const; 10: export type ShotName = keyof typeof SHOTS; 11: export const SHOT_NAMES = Object.keys(SHOTS) as ShotName[]; 12: 13: /** Thruster states through a shot: [start second, state]. */ 14: const SCHEDULE: Partial<Record<ShotName, [number, BenchState][]>> = { 15: chase: [[0, 'cruise'], [1, 'boost'], [2.4, 'quick'], [3, 'cruise']], 16: orbit: [[0, 'boost'], [1.4, 'brake'], [2.2, 'idle']], 17: }; 18: 19: export interface ClipFrame { 20: shot: ShotName; 21: /** Seconds into the shot, and the same as a 0..1 fraction. */ 22: t: number; 23: u: number; 24: state: BenchState; 25: /** Seconds since this thruster state began. */ 26: stateT: number; 27: /** First frame of a shot: everything snaps. */ 28: cut: boolean; 29: } 30: 31: export function clipFrames(shots: readonly ShotName[], fps: number): ClipFrame[] { 32: const out: ClipFrame[] = []; 33: for (const shot of shots) { 34: const n = Math.max(1, Math.round(SHOTS[shot] * fps)); 35: const plan = SCHEDULE[shot] ?? [[0, 'idle'] as [number, BenchState]]; 36: for (let i = 0; i < n; i++) { 37: const t = i / fps; 38: let at = plan[0]; 39: for (const p of plan) if (p[0] <= t + 1e-9) at = p; 40: out.push({ shot, t, u: n > 1 ? i / (n - 1) : 0, state: at[1], stateT: t - at[0], cut: i === 0 }); 41: } 42: } 43: return out; 44: } 45: 46: /** Where things are in a shot. Lengths are in frame heights, angles in degrees. Yaw 0 looks at the 47: * frame's front, 180 at its back. `chase` means the game's chase camera, turned by mechYaw. */ 48: export interface ShotView { 49: chase: boolean; 50: mechYaw: number; 51: camYaw: number; 52: pitch: number; 53: dist: number; 54: /** Look point height as a fraction of the frame's height. */ 55: lookAt: number; 56: pose: 'flight' | 'stand'; 57: /** How far toward BEND_POSE, 0..1. */ 58: bend: number; 59: /** The pilot and the deck are in shot. */ 60: ground: boolean; 61: } 62: 63: const ease = (x: number) => x * x * (3 - 2 * x); 64: 65: export function shotView(f: ClipFrame): ShotView { 66: const base = { chase: false, mechYaw: 0, camYaw: 0, pitch: 8, dist: 2.4, lookAt: 0.5, pose: 'stand', bend: 0, ground: false } as ShotView; 67: switch (f.shot) { 68: case 'chase': { 69: // a gentle turn and back: the camera trails the frame, so the stars pan and the frame leans in shot 70: const turn = Math.sin(f.u * Math.PI * 2) * 22; 71: return { ...base, chase: true, mechYaw: turn, camYaw: turn * 0.75, pose: 'flight' }; 72: } 73: case 'orbit': 74: return { ...base, camYaw: 165 - 75 * ease(f.u), pitch: 12, dist: 2.2, pose: 'flight' }; 75: case 'turn': 76: return { ...base, camYaw: 180 + 360 * f.u }; 77: case 'bend': 78: return { ...base, camYaw: 35, pitch: 6, bend: Math.sin(f.u * Math.PI) ** 2 }; 79: case 'scale': 80: // from the deck beside the pilot, looking up at the frame, pushing in slowly 81: return { ...base, camYaw: 28, pitch: -6 + 2 * f.u, dist: 2.25 - 0.15 * ease(f.u), lookAt: 0.42, ground: true }; 82: } 83: } 84: 85: /** A deliberately large range of motion, to find plates that collide or joints that show. Glances at 86: * every limb: one arm up and forward, the other out, one knee high, a twist. */ 87: export const BEND_POSE: Pose = { 88: torso: [12, 18, 0], head: [-8, -24, 0], 89: 'upperarm.L': [-115, 0, 22], 'forearm.L': [-80, 0, 0], 90: 'upperarm.R': [-20, 0, -72], 'forearm.R': [-100, 0, 0], 91: 'thigh.L': [-85, 0, 10], 'shin.L': [100, 0, 0], 'foot.L': [-22, 0, 0], 92: 'thigh.R': [-8, 0, -14], 'shin.R': [22, 0, 0], 'foot.R': [8, 0, 0], 93: 'binder.L': [-20, 0, 0], 'binder.R': [20, 0, 0], 94: }; 95: 96: /** A blend of two poses, joint by joint. */ 97: export function mixPose(a: Pose, b: Pose, w: number): Pose { 98: const out: Pose = {}; 99: for (const j of new Set([...Object.keys(a), ...Object.keys(b)]) as Set<keyof Pose>) { 100: const p = a[j] ?? [0, 0, 0], q = b[j] ?? [0, 0, 0]; 101: out[j] = [p[0] + (q[0] - p[0]) * w, p[1] + (q[1] - p[1]) * w, p[2] + (q[2] - p[2]) * w]; 102: } 103: return out; 104: }read_file{"EndLine":120,"Path":"~/work/sortie/src/view/cameras.ts","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/src/view/cameras.ts", "StartLine": 1 }result, 103 lines
Showing lines 1-102 of 102 1: import * as THREE from 'three'; 2: 3: export type ViewMode = 'cockpit' | 'chase'; 4: 5: const FLIP = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI); 6: const _p = new THREE.Vector3(); 7: const _look = new THREE.Matrix4(); 8: const _up = new THREE.Vector3(); 9: 10: /** 11: * Cockpit: the camera sits at the frame's cockpit node, looking along the frame's nose. 12: * Chase (F5): over the frame's right shoulder, so the frame sits left of centre and the crosshair 13: * (screen centre) has clear space. Position follows rigidly; only the orientation is smoothed, so the 14: * frame never drifts toward or away from the camera when it speeds up or slows down. 15: */ 16: export class CameraRig { 17: mode: ViewMode = 'chase'; 18: readonly camera: THREE.PerspectiveCamera; 19: /** Chase offset in the frame's axes (+X is the frame's left, +Z forward). X is set from `shoulder`. */ 20: chaseOffset = new THREE.Vector3(0, 4.5, -30); 21: /** How far over the right shoulder the chase camera sits in flight (negative X is the frame's right). */ 22: shoulder = -8.5; 23: /** How far below the camera the look point sits, so the frame rides low in the view. */ 24: lookDrop = 1.5; 25: /** Scales the chase distance and height. On the catapult a heavy's camera pulls in to the 26: * striker's distance, so it stays near the tube mouth instead of deep in the hangar. */ 27: reach = 1; 28: /** 0 centred behind the frame (on the catapult), 1 fully over the shoulder. Eases toward `shoulderWanted`. */ 29: private shoulderBlend = 0; 30: shoulderWanted = 0; 31: private smoothed = new THREE.Quaternion(); 32: private shake = 0; 33: private time = 0; 34: 35: constructor(fov = 68) { 36: this.camera = new THREE.PerspectiveCamera(fov, 1, 0.5, 60000); 37: } 38: 39: toggle() { 40: this.mode = this.mode === 'cockpit' ? 'chase' : 'cockpit'; 41: } 42: 43: /** Jolt the view (catapult, hits). Decays on its own. */ 44: kick(amount: number) { 45: this.shake = Math.max(this.shake, amount); 46: } 47: 48: update(mech: { pos: THREE.Vector3; rot: THREE.Quaternion }, cockpit: THREE.Object3D, dt: number, snap = false) { 49: this.time += dt; 50: const cam = this.camera; 51: if (snap) this.smoothed.copy(mech.rot); 52: else this.smoothed.slerp(mech.rot, 1 - Math.exp(-10 * dt)); 53: this.shoulderBlend = snap ? this.shoulderWanted : this.shoulderBlend + (this.shoulderWanted - this.shoulderBlend) * (1 - Math.exp(-1.8 * dt)); 54: this.chaseOffset.x = this.shoulder * THREE.MathUtils.smoothstep(this.shoulderBlend, 0, 1); 55: if (this.mode === 'cockpit') { 56: cockpit.getWorldPosition(cam.position); 57: cam.quaternion.copy(mech.rot).multiply(FLIP); 58: } else { 59: const q = this.smoothed; 60: const o = this.chaseOffset, r = this.reach; 61: cam.position.set(o.x, o.y * r, o.z * r).applyQuaternion(q).add(mech.pos); 62: // look straight ahead from the shoulder, parallel to the frame's nose 63: _p.set(o.x, (o.y - this.lookDrop) * r, 400).applyQuaternion(q).add(mech.pos); 64: _up.set(0, 1, 0).applyQuaternion(q); 65: _look.lookAt(cam.position, _p, _up); 66: cam.quaternion.setFromRotationMatrix(_look); 67: } 68: this.applyShake(dt); 69: } 70: 71: /** 72: * The wreck seen from outside: a slow orbit round the drifting frame that pulls back as it goes, 73: * starting from the chase spot behind the heading it had when it was hit. `t` is seconds since 74: * the wreck and `size` the frame's scale, so the shot is a pure function of time. 75: */ 76: wreck(target: THREE.Vector3, heading: THREE.Quaternion, t: number, size: number, dt: number) { 77: this.time += dt; 78: const cam = this.camera; 79: const ease = 1 - Math.exp(-t * 0.8); 80: const dist = (32 + 95 * ease) * size; 81: const yaw = 0.35 * t + 0.25 * ease; 82: const rise = 0.18 + 0.32 * ease; 83: _p.set(Math.sin(yaw) * Math.cos(rise), Math.sin(rise), -Math.cos(yaw) * Math.cos(rise)).multiplyScalar(dist); 84: cam.position.copy(_p.applyQuaternion(heading)).add(target); 85: _up.set(0, 1, 0).applyQuaternion(heading); 86: _look.lookAt(cam.position, target, _up); 87: cam.quaternion.setFromRotationMatrix(_look); 88: this.smoothed.copy(heading); 89: this.applyShake(dt); 90: } 91: 92: private applyShake(dt: number) { 93: const cam = this.camera; 94: if (this.shake > 0.001) { 95: const s = this.shake; 96: cam.position.x += (Math.sin(this.time * 71) + Math.sin(this.time * 113)) * 0.05 * s; 97: cam.position.y += (Math.sin(this.time * 89) + Math.sin(this.time * 131)) * 0.05 * s; 98: cam.rotateZ(Math.sin(this.time * 47) * 0.004 * s); 99: this.shake *= Math.exp(-4 * dt); 100: } 101: } 102: }read_file{"EndLine":120,"Path":"~/work/sortie/tools/clip.mjs","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/tools/clip.mjs", "StartLine": 1 }result, 69 lines
Showing lines 1-68 of 68 1: // A review clip of one model: chase camera, orbit, turntable, range of motion, next to a pilot. 2: // node tools/clip.mjs <model> [--quick] [--shots chase,turn] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--out file.mp4] 3: // --quick is for the loop: chase and turntable only, 12 fps, 640x360. 4: // Starts its own dev server on a free port and always stops it. Frames are rendered one at a time, so 5: // the clip is smooth however slow the machine (src/view/clip.ts). Writes the mp4 and, because a reader 6: // that can't watch video still has to judge it, a contact sheet of frames beside it. Headless only. 7: import { spawn, spawnSync } from 'node:child_process'; 8: import { mkdirSync } from 'node:fs'; 9: import { dirname, resolve } from 'node:path'; 10: import { chromium } from 'playwright'; 11: import { createServer } from 'vite'; 12: 13: const args = process.argv.slice(2); 14: const flag = (name, fallback) => { 15: const i = args.indexOf(`--${name}`); 16: return i >= 0 ? args[i + 1] : fallback; 17: }; 18: const name = args[0]; 19: if (!name || name.startsWith('--')) { 20: console.error('usage: node tools/clip.mjs <model> [--quick] [--shots chase,orbit,turn,bend,scale] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--out file.mp4]'); 21: process.exit(2); 22: } 23: const quick = args.includes('--quick'); 24: const [w, h] = flag('size', quick ? '640x360' : '854x480').split('x').map(Number); 25: const fps = Number(flag('fps', quick ? 12 : 24)); 26: const out = resolve(flag('out', `review/out/one-mech/clips/${name}.mp4`)); 27: const params = new URLSearchParams({ view: 'clip', model: name, w, h, fps, palette: flag('palette', 'merc') }); 28: for (const k of ['shots', 'look']) if (flag(k)) params.set(k, flag(k)); 29: if (quick && !flag('shots')) params.set('shots', 'chase,turn'); 30: mkdirSync(dirname(out), { recursive: true }); 31: 32: const started = Date.now(); 33: const server = await createServer({ server: { host: '127.0.0.1', port: 5230, strictPort: false }, logLevel: 'error' }); 34: await server.listen(); 35: const browser = await chromium.launch({ args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'] }); 36: let failed = false; 37: try { 38: const page = await browser.newPage({ viewport: { width: w, height: h } }); 39: page.setDefaultTimeout(300000); 40: page.on('pageerror', (e) => { failed = true; console.error('[pageerror]', e.message); }); 41: page.on('console', (m) => { if (m.type() === 'error') console.error('[console]', m.text().slice(0, 300)); }); 42: await page.goto(`${server.resolvedUrls.local[0]}?${params}`); 43: await page.waitForFunction(() => window.__ready === true); 44: const frames = await page.evaluate(() => window.__clip.frames); 45: const loaded = Date.now(); 46: const ffmpeg = spawn('ffmpeg', ['-loglevel', 'error', '-y', '-f', 'image2pipe', '-c:v', 'mjpeg', '-framerate', String(fps), '-i', '-', 47: '-c:v', 'libx264', '-crf', '20', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', out], { stdio: ['pipe', 'inherit', 'inherit'] }); 48: const ended = new Promise((ok) => ffmpeg.on('close', ok)); 49: for (let i = 0; i < frames; i++) { 50: const url = await page.evaluate((n) => window.__clip.render(n), i); 51: const jpeg = Buffer.from(url.slice(url.indexOf(',') + 1), 'base64'); 52: if (!ffmpeg.stdin.write(jpeg)) await new Promise((ok) => ffmpeg.stdin.once('drain', ok)); 53: } 54: ffmpeg.stdin.end(); 55: const code = await ended; 56: if (code !== 0) throw new Error(`ffmpeg exited ${code}`); 57: const every = Math.max(1, Math.floor(frames / 12)); 58: const sheet = out.replace(/\.mp4$/, '.sheet.jpg'); 59: spawnSync('ffmpeg', ['-loglevel', 'error', '-y', '-i', out, '-vf', `select=not(mod(n\\,${every})),scale=480:-1,tile=4x3`, '-frames:v', '1', '-q:v', '4', sheet], { stdio: 'inherit' }); 60: const secs = (Date.now() - started) / 1000; 61: console.log(`clip: ${out}`); 62: console.log(`clip: ${sheet}`); 63: console.log(`clip: ${frames} frames, ${(frames / fps).toFixed(1)} s of video, ${secs.toFixed(0)} s to make (${((Date.now() - loaded) / frames).toFixed(0)} ms a frame)`); 64: } finally { 65: await browser.close(); 66: await server.close(); 67: } 68: process.exit(failed ? 1 : 0);