EditorCamera
Spherical orbit camera for the 3D viewport. Produces view + projection matrices and picking rays.
Header
include/MeshCraft/Editor/EditorCamera.hpp
Namespace
MeshCraft::Editor
Model
The camera is defined by three parameters plus a target point:
yaw(radians) — horizontal orbit anglepitch(radians) — vertical orbit angle, clamped to ±1.48 rad (~±85°)distance— distance from the camera eye to the target, clamped to [0.5, 2000]target(Vector3) — the point the camera orbits around and looks at
The camera eye position is computed from these four values each frame. There is no separate eye position stored.
Public Fields
| Field | Type | Default | Description |
|---|---|---|---|
yaw | float | 0.0f | Horizontal orbit (radians) |
pitch | float | 0.4f | Vertical orbit (radians, clamped to ±85°) |
distance | float | 15.0f | Distance from target |
fovDegrees | float | 60.0f | Field of view |
nearPlane | float | 0.1f | Near clip |
farPlane | float | 2000.0f | Far clip |
target | Vector3 | (0,0,0) | The orbit center / look-at point |
Methods
| Method | Description |
|---|---|
orbit(deltaYaw, deltaPitch) | Add to yaw and pitch. Pitch is clamped. Called on middle-mouse drag. |
pan(deltaX, deltaY) | Translate target in the camera's right+up plane. Called on right-mouse drag. |
zoom(delta) | Multiply distance by a factor. Clamps result to [0.5, 2000]. |
focusOn(x, y, z, radius) | Move target to (x,y,z), set distance to fit the given radius. Used by F key. |
reset() | Reset yaw=0, pitch=0.4, distance=15, target=(0,0,0). |
viewMatrix() | Compute and return the view matrix from yaw/pitch/distance/target. |
projectionMatrix(aspectRatio) | Return a perspective projection matrix (fovDegrees, aspect, near, far). |
position() | Compute and return the current eye position (derived from orbit params). |
screenRayDirection(ndcX, ndcY, aspect) | Unproject a normalized device coordinate to a world-space ray direction. Used for AABB picking. |