Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chungmin99 committed Nov 29, 2023
1 parent 646c893 commit d70c6c5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/developer_guides/viewer/viewer_control.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MyModel(nn.Module): # Must inherit from nn.Module
```

## Double-click Callbacks
We forward *double* clicks inside the viewer to the ViewerControl object, which you can use to interact with the scene. To do this, register a callback using `register_click_cb()`. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates.
We forward *single* clicks inside the viewer to the ViewerControl object, which you can use to interact with the scene. To do this, register a callback using `register_click_cb()`. The click is defined to be a ray that starts at the camera origin and passes through the click point on the screen, in world coordinates.

```python
from nerfstudio.viewer.server.viewer_elements import ViewerControl,ViewerClick
Expand All @@ -77,6 +77,16 @@ class MyModel(nn.Module): # must inherit from nn.Module
self.viewer_control.register_click_cb(click_cb)
```

You can also use `unregister_click_cb()` to remove callbacks that are no longer needed. A good example is a "Click on Scene" button, that when pressed, would register a callback that would wait for the next click, and then unregister itself.
```python
...
def button_cb(button: ViewerButton):
def click_cb(click: ViewerClick):
print(f"Click at {click.origin} in direction {click.direction}")
self.viewer_control.unregister_click_cb(click_cb)
self.viewer_control.register_click_cb(click_cb)
```

### Thread safety
Just like `ViewerElement` callbacks, click callbacks are asynchronous to training and can potentially interrupt a call to `get_outputs()`.

0 comments on commit d70c6c5

Please sign in to comment.