"""Reunite camera_body/cover with the moved camera_mount (round-trip GLBs are FLAT: parenting is baked away,
so a Blender move of the mount leaves the children behind). Delta = mount center (his export) - mount center
(previous state); applies the delta to body+cover geometry in gripper_from_blender.glb."""
import numpy as np, trimesh
his = trimesh.load("gripper_from_blender.glb")
old = trimesh.load("gripper.glb")
def center(s, node):
    T, gn = s.graph[node]
    w = trimesh.transform_points(s.geometry[gn].vertices, np.array(T, float))
    return (w.min(0) + w.max(0)) / 2
d = center(his, "camera_mount") - center(old, "camera_mount")
print("mount delta (mm):", np.round(d * 100, 1).tolist())
for node in ("camera_body", "camera_cover"):
    g = his.geometry[his.graph[node][1]]
    g.vertices = g.vertices + d                       # bake the same delta into the children
his.export("gripper_from_blender.glb")
print("children reunited with the mount")
