#!/usr/bin/env python3 """glb_inspect.py — stdlib-only GLB animation/skin inspector. Prints: animation clip count + names, skins/meshes/images/materials, material alphaMode (warns on non-OPAQUE), and per-clip root-node scale ranges (catches the Meshy library-animation baked-scale bug, e.g. Hips scale 1.176 on one clip while others are 1.0). A correct character GLB: skins >= 1, expected clip count, all alphaMode OPAQUE, every clip's root scale ~= 1.0. If clips == 1 and the name contains "T-Pose", the NLA-tracks export step was skipped. Usage: python3 glb_inspect.py model.glb """ import json import struct import sys MAGIC = 0x46546C67 CHUNK_JSON = 0x4E4F534A CHUNK_BIN = 0x004E4942 COMPONENT_FMT = {5120: "b", 5121: "B", 5122: "h", 5123: "H", 5125: "I", 5126: "f"} TYPE_COUNT = {"SCALAR": 1, "VEC2": 2, "VEC3": 3, "VEC4": 4, "MAT4": 16} def read_glb(path): with open(path, "rb") as f: data = f.read() magic, version, _ = struct.unpack_from(" 1e-3 or abs(hi - 1.0) > 1e-3: node_name = gltf["nodes"][tgt["node"]].get("name", tgt["node"]) scale_note = (f" <-- WARNING: root '{node_name}' scale in " f"[{lo:.4f}, {hi:.4f}] != 1.0 (Meshy baked-scale bug; " f"re-run merge_anim_glbs.py or fix manually)") warnings.append(name) print(f" clip: {name}{scale_note}") if len(anims) == 1 and "t-pose" in anims[0].get("name", "").lower().replace("_", "-"): print("WARNING: single clip named like T-Pose — NLA-tracks export step was skipped") if not gltf.get("skins"): print("WARNING: skins == 0 — weight transfer failed (check data_transfer direction: source must be ACTIVE)") if warnings: sys.exit(2) if __name__ == "__main__": main()