← Commit history

Metal finishing for every GLB; models.json front = the side-wall mark's face

John Lauer ·c72418cb8a ·16d ago ·parent 7723e88
2 files changed +32−1
models.json+6−1
@@ -151,5 +151,10 @@    "git_blob": "040785e3dfa08134ce8404c9669152ce6d6abfc4"   }  ],- "updated": "2026-10-04"+ "updated": "2026-10-04",+ "front": [+  0,+  -1,+  0+ ] }
provenance/tools/glb_post_metal.pyadded+26
@@ -0,0 +1,26 @@+#!/usr/bin/env python3+"""Make the terminal metal read as metal in every GLB of the WS2812B-2020 page (hero, chip GLB, scenes).++STEP colours carry no metalness, so step2glb writes the tinned terminals (sRGB 0.80, 0.81, 0.83; linear+0.604, 0.621, 0.656) as a plain grey. This sets every material of that colour (the castellations, bottom pads,+top-side terminals and lead-frame stubs) to metallicFactor 0.9, roughnessFactor 0.25: bright tinned metal against+the white insulation. Idempotent. usage: glb_post_metal.py FILE.glb [...]"""+import json, struct, sys+METAL = (0.6038, 0.6209, 0.6559)+++def read_glb(p):+    b = open(p, "rb").read(); n = struct.unpack("<I", b[12:16])[0]; js = json.loads(b[20:20 + n]); o = 20 + n+    return js, b[o:]+++for p in sys.argv[1:]:+    js, rest = read_glb(p); n = 0+    for m in js.get("materials", []):+        pbr = m.setdefault("pbrMetallicRoughness", {}); c = (pbr.get("baseColorFactor") or [1, 1, 1, 1])[:3]+        if max(abs(a - b) for a, b in zip(c, METAL)) < 2e-3 or m.get("name") == "terminal_tinned":+            pbr.update(metallicFactor=0.9, roughnessFactor=0.25); n += 1+    j = json.dumps(js, separators=(",", ":")).encode(); j += b" " * (-len(j) % 4)+    body = struct.pack("<II", len(j), 0x4E4F534A) + j + rest+    open(p, "wb").write(struct.pack("<III", 0x46546C67, 2, 12 + len(body)) + body)+    print(json.dumps(dict(glb=p, metal_materials=n)))