Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
TrailRenderer.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
21#pragma once
22
23// =============================================================================
24// Includes
25// =============================================================================
26
27#include "../../core/Types.hpp"
29#include "../../math/Math.hpp"
31
32namespace esengine::ecs {
33
34// =============================================================================
35// TrailRenderer Component
36// =============================================================================
37
38ES_COMPONENT(renderable=enabled)
40 // Trail — how long the streak lives and how densely it samples the path.
42 ES_PROPERTY(min=0, category=Trail, tooltip="Seconds each trail point lives before it fades out of the tail.")
43 f32 time{0.5f};
44
47 ES_PROPERTY(min=0, category=Trail, tooltip="Min world distance moved before a new trail point is recorded.")
49
52 ES_PROPERTY(category=Trail, tooltip="Record new points. False = freeze and let the streak fade in place.")
53 bool emitting{true};
54
55 // Width — full ribbon width tapered from the head (newest) to the tail (oldest).
57 ES_PROPERTY(min=0, category=Width, tooltip="Full ribbon width at the head (newest point).")
59
61 ES_PROPERTY(min=0, category=Width, tooltip="Full ribbon width at the tail (oldest point).")
63
64 // Color — lerped from head to tail; the alpha is the usual fade-out control.
66 ES_PROPERTY(animatable, category=Color, tooltip="Color at the head (newest point).")
67 glm::vec4 startColor{1.0f, 1.0f, 1.0f, 1.0f};
68
70 ES_PROPERTY(animatable, category=Color, tooltip="Color at the tail (oldest point) — usually alpha 0 to fade out.")
71 glm::vec4 endColor{1.0f, 1.0f, 1.0f, 0.0f};
72
73 // Rendering.
76 ES_PROPERTY(asset = texture, category=Rendering)
78
80 ES_PROPERTY(category=Rendering, tooltip="Blend mode: 0 Normal, 1 Additive (glow), 2 Multiply, …")
82
84 ES_PROPERTY(step=1, enum_source=sortingLayers, category=Rendering, tooltip="Sorting layer — controls draw order across renderables.")
86
88 ES_PROPERTY(asset = material, advanced, category=Rendering)
90
91 // State.
93 bool enabled{true};
94
95 TrailRenderer() = default;
96};
97
98} // namespace esengine::ecs
Type-safe resource handle system.
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_PROPERTY(...)
Mark a field as a property that should be exposed to scripts.
Core type definitions and utilities for ESEngine.
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
float f32
32-bit floating point
Definition Types.hpp:59
i32 blendMode
Blend mode (0 = Normal, 1 = Additive for glow, …).
glm::vec4 startColor
Color at the head (newest).
bool emitting
Record new points. Set false to freeze emission and let the existing streak fade in place (the ribbon...
glm::vec4 endColor
Color at the tail (oldest) — typically the head color with alpha 0.
resource::TextureHandle texture
Texture sampled along the ribbon (U runs head→tail, V across the width). Invalid = untextured (vertex...
f32 startWidth
Full ribbon width at the head (the newest point, glued to the entity).
u32 material
Custom material ID (0 = default batch shader).
f32 time
Seconds each recorded point persists before fading out of the tail.
f32 endWidth
Full ribbon width at the tail (the oldest point). 0 = taper to a line.
f32 minVertexDistance
Minimum world distance the entity must move before a new point is recorded (0 = record every frame; l...
i32 layer
Sorting layer (higher = rendered on top).