Skip to main content

Module camera

Module camera 

Structs§

CameraState
Interactive orbit state driven from JS (set_camera, set_camera_pan, set_camera_target).
FlyCamera
6-DOF Free-flight camera with velocity damping for editor, debug, and free inspection.
OrbitCamera
Orbit inspection camera around a central pivot point.
Ray3D
A 3D ray with origin and normalized direction vector.
SpringChaseCamera
2nd-order spring-damper critically damped pursuit camera.

Constants§

CAMERA_FAR_PLANE
CAMERA_MAX_ZOOM
CAMERA_MIN_ZOOM
CAMERA_NEAR_PLANE
CAMERA_TAN_HALF_FOV
Tangent of the vertical half-FOV used by both projection and AO reconstruction.

Functions§

extract_frustum_planes
Extracts 6 normalized inward-pointing frustum planes [nx, ny, nz, d] from a column-major view-projection matrix ([0, w] depth convention).
look_at_rh
Right-handed look-at view matrix (column-major).
mat4_mul_col
Column-major $4\times 4$ matrix product a * b.
orbit_eye_position
Orbit camera eye position — matches the look_at used in orbit_view_projection.
orbit_eye_position_target
Orbit camera eye position with pan target center point.
orbit_forward
Unit world-space direction from the orbit eye toward its target.
orbit_view_projection
Column-major view×projection (WGSL mat4x4<f32> compatible) centered at world origin.
orbit_view_projection_target
Column-major view×projection centered at arbitrary world-space target center.
orbit_view_projection_with_near
Orbit view-projection with custom near plane.
painter_order_far_to_near
Far-to-near index order for a proof canvas tick.
perspective_rh_zo
Right-handed perspective projection matrix with [0, 1] clip depth (WebGPU convention, column-major).
sphere_in_frustum
Returns true if a sphere (center, radius) intersects or lies inside all 6 normalized frustum planes.
unproject_screen_to_ray
Unprojects 2D screen coordinates into a 3D world ray using a $4 \times 4$ inverse view-projection matrix.