Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

refactor(anim): delete the C++ timeline runtime + animTargets codegen — REARCH_ANIMATION P4c (2b/2)

esengine6bdbdbe91fb1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index df71446ff..eb59e54e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,6 @@ option(ES_ENABLE_SPINE "Enable Spine animation support" ON)
option(ES_ENABLE_BOX2D "Enable Box2D physics support" OFF)
option(ES_ENABLE_TILEMAP "Enable Tilemap support" ON)
option(ES_ENABLE_PARTICLES "Enable Particle system" ON)
-option(ES_ENABLE_TIMELINE "Enable Timeline animation" ON)
option(ES_ENABLE_POSTPROCESS "Enable Post-processing pipeline" ON)
option(ES_ENABLE_BITMAP_TEXT "Enable Bitmap text rendering" ON)
option(ES_ENABLE_BASIS "Build the Basis Universal KTX2 transcoder module" OFF)
@@ -87,11 +86,6 @@ if(ES_ENABLE_PARTICLES)
)
endif()
-if(ES_ENABLE_TIMELINE)
- list(APPEND ESENGINE_SOURCES
- src/esengine/animation/TimelineSystem.cpp
- )
-endif()
list(APPEND ESENGINE_SOURCES
src/esengine/text/BitmapFont.cpp
@@ -181,13 +175,6 @@ if(ES_ENABLE_PARTICLES)
)
endif()
-if(ES_ENABLE_TIMELINE)
- list(APPEND ESENGINE_HEADERS
- src/esengine/animation/TimelineData.hpp
- src/esengine/animation/TimelineSystem.hpp
- )
-endif()
-
list(APPEND ESENGINE_HEADERS
src/esengine/text/BitmapFont.hpp
)
@@ -263,9 +250,6 @@ if(ES_ENABLE_PARTICLES)
target_compile_definitions(esengine PUBLIC ES_ENABLE_PARTICLES)
endif()
-if(ES_ENABLE_TIMELINE)
- target_compile_definitions(esengine PUBLIC ES_ENABLE_TIMELINE)
-endif()
if(ES_ENABLE_POSTPROCESS)
target_compile_definitions(esengine PUBLIC ES_ENABLE_POSTPROCESS)
@@ -315,9 +299,6 @@ if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
if(ES_ENABLE_TILEMAP)
list(APPEND SDK_BINDING_SOURCES src/esengine/bindings/TilemapBindings.cpp)
endif()
- if(ES_ENABLE_TIMELINE)
- list(APPEND SDK_BINDING_SOURCES src/esengine/bindings/TimelineBindings.cpp)
- endif()
add_executable(esengine_sdk ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_sdk PRIVATE esengine)
diff --git a/sdk/src/timeline/animTargets.generated.ts b/sdk/src/timeline/animTargets.generated.ts
deleted file mode 100644
index e344cd515..000000000
--- a/sdk/src/timeline/animTargets.generated.ts
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * @file animTargets.generated.ts
- * @brief Auto-generated animation target mappings
- * @details Generated by EHT - DO NOT EDIT
- */
-
-export enum AnimTargetField {
- BitmapTextColorR = 0,
- BitmapTextColorG = 1,
- BitmapTextColorB = 2,
- BitmapTextColorA = 3,
- CameraOrthoSize = 4,
- SpriteColorR = 5,
- SpriteColorG = 6,
- SpriteColorB = 7,
- SpriteColorA = 8,
- SpriteSizeX = 9,
- SpriteSizeY = 10,
- TilemapLayerTintColorR = 11,
- TilemapLayerTintColorG = 12,
- TilemapLayerTintColorB = 13,
- TilemapLayerTintColorA = 14,
- TilemapLayerOpacity = 15,
- TransformPositionX = 16,
- TransformPositionY = 17,
- TransformPositionZ = 18,
- TransformRotationZ = 19,
- TransformScaleX = 20,
- TransformScaleY = 21,
- TransformScaleZ = 22,
- UIRectAnchorMinX = 23,
- UIRectAnchorMinY = 24,
- UIRectAnchorMaxX = 25,
- UIRectAnchorMaxY = 26,
- UIRectOffsetMinX = 27,
- UIRectOffsetMinY = 28,
- UIRectOffsetMaxX = 29,
- UIRectOffsetMaxY = 30,
- UIRectPivotX = 31,
- UIRectPivotY = 32,
- UIRendererColorR = 33,
- UIRendererColorG = 34,
- UIRendererColorB = 35,
- UIRendererColorA = 36,
- CustomField = 37,
-}
-
-export enum AnimTargetComponent {
- BitmapText = 0,
- Camera = 1,
- Sprite = 2,
- TilemapLayer = 3,
- Transform = 4,
- UIRect = 5,
- UIRenderer = 6,
- Custom = 7,
-}
-
-export const FIELD_MAP: Record<string, Record<string, AnimTargetField>> = {
- BitmapText: {
- 'color.r': AnimTargetField.BitmapTextColorR,
- 'color.g': AnimTargetField.BitmapTextColorG,
- 'color.b': AnimTargetField.BitmapTextColorB,
- 'color.a': AnimTargetField.BitmapTextColorA,
- },
- Camera: {
- 'orthoSize': AnimTargetField.CameraOrthoSize,
- },
- Sprite: {
- 'color.r': AnimTargetField.SpriteColorR,
- 'color.g': AnimTargetField.SpriteColorG,
- 'color.b': AnimTargetField.SpriteColorB,
- 'color.a': AnimTargetField.SpriteColorA,
- 'size.x': AnimTargetField.SpriteSizeX,
- 'size.y': AnimTargetField.SpriteSizeY,
- },
- TilemapLayer: {
- 'tintColor.r': AnimTargetField.TilemapLayerTintColorR,
- 'tintColor.g': AnimTargetField.TilemapLayerTintColorG,
- 'tintColor.b': AnimTargetField.TilemapLayerTintColorB,
- 'tintColor.a': AnimTargetField.TilemapLayerTintColorA,
- 'opacity': AnimTargetField.TilemapLayerOpacity,
- },
- Transform: {
- 'position.x': AnimTargetField.TransformPositionX,
- 'position.y': AnimTargetField.TransformPositionY,
- 'position.z': AnimTargetField.TransformPositionZ,
- 'rotation.z': AnimTargetField.TransformRotationZ,
- 'scale.x': AnimTargetField.TransformScaleX,
- 'scale.y': AnimTargetField.TransformScaleY,
- 'scale.z': AnimTargetField.TransformScaleZ,
- },
- UIRect: {
- 'anchorMin.x': AnimTargetField.UIRectAnchorMinX,
- 'anchorMin.y': AnimTargetField.UIRectAnchorMinY,
- 'anchorMax.x': AnimTargetField.UIRectAnchorMaxX,
- 'anchorMax.y': AnimTargetField.UIRectAnchorMaxY,
- 'offsetMin.x': AnimTargetField.UIRectOffsetMinX,
- 'offsetMin.y': AnimTargetField.UIRectOffsetMinY,
- 'offsetMax.x': AnimTargetField.UIRectOffsetMaxX,
- 'offsetMax.y': AnimTargetField.UIRectOffsetMaxY,
- 'pivot.x': AnimTargetField.UIRectPivotX,
- 'pivot.y': AnimTargetField.UIRectPivotY,
- },
- UIRenderer: {
- 'color.r': AnimTargetField.UIRendererColorR,
- 'color.g': AnimTargetField.UIRendererColorG,
- 'color.b': AnimTargetField.UIRendererColorB,
- 'color.a': AnimTargetField.UIRendererColorA,
- },
-};
-
-export const COMPONENT_MAP: Record<string, AnimTargetComponent> = {
- BitmapText: AnimTargetComponent.BitmapText,
- Camera: AnimTargetComponent.Camera,
- Sprite: AnimTargetComponent.Sprite,
- TilemapLayer: AnimTargetComponent.TilemapLayer,
- Transform: AnimTargetComponent.Transform,
- UIRect: AnimTargetComponent.UIRect,
- UIRenderer: AnimTargetComponent.UIRenderer,
-};
diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.ts
index 46778738e..8ab14b3ed 100644
--- a/sdk/src/wasm.ts
+++ b/sdk/src/wasm.ts
@@ -335,53 +335,6 @@ export interface ESEngineModule {
_anim_updateTweens(registry: CppRegistry, deltaTime: number): void;
_anim_getTweenState(registry: CppRegistry, tweenEntity: number): number;
- // Timeline API
- _tl_create(duration: number, wrapMode: number): number;
- _tl_destroy(handle: number): void;
- _tl_addPropertyTrack(handle: number, childPathPtr: number, childPathLen: number,
- component: number, fieldsPtr: number, channelCount: number,
- keyframeDataPtr: number, keyframeCountsPtr: number): void;
- _tl_addCustomPropertyTrack(handle: number, childPathPtr: number, childPathLen: number,
- componentNamePtr: number, componentNameLen: number,
- fieldPathsPtr: number, fieldPathLensPtr: number,
- channelCount: number,
- keyframeDataPtr: number, keyframeCountsPtr: number): void;
- _tl_addSpineTrack(handle: number, childPathPtr: number, childPathLen: number,
- clipsDataPtr: number, clipAnimPtrs: number,
- clipAnimLens: number, clipCount: number, blendIn: number): void;
- _tl_addAudioTrack(handle: number, childPathPtr: number, childPathLen: number,
- eventsFloatPtr: number, clipPtrs: number,
- clipLens: number, eventCount: number): void;
- _tl_addActivationTrack(handle: number, childPathPtr: number, childPathLen: number,
- rangesPtr: number, rangeCount: number): void;
- _tl_addSpriteAnimTrack(handle: number, childPathPtr: number, childPathLen: number,
- clipPathPtr: number, clipPathLen: number, startTime: number): void;
- _tl_play(handle: number): void;
- _tl_pause(handle: number): void;
- _tl_stop(handle: number): void;
- _tl_setTime(handle: number, time: number): void;
- _tl_setSpeed(handle: number, speed: number): void;
- _tl_setWrapMode(handle: number, mode: number): void;
- _tl_getTime(handle: number): number;
- _tl_isPlaying(handle: number): number;
- _tl_advance(registry: CppRegistry, handle: number, rootEntity: number,
- deltaTime: number, speed: number): void;
- _tl_evaluateAt(handle: number, time: number, outPtr: number, maxChannels: number): number;
- _tl_getEventCount(): number;
- _tl_getEventType(index: number): number;
- _tl_getEventEntity(index: number): number;
- _tl_getEventIntParam(index: number): number;
- _tl_getEventFloatParam(index: number): number;
- _tl_getEventString(index: number): number;
- _tl_getEventStringLen(index: number): number;
- _tl_getCustomPropertyCount(): number;
- _tl_getCustomPropertyEntity(index: number): number;
- _tl_getCustomPropertyTrackIndex(index: number): number;
- _tl_getCustomPropertyChannelIndex(index: number): number;
- _tl_getCustomPropertyValue(index: number): number;
- _tl_clearResults(): void;
- _tl_setTrackTarget(handle: number, isEventTrack: number, trackIndex: number, entity: number): void;
-
// Pointer-based component access
getTransformPtr(registry: CppRegistry, entity: number): number;
getSpritePtr(registry: CppRegistry, entity: number): number;
diff --git a/src/esengine/animation/AnimPropertyApply.hpp b/src/esengine/animation/AnimPropertyApply.hpp
deleted file mode 100644
index 62359746d..000000000
--- a/src/esengine/animation/AnimPropertyApply.hpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-#include "animTargets.generated.hpp"
diff --git a/src/esengine/animation/TimelineData.hpp b/src/esengine/animation/TimelineData.hpp
deleted file mode 100644
index 1e6f7ba35..000000000
--- a/src/esengine/animation/TimelineData.hpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#pragma once
-
-#include "../core/Types.hpp"
-#include "animTargets.generated.hpp"
-
-#include <string>
-#include <vector>
-
-namespace esengine::animation {
-
-enum class TimelineWrapMode : u8 {
- Once = 0,
- Loop,
- PingPong,
-};
-
-enum class InterpType : u8 {
- Hermite = 0,
- Linear,
- Step,
- EaseIn,
- EaseOut,
- EaseInOut,
-};
-
-struct TimelineKeyframe {
- f32 time;
- f32 value;
- f32 inTangent;
- f32 outTangent;
- InterpType interpolation{InterpType::Hermite};
-};
-
-struct TimelineChannel {
- std::vector<TimelineKeyframe> keyframes;
-};
-
-struct PropertyTrackBinding {
- std::string childPath;
- AnimTargetComponent component;
- std::vector<AnimTargetField> fields;
- std::vector<TimelineChannel> channels;
- std::string customComponentName;
- std::vector<std::string> customFieldPaths;
- Entity resolvedTarget{INVALID_ENTITY};
-};
-
-struct SpineClipData {
- f32 start;
- f32 duration;
- std::string animation;
- bool loop;
- f32 speed;
-};
-
-struct AudioEventData {
- f32 time;
- std::string clip;
- f32 volume;
-};
-
-struct ActivationRange {
- f32 start;
- f32 end;
-};
-
-enum class EventTrackType : u8 {
- Spine = 0,
- SpriteAnim,
- Audio,
- Activation,
-};
-
-struct EventTrack {
- std::string childPath;
- EventTrackType type;
- std::vector<SpineClipData> spineClips;
- f32 spineBlendIn{0.0f};
- std::string spriteAnimClip;
- f32 spriteAnimStartTime{0.0f};
- std::vector<AudioEventData> audioEvents;
- std::vector<ActivationRange> activationRanges;
- Entity resolvedTarget{INVALID_ENTITY};
-};
-
-struct TimelineData {
- f32 duration{0.0f};
- TimelineWrapMode wrapMode{TimelineWrapMode::Once};
- std::vector<PropertyTrackBinding> propertyTracks;
- std::vector<EventTrack> eventTracks;
-};
-
-} // namespace esengine::animation
diff --git a/src/esengine/animation/TimelineSystem.cpp b/src/esengine/animation/TimelineSystem.cpp
deleted file mode 100644
index d7c98b81e..000000000
--- a/src/esengine/animation/TimelineSystem.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-#include "TimelineSystem.hpp"
-#include "AnimPropertyApply.hpp"
-#include "../ecs/components/Hierarchy.hpp"
-#include "../ecs/components/Common.hpp"
-
-#include <cmath>
-#include <algorithm>
-
-namespace esengine::animation {
-
-const std::string TimelineSystem::EMPTY_STRING;
-
-// ---------------------------------------------------------------------------
-// Lifecycle
-// ---------------------------------------------------------------------------
-
-TimelineHandle TimelineSystem::createTimeline(TimelineData&& data) {
- TimelineHandle handle = nextHandle_++;
- Instance inst;
- inst.spineClipIndices.resize(data.eventTracks.size(), -1);
- inst.data = std::move(data);
- instances_.emplace(handle, std::move(inst));
- return handle;
-}
-
-void TimelineSystem::destroyTimeline(TimelineHandle handle) {
- instances_.erase(handle);
-}
-
-// ---------------------------------------------------------------------------
-// Playback control
-// ---------------------------------------------------------------------------
-
-void TimelineSystem::play(TimelineHandle handle) {
- if (auto* inst = getInstance(handle)) {
- inst->currentTime = 0.0f;
- inst->previousTime = 0.0f;
- inst->playing = true;
- inst->childCache.clear();
- std::fill(inst->spineClipIndices.begin(), inst->spineClipIndices.end(), -1);
- }
-}
-
-void TimelineSystem::pause(TimelineHandle handle) {
- if (auto* inst = getInstance(handle)) {
- inst->playing = false;
- }
-}
-
-void TimelineSystem::stop(TimelineHandle handle) {
- if (auto* inst = getInstance(handle)) {
- inst->playing = false;
- inst->currentTime = 0.0f;
- inst->previousTime = 0.0f;
- inst->childCache.clear();
- std::fill(inst->spineClipIndices.begin(), inst->spineClipIndices.end(), -1);
- }
-}
-
-void TimelineSystem::setTime(TimelineHandle handle, f32 time) {
- if (auto* inst = getInstance(handle)) {
- inst->previousTime = inst->currentTime;
- inst->currentTime = time;
- }
-}
-
-void TimelineSystem::setSpeed(TimelineHandle handle, f32 speed) {
- if (auto* inst = getInstance(handle)) {
- inst->speed = speed;
- }
-}
-
-void TimelineSystem::setWrapMode(TimelineHandle handle, TimelineWrapMode mode) {
- if (auto* inst = getInstance(handle)) {
- inst->data.wrapMode = mode;
- }
-}
-
-f32 TimelineSystem::getTime(TimelineHandle handle) const {
- if (auto* inst = getInstance(handle)) {
- return inst->currentTime;
- }
- return 0.0f;
-}
-
-bool TimelineSystem::isPlaying(TimelineHandle handle) const {
- if (auto* inst = getInstance(handle)) {
- return inst->playing;
- }
- return false;
-}
-
-bool TimelineSystem::isStopped(TimelineHandle handle) const {
- if (auto* inst = getInstance(handle)) {
- return !inst->playing && inst->currentTime == 0.0f;
- }
- return true;
-}
-
-// ---------------------------------------------------------------------------
-// Core math
-// ---------------------------------------------------------------------------
-
-f32 TimelineSystem::hermiteInterpolate(f32 p0, f32 p1, f32 m0, f32 m1, f32 t) {
- f32 t2 = t * t;
- f32 t3 = t2 * t;
- f32 h00 = 2.0f * t3 - 3.0f * t2 + 1.0f;
- f32 h10 = t3 - 2.0f * t2 + t;
- f32 h01 = -2.0f * t3 + 3.0f * t2;
- f32 h11 = t3 - t2;
- return h00 * p0 + h10 * m0 + h01 * p1 + h11 * m1;
-}
-
-f32 TimelineSystem::easeIn(f32 t) {
- return t * t;
-}
-
-f32 TimelineSystem::easeOut(f32 t) {
- return 1.0f - (1.0f - t) * (1.0f - t);
-}
-
-f32 TimelineSystem::easeInOut(f32 t) {
- return t < 0.5f ? 2.0f * t * t : 1.0f - 2.0f * (1.0f - t) * (1.0f - t);
-}
-
-f32 TimelineSystem::evaluateChannel(const TimelineChannel& channel, f32 time) {
- const auto& kfs = channel.keyframes;
- if (kfs.empty()) return 0.0f;
- if (kfs.size() == 1) return kfs[0].value;
-
- if (time <= kfs.front().time) return kfs.front().value;
- if (time >= kfs.back().time) return kfs.back().value;
-
- usize i = 0;
- while (i < kfs.size() - 1 && kfs[i + 1].time <= time) {
- i++;
- }
-
- const auto& k0 = kfs[i];
- const auto& k1 = kfs[i + 1];
- f32 dt = k1.time - k0.time;
- if (dt <= 0.0f) return k0.value;
-
- f32 t = (time - k0.time) / dt;
-
- switch (k0.interpolation) {
- case InterpType::Linear:
- return k0.value + (k1.value - k0.value) * t;
- case InterpType::Step:
- return k0.value;
- case InterpType::EaseIn:
- return k0.value + (k1.value - k0.value) * easeIn(t);
- case InterpType::EaseOut:
- return k0.value + (k1.value - k0.value) * easeOut(t);
- case InterpType::EaseInOut:
- return k0.value + (k1.value - k0.value) * easeInOut(t);
- case InterpType::Hermite:
- default:
- return hermiteInterpolate(k0.value, k1.value, k0.outTangent * dt, k1.inTangent * dt, t);
- }
-}
-
-f32 TimelineSystem::applyWrapMode(f32 time, f32 duration, TimelineWrapMode mode, bool& stopped) {
- stopped = false;
- if (duration <= 0.0f) {
- stopped = true;
- return 0.0f;
- }
- if (time < 0.0f) return 0.0f;
- if (time < duration) return time;
-
- switch (mode) {
- case TimelineWrapMode::Once:
- stopped = true;
- return duration;
- case TimelineWrapMode::Loop:
- return std::fmod(time, duration);
- case TimelineWrapMode::PingPong: {
- f32 cycle = duration * 2.0f;
- f32 t = std::fmod(time, cycle);
- return (t <= duration) ? t : cycle - t;
- }
- default:
- stopped = true;
- return duration;
- }
-}
-
-// ---------------------------------------------------------------------------
-// Child entity resolution
-// ---------------------------------------------------------------------------
-
-Entity TimelineSystem::resolveChildEntity(
- ecs::Registry& registry, Entity root,
- const std::string& path, Instance& inst) const
-{
- if (path.empty()) return root;
-
- auto it = inst.childCache.find(path);
- if (it != inst.childCache.end()) {
- if (registry.valid(it->second)) return it->second;
- inst.childCache.erase(it);
- }
-
- Entity current = root;
- usize start = 0;
- while (start < path.size()) {
- auto slash = path.find('/', start);
- auto segment = (slash == std::string::npos)
- ? path.substr(start)
- : path.substr(start, slash - start);
- start = (slash == std::string::npos) ? path.size() : slash + 1;
-
- auto* children = registry.tryGet<ecs::Children>(current);
- if (!children) return INVALID_ENTITY;
-
- Entity found = INVALID_ENTITY;
- for (auto child : children->entities) {
- auto* name = registry.tryGet<ecs::Name>(child);
- if (name && name->value == segment) {
- found = child;
- break;
- }
- }
- if (found == INVALID_ENTITY) return INVALID_ENTITY;
- current = found;
- }
-
- inst.childCache[path] = current;
- return current;
-}
-
-// ---------------------------------------------------------------------------
-// Property apply
-// ---------------------------------------------------------------------------
-
-void TimelineSystem::applyPropertyValue(
- ecs::Registry& registry, Entity entity,
- AnimTargetField field, f32 value) const
-{
- applyAnimatedValue(registry, entity, field, value);
-}
-
-// ---------------------------------------------------------------------------
-// Evaluate property tracks
-// ---------------------------------------------------------------------------
-
-void TimelineSystem::evaluatePropertyTracks(
- ecs::Registry& registry, Entity rootEntity, Instance& inst)
-{
- f32 time = inst.currentTime;
- for (i32 ti = 0; ti < static_cast<i32>(inst.data.propertyTracks.size()); ti++) {
- const auto& track = inst.data.propertyTracks[ti];
- Entity target = track.resolvedTarget != INVALID_ENTITY
- ? track.resolvedTarget
- : resolveChildEntity(registry, rootEntity, track.childPath, inst);
- if (target == INVALID_ENTITY) continue;
-
- for (i32 ci = 0; ci < static_cast<i32>(track.channels.size()); ci++) {
- f32 value = evaluateChannel(track.channels[ci], time);
- AnimTargetField field = track.fields[ci];
-
- if (field == AnimTargetField::CustomField) {
- pendingCustomProperties_.push_back({target, ti, ci, value});
- } else {
- applyPropertyValue(registry, target, field, value);
- }
- }
- }
-}
-
-// ---------------------------------------------------------------------------
-// Evaluate event tracks
-// ---------------------------------------------------------------------------
-
-void TimelineSystem::evaluateEventTracks(
- ecs::Registry& registry, Entity rootEntity, Instance& inst)
-{
- f32 time = inst.currentTime;
- f32 prevTime = inst.previousTime;
-
- for (i32 i = 0; i < static_cast<i32>(inst.data.eventTracks.size()); i++) {
- const auto& track = inst.data.eventTracks[i];
- Entity target = track.resolvedTarget != INVALID_ENTITY
- ? track.resolvedTarget
- : resolveChildEntity(registry, rootEntity, track.childPath, inst);
- if (target == INVALID_ENTITY) continue;
-
- switch (track.type) {
- case EventTrackType::Spine: {
- i32 currentClip = -1;
- for (i32 ci = static_cast<i32>(track.spineClips.size()) - 1; ci >= 0; ci--) {
- const auto& clip = track.spineClips[ci];
- if (time >= clip.start && time < clip.start + clip.duration) {
- currentClip = ci;
- break;
- }
- }
-
- i32 prevClip = inst.spineClipIndices[i];
- if (currentClip != prevClip) {
- inst.spineClipIndices[i] = currentClip;
- if (currentClip == -1) {
- if (prevClip >= 0) {
- pendingEvents_.push_back({
- TimelineEvent::SpineStop, target, 0, 0.0f, -1
- });
- }
- } else {
- const auto& clip = track.spineClips[currentClip];
- i32 strIdx = addEventString(clip.animation);
- pendingEvents_.push_back({
- TimelineEvent::SpinePlay, target,
- clip.loop ? 1 : 0, clip.speed, strIdx
- });
- }
- }
- break;
- }
- case EventTrackType::SpriteAnim: {
- if (prevTime <= track.spriteAnimStartTime &&
- time >= track.spriteAnimStartTime && time > prevTime) {
- i32 strIdx = addEventString(track.spriteAnimClip);
- pendingEvents_.push_back({
- TimelineEvent::SpriteAnimPlay, target, 0, 0.0f, strIdx
- });
- }
- break;
- }
- case EventTrackType::Audio: {
- for (const auto& event : track.audioEvents) {
- if (event.time > prevTime && event.time <= time) {
- i32 strIdx = addEventString(event.clip);
- pendingEvents_.push_back({
- TimelineEvent::AudioPlay, target, 0, event.volume, strIdx
- });
- }
- }
- break;
- }
- case EventTrackType::Activation: {
- bool active = false;
- for (const auto& range : track.activationRanges) {
- if (time >= range.start && time < range.end) {
- active = true;
- break;
- }
- }
- pendingEvents_.push_back({
- TimelineEvent::ActivationSet, target, active ? 1 : 0, 0.0f, -1
- });
- break;
- }
- }
- }
-}
-
-// ---------------------------------------------------------------------------
-// Advance (runtime per-frame)
-// ---------------------------------------------------------------------------
-
-void TimelineSystem::advance(
- ecs::Registry& registry, TimelineHandle handle,
- Entity rootEntity, f32 deltaTime)
-{
- auto* inst = getInstance(handle);
- if (!inst || !inst->playing) return;
-
- inst->previousTime = inst->currentTime;
- inst->currentTime += deltaTime * inst->speed;
-
- bool stopped = false;
- inst->currentTime = applyWrapMode(
- inst->currentTime, inst->data.duration, inst->data.wrapMode, stopped);
-
- evaluatePropertyTracks(registry, rootEntity, *inst);
- evaluateEventTracks(registry, rootEntity, *inst);
-
- if (stopped) {
- inst->playing = false;
- }
-}
-
-// ---------------------------------------------------------------------------
-// EvaluateAt (editor scrub, evaluate only)
-// ---------------------------------------------------------------------------
-
-i32 TimelineSystem::evaluateAt(
- TimelineHandle handle, f32 time,
- f32* outValues, i32 maxChannels) const
-{
- auto* inst = getInstance(handle);
- if (!inst) return 0;
-
- i32 idx = 0;
- for (const auto& track : inst->data.propertyTracks) {
- for (const auto& channel : track.channels) {
- if (idx >= maxChannels) return idx;
- outValues[idx++] = evaluateChannel(channel, time);
- }
- }
- return idx;
-}
-
-// ---------------------------------------------------------------------------
-// Event string pool
-// ---------------------------------------------------------------------------
-
-i32 TimelineSystem::addEventString(const std::string& str) {
- auto it = stringPoolIndex_.find(str);
- if (it != stringPoolIndex_.end()) {
- return it->second;
- }
- i32 idx = static_cast<i32>(stringPool_.size());
- stringPool_.push_back(str);
- stringPoolIndex_[str] = idx;
- return idx;
-}
-
-const std::string& TimelineSystem::getEventString(i32 index) const {
- if (index < 0 || index >= static_cast<i32>(stringPool_.size())) {
- return EMPTY_STRING;
- }
- return stringPool_[index];
-}
-
-void TimelineSystem::setTrackTarget(
- TimelineHandle handle, bool isEventTrack,
- i32 trackIndex, Entity target)
-{
- auto* inst = getInstance(handle);
- if (!inst) return;
-
- if (isEventTrack) {
- if (trackIndex >= 0 && trackIndex < static_cast<i32>(inst->data.eventTracks.size())) {
- inst->data.eventTracks[trackIndex].resolvedTarget = target;
- }
- } else {
- if (trackIndex >= 0 && trackIndex < static_cast<i32>(inst->data.propertyTracks.size())) {
- inst->data.propertyTracks[trackIndex].resolvedTarget = target;
- }
- }
-}
-
-void TimelineSystem::clearPendingResults() {
- pendingEvents_.clear();
- pendingCustomProperties_.clear();
- stringPool_.clear();
- stringPoolIndex_.clear();
-}
-
-// ---------------------------------------------------------------------------
-// Instance lookup
-// ---------------------------------------------------------------------------
-
-TimelineSystem::Instance* TimelineSystem::getInstance(TimelineHandle handle) {
- auto it = instances_.find(handle);
- return (it != instances_.end()) ? &it->second : nullptr;
-}
-
-const TimelineSystem::Instance* TimelineSystem::getInstance(TimelineHandle handle) const {
- auto it = instances_.find(handle);
- return (it != instances_.end()) ? &it->second : nullptr;
-}
-
-} // namespace esengine::animation
diff --git a/src/esengine/animation/TimelineSystem.hpp b/src/esengine/animation/TimelineSystem.hpp
deleted file mode 100644
index 4c8c0efb3..000000000
--- a/src/esengine/animation/TimelineSystem.hpp
+++ /dev/null
@@ -1,115 +0,0 @@
-#pragma once
-
-#include "../core/Types.hpp"
-#include "../ecs/Registry.hpp"
-#include "TimelineData.hpp"
-
-#include <string>
-#include <unordered_map>
-#include <vector>
-
-namespace esengine::animation {
-
-using TimelineHandle = u32;
-constexpr TimelineHandle INVALID_TIMELINE = 0;
-
-struct TimelineEvent {
- enum Type : u8 {
- SpinePlay = 0,
- SpineStop,
- SpriteAnimPlay,
- AudioPlay,
- ActivationSet,
- };
-
- Type type;
- Entity targetEntity{INVALID_ENTITY};
- i32 intParam{0};
- f32 floatParam{0.0f};
- i32 stringIndex{-1};
-};
-
-struct CustomPropertyResult {
- Entity targetEntity{INVALID_ENTITY};
- i32 trackIndex{0};
- i32 channelIndex{0};
- f32 value{0.0f};
-};
-
-class TimelineSystem {
-public:
- TimelineHandle createTimeline(TimelineData&& data);
- void destroyTimeline(TimelineHandle handle);
-
- void play(TimelineHandle handle);
- void pause(TimelineHandle handle);
- void stop(TimelineHandle handle);
- void setTime(TimelineHandle handle, f32 time);
- void setSpeed(TimelineHandle handle, f32 speed);
- void setWrapMode(TimelineHandle handle, TimelineWrapMode mode);
- f32 getTime(TimelineHandle handle) const;
- bool isPlaying(TimelineHandle handle) const;
- bool isStopped(TimelineHandle handle) const;
-
- void advance(ecs::Registry& registry, TimelineHandle handle,
- Entity rootEntity, f32 deltaTime);
-
- void setTrackTarget(TimelineHandle handle, bool isEventTrack,
- i32 trackIndex, Entity target);
-
- i32 evaluateAt(TimelineHandle handle, f32 time,
- f32* outValues, i32 maxChannels) const;
-
- const std::vector<TimelineEvent>& pendingEvents() const { return pendingEvents_; }
- const std::vector<CustomPropertyResult>& pendingCustomProperties() const { return pendingCustomProperties_; }
- const std::string& getEventString(i32 index) const;
- void clearPendingResults();
-
-private:
- struct Instance {
- TimelineData data;
- f32 currentTime{0.0f};
- f32 previousTime{0.0f};
- f32 speed{1.0f};
- bool playing{false};
- std::vector<i32> spineClipIndices;
- std::unordered_map<std::string, Entity> childCache;
- };
-
- static f32 hermiteInterpolate(f32 p0, f32 p1, f32 m0, f32 m1, f32 t);
- static f32 easeIn(f32 t);
- static f32 easeOut(f32 t);
- static f32 easeInOut(f32 t);
- static f32 evaluateChannel(const TimelineChannel& channel, f32 time);
- static f32 applyWrapMode(f32 time, f32 duration, TimelineWrapMode mode, bool& stopped);
-
- Entity resolveChildEntity(ecs::Registry& registry, Entity root,
- const std::string& path, Instance& inst) const;
-
- void applyPropertyValue(ecs::Registry& registry, Entity entity,
- AnimTargetField field, f32 value) const;
-
- void evaluatePropertyTracks(ecs::Registry& registry, Entity rootEntity,
- Instance& inst);
- void evaluateEventTracks(ecs::Registry& registry, Entity rootEntity,
- Instance& inst);
-
- i32 addEventString(const std::string& str);
-
-public:
- Instance* getInstance(TimelineHandle handle);
- const Instance* getInstance(TimelineHandle handle) const;
-
-private:
-
- u32 nextHandle_{1};
- std::unordered_map<TimelineHandle, Instance> instances_;
- std::vector<TimelineEvent> pendingEvents_;
- std::vector<CustomPropertyResult> pendingCustomProperties_;
- std::vector<std::string> stringPool_;
- std::unordered_map<std::string, i32> stringPoolIndex_;
-
- static const std::string EMPTY_STRING;
-};
-
-} // namespace esengine::animation
diff --git a/src/esengine/animation/animTargets.generated.hpp b/src/esengine/animation/animTargets.generated.hpp
deleted file mode 100644
index 5378d720f..000000000
--- a/src/esengine/animation/animTargets.generated.hpp
+++ /dev/null
@@ -1,275 +0,0 @@
-#pragma once
-
-#include "../core/Types.hpp"
-#include "../ecs/Registry.hpp"
-#include "../ecs/components/BitmapText.hpp"
-#include "../ecs/components/Camera.hpp"
-#include "../ecs/components/Sprite.hpp"
-#include "../ecs/components/TilemapLayer.hpp"
-#include "../ecs/components/Transform.hpp"
-#include "../ecs/components/UIRect.hpp"
-#include "../ecs/components/UIRenderer.hpp"
-#include "../ecs/components/UIRect.hpp"
-
-#include <glm/glm.hpp>
-#include <cmath>
-
-namespace esengine::animation {
-
-enum class AnimTargetComponent : u8 {
- BitmapText = 0,
- Camera = 1,
- Sprite = 2,
- TilemapLayer = 3,
- Transform = 4,
- UIRect = 5,
- UIRenderer = 6,
- Custom = 7,
- COUNT
-};
-
-enum class AnimTargetField : u8 {
- BitmapTextColorR = 0,
- BitmapTextColorG = 1,
- BitmapTextColorB = 2,
- BitmapTextColorA = 3,
- CameraOrthoSize = 4,
- SpriteColorR = 5,
- SpriteColorG = 6,
- SpriteColorB = 7,
- SpriteColorA = 8,
- SpriteSizeX = 9,
- SpriteSizeY = 10,
- TilemapLayerTintColorR = 11,
- TilemapLayerTintColorG = 12,
- TilemapLayerTintColorB = 13,
- TilemapLayerTintColorA = 14,
- TilemapLayerOpacity = 15,
- TransformPositionX = 16,
- TransformPositionY = 17,
- TransformPositionZ = 18,
- TransformRotationZ = 19,
- TransformScaleX = 20,
- TransformScaleY = 21,
- TransformScaleZ = 22,
- UIRectAnchorMinX = 23,
- UIRectAnchorMinY = 24,
- UIRectAnchorMaxX = 25,
- UIRectAnchorMaxY = 26,
- UIRectOffsetMinX = 27,
- UIRectOffsetMinY = 28,
- UIRectOffsetMaxX = 29,
- UIRectOffsetMaxY = 30,
- UIRectPivotX = 31,
- UIRectPivotY = 32,
- UIRendererColorR = 33,
- UIRendererColorG = 34,
- UIRendererColorB = 35,
- UIRendererColorA = 36,
- CustomField = 37,
- COUNT
-};
-
-inline void applyAnimatedValue(
- ecs::Registry& registry, Entity entity,
- AnimTargetField field, f32 value)
-{
- switch (field) {
- case AnimTargetField::BitmapTextColorR:
- if (auto* c = registry.tryGet<ecs::BitmapText>(entity)) {
- c->color.r = value;
- }
- break;
- case AnimTargetField::BitmapTextColorG:
- if (auto* c = registry.tryGet<ecs::BitmapText>(entity)) {
- c->color.g = value;
- }
- break;
- case AnimTargetField::BitmapTextColorB:
- if (auto* c = registry.tryGet<ecs::BitmapText>(entity)) {
- c->color.b = value;
- }
- break;
- case AnimTargetField::BitmapTextColorA:
- if (auto* c = registry.tryGet<ecs::BitmapText>(entity)) {
- c->color.a = value;
- }
- break;
- case AnimTargetField::CameraOrthoSize:
- if (auto* c = registry.tryGet<ecs::Camera>(entity)) {
- c->orthoSize = value;
- }
- break;
- case AnimTargetField::SpriteColorR:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->color.r = value;
- }
- break;
- case AnimTargetField::SpriteColorG:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->color.g = value;
- }
- break;
- case AnimTargetField::SpriteColorB:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->color.b = value;
- }
- break;
- case AnimTargetField::SpriteColorA:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->color.a = value;
- }
- break;
- case AnimTargetField::SpriteSizeX:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->size.x = value;
- }
- break;
- case AnimTargetField::SpriteSizeY:
- if (auto* c = registry.tryGet<ecs::Sprite>(entity)) {
- c->size.y = value;
- }
- break;
- case AnimTargetField::TilemapLayerTintColorR:
- if (auto* c = registry.tryGet<ecs::TilemapLayer>(entity)) {
- c->tintColor.r = value;
- }
- break;
- case AnimTargetField::TilemapLayerTintColorG:
- if (auto* c = registry.tryGet<ecs::TilemapLayer>(entity)) {
- c->tintColor.g = value;
- }
- break;
- case AnimTargetField::TilemapLayerTintColorB:
- if (auto* c = registry.tryGet<ecs::TilemapLayer>(entity)) {
- c->tintColor.b = value;
- }
- break;
- case AnimTargetField::TilemapLayerTintColorA:
- if (auto* c = registry.tryGet<ecs::TilemapLayer>(entity)) {
- c->tintColor.a = value;
- }
- break;
- case AnimTargetField::TilemapLayerOpacity:
- if (auto* c = registry.tryGet<ecs::TilemapLayer>(entity)) {
- c->opacity = value;
- }
- break;
- case AnimTargetField::TransformPositionX:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->position.x = value;
- if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::ANIM_POS_X;
- }
- break;
- case AnimTargetField::TransformPositionY:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->position.y = value;
- if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::ANIM_POS_Y;
- }
- break;
- case AnimTargetField::TransformPositionZ:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->position.z = value;
- }
- break;
- case AnimTargetField::TransformRotationZ:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- f32 h = value * 0.5f;
- c->rotation = glm::quat(std::cos(h), 0.0f, 0.0f, std::sin(h));
- if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::ANIM_ROT_Z;
- }
- break;
- case AnimTargetField::TransformScaleX:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->scale.x = value;
- if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::ANIM_SCALE_X;
- }
- break;
- case AnimTargetField::TransformScaleY:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->scale.y = value;
- if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::ANIM_SCALE_Y;
- }
- break;
- case AnimTargetField::TransformScaleZ:
- if (auto* c = registry.tryGet<ecs::Transform>(entity)) {
- c->scale.z = value;
- }
- break;
- case AnimTargetField::UIRectAnchorMinX:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->anchorMin.x = value;
- }
- break;
- case AnimTargetField::UIRectAnchorMinY:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->anchorMin.y = value;
- }
- break;
- case AnimTargetField::UIRectAnchorMaxX:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->anchorMax.x = value;
- }
- break;
- case AnimTargetField::UIRectAnchorMaxY:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->anchorMax.y = value;
- }
- break;
- case AnimTargetField::UIRectOffsetMinX:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->offsetMin.x = value;
- }
- break;
- case AnimTargetField::UIRectOffsetMinY:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->offsetMin.y = value;
- }
- break;
- case AnimTargetField::UIRectOffsetMaxX:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->offsetMax.x = value;
- }
- break;
- case AnimTargetField::UIRectOffsetMaxY:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->offsetMax.y = value;
- }
- break;
- case AnimTargetField::UIRectPivotX:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->pivot.x = value;
- }
- break;
- case AnimTargetField::UIRectPivotY:
- if (auto* c = registry.tryGet<ecs::UIRect>(entity)) {
- c->pivot.y = value;
- }
- break;
- case AnimTargetField::UIRendererColorR:
- if (auto* c = registry.tryGet<ecs::UIRenderer>(entity)) {
- c->color.r = value;
- }
- break;
- case AnimTargetField::UIRendererColorG:
- if (auto* c = registry.tryGet<ecs::UIRenderer>(entity)) {
- c->color.g = value;
- }
- break;
- case AnimTargetField::UIRendererColorB:
- if (auto* c = registry.tryGet<ecs::UIRenderer>(entity)) {
- c->color.b = value;
- }
- break;
- case AnimTargetField::UIRendererColorA:
- if (auto* c = registry.tryGet<ecs::UIRenderer>(entity)) {
- c->color.a = value;
- }
- break;
- case AnimTargetField::CustomField:
- default:
- break;
- }
-}
-
-} // namespace esengine::animation
diff --git a/src/esengine/bindings/TimelineBindings.cpp b/src/esengine/bindings/TimelineBindings.cpp
deleted file mode 100644
index ff89ae124..000000000
--- a/src/esengine/bindings/TimelineBindings.cpp
+++ /dev/null
@@ -1,392 +0,0 @@
-#ifdef ES_ENABLE_TIMELINE
-
-#include <emscripten.h>
-#include <emscripten/bind.h>
-
-#include "ActiveContext.hpp"
-#include "../animation/TimelineSystem.hpp"
-
-#include <cstring>
-#include <string>
-
-namespace esengine {
-
-static animation::TimelineSystem* tlSys() { return activeCtx().tryGet<animation::TimelineSystem>(); }
-
-// ---------------------------------------------------------------------------
-// Create / Destroy
-// ---------------------------------------------------------------------------
-
-u32 tl_create(f32 duration, i32 wrapMode) {
- auto* sys = tlSys();
- if (!sys) return 0;
- animation::TimelineData data;
- data.duration = duration;
- data.wrapMode = static_cast<animation::TimelineWrapMode>(wrapMode);
- return sys->createTimeline(std::move(data));
-}
-
-void tl_destroy(u32 handle) {
- if (auto* sys = tlSys()) {
- sys->destroyTimeline(handle);
- }
-}
-
-// ---------------------------------------------------------------------------
-// Upload property track
-// ---------------------------------------------------------------------------
-
-void tl_addPropertyTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- i32 component,
- uintptr_t fieldsPtr, i32 channelCount,
- uintptr_t keyframeDataPtr, uintptr_t keyframeCountsPtr) {
- auto* sys = tlSys();
- if (!sys) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
- auto* fields = reinterpret_cast<const u8*>(fieldsPtr);
- auto* kfCounts = reinterpret_cast<const i32*>(keyframeCountsPtr);
- auto* kfData = reinterpret_cast<const f32*>(keyframeDataPtr);
-
- animation::PropertyTrackBinding track;
- track.childPath = std::move(childPath);
- track.component = static_cast<animation::AnimTargetComponent>(component);
-
- i32 dataOffset = 0;
- for (i32 ci = 0; ci < channelCount; ci++) {
- track.fields.push_back(static_cast<animation::AnimTargetField>(fields[ci]));
- animation::TimelineChannel channel;
- i32 count = kfCounts[ci];
- channel.keyframes.resize(count);
- for (i32 ki = 0; ki < count; ki++) {
- channel.keyframes[ki] = {
- kfData[dataOffset], kfData[dataOffset + 1],
- kfData[dataOffset + 2], kfData[dataOffset + 3],
- static_cast<animation::InterpType>(static_cast<u8>(kfData[dataOffset + 4]))
- };
- dataOffset += 5;
- }
- track.channels.push_back(std::move(channel));
- }
-
- // Access internal data through system
- // We need a way to add tracks to existing timeline
- // For simplicity, we get the instance and modify it
- // This is only called during setup, not per-frame
- auto* inst = sys->getInstance(handle);
- if (inst) {
- inst->data.propertyTracks.push_back(std::move(track));
- }
-}
-
-void tl_addCustomPropertyTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- uintptr_t componentNamePtr, i32 componentNameLen,
- uintptr_t fieldPathsPtr, uintptr_t fieldPathLensPtr,
- i32 channelCount,
- uintptr_t keyframeDataPtr, uintptr_t keyframeCountsPtr) {
- auto* sys = tlSys();
- if (!sys) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
- std::string componentName(reinterpret_cast<const char*>(componentNamePtr), componentNameLen);
- auto* pathChars = reinterpret_cast<const char*>(fieldPathsPtr);
- auto* pathLens = reinterpret_cast<const i32*>(fieldPathLensPtr);
- auto* kfCounts = reinterpret_cast<const i32*>(keyframeCountsPtr);
- auto* kfData = reinterpret_cast<const f32*>(keyframeDataPtr);
-
- animation::PropertyTrackBinding track;
- track.childPath = std::move(childPath);
- track.component = animation::AnimTargetComponent::Custom;
- track.customComponentName = std::move(componentName);
-
- i32 pathOffset = 0;
- i32 dataOffset = 0;
- for (i32 ci = 0; ci < channelCount; ci++) {
- track.fields.push_back(animation::AnimTargetField::CustomField);
- track.customFieldPaths.emplace_back(pathChars + pathOffset, pathLens[ci]);
- pathOffset += pathLens[ci];
-
- animation::TimelineChannel channel;
- i32 count = kfCounts[ci];
- channel.keyframes.resize(count);
- for (i32 ki = 0; ki < count; ki++) {
- channel.keyframes[ki] = {
- kfData[dataOffset], kfData[dataOffset + 1],
- kfData[dataOffset + 2], kfData[dataOffset + 3],
- static_cast<animation::InterpType>(static_cast<u8>(kfData[dataOffset + 4]))
- };
- dataOffset += 5;
- }
- track.channels.push_back(std::move(channel));
- }
-
- auto* inst = sys->getInstance(handle);
- if (inst) {
- inst->data.propertyTracks.push_back(std::move(track));
- }
-}
-
-// ---------------------------------------------------------------------------
-// Upload event tracks
-// ---------------------------------------------------------------------------
-
-void tl_addSpineTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- uintptr_t clipsDataPtr, uintptr_t clipAnimPtrs,
- uintptr_t clipAnimLens, i32 clipCount, f32 blendIn) {
- auto* sys = tlSys();
- if (!sys) return;
- auto* inst = sys->getInstance(handle);
- if (!inst) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
- auto* clipFloats = reinterpret_cast<const f32*>(clipsDataPtr);
- auto* animPtrs = reinterpret_cast<const uintptr_t*>(clipAnimPtrs);
- auto* animLens = reinterpret_cast<const i32*>(clipAnimLens);
-
- animation::EventTrack track;
- track.childPath = std::move(childPath);
- track.type = animation::EventTrackType::Spine;
- track.spineBlendIn = blendIn;
-
- for (i32 i = 0; i < clipCount; i++) {
- animation::SpineClipData clip;
- clip.start = clipFloats[i * 4];
- clip.duration = clipFloats[i * 4 + 1];
- clip.speed = clipFloats[i * 4 + 2];
- clip.loop = clipFloats[i * 4 + 3] > 0.5f;
- clip.animation = std::string(reinterpret_cast<const char*>(animPtrs[i]), animLens[i]);
- track.spineClips.push_back(std::move(clip));
- }
-
- inst->data.eventTracks.push_back(std::move(track));
- inst->spineClipIndices.push_back(-1);
-}
-
-void tl_addAudioTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- uintptr_t eventsFloatPtr, uintptr_t clipPtrs,
- uintptr_t clipLens, i32 eventCount) {
- auto* sys = tlSys();
- if (!sys) return;
- auto* inst = sys->getInstance(handle);
- if (!inst) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
- auto* floats = reinterpret_cast<const f32*>(eventsFloatPtr);
- auto* cPtrs = reinterpret_cast<const uintptr_t*>(clipPtrs);
- auto* cLens = reinterpret_cast<const i32*>(clipLens);
-
- animation::EventTrack track;
- track.childPath = std::move(childPath);
- track.type = animation::EventTrackType::Audio;
-
- for (i32 i = 0; i < eventCount; i++) {
- animation::AudioEventData evt;
- evt.time = floats[i * 2];
- evt.volume = floats[i * 2 + 1];
- evt.clip = std::string(reinterpret_cast<const char*>(cPtrs[i]), cLens[i]);
- track.audioEvents.push_back(std::move(evt));
- }
-
- inst->data.eventTracks.push_back(std::move(track));
-}
-
-void tl_addActivationTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- uintptr_t rangesPtr, i32 rangeCount) {
- auto* sys = tlSys();
- if (!sys) return;
- auto* inst = sys->getInstance(handle);
- if (!inst) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
- auto* floats = reinterpret_cast<const f32*>(rangesPtr);
-
- animation::EventTrack track;
- track.childPath = std::move(childPath);
- track.type = animation::EventTrackType::Activation;
-
- for (i32 i = 0; i < rangeCount; i++) {
- track.activationRanges.push_back({floats[i * 2], floats[i * 2 + 1]});
- }
-
- inst->data.eventTracks.push_back(std::move(track));
-}
-
-void tl_addSpriteAnimTrack(u32 handle, uintptr_t childPathPtr, i32 childPathLen,
- uintptr_t clipPathPtr, i32 clipPathLen, f32 startTime) {
- auto* sys = tlSys();
- if (!sys) return;
- auto* inst = sys->getInstance(handle);
- if (!inst) return;
-
- std::string childPath(reinterpret_cast<const char*>(childPathPtr), childPathLen);
-
- animation::EventTrack track;
- track.childPath = std::move(childPath);
- track.type = animation::EventTrackType::SpriteAnim;
- track.spriteAnimClip = std::string(reinterpret_cast<const char*>(clipPathPtr), clipPathLen);
- track.spriteAnimStartTime = startTime;
-
- inst->data.eventTracks.push_back(std::move(track));
-}
-
-// ---------------------------------------------------------------------------
-// Playback control
-// ---------------------------------------------------------------------------
-
-void tl_play(u32 handle) { if (auto* s = tlSys()) s->play(handle); }
-void tl_pause(u32 handle) { if (auto* s = tlSys()) s->pause(handle); }
-void tl_stop(u32 handle) { if (auto* s = tlSys()) s->stop(handle); }
-void tl_setTime(u32 handle, f32 time) { if (auto* s = tlSys()) s->setTime(handle, time); }
-void tl_setSpeed(u32 handle, f32 speed) { if (auto* s = tlSys()) s->setSpeed(handle, speed); }
-void tl_setWrapMode(u32 handle, i32 mode) { if (auto* s = tlSys()) s->setWrapMode(handle, static_cast<animation::TimelineWrapMode>(mode)); }
-f32 tl_getTime(u32 handle) { auto* s = tlSys(); return s ? s->getTime(handle) : 0.0f; }
-i32 tl_isPlaying(u32 handle) { auto* s = tlSys(); return s && s->isPlaying(handle) ? 1 : 0; }
-
-// ---------------------------------------------------------------------------
-// Advance (runtime per-frame)
-// ---------------------------------------------------------------------------
-
-void tl_advance(ecs::Registry& registry, u32 handle, u32 rootEntity, f32 deltaTime, f32 speed) {
- auto* sys = tlSys();
- if (!sys) return;
- sys->setSpeed(handle, speed);
- sys->advance(registry, handle, Entity::fromRaw(rootEntity), deltaTime);
-}
-
-// ---------------------------------------------------------------------------
-// Evaluate at time (editor scrub)
-// ---------------------------------------------------------------------------
-
-i32 tl_evaluateAt(u32 handle, f32 time, uintptr_t outPtr, i32 maxChannels) {
- auto* sys = tlSys();
- if (!sys) return 0;
- return sys->evaluateAt(handle, time, reinterpret_cast<f32*>(outPtr), maxChannels);
-}
-
-// ---------------------------------------------------------------------------
-// Read pending results
-// ---------------------------------------------------------------------------
-
-i32 tl_getEventCount() {
- auto* sys = tlSys();
- return sys ? static_cast<i32>(sys->pendingEvents().size()) : 0;
-}
-
-i32 tl_getEventType(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return -1;
- return static_cast<i32>(sys->pendingEvents()[index].type);
-}
-
-u32 tl_getEventEntity(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return INVALID_ENTITY.id();
- return sys->pendingEvents()[index].targetEntity.id();
-}
-
-i32 tl_getEventIntParam(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return 0;
- return sys->pendingEvents()[index].intParam;
-}
-
-f32 tl_getEventFloatParam(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return 0.0f;
- return sys->pendingEvents()[index].floatParam;
-}
-
-uintptr_t tl_getEventString(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return 0;
- i32 strIdx = sys->pendingEvents()[index].stringIndex;
- const auto& str = sys->getEventString(strIdx);
- return reinterpret_cast<uintptr_t>(str.c_str());
-}
-
-i32 tl_getEventStringLen(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingEvents().size())) return 0;
- i32 strIdx = sys->pendingEvents()[index].stringIndex;
- return static_cast<i32>(sys->getEventString(strIdx).size());
-}
-
-i32 tl_getCustomPropertyCount() {
- auto* sys = tlSys();
- return sys ? static_cast<i32>(sys->pendingCustomProperties().size()) : 0;
-}
-
-u32 tl_getCustomPropertyEntity(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingCustomProperties().size())) return INVALID_ENTITY.id();
- return sys->pendingCustomProperties()[index].targetEntity.id();
-}
-
-i32 tl_getCustomPropertyTrackIndex(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingCustomProperties().size())) return -1;
- return sys->pendingCustomProperties()[index].trackIndex;
-}
-
-i32 tl_getCustomPropertyChannelIndex(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingCustomProperties().size())) return -1;
- return sys->pendingCustomProperties()[index].channelIndex;
-}
-
-f32 tl_getCustomPropertyValue(i32 index) {
- auto* sys = tlSys();
- if (!sys || index < 0 || index >= static_cast<i32>(sys->pendingCustomProperties().size())) return 0.0f;
- return sys->pendingCustomProperties()[index].value;
-}
-
-void tl_clearResults() {
- if (auto* sys = tlSys()) {
- sys->clearPendingResults();
- }
-}
-
-void tl_setTrackTarget(u32 handle, i32 isEventTrack, i32 trackIndex, u32 entity) {
- auto* sys = tlSys();
- if (!sys) return;
- sys->setTrackTarget(handle, isEventTrack != 0, trackIndex, Entity::fromRaw(entity));
-}
-
-} // namespace esengine
-
-EMSCRIPTEN_BINDINGS(esengine_timeline) {
- emscripten::function("_tl_create", &esengine::tl_create);
- emscripten::function("_tl_destroy", &esengine::tl_destroy);
- emscripten::function("_tl_addPropertyTrack", &esengine::tl_addPropertyTrack);
- emscripten::function("_tl_addCustomPropertyTrack", &esengine::tl_addCustomPropertyTrack);
- emscripten::function("_tl_addSpineTrack", &esengine::tl_addSpineTrack);
- emscripten::function("_tl_addAudioTrack", &esengine::tl_addAudioTrack);
- emscripten::function("_tl_addActivationTrack", &esengine::tl_addActivationTrack);
- emscripten::function("_tl_addSpriteAnimTrack", &esengine::tl_addSpriteAnimTrack);
- emscripten::function("_tl_play", &esengine::tl_play);
- emscripten::function("_tl_pause", &esengine::tl_pause);
- emscripten::function("_tl_stop", &esengine::tl_stop);
- emscripten::function("_tl_setTime", &esengine::tl_setTime);
- emscripten::function("_tl_setSpeed", &esengine::tl_setSpeed);
- emscripten::function("_tl_setWrapMode", &esengine::tl_setWrapMode);
- emscripten::function("_tl_getTime", &esengine::tl_getTime);
- emscripten::function("_tl_isPlaying", &esengine::tl_isPlaying);
- emscripten::function("_tl_advance", &esengine::tl_advance);
- emscripten::function("_tl_evaluateAt", &esengine::tl_evaluateAt);
- emscripten::function("_tl_getEventCount", &esengine::tl_getEventCount);
- emscripten::function("_tl_getEventType", &esengine::tl_getEventType);
- emscripten::function("_tl_getEventEntity", &esengine::tl_getEventEntity);
- emscripten::function("_tl_getEventIntParam", &esengine::tl_getEventIntParam);
- emscripten::function("_tl_getEventFloatParam", &esengine::tl_getEventFloatParam);
- emscripten::function("_tl_getEventString", &esengine::tl_getEventString);
- emscripten::function("_tl_getEventStringLen", &esengine::tl_getEventStringLen);
- emscripten::function("_tl_getCustomPropertyCount", &esengine::tl_getCustomPropertyCount);
- emscripten::function("_tl_getCustomPropertyEntity", &esengine::tl_getCustomPropertyEntity);
- emscripten::function("_tl_getCustomPropertyTrackIndex", &esengine::tl_getCustomPropertyTrackIndex);
- emscripten::function("_tl_getCustomPropertyChannelIndex", &esengine::tl_getCustomPropertyChannelIndex);
- emscripten::function("_tl_getCustomPropertyValue", &esengine::tl_getCustomPropertyValue);
- emscripten::function("_tl_clearResults", &esengine::tl_clearResults);
- emscripten::function("_tl_setTrackTarget", &esengine::tl_setTrackTarget);
-}
-
-#endif // ES_ENABLE_TIMELINE
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index 71769bf52..697ed6ae8 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -45,9 +45,6 @@
#include "../ecs/components/Collider.hpp"
#include "../ecs/components/ShapeRenderer.hpp"
#include "../animation/TweenSystem.hpp"
-#ifdef ES_ENABLE_TIMELINE
-#include "../animation/TimelineSystem.hpp"
-#endif
#ifdef ES_ENABLE_PARTICLES
#include "../particle/ParticleSystem.hpp"
#endif
diff --git a/src/esengine/core/EstellaContext.cpp b/src/esengine/core/EstellaContext.cpp
index 76be5937f..f161cfd51 100644
--- a/src/esengine/core/EstellaContext.cpp
+++ b/src/esengine/core/EstellaContext.cpp
@@ -32,9 +32,6 @@
#include "../ecs/TransformSystem.hpp"
#include "../ecs/UISystem.hpp"
#include "../animation/TweenSystem.hpp"
-#ifdef ES_ENABLE_TIMELINE
-#include "../animation/TimelineSystem.hpp"
-#endif
#ifdef ES_PLATFORM_WEB
#include <emscripten/html5.h>
@@ -123,9 +120,6 @@ void EstellaContext::initSubsystems() {
// they are already present.
registerLogicSystems();
-#ifdef ES_ENABLE_TIMELINE
- services_.registerOwned<animation::TimelineSystem>(makeUnique<animation::TimelineSystem>());
-#endif
#ifdef ES_ENABLE_PARTICLES
services_.registerOwned<particle::ParticleSystem>(makeUnique<particle::ParticleSystem>());
#endif
diff --git a/tools/eht/__main__.py b/tools/eht/__main__.py
index 005d7c70c..c15e50ac3 100644
--- a/tools/eht/__main__.py
+++ b/tools/eht/__main__.py
@@ -8,7 +8,7 @@ from .parser import CppParser
from .abi import compute_abi_hash
from .generators import (
EmbindGenerator, TypeScriptGenerator, MetadataGenerator,
- AnimTargetGenerator, PtrLayoutGenerator, EditorAPIGenerator,
+ PtrLayoutGenerator, EditorAPIGenerator,
)
@@ -99,15 +99,6 @@ def main() -> int:
meta_gen = MetadataGenerator(cpp_parser.components, cpp_parser.enums, abi_hash=abi_hash)
write_ts('component.generated.ts', meta_gen.generate())
- # ── Animation Targets ──
- anim_gen = AnimTargetGenerator(cpp_parser.components, cpp_parser.enums)
-
- anim_hpp_path = Path('src/esengine/animation') / 'animTargets.generated.hpp'
- print(f"Generating: {anim_hpp_path}")
- anim_hpp_path.write_text(anim_gen.generate_hpp(), encoding='utf-8')
-
- write_ts('timeline/animTargets.generated.ts', anim_gen.generate_ts())
-
# ── Pointer Layouts & Accessors ──
write_ts('ptrLayouts.generated.ts', ptr_gen.generate())
write_ts('ecs/ptrAccessors.generated.ts', ptr_gen.generate_accessors())
diff --git a/tools/eht/generators/__init__.py b/tools/eht/generators/__init__.py
index 3e9fecff7..bf7444247 100644
--- a/tools/eht/generators/__init__.py
+++ b/tools/eht/generators/__init__.py
@@ -3,11 +3,10 @@
from .embind import EmbindGenerator
from .typescript import TypeScriptGenerator
from .metadata import MetadataGenerator
-from .anim_target import AnimTargetGenerator
from .ptr_layout import PtrLayoutGenerator
from .editor_api import EditorAPIGenerator
__all__ = [
'EmbindGenerator', 'TypeScriptGenerator', 'MetadataGenerator',
- 'AnimTargetGenerator', 'PtrLayoutGenerator', 'EditorAPIGenerator',
+ 'PtrLayoutGenerator', 'EditorAPIGenerator',
]
diff --git a/tools/eht/generators/anim_target.py b/tools/eht/generators/anim_target.py
deleted file mode 100644
index 2f5b0df2f..000000000
--- a/tools/eht/generators/anim_target.py
+++ /dev/null
@@ -1,223 +0,0 @@
-from typing import Dict, List, Set
-from ..data import Component, Enum
-from ..type_system import TypeSystem
-from ..field_utils import is_color_field, COLOR_FIELD_PATTERNS
-
-
-class AnimTargetGenerator:
- """Generates animation target enum, apply function, and TS mappings."""
-
- # Sub-component expansions per GLM type
- VEC2_SUBS = [('x', 'x'), ('y', 'y')]
- VEC3_SUBS = [('x', 'x'), ('y', 'y'), ('z', 'z')]
- VEC4_COLOR_SUBS = [('r', 'r'), ('g', 'g'), ('b', 'b'), ('a', 'a')]
- QUAT_SUBS = [('z', 'z')]
-
- # UIRect anim_override flags per sub-component label
- OVERRIDE_FLAGS = {
- 'position': {'x': 'ANIM_POS_X', 'y': 'ANIM_POS_Y'},
- 'scale': {'x': 'ANIM_SCALE_X', 'y': 'ANIM_SCALE_Y'},
- 'rotation': {'z': 'ANIM_ROT_Z'},
- }
-
- def __init__(self, components: List[Component], enums: List[Enum]):
- self.components = components
- self.types = TypeSystem(enums)
- self.entries: List[Dict] = []
- self._collect()
-
- def _collect(self):
- for comp in self.components:
- for prop in comp.properties:
- if 'animatable' not in prop.annotations:
- continue
- t = self.types.clean_type(prop.cpp_type)
- has_override = 'anim_override' in prop.annotations
- is_color = any(pat in prop.name for pat in COLOR_FIELD_PATTERNS)
-
- if t == 'glm::vec2':
- subs = self.VEC2_SUBS
- elif t == 'glm::vec3':
- subs = self.VEC3_SUBS
- elif t == 'glm::vec4':
- subs = self.VEC4_COLOR_SUBS if is_color else [('x', 'x'), ('y', 'y'), ('z', 'z'), ('w', 'w')]
- elif t == 'glm::quat':
- subs = self.QUAT_SUBS
- else:
- subs = [('', '')]
-
- for sub_label, sub_member in subs:
- enum_name = self._make_enum_name(comp.name, prop.name, sub_label)
- field_path = f'{prop.name}.{sub_label}' if sub_label else prop.name
- cpp_member = f'{prop.name}.{sub_member}' if sub_member else prop.name
-
- override_flag = None
- if has_override:
- flags = self.OVERRIDE_FLAGS.get(prop.name, {})
- override_flag = flags.get(sub_label)
-
- self.entries.append({
- 'enum_name': enum_name,
- 'comp_name': comp.name,
- 'field_path': field_path,
- 'cpp_member': cpp_member,
- 'cpp_type': t,
- 'is_quat_z': t == 'glm::quat' and sub_label == 'z',
- 'override_flag': override_flag,
- })
-
- @staticmethod
- def _make_enum_name(comp: str, field: str, sub: str) -> str:
- parts = [comp, field[0].upper() + field[1:]]
- if sub:
- parts.append(sub.upper())
- return ''.join(parts)
-
- def generate_hpp(self) -> str:
- lines = [
- '#pragma once',
- '',
- '#include "../core/Types.hpp"',
- '#include "../ecs/Registry.hpp"',
- ]
-
- includes = set()
- for e in self.entries:
- includes.add(e['comp_name'])
- for comp in self.components:
- if comp.name in includes:
- lines.append(f'#include "../ecs/components/{comp.name}.hpp"')
- has_override = any(e['override_flag'] for e in self.entries)
- if has_override:
- lines.append('#include "../ecs/components/UIRect.hpp"')
-
- lines.extend([
- '',
- '#include <glm/glm.hpp>',
- '#include <cmath>',
- '',
- 'namespace esengine::animation {',
- '',
- ])
-
- comp_names = []
- seen_comps: Set[str] = set()
- for e in self.entries:
- if e['comp_name'] not in seen_comps:
- seen_comps.add(e['comp_name'])
- comp_names.append(e['comp_name'])
-
- lines.append('enum class AnimTargetComponent : u8 {')
- for i, name in enumerate(comp_names):
- lines.append(f' {name} = {i},')
- lines.extend([
- f' Custom = {len(comp_names)},',
- ' COUNT',
- '};',
- '',
- 'enum class AnimTargetField : u8 {',
- ])
-
- for i, e in enumerate(self.entries):
- lines.append(f' {e["enum_name"]} = {i},')
-
- lines.extend([
- f' CustomField = {len(self.entries)},',
- ' COUNT',
- '};',
- '',
- 'inline void applyAnimatedValue(',
- ' ecs::Registry& registry, Entity entity,',
- ' AnimTargetField field, f32 value)',
- '{',
- ' switch (field) {',
- ])
-
- for e in self.entries:
- lines.append(f' case AnimTargetField::{e["enum_name"]}:')
- comp_cpp = f'ecs::{e["comp_name"]}'
- if e['is_quat_z']:
- lines.append(f' if (auto* c = registry.tryGet<{comp_cpp}>(entity)) {{')
- lines.append(' f32 h = value * 0.5f;')
- lines.append(f' c->{e["cpp_member"].rsplit(".", 1)[0]} = glm::quat(std::cos(h), 0.0f, 0.0f, std::sin(h));')
- if e['override_flag']:
- lines.append(f' if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::{e["override_flag"]};')
- lines.append(' }')
- else:
- lines.append(f' if (auto* c = registry.tryGet<{comp_cpp}>(entity)) {{')
- lines.append(f' c->{e["cpp_member"]} = value;')
- if e['override_flag']:
- lines.append(f' if (auto* r = registry.tryGet<ecs::UIRect>(entity)) r->anim_override_ |= ecs::UIRect::{e["override_flag"]};')
- lines.append(' }')
- lines.append(' break;')
-
- lines.extend([
- ' case AnimTargetField::CustomField:',
- ' default:',
- ' break;',
- ' }',
- '}',
- '',
- '} // namespace esengine::animation',
- '',
- ])
- return '\n'.join(lines)
-
- def generate_ts(self) -> str:
- lines = [
- '/**',
- ' * @file animTargets.generated.ts',
- ' * @brief Auto-generated animation target mappings',
- ' * @details Generated by EHT - DO NOT EDIT',
- ' */',
- '',
- 'export enum AnimTargetField {',
- ]
-
- for i, e in enumerate(self.entries):
- lines.append(f' {e["enum_name"]} = {i},')
-
- lines.extend([
- f' CustomField = {len(self.entries)},',
- '}',
- '',
- 'export enum AnimTargetComponent {',
- ])
-
- comp_names = []
- seen = set()
- for e in self.entries:
- if e['comp_name'] not in seen:
- seen.add(e['comp_name'])
- comp_names.append(e['comp_name'])
- for i, name in enumerate(comp_names):
- lines.append(f' {name} = {i},')
- lines.extend([
- f' Custom = {len(comp_names)},',
- '}',
- '',
- 'export const FIELD_MAP: Record<string, Record<string, AnimTargetField>> = {',
- ])
-
- by_comp: Dict[str, List[Dict]] = {}
- for e in self.entries:
- by_comp.setdefault(e['comp_name'], []).append(e)
-
- for comp_name, entries in by_comp.items():
- lines.append(f' {comp_name}: {{')
- for e in entries:
- lines.append(f" '{e['field_path']}': AnimTargetField.{e['enum_name']},")
- lines.append(' },')
-
- lines.extend([
- '};',
- '',
- 'export const COMPONENT_MAP: Record<string, AnimTargetComponent> = {',
- ])
- for name in comp_names:
- lines.append(f' {name}: AnimTargetComponent.{name},')
- lines.extend([
- '};',
- '',
- ])
- return '\n'.join(lines)