Args: keyframes: List of dicts with keys: frame, eye, center, up, fov. Must be sorted by frame and cover frame 0 .. total_frames-1. total_frames: Total number of frames in the sequence. interpolation: 'linear' | 'smoothstep'
(self, keyframes: List[dict], total_frames: int,
interpolation: str = 'smoothstep')
| 161 | """ |
| 162 | |
| 163 | def __init__(self, keyframes: List[dict], total_frames: int, |
| 164 | interpolation: str = 'smoothstep'): |
| 165 | """ |
| 166 | Args: |
| 167 | keyframes: List of dicts with keys: frame, eye, center, up, fov. |
| 168 | Must be sorted by frame and cover frame 0 .. total_frames-1. |
| 169 | total_frames: Total number of frames in the sequence. |
| 170 | interpolation: 'linear' | 'smoothstep' |
| 171 | """ |
| 172 | self.total_frames = total_frames |
| 173 | self.interpolation = interpolation |
| 174 | # Normalize keyframes: ensure numpy arrays |
| 175 | self.keyframes = [] |
| 176 | for kf in sorted(keyframes, key=lambda k: k['frame']): |
| 177 | self.keyframes.append({ |
| 178 | 'frame': int(kf['frame']), |
| 179 | 'eye': np.asarray(kf['eye'], dtype=np.float32), |
| 180 | 'center': np.asarray(kf['center'], dtype=np.float32), |
| 181 | 'up': np.asarray(kf['up'], dtype=np.float32), |
| 182 | 'fov': float(kf.get('fov', 60.0)), |
| 183 | }) |
| 184 | |
| 185 | def get_camera(self, frame_idx: int) -> Camera: |
| 186 | """Interpolate keyframes to get camera at any frame.""" |
nothing calls this directly
no outgoing calls
no test coverage detected