1
0

scene_documentation.py 1.2 KB

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. def main_demo() -> None:
  3. with ui.scene(width=285, height=285) as scene:
  4. scene.sphere().material('#4488ff')
  5. scene.cylinder(1, 0.5, 2, 20).material('#ff8800', opacity=0.5).move(-2, 1)
  6. scene.extrusion([[0, 0], [0, 1], [1, 0.5]], 0.1).material('#ff8888').move(-2, -2)
  7. with scene.group().move(z=2):
  8. scene.box().move(x=2)
  9. scene.box().move(y=2).rotate(0.25, 0.5, 0.75)
  10. scene.box(wireframe=True).material('#888888').move(x=2, y=2)
  11. scene.line([-4, 0, 0], [-4, 2, 0]).material('#ff0000')
  12. scene.curve([-4, 0, 0], [-4, -1, 0], [-3, -1, 0], [-3, -2, 0]).material('#008800')
  13. logo = 'https://avatars.githubusercontent.com/u/2843826'
  14. scene.texture(logo, [[[0.5, 2, 0], [2.5, 2, 0]],
  15. [[0.5, 0, 0], [2.5, 0, 0]]]).move(1, -2)
  16. teapot = 'https://upload.wikimedia.org/wikipedia/commons/9/93/Utah_teapot_(solid).stl'
  17. scene.stl(teapot).scale(0.2).move(-3, 4)
  18. scene.text('2D', 'background: rgba(0, 0, 0, 0.2); border-radius: 5px; padding: 5px').move(z=2)
  19. scene.text3d('3D', 'background: rgba(0, 0, 0, 0.2); border-radius: 5px; padding: 5px').move(y=-2).scale(.05)