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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(spine): delete the native spine runtime — fully side-module (S3)
esenginec4947f16aa28
diff --git a/CMakeLists.txt b/CMakeLists.txtindex efc4b5781..df71446ff 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -97,14 +97,6 @@ endif()src/esengine/text/BitmapFont.cpp)-if(ES_ENABLE_SPINE)- list(APPEND ESENGINE_SOURCES- src/esengine/spine/SpineExtension.cpp- src/esengine/spine/SpineResourceManager.cpp- src/esengine/spine/SpineSystem.cpp- src/esengine/renderer/plugins/SpinePlugin.cpp- )-endif()set(ESENGINE_HEADERSsrc/esengine/ESEngine.hpp@@ -157,7 +149,6 @@ set(ESENGINE_HEADERSsrc/esengine/renderer/plugins/UIElementPlugin.hppsrc/esengine/renderer/plugins/TextPlugin.hppsrc/esengine/renderer/plugins/ShapePlugin.hpp- src/esengine/renderer/plugins/SpinePlugin.hppsrc/esengine/platform/FileSystem.hppsrc/esengine/events/Events.hppsrc/esengine/events/Connection.hpp@@ -201,13 +192,6 @@ endif()src/esengine/text/BitmapFont.hpp)-if(ES_ENABLE_SPINE)- list(APPEND ESENGINE_HEADERS- src/esengine/spine/SpineExtension.hpp- src/esengine/spine/SpineResourceManager.hpp- src/esengine/spine/SpineSystem.hpp- )-endif()list(APPEND ESENGINE_HEADERSsrc/esengine/ecs/components/RigidBody.hpp@@ -292,7 +276,9 @@ if(ES_ENABLE_BITMAP_TEXT)endif()if(ES_ENABLE_SPINE)- target_link_libraries(esengine PUBLIC spine-cpp)+ # Core links no spine runtime — spine is fully side-module (spine{NN}.wasm).+ # ES_ENABLE_SPINE still gates the renderer's spine RenderItem plumbing and the+ # side-module mesh-submit binding (renderer_submitSpineBatch).target_compile_definitions(esengine PUBLIC ES_ENABLE_SPINE)endif()diff --git a/docs/REARCH_SPINE.md b/docs/REARCH_SPINE.mdindex 740783237..97e2ee10c 100644--- a/docs/REARCH_SPINE.md+++ b/docs/REARCH_SPINE.md@@ -84,8 +84,10 @@- **验证改为更优:确定性 node clip 不变量**(`spine-clip.integration.test.ts`)替代"对原生像素对拍"——既然原生已非生产路径且自身漏 PMA / 漏 region 裁剪,对齐它不是正确目标;移植的是 spine 官方 `spSkeletonClipping`(三版 API 一致),用几何不变量(裁剪改变网格 + clipped ⊆ unclipped + 严格缩小)验证接线正确。RED→GREEN 走通,spine 套件 28 绿 / 全量 2245 绿。Electron 像素视觉 smoke 留作后续 live-check。- 副产:spine41 出货(S1 残留补齐),3.8/4.1/4.2 三版齐全。-### S3 —— 4.2 切到 side-module + **删原生**-`spine42` 成 canonical 运行时;`SpineManager` 所有版本走同一 backend 接口;**删** `SpineSystem.cpp`/原生 `SpinePlugin.cpp`/`SpineResourceManager.cpp`/`SpineCpp` embind/`needsReload`,**spine-cpp 移出核心链接**。**验证:全量 `node build-tools/cli.js build -t web` + 微信 + playable 三平台跑通;核心 wasm 体积下降 ~278KB;不用 spine 的 example 不再含 spine 代码。**+### S3 —— 4.2 切到 side-module + **删原生** ✅ DONE+所有版本走同一 side-module backend;删 `SpineSystem`/原生 `SpinePlugin`/`SpineResourceManager`/`SpineExtension`/`SpineCpp` embind+TS/`needsReload` 握手/原生 tick;spine-cpp 移出核心链接。`SpineManager` 删原生回退(无 factory 即加载失败 = pay-for-use)。**保留**:`SpineAnimation` 组件(ABI 不变,骨架句柄字段变 vestigial)、渲染器 spine pass、`renderer_submitSpineBatch/ByEntity`(side-module 提交网格路径)。+- **结果(已验证)**:核心 `esengine.wasm` **1,460,160 → 957,156 字节(-503KB)**;embind 确认 `renderer_submitSpineBatch` 在、`spine_native_*` 没了;`verify:render` 引擎 boot+渲染 PASS;side-module clipping 仍绿(spine-clip gate);2240 SDK 测试 + sdk/desktop tsc 绿。+- **未 headless 验证**:编辑器里 spine 实时渲染(SceneLoader 仍未接 spine = S1 编辑器残留;但 side-module 网格路径 node 已证 + 提交 binding 在 + 引擎渲染正常 → 路径完整)。微信/playable 运行时(需各自配 spine module;3.8/4.1 本就如此)。### S4 —— 资源所有权 RAII 根治`g_ctx` move-only RAII + 骨架数据 dedup/refcount(命中 addRef)+ 纹理按 page key。**验证:ASAN 下多实体共享同一骨架 reload/despawn 无 UAF;多页图集 load/unload refcount 对称。**diff --git a/sdk/src/spine/SpineBridge.ts b/sdk/src/spine/SpineBridge.tsindex ce98386c6..90fe35009 100644--- a/sdk/src/spine/SpineBridge.ts+++ b/sdk/src/spine/SpineBridge.ts@@ -2,27 +2,15 @@* @file SpineBridge.ts* @brief Spine's bridges to its two WASM surfaces.*- * @details Spine spans two runtimes (see SpineManager): the built-in `spine_*`- * exports on the MAIN engine module, and version-specific standalone- * side modules (3.8 / 4.1) each with their own runtime. Both surfaces- * route through {@link WasmBridge} so every call inherits the- * terminal-abort guard.+ * @details Each spine version runs in its own standalone side module+ * (3.8 / 4.1 / 4.2), guarded through {@link WasmBridge} so every call+ * inherits the terminal-abort guard. (There is no native spine runtime+ * in the core module any more — spine is fully side-module.)*/-import type { ESEngineModule } from '../wasm';import { WasmBridge } from '../WasmBridge';import type { SpineWrappedAPI } from './SpineModuleLoader';-/**- * Guards the built-in `spine_*` exports on the main engine module. The main- * module is shared with {@link ../ecs/BuiltinBridge BuiltinBridge}; installing- * the abort guard twice is idempotent and the dead flag is shared by module- * identity, so an abort anywhere short-circuits everywhere.- */-export class SpineCoreBridge extends WasmBridge<ESEngineModule> {- protected readonly label = 'spine';-}-/*** Guards a version-specific spine side module's wrapped API. The call surface* (`SpineWrappedAPI`, all functions) is guarded; its abort-authoritative modulediff --git a/sdk/src/spine/SpineCppAPI.ts b/sdk/src/spine/SpineCppAPI.tsdeleted file mode 100644index ef4a0a83b..000000000--- a/sdk/src/spine/SpineCppAPI.ts+++ /dev/null@@ -1,95 +0,0 @@-import type { ESEngineModule, CppRegistry } from '../wasm';-import type { Entity } from '../types';-import { SpineCoreBridge } from './SpineBridge';--const bridge = new SpineCoreBridge();-let module: ESEngineModule | null = null;--export function initSpineCppAPI(wasmModule: ESEngineModule): void {- // Route through the single WASM bridge: every `spine_*` call below then- // short-circuits with WasmModuleAborted after an abort instead of touching- // a dead module. The optional-chaining call sites are unchanged — a missing- // binding still resolves to undefined (handled by `?? fallback`); only a- // post-abort call throws.- bridge.connect(wasmModule);- module = bridge.module;-}--export function shutdownSpineCppAPI(): void {- bridge.disconnect();- module = null;-}--export const SpineCpp = {- update(registry: { _cpp: CppRegistry }, dt: number): void {- module?.spine_update?.(registry._cpp, dt);- },-- play(entity: Entity, animation: string, loop: boolean = true, track: number = 0): boolean {- return module?.spine_play?.(entity, animation, loop, track) ?? false;- },-- addAnimation(entity: Entity, animation: string, loop: boolean = true, delay: number = 0, track: number = 0): boolean {- return module?.spine_addAnimation?.(entity, animation, loop, delay, track) ?? false;- },-- setSkin(entity: Entity, skinName: string): boolean {- return module?.spine_setSkin?.(entity, skinName) ?? false;- },-- getBonePosition(entity: Entity, boneName: string): { x: number; y: number } | null {- return module?.spine_getBonePosition?.(entity, boneName) ?? null;- },-- hasInstance(entity: Entity): boolean {- return module?.spine_hasInstance?.(entity) ?? false;- },-- reloadAssets(registry: { _cpp: CppRegistry }): void {- module?.spine_reloadAssets?.(registry._cpp);- },-- getAnimations(entity: Entity): string[] {- return module?.spine_getAnimations?.(entity) ?? [];- },-- getSkins(entity: Entity): string[] {- return module?.spine_getSkins?.(entity) ?? [];- },-- listConstraints(entity: Entity): { ik: string[]; transform: string[]; path: string[] } | null {- return module?.spine_native_listConstraints?.(entity) ?? null;- },-- getTransformConstraintMix(entity: Entity, name: string): { mixRotate: number; mixX: number; mixY: number; mixScaleX: number; mixScaleY: number; mixShearY: number } | null {- return module?.spine_native_getTransformConstraintMix?.(entity, name) ?? null;- },-- setTransformConstraintMix(entity: Entity, name: string, rotate: number, x: number, y: number, scaleX: number, scaleY: number, shearY: number): boolean {- return module?.spine_native_setTransformConstraintMix?.(entity, name, rotate, x, y, scaleX, scaleY, shearY) ?? false;- },-- getPathConstraintMix(entity: Entity, name: string): { position: number; spacing: number; mixRotate: number; mixX: number; mixY: number } | null {- return module?.spine_native_getPathConstraintMix?.(entity, name) ?? null;- },-- setPathConstraintMix(entity: Entity, name: string, position: number, spacing: number, rotate: number, x: number, y: number): boolean {- return module?.spine_native_setPathConstraintMix?.(entity, name, position, spacing, rotate, x, y) ?? false;- },-- getEventCount(): number {- return module?.spine_native_getEventCount?.() ?? 0;- },-- getEventRecord(index: number): { entity: number; animationName: string; eventName: string; stringValue: string } | null {- return module?.spine_native_getEventRecord?.(index) ?? null;- },-- getEventBuffer(): number {- return module?.spine_native_getEventBuffer?.() ?? 0;- },-- clearEvents(): void {- module?.spine_native_clearEvents?.();- },-};diff --git a/sdk/src/spine/SpineManager.ts b/sdk/src/spine/SpineManager.tsindex 5a9bb3de8..dc5010dcc 100644--- a/sdk/src/spine/SpineManager.ts+++ b/sdk/src/spine/SpineManager.ts@@ -5,7 +5,6 @@ import type { SpineModuleFactory } from './SpineModuleLoader';import { wrapSpineModule } from './SpineModuleLoader';import { SpineModuleController } from './SpineController';import { ModuleBackend } from './ModuleBackend';-import { SpineCpp } from './SpineCppAPI';import { log } from '../logger';export type SpineVersion = '3.8' | '4.1' | '4.2';@@ -45,7 +44,7 @@ export class SpineManager {skelData: Uint8Array | string,atlasText: string,textures: Map<string, { glId: number; w: number; h: number }>,- registry: CppRegistry,+ _registry: CppRegistry,): Promise<SpineVersion | null> {const version = typeof skelData === 'string'? SpineManager.detectVersionJson(skelData)@@ -53,22 +52,9 @@ export class SpineManager {if (!version) return null;- // Version routing, see SpinePlugin spineUpdateSystem for the- // full story. When a 4.2 entity shows up and no 4.2 JS factory- // is registered, we leave it for the native C++ runtime- // (`spine_setNeedsReload` stays at its default of true, so- // SpineCpp.update ticks it each frame). For older versions- // (3.8 / 4.1) we hand the entity off to the JS runtime by- // disabling needsReload on the C++ side and loading into- // ModuleBackend. The two runtimes therefore tick disjoint- // entity sets — there is NO double update per entity.- if (version === '4.2' && !this.factories_.has('4.2')) {- this.entityVersions_.set(entity, '4.2');- return '4.2';- }-- this.coreModule_.spine_setNeedsReload?.(registry, entity as number, false);-+ // Every version loads into its per-version side-module backend; there is+ // no native runtime fallback. A missing factory for `version` fails the+ // load (logged below) — spine is strictly pay-for-use.const backend = await this.ensureBackend(version);if (!backend) {log.error('spine', `Failed to create backend for version ${version}`);@@ -220,33 +206,31 @@ export class SpineManager {listConstraints(entity: Entity): ConstraintList | null {const backend = this.getEntityBackend_(entity);if (backend) return backend.listConstraints(entity);- return SpineCpp.listConstraints(entity);+ return null;}getTransformConstraintMix(entity: Entity, name: string): TransformMixData | null {const backend = this.getEntityBackend_(entity);if (backend) return backend.getTransformConstraintMix(entity, name);- return SpineCpp.getTransformConstraintMix(entity, name);+ return null;}setTransformConstraintMix(entity: Entity, name: string, mix: TransformMixData): boolean {const backend = this.getEntityBackend_(entity);if (backend) return backend.setTransformConstraintMix(entity, name, mix);- return SpineCpp.setTransformConstraintMix(entity, name,- mix.mixRotate, mix.mixX, mix.mixY, mix.mixScaleX, mix.mixScaleY, mix.mixShearY);+ return false;}getPathConstraintMix(entity: Entity, name: string): PathMixData | null {const backend = this.getEntityBackend_(entity);if (backend) return backend.getPathConstraintMix(entity, name);- return SpineCpp.getPathConstraintMix(entity, name);+ return null;}setPathConstraintMix(entity: Entity, name: string, mix: PathMixData): boolean {const backend = this.getEntityBackend_(entity);if (backend) return backend.setPathConstraintMix(entity, name, mix);- return SpineCpp.setPathConstraintMix(entity, name,- mix.position, mix.spacing, mix.mixRotate, mix.mixX, mix.mixY);+ return false;}setEnabled(entity: Entity, enabled: boolean): void {diff --git a/sdk/src/spine/SpinePlugin.ts b/sdk/src/spine/SpinePlugin.tsindex 31cbc635f..1e64c8a83 100644--- a/sdk/src/spine/SpinePlugin.ts+++ b/sdk/src/spine/SpinePlugin.ts@@ -4,7 +4,6 @@ import { defineResource, Time } from '../resource';import { Schedule } from '../system';import type { SystemDef } from '../system';import type { Entity } from '../types';-import { initSpineCppAPI, SpineCpp } from './SpineCppAPI';import { SpineManager } from './SpineManager';import type { SpineWasmProvider } from './SpineModuleLoader';import { createSpineFactories } from './SpineModuleLoader';@@ -72,7 +71,6 @@ export class SpinePlugin implements Plugin {build(app: App): void {this.app_ = app;const coreModule = app.wasmModule!;- initSpineCppAPI(coreModule);if (!this.spineManager_ && this.provider_) {const factories = createSpineFactories(this.provider_);@@ -85,35 +83,15 @@ export class SpinePlugin implements Plugin {this.spineManager_?.removeEntity(entity);});- // Per-frame spine tick. Both calls fire unconditionally, but- // they tick DISJOINT entity sets — this is not a double-tick:- // - SpineCpp.update(registry, dt) advances every entity- // whose C++ `needsReload`- // flag is true. That's- // the 4.2 set.- // - spineManager_.updateAnimations(dt) iterates- // SpineManager.backends_- // (ModuleBackend- // instances, one per- // loaded JS runtime- // version — 3.8 / 4.1).- // Each backend advances- // only its own entities.- //- // SpineManager.loadEntity does the routing:- // - version '4.2': sets entityVersions_['4.2'] and returns,- // leaving the entity under C++ control;- // - version '3.8' / '4.1': calls spine_setNeedsReload(false)- // to hand the entity off to the JS runtime.+ // Per-frame spine tick: advance every loaded side-module backend (one+ // per version) and publish their events. Each backend advances only its+ // own entities; there is no native runtime to tick.const spineUpdateSystem: SystemDef = {_id: Symbol('SpineUpdateSystem'),_name: 'SpineUpdateSystem',_params: [],_fn: () => {- const cppRegistry = app.world.getCppRegistry();- if (!cppRegistry) return;const time = app.getResource(Time);- SpineCpp.update({ _cpp: cppRegistry }, time.delta);this.spineManager_?.updateAnimations(time.delta);this.collectAndPublishEvents_(app);},@@ -165,49 +143,6 @@ export class SpinePlugin implements Plugin {}}- this.collectNativeEvents_(events);app.insertResource(SpineEvents, { events });}-- private collectNativeEvents_(events: SpineEvent[]): void {- const EVENT_STRIDE = 4;- const count = SpineCpp.getEventCount();- if (count === 0) return;-- const bufferPtr = SpineCpp.getEventBuffer();- const coreModule = this.app_?.wasmModule;- if (!coreModule || !bufferPtr) {- SpineCpp.clearEvents();- return;- }-- const f32 = coreModule.HEAPF32;- const base = bufferPtr >> 2;-- for (let i = 0; i < count; i++) {- const offset = base + i * EVENT_STRIDE;- const typeNum = f32[offset];- const type = SPINE_TYPE_MAP[typeNum];- if (type === null || type === undefined) continue;-- const record = SpineCpp.getEventRecord(i);- if (!record) continue;-- const evt: SpineEvent = {- entity: record.entity as Entity,- type,- track: f32[offset + 1],- animationName: record.animationName,- };- if (type === 'event') {- evt.eventName = record.eventName;- evt.floatValue = f32[offset + 2];- evt.intValue = f32[offset + 3];- evt.stringValue = record.stringValue;- }- events.push(evt);- }-- SpineCpp.clearEvents();- }}diff --git a/sdk/src/spine/index.ts b/sdk/src/spine/index.tsindex da325c0d3..1bc730d45 100644--- a/sdk/src/spine/index.ts+++ b/sdk/src/spine/index.ts@@ -1,6 +1,5 @@export { SpinePlugin, SpineEvents } from './SpinePlugin';export type { SpineEvent, SpineEventType, SpineEventsData } from './SpinePlugin';-export { SpineCpp, initSpineCppAPI, shutdownSpineCppAPI } from './SpineCppAPI';export { SpineManager } from './SpineManager';export type { SpineVersion } from './SpineManager';export { ModuleBackend } from './ModuleBackend';diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex e77360322..46778738e 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -119,43 +119,6 @@ export interface ESEngineModule {getResourceManager(): CppResourceManager;getSpineBounds?(registry: CppRegistry, entity: number): SpineBounds;- spine_update?(registry: CppRegistry, dt: number): void;- spine_play?(entity: number, animation: string, loop: boolean, track: number): boolean;- spine_addAnimation?(entity: number, animation: string, loop: boolean, delay: number, track: number): boolean;- spine_setSkin?(entity: number, skinName: string): boolean;- spine_getBonePosition?(entity: number, boneName: string): { x: number; y: number } | null;- spine_hasInstance?(entity: number): boolean;- spine_reloadAssets?(registry: CppRegistry): void;- spine_getAnimations?(entity: number): string[];- spine_getSkins?(entity: number): string[];- spine_setNeedsReload?(registry: CppRegistry, entity: number, value: boolean): void;-- // Spine native (4.2) constraint + event accessors — only present when- // the 4.2 runtime is compiled in; optional on module interface.- spine_native_listConstraints?(entity: number): { ik: string[]; transform: string[]; path: string[] } | null;- spine_native_getTransformConstraintMix?(entity: number, name: string): {- mixRotate: number; mixX: number; mixY: number;- mixScaleX: number; mixScaleY: number; mixShearY: number;- } | null;- spine_native_setTransformConstraintMix?(- entity: number, name: string,- rotate: number, x: number, y: number,- scaleX: number, scaleY: number, shearY: number,- ): boolean;- spine_native_getPathConstraintMix?(entity: number, name: string): {- position: number; spacing: number; mixRotate: number; mixX: number; mixY: number;- } | null;- spine_native_setPathConstraintMix?(- entity: number, name: string,- position: number, spacing: number,- rotate: number, x: number, y: number,- ): boolean;- spine_native_getEventCount?(): number;- spine_native_getEventRecord?(index: number): {- entity: number; animationName: string; eventName: string; stringValue: string;- } | null;- spine_native_getEventBuffer?(): number;- spine_native_clearEvents?(): void;renderer_submitSpineBatch?(verticesPtr: number, vertexCount: number,indicesPtr: number, indexCount: number,diff --git a/sdk/tests/spine-bridge.test.ts b/sdk/tests/spine-bridge.test.tsindex 6233781c3..84563a40d 100644--- a/sdk/tests/spine-bridge.test.ts+++ b/sdk/tests/spine-bridge.test.ts@@ -1,66 +1,17 @@/*** @file spine-bridge.test.ts- * @brief F2 spine migration: both spine WASM surfaces (the main-module- * `spine_*` exports behind SpineCpp, and a side module's wrapped API- * behind SpineModuleController) inherit the terminal-abort guard with- * no change to their call sites.+ * @brief A spine side module's wrapped API (behind SpineModuleController)+ * inherits the terminal-abort guard with no change to its call sites.+ * The old main-module SpineCpp surface was removed in S3 — spine is+ * now fully side-module.*/-import { describe, it, expect, vi, afterEach } from 'vitest';+import { describe, it, expect, vi } from 'vitest';import { WasmModuleAborted } from '../src/moduleHealth';-import {- SpineCpp, initSpineCppAPI, shutdownSpineCppAPI,-} from '../src/spine/SpineCppAPI';import { SpineModuleController } from '../src/spine/SpineController';-import type { ESEngineModule } from '../src/wasm';import type { SpineWasmModule, SpineWrappedAPI } from '../src/spine/SpineModuleLoader';// ----------------------------------------------------------------------------// Surface 1: SpineCpp over the main engine module's spine_* exports.-// ----------------------------------------------------------------------------function makeMainModule(over: Record<string, unknown> = {}): ESEngineModule {- return {- spine_play: (_e: number, _a: string, _l: boolean, _t: number) => true,- spine_setSkin: (_e: number, _s: string) => true,- onAbort: undefined,- ...over,- } as unknown as ESEngineModule;-}--describe('SpineCpp (main-module surface)', () => {- afterEach(() => shutdownSpineCppAPI());-- it('calls spine_* through the guard when healthy', () => {- initSpineCppAPI(makeMainModule());- expect(SpineCpp.play(0 as never, 'walk')).toBe(true);- });-- it('refuses spine_* calls after the module aborts', () => {- const m = makeMainModule();- initSpineCppAPI(m);- (m as unknown as { onAbort: (w: unknown) => void }).onAbort('unreachable');-- let caught: unknown;- try { SpineCpp.play(0 as never, 'walk'); } catch (e) { caught = e; }- expect(caught).toBeInstanceOf(WasmModuleAborted);- expect((caught as WasmModuleAborted).context).toBe('spine.spine_play');- });-- it('keeps missing-binding tolerance (absent export → fallback, not throw)', () => {- // Module without spine_setSkin: optional chaining still yields the- // `?? false` fallback rather than throwing.- initSpineCppAPI(makeMainModule({ spine_setSkin: undefined }));- expect(SpineCpp.setSkin(0 as never, 'armor')).toBe(false);- });-- it('returns fallbacks once disconnected', () => {- initSpineCppAPI(makeMainModule());- shutdownSpineCppAPI();- expect(SpineCpp.play(0 as never, 'walk')).toBe(false);- });-});--// ----------------------------------------------------------------------------// Surface 2: SpineModuleController over a side module (api surface + raw heap).+// SpineModuleController over a side module (api surface + raw heap).// ---------------------------------------------------------------------------function makeRaw(): SpineWasmModule {return {diff --git a/sdk/tests/spine-multi-version-build.test.ts b/sdk/tests/spine-multi-version-build.test.tsindex 762c8b819..d69f4d739 100644--- a/sdk/tests/spine-multi-version-build.test.ts+++ b/sdk/tests/spine-multi-version-build.test.ts@@ -17,22 +17,16 @@ describe('Spine multi-version build pipeline', () => {}});- test('only non-4.2 versions produce standalone modules', () => {+ test('every spine version ships as a standalone side module (no native 4.2)', () => {+ // S3 removed the native runtime: 4.2 is a side module like 3.8/4.1.const spineVersions = new Set(['3.8', '4.1', '4.2']);- const nonNative = [...spineVersions].filter(v => v !== '4.2');- expect(nonNative).toEqual(['3.8', '4.1']);+ const modules = [...spineVersions].map(v => `spine${v.replace('.', '')}`);+ expect(modules.sort()).toEqual(['spine38', 'spine41', 'spine42']);});- test('4.2-only project produces zero standalone modules', () => {- const spineVersions = new Set(['4.2']);- const nonNative = [...spineVersions].filter(v => v !== '4.2');- expect(nonNative).toHaveLength(0);- });-- test('empty spine project produces zero standalone modules', () => {+ test('empty spine project ships zero modules', () => {const spineVersions = new Set<string>();- const nonNative = [...spineVersions].filter(v => v !== '4.2');- expect(nonNative).toHaveLength(0);+ expect([...spineVersions]).toHaveLength(0);});test('SpineManager constructor accepts version factory map', () => {@@ -45,42 +39,39 @@ describe('Spine multi-version build pipeline', () => {manager.shutdown();});- test('SpineManager routes 4.2 to native without backend', async () => {- const factories = new Map<'3.8' | '4.1' | '4.2', () => Promise<any>>();- const mockModule = { spine_setNeedsReload: () => {} } as any;- const manager = new SpineManager(mockModule, factories);+ test('SpineManager fails the load (no native fallback) when a version has no factory', async () => {+ // S3: 4.2 no longer routes to a native runtime — without a factory the+ // load fails, exactly like 3.8/4.1. Spine is strictly pay-for-use.+ const manager = new SpineManager({} as any, new Map());- const json42 = '{"spine":"4.2.10","skeleton":{}}';- const version = await manager.loadEntity(- 1 as any, json42, '', new Map(), {} as any,+ const v42 = await manager.loadEntity(+ 1 as any, '{"spine":"4.2.10","skeleton":{}}', '', new Map(), {} as any,+ );+ const v41 = await manager.loadEntity(+ 2 as any, '{"spine":"4.1.20","skeleton":{}}', '', new Map(), {} as any,);- expect(version).toBe('4.2');- expect(manager.getEntityVersion(1 as any)).toBe('4.2');- expect(manager.hasModuleBackend('4.2' as any)).toBe(false);-+ expect(v42).toBeNull();+ expect(v41).toBeNull();+ expect(manager.getEntityVersion(1 as any)).toBeUndefined();manager.shutdown();});- test('SpineManager calls spine_setNeedsReload for non-4.2 entities', async () => {- let calledWith: { entity: number; value: boolean } | null = null;- const mockModule = {- spine_setNeedsReload: (_reg: any, entity: number, value: boolean) => {- calledWith = { entity, value };+ test('SpineManager never touches a native spine_* binding', async () => {+ // The old path called coreModule.spine_setNeedsReload; that handshake is+ // gone. Proxy-trap any spine_* access to prove none happens.+ let touched: string | null = null;+ const mockModule = new Proxy({} as any, {+ get(_t, prop) {+ if (typeof prop === 'string' && prop.startsWith('spine_')) touched = prop;+ return undefined;},- } as any;-- const factories = new Map<'3.8' | '4.1' | '4.2', () => Promise<any>>();- const manager = new SpineManager(mockModule, factories);-- const json41 = '{"spine":"4.1.20","skeleton":{}}';- const version = await manager.loadEntity(- 42 as any, json41, '', new Map(), {} as any,+ });+ const manager = new SpineManager(mockModule, new Map());+ await manager.loadEntity(+ 1 as any, '{"spine":"4.2.10","skeleton":{}}', '', new Map(), {} as any,);-- expect(version).toBeNull();- expect(calledWith).toEqual({ entity: 42, value: false });-+ expect(touched).toBeNull();manager.shutdown();});diff --git a/src/esengine/bindings/GeometryBindings.cpp b/src/esengine/bindings/GeometryBindings.cppindex ca5c7b0a1..41e85a3ab 100644--- a/src/esengine/bindings/GeometryBindings.cpp+++ b/src/esengine/bindings/GeometryBindings.cpp@@ -10,10 +10,6 @@#include "../renderer/ImmediateDraw.hpp"#include "../resource/ResourceManager.hpp"#include "../ecs/TransformSystem.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include <glm/glm.hpp>#include <glm/gtc/type_ptr.hpp>diff --git a/src/esengine/bindings/ImmediateDrawBindings.cpp b/src/esengine/bindings/ImmediateDrawBindings.cppindex 657d0bab4..e2ce79df3 100644--- a/src/esengine/bindings/ImmediateDrawBindings.cpp+++ b/src/esengine/bindings/ImmediateDrawBindings.cpp@@ -10,10 +10,6 @@#include "../renderer/CustomGeometry.hpp"#include "../resource/ResourceManager.hpp"#include "../ecs/TransformSystem.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include <glm/glm.hpp>#include <glm/gtc/type_ptr.hpp>diff --git a/src/esengine/bindings/PostProcessBindings.cpp b/src/esengine/bindings/PostProcessBindings.cppindex ce4b90677..3ec2aebc5 100644--- a/src/esengine/bindings/PostProcessBindings.cpp+++ b/src/esengine/bindings/PostProcessBindings.cpp@@ -11,10 +11,6 @@#include "../renderer/CustomGeometry.hpp"#include "../resource/ResourceManager.hpp"#include "../ecs/TransformSystem.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include <glm/glm.hpp>diff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cppindex 125c4904b..20970ee74 100644--- a/src/esengine/bindings/RendererBindings.cpp+++ b/src/esengine/bindings/RendererBindings.cpp@@ -16,10 +16,6 @@#include "../ecs/components/Transform.hpp"#include "../ecs/components/Hierarchy.hpp"#include "../core/Log.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#ifdef ES_ENABLE_PARTICLES#include "../particle/ParticleSystem.hpp"#endif@@ -40,9 +36,6 @@ static EstellaContext& ctx() { return activeCtx(); }#define g_glErrorCheckEnabled (ctx().state().gl_error_check_enabled)#define g_viewportWidth (ctx().state().viewport_width)#define g_viewportHeight (ctx().state().viewport_height)-#ifdef ES_ENABLE_SPINE-#define g_spineSystem (ctx().tryGet<spine::SpineSystem>())-#endif#ifdef ES_ENABLE_PARTICLES#define g_particleSystem (ctx().tryGet<particle::ParticleSystem>())#endif@@ -58,80 +51,10 @@ static u32 checkGLErrors(const char* context) {return errorCount;}+// Spine renders fully through the side modules now: the SDK SpineManager+// computes meshes in spine{NN}.wasm and submits each batch here. The old native+// spine_* accessors (driven by a core spine-cpp runtime) are gone.#ifdef ES_ENABLE_SPINE-SpineBounds getSpineBounds(ecs::Registry& registry, Entity entity) {- SpineBounds bounds;- if (!g_spineSystem) return bounds;-- if (g_spineSystem->getSkeletonBounds(entity, bounds.x, bounds.y,- bounds.width, bounds.height)) {- bounds.valid = true;- }- return bounds;-}--void spine_update(ecs::Registry& registry, f32 dt) {- if (!g_spineSystem) return;- g_spineSystem->update(registry, dt);-}--bool spine_play(Entity entity, const std::string& animation, bool loop, i32 track) {- if (!g_spineSystem) return false;- return g_spineSystem->playAnimation(entity, animation, loop, track);-}--bool spine_addAnimation(Entity entity, const std::string& animation, bool loop, f32 delay, i32 track) {- if (!g_spineSystem) return false;- return g_spineSystem->addAnimation(entity, animation, loop, delay, track);-}--bool spine_setSkin(Entity entity, const std::string& skinName) {- if (!g_spineSystem) return false;- return g_spineSystem->setSkin(entity, skinName);-}--emscripten::val spine_getBonePosition(Entity entity, const std::string& boneName) {- if (!g_spineSystem) return emscripten::val::null();- f32 x = 0, y = 0;- if (!g_spineSystem->getBonePosition(entity, boneName, x, y)) {- return emscripten::val::null();- }- auto result = emscripten::val::object();- result.set("x", x);- result.set("y", y);- return result;-}--bool spine_hasInstance(Entity entity) {- if (!g_spineSystem) return false;- return g_spineSystem->getInstance(entity) != nullptr;-}--void spine_reloadAssets(ecs::Registry& registry) {- if (!g_spineSystem) return;- g_spineSystem->reloadAssets(registry);-}--emscripten::val spine_getAnimations(Entity entity) {- auto result = emscripten::val::array();- if (!g_spineSystem) return result;- auto names = g_spineSystem->getAnimationNames(entity);- for (size_t i = 0; i < names.size(); ++i) {- result.call<void>("push", names[i]);- }- return result;-}--emscripten::val spine_getSkins(Entity entity) {- auto result = emscripten::val::array();- if (!g_spineSystem) return result;- auto names = g_spineSystem->getSkinNames(entity);- for (size_t i = 0; i < names.size(); ++i) {- result.call<void>("push", names[i]);- }- return result;-}-void renderer_submitSpineBatch(uintptr_t verticesPtr, i32 vertexCount,uintptr_t indicesPtr, i32 indexCount,@@ -179,101 +102,6 @@ void renderer_submitSpineBatchByEntity(textureId, blendMode, &model[0][0], entity, layer, depth);}-void spine_setNeedsReload(ecs::Registry& registry, Entity entity, bool value) {- if (!registry.has<ecs::SpineAnimation>(entity)) return;- auto& comp = registry.get<ecs::SpineAnimation>(entity);- comp.needsReload = value;-}--i32 spine_native_getEventCount() {- if (!g_spineSystem) return 0;- return g_spineSystem->getEventCount();-}--uintptr_t spine_native_getEventBuffer() {- if (!g_spineSystem) return 0;- return reinterpret_cast<uintptr_t>(g_spineSystem->getEventBuffer());-}--emscripten::val spine_native_getEventRecord(i32 index) {- if (!g_spineSystem || index < 0 || index >= g_spineSystem->getEventCount()) {- return emscripten::val::null();- }- auto& record = g_spineSystem->getEventRecord(index);- auto result = emscripten::val::object();- result.set("entity", static_cast<i32>(record.entity.id()));- result.set("animationName", record.animationName);- result.set("eventName", record.eventName);- result.set("stringValue", record.stringValue);- return result;-}--void spine_native_clearEvents() {- if (!g_spineSystem) return;- g_spineSystem->clearEvents();-}--emscripten::val spine_native_listConstraints(Entity entity) {- auto result = emscripten::val::object();- if (!g_spineSystem) return result;-- auto names = g_spineSystem->listConstraints(entity);-- auto ikArr = emscripten::val::array();- for (size_t i = 0; i < names.ik.size(); ++i) ikArr.call<void>("push", names.ik[i]);- auto tfArr = emscripten::val::array();- for (size_t i = 0; i < names.transform.size(); ++i) tfArr.call<void>("push", names.transform[i]);- auto pathArr = emscripten::val::array();- for (size_t i = 0; i < names.path.size(); ++i) pathArr.call<void>("push", names.path[i]);-- result.set("ik", ikArr);- result.set("transform", tfArr);- result.set("path", pathArr);- return result;-}--emscripten::val spine_native_getTransformConstraintMix(Entity entity, const std::string& name) {- if (!g_spineSystem) return emscripten::val::null();- f32 rotate = 0, x = 0, y = 0, scaleX = 0, scaleY = 0, shearY = 0;- if (!g_spineSystem->getTransformConstraintMix(entity, name, rotate, x, y, scaleX, scaleY, shearY)) {- return emscripten::val::null();- }- auto result = emscripten::val::object();- result.set("mixRotate", rotate);- result.set("mixX", x);- result.set("mixY", y);- result.set("mixScaleX", scaleX);- result.set("mixScaleY", scaleY);- result.set("mixShearY", shearY);- return result;-}--bool spine_native_setTransformConstraintMix(Entity entity, const std::string& name,- f32 rotate, f32 x, f32 y, f32 scaleX, f32 scaleY, f32 shearY) {- if (!g_spineSystem) return false;- return g_spineSystem->setTransformConstraintMix(entity, name, rotate, x, y, scaleX, scaleY, shearY);-}--emscripten::val spine_native_getPathConstraintMix(Entity entity, const std::string& name) {- if (!g_spineSystem) return emscripten::val::null();- f32 position = 0, spacing = 0, rotate = 0, x = 0, y = 0;- if (!g_spineSystem->getPathConstraintMix(entity, name, position, spacing, rotate, x, y)) {- return emscripten::val::null();- }- auto result = emscripten::val::object();- result.set("position", position);- result.set("spacing", spacing);- result.set("mixRotate", rotate);- result.set("mixX", x);- result.set("mixY", y);- return result;-}--bool spine_native_setPathConstraintMix(Entity entity, const std::string& name,- f32 position, f32 spacing, f32 rotate, f32 x, f32 y) {- if (!g_spineSystem) return false;- return g_spineSystem->setPathConstraintMix(entity, name, position, spacing, rotate, x, y);-}#endifvoid renderFrame(ecs::Registry& registry, i32 viewportWidth, i32 viewportHeight) {@@ -288,12 +116,6 @@ void renderFrame(ecs::Registry& registry, i32 viewportWidth, i32 viewportHeight)g_transformSystem->update(w);}-#ifdef ES_ENABLE_SPINE- if (g_spineSystem) {- g_spineSystem->update(registry, ctx().state().delta_time);- }-#endif-ctx().state().viewport_width = static_cast<u32>(viewportWidth);ctx().state().viewport_height = static_cast<u32>(viewportHeight);g_renderFrame->resize(g_viewportWidth, g_viewportHeight);@@ -353,12 +175,6 @@ void renderFrameWithMatrix(ecs::Registry& registry, i32 viewportWidth, i32 viewpg_transformSystem->update(w);}-#ifdef ES_ENABLE_SPINE- if (g_spineSystem) {- g_spineSystem->update(registry, ctx().state().delta_time);- }-#endif-ctx().state().viewport_width = static_cast<u32>(viewportWidth);ctx().state().viewport_height = static_cast<u32>(viewportHeight);g_renderFrame->resize(g_viewportWidth, g_viewportHeight);diff --git a/src/esengine/bindings/RendererBindings.hpp b/src/esengine/bindings/RendererBindings.hppindex 75f26665a..813bca08c 100644--- a/src/esengine/bindings/RendererBindings.hpp+++ b/src/esengine/bindings/RendererBindings.hpp@@ -69,19 +69,6 @@ void renderer_submitSpineBatchByEntity(Entity entity, f32 skelScale, bool flipX, bool flipY,i32 layer, f32 depth);-void spine_setNeedsReload(ecs::Registry& registry, Entity entity, bool value);-i32 spine_native_getEventCount();-uintptr_t spine_native_getEventBuffer();-emscripten::val spine_native_getEventRecord(i32 index);-void spine_native_clearEvents();--emscripten::val spine_native_listConstraints(Entity entity);-emscripten::val spine_native_getTransformConstraintMix(Entity entity, const std::string& name);-bool spine_native_setTransformConstraintMix(Entity entity, const std::string& name,- f32 rotate, f32 x, f32 y, f32 scaleX, f32 scaleY, f32 shearY);-emscripten::val spine_native_getPathConstraintMix(Entity entity, const std::string& name);-bool spine_native_setPathConstraintMix(Entity entity, const std::string& name,- f32 position, f32 spacing, f32 rotate, f32 x, f32 y);#endif#ifdef ES_ENABLE_PARTICLESvoid renderer_submitParticles(ecs::Registry& registry);diff --git a/src/esengine/bindings/TilemapBindings.cpp b/src/esengine/bindings/TilemapBindings.cppindex e8aa9f281..f7b36666c 100644--- a/src/esengine/bindings/TilemapBindings.cpp+++ b/src/esengine/bindings/TilemapBindings.cpp@@ -10,10 +10,6 @@#include "../renderer/PostProcessPipeline.hpp"#include "../resource/ResourceManager.hpp"#include "../ecs/TransformSystem.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include <emscripten/bind.h>#include <cstring>diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex 26bb4118a..71769bf52 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -52,10 +52,6 @@#include "../particle/ParticleSystem.hpp"#endif#include "../core/Log.hpp"-#ifdef ES_ENABLE_SPINE-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include <glm/glm.hpp>#include <cstring>@@ -73,9 +69,6 @@ static EstellaContext& ctx() { return activeCtx(); }#define g_initialized (ctx().state().initialized)#define g_resourceManager (ctx().tryGet<resource::ResourceManager>())-#ifdef ES_ENABLE_SPINE-#define g_spineResourceManager (ctx().tryGet<spine::SpineResourceManager>())-#endif#define g_renderContext (ctx().tryGet<RenderContext>())#ifdef ES_ENABLE_PARTICLES#define g_particleSystem (ctx().tryGet<particle::ParticleSystem>())@@ -367,36 +360,10 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {;#ifdef ES_ENABLE_SPINE- emscripten::value_object<esengine::SpineBounds>("SpineBounds")- .field("x", &esengine::SpineBounds::x)- .field("y", &esengine::SpineBounds::y)- .field("width", &esengine::SpineBounds::width)- .field("height", &esengine::SpineBounds::height)- .field("valid", &esengine::SpineBounds::valid);-- emscripten::function("getSpineBounds", &esengine::getSpineBounds);-- emscripten::function("spine_update", &esengine::spine_update);- emscripten::function("spine_play", &esengine::spine_play);- emscripten::function("spine_addAnimation", &esengine::spine_addAnimation);- emscripten::function("spine_setSkin", &esengine::spine_setSkin);- emscripten::function("spine_getBonePosition", &esengine::spine_getBonePosition);- emscripten::function("spine_hasInstance", &esengine::spine_hasInstance);- emscripten::function("spine_reloadAssets", &esengine::spine_reloadAssets);- emscripten::function("spine_getAnimations", &esengine::spine_getAnimations);- emscripten::function("spine_getSkins", &esengine::spine_getSkins);+ // Spine renders via the side modules — only the mesh-submit bindings the+ // SDK SpineManager calls remain. Native spine_* / spine_native_* are gone.emscripten::function("renderer_submitSpineBatch", &esengine::renderer_submitSpineBatch);emscripten::function("renderer_submitSpineBatchByEntity", &esengine::renderer_submitSpineBatchByEntity);- emscripten::function("spine_setNeedsReload", &esengine::spine_setNeedsReload);- emscripten::function("spine_native_getEventCount", &esengine::spine_native_getEventCount);- emscripten::function("spine_native_getEventBuffer", &esengine::spine_native_getEventBuffer);- emscripten::function("spine_native_getEventRecord", &esengine::spine_native_getEventRecord);- emscripten::function("spine_native_clearEvents", &esengine::spine_native_clearEvents);- emscripten::function("spine_native_listConstraints", &esengine::spine_native_listConstraints);- emscripten::function("spine_native_getTransformConstraintMix", &esengine::spine_native_getTransformConstraintMix);- emscripten::function("spine_native_setTransformConstraintMix", &esengine::spine_native_setTransformConstraintMix);- emscripten::function("spine_native_getPathConstraintMix", &esengine::spine_native_getPathConstraintMix);- emscripten::function("spine_native_setPathConstraintMix", &esengine::spine_native_setPathConstraintMix);#endifemscripten::function("invalidateMaterialCache", &esengine::invalidateMaterialCache);diff --git a/src/esengine/core/EstellaContext.cpp b/src/esengine/core/EstellaContext.cppindex 2d8ded954..76be5937f 100644--- a/src/esengine/core/EstellaContext.cpp+++ b/src/esengine/core/EstellaContext.cpp@@ -28,11 +28,6 @@#include "../tilemap/TilemapSystem.hpp"#include "../tilemap/TiledMapLoader.hpp"#endif-#ifdef ES_ENABLE_SPINE-#include "../renderer/plugins/SpinePlugin.hpp"-#include "../spine/SpineResourceManager.hpp"-#include "../spine/SpineSystem.hpp"-#endif#include "../resource/ResourceManager.hpp"#include "../ecs/TransformSystem.hpp"#include "../ecs/UISystem.hpp"@@ -135,17 +130,6 @@ void EstellaContext::initSubsystems() {services_.registerOwned<particle::ParticleSystem>(makeUnique<particle::ParticleSystem>());#endif-#ifdef ES_ENABLE_SPINE- {- auto* rm = services_.getService<resource::ResourceManager>();- auto spineRM = makeUnique<spine::SpineResourceManager>(*rm);- spineRM->init();- auto* spineRMPtr = spineRM.get();- services_.registerOwned<spine::SpineResourceManager>(std::move(spineRM));- services_.registerOwned<spine::SpineSystem>(makeUnique<spine::SpineSystem>(*spineRMPtr));- }-#endif-auto* rm = services_.getService<resource::ResourceManager>();auto* rc = services_.getService<RenderContext>();auto immediateDraw = makeUnique<ImmediateDraw>(*gfxDevicePtr, *statePtr, *rc, *rm);@@ -172,13 +156,6 @@ void EstellaContext::initSubsystems() {renderFrame->addPlugin(std::move(tilemapPlugin));}#endif-#ifdef ES_ENABLE_SPINE- {- auto spinePlugin = std::make_unique<SpinePlugin>();- spinePlugin->setSpineSystem(services_.getService<spine::SpineSystem>());- renderFrame->addPlugin(std::move(spinePlugin));- }-#endif#ifdef ES_ENABLE_PARTICLES{auto particlePlugin = std::make_unique<ParticlePlugin>();@@ -205,9 +182,6 @@ void EstellaContext::shutdown() {if (auto* rf = tryGet<RenderFrame>()) rf->shutdown();if (auto* id = tryGet<ImmediateDraw>()) id->shutdown();-#ifdef ES_ENABLE_SPINE- if (auto* srm = tryGet<spine::SpineResourceManager>()) srm->shutdown();-#endifif (auto* rc = tryGet<RenderContext>()) rc->shutdown();if (auto* rm = tryGet<resource::ResourceManager>()) rm->shutdown();diff --git a/src/esengine/renderer/plugins/SpinePlugin.cpp b/src/esengine/renderer/plugins/SpinePlugin.cppdeleted file mode 100644index 9371b186e..000000000--- a/src/esengine/renderer/plugins/SpinePlugin.cpp+++ /dev/null@@ -1,294 +0,0 @@-#include "SpinePlugin.hpp"--#ifdef ES_ENABLE_SPINE--#include "../RenderContext.hpp"-#include "../Texture.hpp"-#include "../../ecs/components/Transform.hpp"-#include "../../ecs/components/SpineAnimation.hpp"-#include "../../spine/SpineSystem.hpp"--#include <spine/RegionAttachment.h>-#include <spine/MeshAttachment.h>-#include <spine/ClippingAttachment.h>--#include <glm/gtc/matrix_transform.hpp>-#include <glm/gtc/quaternion.hpp>--namespace esengine {--void SpinePlugin::init(RenderFrameContext& ctx) {- batch_shader_id_ = ctx.batch_shader_id;- vertices_.reserve(512);- indices_.reserve(1024);- world_vertices_.reserve(512);-}--u32 SpinePlugin::getTextureId(void* spineTexture, RenderFrameContext& ctx) {- if (!spineTexture) {- return ctx.white_texture_id;- }- u32 handleId = static_cast<u32>(reinterpret_cast<uintptr_t>(spineTexture)) - 1;- resource::TextureHandle handle(handleId);- auto* texture = ctx.resources.getTexture(handle);- if (texture) {- return texture->getId();- }- return ctx.white_texture_id;-}--BlendMode SpinePlugin::mapBlendMode(::spine::BlendMode mode) {- switch (mode) {- case ::spine::BlendMode_Additive: return BlendMode::Additive;- case ::spine::BlendMode_Multiply: return BlendMode::Multiply;- case ::spine::BlendMode_Screen: return BlendMode::Screen;- default: return BlendMode::Normal;- }-}--void SpinePlugin::emitBatch(- u32 textureId, BlendMode blend,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx-) {- if (vertices_.empty() || indices_.empty()) return;-- u32 vBytes = static_cast<u32>(vertices_.size()) * sizeof(BatchVertex);- u32 vOff = buffers.appendVertices(LayoutId::Batch, vertices_.data(), vBytes);- u32 baseVertex = vOff / sizeof(BatchVertex);-- for (auto& idx : indices_) {- idx = static_cast<u32>(idx + baseVertex);- }- u32 iOff = buffers.appendIndices(LayoutId::Batch, indices_.data(), static_cast<u32>(indices_.size()));-- DrawCommand cmd{};- cmd.sort_key = DrawCommand::buildSortKey(- ctx.current_stage, layer, batch_shader_id_, blend, 0, textureId, depth);- cmd.index_offset = iOff;- cmd.index_count = static_cast<u32>(indices_.size());- cmd.vertex_byte_offset = vOff;- cmd.shader_id = batch_shader_id_;- cmd.blend_mode = blend;- cmd.layout_id = LayoutId::Batch;- cmd.texture_count = 1;- cmd.texture_ids[0] = textureId;- cmd.entity = entity;- cmd.type = RenderType::Spine;- cmd.layer = layer;-- clips.applyTo(entity, cmd);- draw_list.push(cmd);-- vertices_.clear();- indices_.clear();-}--void SpinePlugin::emitRegionAttachment(- ::spine::RegionAttachment* attachment,- ::spine::Slot& slot,- const glm::mat4& transform,- const glm::vec4& tintColor,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx-) {- auto* region = attachment->getRegion();- if (!region) return;-- u32 textureId = getTextureId(region->rendererObject, ctx);- BlendMode blend = mapBlendMode(slot.getData().getBlendMode());-- world_vertices_.resize(8);- attachment->computeWorldVertices(slot, world_vertices_.data(), 0, 2);-- auto& uvs = attachment->getUVs();- auto& attachColor = attachment->getColor();- auto& slotColor = slot.getColor();- auto& skelColor = slot.getSkeleton().getColor();-- f32 r = skelColor.r * slotColor.r * attachColor.r * tintColor.r;- f32 g = skelColor.g * slotColor.g * attachColor.g * tintColor.g;- f32 b = skelColor.b * slotColor.b * attachColor.b * tintColor.b;- f32 a = skelColor.a * slotColor.a * attachColor.a * tintColor.a;- u32 pc = packColor(r, g, b, a);-- u32 base = static_cast<u32>(vertices_.size());-- for (int j = 0; j < 4; ++j) {- glm::vec4 pos(world_vertices_[j * 2], world_vertices_[j * 2 + 1], 0.0f, 1.0f);- pos = transform * pos;- vertices_.push_back({- glm::vec2(pos.x, pos.y),- pc,- glm::vec2(uvs[j * 2], uvs[j * 2 + 1])- });- }-- indices_.push_back(base);- indices_.push_back(base + 1);- indices_.push_back(base + 2);- indices_.push_back(base + 2);- indices_.push_back(base + 3);- indices_.push_back(base);-- emitBatch(textureId, blend, buffers, draw_list, clips, entity, layer, depth, ctx);-}--void SpinePlugin::emitMeshAttachment(- ::spine::MeshAttachment* attachment,- ::spine::Slot& slot,- const glm::mat4& transform,- const glm::vec4& tintColor,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx-) {- auto* region = attachment->getRegion();- if (!region) return;-- u32 textureId = getTextureId(region->rendererObject, ctx);- BlendMode blend = mapBlendMode(slot.getData().getBlendMode());-- size_t vertexCount = attachment->getWorldVerticesLength() / 2;- world_vertices_.resize(attachment->getWorldVerticesLength());- attachment->computeWorldVertices(slot, 0, attachment->getWorldVerticesLength(),- world_vertices_.data(), 0, 2);-- auto& uvs = attachment->getUVs();- auto& triangles = attachment->getTriangles();- auto& attachColor = attachment->getColor();- auto& slotColor = slot.getColor();- auto& skelColor = slot.getSkeleton().getColor();-- f32 r = skelColor.r * slotColor.r * attachColor.r * tintColor.r;- f32 g = skelColor.g * slotColor.g * attachColor.g * tintColor.g;- f32 b = skelColor.b * slotColor.b * attachColor.b * tintColor.b;- f32 a = skelColor.a * slotColor.a * attachColor.a * tintColor.a;- u32 pc = packColor(r, g, b, a);-- u32 base = static_cast<u32>(vertices_.size());-- if (clipper_.isClipping()) {- clipper_.clipTriangles(world_vertices_.data(),- const_cast<unsigned short*>(triangles.buffer()),- triangles.size(),- uvs.buffer(), 2);-- auto& clippedVerts = clipper_.getClippedVertices();- auto& clippedUVs = clipper_.getClippedUVs();- auto& clippedTris = clipper_.getClippedTriangles();-- size_t clippedVertCount = clippedVerts.size() / 2;- for (size_t j = 0; j < clippedVertCount; ++j) {- glm::vec4 pos(clippedVerts[j * 2], clippedVerts[j * 2 + 1], 0.0f, 1.0f);- pos = transform * pos;- vertices_.push_back({- glm::vec2(pos.x, pos.y),- pc,- glm::vec2(clippedUVs[j * 2], clippedUVs[j * 2 + 1])- });- }-- for (size_t j = 0; j < clippedTris.size(); ++j) {- indices_.push_back(static_cast<u32>(base + clippedTris[j]));- }- } else {- for (size_t j = 0; j < vertexCount; ++j) {- glm::vec4 pos(world_vertices_[j * 2], world_vertices_[j * 2 + 1], 0.0f, 1.0f);- pos = transform * pos;- vertices_.push_back({- glm::vec2(pos.x, pos.y),- pc,- glm::vec2(uvs[j * 2], uvs[j * 2 + 1])- });- }-- for (size_t j = 0; j < triangles.size(); ++j) {- indices_.push_back(static_cast<u32>(base + triangles[j]));- }- }-- emitBatch(textureId, blend, buffers, draw_list, clips, entity, layer, depth, ctx);-}--void SpinePlugin::collect(RenderCollectContext& collect_ctx) {- auto& registry = collect_ctx.registry;- auto& clips = collect_ctx.clip_state;- auto& buffers = collect_ctx.buffer_pool;- auto& draw_list = collect_ctx.draw_list;- auto& ctx = collect_ctx.frame_context;- if (!spine_system_) return;-- auto view = registry.view<ecs::SpineAnimation>();-- for (auto entity : view) {- auto& comp = registry.get<ecs::SpineAnimation>(entity);- if (!comp.enabled) continue;- auto* instance = spine_system_->getInstance(entity);- if (!instance || !instance->skeleton) continue;-- glm::vec3 position{0.0f};- glm::quat rotation{1.0f, 0.0f, 0.0f, 0.0f};- glm::vec3 scale{1.0f};-- if (registry.has<ecs::Transform>(entity)) {- auto& t = registry.get<ecs::Transform>(entity);- t.ensureDecomposed();- position = t.worldPosition;- rotation = t.worldRotation;- scale = t.worldScale;- }-- glm::mat4 transform = glm::mat4(1.0f);- transform = glm::translate(transform, position);- transform *= glm::mat4_cast(rotation);- transform = glm::scale(transform, scale);-- auto* skeleton = instance->skeleton.get();- auto& drawOrder = skeleton->getDrawOrder();-- for (size_t i = 0; i < drawOrder.size(); ++i) {- ::spine::Slot* slot = drawOrder[i];- if (!slot) continue;-- ::spine::Attachment* attachment = slot->getAttachment();- if (!attachment) continue;-- if (!slot->getData().isVisible()) continue;-- if (attachment->getRTTI().isExactly(::spine::ClippingAttachment::rtti)) {- auto* clip = static_cast<::spine::ClippingAttachment*>(attachment);- clipper_.clipStart(*slot, clip);- continue;- }-- if (attachment->getRTTI().isExactly(::spine::RegionAttachment::rtti)) {- emitRegionAttachment(- static_cast<::spine::RegionAttachment*>(attachment),- *slot, transform, comp.color,- buffers, draw_list, clips, entity, comp.layer, position.z, ctx);- } else if (attachment->getRTTI().isExactly(::spine::MeshAttachment::rtti)) {- emitMeshAttachment(- static_cast<::spine::MeshAttachment*>(attachment),- *slot, transform, comp.color,- buffers, draw_list, clips, entity, comp.layer, position.z, ctx);- }-- clipper_.clipEnd(*slot);- }-- clipper_.clipEnd();- }-}--} // namespace esengine--#endifdiff --git a/src/esengine/renderer/plugins/SpinePlugin.hpp b/src/esengine/renderer/plugins/SpinePlugin.hppdeleted file mode 100644index 9e54fbc94..000000000--- a/src/esengine/renderer/plugins/SpinePlugin.hpp+++ /dev/null@@ -1,75 +0,0 @@-#pragma once--#include "../RenderTypePlugin.hpp"-#include "../BatchVertex.hpp"--#ifdef ES_ENABLE_SPINE--#include <spine/spine.h>-#include <vector>--namespace esengine {--namespace spine { class SpineSystem; }--class SpinePlugin : public RenderTypePlugin {-public:- void init(RenderFrameContext& ctx) override;- void shutdown() override {}-- u32 skipFlag() const override { return 1; }-- void setSpineSystem(spine::SpineSystem* system) { spine_system_ = system; }-- void collect(RenderCollectContext& ctx) override;--private:- u32 getTextureId(void* spineTexture, RenderFrameContext& ctx);-- static BlendMode mapBlendMode(::spine::BlendMode mode);-- void emitRegionAttachment(- ::spine::RegionAttachment* attachment,- ::spine::Slot& slot,- const glm::mat4& transform,- const glm::vec4& tintColor,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx- );-- void emitMeshAttachment(- ::spine::MeshAttachment* attachment,- ::spine::Slot& slot,- const glm::mat4& transform,- const glm::vec4& tintColor,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx- );-- void emitBatch(- u32 textureId, BlendMode blend,- TransientBufferPool& buffers,- DrawList& draw_list,- const ClipState& clips,- Entity entity, i32 layer, f32 depth,- RenderFrameContext& ctx- );-- spine::SpineSystem* spine_system_ = nullptr;- u32 batch_shader_id_ = 0;-- std::vector<BatchVertex> vertices_;- std::vector<u32> indices_;- std::vector<f32> world_vertices_;- ::spine::SkeletonClipping clipper_;-};--} // namespace esengine--#endifdiff --git a/src/esengine/resource/Handle.hpp b/src/esengine/resource/Handle.hppindex d4c9ae885..7fdccb2eb 100644--- a/src/esengine/resource/Handle.hpp+++ b/src/esengine/resource/Handle.hpp@@ -187,6 +187,10 @@ namespace esengine {class IndexBuffer;}+// Forward-declared only — the native spine runtime was removed (spine is fully+// side-module now), but SpineAnimation keeps its (vestigial) skeleton-data handle+// field so the component layout/hash is unchanged. Handle<T> stores just an id,+// so T never needs a definition here.namespace esengine::spine {struct SpineSkeletonData;}@@ -213,7 +217,7 @@ using VertexBufferHandle = Handle<esengine::VertexBuffer>;/** @brief Handle to an index buffer resource */using IndexBufferHandle = Handle<esengine::IndexBuffer>;-/** @brief Handle to a Spine skeleton data resource */+/** @brief Handle to a Spine skeleton data resource (vestigial — see fwd decl) */using SpineDataHandle = Handle<esengine::spine::SpineSkeletonData>;/** @brief Handle to a bitmap font resource */diff --git a/src/esengine/spine/SpineExtension.cpp b/src/esengine/spine/SpineExtension.cppdeleted file mode 100644index 0986a6f0c..000000000--- a/src/esengine/spine/SpineExtension.cpp+++ /dev/null@@ -1,64 +0,0 @@-/**- * @file SpineExtension.cpp- * @brief ESEngine implementation of Spine's extension interface- */--// =============================================================================-// Includes-// =============================================================================--#include "SpineExtension.hpp"-#include "../platform/FileSystem.hpp"-#include "../core/Log.hpp"--#include <spine/SpineString.h>--#include <cstring>--namespace esengine::spine {--// =============================================================================-// ESEngineSpineExtension Implementation-// =============================================================================--char* ESEngineSpineExtension::_readFile(const ::spine::String& path, int* length) {- std::string pathStr(path.buffer(), path.length());-- auto data = FileSystem::readBinaryFile(pathStr);- if (data.empty()) {- ES_LOG_ERROR("Failed to read Spine file: {}", pathStr);- *length = 0;- return nullptr;- }-- *length = static_cast<int>(data.size());- char* buffer = ::spine::SpineExtension::alloc<char>(data.size() + 1, __FILE__, __LINE__);- std::memcpy(buffer, data.data(), data.size());- buffer[data.size()] = '\0';-- return buffer;-}--// =============================================================================-// Extension Initialization-// =============================================================================--void initSpineExtension() {- static ESEngineSpineExtension s_extension;- ::spine::SpineExtension::setInstance(&s_extension);-}--} // namespace esengine::spine--// =============================================================================-// Spine Default Extension Provider-// =============================================================================--namespace spine {--SpineExtension* getDefaultExtension() {- static esengine::spine::ESEngineSpineExtension s_defaultExtension;- return &s_defaultExtension;-}--} // namespace spinediff --git a/src/esengine/spine/SpineExtension.hpp b/src/esengine/spine/SpineExtension.hppdeleted file mode 100644index fe0c0fa31..000000000--- a/src/esengine/spine/SpineExtension.hpp+++ /dev/null@@ -1,55 +0,0 @@-/**- * @file SpineExtension.hpp- * @brief ESEngine implementation of Spine's extension interface- * @details Bridges Spine's file/memory operations with ESEngine's FileSystem.- *- * @author ESEngine Team- * @date 2026- *- * @copyright Copyright (c) 2026 ESEngine Team- * Licensed under the MIT License.- */-#pragma once--// =============================================================================-// Includes-// =============================================================================--#include <spine/Extension.h>--namespace esengine::spine {--// =============================================================================-// ESEngineSpineExtension Class-// =============================================================================--/**- * @brief ESEngine implementation of Spine's extension interface- *- * @details Provides file reading through ESEngine's FileSystem and- * uses standard memory allocation. This extension is automatically- * set when SpineResourceManager is initialized.- */-class ESEngineSpineExtension : public ::spine::DefaultSpineExtension {-public:- ESEngineSpineExtension() = default;- ~ESEngineSpineExtension() override = default;--protected:- /**- * @brief Reads a file using ESEngine's FileSystem- * @param path File path to read- * @param length Output parameter for file length- * @return Allocated buffer containing file data (caller must free)- */- char* _readFile(const ::spine::String& path, int* length) override;-};--/**- * @brief Initializes the ESEngine Spine extension- * @details Must be called before loading any Spine assets.- * Called automatically by SpineResourceManager::init().- */-void initSpineExtension();--} // namespace esengine::spinediff --git a/src/esengine/spine/SpineResourceManager.cpp b/src/esengine/spine/SpineResourceManager.cppdeleted file mode 100644index 791f63f57..000000000--- a/src/esengine/spine/SpineResourceManager.cpp+++ /dev/null@@ -1,206 +0,0 @@-/**- * @file SpineResourceManager.cpp- * @brief Spine skeleton data resource management- */--// =============================================================================-// Includes-// =============================================================================--#include "SpineResourceManager.hpp"-#include "SpineExtension.hpp"-#include "../core/Log.hpp"-#include "../platform/FileSystem.hpp"-#include "../renderer/Texture.hpp"--#include <spine/SkeletonBinary.h>-#include <spine/SkeletonJson.h>-#include <spine/AtlasAttachmentLoader.h>--namespace esengine::spine {--// =============================================================================-// ESEngineTextureLoader Implementation-// =============================================================================--ESEngineTextureLoader::ESEngineTextureLoader(resource::ResourceManager& resourceManager)- : resource_manager_(resourceManager) {-}--void ESEngineTextureLoader::load(::spine::AtlasPage& page, const ::spine::String& path) {- std::string pathStr(path.buffer(), path.length());-- auto handle = resource_manager_.loadTexture(pathStr);- if (!handle.isValid()) {- ES_LOG_ERROR("Failed to load Spine texture: {}", pathStr);- return;- }-- auto* texture = resource_manager_.getTexture(handle);- if (texture) {- page.width = static_cast<int>(texture->getWidth());- page.height = static_cast<int>(texture->getHeight());- void* key = reinterpret_cast<void*>(static_cast<uintptr_t>(handle.id() + 1));- page.texture = key;- texture_handles_[key] = handle;- }-}--void ESEngineTextureLoader::unload(void* texture) {- auto it = texture_handles_.find(texture);- if (it != texture_handles_.end()) {- resource_manager_.releaseTexture(it->second);- texture_handles_.erase(it);- }-}--// =============================================================================-// SpineResourceManager Implementation-// =============================================================================--SpineResourceManager::SpineResourceManager(resource::ResourceManager& resourceManager)- : resource_manager_(resourceManager) {-}--SpineResourceManager::~SpineResourceManager() {- if (initialized_) {- shutdown();- }-}--void SpineResourceManager::init() {- if (initialized_) return;-- initSpineExtension();- texture_loader_ = makeUnique<ESEngineTextureLoader>(resource_manager_);- initialized_ = true;-}--void SpineResourceManager::shutdown() {- if (!initialized_) return;-- cache_.clear();- pool_.clear();- texture_loader_.reset();- initialized_ = false;-- ES_LOG_INFO("SpineResourceManager shutdown");-}--resource::SpineDataHandle SpineResourceManager::load(const std::string& skeletonPath,- const std::string& atlasPath,- f32 scale) {- if (!initialized_) {- ES_LOG_ERROR("SpineResourceManager not initialized");- return resource::SpineDataHandle();- }-- std::string cacheKey = skeletonPath + ":" + atlasPath + ":" + std::to_string(scale);- auto cacheIt = cache_.find(cacheKey);- if (cacheIt != cache_.end()) {- return cacheIt->second;- }-- auto atlas = makeUnique<::spine::Atlas>(atlasPath.c_str(), texture_loader_.get());- if (atlas->getPages().size() == 0) {- ES_LOG_ERROR("Failed to load Spine atlas: {}", atlasPath);- return resource::SpineDataHandle();- }-- bool isBinary = skeletonPath.ends_with(".skel");- resource::SpineDataHandle handle;-- if (isBinary) {- handle = loadBinary(skeletonPath, atlas.get(), scale);- } else {- handle = loadJson(skeletonPath, atlas.get(), scale);- }-- if (handle.isValid()) {- auto* data = pool_.get(handle);- if (data) {- data->atlas = std::move(atlas);- }- cache_[cacheKey] = handle;- ES_LOG_INFO("Loaded Spine skeleton: {}", skeletonPath);- }-- return handle;-}--resource::SpineDataHandle SpineResourceManager::loadBinary(const std::string& skeletonPath,- ::spine::Atlas* atlas, f32 scale) {- ::spine::AtlasAttachmentLoader attachmentLoader(atlas);- ::spine::SkeletonBinary binary(&attachmentLoader);- binary.setScale(scale);-- auto* skeletonData = binary.readSkeletonDataFile(skeletonPath.c_str());- if (!skeletonData) {- ES_LOG_ERROR("Failed to load Spine skeleton binary: {} - {}",- skeletonPath, binary.getError().buffer());- return resource::SpineDataHandle();- }-- auto data = makeUnique<SpineSkeletonData>();- data->skeletonData.reset(skeletonData);- data->stateData = makeUnique<::spine::AnimationStateData>(skeletonData);- data->stateData->setDefaultMix(0.2f);-- return pool_.add(std::move(data));-}--resource::SpineDataHandle SpineResourceManager::loadJson(const std::string& skeletonPath,- ::spine::Atlas* atlas, f32 scale) {- ::spine::AtlasAttachmentLoader attachmentLoader(atlas);- ::spine::SkeletonJson json(&attachmentLoader);- json.setScale(scale);-- auto* skeletonData = json.readSkeletonDataFile(skeletonPath.c_str());- if (!skeletonData) {- ES_LOG_ERROR("Failed to load Spine skeleton JSON: {} - {}",- skeletonPath, json.getError().buffer());- return resource::SpineDataHandle();- }-- auto data = makeUnique<SpineSkeletonData>();- data->skeletonData.reset(skeletonData);- data->stateData = makeUnique<::spine::AnimationStateData>(skeletonData);- data->stateData->setDefaultMix(0.2f);-- return pool_.add(std::move(data));-}--SpineSkeletonData* SpineResourceManager::get(resource::SpineDataHandle handle) {- return pool_.get(handle);-}--const SpineSkeletonData* SpineResourceManager::get(resource::SpineDataHandle handle) const {- return pool_.get(handle);-}--void SpineResourceManager::release(resource::SpineDataHandle handle) {- if (!handle.isValid()) return;-- for (auto it = cache_.begin(); it != cache_.end(); ++it) {- if (it->second == handle) {- cache_.erase(it);- break;- }- }- pool_.release(handle.id());-}--resource::SpineDataHandle SpineResourceManager::getByPath(const std::string& skeletonPath) const {- for (const auto& [key, handle] : cache_) {- if (key == skeletonPath || key.starts_with(skeletonPath + ":")) {- return handle;- }- }- return resource::SpineDataHandle();-}--usize SpineResourceManager::getLoadedCount() const {- return pool_.size();-}--} // namespace esengine::spinediff --git a/src/esengine/spine/SpineResourceManager.hpp b/src/esengine/spine/SpineResourceManager.hppdeleted file mode 100644index 02e32b891..000000000--- a/src/esengine/spine/SpineResourceManager.hpp+++ /dev/null@@ -1,185 +0,0 @@-/**- * @file SpineResourceManager.hpp- * @brief Spine skeleton data resource management- * @details Provides caching and lifecycle management for Spine resources.- *- * @author ESEngine Team- * @date 2026- *- * @copyright Copyright (c) 2026 ESEngine Team- * Licensed under the MIT License.- */-#pragma once--// =============================================================================-// Includes-// =============================================================================--#include "../core/Types.hpp"-#include "../resource/Handle.hpp"-#include "../resource/ResourcePool.hpp"-#include "../resource/ResourceManager.hpp"--#include <spine/spine.h>--#include <string>-#include <unordered_map>--namespace esengine::spine {--// =============================================================================-// Forward Declarations-// =============================================================================--struct SpineSkeletonData;--// =============================================================================-// ESEngineTextureLoader-// =============================================================================--/**- * @brief Texture loader for Spine atlases- *- * @details Loads textures through ESEngine's ResourceManager and associates- * them with Spine atlas pages.- */-class ESEngineTextureLoader : public ::spine::TextureLoader {-public:- explicit ESEngineTextureLoader(resource::ResourceManager& resourceManager);- ~ESEngineTextureLoader() override = default;-- void load(::spine::AtlasPage& page, const ::spine::String& path) override;- void unload(void* texture) override;--private:- resource::ResourceManager& resource_manager_;- std::unordered_map<void*, resource::TextureHandle> texture_handles_;-};--// =============================================================================-// SpineSkeletonData-// =============================================================================--/**- * @brief Container for loaded Spine skeleton resources- *- * @details Holds all data needed to create Skeleton and AnimationState- * instances. Resources are reference-counted by SpineResourceManager.- */-struct SpineSkeletonData {- Unique<::spine::Atlas> atlas;- Unique<::spine::SkeletonData> skeletonData;- Unique<::spine::AnimationStateData> stateData;-- SpineSkeletonData() = default;- ~SpineSkeletonData() = default;-- SpineSkeletonData(const SpineSkeletonData&) = delete;- SpineSkeletonData& operator=(const SpineSkeletonData&) = delete;- SpineSkeletonData(SpineSkeletonData&&) = default;- SpineSkeletonData& operator=(SpineSkeletonData&&) = default;-};--// =============================================================================-// SpineResourceManager-// =============================================================================--/**- * @brief Manages Spine skeleton resources with caching- *- * @details Provides loading, caching, and lifecycle management for Spine- * skeleton data. Resources are cached by path for deduplication.- *- * @code- * SpineResourceManager spineMgr(resourceManager);- * spineMgr.init();- *- * auto handle = spineMgr.load("skeleton.skel", "skeleton.atlas");- * auto* data = spineMgr.get(handle);- *- * // Create skeleton instance- * auto skeleton = makeUnique<spine::Skeleton>(data->skeletonData.get());- * auto state = makeUnique<spine::AnimationState>(data->stateData.get());- *- * spineMgr.release(handle);- * spineMgr.shutdown();- * @endcode- */-class SpineResourceManager {-public:- explicit SpineResourceManager(resource::ResourceManager& resourceManager);- ~SpineResourceManager();-- SpineResourceManager(const SpineResourceManager&) = delete;- SpineResourceManager& operator=(const SpineResourceManager&) = delete;-- // =========================================================================- // Lifecycle- // =========================================================================-- void init();- void shutdown();- bool isInitialized() const { return initialized_; }-- // =========================================================================- // Resource Loading- // =========================================================================-- /**- * @brief Loads Spine skeleton data from files- * @param skeletonPath Path to .skel (binary) or .json skeleton file- * @param atlasPath Path to .atlas file- * @param scale Optional skeleton scale (default 1.0)- * @return Handle to the loaded data, or invalid handle on failure- */- resource::SpineDataHandle load(const std::string& skeletonPath,- const std::string& atlasPath,- f32 scale = 1.0f);-- /**- * @brief Gets skeleton data by handle- * @param handle The data handle- * @return Pointer to the data, or nullptr if invalid- */- SpineSkeletonData* get(resource::SpineDataHandle handle);-- /**- * @brief Gets skeleton data by handle (const)- * @param handle The data handle- * @return Const pointer to the data, or nullptr if invalid- */- const SpineSkeletonData* get(resource::SpineDataHandle handle) const;-- /**- * @brief Releases skeleton data- * @param handle The data handle- */- void release(resource::SpineDataHandle handle);-- /**- * @brief Gets handle by skeleton path (if cached)- * @param skeletonPath Path used to load the skeleton- * @return Handle if cached, invalid handle otherwise- */- resource::SpineDataHandle getByPath(const std::string& skeletonPath) const;-- // =========================================================================- // Statistics- // =========================================================================-- usize getLoadedCount() const;--private:- resource::ResourceManager& resource_manager_;- Unique<ESEngineTextureLoader> texture_loader_;- resource::ResourcePool<SpineSkeletonData> pool_;- std::unordered_map<std::string, resource::SpineDataHandle> cache_;- bool initialized_ = false;-- resource::SpineDataHandle loadBinary(const std::string& skeletonPath,- ::spine::Atlas* atlas, f32 scale);- resource::SpineDataHandle loadJson(const std::string& skeletonPath,- ::spine::Atlas* atlas, f32 scale);-};--} // namespace esengine::spinediff --git a/src/esengine/spine/SpineSystem.cpp b/src/esengine/spine/SpineSystem.cppdeleted file mode 100644index 72bfc620f..000000000--- a/src/esengine/spine/SpineSystem.cpp+++ /dev/null@@ -1,381 +0,0 @@-/**- * @file SpineSystem.cpp- * @brief Spine animation update system- */--// =============================================================================-// Includes-// =============================================================================--#include "SpineSystem.hpp"-#include "../core/Log.hpp"-#include "../ecs/components/SpineAnimation.hpp"-#include "../ecs/components/Transform.hpp"--namespace esengine::spine {--// =============================================================================-// SpineSystem Implementation-// =============================================================================--SpineSystem::SpineSystem(SpineResourceManager& resourceManager)- : resource_manager_(resourceManager) {-}--SpineSystem::~SpineSystem() {- instances_.clear();-}--void SpineSystem::update(ecs::Registry& registry, f32 deltaTime) {- auto view = registry.view<ecs::SpineAnimation>();-- for (auto entity : view) {- auto& comp = registry.get<ecs::SpineAnimation>(entity);-- if (comp.needsReload && !comp.skeletonPath.empty() && !comp.atlasPath.empty()) {- loadSkeletonForEntity(entity, comp);- }-- auto it = instances_.find(entity);- if (it != instances_.end()) {- syncComponentToInstance(entity, comp);- updateAnimation(entity, comp, deltaTime);- }- }-- if (!destroyConn_.isConnected()) {- destroyConn_ = registry.onDestroyScoped([this](Entity entity) {- instances_.erase(entity);- });- }-}--void SpineSystem::loadSkeletonForEntity(Entity entity, ecs::SpineAnimation& comp) {- auto handle = resource_manager_.load(comp.skeletonPath, comp.atlasPath, comp.skeletonScale);- if (!handle.isValid()) {- ES_LOG_ERROR("Failed to load spine skeleton for entity {}", entity);- comp.needsReload = false;- return;- }-- auto* data = resource_manager_.get(handle);- if (!data || !data->skeletonData || !data->stateData) {- ES_LOG_ERROR("Invalid spine data for entity {}", entity);- comp.needsReload = false;- return;- }-- auto instance = SpineInstance{};- instance.skeleton = makeUnique<::spine::Skeleton>(data->skeletonData.get());- instance.state = makeUnique<::spine::AnimationState>(data->stateData.get());-- if (!comp.skin.empty()) {- instance.skeleton->setSkin(comp.skin.c_str());- instance.skeleton->setSlotsToSetupPose();- }-- if (!comp.animation.empty()) {- instance.state->setAnimation(0, comp.animation.c_str(), comp.loop);- }-- instance.skeleton->setScaleX(comp.flipX ? -1.0f : 1.0f);- instance.skeleton->setScaleY(comp.flipY ? -1.0f : 1.0f);-- instance.state->setListener(- [this, entity](::spine::AnimationState*, ::spine::EventType type,- ::spine::TrackEntry* entry, ::spine::Event* event) {- recordEvent(entity, type, entry, event);- });-- comp.skeletonData = handle;- comp.needsReload = false;-- instances_[entity] = std::move(instance);-}--void SpineSystem::updateAnimation(Entity entity, ecs::SpineAnimation& comp, f32 deltaTime) {- auto it = instances_.find(entity);- if (it == instances_.end()) return;-- auto& instance = it->second;- auto* skeleton = instance.skeleton.get();- auto* state = instance.state.get();-- if (!skeleton || !state) return;-- if (comp.playing) {- state->update(deltaTime * comp.timeScale);- }-- state->apply(*skeleton);- skeleton->update(deltaTime);- skeleton->updateWorldTransform(::spine::Physics_Update);-}--void SpineSystem::syncComponentToInstance(Entity entity, ecs::SpineAnimation& comp) {- auto it = instances_.find(entity);- if (it == instances_.end()) return;-- auto& instance = it->second;- auto* skeleton = instance.skeleton.get();-- if (!skeleton) return;-- skeleton->setScaleX(comp.flipX ? -1.0f : 1.0f);- skeleton->setScaleY(comp.flipY ? -1.0f : 1.0f);-- auto& color = skeleton->getColor();- color.r = comp.color.r;- color.g = comp.color.g;- color.b = comp.color.b;- color.a = comp.color.a;-}--void SpineSystem::reloadAssets(ecs::Registry& registry) {- instances_.clear();- auto view = registry.view<ecs::SpineAnimation>();- for (auto entity : view) {- auto& comp = registry.get<ecs::SpineAnimation>(entity);- if (comp.skeletonData.isValid()) {- resource_manager_.release(comp.skeletonData);- comp.skeletonData = {};- }- comp.needsReload = true;- }-}--SpineInstance* SpineSystem::getInstance(Entity entity) {- auto it = instances_.find(entity);- return it != instances_.end() ? &it->second : nullptr;-}--const SpineInstance* SpineSystem::getInstance(Entity entity) const {- auto it = instances_.find(entity);- return it != instances_.end() ? &it->second : nullptr;-}--bool SpineSystem::playAnimation(Entity entity, const std::string& animation,- bool loop, i32 track) {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.state) return false;-- auto* entry = it->second.state->setAnimation(- static_cast<size_t>(track), animation.c_str(), loop);- return entry != nullptr;-}--bool SpineSystem::addAnimation(Entity entity, const std::string& animation,- bool loop, f32 delay, i32 track) {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.state) return false;-- auto* entry = it->second.state->addAnimation(- static_cast<size_t>(track), animation.c_str(), loop, delay);- return entry != nullptr;-}--bool SpineSystem::setSkin(Entity entity, const std::string& skinName) {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- it->second.skeleton->setSkin(skinName.c_str());- it->second.skeleton->setSlotsToSetupPose();- return true;-}--bool SpineSystem::getBonePosition(Entity entity, const std::string& boneName,- f32& outX, f32& outY) const {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* bone = it->second.skeleton->findBone(boneName.c_str());- if (!bone) return false;-- outX = bone->getWorldX();- outY = bone->getWorldY();- return true;-}--bool SpineSystem::getBoneRotation(Entity entity, const std::string& boneName,- f32& outRotation) const {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* bone = it->second.skeleton->findBone(boneName.c_str());- if (!bone) return false;-- outRotation = bone->getWorldRotationX();- return true;-}--bool SpineSystem::getSkeletonBounds(Entity entity, f32& outX, f32& outY,- f32& outWidth, f32& outHeight) const {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) {- return false;- }-- ::spine::Vector<f32> vertices;- it->second.skeleton->getBounds(outX, outY, outWidth, outHeight, vertices);- return true;-}--std::vector<std::string> SpineSystem::getAnimationNames(Entity entity) const {- std::vector<std::string> result;- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return result;-- auto* data = it->second.skeleton->getData();- auto& animations = data->getAnimations();- result.reserve(animations.size());- for (size_t i = 0; i < animations.size(); ++i) {- result.emplace_back(animations[i]->getName().buffer());- }- return result;-}--std::vector<std::string> SpineSystem::getSkinNames(Entity entity) const {- std::vector<std::string> result;- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return result;-- auto* data = it->second.skeleton->getData();- auto& skins = data->getSkins();- result.reserve(skins.size());- for (size_t i = 0; i < skins.size(); ++i) {- result.emplace_back(skins[i]->getName().buffer());- }- return result;-}--// =============================================================================-// Constraints-// =============================================================================--SpineSystem::ConstraintNames SpineSystem::listConstraints(Entity entity) const {- ConstraintNames result;- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return result;-- auto* data = it->second.skeleton->getData();-- auto& ikList = data->getIkConstraints();- for (size_t i = 0; i < ikList.size(); ++i) {- result.ik.emplace_back(ikList[i]->getName().buffer());- }- auto& transformList = data->getTransformConstraints();- for (size_t i = 0; i < transformList.size(); ++i) {- result.transform.emplace_back(transformList[i]->getName().buffer());- }- auto& pathList = data->getPathConstraints();- for (size_t i = 0; i < pathList.size(); ++i) {- result.path.emplace_back(pathList[i]->getName().buffer());- }- return result;-}--bool SpineSystem::getTransformConstraintMix(Entity entity, const std::string& name,- f32& outRotate, f32& outX, f32& outY,- f32& outScaleX, f32& outScaleY, f32& outShearY) const {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* constraint = it->second.skeleton->findTransformConstraint(name.c_str());- if (!constraint) return false;-- outRotate = constraint->getMixRotate();- outX = constraint->getMixX();- outY = constraint->getMixY();- outScaleX = constraint->getMixScaleX();- outScaleY = constraint->getMixScaleY();- outShearY = constraint->getMixShearY();- return true;-}--bool SpineSystem::setTransformConstraintMix(Entity entity, const std::string& name,- f32 rotate, f32 x, f32 y, f32 scaleX, f32 scaleY, f32 shearY) {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* constraint = it->second.skeleton->findTransformConstraint(name.c_str());- if (!constraint) return false;-- constraint->setMixRotate(rotate);- constraint->setMixX(x);- constraint->setMixY(y);- constraint->setMixScaleX(scaleX);- constraint->setMixScaleY(scaleY);- constraint->setMixShearY(shearY);- return true;-}--bool SpineSystem::getPathConstraintMix(Entity entity, const std::string& name,- f32& outPosition, f32& outSpacing,- f32& outRotate, f32& outX, f32& outY) const {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* constraint = it->second.skeleton->findPathConstraint(name.c_str());- if (!constraint) return false;-- outPosition = constraint->getPosition();- outSpacing = constraint->getSpacing();- outRotate = constraint->getMixRotate();- outX = constraint->getMixX();- outY = constraint->getMixY();- return true;-}--bool SpineSystem::setPathConstraintMix(Entity entity, const std::string& name,- f32 position, f32 spacing, f32 rotate, f32 x, f32 y) {- auto it = instances_.find(entity);- if (it == instances_.end() || !it->second.skeleton) return false;-- auto* constraint = it->second.skeleton->findPathConstraint(name.c_str());- if (!constraint) return false;-- constraint->setPosition(position);- constraint->setSpacing(spacing);- constraint->setMixRotate(rotate);- constraint->setMixX(x);- constraint->setMixY(y);- return true;-}--// =============================================================================-// Events-// =============================================================================--void SpineSystem::recordEvent(Entity entity, ::spine::EventType type,- ::spine::TrackEntry* entry, ::spine::Event* event) {- if (type == ::spine::EventType_Dispose) return;- if (native_event_count_ >= MAX_NATIVE_EVENTS) return;-- auto idx = native_event_count_;- auto base = idx * EVENT_STRIDE;-- native_event_buffer_[base + 0] = static_cast<f32>(type);- native_event_buffer_[base + 1] = entry ? static_cast<f32>(entry->getTrackIndex()) : 0.0f;- native_event_buffer_[base + 2] = (type == ::spine::EventType_Event && event) ? event->getFloatValue() : 0.0f;- native_event_buffer_[base + 3] = (type == ::spine::EventType_Event && event) ? static_cast<f32>(event->getIntValue()) : 0.0f;-- auto& record = native_event_records_[idx];- record.entity = entity;- record.animationName = (entry && entry->getAnimation())- ? entry->getAnimation()->getName().buffer() : "";- if (type == ::spine::EventType_Event && event) {- record.eventName = event->getData().getName().buffer();- record.stringValue = event->getStringValue().buffer();- } else {- record.eventName.clear();- record.stringValue.clear();- }-- ++native_event_count_;-}--void SpineSystem::clearEvents() {- native_event_count_ = 0;-}--} // namespace esengine::spinediff --git a/src/esengine/spine/SpineSystem.hpp b/src/esengine/spine/SpineSystem.hppdeleted file mode 100644index 8acc09c79..000000000--- a/src/esengine/spine/SpineSystem.hpp+++ /dev/null@@ -1,229 +0,0 @@-/**- * @file SpineSystem.hpp- * @brief Spine animation update system- * @details Updates Spine skeletons and animation states for all entities.- *- * @author ESEngine Team- * @date 2026- *- * @copyright Copyright (c) 2026 ESEngine Team- * Licensed under the MIT License.- */-#pragma once--// =============================================================================-// Includes-// =============================================================================--#include "../core/Types.hpp"-#include "../ecs/Registry.hpp"-#include "../ecs/components/SpineAnimation.hpp"-#include "SpineResourceManager.hpp"--#include <spine/spine.h>--#include <array>-#include <unordered_map>--namespace esengine::spine {--// =============================================================================-// SpineInstance-// =============================================================================--/**- * @brief Per-entity Spine runtime instance- *- * @details Contains the Skeleton and AnimationState objects for a single- * entity. These are created from the shared SpineSkeletonData.- */-struct SpineInstance {- Unique<::spine::Skeleton> skeleton;- Unique<::spine::AnimationState> state;-- SpineInstance() = default;- ~SpineInstance() = default;-- SpineInstance(const SpineInstance&) = delete;- SpineInstance& operator=(const SpineInstance&) = delete;- SpineInstance(SpineInstance&&) = default;- SpineInstance& operator=(SpineInstance&&) = default;-};--// =============================================================================-// SpineSystem-// =============================================================================--/**- * @brief System for updating Spine animations- *- * @details Manages the lifecycle of Spine instances per entity and updates- * animation states each frame. Creates/destroys instances as needed- * when SpineAnimation components are added/removed.- *- * @code- * SpineSystem spineSystem(spineResourceManager);- *- * // In update loop- * spineSystem.update(registry, deltaTime);- * @endcode- */-class SpineSystem {-public:- explicit SpineSystem(SpineResourceManager& resourceManager);- ~SpineSystem();-- SpineSystem(const SpineSystem&) = delete;- SpineSystem& operator=(const SpineSystem&) = delete;-- /**- * @brief Updates all Spine animations- * @param registry ECS registry containing SpineAnimation components- * @param deltaTime Time elapsed since last update (seconds)- */- void update(ecs::Registry& registry, f32 deltaTime);-- /**- * @brief Forces reload of all skeleton assets- * @param registry ECS registry to update- */- void reloadAssets(ecs::Registry& registry);-- /**- * @brief Gets the Spine instance for an entity- * @param entity Entity to query- * @return Pointer to SpineInstance, or nullptr if not found- */- SpineInstance* getInstance(Entity entity);-- /**- * @brief Gets the Spine instance for an entity (const)- * @param entity Entity to query- * @return Const pointer to SpineInstance, or nullptr if not found- */- const SpineInstance* getInstance(Entity entity) const;-- /**- * @brief Plays an animation on an entity- * @param entity Target entity- * @param animation Animation name- * @param loop Whether to loop- * @param track Animation track (default 0)- * @return True if animation was set- */- bool playAnimation(Entity entity, const std::string& animation,- bool loop = true, i32 track = 0);-- /**- * @brief Adds an animation to the queue- * @param entity Target entity- * @param animation Animation name- * @param loop Whether to loop- * @param delay Delay before starting- * @param track Animation track (default 0)- * @return True if animation was queued- */- bool addAnimation(Entity entity, const std::string& animation,- bool loop = true, f32 delay = 0.0f, i32 track = 0);-- /**- * @brief Sets skin on an entity- * @param entity Target entity- * @param skinName Skin name- * @return True if skin was set- */- bool setSkin(Entity entity, const std::string& skinName);-- /**- * @brief Gets bone world position- * @param entity Target entity- * @param boneName Bone name- * @param outX Output X position- * @param outY Output Y position- * @return True if bone was found- */- bool getBonePosition(Entity entity, const std::string& boneName,- f32& outX, f32& outY) const;-- /**- * @brief Gets bone world rotation- * @param entity Target entity- * @param boneName Bone name- * @param outRotation Output rotation in degrees- * @return True if bone was found- */- bool getBoneRotation(Entity entity, const std::string& boneName,- f32& outRotation) const;-- /**- * @brief Gets skeleton bounds- * @param entity Target entity- * @param outX Output X offset- * @param outY Output Y offset- * @param outWidth Output width- * @param outHeight Output height- * @return True if bounds were retrieved- */- bool getSkeletonBounds(Entity entity, f32& outX, f32& outY,- f32& outWidth, f32& outHeight) const;-- std::vector<std::string> getAnimationNames(Entity entity) const;- std::vector<std::string> getSkinNames(Entity entity) const;-- // ── Constraints ─────────────────────────────────────────────────────-- struct ConstraintNames {- std::vector<std::string> ik;- std::vector<std::string> transform;- std::vector<std::string> path;- };-- ConstraintNames listConstraints(Entity entity) const;-- bool getTransformConstraintMix(Entity entity, const std::string& name,- f32& outRotate, f32& outX, f32& outY,- f32& outScaleX, f32& outScaleY, f32& outShearY) const;- bool setTransformConstraintMix(Entity entity, const std::string& name,- f32 rotate, f32 x, f32 y, f32 scaleX, f32 scaleY, f32 shearY);-- bool getPathConstraintMix(Entity entity, const std::string& name,- f32& outPosition, f32& outSpacing,- f32& outRotate, f32& outX, f32& outY) const;- bool setPathConstraintMix(Entity entity, const std::string& name,- f32 position, f32 spacing, f32 rotate, f32 x, f32 y);-- // ── Event buffer ────────────────────────────────────────────────────- static constexpr i32 MAX_NATIVE_EVENTS = 64;- static constexpr i32 EVENT_STRIDE = 4;-- struct NativeEventRecord {- Entity entity;- std::string animationName;- std::string eventName;- std::string stringValue;- };-- i32 getEventCount() const { return native_event_count_; }- const f32* getEventBuffer() const { return native_event_buffer_.data(); }- const NativeEventRecord& getEventRecord(i32 index) const { return native_event_records_[index]; }- void clearEvents();--private:- void recordEvent(Entity entity, ::spine::EventType type,- ::spine::TrackEntry* entry, ::spine::Event* event);- void loadSkeletonForEntity(Entity entity, ecs::SpineAnimation& comp);- void updateAnimation(Entity entity, ecs::SpineAnimation& comp, f32 deltaTime);- void syncComponentToInstance(Entity entity, ecs::SpineAnimation& comp);-- SpineResourceManager& resource_manager_;- std::unordered_map<Entity, SpineInstance> instances_;- // RAII: auto-unregisters from the registry's onDestroy on teardown, so a- // destroyed system never leaves a dangling `this` in the registry.- Connection destroyConn_;-- std::array<f32, MAX_NATIVE_EVENTS * EVENT_STRIDE> native_event_buffer_{};- std::array<NativeEventRecord, MAX_NATIVE_EVENTS> native_event_records_{};- i32 native_event_count_ = 0;-};--} // namespace esengine::spine