Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ecs::Camera Struct Reference

Camera component for rendering viewpoints. More...

#include <Camera.hpp>

Public Member Functions

 Camera ()=default

Public Attributes

ProjectionType projectionType {ProjectionType::Perspective}
 Projection type.
f32 fov {60.0f}
 Field of view in degrees (perspective only).
f32 orthoSize {5.0f}
 Orthographic size (half-height in world units).
f32 nearPlane {0.1f}
 Near clipping plane distance.
f32 farPlane {1000.0f}
 Far clipping plane distance.
f32 aspectRatio {0.0f}
 Aspect ratio (width / height), 0 = auto from viewport.
bool isActive {false}
 Whether this is the active camera.
i32 priority {0}
 Priority for determining active camera (higher = preferred).
glm::vec4 viewport {0.0f, 0.0f, 1.0f, 1.0f}
 Viewport rectangle (x, y, width, height) in normalized coords.
ClearFlags clearFlags {ClearFlags::ColorAndDepth}
bool pixelPerfect {false}
 Snap the camera to the world-space pixel grid (Orthographic) so static pixel art renders crisp, without sub-pixel shimmer when the camera moves.
u32 cullingMask {0xFFFFFFFFu}
 Sorting layers this camera renders (bit i = layer i). UI belongs to its Canvas' layer. Layers outside 0..31 have no bit and every camera draws them.
u32 renderTarget {0}
 Offscreen target this camera draws into; 0 = the screen. A RenderTexture handle, so it is created at run time and set from a script — a minimap, a mirror, a portrait rendered once. The camera's viewport covers the whole target, whose own size decides the resolution.

Detailed Description

Camera component for rendering viewpoints.

Defines a camera that can be used to render the scene. Supports both perspective and orthographic projections.

Entity camera = registry.create();
registry.emplace<Transform>(camera, glm::vec3(0, 0, 10));
auto& cam = registry.emplace<Camera>(camera);
cam.projectionType = ProjectionType::Perspective;
cam.fov = 60.0f;
cam.isActive = true;
Entity identifier with packed index + generation.
Definition Types.hpp:135
Unified transform component.
Definition Transform.hpp:45

Definition at line 70 of file Camera.hpp.

Constructor & Destructor Documentation

◆ Camera()

esengine::ecs::Camera::Camera ( )
default

Member Data Documentation

◆ aspectRatio

f32 esengine::ecs::Camera::aspectRatio {0.0f}

Aspect ratio (width / height), 0 = auto from viewport.

Definition at line 94 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ clearFlags

ClearFlags esengine::ecs::Camera::clearFlags {ClearFlags::ColorAndDepth}

Definition at line 111 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ cullingMask

u32 esengine::ecs::Camera::cullingMask {0xFFFFFFFFu}

Sorting layers this camera renders (bit i = layer i). UI belongs to its Canvas' layer. Layers outside 0..31 have no bit and every camera draws them.

Definition at line 122 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ farPlane

f32 esengine::ecs::Camera::farPlane {1000.0f}

Far clipping plane distance.

Definition at line 90 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ fov

f32 esengine::ecs::Camera::fov {60.0f}

Field of view in degrees (perspective only).

Definition at line 77 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ isActive

bool esengine::ecs::Camera::isActive {false}

Whether this is the active camera.

Definition at line 98 of file Camera.hpp.

Referenced by cameraApplyJS(), cameraToJS(), and esengine::particle::ParticleSystem::update().

◆ nearPlane

f32 esengine::ecs::Camera::nearPlane {0.1f}

Near clipping plane distance.

Definition at line 86 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ orthoSize

f32 esengine::ecs::Camera::orthoSize {5.0f}

Orthographic size (half-height in world units).

Definition at line 82 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ pixelPerfect

bool esengine::ecs::Camera::pixelPerfect {false}

Snap the camera to the world-space pixel grid (Orthographic) so static pixel art renders crisp, without sub-pixel shimmer when the camera moves.

Definition at line 117 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ priority

i32 esengine::ecs::Camera::priority {0}

Priority for determining active camera (higher = preferred).

Definition at line 102 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ projectionType

ProjectionType esengine::ecs::Camera::projectionType {ProjectionType::Perspective}

Projection type.

Definition at line 73 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ renderTarget

u32 esengine::ecs::Camera::renderTarget {0}

Offscreen target this camera draws into; 0 = the screen. A RenderTexture handle, so it is created at run time and set from a script — a minimap, a mirror, a portrait rendered once. The camera's viewport covers the whole target, whose own size decides the resolution.

Definition at line 129 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().

◆ viewport

glm::vec4 esengine::ecs::Camera::viewport {0.0f, 0.0f, 1.0f, 1.0f}

Viewport rectangle (x, y, width, height) in normalized coords.

Definition at line 106 of file Camera.hpp.

Referenced by cameraApplyJS(), and cameraToJS().


The documentation for this struct was generated from the following file:
  • /home/runner/work/estella/estella/src/esengine/ecs/components/Camera.hpp