Hello world¶
The simplest possible viser program - creates a server and adds a red sphere.
This demonstrates the two essential steps to get started with viser:
Create a
viser.ViserServer
instance, which starts a web server at http://localhost:8080Add 3D content using the scene API, like
viser.SceneApi.add_icosphere()
The server runs indefinitely until interrupted with Ctrl+C.
Source: examples/00_getting_started/00_hello_world.py

Code¶
1import time
2
3import viser
4
5
6def main():
7 server = viser.ViserServer()
8 server.scene.add_icosphere(
9 name="hello_sphere",
10 radius=0.5,
11 color=(255, 0, 0), # Red
12 position=(0.0, 0.0, 0.0),
13 )
14
15 print("Open your browser to http://localhost:8080")
16 print("Press Ctrl+C to exit")
17
18 while True:
19 time.sleep(10.0)
20
21
22if __name__ == "__main__":
23 main()