Spaces:
Paused
Paused
| import numpy as np, pygltflib | |
| from vid2rig.glb_exporter.bake import bake | |
| from vid2rig.retarget.retarget import TargetAnimation | |
| from vid2rig.tests.fixtures import make_mixamo_glb | |
| def test_bake_adds_animation_with_minmax(tmp_path): | |
| rig = make_mixamo_glb(tmp_path / "rig.glb") | |
| F = 3 | |
| rot = np.tile([0, 0, 0, 1.0], (F, 1)) | |
| anim = TargetAnimation( | |
| bone_names=["mixamorigHips", "mixamorigSpine", "mixamorigHead"], | |
| rotations={"mixamorigSpine": rot, "mixamorigHead": rot, "mixamorigHips": rot}, | |
| hips_translation=np.array([[0, 0, 0], [0, 0.1, 0], [0, 0.2, 0.0]]), fps=30.0) | |
| out = bake(str(rig), anim, str(tmp_path / "out.glb")) | |
| g = pygltflib.GLTF2().load(out) | |
| assert len(g.animations) == 1 | |
| ch_targets = {c.target.path for c in g.animations[0].channels} | |
| assert "rotation" in ch_targets and "translation" in ch_targets | |
| for s in g.animations[0].samplers: | |
| acc = g.accessors[s.input] | |
| assert acc.min is not None and acc.max is not None | |
| assert abs(acc.max[0] - (F - 1) / 30.0) < 1e-6 | |