"""Dump the full node hierarchy (parents + world transforms) of a GLB."""
import sys
import numpy as np
import trimesh

s = trimesh.load(sys.argv[1])
print("geometry nodes:", sorted(s.graph.nodes_geometry))
print("all nodes:", sorted(s.graph.nodes))
edges = {}
try:
    for a, b in s.graph.transforms.edges:
        edges[b] = a
except Exception as e:
    print("edge dump failed:", e)
for node in sorted(s.graph.nodes):
    T, geom = s.graph[node]
    T = np.array(T, float)
    rot = np.round(np.degrees(trimesh.transformations.euler_from_matrix(T)), 1).tolist()
    pos = np.round(T[:3, 3], 3).tolist()
    print(f"{node:16s} parent={str(edges.get(node,'-')):16s} geom={geom} pos={pos} rot={rot}")
