-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` | ||
|
||
 | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters