Markdown demonstrationΒΆ

Viser GUI has MDX 2 support.

 1import time
 2from pathlib import Path
 3
 4import viser
 5
 6server = viser.ViserServer()
 7server.scene.world_axes.visible = True
 8
 9markdown_counter = server.gui.add_markdown("Counter: 0")
10
11here = Path(__file__).absolute().parent
12
13button = server.gui.add_button("Remove blurb")
14checkbox = server.gui.add_checkbox("Visibility", initial_value=True)
15
16markdown_source = (here / "./assets/mdx_example.mdx").read_text()
17markdown_blurb = server.gui.add_markdown(
18    content=markdown_source,
19    image_root=here,
20)
21
22
23@button.on_click
24def _(_):
25    markdown_blurb.remove()
26
27
28@checkbox.on_update
29def _(_):
30    markdown_blurb.visible = checkbox.value
31
32
33counter = 0
34while True:
35    markdown_counter.content = f"Counter: {counter}"
36    counter += 1
37    time.sleep(0.1)