← Commit history

Fix: keep the insertion animation in the rebuilt page GLBs

John Lauer ·7932b17601 ·20d ago ·parent 1f2f3d4
4 files changed +20−8
IN-S63BTG.glb
⋯ 1 unchanged line ⋯
IN-S63BTG.insertion.glb
⋯ 1 unchanged line ⋯
provenance/in-s63btg-led-pass.provenance.json+6−5
@@ -85,8 +85,8 @@   "meaning": "<MPN>.glb and <MPN>.insertion.glb are the page's composite LED scenes (FR4 board, pads, silk, solder fillets, the LED, an emissive LED_lit skin, FOV cone and a point light). The README's inline viewer (Colby's viewer + Static / Pick&Place additions) loads <MPN>.insertion.glb and animates the LED being inserted (placed) into its footprint; <MPN>.glb is the older static composite with the earlier silkscreen. Only the LED geometry/colours were replaced; every other node is copied unchanged.",   "files": {    "IN-S63BTG.glb": {-    "sha256": "f153a45efba15915b78687459744e8754a98b276e66d4f42abc0d25250ec6086",-    "bytes": 148548,+    "sha256": "5ca2a83bb85b11a7e98c798cc13ec81c5cb8869bd8c15f560d62f1aa1dd8ecec",+    "bytes": 148876,     "bytes_before": 877664,     "tris_before": 10324,     "tris_after": 2026,@@ -128,8 +128,8 @@     }    },    "IN-S63BTG.insertion.glb": {-    "sha256": "e207950982ff853e6a734c3101d46d35b115e68ac0fbd9d1561e01ad767b4c39",-    "bytes": 114688,+    "sha256": "13b0465520d3c35a53c1a205643be8430102d9df93c1ff700ab1888fbebf5f29",+    "bytes": 115016,     "bytes_before": 901360,     "tris_before": 10604,     "tris_after": 2306,@@ -170,7 +170,8 @@      }     }    }-  }+  },+  "animation_fix": "2026-09-30: the pick-and-place insertion animation (sampler keyframe accessors) is carried over unchanged; the earlier rebuilds of this pass had dropped those accessors, leaving the animation pointing at geometry data"  },  "hero_glb": {   "file": "in-s63btg-hero.glb",
provenance/tools/gltfio.py+14−3
@@ -49,12 +49,17 @@ def save(path, d, arrays):         k = 1 if arr.ndim == 1 else arr.shape[1]         acc = {'bufferView': len(d['bufferViews']) - 1, 'componentType': ct, 'count': int(arr.shape[0]),                'type': {1: 'SCALAR', 2: 'VEC2', 3: 'VEC3', 4: 'VEC4'}[k]}-        if pos or key.endswith('POSITION'): acc['min'] = [float(v) for v in arr.min(0)]; acc['max'] = [float(v) for v in arr.max(0)]+        if pos or key.endswith('POSITION'):+            mn, mx = arr.min(0), arr.max(0)+            acc['min'] = [float(v) for v in np.atleast_1d(mn)]; acc['max'] = [float(v) for v in np.atleast_1d(mx)]         d['accessors'].append(acc); idx[key] = len(d['accessors']) - 1; return idx[key]     for m in d['meshes']:         for p in m['primitives']:             p['attributes'] = {k: add(v, k == 'POSITION') for k, v in p['attributes'].items()}             if 'indices' in p: p['indices'] = add(p['indices'])+    for an in d.get('animations', []):             # keyframe times need min/max (glTF requires it on sampler input)+        for sm in an['samplers']:+            sm['input'] = add(sm['input'], True); sm['output'] = add(sm['output'])     while len(blob) % 4: blob.append(0)     d['buffers'] = [{'byteLength': len(blob)}]     j = json.dumps(d, separators=(',', ':')).encode(); j += b' ' * ((-len(j)) % 4)@@ -70,6 +75,10 @@ def explode(d, binc):                 key = f'a{a}_{k}'; arrays[key] = (accessor(d, binc, a), 34962); p['attributes'][k] = key             if 'indices' in p:                 key = f'a{p["indices"]}_IDX'; arrays[key] = (accessor(d, binc, p['indices']), 34963); p['indices'] = key+    for an in d.get('animations', []):             # animation keyframes are accessors too: carry them (bug fixed 2026-09-30)+        for sm in an['samplers']:+            for k in ('input', 'output'):+                key = f'a{sm[k]}_ANIM'; arrays[key] = (accessor(d, binc, sm[k]), None); sm[k] = key     for k in ('accessors', 'bufferViews', 'buffers'): d.pop(k, None)     return arrays @@ -84,8 +93,10 @@ def flatten(d, binc):             R = W[:3, :3]; Nm = np.linalg.inv(R).T             for p in d['meshes'][n['mesh']]['primitives']:                 P = accessor(d, binc, p['attributes']['POSITION']).astype(np.float64) @ R.T + W[:3, 3]-                N = accessor(d, binc, p['attributes']['NORMAL']).astype(np.float64) @ Nm.T-                N /= np.maximum(np.linalg.norm(N, axis=1, keepdims=True), 1e-12)+                N = None+                if 'NORMAL' in p['attributes']:+                    N = accessor(d, binc, p['attributes']['NORMAL']).astype(np.float64) @ Nm.T+                    N /= np.maximum(np.linalg.norm(N, axis=1, keepdims=True), 1e-12)                 out.append((p.get('material'), P, N, accessor(d, binc, p['indices']).astype(np.int64)))         for c in n.get('children', []): walk(c, W)     for r in d['scenes'][d.get('scene', 0)]['nodes']: walk(r, np.eye(4))