← Commit history

Fix: keep the insertion animation in the rebuilt page GLBs

John Lauer ·d9482b54e4 ·20d ago ·parent 1702ce4
4 files changed +20−8
IN-S42ATA.glb
⋯ 1 unchanged line ⋯
IN-S42ATA.insertion.glb
⋯ 1 unchanged line ⋯
provenance/in-s42ata-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-S42ATA.glb": {-    "sha256": "aaeceff3970d61017161255bdcd79ff9df657b46f863e717947dffe595cc96ad",-    "bytes": 87588,+    "sha256": "e963f124cea4213a11fe5e3f13854b25938911cc775c7846ed4adf196e7fe6f1",+    "bytes": 87916,     "bytes_before": 263160,     "tris_before": 3010,     "tris_after": 1157,@@ -128,8 +128,8 @@     }    },    "IN-S42ATA.insertion.glb": {-    "sha256": "760923443aeda74bbad929b7080f9e05c6f50855ece34ac530a21cf5bd47940a",-    "bytes": 53744,+    "sha256": "bd2406796a36f5ba7991521fd71ead3ca511611d429229d2c8def525553b3fb2",+    "bytes": 54072,     "bytes_before": 286824,     "tris_before": 3290,     "tris_after": 1437,@@ -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-s42ata-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))