-
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.
Add get_render() method for client handles (#102)
* Add get_render() method for client handles * Suppress type error
- Loading branch information
Showing
12 changed files
with
381 additions
and
156 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
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,47 @@ | ||
"""Get Renders | ||
Example for getting renders from a client's viewport to the Python API.""" | ||
|
||
import time | ||
|
||
import imageio.v3 as iio | ||
import numpy as onp | ||
|
||
import viser | ||
|
||
|
||
def main(): | ||
server = viser.ViserServer() | ||
|
||
button = server.add_gui_button("Render a GIF") | ||
|
||
@button.on_click | ||
def _(event: viser.GuiEvent) -> None: | ||
client = event.client | ||
assert client is not None | ||
|
||
client.reset_scene() | ||
|
||
images = [] | ||
|
||
for i in range(20): | ||
positions = onp.random.normal(size=(30, 3)) * 3.0 | ||
client.add_spline_catmull_rom( | ||
f"/catmull_{i}", | ||
positions, | ||
tension=0.5, | ||
line_width=3.0, | ||
color=onp.random.uniform(size=3), | ||
) | ||
images.append(client.get_render(height=720, width=1280)) | ||
|
||
print("Writing GIF...") | ||
iio.imwrite("saved.gif", images) | ||
print("Wrote GIF!") | ||
|
||
while True: | ||
time.sleep(10.0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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.