"""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