A 3D model pipeline, pushed by GPT-6-Astra
agent (cont.)
+0:51exec_commandrg --files ~/.local/share/lowmarch/trials | rg '(camera.json|\.glb.json|index.html)$' | head -60 && cat tools/mobs.py | head -140 && sed -n '1,180p' tools/poses.py && sed -n '1,100p' tools/cage.py (+1 more)
command
rg --files ~/.local/share/lowmarch/trials | rg '(camera.json|\.glb.json|index.html)$' | head -60 && cat tools/mobs.py | head -140 && sed -n '1,180p' tools/poses.py && sed -n '1,100p' tools/cage.py rg -n 'function |PAINT_|sheet|renderPaint|render.*paint|loadChar|const renderer|const scene|async |camera.json' review/vroid-02/index.html | tail -120 && sed -n '1,180p' review/frame/index.html
result, 8 lines
Script completed Wall time 0.1 seconds Output: Warning: truncated output (original token count: 10804) Total output lines: 2 {"chunk_id":"361e03","wall_time_seconds":0.000005871,"exit_code":0,"original_token_count":6238,"output":"~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_youth.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_heroic.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_strong.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_old.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/camera.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_average.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_old.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_heavy.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/plains.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_heavy.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_average.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_lean.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_m_strong.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_slender.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/arm_f_sexy.glb.json\n~/.local/share/lowmarch/trials/face-shading-2026-10-30/armsite_before_v13/index.html\n~/.local/share/lowmarch/trials/hair-research-2026-10-31/index.html\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_youth.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_heroic.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_strong.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_old.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/camera.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_average.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_old.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_heavy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_f_slender.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_m_average.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/plains.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_f_strong.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_m_old.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/camera.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_m_heroic.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/smug/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_f_sexy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/angry/arm_m_youth.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/exb/surprised/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14b/shootsite/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_heavy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_average.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_lean.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_m_strong.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_slender.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/arm_f_sexy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14/site/index.html\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_youth.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_heroic.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_f_strong.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_old.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/camera.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_average.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_f_old.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/arm_m_heavy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/final14/site/plains.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14b/site/arm_f_heavy.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14b/site/arm_m_brute.glb.json\n~/.local/share/lowmarch/trials/combined-2026-10-31/all14b/site/arm_f_average.glb.json\n\"\"\"Common enemy units: one costume per class, built from gear.py on any base body. Generic but detailed:\nlayered padding, mail and plate, riveted straps, an army colour on the cloth and shields (portrait\nguide, lesson 15). Pair each with a build and a face from gear.BUILDS / gear.FACES in the cast.\n\"\"\"\nimport numpy as np\n\nimport outfit as O\nimport gear as G\nfrom fitting import Surface, merge_surfaces\nfrom vrm import bone_weight\n\n\ndef _base(fit, shirt=\"padding\", legs=\"cloth\", boots=\"boot\", gloves=\"glove\", knee=None, shirt_subdiv=0, boot_top=None):\n \"\"\"Under layers every class shares: a shirt with sleeves to the wrist, trousers, boots to below\n the knee (or to boot_top: above the knee, they take the thigh too), gloves. Returns the pieces and\n the shirt (what coats are fitted over).\"\"\"\n B = fit.bone\n nk, hips = B[\"J_Bip_C_Neck\"], B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1] if knee is None else knee\n\n def cuff(side):\n a, h = B[f\"J_Bip_{side}_LowerArm\"], B[f\"J_Bip_{side}_Hand\"]\n n = (h - a) / np.linalg.norm(h - a)\n return n, n @ (h - n * 0.02)\n torso = (\"Spine\", \"Chest\", \"UpperChest\", \"Bust\", \"Shoulder\", \"UpperArm\", \"LowerArm\", \"Neck\", \"Hips\")\n # the neckline: a straight hem, lower at the throat than at the back of the neck (a level cut of\n # whole triangles left a saw-tooth edge, and a big trapezius showed above it)\n nh = np.array([0.0, 1.0, -0.3]) / np.linalg.norm([0.0, 1.0, -0.3])\n neckline = (nh, float(nh @ (nk + np.array([0.0, 0.012, 0.0]))))\n s = O.wrap(fit, \"shirt\", shirt, torso, offset=0.006, exclude=(\"UpperLeg\",), y_min=hips[1] - 0.04,\n y_max=nk[1] + 0.05, cut=neckline, hems=[cuff(\"L\"), cuff(\"R\"), neckline], subdiv=shirt_subdiv)\n t = O.wrap(fit, \"trousers\", legs, (\"Hips\", \"UpperLeg\", \"LowerLeg\"), offset=0.007, y_max=hips[1] + 0.02, subdiv=1)\n top = knee - 0.07 if boot_top is None else boot_top\n b = O.wrap(fit, \"boots\", boots, (\"LowerLeg\", \"Foot\", \"ToeBase\") + ((\"UpperLeg\",) if top > knee else ()), offset=0.015,\n y_max=top, subdiv=1, hems=[((0, 1, 0), top - 0.005)])\n g = O.wrap(fit, \"gloves\", gloves, (\"Hand\", \"Thumb\", \"Index\", \"Middle\", \"Ring\", \"Little\"), offset=0.003, min_w=0.3, smooth=4)\n out = [p for p in (s, t, b, g) if p is not None]\n for p, grp in zip(out, (\"doublet\", \"trousers\", \"boots\", \"gloves\")):\n p[\"group\"] = grp\n return out, s, t, b\n\n\ndef underwear(fit, band=False):\n \"\"\"Plain shorts (and a chest band with band=True) for inspecting bare bodies (the armory page, built\n in the T-pose): hips to mid-thigh, close to the skin.\"\"\"\n B = fit.bone\n hips, knee = B[\"J_Bip_C_Hips\"][1], B[\"J_Bip_L_LowerLeg\"][1]\n lo, hi = (hips + knee) / 2 + 0.03, hips + 0.07\n # all the skin between the hems but the arms' (they hang there in the fitting pose): taking only skin\n # weighted to the hips, legs and spine left holes where MakeHuman weights it to the chest or elsewhere\n out = [O.wrap(fit, \"shorts\", \"cloth\", (\"J_\",), offset=0.004, y_min=lo - 0.04, y_max=hi + 0.04, subdiv=1,\n exclude=(\"Shoulder\", \"Arm\", \"Hand\", \"Thumb\", \"Index\", \"Middle\", \"Ring\", \"Little\"),\n hems=[((0, 1, 0), hi - 0.005), ((0, -1, 0), -(lo + 0.005))], refloor=True, clamp=True)]\n if band:\n ch, uc = B[\"J_Bip_C_Chest\"][1], B[\"J_Bip_C_UpperChest\"][1]\n blo, bhi = ch - 0.01, uc + 0.06\n # like the shorts: triangles past the hems taken and clamped onto them (dropping them notched the\n # top edge into steps on broad backs), every bone but the arms'\n out.append(O.wrap(fit, \"band\", \"cloth\", (\"J_\",), offset=0.004, y_min=blo - 0.03, y_max=bhi + 0.03, subdiv=1,\n exclude=(\"Shoulder\", \"Arm\", \"Hand\", \"Thumb\", \"Index\", \"Middle\", \"Ring\", \"Little\"),\n hems=[((0, 1, 0), bhi - 0.005), ((0, -1, 0), -(blo + 0.005))], refloor=True, clamp=True))\n out = [p for p in out if p is not None]\n for p in out:\n p[\"group\"] = \"underwear\"\n fit.keep_skin = (\"J_\",) # bare everywhere else: keep all the skin (VRoid 2 weights some to J_Sec_ bones)\n # but not the skin well inside the shorts: on fitted bodies (tools/fit.py) it came through the waistband.\n # Never the arms', which hang beside the hips in the fitting pose\n arms = (\"Shoulder\", \"Arm\", \"Hand\", \"Thumb\", \"Index\", \"Middle\", \"Ring\", \"Little\")\n fit.drop_skin = lambda p: ((p[\"pos\"][:, 1] > lo + 0.015) & (p[\"pos\"][:, 1] < hi - 0.015)\n & (bone_weight(p, arms) < 0.05))\n return out\n\n\ndef underwear_f(fit):\n return underwear(fit, band=True)\n\n\ndef _under(shirt):\n return Surface(*O.without(shirt, (\"Shoulder\", \"UpperArm\", \"LowerArm\", \"Hand\")))\n\n\ndef _surf(pcs, *names, prefix=False):\n sel = [p for p in pcs if (p[\"material\"].startswith(tuple(\"OUTFIT_\" + n for n in names)) if prefix\n else p[\"material\"] in tuple(\"OUTFIT_\" + n for n in names))]\n return merge_surfaces(*[(p[\"pos\"], p[\"tri\"]) for p in sel])\n\n\ndef soldier(fit, legs=\"breeches\"):\n \"\"\"Halberd infantry, after the study's Soldier: a kettle hat, a doublet in the army colour with\n full sleeves bagging into gauntlets that reach almost to the elbow, a short breastplate with a\n plackart (full width to the armpits), a fauld of round scales to mid-thigh, a belt, a halberd\n held in both hands (the cast's polearm stance, tools/clips.py). No puff or band on the upper arm:\n the study's soldiers have neither, and on a real arm a puff read as a bicep.\n legs: \"breeches\" (baggy, bagging over calf boots: the study's men) or \"tights\" (with boots to\n above the knee: the study's women).\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n gauntlet = 0.70 # of the forearm, from the wrist\n y_hem = hips[1] - 0.20 # the fauld's\n boot_top = knee + 0.08 if legs == \"tights\" else knee - 0.07\n out, shirt, trousers, boots = _base(fit, shirt=\"signature\", legs=\"cloth\", boots=\"boot\", shirt_subdiv=1,\n boot_top=boot_top)\n G.loose_sleeves(fit, shirt, cuff=gauntlet)\n if legs == \"breeches\":\n G.breeches(fit, trousers, boots, y_hem, boot_top - 0.005)\n else:\n G.flare_boots(fit, boots, boot_top - 0.005, ease=0.008)\n under = _under(shirt)\n out += G.breastplate(fit, under, arm=64.0)\n plate = _surf(out, \"breastplate\", prefix=True)\n # the guard's wide stance: the fauld follows the thighs closely and clears the seat\n out += G.scale_skirt(fit, under, hips[1] + 0.06, y_hem, role=\"mail\", share=0.15,\n clear=Surface(trousers[\"pos\"], trousers[\"tri\"]))\n G.slim_under(fit, trousers, y_hem) # and what it hides can't come through it\n belt, front = O.belt(fit, \"belt\", \"leather\", plate, hips[1] + 0.05, height=0.034, offset=0.004)\n out.append(belt)\n cuffs = G.cuffs(fit, length=gauntlet, flare=0.034)\n G.tuck_sleeves(fit, shirt, cuffs)\n out += cuffs\n out += G.coif(fit, role=\"padding\")\n out += G.helmet(fit, \"kettle\")\n out += G.halberd(fit, grip=0.50) # the rear hand near the butt, as the study holds it\n return out\n\n\ndef soldier_f(fit):\n \"\"\"The soldier as the study draws its women: tights and boots to above the knee.\"\"\"\n return soldier(fit, legs=\"tights\")\n\n\ndef fighter(fit):\n \"\"\"Sword and round shield, after the study's Fighter: a kettle hat worn low, a quilted gambeson with\n full sleeves, a breastplate, lamed spaulders, a knife-pleated skirt in the army colour, greaves, a\n wooden round shield, an arming sword.\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n out, shirt, trousers, boots = _base(fit, shirt=\"padding\", legs=\"cloth\", boots=\"boot\")\n under = _under(shirt)\n\"\"\"Poses for VRoid skeletons: bone name -> 3x3 rotation applied in the bone's own (rest) frame.\n\nRest pose is a T-pose with identity bone rotations, so local axes start aligned with the model:\nx = character's left is -x, y up, the character faces -z. For the RIGHT arm the bones run along\n+x and the palm faces -y; for the LEFT arm along -x.\n\"\"\"\nimport math\n\nimport numpy as np\n\n\ndef rot(axis, deg):\n a = math.radians(deg)\n c, s = math.cos(a), math.sin(a)\n x, y, z = np.asarray(axis, float) / np.linalg.norm(axis)\n return np.array([[c + x * x * (1 - c), x * y * (1 - c) - z * s, x * z * (1 - c) + y * s],\n [y * x * (1 - c) + z * s, c + y * y * (1 - c), y * z * (1 - c) - x * s],\n [z * x * (1 - c) - y * s, z * y * (1 - c) + x * s, c + z * z * (1 - c)]])\n\n\ndef as4(r):\n r = np.asarray(r, float)\n if r.shape == (4, 4):\n return r\n m = np.eye(4)\n m[:3, :3] = r\n return m\n\n\ndef move(dx=0.0, dy=0.0, dz=0.0, r=None):\n \"\"\"A 4x4 adjustment: translate (in the bone's parent frame units, metres) and optionally rotate.\"\"\"\n m = as4(np.eye(3) if r is None else r)\n m[:3, 3] = (dx, dy, dz)\n return m\n\n\ndef merge(*poses):\n out = {}\n for p in poses:\n for k, r in p.items():\n out[k] = as4(out[k]) @ as4(r) if k in out else r\n return out\n\n\ndef fist(side, curl=(70, 85, 55), thumb=35):\n \"\"\"Curl the fingers of one hand toward the palm (a grip).\"\"\"\n sz = -1 if side == \"R\" else 1 # rotation about local z that bends toward -y\n out = {}\n for f in (\"Index\", \"Middle\", \"Ring\", \"Little\"):\n for i, a in enumerate(curl, 1):\n out[f\"J_Bip_{side}_{f}{i}\"] = rot((0, 0, 1), sz * a)\n out[f\"J_Bip_{side}_Thumb2\"] = rot((0, 1, 0), (1 if side == \"R\" else -1) * thumb)\n out[f\"J_Bip_{side}_Thumb3\"] = rot((0, 0, 1), sz * 30)\n return out\n\n\n# Bust: arms down from the T-pose, shoulders relaxed.\nBUST = {\"J_Bip_L_UpperArm\": rot((0, 0, 1), 72), \"J_Bip_R_UpperArm\": rot((0, 0, 1), -72),\n \"J_Bip_L_Shoulder\": rot((0, 0, 1), 6), \"J_Bip_R_Shoulder\": rot((0, 0, 1), -6)}\n\n# Battle idle: sword in the right hand held forward, left arm loose, feet apart.\nBATTLE_IDLE = merge(BUST, {\n \"J_Bip_R_UpperArm\": rot((0, 1, 0), 18), # swing the right arm a little forward\n \"J_Bip_R_LowerArm\": rot((0, 1, 0), 55), # bend the elbow, forearm forward\n \"J_Bip_R_Hand\": rot((1, 0, 0), -20), # tip the blade up a little\n \"J_Bip_L_LowerArm\": rot((0, 1, 0), -20),\n \"J_Bip_L_UpperLeg\": rot((0, 0, 1), -5) @ rot((1, 0, 0), 8),\n \"J_Bip_R_UpperLeg\": rot((0, 0, 1), 5) @ rot((1, 0, 0), -10),\n \"J_Bip_R_LowerLeg\": rot((1, 0, 0), 12),\n}, fist(\"R\"), fist(\"L\", curl=(25, 35, 20), thumb=10))\n\n\n# ---- battle clips: (time in seconds, pose) keyframes ------------------------------------------------------------\n# Signs (VRoid rest frame): the character faces -z. For the right arm, rot_z(+) raises it,\n# rot_y(+) swings it forward. For legs, rot_x(+) swings the leg forward, rot_x(-) on a lower leg\n# bends the knee. For the spine, rot_y(+) turns the shoulders toward the left (the attack side),\n# rot_x(-) leans forward.\nWIND_UP = merge(BATTLE_IDLE, {\n \"J_Bip_C_Hips\": move(0, -0.02, 0.05),\n \"J_Bip_C_Spine\": rot((0, 1, 0), -22),\n \"J_Bip_C_Chest\": rot((1, 0, 0), 4),\n \"J_Bip_R_UpperArm\": rot((0, 0, 1), 95) @ rot((0, 1, 0), -40),\n \"J_Bip_R_LowerArm\": rot((0, 1, 0), 45),\n \"J_Bip_R_Hand\": rot((1, 0, 0), 25),\n \"J_Bip_L_UpperArm\": rot((0, 1, 0), -25),\n \"J_Bip_L_UpperLeg\": rot((1, 0, 0), 12),\n \"J_Bip_R_LowerLeg\": rot((1, 0, 0), -14),\n})\nSLASH = merge(BATTLE_IDLE, {\n \"J_Bip_C_Hips\": move(0, -0.07, -0.30),\n \"J_Bip_C_Spine\": rot((0, 1, 0), 26),\n \"J_Bip_C_Chest\": rot((1, 0, 0), -12),\n \"J_Bip_R_UpperArm\": rot((0, 0, 1), 30) @ rot((0, 1, 0), 70),\n \"J_Bip_R_LowerArm\": rot((0, 1, 0), -50),\n \"J_Bip_R_Hand\": rot((1, 0, 0), 15),\n \"J_Bip_L_UpperArm\": rot((0, 1, 0), -35) @ rot((0, 0, 1), -10),\n \"J_Bip_L_UpperLeg\": rot((1, 0, 0), 38),\n \"J_Bip_L_LowerLeg\": rot((1, 0, 0), -40),\n \"J_Bip_R_UpperLeg\": rot((1, 0, 0), -30),\n \"J_Bip_R_LowerLeg\": rot((1, 0, 0), -12),\n})\nFOLLOW = merge(SLASH, {\n \"J_Bip_C_Spine\": rot((0, 1, 0), 14),\n \"J_Bip_R_UpperArm\": rot((0, 0, 1), -40) @ rot((0, 1, 0), 15),\n \"J_Bip_R_LowerArm\": rot((0, 1, 0), -10),\n \"J_Bip_R_Hand\": rot((1, 0, 0), 25),\n})\nIDLE_BREATH = merge(BATTLE_IDLE, {\"J_Bip_C_Chest\": rot((1, 0, 0), -2.5), \"J_Bip_R_UpperArm\": rot((0, 0, 1), 3),\n \"J_Bip_C_Hips\": move(0, -0.008, 0)})\n\nCLIPS = {\n \"idle\": [(0.0, BATTLE_IDLE), (0.9, IDLE_BREATH), (1.8, BATTLE_IDLE)],\n \"attack\": [(0.0, BATTLE_IDLE), (0.32, WIND_UP), (0.44, WIND_UP), (0.56, SLASH), (0.68, FOLLOW), (1.05, FOLLOW),\n (1.5, BATTLE_IDLE)],\n}\n\"\"\"VRoid bodies reshaped whole, their own head kept (spike, 2026-10-10).\n\nThe head graft (tools/makehuman.py) joins an anime head to a realistic body, and the mass transfer\n(tools/mass.py) carried MakeHuman's realistic muscle, many small forms, onto VRoid's smooth surface. Here a\nVRoid model keeps its own head and its own mesh. Every change is broad and smooth, and every mesh follows\nthe rig by its skin weights, so the face and the body stay joined wherever they meet.\n\nShaped by a reference body (spec[\"ref\"], the way the armory's cage bodies are made):\n 1. the skeleton goes on…804 tokens truncated…the bump stands where a ray from it along `face` leaves the skin, h high there, with Gaussian\nradii `size`, on skin weighted to the gate bones (\"{s}\" in a bone name makes one per side; a centre form\noff the midline is a mirrored pair); height: metres, crown to sole (default: the base's). With\nspec[\"fit\"] the fitter moves CONTROLS until the archetype's ratios pass.\n\n python3 -I tools/cage.py [NAME ...] build these cast entries (default: every cage entry)\n\"\"\"\nimport site\nimport sys\n\nsys.path.append(site.getusersitepackages()) # run with -I (it reads downloaded data): numpy is in the user site\nimport copy # noqa: E402\nimport hashlib # noqa: E402\nimport json # noqa: E402\nimport os # noqa: E402\nimport struct # noqa: E402\n\nimport numpy as np # noqa: E402\nimport scipy.sparse as sp # noqa: E402\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nsys.path[:0] = [HERE]\nfrom vrm import VRM # noqa: E402\nimport collide # noqa: E402\n\nVROID = os.environ.get(\"LOWMARCH_VROID\", os.path.expanduser(\"~/.local/share/lowmarch/vroid\"))\nOUT = os.path.join(VROID, \"lowmarch_bodies\", \"cage\")\nCACHE = os.path.join(OUT, \"fits.json\")\nFWD = np.array([0.0, 0.0, -1.0]) # VRoid models face -z, y up; the left side is -x\n# each scaled bone and the joint its length runs to\nNEXT = {\"Hips\": \"Spine\", \"Spine\": \"Chest\", \"Chest\": \"UpperChest\", \"UpperChest\": \"Neck\", \"Neck\": \"Head\",\n \"Shoulder\": \"UpperArm\", \"UpperArm\": \"LowerArm\", \"LowerArm\": \"Hand\", \"UpperLeg\": \"LowerLeg\", \"LowerLeg\": \"Foot\"}\nWHOLE = {\"Head\": \"head\", \"Hand\": \"hand\", \"Foot\": \"foot\"} # scaled whole, with everything under them\nTORSO_CHAIN = (\"Hips\", \"Spine\", \"Chest\", \"UpperChest\")\n# the rings' stations: u runs joint to joint along a limb (arm: upper-arm joint 0, elbow 1, wrist 2; leg: hip\n# joint 0, knee 1, ankle 2) and up the torso from the hips' joint (0) to the neck's (1); the head's joint\n# is always unchanged\nSTATIONS = {\"torso\": {\"crotch\": -0.25, \"hips\": -0.05, \"waist\": 0.3, \"chest\": 0.6, \"shoulders\": 0.82, \"neck_base\": 1.0,\n \"neck\": 1.1},\n \"arm\": {\"shoulder\": 0.0, \"biceps\": 0.45, \"elbow\": 1.0, \"forearm\": 1.3, \"wrist\": 2.0},\n \"leg\": {\"top\": 0.0, \"thigh\": 0.4, \"knee\": 1.0, \"calf\": 1.3, \"ankle\": 2.0}}\n\n\ndef _bone(name):\n \"\"\"'J_Bip_L_UpperArm' -> 'UpperArm' (sides share a control), anything else -> None.\"\"\"\n if not name.startswith(\"J_Bip_\"):\n return None\n return name.split(\"_\", 3)[3]\n\n\ndef _frame(a):\n a = a / np.linalg.norm(a)\n e1 = FWD - (FWD @ a) * a\n e1 /= np.linalg.norm(e1)\n return a, e1, np.cross(a, e1)\n\n\ndef _turn(a, b):\n"} {"chunk_id":"366737","wall_time_seconds":0.000004711,"exit_code":0,"original_token_count":4154,"output":"6:<link href=\"https://fonts.googleapis.com/css2?family=Alegreya+Sans:ital,wght@0,400;0,500;0,700;1,400&family=Pixelify+Sans:wght@500;700&family=Silkscreen&display=swap\" rel=\"stylesheet\">\n95:.sheets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }\n96:.sheets a { display: grid; gap: 4px; color: var(--accent); font-size: 14px; text-decoration: none; }\n97:.sheets img { width: 100%; height: 120px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 3px; background: var(--screen); }\n117:body.sheet .hud, body.sheet .panel, body.sheet .tags { display: none; }\n118:#sheetOut { display: none; }\n183: <li><b>Builds and faces vary.</b> The soldier's kit is also worn by a stocky grey veteran and a slim woman. Builds run from petite (the thief, 1.4 m) to huge (the berserker), with a new overall height control and oversized hands, as the study's units have. Faces differ in shape (jaw, chin, brow, nose, cheeks), expression, hair and eye colour, skin tone, and beards and moustaches. The lineup's check sheet has rows of faces with helmets off and on.</li>\n193: <h3>Check sheets</h3>\n195: <div class=\"sheets\" id=\"sheets\"></div>\n216:<textarea id=\"sheetOut\" aria-hidden=\"true\"></textarea>\n230:const SHEET = params.get(\"sheet\"); // a character's name, or \"duel\": render a check sheet\n232:try { CAM = await (await fetch(\"camera.json\")).json(); }\n233:catch (e) { statusEl.textContent = \"Couldn't load camera.json. Open this page from its published link.\"; throw e; }\n251:// a workshop page (camera.json \"page\"): its own title and notes, and no duel\n302:const scene = new THREE.Scene();\n316:const PAINT_VS = `${SKIN_HEAD}\n342:const PAINT_FS = `\n517:const PAINT_COMP = `\n609:function compPass(fs, uniforms) {\n622:const paint = compPass(PAINT_COMP, { tColor: { value: null }, tInfo: { value: null }, tDepth: { value: null }, uRes: { value: new THREE.Vector2() },\n631:function targetsFor(w, h) {\n859:function paintMaterial(V, role, map, index, infoRole = role, decal = false) {\n891: const m = new THREE.ShaderMaterial({ uniforms: u, vertexShader: PAINT_VS, fragmentShader: PAINT_FS, side: THREE.DoubleSide,\n904:// the lineup: every enemy model standing in a row (camera.json's lineup), each turning in place\n912:async function parseGlb(file) {\n918:function prepMesh(o, V, opts = {}) {\n946:async function loadCharacter(name) {\n983:async function loadGround() {\n994:function applyMaterials() {\n1011:function setClip(name, blendFrom = null) {\n1024:function animate(dt) {\n1051:function armSide(c, side) { // +1 when the arm points along the model's +x\n1060:function turnBone(c, name, deg) { // about the model's front axis, at the bone's own joint\n1068:function applyPose(c) {\n1081:function applyMotion(c, dt) {\n1099:function makeSprings(c, groups) {\n1123:function stepSprings(c, dt) {\n1156:function layoutCompare() {\n1179:function placeTags() { // the names under the feet\n1193:function compareChanged() { // the comparison is in the link, to share it\n1203:function insets() {\n1209:function fitFrustum() {\n1219:function size() {\n1229:function matchCamera() {\n1245:function focusAt(e) {\n1255:function setYaw(y) {\n1265:function buildParts() {\n1275:function groupedSelect(label, skip, onPick) { // every model in its group, as one dropdown\n1289:function buildWho() {\n1306: if (CAM.characters.some(c => c.group)) { // a long roster in groups (camera.json \"group\"): one dropdown\n1331:async function setView(view, clip) {\n1338: const cs = await Promise.all(activeNames().map(loadCharacter));\n1377:function applySkin(meshes) {\n1388:function render() {\n1425: R.setRenderTarget(null); R.clear(); R.render(paint.scene, compCam);\n1428:// ---- check sheets ----------------------------------------------------------------------------------------------------\n1429:// ?sheet=<name> poses one character through every check view; ?sheet=duel shows the bind. Each tile\n1430:// is posed, its cloth settled at that angle, rendered by the same painted renderer as the page, and\n1431:// drawn into one image, which lands in #sheetOut as a PNG data URL (a headless browser reads it).\n1434: // arms down, as character design sheets are drawn: the row to compare against references\n1487:function holdPose(clip, t) {\n1497:function settleCloth() {\n1503:function frameAt(centre, h, tw, th, pitch) {\n1510:async function runSheet(kind) {\n1511: document.body.classList.add(\"sheet\");\n1595: $(\"sheetOut\").textContent = cv.toDataURL(\"image/png\");\n1596: document.title = \"sheet ready\";\n1599:// ---- panel: checks and sheets ------------------------------------------------------------------------------------------\n1600:async function loadChecks() {\n1633: const sh = await (await fetch(\"sheets.json\")).json();\n1634: const box2 = $(\"sheets\");\n1638: a.querySelector(\"img\").src = s.file; a.querySelector(\"img\").alt = `Check sheet: ${s.label}.`;\n1642: } catch (e) { $(\"sheets\").textContent = \"No sheets in this build.\"; }\n1647:function setPanel(open) {\n1674:document.querySelectorAll(\"[data-clip]\").forEach(b => b.addEventListener(\"click\", async () => {\n1695:function frame(now) {\n1725: runSheet(SHEET).catch(e => { console.error(e); $(\"sheetOut\").textContent = \"error: \" + e; document.title = \"sheet failed\"; });\n<!doctype html>\n<!-- The first-session frame (docs/handbook.md): a plain stand-in figure in the game's camera, with options that change\n in seconds because nothing is rebuilt. Blocks and colours come from a JSON spec, drawn here at load.\n Not the game's look: flat two-tone only. The painted renderer stays review/vroid-02/index.html.\n tools/session/frame.py serves this page and shoots it headless; ?spec=<file.json> names the spec. -->\n<html><head><meta charset=\"utf-8\"><title>frame</title>\n<style>html,body{margin:0;background:#222}canvas{display:block}#out{display:none}</style>\n<script type=\"importmap\">\n{ \"imports\": { \"three\": \"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js\",\n \"three/addons/\": \"https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/\" } }\n</script></head><body>\n<textarea id=\"out\" aria-hidden=\"true\"></textarea>\n<script type=\"module\">\nimport * as THREE from \"three\";\nimport { GLTFLoader } from \"three/addons/loaders/GLTFLoader.js\";\n\nTHREE.ColorManagement.enabled = false; // colours are written as they are (portrait guide, lesson 08)\nconst params = new URLSearchParams(location.search);\nconst SPEC = await (await fetch(params.get(\"spec\") || \"spec.json\")).json();\n// ground_y: where the feet stand, as a share of the frame's height from the bottom; horizon: top of the flat ground band\nconst F = { w: 960, h: 540, background: \"#b9c4cf\", ground: \"#8d9186\", ground_y: 0.16, horizon: 0.3, camera: {}, ...SPEC.frame };\nconst C = { kind: \"ortho\", fov: 30, yaw: 0, pitch: 0, figure_h: 0.5, figure_x: 0.5, ...F.camera };\nconst LOOK = { skin: \"#b8b8bc\", shade: \"#8c8c94\", hair: \"#6d6d76\", hair_shade: \"#55555e\", cloth: \"#a2a2a8\",\n cloth_shade: \"#7c7c86\", ink: \"#2c2438\", outline: 0.004, threshold: 0.15, light: [-0.5, 0.75, 0.6],\n features: false, hide: [], pose: \"down\", ...SPEC.look };\nconst hex = s => new THREE.Color(s);\n\n// ---- two flat tones, split by the light; the mesh's own (baked) normals, skinned; an inverted copy for the outline ----\nconst VS = `#include <common>\n #include <skinning_pars_vertex>\n uniform float uPush; varying vec3 vN; varying vec2 vUv;\n void main() {\n #include <beginnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <begin_vertex>\n #include <skinning_vertex>\n vN = normalize(mat3(modelMatrix) * objectNormal); vUv = uv;\n transformed += normalize(objectNormal) * uPush;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.0);\n }`;\nconst FS = `uniform vec3 uLit, uShade, uL; uniform float uT, uFlat; uniform sampler2D uMask; uniform float uHasMask;\n varying vec3 vN; varying vec2 vUv;\n void main() {\n if (uHasMask > 0.5 && texture2D(uMask, vUv).a < 0.5) discard;\n float d = dot(normalize(vN), uL);\n gl_FragColor = vec4(uFlat > 0.5 || d > uT ? uLit : uShade, 1.0);\n }`;\nfunction toon(lit, shade, look, mask, flat) {\n return new THREE.ShaderMaterial({ vertexShader: VS, fragmentShader: FS, side: THREE.DoubleSide, uniforms: {\n uLit: { value: hex(lit) }, uShade: { value: hex(shade) }, uL: { value: new THREE.Vector3(...look.light).normalize() },\n uT: { value: look.threshold }, uFlat: { value: flat ? 1 : 0 }, uPush: { value: 0 },\n uMask: { value: mask || null }, uHasMask: { value: mask ? 1 : 0 } } });\n}\nconst inkMat = look => new THREE.ShaderMaterial({ vertexShader: VS, side: THREE.BackSide,\n fragmentShader: `uniform vec3 uInk; void main() { gl_FragColor = vec4(uInk, 1.0); }`,\n uniforms: { uPush: { value: look.outline }, uInk: { value: hex(look.ink) } } });\n\n// ---- the figure: role from the material's name (\"body:face\", \"hair:hair\", \"underwear:cloth\") ----\nfunction colours(role, look) {\n if (role === \"hair\") return [look.hair, look.hair_shade];\n if (role === \"body\" || role === \"face\" || role === \"shadow\") return [look.skin, look.shade];\n if (role === \"white\") return [\"#f4f2ee\", \"#f4f2ee\"];\n if ([\"iris\", \"brow\", \"line\", \"mouth\"].includes(role)) return [look.ink, look.ink];\n return [look.cloth, look.cloth_shade];\n}\nconst POSE = { down: 74, out: 0 };\nfunction posed(root, kind) { // from the T-pose: each upper arm turns about the body's front axis\n root.updateMatrixWorld(true);\n const at = n => root.getObjectByName(n).getWorldPosition(new THREE.Vector3());\n for (const s of [\"L\", \"R\"]) {\n const b = root.getObjectByName(`J_Bip_${s}_UpperArm`);\n const side = Math.sign(at(`J_Bip_${s}_Hand`).x - at(`J_Bip_${s}_UpperArm`).x) || 1;\n const axis = new THREE.Vector3(0, 0, 1).applyQuaternion(b.parent.getWorldQuaternion(new THREE.Quaternion()).invert());\n b.quaternion.premultiply(new THREE.Quaternion().setFromAxisAngle(axis, THREE.MathUtils.degToRad(-side * (POSE[kind] || 0))));\n root.updateMatrixWorld(true);\n }\n}\nconst j = await (await fetch(`${SPEC.figure}.glb.json`)).json();\nconst bin = Uint8Array.from(atob(j.glb), c => c.charCodeAt(0));\nconst gltf = await new Promise((ok, bad) => new GLTFLoader().parse(bin.buffer, \"\", ok, bad));\nconst figure = gltf.scene;\nlet skeleton = null;\nfigure.traverse(o => { if (o.isMesh) { o.frustumCulled = false; o.userData.base = o.material; if (o.isSkinnedMesh) skeleton = o.skeleton; } });\n// The skeleton's bind pose holds the arms down while the mesh stays T-posed (lesson 26): turning a bone from bind lowers\n// the mesh's arm, so an arm bone's world position doesn't say where the visible arm is. See meshAt below.\nskeleton.pose();\nposed(figure, LOOK.pose);\nfigure.updateMatrixWorld(true);\nskeleton.update();\nconst box = new THREE.Box3();\nfigure.traverse(o => { if (o.isSkinnedMesh) { const p = o.geometry.attributes.position, v = new THREE.Vector3();\n for (let i = 0; i < p.count; i += 7) { o.getVertexPosition(i, v); box.expandByPoint(v); } } });\nconst H = box.max.y - box.min.y;\nfunction meshAt(name) { // where the visible part is: the mean of the skin that follows this bone\n const k = skeleton.bones.findIndex(b => b.name === name), sum = new THREE.Vector3(), v = new THREE.Vector3();\n let n = 0;\n figure.traverse(o => { if (!o.isSkinnedMesh || !o.geometry.attributes.skinIndex) return;\n const I = o.geometry.attributes.skinIndex, W = o.geometry.attributes.skinWeight;\n for (let i = 0; i < I.count; i++) if (I.getX(i) === k && W.getX(i) > 0.5) { o.getVertexPosition(i, v); sum.add(v); n++; } });\n return n ? sum.divideScalar(n) : null;\n}\nconst LANDMARKS = {};\nfor (const n of [\"J_Bip_C_Head\", \"J_Bip_C_Neck\", \"J_Bip_C_Chest\", \"J_Bip_C_Hips\", \"J_Bip_L_Foot\", \"J_Bip_R_Foot\"]) {\n const b = figure.getObjectByName(n); if (b) LANDMARKS[n] = b.getWorldPosition(new THREE.Vector3()).toArray().map(x => +x.toFixed(3));\n}\nfor (const n of [\"J_Bip_L_UpperArm\", \"J_Bip_R_UpperArm\", \"J_Bip_L_Hand\", \"J_Bip_R_Hand\"]) {\n const p = meshAt(n); if (p) LANDMARKS[n] = p.toArray().map(x => +x.toFixed(3));\n}\n\n// ---- rough blocks, positions in metres from a landmark (+x the model's left, +y up, +z front) ----\n// {\"kind\":\"ball\",\"at\":\"J_Bip_C_Head\",\"c\":[0,0.1,0],\"r\":[0.11,0.1,0.11],\"colour\":\"#333\",\"shade\":\"#222\"}\n// {\"kind\":\"tube\",\"at\":...,\"points\":[[x,y,z],...],\"radii\":[0.03,0.02,0.001],\"flat\":0.4,...}\n// {\"kind\":\"loft\",\"at\":...,\"rings\":[{\"y\":0,\"rx\":0.1,\"rz\":0.08,\"cx\":0,\"cz\":0},...],\"closed\":true,...}\nfunction at(name) { return new THREE.Vector3(...(LANDMARKS[name] || [0, 0, 0])); }\nfunction ringMesh(rings, seg) { // rings: arrays of Vector3, all one length\n const P = [], I = [], n = rings[0].length;\n rings.forEach(r => r.forEach(v => P.push(v.x, v.y, v.z)));\n for (let a = 0; a < rings.length - 1; a++) for (let b = 0; b < n; b++) {\n const c = (b + 1) % n, q = [a * n + b, a * n + c, (a + 1) * n + c, (a + 1) * n + b];\n I.push(q[0], q[1], q[2], q[0], q[2], q[3]);\n }\n for (const [k, w] of [[0, 1], [rings.length - 1, -1]]) { // close both ends with a fan\n const m = new THREE.Vector3(); rings[k].forEach(v => m.add(v)); m.divideScalar(n);\n const i0 = P.length / 3; P.push(m.x, m.y, m.z);\n for (let b = 0; b < n; b++) { const c = (b + 1) % n; w > 0 ? I.push(i0, k * n + c, k * n + b) : I.push(i0, k * n + b, k * n + c); }\n }\n const g = new THREE.BufferGeometry();\n g.setAttribute(\"position\", new THREE.Float32BufferAttribute(P, 3));\n g.setAttribute(\"uv\", new THREE.Float32BufferAttribute(new Array(P.length / 3 * 2).fill(0), 2));\n g.setIndex(I); g.computeVertexNormals();\n return g;\n}\nfunction blockGeometry(b) {\n const o = at(b.at), seg = 24;\n if (b.kind === \"ball\") {\n const g = new THREE.SphereGeometry(1, 24, 16); g.scale(...b.r); g.translate(o.x + b.c[0], o.y + b.c[1], o.z + b.c[2]); return g;\n }\n if (b.kind === \"loft\") {\n const R = b.rings.map(r => Array.from({ length: seg }, (_, i) => { const t = i / seg * 2 * Math.PI;\n return new THREE.Vector3(o.x + (r.cx || 0) + r.rx * Math.sin(t), o.y + r.y, o.z + (r.cz || 0) + r.rz * Math.cos(t)); }));\n return ringMesh(R, seg);\n }\n if (b.kind === \"tube\") { // swept along the points; \"flat\" squashes the section toward the head's centre\n const curve = new THREE.CatmullRomCurve3(b.points.map(p => new THREE.Vector3(...p).add(o)));\n const N = 18, R = [], flat = b.flat ?? 1, c0 = at(b.at);\n for (let i = 0; i <= N; i++) {\n const u = i / N, p = curve.getPoint(u), t = curve.getTangent(u);\n const k = u * (b.radii.length - 1), a = Math.min(Math.floor(k), b.radii.length - 2), r = b.radii[a] + (b.radii[a + 1] - b.radii[a]) * (k - a);\n const out = p.clone().sub(c0).setY(0); if (out.lengthSq() < 1e-6) out.set(0, 0, 1); out.normalize();\n const side = new THREE.Vector3().crossVectors(t, out).normalize(), up = new THREE.Vector3().crossVectors(side, t).normalize();\n R.push(Array.from({ length: 12 }, (_, s) => { const q = s / 12 * 2 * Math.PI;\n return p.clone().addScaledVector(side, r * Math.cos(q)).addScaledVector(up, r * flat * Math.sin(q)); }));\n }\n return ringMesh(R, 12);\n }\n throw new Error(\"unknown block kind \" + b.kind);\n}\n\n// ---- the camera: figure_h is the figure's share of the frame's height; ortho or a lens ----\nconst scene = new THREE.Scene();\nconst center = new THREE.Vector3((box.min.x + box.max.x) / 2, (box.min.y + box.max.y) / 2, 0);\nconst span = H / C.figure_h, aspect = F.w / F.h;\nconst ry = THREE.MathUtils.degToRad(C.yaw), rp = THREE.MathUtils.degToRad(C.pitch);\nconst look = new THREE.Vector3(center.x - (C.figure_x - 0.5) * span * aspect * Math.cos(ry),\n box.min.y + span * (0.5 - F.ground_y),\n (C.figure_x - 0.5) * span * aspect * Math.sin(ry));\nlet camera;\nconst dir = new THREE.Vector3(Math.sin(ry) * Math.cos(rp), Math.sin(rp), Math.cos(ry) * Math.cos(rp));\nif (C.kind === \"ortho\") {\n camera = new THREE.OrthographicCamera(-span * aspect / 2, span * aspect / 2, span / 2, -span / 2, 0.1, 60);\n camera.position.copy(look).addScaledVector(dir, 20);\n} else {\n camera = new THREE.PerspectiveCamera(C.fov, aspect, 0.05, 200);\n camera.position.copy(look).addScaledVector(dir, span / 2 / Math.tan(THREE.MathUtils.degToRad(C.fov) / 2));\n}\ncamera.lookAt(look);\nscene.add(figure);\n\nconst renderer = new THREE.WebGLRenderer({ antialias: true, preserveDrawingBuffer: true });\n"}