camera

3D Camera representation and mathematical matrix manipulation.

This module handles the player’s perspective, generating the View and Projection matrices required by OpenGL to render the world. It provides movement vectors and rotational controls for exploring the 3D voxel space.

class camera.Camera(position, yaw, pitch)[source]

Bases: object

Represents a 3D camera in the world.

Handles position, orientation (yaw/pitch), view matrix calculation, and movement direction vectors for navigating the voxel environment.

Parameters:
  • position (Any) – Initial (x, y, z) 3D coordinate vector.

  • yaw (float) – Initial horizontal rotation in degrees.

  • pitch (float) – Initial vertical rotation in degrees.

update()[source]

Updates the camera’s directional vectors and view matrix for the current frame.

Return type:

None

update_view_matrix()[source]

Calculates the OpenGL lookAt view matrix based on the camera’s position and forward vector.

Return type:

None

update_vectors()[source]

Recalculates the forward, right, and up vectors using spherical coordinates derived from the current yaw and pitch.

Return type:

None

rotate_pitch(delta_y)[source]

Adjusts the camera’s pitch (up/down rotation), clamping it to prevent flipping over.

Parameters:

delta_y (float)

Return type:

None

rotate_yaw(delta_x)[source]

Adjusts the camera’s yaw (left/right rotation).

Parameters:

delta_x (float)

Return type:

None

move_left(velocity)[source]

Translates the camera leftward along its right vector.

Parameters:

velocity (float)

Return type:

None

move_right(velocity)[source]

Translates the camera rightward along its right vector.

Parameters:

velocity (float)

Return type:

None

move_up(velocity)[source]

Translates the camera upward along its up vector.

Parameters:

velocity (float)

Return type:

None

move_down(velocity)[source]

Translates the camera downward along its up vector.

Parameters:

velocity (float)

Return type:

None

move_forward(velocity)[source]

Translates the camera forward along its forward vector.

Parameters:

velocity (float)

Return type:

None

move_back(velocity)[source]

Translates the camera backward along its forward vector.

Parameters:

velocity (float)

Return type:

None