import bpy, json
from pathlib import Path
root = Path(__file__).resolve().parents[2]
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.import_scene.gltf(filepath=str(root / 'assets/models/player/clockwork_balloonkeep.glb'))
rig = next(o for o in bpy.data.objects if o.type == 'ARMATURE')
print('RIG', rig.name, 'matrix', [list(row) for row in rig.matrix_world])
for b in rig.data.bones:
    print('BONE', b.name, 'parent', b.parent.name if b.parent else '', 'head', [round(x, 4) for x in b.head_local], 'tail', [round(x, 4) for x in b.tail_local])
for a in bpy.data.actions:
    curves = [fc for layer in a.layers for strip in layer.strips for slot in a.slots for fc in strip.channelbag(slot).fcurves]
    print('ACTION', a.name, list(a.frame_range), 'curves', len(curves), 'locations', [(fc.data_path, fc.array_index, round(max(abs(k.co.y) for k in fc.keyframe_points), 3)) for fc in curves if fc.data_path.endswith('location') and max(abs(k.co.y) for k in fc.keyframe_points) > 0.01][:12])
