simvx.core.helpers¶
Matrix helpers, coroutine helpers, easing functions, and raycasting utilities.
Module Contents¶
Functions¶
Build model matrix from position, rotation quaternion, and scale. |
|
Convert mat4 to bytes for GPU upload. |
|
Run multiple coroutines simultaneously, finish when all complete. |
|
Pause a coroutine for given seconds. |
|
Yield until condition() returns True. |
|
Yield until signal is emitted. Returns signal args. |
|
Yield for exactly one frame. |
|
Convert a screen pixel coordinate to a world-space ray (origin, direction). |
|
Ray-sphere intersection. Returns distance t or None if no hit. |
API¶
- simvx.core.helpers.mat4_from_trs(pos: tuple[float, float, float] | numpy.ndarray, rot, scl: tuple[float, float, float] | numpy.ndarray) numpy.ndarray¶
Build model matrix from position, rotation quaternion, and scale.
Args: pos: Position (x, y, z) rot: Rotation quaternion — Quat or any object with .w/.x/.y/.z scl: Scale (x, y, z)
Returns: 4x4 model matrix as numpy array (Translate * Rotate * Scale)
- simvx.core.helpers.mat4_to_bytes(m: numpy.ndarray) bytes¶
Convert mat4 to bytes for GPU upload.
Args: m: 4x4 numpy matrix
Returns: 64 bytes (row-major float32)
- simvx.core.helpers.parallel(*coroutines: simvx.core.descriptors.Coroutine) simvx.core.descriptors.Coroutine¶
Run multiple coroutines simultaneously, finish when all complete.
- simvx.core.helpers.wait(seconds: float) simvx.core.descriptors.Coroutine¶
Pause a coroutine for given seconds.
- simvx.core.helpers.wait_until(condition: collections.abc.Callable[[], bool]) simvx.core.descriptors.Coroutine¶
Yield until condition() returns True.
- simvx.core.helpers.wait_signal(signal: simvx.core.descriptors.Signal) simvx.core.descriptors.Coroutine¶
Yield until signal is emitted. Returns signal args.
- simvx.core.helpers.next_frame() simvx.core.descriptors.Coroutine¶
Yield for exactly one frame.
- simvx.core.helpers.ease_in_quad(t)¶
- simvx.core.helpers.ease_out_quad(t)¶
- simvx.core.helpers.ease_in_out_quad(t)¶
- simvx.core.helpers.ease_in_cubic(t)¶
- simvx.core.helpers.ease_out_cubic(t)¶
- simvx.core.helpers.screen_to_ray(screen_pos, screen_size, view, proj)¶
Convert a screen pixel coordinate to a world-space ray (origin, direction).
Returns (origin, direction) as Vec3.
- simvx.core.helpers.ray_intersect_sphere(origin, direction, center, radius: float)¶
Ray-sphere intersection. Returns distance t or None if no hit.