Skip to content

Commit

Permalink
deploy: 9036fcf
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 6, 2023
1 parent ef7d87f commit 4650557
Show file tree
Hide file tree
Showing 29 changed files with 525 additions and 414 deletions.
Binary file modified .doctrees/client_handles.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/examples/03_gui_callbacks.doctree
Binary file not shown.
Binary file modified .doctrees/examples/05_camera_commands.doctree
Binary file not shown.
Binary file modified .doctrees/examples/07_record3d_visualizer.doctree
Binary file not shown.
Binary file modified .doctrees/examples/11_colmap_visualizer.doctree
Binary file not shown.
Binary file modified .doctrees/examples/13_theming.doctree
Binary file not shown.
Binary file modified .doctrees/examples/19_get_renders.doctree
Binary file not shown.
Binary file modified .doctrees/server.doctree
Binary file not shown.
2 changes: 2 additions & 0 deletions _modules/viser/_scene_handles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ <h1>Source code for viser._scene_handles</h1><div class="highlight"><pre>

<span class="nd">@visible</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">visible</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">visible</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">if</span> <span class="n">visible</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_impl</span><span class="o">.</span><span class="n">visible</span><span class="p">:</span>
<span class="k">return</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_impl</span><span class="o">.</span><span class="n">api</span><span class="o">.</span><span class="n">_queue</span><span class="p">(</span>
<span class="n">_messages</span><span class="o">.</span><span class="n">SetSceneNodeVisibilityMessage</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_impl</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">visible</span><span class="p">)</span>
<span class="p">)</span>
Expand Down
18 changes: 17 additions & 1 deletion _modules/viser/_viser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,14 @@ <h1>Source code for viser._viser</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">got_lock</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_atomic_lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_locked_thread_id</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span></div>


<div class="viewcode-block" id="ClientHandle.flush">
<a class="viewcode-back" href="../../../client_handles/#viser.ClientHandle.flush">[docs]</a>
<span class="k">def</span> <span class="nf">flush</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Flush the outgoing message buffer. Any buffered messages will immediately be</span>
<span class="sd"> sent. (by default they are windowed)&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_state</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">_flush_event_from_client_id</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">client_id</span><span class="p">]</span><span class="o">.</span><span class="n">set</span><span class="p">()</span></div>
</div>


Expand Down Expand Up @@ -620,7 +628,7 @@ <h1>Source code for viser._viser</h1><div class="highlight"><pre>
<span class="k">assert</span> <span class="n">client_id</span> <span class="o">==</span> <span class="n">client</span><span class="o">.</span><span class="n">client_id</span>

<span class="c1"># Update the client&#39;s camera.</span>
<span class="k">with</span> <span class="n">client</span><span class="o">.</span><span class="n">_atomic_lock</span><span class="p">:</span>
<span class="k">with</span> <span class="n">client</span><span class="o">.</span><span class="n">atomic</span><span class="p">():</span>
<span class="n">client</span><span class="o">.</span><span class="n">camera</span><span class="o">.</span><span class="n">_state</span> <span class="o">=</span> <span class="n">_CameraHandleState</span><span class="p">(</span>
<span class="n">client</span><span class="p">,</span>
<span class="n">onp</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">message</span><span class="o">.</span><span class="n">wxyz</span><span class="p">),</span>
Expand Down Expand Up @@ -799,6 +807,14 @@ <h1>Source code for viser._viser</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">got_lock</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_atomic_lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_locked_thread_id</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span></div>


<div class="viewcode-block" id="ViserServer.flush">
<a class="viewcode-back" href="../../../server/#viser.ViserServer.flush">[docs]</a>
<span class="k">def</span> <span class="nf">flush</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Flush the outgoing message buffer. Any buffered messages will immediately be</span>
<span class="sd"> sent. (by default they are windowed)&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_server</span><span class="o">.</span><span class="n">_broadcast_buffer</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span></div>
</div>

</pre></div>
Expand Down
13 changes: 12 additions & 1 deletion _modules/viser/infra/_infra/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">_thread_executor</span> <span class="o">=</span> <span class="n">ThreadPoolExecutor</span><span class="p">(</span><span class="n">max_workers</span><span class="o">=</span><span class="mi">32</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_shutdown_event</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>

<span class="bp">self</span><span class="o">.</span><span class="n">_flush_event_from_client_id</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">Event</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>

<div class="viewcode-block" id="Server.start">
<a class="viewcode-back" href="../../../../infrastructure/#viser.infra.Server.start">[docs]</a>
<span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -499,6 +501,7 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="k">nonlocal</span> <span class="n">total_connections</span>
<span class="n">total_connections</span> <span class="o">+=</span> <span class="mi">1</span>

<span class="bp">self</span><span class="o">.</span><span class="n">_flush_event_from_client_id</span><span class="p">[</span><span class="n">client_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_verbose</span><span class="p">:</span>
<span class="n">rich</span><span class="o">.</span><span class="n">print</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;[bold](viser)[/bold] Connection opened (</span><span class="si">{</span><span class="n">client_id</span><span class="si">}</span><span class="s2">,&quot;</span>
Expand Down Expand Up @@ -538,6 +541,7 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="n">_client_producer</span><span class="p">(</span>
<span class="n">websocket</span><span class="p">,</span>
<span class="n">client_id</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_flush_event_from_client_id</span><span class="p">[</span><span class="n">client_id</span><span class="p">],</span>
<span class="n">client_state</span><span class="o">.</span><span class="n">message_buffer</span><span class="o">.</span><span class="n">get</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_client_api_version</span><span class="p">,</span>
<span class="p">),</span>
Expand All @@ -559,6 +563,7 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="c1"># queue get() tasks, which suppresses a &quot;Task was destroyed but it is</span>
<span class="c1"># pending&quot; error.</span>
<span class="k">await</span> <span class="n">client_state</span><span class="o">.</span><span class="n">message_buffer</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">DONE_SENTINEL</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_flush_event_from_client_id</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">client_id</span><span class="p">)</span>

<span class="c1"># Disconnection callbacks.</span>
<span class="k">for</span> <span class="n">cb</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client_disconnect_cb</span><span class="p">:</span>
Expand Down Expand Up @@ -631,6 +636,7 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="k">async</span> <span class="k">def</span> <span class="nf">_client_producer</span><span class="p">(</span>
<span class="n">websocket</span><span class="p">:</span> <span class="n">WebSocketServerProtocol</span><span class="p">,</span>
<span class="n">client_id</span><span class="p">:</span> <span class="n">ClientId</span><span class="p">,</span>
<span class="n">flush_event</span><span class="p">:</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">Event</span><span class="p">,</span>
<span class="n">get_next</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[[],</span> <span class="n">Coroutine</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">Union</span><span class="p">[</span><span class="n">Message</span><span class="p">,</span> <span class="n">DoneSentinel</span><span class="p">]]],</span>
<span class="n">client_api_version</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand All @@ -640,7 +646,10 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="n">message_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">get_next</span><span class="p">())</span>

<span class="k">while</span> <span class="ow">not</span> <span class="n">window</span><span class="o">.</span><span class="n">done</span><span class="p">:</span>
<span class="k">if</span> <span class="k">await</span> <span class="n">window</span><span class="o">.</span><span class="n">wait_and_append_to_window</span><span class="p">(</span><span class="n">message_task</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">window</span><span class="o">.</span><span class="n">done</span><span class="p">:</span>
<span class="k">if</span> <span class="p">(</span>
<span class="k">await</span> <span class="n">window</span><span class="o">.</span><span class="n">wait_and_append_to_window</span><span class="p">(</span><span class="n">message_task</span><span class="p">,</span> <span class="n">flush_event</span><span class="p">)</span>
<span class="ow">and</span> <span class="ow">not</span> <span class="n">window</span><span class="o">.</span><span class="n">done</span>
<span class="p">):</span>
<span class="n">message_task</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">get_next</span><span class="p">())</span>
<span class="n">outgoing</span> <span class="o">=</span> <span class="n">window</span><span class="o">.</span><span class="n">get_window_to_send</span><span class="p">()</span>
<span class="k">if</span> <span class="n">outgoing</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
Expand All @@ -651,6 +660,8 @@ <h1>Source code for viser.infra._infra</h1><div class="highlight"><pre>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">serialized</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">)</span>
<span class="k">await</span> <span class="n">websocket</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">serialized</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">client_api_version</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="c1"># Clients built for the original viser API didn&#39;t do any windowing of</span>
<span class="c1"># messages.</span>
<span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="n">outgoing</span><span class="p">:</span>
<span class="n">serialized</span> <span class="o">=</span> <span class="n">msgpack</span><span class="o">.</span><span class="n">packb</span><span class="p">(</span><span class="n">msg</span><span class="o">.</span><span class="n">as_serializable_dict</span><span class="p">())</span>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">serialized</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">)</span>
Expand Down
17 changes: 17 additions & 0 deletions _sources/examples/03_gui_callbacks.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ we get updates.
gui_reset_scene = server.add_gui_button("Reset Scene")
gui_plane = server.add_gui_dropdown(
"Grid plane", ("xz", "xy", "yx", "yz", "zx", "zy")
)
def update_plane() -> None:
server.add_grid(
"/grid",
width=10.0,
height=20.0,
width_segments=10,
height_segments=20,
plane=gui_plane.value,
)
gui_plane.on_update(lambda _: update_plane())
with server.add_gui_folder("Control"):
gui_show = server.add_gui_checkbox("Show Frame", initial_value=True)
gui_axis = server.add_gui_dropdown("Axis", ("x", "y", "z"))
Expand Down Expand Up @@ -90,6 +106,7 @@ we get updates.
draw_points()
# Finally, let's add the initial frame + point cloud and just loop infinitely. :)
update_plane()
draw_frame()
draw_points()
while True:
Expand Down
7 changes: 5 additions & 2 deletions _sources/examples/05_camera_commands.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ corresponding client automatically.
T_current_target.log() * j / 19.0
)
# Important bit: we atomically set both the orientation and the position
# of the camera.
# We can atomically set the orientation and the position of the camera
# together to prevent jitter that might happen if one was set before the
# other.
with client.atomic():
client.camera.wxyz = T_world_set.rotation().wxyz
client.camera.position = T_world_set.translation()
client.flush() # Optional!
time.sleep(1.0 / 60.0)
# Mouse interactions should orbit around the frame origin.
Expand Down
1 change: 1 addition & 0 deletions _sources/examples/07_record3d_visualizer.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Parse and stream record3d captures. To get the demo data, see ``./assets/downloa
frame_nodes[current_timestep].visible = True
frame_nodes[prev_timestep].visible = False
prev_timestep = current_timestep
server.flush() # Optional!
# Load in frames.
server.add_frame(
Expand Down
3 changes: 2 additions & 1 deletion _sources/examples/11_colmap_visualizer.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Visualize COLMAP sparse reconstruction outputs. To get demo data, see ``./assets
:linenos:
import random
import time
from pathlib import Path
Expand Down Expand Up @@ -99,7 +100,7 @@ Visualize COLMAP sparse reconstruction outputs. To get demo data, see ``./assets
# Interpret the images and cameras.
img_ids = [im.id for im in images.values()]
onp.random.shuffle(img_ids)
random.shuffle(img_ids)
img_ids = sorted(img_ids[: gui_frames.value])
def attach_callback(
Expand Down
Loading

0 comments on commit 4650557

Please sign in to comment.