Download studio/root_motion.py from mantrakp/component-studio-coordinator: direct link, hf CLI and curl.
- Browser
- Download file 757 Bytes
-
https://huggingface.co/spaces/mantrakp/component-studio-coordinator/resolve/main/studio/root_motion.py
- Command line
-
hf download hf://spaces/mantrakp/component-studio-coordinator/studio/root_motion.py
-
curl -L -o root_motion.py https://huggingface.co/spaces/mantrakp/component-studio-coordinator/resolve/main/studio/root_motion.py
757 Bytes
| """Explicit translation policy for generated motion, in Blender's Z-up coordinates.""" | |
| import numpy as np | |
| def root_offsets(positions, scale, mode='world'): | |
| positions = np.asarray(positions, dtype=np.float64) | |
| if positions.ndim != 2 or positions.shape[1] != 3 or not len(positions) or not np.isfinite(positions).all(): | |
| raise ValueError('Root positions must be finite frame-by-XYZ coordinates') | |
| if not np.isfinite(scale) or scale <= 0: | |
| raise ValueError('Root motion scale must be positive and finite') | |
| if mode not in {'world', 'in-place'}: | |
| raise ValueError(f'Unknown root motion policy: {mode}') | |
| offsets = (positions - positions[0]) * scale | |
| if mode == 'in-place': | |
| offsets[:, :2] = 0 | |
| return offsets | |