basilisk-engine 0.1.22__py3-none-any.whl → 0.1.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of basilisk-engine might be problematic. Click here for more details.

basilisk/scene.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import moderngl as mgl
2
2
  import glm
3
+ import pygame as pg
3
4
 
4
5
  from .mesh.mesh import Mesh
5
6
  from .render.material import Material
@@ -10,7 +11,6 @@ from .render.camera import Camera, FreeCamera
10
11
  from .nodes.node_handler import NodeHandler
11
12
  from .physics.physics_engine import PhysicsEngine
12
13
  from .collisions.collider_handler import ColliderHandler
13
- from .draw.draw_handler import DrawHandler
14
14
  from .render.sky import Sky
15
15
  from .render.frame import Frame
16
16
  from .particles.particle_handler import ParticleHandler
@@ -21,40 +21,56 @@ from .render.post_process import PostProcess
21
21
  from .render.framebuffer import Framebuffer
22
22
 
23
23
  class Scene():
24
- engine: any
24
+ engine: ...=None
25
25
  """Parent engine of the scene"""
26
26
  ctx: mgl.Context
27
27
  """Reference to the engine context"""
28
+ camera: Camera=None
29
+ """"""
30
+ light_handler: LightHandler=None
31
+ """"""
32
+ physics_engine: PhysicsEngine=None
33
+ """"""
34
+ node_handler: NodeHandler=None
35
+ """"""
28
36
 
29
- def __init__(self) -> None:
37
+ def __init__(self, engine: ...) -> None:
30
38
  """
31
39
  Basilisk scene object. Contains all nodes for the scene
32
40
  """
33
41
 
34
- self.engine = None
35
- self.ctx = None
42
+ self.engine = engine
43
+ self.ctx = engine.ctx
44
+ self.camera = FreeCamera()
45
+ self.light_handler = LightHandler(self)
46
+ self.physics_engine = PhysicsEngine()
47
+ self.node_handler = NodeHandler(self)
48
+ self.particle = ParticleHandler(self)
49
+ self.collider_handler = ColliderHandler(self)
50
+ self.sky = Sky(self.engine)
36
51
 
37
- self.camera = None
38
- self.shader_handler = None
39
- self.node_handler = None
40
- self.material_handler = None
41
- self.light_handler = None
42
- self.draw_handler = None
43
- self.sky = None
44
- self.frame = None
45
52
 
46
- def update(self) -> None:
53
+ def update(self, render: bool=True, nodes: bool=True, particles: bool=True, collisions: bool=True) -> None:
47
54
  """
48
55
  Updates the physics and in the scene
49
56
  """
50
- self.particle.update()
51
- self.camera.update()
52
57
 
58
+ # Check that the engine is still running
59
+ self.engine._update()
60
+ if not self.engine.running: return
61
+
62
+ # Update based on the given parameters
63
+ if nodes: self.node_handler.update()
64
+ if particles: self.particle.update()
65
+ if self.engine.event_resize: self.camera.use()
66
+ self.camera.update()
53
67
 
54
- self.node_handler.update()
55
- if self.engine.delta_time < 0.5: # TODO this will cause physics to slow down when on low frame rate, this is probabl;y acceptable
68
+ if collisions and self.engine.delta_time < 0.5: # TODO this will cause physics to slow down when on low frame rate, this is probabl;y acceptable
56
69
  self.collider_handler.resolve_collisions()
57
70
 
71
+ # Render by default to the engine frame
72
+ if render: self.render()
73
+
58
74
  def render(self, render_target: Framebuffer|Frame=None) -> None:
59
75
  """
60
76
  Renders all the nodes with meshes in the scene
@@ -63,19 +79,19 @@ class Scene():
63
79
  if render_target:
64
80
  show = False
65
81
  else:
66
- render_target = self.frame
82
+ render_target = self.engine.frame
67
83
  show = True
68
84
 
69
85
  render_target.use()
70
- render_target.clear()
71
- self.shader_handler.write()
86
+ self.engine.shader_handler.write(self)
72
87
  if self.sky: self.sky.render()
73
88
  self.node_handler.render()
74
89
  self.particle.render()
75
- self.draw_handler.render()
90
+
76
91
 
77
92
  if self.engine.headless or not show: return
78
- self.frame.render()
93
+
94
+
79
95
 
80
96
  def add(self, *objects: Node | None) -> None | Node | list:
81
97
  """
@@ -100,7 +116,7 @@ class Scene():
100
116
 
101
117
  # Add a node to the scene
102
118
  elif isinstance(bsk_object, PostProcess):
103
- returns.append(self.frame.add_post_process(bsk_object)); continue
119
+ returns.append(self.engine.frame.add_post_process(bsk_object)); continue
104
120
 
105
121
 
106
122
  # Recived incompatable type
@@ -140,19 +156,6 @@ class Scene():
140
156
  if len(returns) == 1: return returns[0]
141
157
  return returns
142
158
 
143
- def init_handlers(self) -> None:
144
- self.camera = FreeCamera()
145
- self.shader_handler = ShaderHandler(self)
146
- self.material_handler = MaterialHandler(self)
147
- self.light_handler = LightHandler(self)
148
- self.physics_engine = PhysicsEngine()
149
- self.node_handler = NodeHandler(self)
150
- self.particle = ParticleHandler(self)
151
- self.collider_handler = ColliderHandler(self)
152
- self.draw_handler = DrawHandler(self)
153
- self.frame = Frame(self)
154
- self.sky = Sky(self.engine)
155
-
156
159
  def set_engine(self, engine: any) -> None:
157
160
  """
158
161
  Sets the back references to the engine and creates handlers with the context
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: basilisk-engine
3
- Version: 0.1.22
3
+ Version: 0.1.24
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -1,7 +1,7 @@
1
- basilisk/__init__.py,sha256=nltSEm5HK3aeg1VSkYBEBGLj7DcFzUwt4yZUmEJQ8EM,602
2
- basilisk/config.py,sha256=ynTRlX633DGoEtZOeAK8KNJF6offV3k3XFD7cia3Keg,61
3
- basilisk/engine.py,sha256=qfyUk_o0gVrVc-3sCp2qbBNCEx0MsfHI5VbTAVZ9PsE,7441
4
- basilisk/scene.py,sha256=sa8UIV1MH-4OEmlc4geaSHBmzSPRNFS8g5MsO-XjwNA,12153
1
+ basilisk/__init__.py,sha256=gP1qcygI7m5Re8MlZZfNuBJK_uHu_CxhA6refXVN7nU,615
2
+ basilisk/config.py,sha256=ipG9uxCd7lcyRIzS6O9PbyINmo8h8Whj_j9ZmpU1wv4,112
3
+ basilisk/engine.py,sha256=eSt72slr2Xt6Bg4lUpqETk0E7ymmVhocigSExOjkrQY,5989
4
+ basilisk/scene.py,sha256=7u1scIJbQVxO0LWFXzKMGai-CtAgaSy8gVi-dWtJOlU,12167
5
5
  basilisk/audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  basilisk/audio/sound.py,sha256=BjqaPv_07iD_-NDRy1cc0TS4PJzAnQc4hfsW9ntNjGQ,719
7
7
  basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
@@ -26,8 +26,8 @@ basilisk/collisions/narrow/helper.py,sha256=aUdLdHkbAimnMnh_TWIanCTOJi2ZTY-cXLMh
26
26
  basilisk/collisions/narrow/line_intersections.py,sha256=CGtttZ6n51u4l8JtQXzkClgZ_uvgx9IyrrGqli6JDbI,4629
27
27
  basilisk/collisions/narrow/sutherland_hodgman.py,sha256=SUjSU5y7AuzIDiljMcTXxlGuFHT5IwtrOJ_k5HS1S2Y,3140
28
28
  basilisk/draw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- basilisk/draw/draw.py,sha256=rNmHLhLpPZ2IkT5kx4yE265Q41Db_7GiazY5LdLvlek,3656
30
- basilisk/draw/draw_handler.py,sha256=MwUOMSXgo7Hf8UX4GbEjh0HRtf8w7XN9QsAgDfksNH4,6394
29
+ basilisk/draw/draw.py,sha256=j6vMAww5RqU_4VM4UcgxXl7FASBPbxy1Dqr-2eLx2pY,3620
30
+ basilisk/draw/draw_handler.py,sha256=O8PXvyDigDv_GBHARzLl7nbuu-gS18WP2-8vrg3a0Ds,6246
31
31
  basilisk/draw/font_renderer.py,sha256=gyI59fW3DUswIcSg5VJLLcJti3OLTMdXNQrYJaw18dE,1092
32
32
  basilisk/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  basilisk/generic/abstract_bvh.py,sha256=iQ6HjcI8Msw34dZ3YuDAhWSqEc4NTBHAaGqAZZAoLL8,383
@@ -41,9 +41,12 @@ basilisk/generic/quat.py,sha256=4uVMo_ZyB9a0yX89JCKrLUb7pqu2DbLn1cNByGb9Z-k,5244
41
41
  basilisk/generic/quat_methods.py,sha256=FFqS2Iy1OLH6oJf1elhH9RbWiE_KMXe5eO95ayrEhbc,241
42
42
  basilisk/generic/raycast_result.py,sha256=S0eRDWk8Qi0AW1xkqp9PzFJRUD8iJ365SOaldWi9xU4,809
43
43
  basilisk/generic/vec3.py,sha256=n_OAVVFtzH-ctqU8Pqhs2426MQ0WOgBbq2Lfo3Nt498,5280
44
- basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- basilisk/input/mouse.py,sha256=K2An-VI3r3VZLEx9bChKp2U2jHfSdxrvHtmyBu4yzCE,1998
46
- basilisk/input/path.py,sha256=GiO1OS1UGujnl3KdIB7fGzI5BgIg7RHyI8LxsGWskcs,455
44
+ basilisk/input_output/IO_handler.py,sha256=jlBQTu7TlDICKcauJrTDtGrdY_U4yJUYSFu2WFGh6ys,2913
45
+ basilisk/input_output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ basilisk/input_output/clock.py,sha256=cFnWDBItD5pWw3Gu1xld771hYpYR_G6Z53DvJiZj5jg,1511
47
+ basilisk/input_output/keys.py,sha256=hTZqrR4EVLOXLq093yBBqBbpJJoasQV85BuBG5eW5aw,1411
48
+ basilisk/input_output/mouse.py,sha256=ZuSd7JJ1TBER3x_r6h8owsXV616eWbRwGl5h1FpbJOE,2988
49
+ basilisk/input_output/path.py,sha256=GiO1OS1UGujnl3KdIB7fGzI5BgIg7RHyI8LxsGWskcs,455
47
50
  basilisk/mesh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
51
  basilisk/mesh/cube.py,sha256=UAwjEmaoWfUdtSKjxATU6vUbksDYj7_bBIr1k1xDsYc,1077
49
52
  basilisk/mesh/mesh.py,sha256=vujJ0VxwCvvIKBAScPzo8nWWAouyRzE97M4-JVpqco0,9782
@@ -54,32 +57,32 @@ basilisk/mesh/narrow_bvh.py,sha256=jLQhmUNi6mFyU2wVwB_SOf4PIaOAygBTtcnQIyaMOGg,4
54
57
  basilisk/mesh/narrow_primative.py,sha256=vWpIeo8I9le-EAvcr9rFUQlbl9mi6eYroqCSMK-m9eY,953
55
58
  basilisk/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
59
  basilisk/nodes/helper.py,sha256=VdlGuEaMtLa992_8yNOB-QIgz4Izr5wNMSm8H6KftKE,2097
57
- basilisk/nodes/node.py,sha256=M8VWCuAM7JSpIloH8QSwwidrw4xCHibyswrhwObPyKY,32573
58
- basilisk/nodes/node_handler.py,sha256=Bz9sf3VwYd68fY8LyR6j0H52-ZjZ8fe-_gBEuhE6T5A,4164
60
+ basilisk/nodes/node.py,sha256=yC5eDkLa-fXyX2oBd4VpSTdW3sGbpLs8bm7j95q-p9U,32637
61
+ basilisk/nodes/node_handler.py,sha256=V8OYMuI7WkULuoprE8_mN2bCrkml_no8fJN2sNcXPGQ,4203
59
62
  basilisk/particles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
- basilisk/particles/particle_handler.py,sha256=R3FC7XWUSvQV1gMtJku68kYl_jyhez9kg54lIk5nEKM,2985
61
- basilisk/particles/particle_renderer.py,sha256=bRbeaEv3ZZu3c4f9lFXRhWHpnsdZri3J-KS-77R_v7o,3785
63
+ basilisk/particles/particle_handler.py,sha256=fFvvwtT-dw-Tst7Y6xLyjl2ljiP9u6T0ccNPZo3xy-8,2992
64
+ basilisk/particles/particle_renderer.py,sha256=PEJ5qKCEPbPG__NSQcv2NKjTHtKviK5LqfCJS1vDbP8,3792
62
65
  basilisk/physics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
66
  basilisk/physics/impulse.py,sha256=zv6MoGTSlu8qVbsbe2QxERGeyQZYbtzR_WVSqVLsmhw,5873
64
67
  basilisk/physics/physics_body.py,sha256=_mi-AVMgQqUsC3bQIca5tgk2xWXTIUw0D_uC4DcQqqs,1508
65
68
  basilisk/physics/physics_engine.py,sha256=IPMshr4j5TII5JdcRqiULc6BfkeCLPxdICKqQeZGAtY,1735
66
69
  basilisk/render/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
70
  basilisk/render/batch.py,sha256=VvcKXNmiPxdQ92jzoARPGhLujUGomm6nQX7f7rkoyAQ,3775
68
- basilisk/render/camera.py,sha256=V9LU0-MMhGPnbYa65wUCeOFLmEJDoZfV5sbMjkJcb5o,8046
71
+ basilisk/render/camera.py,sha256=EaIQ2pKFSN6K51JcRzJhXO4ck_7tQrbTKc8i8tImoy4,9668
69
72
  basilisk/render/chunk.py,sha256=R6Jlugxisnl_jkxp0KYkwTt9lzmz-IFCOgdSqGMBf1c,2824
70
73
  basilisk/render/chunk_handler.py,sha256=KY-AqnydAc4ae2yKUsLrjs1GdvjoGdZbyXmSSnTtOFY,6497
71
- basilisk/render/frame.py,sha256=cYeuEAyiMwXUQZgHfNPGEH43zZfrmNXyOpCjxtz2Ji8,3292
72
- basilisk/render/framebuffer.py,sha256=wuYKIzKxkzuYnCxo2ufIdN8FceoZcb4pgVB0Xz6LGO8,4430
74
+ basilisk/render/frame.py,sha256=DPZhjuhyamREGN1yhl2__9bEyeVbX91i_zXilEFp1yc,3012
75
+ basilisk/render/framebuffer.py,sha256=7Fl31Ww8MRysHvUpHCJ7qG-92po981r8xJRUfDKITik,10173
73
76
  basilisk/render/image.py,sha256=p7bSFbD_Nv5TeiVCEdQ_X84Nfrs1YuwqJKKNzrgGkkM,2960
74
- basilisk/render/image_handler.py,sha256=6limLZvLznUK_l1UdEBsQ3XEPnnrCLzmBzSyifbV81M,4351
77
+ basilisk/render/image_handler.py,sha256=CJyel7POIserAoLQ8YCc3SY24zia2ry6P3wMNK0-Vms,4295
75
78
  basilisk/render/light.py,sha256=hFqODv9iK4GEDZeDyBHxOWwwd4v8Pm089_xoScBMjVY,3879
76
- basilisk/render/light_handler.py,sha256=Le5InqqjgglSXUu7MwkVVsb7WbNJeRkRKldYDQGr6kg,2161
79
+ basilisk/render/light_handler.py,sha256=baJ1p0ob_5OK2Dyd5zZYcldAGWUyVlF21dp_Yfopyd8,2162
77
80
  basilisk/render/material.py,sha256=JmmwCxSYkPLHw73bH-7SzPo5ewzbU3QPTIvI_2pInXQ,9655
78
- basilisk/render/material_handler.py,sha256=dbfQs0u7qkEan0e0FsnqPpxbmkSNAQmH2B9jv4vx-bs,4242
81
+ basilisk/render/material_handler.py,sha256=o-OlDCMj0ZbRF5b-a9u6O5pDKMV0f-dsfURUC5RbwAk,4114
79
82
  basilisk/render/post_process.py,sha256=w71zgvnc1VyQAK7xTAyEe1FsUBDzch_6TrkhxZ27MgA,5098
80
- basilisk/render/shader.py,sha256=C4LtkAqC_QE1I9ftiFBTsCNM9uv811gOAyriXuqGRKk,3988
81
- basilisk/render/shader_handler.py,sha256=G3cQ_tTIC_GUa68MP_l_VycMxqfZq2IyZqJQeipmUZk,2579
82
- basilisk/render/sky.py,sha256=TwLJ_6dYWCOAb06HZocrRdBzlbR6mQ0ojmmJgCC6im4,4910
83
+ basilisk/render/shader.py,sha256=sXxtACU9c8i3f6y2RZPF1NZXYJGrfrA0HEyl1AZSv_U,3913
84
+ basilisk/render/shader_handler.py,sha256=bSthLrbDpd7xWxdqku5XkAmULf1a28DAQRFlDlTMUTU,2821
85
+ basilisk/render/sky.py,sha256=tu4ldzQpGjhS8SgooGo9lQZFNbog6-M43ju7vV95iE8,4888
83
86
  basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
87
  basilisk/shaders/batch.frag,sha256=658z5GLegHDarroeqUpoiWDCCT2FHMr0ZHnYJ21qMhQ,9339
85
88
  basilisk/shaders/batch.vert,sha256=nUZKd5uBTFJm1aOG0auQRxE2ElhcAGf1YmepyzWeG8g,5403
@@ -97,7 +100,7 @@ basilisk/shaders/particle.frag,sha256=Cv8cWQpVVQvhZeWj3NqL0D5nLtSO3EWV0VzOU-ZVL4
97
100
  basilisk/shaders/particle.vert,sha256=ElXzT7ywiZ0SjrFcUistVDBi4wOobQ7_J5O7XVxrsVs,3027
98
101
  basilisk/shaders/sky.frag,sha256=vTmZ1Xsd601_gmeBRfLYodHuBoBDI-M_1IybRt0ZDFk,178
99
102
  basilisk/shaders/sky.vert,sha256=v_BSdnMiljSJGPqno-J_apAiom38IrBzbDoxM7pIgwI,345
100
- basilisk_engine-0.1.22.dist-info/METADATA,sha256=dCFBegbwaCFFRnZnUwmFQq-pK6sgZ3buKRDtLziFL5k,1147
101
- basilisk_engine-0.1.22.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
102
- basilisk_engine-0.1.22.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
103
- basilisk_engine-0.1.22.dist-info/RECORD,,
103
+ basilisk_engine-0.1.24.dist-info/METADATA,sha256=vJFy9ubTtVw-jeX3Mci3SZvbBIuctfQOfIx_U4GkwEk,1147
104
+ basilisk_engine-0.1.24.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
105
+ basilisk_engine-0.1.24.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
106
+ basilisk_engine-0.1.24.dist-info/RECORD,,
basilisk/input/mouse.py DELETED
@@ -1,62 +0,0 @@
1
- import pygame as pg
2
-
3
-
4
- class Mouse():
5
- def __init__(self, grab=True):
6
- self.x, self.y = pg.mouse.get_pos()
7
- self.buttons = pg.mouse.get_pressed()
8
- self.previous_buttons = pg.mouse.get_pressed()
9
- self.grab = grab
10
-
11
- def update(self, events):
12
- """
13
- Updates all mouse state variables.
14
- Checks for mouse-related events.
15
- """
16
-
17
- self.x, self.y = pg.mouse.get_pos()
18
- self.previous_buttons = self.buttons
19
- self.buttons = pg.mouse.get_pressed()
20
-
21
- for event in events:
22
- if event.type == pg.KEYUP:
23
- if event.key == pg.K_ESCAPE and self.grab:
24
- # Unlock mouse
25
- pg.event.set_grab(False)
26
- pg.mouse.set_visible(True)
27
- if event.type == pg.MOUSEBUTTONUP and self.grab:
28
- # Lock mouse
29
- pg.event.set_grab(True)
30
- pg.mouse.set_visible(False)
31
-
32
- def set_pos(self, x, y):
33
- """Set the mouse position"""
34
- pg.mouse.set_pos(x, y)
35
-
36
- @property
37
- def click(self): return self.buttons[0] and not self.previous_buttons[0]
38
- @property
39
- def left_click(self): return self.buttons[0] and not self.previous_buttons[0]
40
- @property
41
- def middle_click(self): return self.buttons[1] and not self.previous_buttons[1]
42
- @property
43
- def right_click(self): return self.buttons[2] and not self.previous_buttons[2]
44
- @property
45
- def left_down(self): return self.buttons[0]
46
- @property
47
- def middle_down(self): return self.buttons[1]
48
- @property
49
- def right_down(self): return self.buttons[2]
50
-
51
- @property
52
- def grab(self): return self._grab
53
-
54
- @grab.setter
55
- def grab(self, value):
56
- self._grab = value
57
- if self._grab:
58
- pg.event.set_grab(True)
59
- pg.mouse.set_visible(False)
60
- else:
61
- pg.event.set_grab(False)
62
- pg.mouse.set_visible(True)
File without changes
File without changes