basilisk-engine 0.1.50__py3-none-any.whl → 0.1.52__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/__init__.py CHANGED
@@ -15,6 +15,7 @@ from .particles.particle_handler import ParticleHandler
15
15
  from .render.framebuffer import Framebuffer
16
16
  from .audio.sound import Sound
17
17
 
18
+
18
19
  # expose internal algorithms
19
20
  from .collisions.narrow.epa import get_epa_from_gjk
20
21
  from .collisions.narrow.gjk import collide_gjk
basilisk/audio/sound.py CHANGED
@@ -11,18 +11,31 @@ class Sound:
11
11
  raise ValueError(f'bsk.Sound: Invalid source path type {type(path)}. Expected string or os.PathLike')
12
12
 
13
13
  self.source = pg.mixer.Sound(path)
14
+ self.volume = 100
14
15
 
15
- def play(self, volume: float=1.0):
16
+ def play(self, fade: float=0.0):
16
17
  """
17
- Play the sound at the given volume level. Full volume if none given
18
+ Play the sound at the given volume level. Fades in over `fade` seconds
18
19
  """
19
20
 
20
- self.source.set_volume(volume)
21
- self.source.play()
21
+ self.source.play(fade_ms=int(fade * 1000))
22
22
 
23
- def stop(self):
23
+ def stop(self, fade: float=0.0):
24
24
  """
25
- Stops the sound
25
+ Stops the sound. Fades out over `fade` seconds
26
26
  """
27
27
 
28
- self.source.stop()
28
+ self.source.fadeout(int(fade * 1000))
29
+
30
+ @property
31
+ def volume(self) -> float:
32
+ return self._volume
33
+
34
+ @volume.setter
35
+ def volume(self, value: int) -> None:
36
+ """
37
+ Sets the volume of the music. Int from [0, 100]
38
+ """
39
+
40
+ self._volume = min(max(value, 0), 100)
41
+ self.source.set_volume(self._volume / 100)
@@ -95,4 +95,13 @@ class NodeHandler():
95
95
  self.nodes.remove(node)
96
96
  node.node_handler = None
97
97
 
98
- for child in node.children: self.remove(child)
98
+ for child in node.children: self.remove(child)
99
+
100
+ def clear(self) -> None:
101
+ """
102
+ Removes all nodes from the scene
103
+ TODO: this is prolly not the optimal solution lmao
104
+ """
105
+
106
+ while self.nodes:
107
+ self.remove(self.nodes[0])
@@ -61,5 +61,9 @@ class ParticleHandler:
61
61
 
62
62
  def render(self) -> None:
63
63
  for renderer in self.particle_renderers.values(): renderer.render()
64
+
64
65
  def update(self) -> None:
65
- for renderer in self.particle_renderers.values(): renderer.update()
66
+ for renderer in self.particle_renderers.values(): renderer.update()
67
+
68
+ def clear(self) -> None:
69
+ self.particle_renderers.clear()
@@ -9,7 +9,7 @@ from numba import njit
9
9
  def update_particle_matrix(particle_instances, dt):
10
10
  particle_instances[:,6:9] += particle_instances[:,9:12] * dt
11
11
  particle_instances[:,:3] += particle_instances[:,6:9] * dt
12
- particle_instances[:,5] -= dt/3
12
+ particle_instances[:,5] -= dt
13
13
  return particle_instances
14
14
 
15
15
  @njit
@@ -88,7 +88,6 @@ class ParticleRenderer:
88
88
  new_particle = np.array([*position, material, scale, life, *velocity, *acceleration])
89
89
  self.particle_instances = np.vstack([new_particle, self.particle_instances], dtype='f4')
90
90
 
91
-
92
91
  def __del__(self):
93
92
  self.instance_buffer.release()
94
93
  self.vao.release()
basilisk/scene.py CHANGED
@@ -159,6 +159,10 @@ class Scene():
159
159
  if len(returns) == 1: return returns[0]
160
160
  return returns
161
161
 
162
+ def clear(self) -> None:
163
+ self.node_handler.clear()
164
+ self.particle.clear()
165
+
162
166
  def set_engine(self, engine: any) -> None:
163
167
  """
164
168
  Sets the back references to the engine and creates handlers with the context
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: basilisk-engine
3
- Version: 0.1.50
3
+ Version: 0.1.52
4
4
  Summary: Python 3D Framework
5
5
  Home-page: https://basilisk-website.vercel.app/
6
6
  Author: Name
@@ -1,9 +1,9 @@
1
- basilisk/__init__.py,sha256=23OM1kiXMU44J2TVp66efVSrbQAeiuTDmcdhNAftFfY,1134
1
+ basilisk/__init__.py,sha256=X7Mljz41Z97Fx0P3qL445mF5-kEX-82x_i3nCAAgyFc,1135
2
2
  basilisk/config.py,sha256=Ajm3BjCryuX5bmJglqRZDR1SjE0sDjTbulta5GZ67hA,1712
3
3
  basilisk/engine.py,sha256=QwKGhnxAulGsMmIIUrY80fUnbWVe-Y2-t2d8PH2xP4c,6025
4
- basilisk/scene.py,sha256=S0aoVMxA3SEO0ON3MTs1GF1JVLMi_TX7KNconeCAbYc,12389
4
+ basilisk/scene.py,sha256=L_XpXU0t-9kYUH_N8EP2y7oh0tyqm-_oMm3BNyQL0mg,12483
5
5
  basilisk/audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- basilisk/audio/sound.py,sha256=h2dQ3IKb_SRKNZqNuk-fdNg_Xfz0P7sqEXA33qiBXG4,692
6
+ basilisk/audio/sound.py,sha256=feRzVzp1ssu5QcyEErK0eGezPTZrhzEbbRRZw2d9aWc,1087
7
7
  basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
8
8
  basilisk/bsk_assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  basilisk/bsk_assets/basilisk.png,sha256=1xePD8qDycxlRQ7hjEmfuw900BRykhRyumJePi6hxi8,21299
@@ -41,9 +41,6 @@ basilisk/generic/quat.py,sha256=gEqvQvNwx5K7e0zqY0TFTAFtNFSkOatleoP9HQQ-xyk,5102
41
41
  basilisk/generic/quat_methods.py,sha256=SO18ush7pfeGUmncPy4i5nsab1e_zkQkY6zT1bAsSDY,234
42
42
  basilisk/generic/raycast_result.py,sha256=waVmS9fYhLoz_G_DU2Mj7896rF0Xy_59JVGALq-kD7g,783
43
43
  basilisk/generic/vec3.py,sha256=AtPSz2S1ZqAm-sZUz4phB09hgFxMIsJnQdU1wmxiOBw,5137
44
- basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- basilisk/input/mouse.py,sha256=waXJLIyka4IVe3W2WH5SNNxiOQRouYo3NxafP3fg0qg,1937
46
- basilisk/input/path.py,sha256=GpFYe3Uu6VZAuKh9Q2nQM1H8immiCp_snznLG9FKcvU,441
47
44
  basilisk/input_output/IO_handler.py,sha256=DDQEjmIHzWo99rk1riT_QJKGQ5F8-lOilmchRXeQuYI,2822
48
45
  basilisk/input_output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
46
  basilisk/input_output/clock.py,sha256=GHTagpPyPlLjWyonaHV8M-nPCcdHcHL4JobbuUOxYf0,1462
@@ -61,10 +58,10 @@ basilisk/mesh/narrow_primative.py,sha256=Dlw0jnFewPwAvT0Ap9IxAh05tgjZAdjAyuiRy1D
61
58
  basilisk/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
59
  basilisk/nodes/helper.py,sha256=GZ2-TY_4PDEfxBGp7ddktYoDDMOogPMbDeRPqsrPu1A,2069
63
60
  basilisk/nodes/node.py,sha256=IYWKqRrFACdZl95SRxkvwdVS8px2cCCYwdbgZQyLfTQ,33177
64
- basilisk/nodes/node_handler.py,sha256=IFEcEefVzlMbYR0O6OtM2qPcoZFrLYugiwAqEQMoTqo,4106
61
+ basilisk/nodes/node_handler.py,sha256=aai0Dm0yoB9Vd96O_mYVLId2AeXAfc_RYUnMfS_jAhQ,4334
65
62
  basilisk/particles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
- basilisk/particles/particle_handler.py,sha256=NkQz3fJaURdF5DhKu4BJ8igZ-4yWvj6a7omblN9mCXg,2927
67
- basilisk/particles/particle_renderer.py,sha256=z82gZj9lT6kUGzjN6ZZ9D9j_Qb8wmCRYWvsuuiezfyo,3701
63
+ basilisk/particles/particle_handler.py,sha256=FRwCC9tTyTI2zGDjWl-ZYzN3BX0gTuIT-LlTygHJ3O8,2998
64
+ basilisk/particles/particle_renderer.py,sha256=e7HrNc0IfiBhNMLPXq4RTugkWnuvbKcqNq5uGIll35A,3698
68
65
  basilisk/physics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
66
  basilisk/physics/impulse.py,sha256=a_Ks-4LrjaN3siMmVwGp92_iyr9a-G1lb5Q-J7g6ipA,5761
70
67
  basilisk/physics/physics_body.py,sha256=-iqo3YyCfMzpBVNA2I34JbfN7Z6phj5nnGHN-S8lBgs,1465
@@ -87,12 +84,10 @@ basilisk/render/post_process.py,sha256=QAIwNccycEJqA1UVGKUqwVus11sJX9qm3Mjl0gdGY
87
84
  basilisk/render/shader.py,sha256=xh2p8kPFCPD479wyf6X3NUsgGfy3sbnSypNqFd8k83c,4870
88
85
  basilisk/render/shader_handler.py,sha256=Tk-wbejg7UhXyq1c9pHjb-590zqAakNLCZu2ZbKCCAs,3260
89
86
  basilisk/render/sky.py,sha256=10kPdEpo8l7s8Iz-XP0W9_CXAHTANHZ3BRjzkdPVTnQ,4786
90
- basilisk/render/tempCodeRunnerFile.py,sha256=ep1eVZzUd30SDCNE5l3OJsqp2fW2LEXrjYGW31AMWgw,10
91
87
  basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
88
  basilisk/shaders/batch.frag,sha256=F_rGIQaY5jfep3WTCNY9Q3uLfu2lNuUSZZR7GZy_HCk,9514
93
89
  basilisk/shaders/batch.vert,sha256=LYzcqcwCyCpnxF5V-ilx79HU2cYz66hylBmZChcVmos,5555
94
90
  basilisk/shaders/bloom_downsample.frag,sha256=rIQTnBkSNiTF57D-yvWwQv_3_PmxznquHdlma8ua8Uw,685
95
- basilisk/shaders/bloom_frame.frag,sha256=Y0m8DnQKz3G9FKq7VjCGrVXZw2vSigyGX7-tlxZN0lE,567
96
91
  basilisk/shaders/bloom_upsample.frag,sha256=Pe1AupjM2OCMieW7oEYHoEx2LhbPtbpwcylruF5Ntm4,1156
97
92
  basilisk/shaders/crt.frag,sha256=ss6xhXwwOH9bXEhqyim--K4o1BOo1Wwq6tGAwjpRHEQ,1043
98
93
  basilisk/shaders/draw.frag,sha256=rcPmGMh850M1ypcFNlJCyFWxfZ739lVNl6OPTxPIYIE,605
@@ -109,7 +104,7 @@ basilisk/shaders/particle.frag,sha256=IskhyXelHs9GqABKwTYSwooWL0nP-nkmXl6a5iT6Q3
109
104
  basilisk/shaders/particle.vert,sha256=oiBz6S_2dzqioAhyzVYT1ZKOED4h4R6IoP-UJ8KRHhU,3227
110
105
  basilisk/shaders/sky.frag,sha256=dJRdSbg16aZYYjxdoG1spVQRIVBGNVdyX0rqp4ER6v8,556
111
106
  basilisk/shaders/sky.vert,sha256=oAnrknEgsd9MawE_zx8P0u9nUSFEBYBg5ykBmWpqZ_g,332
112
- basilisk_engine-0.1.50.dist-info/METADATA,sha256=L3N_TMqX5mZEcWt6L9h9ZA9KEAlGH04kd4RqtsdW0a4,3793
113
- basilisk_engine-0.1.50.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
114
- basilisk_engine-0.1.50.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
115
- basilisk_engine-0.1.50.dist-info/RECORD,,
107
+ basilisk_engine-0.1.52.dist-info/METADATA,sha256=WBuIaNKdinXwjl9RxX-eUekrSkK8Xuex4rGp3QMGql8,3793
108
+ basilisk_engine-0.1.52.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
109
+ basilisk_engine-0.1.52.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
110
+ basilisk_engine-0.1.52.dist-info/RECORD,,
File without changes
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)
basilisk/input/path.py DELETED
@@ -1,14 +0,0 @@
1
- import os
2
- import sys
3
-
4
-
5
- # Credit for function: https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile
6
- def get_root():
7
- """ Get absolute path to resource, works for dev and for PyInstaller """
8
- try:
9
- # PyInstaller creates a temp folder and stores path in _MEIPASS
10
- base_path = sys._MEIPASS
11
- except Exception:
12
- base_path = os.path.abspath(".")
13
-
14
- return base_path + '/basilisk'
@@ -1 +0,0 @@
1
- source[0][
@@ -1,25 +0,0 @@
1
- #version 330 core
2
-
3
- out vec4 fragColor;
4
-
5
- in vec2 uv;
6
-
7
- uniform sampler2D screenTexture;
8
- uniform sampler2D bloomTexture;
9
-
10
-
11
-
12
- void main()
13
- {
14
- const float gamma = 2.2;
15
- const float exposure = 1.2;
16
- vec3 hdrColor = texture(screenTexture, uv).rgb + texture(bloomTexture, uv).rgb / 2;
17
-
18
- // exposure tone mapping
19
- vec3 mapped = vec3(1.0) - exp(-hdrColor * exposure);
20
- // gamma correction
21
- mapped = pow(mapped, vec3(1.0 / gamma));
22
-
23
- fragColor = vec4(mapped, 1.0);
24
- //fragColor = texture(screenTexture, uv) + texture(bloomTexture, uv) / 20000.0;
25
- }