A 3D model pipeline, pushed by GPT-6.2-Astra
agent (cont.)
+1:29exec_commandsed -n '855,907p' tools/cage.py && sed -n '173,210p' tools/vroid_portrait.py && sed -n '305,323p' tools/mobs.py && sed -n '312,324p;367,382p;421,483p' tools/gear.py (+2 more)
command
sed -n '855,907p' tools/cage.py && sed -n '173,210p' tools/vroid_portrait.py && sed -n '305,323p' tools/mobs.py && sed -n '312,324p;367,382p;421,483p' tools/gear.py sed -n '195,246p;500,651p' review/vroid-02/index.html cat .gitignore && cat ~/context/sortie-node_modules/playwright-core/browsers.json | head -24 && ls -al ~/work/lowmarch/review/out python3 -c 'import scipy; print(scipy.__version__)' ls -l ~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_average* | tail -2 rg -n 'mkdir|makedirs|cache_key|def key|def path_for' tools/{cage,makehuman,heads}.pyresult, 415 lines
Script completed Wall time 0.2 seconds Output: cache = json.load(open(CACHE)) except (OSError, ValueError): cache = {} if k not in cache: s, _ = fit.fit(spec, log, probe=probe, controls=CONTROLS, head_step=False, rescale=False) try: cache = json.load(open(CACHE)) except (OSError, ValueError): cache = {} cache[k] = s os.makedirs(OUT, exist_ok=True) tmp = CACHE + f".{os.getpid()}" json.dump(cache, open(tmp, "w"), indent=1, sort_keys=True) os.replace(tmp, CACHE) return cache[k] def path_for(name, spec): return os.path.join(OUT, f"{name}_{_key(spec)}.vrm") def ensure(name, spec, log=None): p = path_for(name, spec) if not os.path.exists(p): write(p, *build(fitted(copy.deepcopy(spec), log))) return p if __name__ == "__main__": sys.path[:0] = [os.path.join(os.path.dirname(HERE), "art", "cast")] from cast import CAST todo = sys.argv[1:] or [n for n, c in CAST.items() if c.get("cage")] for name in todo: print(name, ensure(name, CAST[name]["cage"], print)) def bone_pose(v, sh, base_pose): """Pose dict (bone -> 3x3) = base rotations combined with proportion scales. Each scaled bone resets its children to scale 1 except the head, whose children (hair bones) grow with it.""" # Body proportions (all 1.0 = VRoid's): shoulders lengthens the clavicles (wider shoulders), arms # and legs thicken the limbs, torso broadens the waist-to-chest, leg_len lengthens thigh and shin # (the hips are lifted to keep the feet on the ground), hands scales the hands. a, lg, t = sh["arms"], sh["legs"], sh["torso"] spec = {"J_Bip_C_Head": ((sh["head"],) * 3, True), "J_Bip_C_Neck": ((sh["neck"], 1.0, sh["neck"]), False), "J_Bip_C_UpperChest": ((sh["chest"], 1.0, 1 + (sh["chest"] - 1) * 0.6), False), "J_Bip_C_Spine": ((1 + (t - 1) * 0.7, 1.0, 1 + (t - 1) * 0.5), False), "J_Bip_C_Chest": ((t, 1.0, 1 + (t - 1) * 0.7), False)} for side in "LR": spec[f"J_Bip_{side}_Shoulder"] = ((sh["shoulders"], 1.0, 1.0), False) for b in ("UpperArm", "LowerArm"): spec[f"J_Bip_{side}_{b}"] = ((1.0, a, a), False) # arm bones run along x for b in ("UpperLeg", "LowerLeg"): spec[f"J_Bip_{side}_{b}"] = ((lg, sh["leg_len"], lg), False) # leg bones run along y spec[f"J_Bip_{side}_Hand"] = ((sh["hands"],) * 3, True) spec = {k: v for k, v in spec.items() if not np.allclose(v[0], 1.0)} nodes = v.j["nodes"] parent = {c: i for i, n in enumerate(nodes) for c in n.get("children", [])} own = {} def own_of(i): if i in own: return own[i] nm = nodes[i].get("name") if nm in spec: own[i] = np.array(spec[nm][0], float) elif i in parent and nodes[parent[i]].get("name") in spec and spec[nodes[parent[i]]["name"]][1]: own[i] = own_of(parent[i]) elif i in parent and (own_of(parent[i]) != 1).any() and nodes[parent[i]].get("name") not in spec: own[i] = own_of(parent[i]) # inherited chain (below the head) else: own[i] = np.ones(3) return own[i] out += G.robe(fit, under, role="signature", split=14.0) rob = merge_surfaces(*[(p["pos"], p["tri"]) for p in out if p["material"] == "OUTFIT_robe"]) sash, front = O.belt(fit, "sash", "gold", rob, hips[1] + 0.06, height=0.03, offset=0.006) out.append(sash) out += G.witch_hat(fit) out += G.staff(fit) return out M = fit.world[f"J_Bip_{hand}_Hand"] R, o = M[:3, :3], M[:3, 3] R = R / np.linalg.norm(R, axis=0) sx = 1 if hand == "R" else -1 g = getattr(fit, "grip", None) # the fist's measured hole (rig.grip_points) fist = g[hand]["point"] if g else o + R @ np.array([sx * 0.045, -0.018, 0.0]) fwd = R @ np.array([0, 0, -1.0]) side = R @ np.array([sx * 1.0, 0, 0]) return fist, fwd, side, np.cross(fwd, side), R def spear(fit, length=2.0, grip=0.55, head=0.26, hand="R", shaft_role="wood", name="spear"): """A spear held a little behind its middle: an ash shaft, a leaf blade with a socket, a butt cap.""" def staff(fit, length=1.65, hand="R", wood="wood", head_role="gold", name="staff", grip=0.75): fist, fwd, side, flat, _ = _hand_frame(fit, hand) start = fist - fwd * grip out = [O.tube(f"{name}_shaft", wood, start, fwd, length, 0.014, 0.017)] tip = start + fwd * length out.append(O.ball(f"{name}_orb", head_role, tip + fwd * 0.04, 0.035)) for k in range(3): # a cage of three prongs round the orb ang = 2 * math.pi * k / 3 d = side * math.cos(ang) + flat * math.sin(ang) pts = [tip - fwd * 0.02, tip + d * 0.03 + fwd * 0.02, tip + d * 0.042 + fwd * 0.05, tip + d * 0.02 + fwd * 0.085] out.append(O.pipe(f"{name}_prong{k}", head_role, np.array(pts), r=0.004, seg=6)) _bind(fit, out, f"J_Bip_{hand}_Hand") return _group(out, "weapon") def bow(fit, length=1.25, hand="L", name="bow", wood="wood"): def robe(fit, under, name="robe", role="signature", trim=0.012, y_hem=None, flare=0.16, split=0.0, sleeve_flare=0.07): """A long robe: the body over the shirt, a skirt over a cone to the ankles (split at the front if `split` degrees), bell sleeves widening to the wrist; gold-bordered edges.""" B = fit.bone nk, hips = B["J_Bip_C_Neck"], B["J_Bip_C_Hips"] foot = B["J_Bip_L_Foot"][1] y_hem = foot + 0.04 if y_hem is None else y_hem cz = float(hips[2]) y_waist = hips[1] + 0.06 tc = TorsoChart(under, y_waist - 0.04, nk[1] + 0.02, cz=cz, du=3.0, dv=0.008) out = [] body, _ = outline_plate(name, role, tc, -178, 178, lambda u: y_waist, lambda u: nk[1] - 0.025 - 0.03 * max(0.0, 1 - abs(u) / 60), offset=0.008, thickness=0.004, nu=96, nv=20, roll=0, trim=trim) fit.bind(body, allow=("Spine", "Chest", "UpperChest", "Bust", "Hips", "Neck", "Shoulder"), fallback="J_Bip_C_Chest") out.append(body) r0 = lambda u: float(tc.radius(u, y_waist)) + 0.010 cone = ConeChart(lambda u, v: np.vectorize(r0)(u) + flare * np.clip((y_waist - v) / (y_waist - y_hem), 0, 1.2) ** 1.4, cz=cz) u0, u1 = (split, 360 - split) if split else (-178, 178) skirt, _ = outline_plate(f"{name}_skirt", role, cone, u0, u1, lambda u: y_hem, lambda u: y_waist + 0.012, offset=0.002, thickness=0.004, nu=120, nv=22, roll=0, trim=trim) fit.bind(skirt, allow=("Hips", "UpperLeg"), fallback="J_Bip_C_Hips") stiffen(skirt, fit, share=0.6) out.append(skirt) for side in ("L", "R"): for seg, (a, b, v0, v1, fl) in enumerate(((f"J_Bip_{side}_UpperArm", f"J_Bip_{side}_LowerArm", -0.06, 1.02, 0.0), (f"J_Bip_{side}_LowerArm", f"J_Bip_{side}_Hand", -0.02, 0.86, sleeve_flare))): arm = O.limb_surface(fit, (a.replace("J_Bip_", ""), b.replace("J_Bip_", "")), side) lc = LimbChart(arm, B[a], B[b], front=(0, 0, -1)) sl, _ = outline_plate(f"{name}_sleeve_{side}{seg}", role, lc, -180, 180, lambda u, v1=v1: v1, lambda u, v0=v0: v0, offset=0.010, thickness=0.004, nu=48, nv=12, roll=0, trim=trim if seg else 0.0, flare=(lambda u, v, s, t, fl=fl: fl * (1 - t) ** 1.8) if fl else None) fit.bind(sl, allow=(a.replace("J_Bip_", ""), b.replace("J_Bip_", "")), fallback=a) out.append(sl) return _group(out, "dress") def witch_hat(fit, name="hat", role="signature", band_role="gold", height=0.32, brim=0.12, lift=0.034): """A tall pointed hat: a wide soft brim, a crown narrowing to a tip that bends back, a band.""" ch = head_chart(fit) rim_v = lambda u: float(np.interp(abs(u), [0, 90, 180], [62, 74, 84])) U = np.linspace(-180, 180, 49) base = np.array([ch.point(u, rim_v(u), off=lift) for u in U]) c0 = base.mean(0) rings = [] for k, t in enumerate(np.linspace(0, 1, 16)): axis = c0 + np.array([0, height * t, 0.10 * t ** 2.2]) # the tip leans back rings.append(axis + (base - c0) * (1 - t) ** 1.25 * (1 + 0.15 * math.sin(math.pi * t))) G = np.stack(rings, 1) pos, tri, outer = O.thick_grid(G, 0.004, outward_from=c0 + np.array([0, height * 0.3, 0])) crown = O.piece(name, role, pos, tri) d = base - ch.c d[:, 1] = 0 d /= np.linalg.norm(d, axis=1, keepdims=True) B_ = np.stack([base + d * brim * t - np.array([0, 0.03 * t ** 2, 0]) for t in np.linspace(0, 1, 6)], 1) pos, tri, outer2 = O.thick_grid(B_, 0.004, outward_from=ch.c - np.array([0, 0.4, 0])) brim_pc = O.piece(f"{name}_brim", role, pos, tri) band = O.pipe(f"{name}_band", band_role, base + (base - c0) * 0.03 + np.array([0, 0.012, 0]), r=0.007, seg=6, closed=True) out = [crown, brim_pc, band] _bind(fit, out, "J_Bip_C_Head") return _group(out, "helmet") # ---- the study's detail layer (lesson 15): puffed sleeves, breastplates, scale and pleated skirts ---------- Warning: truncated output (original token count: 3098) Total output lines: 204 <div class="sheets" id="sheets"></div> </section> <section> <h3>Display</h3> <div class="opts"> <button class="btn" type="button" id="cloth" aria-pressed="true">Cloth physics</button> <button class="btn" type="button" id="physics" aria-pressed="true">Spring bones</button> <button class="btn" type="button" id="wind" aria-pressed="false">Wind</button> <button class="btn" type="button" id="resetCloth">Drop cloth</button> <button class="btn" type="button" id="stepped" aria-pressed="false">12 fps</button> <button class="btn" type="button" id="shade" aria-pressed="true">3D: toon</button> <button class="btn" type="button" id="xray" aria-pressed="false">X-ray costume</button> </div> </section> <section> <h3>Pieces</h3> <div class="opts" id="parts" aria-label="Pieces to show"></div> </section> <footer>Lowmarch, 8 October 2026. Base bodies: VRoid's CC0 sample models. Aldric's hair is from a VRoid Hub sample (commercial use and modification allowed). Costumes, swords, terrain, renderer and cloth are ours. Unicorn Overlord is Vanillaware's and Saber is Type-Moon's; we study their look, and no image of either is used here. The Saber study is built from written measurements of her design, to benchmark the armour kit; it is not part of the game.</footer> </aside> </div> <textarea id="sheetOut" aria-hidden="true"></textarea> <script type="importmap"> { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/" } } </script> <script type="module"> import * as THREE from "three"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; const $ = id => document.getElementById(id); const statusEl = $("status"); const params = new URLSearchParams(location.search); const SHEET = params.get("sheet"); // a character's name, or "duel": render a check sheet let CAM; try { CAM = await (await fetch("camera.json")).json(); } catch (e) { statusEl.textContent = "Couldn't load camera.json. Open this page from its published link."; throw e; } const GROUP_LABELS = { body: "Body", hair: "Hair", tunic: "Tunic", tails: "Tails", belt: "Belt", trousers: "Trousers / tights", boots: "Boots", gloves: "Gloves", collar: "Collar", pauldron: "Shoulder plates", cape: "Cape", trim: "Gold trim", doublet: "Doublet", plate: "Plate", tabard: "Tabard", mantle: "Mantle", shield: "Shield", dress: "Dress", sword: "Sword", weapon: "Weapon", helmet: "Helmet", hood: "Hood", padding: "Padded coat", mail: "Mail", terrain: "Ground" }; const COSTUME = new Set(["tunic", "tails", "belt", "trousers", "boots", "gloves", "collar", "pauldron", "cape", "trim", "doublet", "plate", "tabard", "mantle", "shield", "dress", "helmet", "hood", "padding", "mail"]); // role ids for the info pass (features 4-9 get no inner lines; hair 3 and 11 shade the forehead) const ROLE_ID = { face: 1, body: 2, hair: 3, line: 4, iris: 5, white: 6, highlight: 7, brow: 8, mouth: 9, cloth: 10, hair_b: 11 }; let nextRole = 12; const roleId = r => (ROLE_ID[r] ??= nextRole++); const VIEW_YAW = { duel: 0, battle: 60, bust: 30, lineup: 20, compare: 0 }; } if (gm > 0.0) col = mix(col, col * 0.30, gm); } if (vEdge > 0.5) { // the cloth's border band vec3 gd = tone(uBand, 0.20, 0.03, 1.0, 0.72); col = mix(gd, uBand, st(lit, 0.45)); col = mix(col, tone(uBand, 0.16, 0.03, 0.5, 1.45), st(lit, 0.85)); } if (uKind <= 6) { vec3 grade = mix(uAmbient, uKeyCol, st(lit, 0.55)); col *= uKind == 1 && uSkinRamp == 1 ? mix(vec3(1.0), grade, 0.3) : grade; // a designed skin ramp takes less of it float fr = pow(1.0 - max(dot(n, v), 0.0), 4.0); float back = clamp(dot(n, normalize(vec3(0.55, 0.45, -0.35))), 0.0, 1.0); col += uRimCol * fr * smoothstep(0.1, 0.5, back); if (uKind != 1) col *= 1.0 + (g2 - 0.5) * 0.06; } gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0); }`; const PAINT_COMP = ` uniform sampler2D tColor; uniform sampler2D tInfo; uniform sampler2D tDepth; uniform vec2 uRes; uniform float uNear; uniform float uFar; uniform float uGap; uniform float uSil; uniform float uInner; uniform float uPpm; ${HSV} float z(vec2 p) { return uNear + texture2D(tDepth, p).x * (uFar - uNear); } int rid(vec4 i) { return int(i.r * 255.0 + 0.5); } float pid(vec4 i) { return floor(i.g * 255.0 + 0.5) + floor(i.b * 255.0 + 0.5) * 256.0; } vec3 ink(vec3 c) { vec3 h = rgb2hsv(c); return hsv2rgb(vec3(h.x, clamp(h.y, 0.20, 0.45), 0.19)); } // How far (px) the mouth's opening runs from this pixel in direction d (2 px steps, up to 128 px). float mouthRun(vec2 uv, vec2 d) { float n = 0.0; for (int s = 1; s <= 64; s++) { vec4 a = texture2D(tInfo, uv + d * float(2 * s)); if (a.a < 0.5 || rid(a) != 9) break; n += 2.0; } return n; } // Brows drawn over the bangs: where hair lies just above or below the stroke, the brow is seen through the hair, // so it takes some of the hair's colour and doesn't sit on it like a sticker. vec3 browOverHair(vec2 uv, vec2 px, vec3 col) { float d = 3.5 * uSil; vec4 a = texture2D(tInfo, uv + vec2(0.0, d) * px), b = texture2D(tInfo, uv - vec2(0.0, d) * px); bool ha = a.a > 0.5 && (rid(a) == 3 || rid(a) == 11), hb = b.a > 0.5 && (rid(b) == 3 || rid(b) == 11); if (!(ha || hb)) return col; vec3 hc = ha ? texture2D(tColor, uv + vec2(0.0, d) * px).rgb : texture2D(tColor, uv - vec2(0.0, d) * px).rgb; return mix(col, hc * 0.80, ha && hb ? 0.68 : 0.34); } void main() { vec2 uv = gl_FragCoord.xy / uRes, px = 1.0 / uRes; vec4 inf = texture2D(tInfo, uv); if (inf.a < 0.5) { // outer line: grow the silhouette outward v…98 tokens truncated… if (r >= 4 && r <= 7) { gl_FragColor = vec4(0.0); return; } gl_FragColor = vec4(ink(texture2D(tColor, bq).rgb), 1.0); return; } gl_FragColor = vec4(0.0); return; } vec3 col = texture2D(tColor, uv).rgb; int r0 = rid(inf); float p0 = pid(inf); float z0 = z(uv); bool feature = r0 >= 4 && r0 <= 9; if (r0 == 9) { // the open mouth's rim: a lip line where it meets the face for (int k = 0; k < 8; k++) { float a = float(k) * 0.785398; vec2 q = uv + vec2(cos(a), sin(a)) * uSil * 0.9 * px; vec4 ni = texture2D(tInfo, q); if (ni.a > 0.5 && rid(ni) == 1) { col = mix(ink(texture2D(tColor, q).rgb), vec3(0.30, 0.10, 0.12), 0.4); break; } } float hu = mouthRun(uv, vec2(0.0, px.y)), hd = mouthRun(uv, vec2(0.0, -px.y)), h = hu + hd + 1.0; // teeth only in an opening tall enough to show them (8 to 11 mm, measured on the face): a slit or parted lips // (angry, sad) is all teeth in VRoid's mesh and read as a white pill; it reads as the dark inside instead float thin = 1.0 - smoothstep(0.008, 0.011, h / uPpm); if (thin > 0.0 && dot(col, vec3(1.0 / 3.0)) >= 0.8) col = mix(col, vec3(0.30, 0.10, 0.13), thin); float up = 0.0; // the upper lip's shadow: the top of the opening is dark for (int s = 2; s <= 5; s++) { vec4 a = texture2D(tInfo, uv + vec2(0.0, float(s)) * uSil * px); if (a.a > 0.5 && rid(a) == 1) up = 1.0; } if (up > 0.5 && dot(col, vec3(1.0 / 3.0)) < 0.8) col = min(col, vec3(0.36, 0.11, 0.14)); // not the teeth // a tall opening (shout, surprise) is dark in its upper part, the tongue only low in it; VRoid's map stretched // over a big opening would fill it with tongue. Small openings keep the map's read. float deep = 0.5 * smoothstep(14.0 * uSil, 30.0 * uSil, h), t = (hu + 0.5) / h; if (deep > 0.0 && dot(col, vec3(1.0 / 3.0)) < 0.8) col = mix(vec3(0.30, 0.10, 0.13), col, smoothstep(deep - 0.08, deep + 0.08, t)); } if (r0 == 8) col = browOverHair(uv, px, col); if (!feature) { for (int k = 0; k < 4; k++) { vec2 d = k == 0 ? vec2(1.0, 0.0) : (k == 1 ? vec2(-1.0, 0.0) : (k == 2 ? vec2(0.0, -1.0) : vec2(0.0, 1.0))); vec2 q = uv + d * px * uInner; vec4 ni = texture2D(tInfo, q); if (z(q) > z0 + uGap && pid(ni) != p0) { col = ink(col); break; } } float acc = 0.0, rad = uSil * 3.0; for (int k = 0; k < 8; k++) { float a = float(k) * 0.785398 + 0.39; vec2 q = uv + vec2(cos(a), sin(a)) * rad * px; vec4 ni = texture2D(tInfo, q); if (ni.a > 0.5) acc += clamp((z0 - z(q)) / 0.05, 0.0, 1.0); } col *= 1.0 - 0.22 * acc / 8.0; if (r0 == 1) { // the bangs shade the forehead float hair = 0.0; for (int s = 1; s <= 4; s++) { vec4 a = texture2D(tInfo, uv + vec2(0.0, float(s)) * uSil * px); int ra = rid(a); if (a.a > 0.5 && (ra == 3 || ra == 11)) hair = 1.0; } col = mix(col, col * vec3(0.84, 0.74, 0.76), 0.75 * hair); } } gl_FragColor = vec4(col, 1.0); }`; const compCam = new THREE.Camera(); function compPass(fs, uniforms) { const mat = new THREE.ShaderMaterial({ uniforms, vertexShader: `void main() { gl_Position = vec4(position.xy, 0.0, 1.0); }`, fragmentShader: fs, transparent: true }); const s = new THREE.Scene(); s.add(new THREE.Mesh(new THREE.PlaneGeometry(2, 2), mat)); return { mat, scene: s }; } // ---- the renderer --------------------------------------------------------------------------------------------------- const stageEl = $("stage"); const R = new THREE.WebGLRenderer({ antialias: false, alpha: true, preserveDrawingBuffer: !!SHEET }); R.setClearColor(0x000000, 0); R.outputColorSpace = THREE.LinearSRGBColorSpace; stageEl.appendChild(R.domElement); const paint = compPass(PAINT_COMP, { tColor: { value: null }, tInfo: { value: null }, tDepth: { value: null }, uRes: { value: new THREE.Vector2() }, uNear: { value: 0.1 }, uFar: { value: 40 }, uGap: { value: 0.012 }, uSil: { value: 2 }, uInner: { value: 1 }, uPpm: { value: 1000 } }); const ctl = new OrbitControls(camera, R.domElement); ctl.enableDamping = true; ctl.zoomToCursor = true; ctl.screenSpacePanning = true; ctl.minZoom = 0.3; ctl.maxZoom = 12; let freeLook = false; ctl.addEventListener("start", () => { freeLook = true; }); R.domElement.addEventListener("dblclick", focusAt); const targets = { rt: null, rtInfo: null, key: "" }; function targetsFor(w, h) { const key = `${w}x${h}`; if (targets.key === key) return; [targets.rt, targets.rtInfo].forEach(t => t && t.dispose()); const o = { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter }; targets.rt = new THREE.WebGLRenderTarget(w, h, o); targets.rtInfo = new THREE.WebGLRenderTarget(w, h, { ...o, depthTexture: new THREE.DepthTexture(w, h) }); targets.key = key; } // ---- cloth ------------------------------------------------------------------------------------------------------- // The skinned cape/tails stay hidden and provide the pinned row (they follow the animated body); // a plain display mesh in world space shows the simulated cloth. Colliders ride the bones. const _v = new THREE.Vector3(), _a = new THREE.Vector3(), _ab = new THREE.Vector3(), _cp = new THREE.Vector3(); const _A = new THREE.Vector3(), _B = new THREE.Vector3(); class Cloth { constructor(skinned, U, V, trims, capsules, bone, closed = false, hemOnly = false) { this.skinned = skinned; this.U = U; this.V = V; this.trims = trims; this.closed = closed; this.hemOnly = hemOnly; this.n = skinned.geometry.attributes.position.count; this.caps = capsules.map(c => ({ a: bone(c.bones[0]), b: bone(c.bones[1]), r: c.r + 0.006 })).filter(c => c.a && c.b); this.x = new Float32Array(this.n * 3); this.prev = new Float32Array(this.n * 3); # Study references (third-party art) never live in this repo; see docs/study.md refs/ study/ __pycache__/ *.pyc review/out/ { "comment": "Do not edit this file, use utils/roll_browser.js", "browsers": [ { "name": "chromium", "revision": "1248", "installByDefault": true, "browserVersion": "156.0.8078.4", "title": "Chrome for Testing" }, { "name": "chromium-headless-shell", "revision": "1248", "installByDefault": true, "browserVersion": "156.0.8078.4", "title": "Chrome Headless Shell" }, { "name": "firefox", "revision": "1555", "installByDefault": true, "browserVersion": "157.0", "title": "Firefox" },15 more lines not shown.
exec_commandsed -n '812,855p' tools/cage.py
command
sed -n '812,855p' tools/cage.py PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=tools:art/cast python3 - <<'PY' from cast import CAST from pathlib import Path import cage for n in ['arm_f_average','arm_f_strong','arm_f_slender']: p=Path(cage.path_for(n,CAST[n]['cage'])) print(p,p.is_file(), CAST[n]['shape']) PY sed -n '242,253p;909,919p;944,984p;1377,1389p' review/vroid-02/index.html rg -n 'out.glb|cams|CAM\.|const active|allMeshes' review/vroid-02/index.html | head -60 ls ~/context/sortie-node_modules/playwright
result, 4 lines
Script completed Wall time 0.6 seconds Output: {"chunk_id":"6dbf87","wall_time_seconds":0.464051115,"exit_code":0,"original_token_count":2217,"output":" \"heads\": [(_c(\"head\"), (-0.3, 0.6), 0.1)],\n \"neck_hd\": [(_c(\"len.Neck\"), (-0.6, 0.6), 0.15)],\n \"shoulder_hd\": [(_c(\"len.Shoulder\"), (-0.5, 3.0), 0.4)],\n \"hip_hd\": [(_c(\"wide.Hips\"), (-0.3, 1.2), 0.15)],\n \"waist_hd\": [(_c(\"rings.torso.waist.w\"), (-0.3, 1.5), 0.15)],\n \"arm_hd\": [(_c(\"len.UpperArm\", \"len.LowerArm\"), (-0.4, 0.5), 0.1)],\n \"hand_CE\": [(_c(\"hand\"), (-0.3, 0.6), 0.1)],\n \"foot_CE\": [(_c(\"foot\"), (-0.3, 0.6), 0.1)],\n \"cup_p\": [(_c(\"bust_shape.inflate\"), (0.0, 0.04), 0.008)], # VRoid's breasts inflated (tools/anthro.py's cup)\n \"thigh_p\": [(_c(\"swell.UpperLeg\"), (-0.01, 0.03), 0.004)], # mid-thigh (tools/anthro.py), metres along normals\n}\n\n\ndef probe(spec, anthro=None):\n import fit\n os.makedirs(OUT, exist_ok=True)\n p = os.path.join(OUT, f\".probe_{os.getpid()}.vrm\")\n write(p, *build(spec))\n try:\n return fit.measure(p, anthro)\n finally:\n os.remove(p)\n\n\ndef _key(spec, hair=True):\n src = \"\".join(open(os.path.join(HERE, f)).read() for f in (\"cage.py\", \"fit.py\", \"proportions.py\", \"makehuman.py\",\n \"anthro.py\", \"heads.py\", \"vroid_portrait.py\")\n + ((\"collide.py\",) if hair else ()))\n ref = spec.get(\"ref\")\n if isinstance(ref, str): # a cast entry's reference: its spec too (a refitted reference left the body stale)\n sys.path[:0] = [os.path.join(os.path.dirname(HERE), \"art\", \"cast\")]\n from cast import CAST\n src += json.dumps(CAST[ref][\"mh\"], sort_keys=True)\n return hashlib.sha1((src + json.dumps(spec, sort_keys=True)).encode()).hexdigest()[:16]\n\n\ndef fitted(spec, log=None):\n \"\"\"spec with its proportion controls fitted to spec[\"fit\"]'s archetype (cached).\"\"\"\n if \"fit\" not in spec:\n return spec\n import fit\n k = _key(spec, hair=False) # the hair's collision (collide.py) never moves the body\n try:\n cache = json.load(open(CACHE))\n~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_average_b9b0f674fce164bc.vrm True {'hands': 1.0}\n~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_strong_4ad9ea3b57cd9a77.vrm True {'hands': 1.0, 'rest': {'Fcl_BRW_Angry': 0.2}}\n~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_slender_81550a78f4ae4dbd.vrm True {'hands': 1.0}\n// role ids for the info pass (features 4-9 get no inner lines; hair 3 and 11 shade the forehead)\nconst ROLE_ID = { face: 1, body: 2, hair: 3, line: 4, iris: 5, white: 6, highlight: 7, brow: 8, mouth: 9, cloth: 10, hair_b: 11 };\nlet nextRole = 12;\nconst roleId = r => (ROLE_ID[r] ??= nextRole++);\nconst VIEW_YAW = { duel: 0, battle: 60, bust: 30, lineup: 20, compare: 0 };\nconst state = { view: \"duel\", who: CAM.characters[0].name, yaw: 0, mode: \"painted\", skin: \"\", toon: true, xray: false, hidden: new Set(),\n cloth: true, wind: false, playing: false, stepped: false, clip: \"clash\", pose: \"out\", compare: [], motion: \"still\",\n physics: true };\nconst charDef = name => CAM.characters.find(c => c.name === name);\n// a workshop page (camera.json \"page\"): its own title and notes, and no duel\nconst PAGE = CAM.page || null;\nconst NO_DUEL = PAGE?.duel === false;\n : state.view === \"lineup\" ? LINEUP.order : state.view === \"compare\" ? state.compare : [state.who];\nconst active = () => activeNames().map(n => chars.get(n)).filter(Boolean);\n\nasync function parseGlb(file) {\n const j = await (await fetch(file)).json();\n const bin = Uint8Array.from(atob(j.glb), c => c.charCodeAt(0));\n return await new Promise((ok, bad) => loader.parse(bin.buffer, \"\", ok, bad));\n}\nlet meshIndex = 1;\nfunction prepMesh(o, V, opts = {}) {\n const m0 = o.material, role = o.userData.role || \"body\", raw = rawTex(m0.map);\n}\n\nasync function loadCharacter(name) {\n if (chars.has(name)) return chars.get(name);\n const def = charDef(name), V = def.info, ci = CAM.characters.indexOf(def);\n const gltf = await parseGlb(`${name}.glb.json`);\n const turn = new THREE.Group(), holder = new THREE.Group();\n turn.add(holder); holder.add(gltf.scene);\n const meshes = [];\n gltf.scene.traverse(o => { if (o.isMesh) { prepMesh(o, V, { hairB: ci > 0 }); meshes.push(o); } });\n gltf.scene.updateMatrixWorld(true);\n const bone = n => gltf.scene.getObjectByName(n);\n const cloths = [], world = new THREE.Group();\n for (const [cname, info] of Object.entries(V.cloth || {})) {\n const skinned = meshes.find(m => m.userData.material === cname);\n if (!skinned) continue;\n const trims = meshes.filter(m => info.trims.includes(m.userData.material));\n const caps = V.capsules.filter(c => !info.collide || info.collide.some(k => c.bones[0].includes(k)));\n const cl = info.closed ? new SkirtRig(skinned, info.u, info.v, trims, caps, bone, info.edges === \"hem\")\n : new Cloth(skinned, info.u, info.v, trims, caps, bone, false, info.edges === \"hem\");\n const band = info.band || \"gold\", BR = V.roles[band] || V.roles.gold;\n const gold = hex(BR.bands ? BR.bands[Math.min(1, BR.bands.length - 1)][1] : BR.color);\n const PB = (V.paint || {})[band];\n if (PB && PB.base) skinned.userData.mats.painted.uniforms.uBand.value = hex(PB.base); // gold stays gold for decals\n cl.lines3d = new THREE.LineSegments(cl.lines.geometry, new THREE.LineBasicMaterial({ color: gold }));\n cl.lines3d.frustumCulled = false;\n world.add(cl.display, cl.lines3d);\n cloths.push(cl);\n }\n const mixer = new THREE.AnimationMixer(gltf.scene);\n const actions = Object.fromEntries(gltf.animations.map(c => [c.name, mixer.clipAction(c)]));\n const skeleton = meshes.find(m => m.isSkinnedMesh)?.skeleton;\n const c = { name, info: V, turn, holder, root: gltf.scene, meshes, cloths, world, mixer, actions, skeleton,\n clip: \"idle\", t: 0, groups: [...new Set(meshes.map(m => m.userData.group))] };\n c.springs = makeSprings(c, V.springs);\n chars.set(name, c);\n return c;\n}\n\nasync function loadGround() {\n if (ground) return ground;\nfunction applySkin(meshes) {\n // the picked tone on every skin material (face, body, shadow cards); the built tone is kept to go back to\n const tone = state.skin && PAGE && PAGE.skins ? PAGE.skins.find(s => s.name === state.skin) : null;\n for (const o of meshes) {\n const m = o.userData.mats && o.userData.mats.painted, u = m && m.uniforms;\n if (!u || !u.uSkinRamp || u.uKind.value !== 1) continue;\n if (!o.userData.builtSkin) o.userData.builtSkin = [u.uSkinRamp.value, u.uSkinL.value.clone(), u.uSkinS.value.clone(), u.uSkinC.value.clone()];\n if (tone) { u.uSkinRamp.value = 1; u.uSkinL.value.copy(hex(tone.ramp[0])); u.uSkinS.value.copy(hex(tone.ramp[1])); u.uSkinC.value.copy(hex(tone.ramp[2])); }\n else { const b = o.userData.builtSkin; u.uSkinRamp.value = b[0]; u.uSkinL.value.copy(b[1]); u.uSkinS.value.copy(b[2]); u.uSkinC.value.copy(b[3]); }\n }\n}\nfunction render() {\n const meshes = allMeshes(), cs = active();\n247:const state = { view: \"duel\", who: CAM.characters[0].name, yaw: 0, mode: \"painted\", skin: \"\", toon: true, xray: false, hidden: new Set(),\n250:const charDef = name => CAM.characters.find(c => c.name === name);\n252:const PAGE = CAM.page || null;\n281: if (!state.compare.length) state.compare = CAM.characters.slice(0, 2).map(c => c.name);\n905:const LINEUP = CAM.lineup || { order: [], spacing: 0.9 };\n907:const CAM_VIEW = () => state.view === \"duel\" || ROW_VIEW() ? CAM.duel.cam : charDef(state.who).cams[state.view];\n908:const activeNames = () => state.view === \"duel\" ? [CAM.duel.order.player, CAM.duel.order.opponent]\n910:const active = () => activeNames().map(n => chars.get(n)).filter(Boolean);\n948: const def = charDef(name), V = def.info, ci = CAM.characters.indexOf(def);\n985: const V = CAM.characters[0].info, gltf = await parseGlb(\"plains.glb.json\"), meshes = [];\n991:const allMeshes = () => [...active().flatMap(c => [...c.meshes, ...c.cloths.map(cl => cl.display)]),\n995: allMeshes().forEach(o => {\n1249: const hit = ray.intersectObjects(allMeshes().filter(o => o.visible), false)[0];\n1279: [...new Set(CAM.characters.map(c => c.group || \"Other\"))].forEach(g => {\n1281: CAM.characters.filter(c => (c.group || \"Other\") === g && !skip.includes(c.name)).forEach(c => {\n1306: if (CAM.characters.some(c => c.group)) { // a long roster in groups (camera.json \"group\"): one dropdown\n1309: const order = [...new Set(CAM.characters.map(c => c.group || \"Other\"))];\n1312: CAM.characters.filter(c => (c.group || \"Other\") === g).forEach(c => {\n1322: CAM.characters.forEach(c => {\n1356: const pl = CAM.duel.place[c.name];\n1389: const meshes = allMeshes(), cs = active();\n1605: for (const c of CAM.characters) {\nLICENSE\nNOTICE\nREADME.md\nThirdPartyNotices.txt\ncli.js\nindex.d.ts\nindex.js\nindex.mjs\nlib\npackage.json\ntest.d.ts\ntest.js\ntest.mjs\ntypes\n"}exec_commandsed -n '380,576p' tools/export_glb.py && sed -n '986,996p;1099,1107p;1203,1231p' review/vroid-02/index.html && ls -l /opt/node/bin/node && git log -1 --oneline
command
sed -n '380,576p' tools/export_glb.py && sed -n '986,996p;1099,1107p;1203,1231p' review/vroid-02/index.html && ls -l /opt/node/bin/node && git log -1 --oneline
result, 243 lines
Script completed Wall time 0.1 seconds Output: def export_skinned(portrait, palette, path, clips=None, max_tex=512): """The character in its reference pose as a skinned glTF: the VRoid skeleton (with our bone scales) drives the body, face, hair and every costume piece through the weights they carry. clips: {name: [(time, pose dict), ...]} -> glTF animations (rotation, plus translation where a pose moves a bone). Scenery is left out (export it with export()).""" import vroid_portrait as vp v = portrait.v nodes_v = v.j["nodes"] names = v.nodes_by_name() parent = v.parents() used = set() for p in portrait.prims: if "jnames" in p and not p.get("world"): used.update(n for n in p["jnames"] if n in names) joints = set() for nm in used: # every used bone plus its ancestors i = names[nm] while i is not None and i not in joints: joints.add(i) i = parent.get(i) order = sorted(joints) jidx = {nodes_v[i].get("name"): k for k, i in enumerate(order)} ref = portrait.pose_ref local_ref = {i: F4 @ v.local_matrix(i, ref) @ F4 for i in order} world_ref = {} def wref(i): if i not in world_ref: world_ref[i] = (wref(parent[i]) @ local_ref[i]) if parent.get(i) in joints else local_ref[i] return world_ref[i] # glTF assembly (reuses the static exporter's buffer helpers by building a fresh document) bin_ = bytearray() views, accessors, meshes, gnodes, materials, textures, images, anims = [], [], [], [], [], [], [], [] tex_index = {} def add_view(data, target=None): while len(bin_) % 4: bin_.append(0) off = len(bin_) bin_.extend(data) vw = dict(buffer=0, byteOffset=off, byteLength=len(data)) if target: vw["target"] = target views.append(vw) return len(views) - 1 def add_acc(arr, kind, comp, target=None, minmax=False): arr = np.ascontiguousarray(arr) a = dict(bufferView=add_view(arr.tobytes(), target), componentType=comp, count=int(arr.shape[0]), type=kind) if minmax or (kind == "VEC3" and comp == 5126): a["min"] = np.atleast_1d(arr.min(0)).tolist() a["max"] = np.atleast_1d(arr.max(0)).tolist() accessors.append(a) return len(accessors) - 1 def add_texture(key, rgba, limit=None): if key in tex_index: return tex_index[key] im = Image.fromarray(rgba) lim = limit or max_tex if max(im.size) > lim: k = lim / max(im.size) im = im.resize((max(1, int(im.width * k)), max(1, int(im.height * k))), Image.LANCZOS) b = io.BytesIO() im.save(b, "PNG", optimize=True) images.append(dict(bufferView=add_view(b.getvalue()), mimeType="image/png")) textures.append(dict(source=len(images) - 1, sampler=0)) tex_index[key] = len(textures) - 1 return tex_index[key] # joint nodes node_of = {} for i in order: t, q, sc = _trs(local_ref[i]) node_of[i] = len(gnodes) gnodes.append(dict(name=nodes_v[i].get("name"), translation=t.tolist(), rotation=q.tolist(), scale=sc.tolist())) for i in order: kids = [node_of[c] for c in nodes_v[i].get("children", []) if c in joints] if kids: gnodes[node_of[i]]["children"] = kids roots = [node_of[i] for i in order if parent.get(i) not in joints] ibm = np.stack([np.linalg.inv(wref(i)).T for i in order]).astype(np.float32) # column-major skin = dict(joints=[node_of[i] for i in order], inverseBindMatrices=add_acc(ibm.reshape(-1, 16), "MAT4", 5126), skeleton=roots[0]) mesh_nodes = [] for k, (p, role) in enumerate(zip(portrait.prims, portrait.roles)): if role == "skip" or not len(p["tri"]) or p.get("world") or "J" not in p: continue usedv, inv = np.unique(p["tri"], return_inverse=True) pos = (p["pos"][usedv] * FLIP).astype(np.float32) nrm = p["nrm"][usedv] * FLIP nrm = (nrm / np.maximum(np.linalg.norm(nrm, axis=1, keepdims=True), 1e-9)).astype(np.float32) remap = np.array([jidx.get(n, jidx.get("J_Bip_C_Head")) for n in p["jnames"]]) J = remap[p["J"][usedv]].astype(np.uint16) W = p["W"][usedv].astype(np.float32) W /= np.maximum(W.sum(1, keepdims=True), 1e-9) attrs = dict(POSITION=add_acc(pos, "VEC3", 5126, 34962), NORMAL=add_acc(nrm, "VEC3", 5126, 34962), JOINTS_0=add_acc(J, "VEC4", 5123, 34962), WEIGHTS_0=add_acc(W, "VEC4", 5126, 34962)) if "plate" in p: # outline plates (tools/plates.py): border, engraving, gradient attrs["_PLATE"] = add_acc(np.asarray(p["plate"])[usedv].astype(np.float32), "VEC4", 5126, 34962) mat = dict(name=f"{group_of(p, role)}:{role}", doubleSided=True, pbrMetallicRoughness=dict(metallicFactor=0.0, roughnessFactor=0.9)) tone = ROLE_TONE.get(role) extra = getattr(portrait, "paint", None) or {} color = hex_rgb(palette[tone]) if tone in palette else \ hex_rgb(extra[role]) if isinstance(extra.get(role), str) else [0.8, 0.8, 0.8] if role in TEXTURED: src = portrait._hair_v if role == "hair" and getattr(portrait, "_hair_v", None) is not None \ and "_HAIR" in p["material"] else portrait.v raw = src.material_texture(p["mi"]) if p["mi"] >= 0 else None if raw is not None and role == "line": raw = fill_line_specks(raw) if p.get("lid_fill") is not None: # a shut eye's lid (vroid_portrait): its lash solid raw = fill_lid(raw, p["lid_fill"]) if raw is not None and role == "mouth": raw = even_mouth(raw) if raw is not None: attrs["TEXCOORD_0"] = add_acc(p["uv"][usedv].astype(np.float32), "VEC2", 5126, 34962) mat["pbrMetallicRoughness"]["baseColorTexture"] = dict( index=add_texture((id(src), p["mi"], p.get("lid_fill")), raw)) if role == "hair": mat["pbrMetallicRoughness"]["baseColorFactor"] = color + [1.0] if role in ("hair", "line", "brow", "iris", "highlight"): mat["alphaMode"], mat["alphaCutoff"] = "MASK", 0.5 else: mat["pbrMetallicRoughness"]["baseColorFactor"] = color + [1.0] else: mat["pbrMetallicRoughness"]["baseColorFactor"] = color + [1.0] if role in ("metal", "steel", "gold"): mat["pbrMetallicRoughness"].update(metallicFactor=0.6, roughnessFactor=0.35) if p.get("strands"): # kit hair (tools/hair.py): one shared strand texture import hair as _hair attrs["TEXCOORD_0"] = add_acc(np.asarray(p["uv"], np.float32)[usedv], "VEC2", 5126, 34962) mat["pbrMetallicRoughness"]["baseColorTexture"] = dict(index=add_texture(("strands",), _hair.STRANDS)) if "decal" in p: # a design in the piece's own coordinates (tools/plates.py Canvas) uvd = np.asarray(p["uv"], np.float32)[usedv].copy() uvd[:, 1] = 1 - uvd[:, 1] # the canvas draws t up; glTF's texture origin is the top left attrs["TEXCOORD_0"] = add_acc(uvd, "VEC2", 5126, 34962) mat["pbrMetallicRoughness"]["baseColorTexture"] = dict(index=add_texture(("decal", k), p["decal"], limit=1024)) mat["extras"] = dict(decal=True) materials.append(mat) meshes.append(dict(name=group_of(p, role), primitives=[dict(attributes=attrs, indices=add_acc(inv.reshape(-1).astype(np.uint32), "SCALAR", 5125, 34963), material=len(materials) - 1)])) mesh_nodes.append(len(gnodes)) gnodes.append(dict(name=f"{group_of(p, role)}/{p['material']}", mesh=len(meshes) - 1, skin=0, extras=dict(group=group_of(p, role), role=role, material=p["material"]))) # animations for name, keys in (clips or {}).items(): times = np.array([t for t, _ in keys], np.float32) tacc = add_acc(times.reshape(-1, 1), "SCALAR", 5126, minmax=True) samplers, channels = [], [] for i in order: mats = [F4 @ v.local_matrix(i, vp.bone_pose(v, portrait.shape, pose)) @ F4 for _, pose in keys] trs = [_trs(m) for m in mats] T = np.array([a for a, _, _ in trs], np.float32) Q = np.array([b for _, b, _ in trs], np.float32) for k in range(1, len(Q)): # keep quaternions on one hemisphere if np.dot(Q[k], Q[k - 1]) < 0: Q[k] = -Q[k] t0, q0, _ = _trs(local_ref[i]) if np.dot(Q[0], q0) < 0: q0 = -q0 # a channel whenever the clip leaves the reference pose, even if it then holds still if np.abs(Q - q0).max() > 1e-5: samplers.append(dict(input=tacc, output=add_acc(Q, "VEC4", 5126), interpolation="LINEAR")) channels.append(dict(sampler=len(samplers) - 1, target=dict(node=node_of[i], path="rotation"))) if np.abs(T - t0).max() > 1e-5: samplers.append(dict(input=tacc, output=add_acc(T, "VEC3", 5126), interpolation="LINEAR")) channels.append(dict(sampler=len(samplers) - 1, target=dict(node=node_of[i], path="translation"))) anims.append(dict(name=name, samplers=samplers, channels=channels)) root = len(gnodes) gnodes.append(dict(name="character", children=roots + mesh_nodes)) gltf = dict(asset=dict(version="2.0", generator="lowmarch export_skinned"), scene=0, scenes=[dict(nodes=[root])], nodes=gnodes, meshes=meshes, materials=materials, skins=[skin], accessors=accessors, bufferViews=views, buffers=[dict(byteLength=len(bin_))], samplers=[dict(magFilter=9729, minFilter=9987)]) if textures: gltf.update(textures=textures, images=images) if anims: gltf["animations"] = anims js = json.dumps(gltf, separators=(",", ":")).encode() js += b" " * ((4 - len(js) % 4) % 4) while len(bin_) % 4: bin_.append(0) out = struct.pack("<4sII", b"glTF", 2, 12 + 8 + len(js) + 8 + len(bin_)) out += struct.pack("<I4s", len(js), b"JSON") + js + struct.pack("<I4s", len(bin_), b"BIN\x00") + bytes(bin_) open(path, "wb").write(out) return len(out) gltf.scene.traverse(o => { if (o.isMesh) { prepMesh(o, V); meshes.push(o); } }); ground = { root: gltf.scene, meshes }; return ground; } const allMeshes = () => [...active().flatMap(c => [...c.meshes, ...c.cloths.map(cl => cl.display)]), ...(ground && ground.root.parent && state.view !== "bust" ? ground.meshes : [])]; const isSimTrim = o => state.cloth && active().some(c => c.cloths.some(cl => cl.trims.includes(o) || cl.skinned === o)); function applyMaterials() { allMeshes().forEach(o => { const mat = state.toon ? o.userData.mats.toon : o.userData.mats.clay; function makeSprings(c, groups) { const joints = []; if (!groups || !groups.length) return joints; c.skeleton && c.skeleton.pose(); c.root.updateMatrixWorld(true); for (const g of groups) { // collision spheres: a bone, an offset in its frame (turned as the export g.spheres = (g.colliders || []).map(s => ({ bone: c.root.getObjectByName(s.bone), // turns the model) offset: new THREE.Vector3(-s.offset[0], s.offset[1], -s.offset[2]), radius: s.radius })).filter(s => s.bone); } for (const g of groups) for (const rootName of g.bones) { function insets() { if (SHEET) return { top: 0, bottom: 0 }; const k = state.view === "compare" ? 1.0 : 0.8; // compare's bar is tall (the picker): raised hands mustn't hide under it return { top: document.querySelector(".hud.top").offsetHeight * k, bottom: document.querySelector(".hud.bottom").offsetHeight * 0.8 }; } let frameRef = null; // the game frame, metres from the orbit target function fitFrustum() { if (!frameRef) return; const W = stageEl.clientWidth || 1, H = stageEl.clientHeight || 1, ins = insets(); const f = frameRef, fw = (f.right - f.left) * 1.04, fh = (f.top - f.bottom) * 1.04; const s = Math.max(fw / W, fh / Math.max(60, H - ins.top - ins.bottom)); // metres per pixel const cx = (f.left + f.right) / 2, cy = (f.top + f.bottom) / 2; const top = cy + (H / 2 + (ins.top - ins.bottom) / 2) * s; // the frame's centre sits midway between the bars camera.left = cx - W * s / 2; camera.right = cx + W * s / 2; camera.top = top; camera.bottom = top - H * s; camera.updateProjectionMatrix(); } function size() { const w = stageEl.clientWidth, h = stageEl.clientHeight; if (!SHEET) { R.setPixelRatio(Math.min(2, window.devicePixelRatio || 1)); R.setSize(w, h, false); } fitFrustum(); } // The default framing: the portrait keeps the game's bust crop; battle and duel frame the figures // (head to feet, both fighters) rather than the whole ground strip, so they fill the window. const FIGURE = { duel: { w: 2.9, top: 1.28, bottom: -1.18 }, battle: { w: 1.5, top: 1.24, bottom: -1.14 }, get lineup() { return { w: Math.max(2.0, LINEUP.order.length * LINEUP.spacing + 0.4), top: 1.60, bottom: -1.16 }; }, get compare() { return COMPARE.frame; } }; function matchCamera() { // orbit around the middle of the body (the feet in battle would send zooms into the ground) const v = CAM_VIEW(), ppm = v.px_per_m, p = v.pivot, a = THREE.MathUtils.degToRad(v.pitch); -rwxr-xr-x 1 runner runner 123395824 Oct 28 2025 /opt/node/bin/node a97f25f Merge prep/kit-check-1109: VRoid licence read by hand (#1443), cold kit times
agent
+2:15I found a cached armory body, the robe and staff kit, and the painted renderer. I’ll use them for one study of a mage testing a flooded crossing. That gives the pose, clothing, and setting a job to do together, while leaving the restart character for you to choose.