diff --git a/docs/source/examples/19_get_renders.rst b/docs/source/examples/19_get_renders.rst new file mode 100644 index 000000000..958b38a82 --- /dev/null +++ b/docs/source/examples/19_get_renders.rst @@ -0,0 +1,58 @@ +.. Comment: this file is automatically generated by `update_example_docs.py`. + It should not be modified manually. + +Get Renders +========================================== + + +Example for getting renders from a client's viewport to the Python API. + + + +.. code-block:: python + :linenos: + + + 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=1080, width=1920)) + + print("Writing GIF...") + iio.imwrite("saved.gif", images) + print("Wrote GIF!") + + while True: + time.sleep(10.0) + + + if __name__ == "__main__": + main() diff --git a/src/viser/client/.eslintrc.js b/src/viser/client/.eslintrc.js index ab41456fc..2396f55bf 100644 --- a/src/viser/client/.eslintrc.js +++ b/src/viser/client/.eslintrc.js @@ -37,6 +37,6 @@ module.exports = { skipUndeclared: true, }, ], - "react-refresh/only-export-components": "warn" + "react-refresh/only-export-components": "warn", }, }; diff --git a/src/viser/client/index.html b/src/viser/client/index.html index 932cca4e9..218df4beb 100644 --- a/src/viser/client/index.html +++ b/src/viser/client/index.html @@ -1,14 +1,11 @@ - + - +