-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
230 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Lines | ||
Make a ball with some random line segments and splines. | ||
""" | ||
|
||
import time | ||
|
||
import numpy as np | ||
import viser | ||
|
||
|
||
def main() -> None: | ||
server = viser.ViserServer() | ||
|
||
# Line segments. | ||
# | ||
# This will be much faster than creating separate scene objects for | ||
# individual line segments or splines. | ||
N = 2000 | ||
points = np.random.normal(size=(N, 2, 3)) * 3.0 | ||
colors = np.random.randint(0, 255, size=(N, 2, 3)) | ||
server.scene.add_line_segments( | ||
f"/line_segments", | ||
points=points, | ||
colors=colors, | ||
line_width=3.0, | ||
) | ||
|
||
# Spline helpers. | ||
# | ||
# If many lines are needed, it'll be more efficient to batch them in | ||
# `add_line_segments()`. | ||
for i in range(10): | ||
points = np.random.normal(size=(30, 3)) * 3.0 | ||
server.scene.add_spline_catmull_rom( | ||
f"/catmull/{i}", | ||
positions=points, | ||
tension=0.5, | ||
line_width=3.0, | ||
color=np.random.uniform(size=3), | ||
segments=100, | ||
) | ||
|
||
control_points = np.random.normal(size=(30 * 2 - 2, 3)) * 3.0 | ||
server.scene.add_spline_cubic_bezier( | ||
f"/cubic_bezier/{i}", | ||
positions=points, | ||
control_points=control_points, | ||
line_width=3.0, | ||
color=np.random.uniform(size=3), | ||
segments=100, | ||
) | ||
|
||
while True: | ||
time.sleep(10.0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.