Skip to content

Commit

Permalink
deploy: 967d646
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Sep 7, 2023
1 parent 2d5872f commit 874c2f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
2 changes: 1 addition & 1 deletion _modules/viser/_scene_handles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ <h1>Source code for viser._scene_handles</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="n">visible</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
<span class="c1"># TODO: we should remove SceneNodeHandle as an argument here.</span>
<span class="n">click_cb</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">Callable</span><span class="p">[[</span><span class="n">SceneNodeHandle</span><span class="p">],</span> <span class="kc">None</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">click_cb</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">Callable</span><span class="p">[[</span><span class="n">ClickEvent</span><span class="p">[</span><span class="n">SceneNodeHandle</span><span class="p">]],</span> <span class="kc">None</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span>


<div class="viewcode-block" id="SceneNodeHandle"><a class="viewcode-back" href="../../../scene_handles/#viser.SceneNodeHandle">[docs]</a><span class="nd">@dataclasses</span><span class="o">.</span><span class="n">dataclass</span>
Expand Down
33 changes: 22 additions & 11 deletions _modules/viser/_viser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,30 @@ <h1>Source code for viser._viser</h1><div class="highlight"><pre>
<span class="c1"># - https://github.com/python/mypy/pull/11643</span>
<span class="nd">@wxyz</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">wxyz</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">wxyz</span><span class="p">:</span> <span class="n">Tuple</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">float</span><span class="p">]</span> <span class="o">|</span> <span class="n">onp</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">R_world_camera</span> <span class="o">=</span> <span class="n">tf</span><span class="o">.</span><span class="n">SO3</span><span class="p">(</span><span class="n">onp</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">wxyz</span><span class="p">))</span>
<span class="n">look_at</span> <span class="o">=</span> <span class="n">onp</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[</span>
<span class="mf">0.0</span><span class="p">,</span>
<span class="mf">0.0</span><span class="p">,</span>
<span class="n">onp</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">look_at</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">position</span><span class="p">),</span>
<span class="p">]</span>
<span class="n">R_world_camera</span> <span class="o">=</span> <span class="n">tf</span><span class="o">.</span><span class="n">SO3</span><span class="p">(</span><span class="n">onp</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">wxyz</span><span class="p">))</span><span class="o">.</span><span class="n">as_matrix</span><span class="p">()</span>
<span class="n">look_distance</span> <span class="o">=</span> <span class="n">onp</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">look_at</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">position</span><span class="p">)</span>

<span class="c1"># We&#39;re following OpenCV conventions: look_direction is +Z, up_direction is -Y,</span>
<span class="c1"># right_direction is +X.</span>
<span class="n">look_direction</span> <span class="o">=</span> <span class="n">R_world_camera</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">]</span>
<span class="n">up_direction</span> <span class="o">=</span> <span class="o">-</span><span class="n">R_world_camera</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span>
<span class="n">right_direction</span> <span class="o">=</span> <span class="n">R_world_camera</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">]</span>

<span class="c1"># Minimize our impact on the orbit controls by keeping the new up direction as</span>
<span class="c1"># close to the old one as possible.</span>
<span class="n">projected_up_direction</span> <span class="o">=</span> <span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">up_direction</span>
<span class="o">-</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">up_direction</span> <span class="o">@</span> <span class="n">right_direction</span><span class="p">)</span> <span class="o">*</span> <span class="n">right_direction</span>
<span class="p">)</span>
<span class="n">new_look_at</span> <span class="o">=</span> <span class="p">(</span><span class="n">R_world_camera</span> <span class="o">@</span> <span class="n">look_at</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">position</span>
<span class="bp">self</span><span class="o">.</span><span class="n">look_at</span> <span class="o">=</span> <span class="n">new_look_at</span>
<span class="n">up_cosine</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">up_direction</span> <span class="o">@</span> <span class="n">projected_up_direction</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">up_cosine</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mf">0.05</span><span class="p">:</span>
<span class="n">projected_up_direction</span> <span class="o">=</span> <span class="n">up_direction</span>
<span class="k">elif</span> <span class="n">up_cosine</span> <span class="o">&lt;</span> <span class="mf">0.0</span><span class="p">:</span>
<span class="n">projected_up_direction</span> <span class="o">=</span> <span class="n">up_direction</span>

<span class="n">up_direction</span> <span class="o">=</span> <span class="n">R_world_camera</span> <span class="o">@</span> <span class="n">onp</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">up_direction</span> <span class="o">=</span> <span class="n">up_direction</span>
<span class="n">new_look_at</span> <span class="o">=</span> <span class="n">look_direction</span> <span class="o">*</span> <span class="n">look_distance</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">position</span>
<span class="bp">self</span><span class="o">.</span><span class="n">look_at</span> <span class="o">=</span> <span class="n">new_look_at</span>
<span class="bp">self</span><span class="o">.</span><span class="n">up_direction</span> <span class="o">=</span> <span class="n">projected_up_direction</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_state</span><span class="o">.</span><span class="n">wxyz</span> <span class="o">=</span> <span class="n">onp</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">wxyz</span><span class="p">)</span>

<span class="nd">@property</span>
Expand Down

0 comments on commit 874c2f5

Please sign in to comment.