EditorCamera
- Namespace: Turian.Engine.Core
- Source File: EditorCamera.cs
Editor-only free camera. Lives outside the scene graph — never serialized, never shown in the SceneTree panel. The viewport owns this camera rather than a scene node. The engine's world space has +Y pointing down (OBJ/FBX importers negate Y), but the camera convention is Y-up: globalUp = +Y, positive pitch = look up. The Vulkan render pass handles the final Y-flip for display.
Properties
Position
(Vector3) { get; set } = new(0f, 1f, -5f)
FieldOfView
(float) { get; set } = 60f * (MathF.PI / 180f)
NearPlane
(float) { get; set } = 0.01f: Gets or sets the near clip plane distance.
FarPlane
(float) { get; set } = 500f: Gets or sets the far clip plane distance.
IsOrthographic
(bool) { get; set } = false: Gets or sets whether the camera uses orthographic projection.
Frustum
(float) { get; set } = 10f: Gets or sets the orthographic frustum half-height in world units.
Orientation
(Quaternion) { get; set }: The camera's orientation. Rotation is free: the camera can look straight up, straight down or roll upside down, because viewport drags rotate about its own axes rather than about a fixed world up.
Pitch
(float) { get; set }: Camera pitch in radians, as an Euler angle about the world X axis. Setting it rebuilds the orientation from yaw and pitch alone, which discards any roll.
Yaw
(float) { get; set }: Camera yaw in radians, as an Euler angle about the world Y axis. Setting it rebuilds the orientation from yaw and pitch alone, which discards any roll.
Front
(Vector3) { get; set } = Vector3.UnitZ
Right
(Vector3) { get; set } = Vector3.UnitX
Up
(Vector3) { get; set } = Vector3.UnitY
Public Methods
SetYawPitch
public void SetYawPitch(float yawRadians, float pitchRadians)
Points the camera using world-space yaw and pitch, levelling any roll. This is the entry point for callers that think in Euler angles — serialized cameras and the screenshot CLI.
Parameters:
yawRadians(float): Yaw about the world Y axis.pitchRadians(float): Pitch about the camera's right axis, clamped just short of vertical.
RotateLocal
public void RotateLocal(float yawRadians, float pitchRadians)
Rotates the camera about its own axes. Horizontal drags therefore move the view along the screen's horizontal instead of sweeping a cone around the world up axis, and vertical drags pass over the top instead of stopping at it.
Parameters:
yawRadians(float): Rotation about the camera's own up axis; positive turns right.pitchRadians(float): Rotation about the camera's own right axis; positive tilts up.
RollLocal
public void RollLocal(float radians)
Rolls the camera about its own forward axis.
Parameters:
radians(float): Rotation about the view direction; positive rolls clockwise.
LookIn
public void LookIn(Vector3 front, Vector3 up)
Aims the camera along front, using up as the reference for which way is up. Falls back to the current up when the two are parallel.
Parameters:
front(Vector3): The direction to look along.up(Vector3): Reference up direction.
LevelRoll
public void LevelRoll()
Levels the camera so its up axis points along world up, keeping the view direction.
Resize
public void Resize(uint width, uint height)
Updates the aspect ratio when the viewport is resized.
Parameters:
width(uint)height(uint)
GetViewMatrix
public Matrix4x4 GetViewMatrix()
Returns: Matrix4x4
GetProjectionMatrix
public Matrix4x4 GetProjectionMatrix()
Returns: Matrix4x4
GetInverseViewMatrix
public Matrix4x4 GetInverseViewMatrix()
Returns: Matrix4x4
Project
public Vector2 Project(Vector3 p)
Parameters:
p(Vector3)
Returns: Vector2
UnProject
public Vector3 UnProject(Vector2 p)
Parameters:
p(Vector2)
Returns: Vector3
ToggleProjection
public void ToggleProjection()
Toggles between perspective and orthographic projection.