← Commit history

Fix: keep the insertion animation in the rebuilt page GLBs

John Lauer ·707e75ed56 ·20d ago ·parent 29076a2
4 files changed +20−8
IN-S42ATR.glb
⋯ 1 unchanged line ⋯
IN-S42ATR.insertion.glb
⋯ 1 unchanged line ⋯
provenance/in-s42atr-led-pass.provenance.json+6−5
@@ -87,8 +87,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-S42ATR.glb": {-    "sha256": "e57447c2233541f295b28d898fdc8f449f3101177404a4f0c40c14ba33944935",-    "bytes": 86988,+    "sha256": "751099306f7a8c3a240c38724403c85619cc60f6e012fc8c60d26b41a7aa24e3",+    "bytes": 87316,     "bytes_before": 263160,     "tris_before": 3010,     "tris_after": 1137,@@ -130,8 +130,8 @@     }    },    "IN-S42ATR.insertion.glb": {-    "sha256": "4246d76c3415306fe4296d7487493cb81deff74174e8c5bb8f1ecd40babf112c",-    "bytes": 86856,+    "sha256": "ffcfc283c6734bb557b8981c3e3a62895a1715371eb9e04f324d5fed69c060c9",+    "bytes": 87184,     "bytes_before": 264668,     "tris_before": 3034,     "tris_after": 1161,@@ -172,7 +172,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-s42atr-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))