"""Classify torn edges (posed stretch >5x) by the dominant joint of each endpoint. usage: fin_bones.py posed.glb""" import json, struct, sys, math from pathlib import Path from collections import Counter def read_glb(path): d = Path(path).read_bytes() length = struct.unpack_from("bw: bw, best = w, j return names[joints[best]] if best is not None else "?" edges = set() for t in range(0, len(idx), 3): a_,b_,c_ = idx[t], idx[t+1], idx[t+2] for u,v in ((a_,b_),(b_,c_),(c_,a_)): edges.add((u,v) if u 5: n_bad += 1; maxr = max(maxr, r) pairs[tuple(sorted((dn_u, dn_v)))] += 1 print(f"edges>5x: {n_bad} max stretch {maxr:.0f}x") for (a_,b_), n in pairs.most_common(20): print(f" {n:5d} {a_} <-> {b_}")