camera module

class camera.Camera(app, position=(0, 0, 4), yaw=-90, pitch=0)[source]

Bases: object

First-person camera that handles view projection, movement, and rotation.

Provides matrix calculations for 3D scene rendering and user navigation.

get_projection_matrix()[source]

Calculate perspective projection matrix.

Returns:

Projection matrix for perspective transformation

Return type:

mat4

get_view_matrix()[source]

Calculate view matrix using camera position and orientation.

Returns:

View matrix for transforming world coordinates to camera space

Return type:

mat4

move()[source]

Handle keyboard input for camera movement in 3D space.

Uses WASD for horizontal movement and QE for vertical movement.

rotate()[source]

Update camera yaw and pitch based on mouse movement.

Applies sensitivity scaling and clamps pitch to prevent over-rotation.

update()[source]

Update camera position and orientation each frame.

Handles movement, rotation, and recalculates view matrix.

update_camera_vectors()[source]

Recalculate forward, right, and up vectors based on current orientation.

Uses spherical coordinates to convert yaw/pitch angles to 3D direction vectors.