Preview keyframes¶
After defining the keyframes, we notice that the viewport didn’t change. That’s expected since we
haven’t previewed them yet. To preview the changes, we need to call the preview_animation()
method on
the scenario.
Note
The preview will leave the world at the state in the final keyframe. To iterate quickly on changes, always define a new scenario to clear the old keyframes, and declare the new keyframes again.
If you make a mistake, don’t worry! You can always reset the world to its original state by restarting the kernel and running the cells again.
scenario.preview_animation() # Playback the keyframes in the viewport
The scenario will start playing back the keyframes in the viewport, and the speedboat will move.
The preview will run for the full number of frames specified in scenario.num_frames
, so be sure
to preview with less frames if you don’t want to wait!
Tip: preview fewer frames
There are two ways to get around previewing a large number of frames:
Preview with less total frames, which may affect keyframe logic if parameters depend on the frame number.
scenario = world.new_scenario(num_frames=5)
scenario.preview_animation()
Preview a subset of frames by providing
start_frame
andend_frame
topreview_animation
.
scenario = world.new_scenario(num_frames=200) # That's a lot!
scenario.preview_animation(start_frame=0, end_frame=5)