Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Apr 9, 2024
1 parent 99ae365 commit 721c936
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 62 deletions.
2 changes: 1 addition & 1 deletion docs/animations.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ cube rotate faster:
```

You could decouple the rotation from the frame rate by incrementing the rotation
depending no how much time has passed since the last call.
depending on how much time has passed since the last call.
4 changes: 2 additions & 2 deletions docs/controls.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Controlling the Viewer

In [The Basics](intro.md), you already learned how to open a new
[`octarine.Viewer`][] and add a simple mesh.
[`octarine.Viewer`][] and add a simple mesh, and [Managing Objects](manage.md)
showed you how to inspect and access objects on the viewer.

Here we will demonstrate various ways to programmatically control the viewer.

Expand Down Expand Up @@ -100,7 +101,6 @@ To activate them you can either press the `c` hotkey or:

>>> #... or do this afterwards
>>> v.show_controls()

```

<center><img src="https://schlegelp.github.io/octarine/_static/jupyter_toolbar.png" alt="jupyter toolbar" width="75%"/></center>
54 changes: 54 additions & 0 deletions docs/manage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Managing objects

As you add objects to the [octarine.Viewer][], you might want to keep track of
them so you can e.g. colorize or remove them at a later point.

Unless specified, each object gets a generic identifier:

```python
>>> duck = tm.load_remote(
... 'https://github.com/mikedh/trimesh/raw/main/models/Duck.glb'
... )

>>> # Add the duck
>>> v.add_mesh(duck)
```

![bunny example](_static/duck_example.png)

Let's check what objects are there:

```python
>>> v.objects
OrderedDict([('Object', [<pygfx.Mesh at 0x37f4f8b90>])])
```

The `.objects` property will return a dictionary mapping IDs to `pygfx` visuals.

Alternatively, you can also do this:

```python
>>> v['Object']
[<pygfx.Mesh at 0x37f4f8b90>]
```

Instead of generic IDs, we can also explicitly set the ID:

```python
>>> v.add_mesh(duck, name='Duck')
>>> v.objects
OrderedDict([('Duck', [<pygfx.Mesh at 0x37f5f8a12>])])
```

This can also be used to combine multiple objects under the same ID.

Why are these IDs relevant? Well, they help you manipulate objects after
they've been added:

```python
>>> v.set_colors({'Duck': 'w'})
>>> v.hide_objects('Duck')
>>> v.remove_objects('Duck')
```

Check out [Viewer Controls](controls.md) for details on how to manipulate objects.
66 changes: 7 additions & 59 deletions docs/objects.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Adding Objects to the Viewer

Off the bat `Octarine` supports four types of objects all of
Off the bat `Octarine` supports 4 types of objects, all of
which have dedicated `Viewer` methods:

| | Type | Viewer method |
|---|---------------|--------------------------------|
| 1.| Meshes | [octarine.Viewer.add_mesh][] |
| 2.| Points | [octarine.Viewer.add_points][] |
| 3.| Lines | [octarine.Viewer.add_lines][] |
| 4.| Image Volumes | [octarine.Viewer.add_volume][] |
| | Object Type | Viewer method |
|---|-----------------------------------|--------------------------------|
| 1.| [Meshes](#meshes) | [octarine.Viewer.add_mesh][] |
| 2.| [Points](#points) | [octarine.Viewer.add_points][] |
| 3.| [Lines](#lines) | [octarine.Viewer.add_lines][] |
| 4.| [Image Volumes](#image-volumes) | [octarine.Viewer.add_volume][] |

As a general entry point you can use the [octarine.Viewer.add][]`()` method
which will pass an object to the respective specialized function:
Expand Down Expand Up @@ -106,58 +106,6 @@ array([[0.38, 0. , 0. ],
![brain volume](_static/brain_volume_example.png)


## Managing objects

As you add objects to the [octarine.Viewer][], you might want to keep track of
them so you can e.g. colorize or remove them.

Unless specified, each object gets a generic identifier:

```python
>>> duck = tm.load_remote(
... 'https://github.com/mikedh/trimesh/raw/main/models/Duck.glb'
... )

>>> # Add the duck
>>> v.add_mesh(duck)
```

![bunny example](_static/duck_example.png)

Let's check what objects are there:

```python
>>> v.objects
OrderedDict([('Object', [<pygfx.Mesh at 0x37f4f8b90>])])
```

The `.objects` property will return a dictionary mapping IDs to `pygfx` visuals.

Alternatively, you can also do this:

```python
>>> v['Object']
[<pygfx.Mesh at 0x37f4f8b90>]
```

Instead of generic IDs, we can also explicitly set the ID:

```python
>>> v.add_mesh(duck, name='Duck')
>>> v.objects
OrderedDict([('Duck', [<pygfx.Mesh at 0x37f5f8a12>])])
```

This can also be used to combine multiple objects under the same ID.

Why are these IDs relevant? Well, they help you manipulate objects after
they've been added:

```
>>> v.set_colors({'Duck': 'w'})
>>> v.hide_objects('Duck')
```

## Custom Objects

What if you have want to visualize something not currently supported
Expand Down
9 changes: 9 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ code.highlight span.n:not(:first-child) {
color: #666;
}

/* Set True/False */
.highlight span.kc {
color: #548fed;
}
/* Set parentheses color */
.highlight span.p {
color: #dfd58b;
}

/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ nav:
- "Installation": install.md
- "The Basics": intro.md
- "Adding Objects": objects.md
- "Managing Objects": manage.md
- "Extending Octarine": extending.md
- "Viewer Controls": controls.md
- "Animations": animations.md
Expand Down

0 comments on commit 721c936

Please sign in to comment.