Camera Controls¶
This notebook demonstrates how to control the camera in the Potree viewer, including setting position, look-at target, flying to point clouds, and resetting the view.
In [ ]:
Copied!
# %pip install anymap-ts
# %pip install anymap-ts
In [ ]:
Copied!
from anymap_ts import PotreeViewer
from anymap_ts import PotreeViewer
Create Viewer and Load Point Cloud¶
In [ ]:
Copied!
viewer = PotreeViewer(height="600px", point_budget=1_000_000, edl_enabled=True)
viewer
viewer = PotreeViewer(height="600px", point_budget=1_000_000, edl_enabled=True)
viewer
In [ ]:
Copied!
url = "https://potree.github.io/potree/pointclouds/lion_takanawa/cloud.js"
viewer.load_point_cloud(url=url, name="lion")
url = "https://potree.github.io/potree/pointclouds/lion_takanawa/cloud.js"
viewer.load_point_cloud(url=url, name="lion")
Set Camera Position¶
The camera position is specified as (x, y, z) coordinates in the point cloud's coordinate system.
In [ ]:
Copied!
# View from the front
viewer.set_camera_position(0, -5, 2)
viewer.set_camera_target(0, 0, 1)
# View from the front
viewer.set_camera_position(0, -5, 2)
viewer.set_camera_target(0, 0, 1)
In [ ]:
Copied!
# View from above
viewer.set_camera_position(0, 0, 8)
viewer.set_camera_target(0, 0, 0)
# View from above
viewer.set_camera_position(0, 0, 8)
viewer.set_camera_target(0, 0, 0)
In [ ]:
Copied!
# View from the side
viewer.set_camera_position(5, 0, 2)
viewer.set_camera_target(0, 0, 1)
# View from the side
viewer.set_camera_position(5, 0, 2)
viewer.set_camera_target(0, 0, 1)
Fly to Point Cloud¶
Automatically frame a point cloud to fit in the viewport.
In [ ]:
Copied!
# Fly to a specific point cloud by name
viewer.fly_to_point_cloud("lion")
# Fly to a specific point cloud by name
viewer.fly_to_point_cloud("lion")
In [ ]:
Copied!
# Fly to fit all point clouds
viewer.fly_to_point_cloud()
# Fly to fit all point clouds
viewer.fly_to_point_cloud()
Reset Camera¶
Reset the camera to show all loaded point clouds.
In [ ]:
Copied!
viewer.reset_camera()
viewer.reset_camera()
Field of View¶
Adjust the camera field of view (in degrees). Wider FOV shows more of the scene, narrower FOV zooms in.
In [ ]:
Copied!
viewer.set_fov(90) # Wide angle
viewer.set_fov(90) # Wide angle
In [ ]:
Copied!
viewer.set_fov(30) # Telephoto
viewer.set_fov(30) # Telephoto
In [ ]:
Copied!
viewer.set_fov(60) # Default
viewer.set_fov(60) # Default