1
0

scene_objects.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from __future__ import annotations
  2. from typing import Optional
  3. from .scene_object3d import Object3D
  4. class Scene(Object3D):
  5. def __init__(self, view):
  6. super().__init__('scene', view)
  7. class Group(Object3D):
  8. def __init__(self):
  9. super().__init__('group')
  10. class Box(Object3D):
  11. def __init__(self,
  12. width: float = 1.0,
  13. height: float = 1.0,
  14. depth: float = 1.0,
  15. wireframe: bool = False,
  16. ):
  17. super().__init__('box', width, height, depth, wireframe)
  18. class Sphere(Object3D):
  19. def __init__(self,
  20. radius: float = 1.0,
  21. width_segments: int = 32,
  22. height_segments: int = 16,
  23. wireframe: bool = False,
  24. ):
  25. super().__init__('sphere', radius, width_segments, height_segments, wireframe)
  26. class Cylinder(Object3D):
  27. def __init__(self,
  28. top_radius: float = 1.0,
  29. bottom_radius: float = 1.0,
  30. height: float = 1.0,
  31. radial_segments: int = 8,
  32. height_segments: int = 1,
  33. wireframe: bool = False,
  34. ):
  35. super().__init__('cylinder', top_radius, bottom_radius, height, radial_segments, height_segments, wireframe)
  36. class Extrusion(Object3D):
  37. def __init__(self,
  38. outline: list[list[float, float]],
  39. height: float,
  40. wireframe: bool = False,
  41. ):
  42. super().__init__('extrusion', outline, height, wireframe)
  43. class Stl(Object3D):
  44. def __init__(self,
  45. url: str,
  46. wireframe: bool = False,
  47. ):
  48. super().__init__('stl', url, wireframe)
  49. class Line(Object3D):
  50. def __init__(self,
  51. start: list[float, float, float],
  52. end: list[float, float, float],
  53. ):
  54. super().__init__('line', start, end)
  55. class Curve(Object3D):
  56. def __init__(self,
  57. start: list[float, float, float],
  58. control1: list[float, float, float],
  59. control2: list[float, float, float],
  60. end: list[float, float, float],
  61. num_points: int = 20,
  62. ):
  63. super().__init__('curve', start, control1, control2, end, num_points)
  64. class Texture(Object3D):
  65. def __init__(self,
  66. url: str,
  67. coordinates: list[list[Optional[list[float]]]],
  68. ):
  69. super().__init__('texture', url, coordinates)