Potree Point Cloud Viewer¶
This notebook demonstrates the Potree integration in anymap-ts for visualizing large-scale 3D point clouds (LiDAR data) directly in a Jupyter notebook.
Potree is a WebGL-based point cloud renderer that efficiently handles millions of points using a level-of-detail (LOD) hierarchy.
In [ ]:
Copied!
# %pip install anymap-ts
# %pip install anymap-ts
In [ ]:
Copied!
from anymap_ts import PotreeViewer
from anymap_ts import PotreeViewer
Create a Potree Viewer¶
Create a viewer and load a sample point cloud from the Potree examples repository.
In [ ]:
Copied!
viewer = PotreeViewer(
height="600px",
point_budget=1_000_000,
point_size=1.0,
background="#000000",
edl_enabled=True,
)
viewer
viewer = PotreeViewer(
height="600px",
point_budget=1_000_000,
point_size=1.0,
background="#000000",
edl_enabled=True,
)
viewer
Load a Point Cloud¶
Load a Potree-formatted point cloud. The dataset must be in Potree's octree format
(with a cloud.js metadata file).
In [ ]:
Copied!
url = "https://potree.github.io/potree/pointclouds/lion_takanawa/cloud.js"
viewer.load_point_cloud(
url=url,
name="lion",
point_size_type="adaptive",
shape="circle",
)
url = "https://potree.github.io/potree/pointclouds/lion_takanawa/cloud.js"
viewer.load_point_cloud(
url=url,
name="lion",
point_size_type="adaptive",
shape="circle",
)
Adjust Visualization Settings¶
Change point budget, point size, and Eye Dome Lighting (EDL) settings.
In [ ]:
Copied!
viewer.set_point_budget(2_000_000)
viewer.set_point_size(1.5)
viewer.set_point_budget(2_000_000)
viewer.set_point_size(1.5)
In [ ]:
Copied!
viewer.set_edl(enabled=True, radius=1.8, strength=0.5)
viewer.set_edl(enabled=True, radius=1.8, strength=0.5)
Camera Controls¶
Set the camera position and look-at target, or fly to a point cloud.
In [ ]:
Copied!
viewer.fly_to_point_cloud("lion")
viewer.fly_to_point_cloud("lion")
In [ ]:
Copied!
viewer.set_camera_position(0, -5, 3)
viewer.set_camera_target(0, 0, 1)
viewer.set_camera_position(0, -5, 3)
viewer.set_camera_target(0, 0, 1)
Change Background Color¶
In [ ]:
Copied!
viewer.set_background("#1a1a2e")
viewer.set_background("#1a1a2e")
Export to HTML¶
Export the viewer to a standalone HTML file with full interactivity.
In [ ]:
Copied!
viewer.to_html("potree_example.html")
viewer.to_html("potree_example.html")