Setters vs. keyframes¶
There are two ways of applying Node attribute changes in BBI, namely
Setters:
node.set_param(value)
, andKeyframes:
set_keyframe(node, t, param=value)
.
Setters |
Keyframes |
|
---|---|---|
Preset |
|
|
Override |
|
|
What are setters?¶
Setting, e.g. world.camera.set_position(position)
is used to immediately apply a change to a Node’s attributes.
These calls are typically made near the beginning of the notebook to define attributes that remain constant throughout the scenario.
When initializing your scenario’s environment or camera, set presets first, then apply overrides as needed.
When to use setters¶
You’re initializing the world
You want to understand what an attribute does
You want to understand the visual effect of changing its value
You want to nodes to change over time
What are keyframes?¶
Keyframes store the state of a Node at a particular frame (usually referred to with i
or t
).
Each rendered image in the final dataset will be a snapshot of the world at a particular keyframe.
The main way to declare keyframes is through a for-loop over the number of frames:
scenario = world.new_scenario(num_frames=25, total_duration=5)
for i in range(scenario.num_frames):
scenario.set_keyframe(node, frame_id=i, position=Vector3(i, 0, 0))
scenario.preview_animation()
Since keyframes are defined in a loop with access to the current frame_id
, we can use that as a temporal index
to drive changes, fast or slow, across the frames.
Keyframes can be played back in the viewport using scenario.preview_animation()
, or rendered live in the viewport via a
scenario.render()
call or sent to Bifrost servers to render via the Send render job > button.
See also
When to use keyframes¶
Keyframes are often declared at the end of notebooks as they’re the recipe for the “final state” of the desired dataset.
They can also be used to create time series animations or visualize changes in individual attributes in the viewport, such as making the sun set by lowering its elevation:
scenario = world.new_scenario(num_frames=10, total_duration=1)
for i in range(scenario.num_frames):
scenario.set_keyframe(world.env.weather, frame_id=i, sun_elevation=10 - i)
scenario.preview_animation()
