Skip to content

Commit 98cd50b

Browse files
feat: added toggle atoms button to demo
1 parent 4a31b09 commit 98cd50b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/demo.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from os import path
22

3-
from ursina import DirectionalLight, EditorCamera, Ursina
3+
from ursina import Button, DirectionalLight, EditorCamera, Ursina, Vec2, window
44
from ursina.shaders import lit_with_shadows_shader
55

66
from ursina_proteins.protein import Protein
@@ -17,6 +17,15 @@ def main():
1717
light = DirectionalLight(position=(1000, 1000, 1000))
1818
light.look_at(protein.atoms_entity)
1919

20+
toggle_atoms_button = Button(
21+
text="Toggle atoms visibility",
22+
on_click=lambda: protein.atoms_entity.disable()
23+
if protein.atoms_entity.enabled
24+
else protein.atoms_entity.enable(),
25+
scale=(0.3, 0.05),
26+
position=window.top_left + Vec2(0.16, -0.04),
27+
)
28+
2029
EditorCamera()
2130
app.run()
2231

0 commit comments

Comments
 (0)