|
@@ -142,15 +142,24 @@ def immediate_updates() -> None:
|
|
|
@doc.demo('Rendering point clouds', '''
|
|
|
You can render point clouds using the `point_cloud` method.
|
|
|
The `points` argument is a list of point coordinates, and the `colors` argument is a list of RGB colors (0..1).
|
|
|
+ You can update the cloud using its `set_points()` method.
|
|
|
''')
|
|
|
def point_clouds() -> None:
|
|
|
import numpy as np
|
|
|
|
|
|
- with ui.scene().classes('w-full h-64') as scene:
|
|
|
+ def generate_data(frequency: float = 1.0):
|
|
|
x, y = np.meshgrid(np.linspace(-3, 3), np.linspace(-3, 3))
|
|
|
- z = np.sin(x) * np.cos(y) + 1
|
|
|
+ z = np.sin(x * frequency) * np.cos(y * frequency) + 1
|
|
|
points = np.dstack([x, y, z]).reshape(-1, 3)
|
|
|
- scene.point_cloud(points=points, colors=points, point_size=0.1)
|
|
|
+ colors = points / [6, 6, 2] + [0.5, 0.5, 0]
|
|
|
+ return points, colors
|
|
|
+
|
|
|
+ with ui.scene().classes('w-full h-64') as scene:
|
|
|
+ points, colors = generate_data()
|
|
|
+ point_cloud = scene.point_cloud(points, colors, point_size=0.1)
|
|
|
+
|
|
|
+ ui.slider(min=0.1, max=3, step=0.1, value=1) \
|
|
|
+ .on_value_change(lambda e: point_cloud.set_points(*generate_data(e.value)))
|
|
|
|
|
|
|
|
|
@doc.demo('Wait for Initialization', '''
|