Move and rotate the camera¶
Camera¶
Camera control mode¶
You can fly through the world by clicking on the
Control Camera
button on the
top right of the viewport. Doing so detaches the camera from the current position in code.
You can then use the W A S D keys and the mouse to move the camera around the scene. Click to drag the mouse to rotate the camera. Q and E keys can be used to move the camera up and down.
Warning
This mode is great for finding nice camera angles, but note that the camera’s position and rotation will not be updated in the code editor.
To register the camera’s current position and rotation, click on the
Copy current camera transform
button, which will copy the camera’s
transform to your clipboard. You can then paste the transform into your code cell,
and run the cell to confirm the camera’s position and rotation.
world.camera.set_transform(<COPIED TRANSFORM>)
Setting camera position and rotation¶
Camera
instances can be manually controlled using the set_position
and
set_rotation
methods.
world.camera.set_position(Vector3(-20, 0, 10))
world.camera.set_rotation(Vector3(-3, -5, 10))
Animating camera position and rotation¶
Camera
instances can be animated through scenario keyframes, allowing the camera to
vary its position and rotation across frames.
scenario = world.new_scenario(num_frames=10)
for i in range(scenario.num_frames):
scenario.set_keyframe(
instance=world.camera,
frame_id=i,
position=Vector3(i, 0, 0),
rotation=Vector3(0, i * 2, 0),
)
Satellite Camera¶
Camera control mode¶
Note
Camera control mode is disabled for SatelliteCamera
, as maintaining a pre-determined camera position is required for accurate satellite imagery.
Setting camera position and rotation¶
SatelliteCamera
instances can be manually controlled using the set_azimuth
, set_look_angle
, set_ground_target
, resolution
and set_fov
methods.
world.camera.set_gsd(0.5)
world.camera.set_resolution((1232, 1232))
world.camera.set_ground_target(xy=(0, 0))
world.camera.set_look_angle(world.camera.MIN_LOOK_ANGLE)
world.camera.set_azimuth(0)
Animating camera position and rotation¶
SatelliteCamera
instances can be animated through scenario keyframes, allowing the camera to
vary its position and rotation across frames.
def rand_camera() -> dict:
return {
"azimuth": rng.randrange(0, 360),
"ground_target": (rng.uniform(-50, 50), rng.uniform(-50, 50)),
"look_angle": rng.uniform(world.camera.MIN_LOOK_ANGLE, 10),
}
scenario = world.new_scenario(num_frames=10)
for i in range(scenario.num_frames):
scenario.set_keyframe(world.camera, i, **rand_camera())