basilisk-engine 0.1.12__py3-none-any.whl → 0.1.14__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.

@@ -7,8 +7,10 @@ class RaycastResult:
7
7
  """The node that the raycast hit. Is None if no object was hit"""
8
8
  position: glm.vec3
9
9
  """The node that the raycast hit"""
10
+ normal: glm.vec3
11
+ """The normal of the raycast hit"""
10
12
 
11
- def __init__(self, node: Node | None, position: glm.vec3):
13
+ def __init__(self, node: Node | None, position: glm.vec3, normal: glm.vec3):
12
14
  """
13
15
  Container for returning raycast results.
14
16
  Contains the node hit and the global position the raycast hit at.
@@ -16,9 +18,10 @@ class RaycastResult:
16
18
 
17
19
  self.node = node
18
20
  self.position = position
21
+ self.normal = normal
19
22
 
20
23
  def __bool__(self):
21
24
  return bool(self.node)
22
25
 
23
26
  def __repr__(self):
24
- return f'<Raycast | Node: {self.node}, Position: {self.position}>'
27
+ return f'<Raycast | Node: {self.node}, Position: {self.position}, Normal: {self.normal}>'
basilisk/scene.py CHANGED
@@ -140,14 +140,7 @@ class Scene():
140
140
  if len(returns) == 1: return returns[0]
141
141
  return returns
142
142
 
143
- def set_engine(self, engine: any) -> None:
144
- """
145
- Sets the back references to the engine and creates handlers with the context
146
- """
147
-
148
- self.engine = engine
149
- self.ctx = engine.ctx
150
-
143
+ def init_handlers(self) -> None:
151
144
  self.camera = FreeCamera()
152
145
  self.shader_handler = ShaderHandler(self)
153
146
  self.material_handler = MaterialHandler(self)
@@ -159,6 +152,19 @@ class Scene():
159
152
  self.draw_handler = DrawHandler(self)
160
153
  self.frame = Frame(self)
161
154
  self.sky = Sky(self.engine)
155
+
156
+ def set_engine(self, engine: any) -> None:
157
+ """
158
+ Sets the back references to the engine and creates handlers with the context
159
+ """
160
+
161
+ if not self.engine:
162
+ self.engine = engine
163
+ self.ctx = engine.ctx
164
+ self.init_handlers()
165
+ else:
166
+ self.engine = engine
167
+ self.ctx = engine.ctx
162
168
 
163
169
  def raycast(self, position: glm.vec3=None, forward: glm.vec3=None, max_distance: float=1e5, has_collisions: bool=None, has_physics: bool=None, tags: list[str]=[]) -> RaycastResult:
164
170
  """
@@ -187,7 +193,7 @@ class Scene():
187
193
  else: nodes = self.node_handler.get_all(collisions=has_collisions, physics=has_physics, tags=tags)
188
194
 
189
195
  # determine closest node
190
- best_distance, best_point, best_node = max_distance, None, None
196
+ best_distance, best_point, best_node, best_triangle = max_distance, None, None, None
191
197
  position_two = position + forward
192
198
  for node in nodes:
193
199
 
@@ -206,8 +212,14 @@ class Scene():
206
212
  best_distance = distance
207
213
  best_point = intersection
208
214
  best_node = node
215
+ best_triangle = triangle
216
+
217
+ if not node: return RaycastResult(best_node, best_point, None)
218
+
219
+ points = [best_node.model_matrix * best_node.mesh.points[t] for t in best_triangle]
220
+ normal = glm.normalize(glm.cross(points[1] - points[0], points[2] - points[0]))
209
221
 
210
- return RaycastResult(best_node, best_point)
222
+ return RaycastResult(best_node, best_point, normal)
211
223
 
212
224
  def raycast_mouse(self, position: tuple[int, int] | glm.vec2, max_distance: float=1e5, has_collisions: bool=None, has_pshyics: bool=None, tags: list[str]=[]) -> RaycastResult:
213
225
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: basilisk-engine
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -1,7 +1,7 @@
1
1
  basilisk/__init__.py,sha256=CpYtvSiC9WM0DoTp7N_vsBCPABnVAoh1CDSCZbVJioA,531
2
2
  basilisk/config.py,sha256=Jr4yMuxaSATVX4bjZ0s5J2JW4RaHzUFj1Z6a7P9aEd4,59
3
3
  basilisk/engine.py,sha256=euxonY78_627uKX61C5TslTYCPKSjWKGd-jwEO4OoFc,6706
4
- basilisk/scene.py,sha256=-Bt2KFvli9Oi0V3IAmKNS3zP1ZuGm9iOjAdRdZuGOrQ,11338
4
+ basilisk/scene.py,sha256=Ks4U41ZVTjm4e_Y1Qxdxurj7qrnBRNi4foe5h5p34RM,11872
5
5
  basilisk/audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  basilisk/audio/sound.py,sha256=h2dQ3IKb_SRKNZqNuk-fdNg_Xfz0P7sqEXA33qiBXG4,692
7
7
  basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
@@ -39,7 +39,7 @@ basilisk/generic/matrices.py,sha256=N21nL_B2jsZ2Oxsw9jpY03qIHaElAZcj_hnWs85K0t8,
39
39
  basilisk/generic/meshes.py,sha256=Rijhvr1NWx0HU2WTaROsspWfyd9FZU27sdkpxGl9xvk,2567
40
40
  basilisk/generic/quat.py,sha256=gEqvQvNwx5K7e0zqY0TFTAFtNFSkOatleoP9HQQ-xyk,5102
41
41
  basilisk/generic/quat_methods.py,sha256=SO18ush7pfeGUmncPy4i5nsab1e_zkQkY6zT1bAsSDY,234
42
- basilisk/generic/raycast_result.py,sha256=OJKqNy7s0jPQuWsEcP57ccdcxTfTXl33wzFwqSOobJw,652
42
+ basilisk/generic/raycast_result.py,sha256=waVmS9fYhLoz_G_DU2Mj7896rF0Xy_59JVGALq-kD7g,783
43
43
  basilisk/generic/vec3.py,sha256=AtPSz2S1ZqAm-sZUz4phB09hgFxMIsJnQdU1wmxiOBw,5137
44
44
  basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  basilisk/input/mouse.py,sha256=waXJLIyka4IVe3W2WH5SNNxiOQRouYo3NxafP3fg0qg,1937
@@ -97,7 +97,7 @@ basilisk/shaders/particle.frag,sha256=JXhPDvgd7JDw0-PCZtCOjHTTw2DMeeSaBvTr5fHuIy
97
97
  basilisk/shaders/particle.vert,sha256=bJv3hsWjWYb-g0mgdCV9eH-TVRwpCzhA3wsgSUI3WEM,2943
98
98
  basilisk/shaders/sky.frag,sha256=KG8ablNdaJ5E2Gf1ZpfP3ih252fY8ZNjign_fwjN6V4,169
99
99
  basilisk/shaders/sky.vert,sha256=oAnrknEgsd9MawE_zx8P0u9nUSFEBYBg5ykBmWpqZ_g,332
100
- basilisk_engine-0.1.12.dist-info/METADATA,sha256=X6TE8jZZbMVP2xgzuE_N98pTAIzOYFs4wihKsfg9dbM,1261
101
- basilisk_engine-0.1.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
102
- basilisk_engine-0.1.12.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
103
- basilisk_engine-0.1.12.dist-info/RECORD,,
100
+ basilisk_engine-0.1.14.dist-info/METADATA,sha256=vj28zVboi4GZ-zC_WxHoIi0S7YYbcSWcouIEqCl2JWA,1261
101
+ basilisk_engine-0.1.14.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
102
+ basilisk_engine-0.1.14.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
103
+ basilisk_engine-0.1.14.dist-info/RECORD,,