Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
Camera.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
14#pragma once
15
16// =============================================================================
17// Includes
18// =============================================================================
19
20#include "../../core/Types.hpp"
22#include "../../math/Math.hpp"
23
24namespace esengine::ecs {
25
26// =============================================================================
27// Projection Type
28// =============================================================================
29
33ES_ENUM(stability=beta)
38
42ES_ENUM(stability=beta)
49
50// =============================================================================
51// Camera Component
52// =============================================================================
53
70struct Camera {
72 ES_PROPERTY(tooltip="Orthographic (2D) or Perspective projection.", editor_default=ProjectionType::Orthographic)
74
76 ES_PROPERTY(min=1, max=179, unit="°", shown_when=projectionType:Perspective)
77 f32 fov{60.0f};
78
80 ES_PROPERTY(animatable, min=0, shown_when=projectionType:Orthographic,
81 tooltip="Half the visible height in world units (Orthographic).", editor_default=540)
83
85 ES_PROPERTY(min=0, advanced)
87
89 ES_PROPERTY(min=0, advanced)
90 f32 farPlane{1000.0f};
91
93 ES_PROPERTY(advanced, editor_default=1.77)
95
97 ES_PROPERTY(editor_default=true)
98 bool isActive{false};
99
101 ES_PROPERTY(step=1, advanced)
103
106 glm::vec4 viewport{0.0f, 0.0f, 1.0f, 1.0f};
107
108 // A bitmask (ColorAndDepth = Color | Depth) → multi-select, so the curated bit
109 // list lives in TS and the single-choice enum dropdown is suppressed (flags).
110 ES_PROPERTY(flags, tooltip="Which buffers to clear before rendering this camera.")
112
115 ES_PROPERTY(advanced, shown_when=projectionType:Orthographic,
116 tooltip="Snap the camera to the pixel grid for crisp pixel-art (Orthographic).")
117 bool pixelPerfect{false};
118
121 ES_PROPERTY(bitmask_source=sortingLayers, tooltip="Which sorting layers this camera renders.")
122 u32 cullingMask{0xFFFFFFFFu};
123
128 ES_PROPERTY(advanced, tooltip="Render into a RenderTexture instead of the screen (0 = screen). Set at run time.")
130
131 Camera() = default;
132};
133
134} // namespace esengine::ecs
Math utilities and GLM configuration for ESEngine.
Reflection and metadata system for automatic binding generation.
#define ES_COMPONENT(...)
Mark a struct/class as a component that should be exposed to scripts.
#define ES_ENUM(...)
Mark an enum that should be exposed to scripts.
#define ES_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
ClearFlags
Camera clear flags.
Definition Camera.hpp:43
ProjectionType
Camera projection type.
Definition Camera.hpp:34
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
float f32
32-bit floating point
Definition Types.hpp:59
u32 renderTarget
Offscreen target this camera draws into; 0 = the screen. A RenderTexture handle, so it is created at ...
Definition Camera.hpp:129
f32 nearPlane
Near clipping plane distance.
Definition Camera.hpp:86
bool pixelPerfect
Snap the camera to the world-space pixel grid (Orthographic) so static pixel art renders crisp,...
Definition Camera.hpp:117
ClearFlags clearFlags
Definition Camera.hpp:111
i32 priority
Priority for determining active camera (higher = preferred).
Definition Camera.hpp:102
f32 orthoSize
Orthographic size (half-height in world units).
Definition Camera.hpp:82
u32 cullingMask
Sorting layers this camera renders (bit i = layer i). UI belongs to its Canvas' layer....
Definition Camera.hpp:122
glm::vec4 viewport
Viewport rectangle (x, y, width, height) in normalized coords.
Definition Camera.hpp:106
f32 aspectRatio
Aspect ratio (width / height), 0 = auto from viewport.
Definition Camera.hpp:94
f32 farPlane
Far clipping plane distance.
Definition Camera.hpp:90
ProjectionType projectionType
Projection type.
Definition Camera.hpp:73
f32 fov
Field of view in degrees (perspective only).
Definition Camera.hpp:77
bool isActive
Whether this is the active camera.
Definition Camera.hpp:98