Initialize world state

The first step is to declare the original state of the world. These properties will not change unless explicitly modified later on.

Import the bbi library and define the world object
from bbi import *

world = World("ocean")

Tip: useful classes are imported!

from bbi import * imports useful classes for scene creation, including Asset, various Geometry classes, SpawnZone, Vector3, and World. Check the bbi API Reference for the full list.

Attention

Don’t run the world definition cell more than once. Since we create objects and change the world through this object instance, redefining it will result in a fresh world state.

If you accidentally do so, don’t worry! Click the Restart kernel button above the notebook to restart the kernel and run the world definition cell again. Restarting the kernel also resets the viewport.

Define the initial state of the camera, assets, and the environment. Examples include the camera position, weather parameters, ocean state, the time of day, and the positions of static objects.

Init the camera position
# Init the camera
world.camera.set_position(Vector3(0, 0, 5))
world.camera.set_rotation(Vector3.zero())
Init the environment
# Init weather parameters
world.env.weather.set_sun_elevation(15)
world.env.weather.set_sun_azimuth(0)
world.env.weather.set_cloud_coverage(3.2)
world.env.weather.set_fog_intensity(4.8)

# Init ocean parameters
world.env.ocean.set_sea_state(SeaState.SMOOTH)

Computer vision models often struggle with distractor objects, interfering with predictions. Let’s simulate this with a target speedboat, and a large floating box behind it.

Init a speedboat and floating box
# Init a speedboat and set its initial position and rotation
boat = BuoyantAsset(node_id="boat", asset_name="Estalia Catania")
boat.set_position(Vector3(20, -15, 0)) # Place 20 meters forward and 15 meters left
boat.set_rotation(Vector3(0, 0, 90)) # Rotate the boat 90 degrees clockwise
world.add(boat)

# Init a floating box and set its position and scale
box = BuoyantAsset(node_id="box", asset_name="Large Box B")
box.set_position(Vector3(50, 0, 0)) # Place 50 meters forward
box.set_scale(Vector3(5, 5, 5)) # Scale the box by 5x
world.add(box)
Initial state of the world

Note

The BuoyantAsset class is used to create floating objects. These objects bob around in the water, but are anchored to their X and Y positions and do not drift! As you’ll see in the subsequent steps, keyframing these objects will respect their buoyancy while moving them.