Place assets along paths¶
BBI allows you to place assets along straight and curved paths and animate their movement.

Init world with calm ocean¶
For the purposes of this example, let’s make the ocean calm to see the splines clearly.
from bbi import *
world = World("ocean")
# Set the camera to a level rotation
world.camera.set_rotation(Vector3.zero())
# Select the "Partly Cloudy B" preset from the bottom drawer
world.env.apply_preset("partly_cloudy_b")
Create straight and curved paths¶
Tip
To create Splines
faster, use the
Coordinate Picker
viewport tool to pick coordinates from the viewport, which will copy them to your clipboard.
Pass these coordinates to Vector3
points to create a Spline
.
# Create a straight path using Spline. Select points using picker.
straight = Spline(
node_id="straight",
points=[
Vector3(24.33, -16.16, 0),
Vector3(96.61, 75.62, 0),
]
)
world.add(straight)
# Create a curved path using Spline. Select points using picker.
curved = Spline(
node_id="curved",
points=[
Vector3(27.71, 16.23, 0),
Vector3(45.69, 37.67, 0),
Vector3(47.71, -3.27, 0),
Vector3(36.1, -23.9, 0),
Vector3(75.51, -37.68, 0),
],
)
world.add(curved)
Place boats on paths¶
Place two boats, one on each path. Place the first boat at the start of the curved path and the second boat at the end of the straight path.
Think of t
as a progress value along the spline: get_position(t)
and get_rotation(t)
returns the position and direction of
the spline at that progress value.
For flat splines with no z-height variation, you can add Vector3(0, 0, 180)
to the rotation to make the boat face the opposite direction of the spline.
# Create a boat asset and place it at the start of the curved path
# Set its rotation to the direction of the path
boat1 = BuoyantAsset(node_id="boat1", asset_name="USCG Response Boat")
boat1.set_position(curved.get_position(t=0))
boat1.set_rotation(curved.get_rotation(t=0))
world.add(boat1)
# Create another boat asset and place it at the end of the straight path
# Set its rotation to the opposite direction of the path
boat2 = BuoyantAsset(node_id="boat2", asset_name="USCG Auxiliary Boat")
boat2.set_position(straight.get_position(t=1))
boat2.set_rotation(straight.get_rotation(t=1) + Vector3(0, 0, 180))
world.add(boat2)
Animate the boats along the paths¶
Animate the boats along the paths by setting keyframes for each frame.
Calculate a progress value across frames (between 0 - 1) and set the boats’ position and rotation along the curved and straight paths.
scenario = world.new_scenario(num_frames=10)
for i in range(scenario.num_frames):
# Calculate a progress value across frames (between 0 - 1)
progress = i / (scenario.num_frames - 1)
# Set boat1's position and rotation along the curved path
scenario.set_keyframe(
boat1,
i,
position=curved.get_position(progress),
rotation=curved.get_rotation(progress),
)
# Set boat2's position and rotation along the straight path
scenario.set_keyframe(
boat2,
i,
position=straight.get_position(1 - progress),
rotation=straight.get_rotation(progress) + Vector3(0, 0, 180),
)
scenario.preview_animation()