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.

feat: a DragonBones component, and a skeletal pair that names its runtime

esengine56441cd98f51
diff --git a/desktop/src/engine/schema.ts b/desktop/src/engine/schema.ts
index bfaee059f..369ec20d5 100644
--- a/desktop/src/engine/schema.ts
+++ b/desktop/src/engine/schema.ts
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
-import { getComponentRegistry, getUserComponents, getComponent, getComponentAssetFieldDescriptors, getComponentSpineFieldDescriptor, getComponentFieldMeta, Light2DType, usesStagger, isHexOrientation } from 'esengine';
+import { getComponentRegistry, getUserComponents, getComponent, getComponentAssetFieldDescriptors, getComponentSkeletalFieldDescriptor, getComponentFieldMeta, Light2DType, usesStagger, isHexOrientation } from 'esengine';
import type { App, SceneData } from 'esengine';
import type { NodeKind, InspectorField, EnumOption, GradientValue, CurveValue } from '@/types';
@@ -334,7 +334,7 @@ export function assetFieldType(compType: string, key: string): string | null {
*/
export type SpineSlotType = 'spine-skeleton' | 'spine-atlas';
export function spineSlotType(compType: string, key: string): SpineSlotType | null {
- const d = getComponentSpineFieldDescriptor(compType);
+ const d = getComponentSkeletalFieldDescriptor(compType);
if (!d) return null;
if (key === d.skeletonField) return 'spine-skeleton';
if (key === d.atlasField) return 'spine-atlas';
diff --git a/desktop/src/engine/spineSync.ts b/desktop/src/engine/spineSync.ts
index 13ea193d6..0a3436878 100644
--- a/desktop/src/engine/spineSync.ts
+++ b/desktop/src/engine/spineSync.ts
@@ -20,7 +20,7 @@
* an install every event is a no-op (dev/automation scene loads bind
* spine themselves, once).
*/
-import { getComponentSpineFieldDescriptor } from 'esengine';
+import { getComponentSkeletalFieldDescriptor } from 'esengine';
import { spineEntityProps } from 'esengine/spine';
import type { SceneData } from 'esengine';
import { SceneModel, type ModelEvent } from './SceneModel';
@@ -76,10 +76,10 @@ function onEvent(ev: ModelEvent): void {
return;
case 'componentAdded':
case 'componentChanged':
- if (getComponentSpineFieldDescriptor(ev.type)) syncEntity(ev.sourceId);
+ if (getComponentSkeletalFieldDescriptor(ev.type)) syncEntity(ev.sourceId);
return;
case 'componentRemoved':
- if (getComponentSpineFieldDescriptor(ev.type)) unbind(ev.sourceId);
+ if (getComponentSkeletalFieldDescriptor(ev.type)) unbind(ev.sourceId);
return;
case 'entityRemoved':
bound.delete(ev.sourceId); // the World despawn already dropped the instance
@@ -90,7 +90,7 @@ function onEvent(ev: ModelEvent): void {
/** The entity's spine component (any component with a spine field descriptor). */
function spineComp(entity: SceneEntity): { type: string; d: Record<string, unknown> } | null {
for (const c of entity.components ?? []) {
- if (getComponentSpineFieldDescriptor(c.type) && c.data) {
+ if (getComponentSkeletalFieldDescriptor(c.type) && c.data) {
return { type: c.type, d: c.data as Record<string, unknown> };
}
}
@@ -98,7 +98,7 @@ function spineComp(entity: SceneEntity): { type: string; d: Record<string, unkno
}
function stateOf(type: string, d: Record<string, unknown>): BoundState {
- const desc = getComponentSpineFieldDescriptor(type)!;
+ const desc = getComponentSkeletalFieldDescriptor(type)!;
const str = (v: unknown): string => (typeof v === 'string' ? v : '');
return {
skel: str(d[desc.skeletonField]),
diff --git a/desktop/src/project/assetImporter.ts b/desktop/src/project/assetImporter.ts
index a95133680..adb5386eb 100644
--- a/desktop/src/project/assetImporter.ts
+++ b/desktop/src/project/assetImporter.ts
@@ -67,6 +67,21 @@ const SPINE: ImporterFieldSpec[] = [
{ key: 'premultiplyAlpha', label: 'Premultiply Alpha', type: 'bool', default: false, category: 'Spine', advanced: true },
];
+// A DragonBones file is a project: it can hold several armatures, so which one an
+// entity gets is an import-time default rather than something derived from the
+// file. Spine needs no equivalent — its file IS one skeleton.
+const DRAGONBONES: ImporterFieldSpec[] = [
+ { key: 'scale', label: 'Scale', type: 'number', default: 1, min: 0, step: 0.01, category: 'DragonBones' },
+ {
+ key: 'defaultArmature', label: 'Default Armature', type: 'string', default: '', category: 'DragonBones',
+ tooltip: 'Armature used when an entity does not name one. Empty picks the first in the file.',
+ },
+ {
+ key: 'defaultAnimation', label: 'Default Animation', type: 'string', default: '', category: 'DragonBones',
+ tooltip: 'Played on spawn. Empty leaves the armature in its setup pose.',
+ },
+];
+
const AUDIO: ImporterFieldSpec[] = [
{
key: 'compress', label: 'Compress', type: 'bool', default: true, category: 'Audio',
@@ -117,6 +132,7 @@ export const IMPORTER_SCHEMAS: Record<string, ImporterFieldSpec[]> = {
texture: TEXTURE,
sprite: TEXTURE,
spine: SPINE,
+ dragonbones: DRAGONBONES,
audio: AUDIO,
video: VIDEO,
scene: SCENELIKE,
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index bdfc5f743..4ce64eac0 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -5,7 +5,7 @@ Symbols: 1361 stable · 17 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
-"7454a67d3890bcbc"
+"9219dd764c94a81e"
```
## ANCHOR_AXES — const
@@ -1160,7 +1160,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1654,7 +1654,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1667,7 +1667,7 @@ entityFields: string[] | undefined
fields: Record<string, FieldMeta> | undefined
readonlyFields: string[] | undefined
replicatedFields: string[] | undefined
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean | undefined
```
@@ -1705,6 +1705,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -1737,6 +1738,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -1765,6 +1767,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -1793,6 +1796,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
@@ -8988,9 +8992,9 @@ FsmPlugin
(): Map<string, AnyComponentDef>
```
-## getComponentSpineFieldDescriptor — function
+## getComponentSkeletalFieldDescriptor — function
```
-(componentType: string): { skeletonField: string; atlasField: string; } | null
+(componentType: string): { skeletonField: string; atlasField: string; runtime: string; } | null
```
## getControllerPage — function
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 8dc406e1e..f3d7d50e8 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -5,7 +5,7 @@ Symbols: 1380 stable · 22 beta · 1 deprecated
## ABI_LAYOUT_HASH — const
```
-"7454a67d3890bcbc"
+"9219dd764c94a81e"
```
## ANCHOR_AXES — const
@@ -1160,7 +1160,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1654,7 +1654,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1675,7 +1675,7 @@ entityFields: string[] | undefined
fields: Record<string, FieldMeta> | undefined
readonlyFields: string[] | undefined
replicatedFields: string[] | undefined
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean | undefined
```
@@ -1713,6 +1713,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -1745,6 +1746,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -1773,6 +1775,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -1801,6 +1804,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
@@ -9192,9 +9196,9 @@ FsmPlugin
(): Map<string, AnyComponentDef>
```
-## getComponentSpineFieldDescriptor — function
+## getComponentSkeletalFieldDescriptor — function
```
-(componentType: string): { skeletonField: string; atlasField: string; } | null
+(componentType: string): { skeletonField: string; atlasField: string; runtime: string; } | null
```
## getControllerPage — function
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index b68b57ec6..a31fca112 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1155,7 +1155,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1649,7 +1649,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1662,7 +1662,7 @@ entityFields: string[] | undefined
fields: Record<string, FieldMeta> | undefined
readonlyFields: string[] | undefined
replicatedFields: string[] | undefined
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean | undefined
```
@@ -1700,6 +1700,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -1732,6 +1733,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -1760,6 +1762,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -1788,6 +1791,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
@@ -8983,9 +8987,9 @@ FsmPlugin
(): Map<string, AnyComponentDef>
```
-## getComponentSpineFieldDescriptor — function
+## getComponentSkeletalFieldDescriptor — function
```
-(componentType: string): { skeletonField: string; atlasField: string; } | null
+(componentType: string): { skeletonField: string; atlasField: string; runtime: string; } | null
```
## getControllerPage — function
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index fa9f03399..d30c3978f 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1155,7 +1155,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1649,7 +1649,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1662,7 +1662,7 @@ entityFields: string[] | undefined
fields: Record<string, FieldMeta> | undefined
readonlyFields: string[] | undefined
replicatedFields: string[] | undefined
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean | undefined
```
@@ -1700,6 +1700,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -1732,6 +1733,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -1760,6 +1762,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -1788,6 +1791,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
@@ -9203,9 +9207,9 @@ FsmPlugin
(): Map<string, AnyComponentDef>
```
-## getComponentSpineFieldDescriptor — function
+## getComponentSkeletalFieldDescriptor — function
```
-(componentType: string): { skeletonField: string; atlasField: string; } | null
+(componentType: string): { skeletonField: string; atlasField: string; runtime: string; } | null
```
## getControllerPage — function
diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.md
index 715dbb3bf..5fd100c66 100644
--- a/sdk/etc/wasm.api.md
+++ b/sdk/etc/wasm.api.md
@@ -20,6 +20,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -52,6 +53,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -80,6 +82,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -108,6 +111,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 363026279..4277c5eff 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1155,7 +1155,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1649,7 +1649,7 @@ entityFields: readonly string[]
fieldMeta: Readonly<Record<string, FieldMeta>>
readonlyFields: readonly string[]
replicatedFields: readonly string[]
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean
```
@@ -1662,7 +1662,7 @@ entityFields: string[] | undefined
fields: Record<string, FieldMeta> | undefined
readonlyFields: string[] | undefined
replicatedFields: string[] | undefined
-spineFields: SpineFieldMeta | undefined
+skeletalFields: SkeletalFieldMeta | undefined
transient: boolean | undefined
```
@@ -1700,6 +1700,7 @@ addCanvas: (entity: Entity, component: Canvas) => void
addCapsuleCollider: (entity: Entity, component: CapsuleCollider) => void
addChildren: (entity: Entity, component: Children) => void
addCircleCollider: (entity: Entity, component: CircleCollider) => void
+addDragonBonesAnimation: (entity: Entity, component: DragonBonesAnimation) => void
addFlexContainer: (entity: Entity, component: FlexContainer) => void
addInteractable: (entity: Entity, component: Interactable) => void
addLight2D: (entity: Entity, component: Light2D) => void
@@ -1732,6 +1733,7 @@ getCanvas: (entity: Entity) => Canvas
getCapsuleCollider: (entity: Entity) => CapsuleCollider
getChildren: (entity: Entity) => Children
getCircleCollider: (entity: Entity) => CircleCollider
+getDragonBonesAnimation: (entity: Entity) => DragonBonesAnimation
getFlexContainer: (entity: Entity) => FlexContainer
getInteractable: (entity: Entity) => Interactable
getLight2D: (entity: Entity) => Light2D
@@ -1760,6 +1762,7 @@ hasCanvas: (entity: Entity) => boolean
hasCapsuleCollider: (entity: Entity) => boolean
hasChildren: (entity: Entity) => boolean
hasCircleCollider: (entity: Entity) => boolean
+hasDragonBonesAnimation: (entity: Entity) => boolean
hasFlexContainer: (entity: Entity) => boolean
hasInteractable: (entity: Entity) => boolean
hasLight2D: (entity: Entity) => boolean
@@ -1788,6 +1791,7 @@ removeCanvas: (entity: Entity) => void
removeCapsuleCollider: (entity: Entity) => void
removeChildren: (entity: Entity) => void
removeCircleCollider: (entity: Entity) => void
+removeDragonBonesAnimation: (entity: Entity) => void
removeFlexContainer: (entity: Entity) => void
removeInteractable: (entity: Entity) => void
removeLight2D: (entity: Entity) => void
@@ -9007,9 +9011,9 @@ FsmPlugin
(): Map<string, AnyComponentDef>
```
-## getComponentSpineFieldDescriptor — function
+## getComponentSkeletalFieldDescriptor — function
```
-(componentType: string): { skeletonField: string; atlasField: string; } | null
+(componentType: string): { skeletonField: string; atlasField: string; runtime: string; } | null
```
## getControllerPage — function
diff --git a/sdk/src/asset/discoverAssets.ts b/sdk/src/asset/discoverAssets.ts
index b6d536772..e6b48b059 100644
--- a/sdk/src/asset/discoverAssets.ts
+++ b/sdk/src/asset/discoverAssets.ts
@@ -6,7 +6,7 @@
*
* Each component may reference assets in three ways: a custom
* `discoverAssets` callback, declared `assetFields`, or paired
- * `spineFields`. This module walks a SceneData and buckets every
+ * `skeletalFields`. This module walks a SceneData and buckets every
* such ref by asset type. A `discoverAssets` callback is authoritative:
* when present, `assetFields` are not walked for discovery (they still
* drive the editor's asset pickers and ref rewrites) — the callback may
@@ -118,9 +118,9 @@ export function discoverSceneAssets(
}
}
- if (comp.spineFields) {
- const skelRaw = data[comp.spineFields.skeletonField] as string;
- const atlasRaw = data[comp.spineFields.atlasField] as string;
+ if (comp.skeletalFields) {
+ const skelRaw = data[comp.skeletalFields.skeletonField] as string;
+ const atlasRaw = data[comp.skeletalFields.atlasField] as string;
if (skelRaw && atlasRaw) {
const skel = resolve(skelRaw);
const atlas = resolve(atlasRaw);
diff --git a/sdk/src/component.generated.ts b/sdk/src/component.generated.ts
index 51c71156f..7da46cf7b 100644
--- a/sdk/src/component.generated.ts
+++ b/sdk/src/component.generated.ts
@@ -15,16 +15,18 @@ import type { Dimension, Padding } from './wasm.generated';
* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to
* run on mismatch, because mismatched offsets read the wrong heap bytes.
*/
-export const ABI_LAYOUT_HASH = '7454a67d3890bcbc';
+export const ABI_LAYOUT_HASH = '9219dd764c94a81e';
export interface AssetFieldMeta {
field: string;
type: AssetFieldType;
}
-export interface SpineFieldMeta {
+export interface SkeletalFieldMeta {
skeletonField: string;
atlasField: string;
+ /** Which runtime the pair belongs to — `spine`, `dragonbones`. */
+ runtime: string;
}
export interface ComponentMetaEntry {
@@ -37,7 +39,7 @@ export interface ComponentMetaEntry {
*/
editorDefaults?: Record<string, unknown>;
assetFields: AssetFieldMeta[];
- spine?: SpineFieldMeta;
+ skeletal?: SkeletalFieldMeta;
entityFields: string[];
colorFields: string[];
animatableFields: string[];
@@ -198,6 +200,36 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
colorFields: [],
animatableFields: [],
},
+ DragonBonesAnimation: {
+ defaults: {
+ skeletonPath: '',
+ atlasPath: '',
+ armature: '',
+ animation: '',
+ timeScale: 1,
+ loop: true,
+ playing: true,
+ fadeInTime: 0,
+ flipX: false,
+ flipY: false,
+ color: { r: 1, g: 1, b: 1, a: 1 },
+ layer: 0,
+ skeletonScale: 1,
+ material: 0,
+ enabled: true,
+ },
+ assetFields: [{ field: 'material', type: 'material' as AssetFieldType }],
+ skeletal: { skeletonField: 'skeletonPath', atlasField: 'atlasPath', runtime: 'dragonbones' },
+ entityFields: [],
+ colorFields: ['color'],
+ animatableFields: [],
+ fields: {
+ timeScale: { min: 0 },
+ fadeInTime: { min: 0, step: 0.05 },
+ layer: { step: 1, enumSource: "sortingLayers" },
+ skeletonScale: { min: 0 },
+ },
+ },
FlexContainer: {
defaults: {
direction: 0,
@@ -523,7 +555,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
enabled: true,
},
assetFields: [{ field: 'material', type: 'material' as AssetFieldType }],
- spine: { skeletonField: 'skeletonPath', atlasField: 'atlasPath' },
+ skeletal: { skeletonField: 'skeletonPath', atlasField: 'atlasPath', runtime: 'spine' },
entityFields: [],
colorFields: ['color'],
animatableFields: [],
@@ -832,6 +864,24 @@ export interface CircleColliderData {
maskBits: number;
}
+export interface DragonBonesAnimationData {
+ skeletonPath: string;
+ atlasPath: string;
+ armature: string;
+ animation: string;
+ timeScale: number;
+ loop: boolean;
+ playing: boolean;
+ fadeInTime: number;
+ flipX: boolean;
+ flipY: boolean;
+ color: Color;
+ layer: number;
+ skeletonScale: number;
+ material: number;
+ enabled: boolean;
+}
+
export interface FlexContainerData {
direction: number;
wrap: number;
diff --git a/sdk/src/component.ts b/sdk/src/component.ts
index 88a2f07bb..dfa0fda4b 100644
--- a/sdk/src/component.ts
+++ b/sdk/src/component.ts
@@ -7,14 +7,14 @@
import { Entity, Vec2, Vec3, Color, Quat } from './types';
import { deepClone } from './deepClone';
-import { COMPONENT_META, type AssetFieldMeta, type SpineFieldMeta } from './component.generated';
+import { COMPONENT_META, type AssetFieldMeta, type SkeletalFieldMeta } from './component.generated';
// C++-backed component data shapes, generated from the ES_COMPONENT structs (single
// source — a TS field can no longer drift from C++). Re-exported below so the public
// `esengine` import site is unchanged; Camera/ParticleEmitter add TS-only fields by
// extending the generated base.
import type {
TransformData, SpriteData, ShapeRendererData, Light2DData, ShadowCaster2DData,
- CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData,
+ CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,
TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,
CameraData as CameraDataCpp, ParticleEmitterData as ParticleEmitterDataCpp,
Mesh2DData as Mesh2DDataCpp,
@@ -93,7 +93,7 @@ export interface FieldMeta {
export interface ComponentMetadata {
assetFields?: AssetFieldMeta[];
- spineFields?: SpineFieldMeta;
+ skeletalFields?: SkeletalFieldMeta;
entityFields?: string[];
/** Per-field editor presentation policy, keyed by field name. */
fields?: Record<string, FieldMeta>;
@@ -160,7 +160,7 @@ export interface ComponentDef<T> {
readonly _default: T;
readonly _builtin: false;
readonly assetFields: readonly AssetFieldMeta[];
- readonly spineFields?: SpineFieldMeta;
+ readonly skeletalFields?: SkeletalFieldMeta;
readonly entityFields: readonly string[];
readonly colorKeys: readonly string[];
readonly animatableFields: readonly string[];
@@ -235,7 +235,7 @@ function createComponentDef<T extends object>(
_default: defaults,
_builtin: false as const,
assetFields: metadata?.assetFields ?? [],
- spineFields: metadata?.spineFields,
+ skeletalFields: metadata?.skeletalFields,
entityFields: metadata?.entityFields ?? [],
colorKeys: detectColorKeys(defaults),
animatableFields: metadata?.animatableFields ?? numericAnimatableFields(defaults),
@@ -367,7 +367,7 @@ export interface BuiltinComponentDef<T> {
readonly _builtin: true;
readonly _default: T;
readonly assetFields: readonly AssetFieldMeta[];
- readonly spineFields?: SpineFieldMeta;
+ readonly skeletalFields?: SkeletalFieldMeta;
readonly entityFields: readonly string[];
readonly colorKeys: readonly string[];
readonly animatableFields: readonly string[];
@@ -519,7 +519,7 @@ export function defineBuiltin<T>(name: string, defaults: T, metadata?: Component
_builtin: true,
_default: defaults,
assetFields: metadata?.assetFields ?? meta?.assetFields ?? [],
- spineFields: metadata?.spineFields ?? meta?.spine,
+ skeletalFields: metadata?.skeletalFields ?? meta?.skeletal,
entityFields: metadata?.entityFields ?? meta?.entityFields ?? [],
colorKeys: meta?.colorFields ?? detectColorKeys(defaults),
animatableFields: meta?.animatableFields ?? [],
@@ -590,7 +590,7 @@ export type ScaleMode = (typeof ScaleMode)[keyof typeof ScaleMode];
// automatically; tsc then enforces every consumer matches.
export type {
TransformData, SpriteData, ShapeRendererData, Light2DData, ShadowCaster2DData,
- CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData,
+ CanvasData, VelocityData, ParentData, ChildrenData, SpineAnimationData, DragonBonesAnimationData,
TilemapLayerData, BitmapTextData, TrailRendererData, ParticleForceFieldData,
};
@@ -710,6 +710,10 @@ export const SpineAnimation = defineBuiltin<SpineAnimationData>('SpineAnimation'
metaDefaults<SpineAnimationData>('SpineAnimation')
);
+export const DragonBonesAnimation = defineBuiltin<DragonBonesAnimationData>('DragonBonesAnimation',
+ metaDefaults<DragonBonesAnimationData>('DragonBonesAnimation')
+);
+
/**
* Local-space geometry of a Mesh2D renderable (triangle list, indexed).
* `positions` is x,y pairs; `uvs` is u,v pairs (default 0,0); `colors` is r,g,b,a
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index d0240b3d7..af4787181 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -116,7 +116,7 @@ export {
registerSceneComponentCodec,
getComponentAssetFields,
getComponentAssetFieldDescriptors,
- getComponentSpineFieldDescriptor,
+ getComponentSkeletalFieldDescriptor,
type AssetFieldType,
type SceneData,
type SceneEntityData,
diff --git a/sdk/src/ecs/ptrAccessors.generated.ts b/sdk/src/ecs/ptrAccessors.generated.ts
index 3fe64e5fb..348ae4b7f 100644
--- a/sdk/src/ecs/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/ptrAccessors.generated.ts
@@ -337,6 +337,70 @@ export function createCircleColliderData(): CircleColliderPtrData {
};
}
+export interface DragonBonesAnimationPtrData {
+ timeScale: number;
+ loop: boolean;
+ playing: boolean;
+ fadeInTime: number;
+ flipX: boolean;
+ flipY: boolean;
+ color: Color;
+ layer: number;
+ skeletonScale: number;
+ material: number;
+ enabled: boolean;
+}
+
+export function fillDragonBonesAnimation(
+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,
+ ptr: number, out: DragonBonesAnimationPtrData,
+): void {
+ out.timeScale = f32[(ptr + 48) >> 2];
+ out.loop = u8[ptr + 52] !== 0;
+ out.playing = u8[ptr + 53] !== 0;
+ out.fadeInTime = f32[(ptr + 56) >> 2];
+ out.flipX = u8[ptr + 60] !== 0;
+ out.flipY = u8[ptr + 61] !== 0;
+ const color_ = out.color; color_.r = f32[(ptr + 64) >> 2]; color_.g = f32[((ptr + 64) >> 2) + 1]; color_.b = f32[((ptr + 64) >> 2) + 2]; color_.a = f32[((ptr + 64) >> 2) + 3];
+ out.layer = u32[(ptr + 80) >> 2] | 0;
+ out.skeletonScale = f32[(ptr + 84) >> 2];
+ out.material = u32[(ptr + 88) >> 2];
+ out.enabled = u8[ptr + 92] !== 0;
+}
+
+export function writeDragonBonesAnimation(
+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,
+ ptr: number, data: DragonBonesAnimationPtrData,
+): void {
+ f32[(ptr + 48) >> 2] = data.timeScale;
+ u8[ptr + 52] = data.loop ? 1 : 0;
+ u8[ptr + 53] = data.playing ? 1 : 0;
+ f32[(ptr + 56) >> 2] = data.fadeInTime;
+ u8[ptr + 60] = data.flipX ? 1 : 0;
+ u8[ptr + 61] = data.flipY ? 1 : 0;
+ f32[(ptr + 64) >> 2] = data.color.r; f32[((ptr + 64) >> 2) + 1] = data.color.g; f32[((ptr + 64) >> 2) + 2] = data.color.b; f32[((ptr + 64) >> 2) + 3] = data.color.a;
+ u32[(ptr + 80) >> 2] = data.layer | 0;
+ f32[(ptr + 84) >> 2] = data.skeletonScale;
+ u32[(ptr + 88) >> 2] = data.material;
+ u8[ptr + 92] = data.enabled ? 1 : 0;
+}
+
+export function createDragonBonesAnimationData(): DragonBonesAnimationPtrData {
+ return {
+ timeScale: 0,
+ loop: false,
+ playing: false,
+ fadeInTime: 0,
+ flipX: false,
+ flipY: false,
+ color: { r: 0, g: 0, b: 0, a: 0 },
+ layer: 0,
+ skeletonScale: 0,
+ material: 0,
+ enabled: false,
+ };
+}
+
export interface FlexContainerPtrData {
direction: number;
wrap: number;
@@ -1602,6 +1666,7 @@ export const PTR_ACCESSORS: Record<string, PtrAccessor<any>> = {
Canvas: { fill: fillCanvas, write: writeCanvas, create: createCanvasData },
CapsuleCollider: { fill: fillCapsuleCollider, write: writeCapsuleCollider, create: createCapsuleColliderData },
CircleCollider: { fill: fillCircleCollider, write: writeCircleCollider, create: createCircleColliderData },
+ DragonBonesAnimation: { fill: fillDragonBonesAnimation, write: writeDragonBonesAnimation, create: createDragonBonesAnimationData },
FlexContainer: { fill: fillFlexContainer, write: writeFlexContainer, create: createFlexContainerData },
Interactable: { fill: fillInteractable, write: writeInteractable, create: createInteractableData },
Light2D: { fill: fillLight2D, write: writeLight2D, create: createLight2DData },
diff --git a/sdk/src/ptrLayouts.generated.ts b/sdk/src/ptrLayouts.generated.ts
index d78f0cecf..746747b2a 100644
--- a/sdk/src/ptrLayouts.generated.ts
+++ b/sdk/src/ptrLayouts.generated.ts
@@ -109,6 +109,22 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ name: 'maskBits', type: 'u32', offset: 32 },
],
},
+ DragonBonesAnimation: {
+ ptrFn: 'getDragonBonesAnimationPtr',
+ fields: [
+ { name: 'timeScale', type: 'f32', offset: 48 },
+ { name: 'loop', type: 'bool', offset: 52 },
+ { name: 'playing', type: 'bool', offset: 53 },
+ { name: 'fadeInTime', type: 'f32', offset: 56 },
+ { name: 'flipX', type: 'bool', offset: 60 },
+ { name: 'flipY', type: 'bool', offset: 61 },
+ { name: 'color', type: 'color', offset: 64 },
+ { name: 'layer', type: 'i32', offset: 80 },
+ { name: 'skeletonScale', type: 'f32', offset: 84 },
+ { name: 'material', type: 'u32', offset: 88 },
+ { name: 'enabled', type: 'bool', offset: 92 },
+ ],
+ },
FlexContainer: {
ptrFn: 'getFlexContainerPtr',
fields: [
diff --git a/sdk/src/scene.ts b/sdk/src/scene.ts
index e0176fcd8..336a58cf6 100644
--- a/sdk/src/scene.ts
+++ b/sdk/src/scene.ts
@@ -119,9 +119,9 @@ export function getComponentAssetFields(componentType: string): string[] {
for (const { field } of comp.assetFields) {
fields.push(field);
}
- if (comp.spineFields) {
- fields.push(comp.spineFields.skeletonField);
- fields.push(comp.spineFields.atlasField);
+ if (comp.skeletalFields) {
+ fields.push(comp.skeletalFields.skeletonField);
+ fields.push(comp.skeletalFields.atlasField);
}
return fields;
}
@@ -132,10 +132,11 @@ export function getComponentAssetFieldDescriptors(
return getComponent(componentType)?.assetFields ?? [];
}
-export function getComponentSpineFieldDescriptor(
+/** The skeleton/atlas pair a component carries, and whose runtime it belongs to. */
+export function getComponentSkeletalFieldDescriptor(
componentType: string,
-): { skeletonField: string; atlasField: string } | null {
- return getComponent(componentType)?.spineFields ?? null;
+): { skeletonField: string; atlasField: string; runtime: string } | null {
+ return getComponent(componentType)?.skeletalFields ?? null;
}
// =============================================================================
diff --git a/sdk/src/spine/loadSpineScene.ts b/sdk/src/spine/loadSpineScene.ts
index 9937b1b37..d6057b46a 100644
--- a/sdk/src/spine/loadSpineScene.ts
+++ b/sdk/src/spine/loadSpineScene.ts
@@ -18,7 +18,7 @@
*/
import type { ESEngineModule } from '../wasm';
import type { Entity } from '../types';
-import { getComponentSpineFieldDescriptor, type SceneData } from '../scene';
+import { getComponentSkeletalFieldDescriptor, type SceneData } from '../scene';
import { discoverSceneAssets } from '../asset/discoverAssets';
import { getAssetTypeEntry } from '../assetTypes';
import { requireResourceManager } from '../resourceManager';
@@ -180,7 +180,7 @@ export async function applySpineEntities(opts: {
// expands prefabs before this runs).
if (!Array.isArray(sceneEntity.components)) continue;
for (const comp of sceneEntity.components) {
- const spineDesc = getComponentSpineFieldDescriptor(comp.type);
+ const spineDesc = getComponentSkeletalFieldDescriptor(comp.type);
if (!spineDesc || !comp.data) continue;
const skelRef = comp.data[spineDesc.skeletonField] as string;
const atlasRef = comp.data[spineDesc.atlasField] as string;
diff --git a/sdk/src/wasm.generated.ts b/sdk/src/wasm.generated.ts
index d7c839470..39dc84743 100644
--- a/sdk/src/wasm.generated.ts
+++ b/sdk/src/wasm.generated.ts
@@ -277,6 +277,24 @@ export interface CircleCollider {
maskBits: number;
}
+export interface DragonBonesAnimation {
+ skeletonPath: string;
+ atlasPath: string;
+ armature: string;
+ animation: string;
+ timeScale: number;
+ loop: boolean;
+ playing: boolean;
+ fadeInTime: number;
+ flipX: boolean;
+ flipY: boolean;
+ color: Vec4;
+ layer: number;
+ skeletonScale: number;
+ material: number;
+ enabled: boolean;
+}
+
export interface FlexContainer {
direction: number;
wrap: number;
@@ -593,6 +611,10 @@ export interface Registry {
getCircleCollider(entity: Entity): CircleCollider;
addCircleCollider(entity: Entity, component: CircleCollider): void;
removeCircleCollider(entity: Entity): void;
+ hasDragonBonesAnimation(entity: Entity): boolean;
+ getDragonBonesAnimation(entity: Entity): DragonBonesAnimation;
+ addDragonBonesAnimation(entity: Entity, component: DragonBonesAnimation): void;
+ removeDragonBonesAnimation(entity: Entity): void;
hasFlexContainer(entity: Entity): boolean;
getFlexContainer(entity: Entity): FlexContainer;
addFlexContainer(entity: Entity, component: FlexContainer): void;
@@ -698,6 +720,7 @@ export interface ESEngineModule {
CapsuleCollider: new () => CapsuleCollider;
Children: new () => Children;
CircleCollider: new () => CircleCollider;
+ DragonBonesAnimation: new () => DragonBonesAnimation;
FlexContainer: new () => FlexContainer;
Interactable: new () => Interactable;
Light2D: new () => Light2D;
diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
index d389e4ed1..a2e20f2d7 100644
--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
@@ -126,6 +126,22 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho
"tooltip": "How the canvas adapts the design resolution to the screen.",
},
},
+ "DragonBonesAnimation": {
+ "fadeInTime": {
+ "min": 0,
+ "step": 0.05,
+ },
+ "layer": {
+ "enumSource": "sortingLayers",
+ "step": 1,
+ },
+ "skeletonScale": {
+ "min": 0,
+ },
+ "timeScale": {
+ "min": 0,
+ },
+ },
"Light2D": {
"direction": {
"advanced": true,
diff --git a/sdk/tests/discoverAssets.test.ts b/sdk/tests/discoverAssets.test.ts
index a4c407556..29f362ba0 100644
--- a/sdk/tests/discoverAssets.test.ts
+++ b/sdk/tests/discoverAssets.test.ts
@@ -38,7 +38,7 @@ beforeEach(() => {
skeleton: '',
atlas: '',
}, {
- spineFields: { skeletonField: 'skeleton', atlasField: 'atlas' },
+ skeletalFields: { skeletonField: 'skeleton', atlasField: 'atlas' },
});
defineComponent(SM_NAME, {
@@ -403,7 +403,7 @@ describe('discoverSceneAssets with UUID refResolver', () => {
expect(refs.unresolved).toEqual([makeUuidRef(UUID_MISSING)]);
});
- it('resolves spineFields via the same resolver', () => {
+ it('resolves skeletalFields via the same resolver', () => {
const reg = new AssetRegistry();
const UUID_SKEL = '11111111-1111-4111-8111-111111111111';
const UUID_ATLAS = '22222222-2222-4222-8222-222222222222';
diff --git a/sdk/tests/scene.test.ts b/sdk/tests/scene.test.ts
index ca654e5ac..57a145055 100644
--- a/sdk/tests/scene.test.ts
+++ b/sdk/tests/scene.test.ts
@@ -19,7 +19,7 @@ import {
serializeEntityComponents,
getComponentAssetFields,
getComponentAssetFieldDescriptors,
- getComponentSpineFieldDescriptor,
+ getComponentSkeletalFieldDescriptor,
type SceneData,
type SceneComponentData,
} from '../src/scene';
@@ -115,16 +115,23 @@ describe('Scene', () => {
expect(getComponentAssetFieldDescriptors('NonExistent')).toEqual([]);
});
- it('should return spine field descriptor', () => {
- const spine = getComponentSpineFieldDescriptor('SpineAnimation');
- expect(spine).toEqual({
+ it('pairs a skeletal component`s two halves, and says whose they are', () => {
+ // The runtime rides along because the pair alone cannot tell a Spine
+ // skeleton from a DragonBones one — the field names are the same.
+ expect(getComponentSkeletalFieldDescriptor('SpineAnimation')).toEqual({
skeletonField: 'skeletonPath',
atlasField: 'atlasPath',
+ runtime: 'spine',
+ });
+ expect(getComponentSkeletalFieldDescriptor('DragonBonesAnimation')).toEqual({
+ skeletonField: 'skeletonPath',
+ atlasField: 'atlasPath',
+ runtime: 'dragonbones',
});
});
it('should return null spine descriptor for non-spine component', () => {
- expect(getComponentSpineFieldDescriptor('Sprite')).toBeNull();
+ expect(getComponentSkeletalFieldDescriptor('Sprite')).toBeNull();
});
});
diff --git a/sdk/tests/spine-apply-routing.test.ts b/sdk/tests/spine-apply-routing.test.ts
index 8d15f8039..b92a2abac 100644
--- a/sdk/tests/spine-apply-routing.test.ts
+++ b/sdk/tests/spine-apply-routing.test.ts
@@ -18,7 +18,7 @@ const SPINE_COMP = 'ApplyRouting_Spine';
beforeEach(() => {
clearUserComponents();
defineComponent(SPINE_COMP, { skeleton: '', atlas: '' }, {
- spineFields: { skeletonField: 'skeleton', atlasField: 'atlas' },
+ skeletalFields: { skeletonField: 'skeleton', atlasField: 'atlas' },
});
});
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 9264d40b3..b2360dd4b 100644
--- a/src/esengine/bindings/EditorAPI.generated.cpp
+++ b/src/esengine/bindings/EditorAPI.generated.cpp
@@ -2,10 +2,10 @@
* @file EditorAPI.generated.cpp
* @brief Auto-generated editor API with string-dispatched component access
* @details Generated by EHT - DO NOT EDIT
- * @schema_hash 143effaba07f6224
+ * @schema_hash 73200e0a9e5cd114
*/
-#define ES_EDITOR_API_SCHEMA_HASH "143effaba07f6224"
+#define ES_EDITOR_API_SCHEMA_HASH "73200e0a9e5cd114"
#include <emscripten/bind.h>
#include <string>
@@ -15,6 +15,7 @@
#include "../ecs/components/Camera.hpp"
#include "../ecs/components/Canvas.hpp"
#include "../ecs/components/Collider.hpp"
+#include "../ecs/components/DragonBonesAnimation.hpp"
#include "../ecs/components/FlexContainer.hpp"
#include "../ecs/components/Hierarchy.hpp"
#include "../ecs/components/Interactable.hpp"
@@ -61,6 +62,7 @@ std::vector<std::string> editor_getComponentNames() {
"CapsuleCollider",
"Children",
"CircleCollider",
+ "DragonBonesAnimation",
"FlexContainer",
"Interactable",
"Light2D",
@@ -178,6 +180,27 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"categoryBits","type":"int","group":"CircleCollider"},
{"key":"maskBits","type":"int","group":"CircleCollider"}
])JSON";
+ } else if (name == "DragonBonesAnimation") {
+ return R"JSON([
+ {"key":"skeletonPath","type":"asset","group":"DragonBonesAnimation"},
+ {"key":"atlasPath","type":"asset","group":"DragonBonesAnimation"},
+ {"key":"armature","type":"string","group":"DragonBonesAnimation"},
+ {"key":"animation","type":"string","group":"DragonBonesAnimation"},
+ {"key":"timeScale","type":"float","group":"DragonBonesAnimation"},
+ {"key":"loop","type":"bool","group":"DragonBonesAnimation"},
+ {"key":"playing","type":"bool","group":"DragonBonesAnimation"},
+ {"key":"fadeInTime","type":"float","group":"DragonBonesAnimation"},
+ {"key":"flipX","type":"bool","group":"DragonBonesAnimation"},
+ {"key":"flipY","type":"bool","group":"DragonBonesAnimation"},
+ {"key":"color.r","type":"color","group":"DragonBonesAnimation"},
+ {"key":"color.g","type":"color","group":"DragonBonesAnimation"},
+ {"key":"color.b","type":"color","group":"DragonBonesAnimation"},
+ {"key":"color.a","type":"color","group":"DragonBonesAnimation"},
+ {"key":"layer","type":"int","group":"DragonBonesAnimation"},
+ {"key":"skeletonScale","type":"float","group":"DragonBonesAnimation"},
+ {"key":"material","type":"asset","group":"DragonBonesAnimation"},
+ {"key":"enabled","type":"bool","group":"DragonBonesAnimation"}
+ ])JSON";
} else if (name == "FlexContainer") {
return R"JSON([
{"key":"direction","type":"enum","group":"FlexContainer","values":["Row","Column","RowReverse","ColumnReverse"]},
@@ -574,6 +597,9 @@ bool editor_addComponent(Registry& reg, u32 e, const std::string& name) {
} else if (name == "CircleCollider") {
if (!reg.has<esengine::ecs::CircleCollider>(entity)) reg.emplace<esengine::ecs::CircleCollider>(entity);
return true;
+ } else if (name == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) reg.emplace<esengine::ecs::DragonBonesAnimation>(entity);
+ return true;
} else if (name == "FlexContainer") {
if (!reg.has<esengine::ecs::FlexContainer>(entity)) reg.emplace<esengine::ecs::FlexContainer>(entity);
return true;
@@ -658,6 +684,8 @@ bool editor_removeComponent(Registry& reg, u32 e, const std::string& name) {
if (reg.has<esengine::ecs::Children>(entity)) { reg.remove<esengine::ecs::Children>(entity); return true; }
} else if (name == "CircleCollider") {
if (reg.has<esengine::ecs::CircleCollider>(entity)) { reg.remove<esengine::ecs::CircleCollider>(entity); return true; }
+ } else if (name == "DragonBonesAnimation") {
+ if (reg.has<esengine::ecs::DragonBonesAnimation>(entity)) { reg.remove<esengine::ecs::DragonBonesAnimation>(entity); return true; }
} else if (name == "FlexContainer") {
if (reg.has<esengine::ecs::FlexContainer>(entity)) { reg.remove<esengine::ecs::FlexContainer>(entity); return true; }
} else if (name == "Interactable") {
@@ -714,6 +742,7 @@ bool editor_hasComponent(Registry& reg, u32 e, const std::string& name) {
if (name == "CapsuleCollider") return reg.has<esengine::ecs::CapsuleCollider>(entity);
if (name == "Children") return reg.has<esengine::ecs::Children>(entity);
if (name == "CircleCollider") return reg.has<esengine::ecs::CircleCollider>(entity);
+ if (name == "DragonBonesAnimation") return reg.has<esengine::ecs::DragonBonesAnimation>(entity);
if (name == "FlexContainer") return reg.has<esengine::ecs::FlexContainer>(entity);
if (name == "Interactable") return reg.has<esengine::ecs::Interactable>(entity);
if (name == "Light2D") return reg.has<esengine::ecs::Light2D>(entity);
@@ -751,6 +780,7 @@ std::vector<std::string> editor_getComponents(Registry& reg, u32 e) {
if (reg.has<esengine::ecs::CapsuleCollider>(entity)) result.push_back("CapsuleCollider");
if (reg.has<esengine::ecs::Children>(entity)) result.push_back("Children");
if (reg.has<esengine::ecs::CircleCollider>(entity)) result.push_back("CircleCollider");
+ if (reg.has<esengine::ecs::DragonBonesAnimation>(entity)) result.push_back("DragonBonesAnimation");
if (reg.has<esengine::ecs::FlexContainer>(entity)) result.push_back("FlexContainer");
if (reg.has<esengine::ecs::Interactable>(entity)) result.push_back("Interactable");
if (reg.has<esengine::ecs::Light2D>(entity)) result.push_back("Light2D");
@@ -853,6 +883,18 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
else if (field == "restitution") { c.restitution = value; }
else { return false; }
return true;
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "timeScale") { c.timeScale = value; }
+ else if (field == "fadeInTime") { c.fadeInTime = value; }
+ else if (field == "color.r") { c.color.r = value; }
+ else if (field == "color.g") { c.color.g = value; }
+ else if (field == "color.b") { c.color.b = value; }
+ else if (field == "color.a") { c.color.a = value; }
+ else if (field == "skeletonScale") { c.skeletonScale = value; }
+ else { return false; }
+ return true;
} else if (comp == "FlexContainer") {
if (!reg.has<esengine::ecs::FlexContainer>(entity)) return false;
auto& c = reg.get<esengine::ecs::FlexContainer>(entity);
@@ -1223,6 +1265,16 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "density") { return c.density; }
else if (field == "friction") { return c.friction; }
else if (field == "restitution") { return c.restitution; }
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return 0.0f;
+ const auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "timeScale") { return c.timeScale; }
+ else if (field == "fadeInTime") { return c.fadeInTime; }
+ else if (field == "color.r") { return c.color.r; }
+ else if (field == "color.g") { return c.color.g; }
+ else if (field == "color.b") { return c.color.b; }
+ else if (field == "color.a") { return c.color.a; }
+ else if (field == "skeletonScale") { return c.skeletonScale; }
} else if (comp == "FlexContainer") {
if (!reg.has<esengine::ecs::FlexContainer>(entity)) return 0.0f;
const auto& c = reg.get<esengine::ecs::FlexContainer>(entity);
@@ -1529,6 +1581,13 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::str
else if (field == "maskBits") { c.maskBits = static_cast<u32>(value); }
else { return false; }
return true;
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "layer") { c.layer = static_cast<i32>(value); }
+ else if (field == "material") { c.material = static_cast<u32>(value); }
+ else { return false; }
+ return true;
} else if (comp == "FlexContainer") {
if (!reg.has<esengine::ecs::FlexContainer>(entity)) return false;
auto& c = reg.get<esengine::ecs::FlexContainer>(entity);
@@ -1706,6 +1765,11 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::stri
const auto& c = reg.get<esengine::ecs::CircleCollider>(entity);
if (field == "categoryBits") { return static_cast<i32>(c.categoryBits); }
else if (field == "maskBits") { return static_cast<i32>(c.maskBits); }
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return 0;
+ const auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "layer") { return static_cast<i32>(c.layer); }
+ else if (field == "material") { return static_cast<i32>(c.material); }
} else if (comp == "FlexContainer") {
if (!reg.has<esengine::ecs::FlexContainer>(entity)) return 0;
const auto& c = reg.get<esengine::ecs::FlexContainer>(entity);
@@ -1854,6 +1918,16 @@ bool editor_setBool(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "enabled") { c.enabled = value; }
else { return false; }
return true;
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "loop") { c.loop = value; }
+ else if (field == "playing") { c.playing = value; }
+ else if (field == "flipX") { c.flipX = value; }
+ else if (field == "flipY") { c.flipY = value; }
+ else if (field == "enabled") { c.enabled = value; }
+ else { return false; }
+ return true;
} else if (comp == "Interactable") {
if (!reg.has<esengine::ecs::Interactable>(entity)) return false;
auto& c = reg.get<esengine::ecs::Interactable>(entity);
@@ -2006,6 +2080,14 @@ bool editor_getBool(Registry& reg, u32 e, const std::string& comp, const std::st
const auto& c = reg.get<esengine::ecs::CircleCollider>(entity);
if (field == "isSensor") { return c.isSensor; }
else if (field == "enabled") { return c.enabled; }
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return false;
+ const auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "loop") { return c.loop; }
+ else if (field == "playing") { return c.playing; }
+ else if (field == "flipX") { return c.flipX; }
+ else if (field == "flipY") { return c.flipY; }
+ else if (field == "enabled") { return c.enabled; }
} else if (comp == "Interactable") {
if (!reg.has<esengine::ecs::Interactable>(entity)) return false;
const auto& c = reg.get<esengine::ecs::Interactable>(entity);
@@ -2108,6 +2190,15 @@ bool editor_setString(Registry& reg, u32 e, const std::string& comp, const std::
if (field == "text") { c.text = value; }
else { return false; }
return true;
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return false;
+ auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "skeletonPath") { c.skeletonPath = value; }
+ else if (field == "atlasPath") { c.atlasPath = value; }
+ else if (field == "armature") { c.armature = value; }
+ else if (field == "animation") { c.animation = value; }
+ else { return false; }
+ return true;
} else if (comp == "SpineAnimation") {
if (!reg.has<esengine::ecs::SpineAnimation>(entity)) return false;
auto& c = reg.get<esengine::ecs::SpineAnimation>(entity);
@@ -2131,6 +2222,13 @@ std::string editor_getString(Registry& reg, u32 e, const std::string& comp, cons
if (!reg.has<esengine::ecs::BitmapText>(entity)) return std::string{};
const auto& c = reg.get<esengine::ecs::BitmapText>(entity);
if (field == "text") { return c.text; }
+ } else if (comp == "DragonBonesAnimation") {
+ if (!reg.has<esengine::ecs::DragonBonesAnimation>(entity)) return std::string{};
+ const auto& c = reg.get<esengine::ecs::DragonBonesAnimation>(entity);
+ if (field == "skeletonPath") { return c.skeletonPath; }
+ else if (field == "atlasPath") { return c.atlasPath; }
+ else if (field == "armature") { return c.armature; }
+ else if (field == "animation") { return c.animation; }
} else if (comp == "SpineAnimation") {
if (!reg.has<esengine::ecs::SpineAnimation>(entity)) return std::string{};
const auto& c = reg.get<esengine::ecs::SpineAnimation>(entity);
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index cb36d0dd0..4528c7879 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -15,6 +15,7 @@
#include "../ecs/components/Camera.hpp"
#include "../ecs/components/Canvas.hpp"
#include "../ecs/components/Collider.hpp"
+#include "../ecs/components/DragonBonesAnimation.hpp"
#include "../ecs/components/FlexContainer.hpp"
#include "../ecs/components/Hierarchy.hpp"
#include "../ecs/components/Interactable.hpp"
@@ -1053,6 +1054,23 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("categoryBits", &esengine::ecs::CircleCollider::categoryBits)
.field("maskBits", &esengine::ecs::CircleCollider::maskBits);
+ value_object<esengine::ecs::DragonBonesAnimation>("DragonBonesAnimation")
+ .field("skeletonPath", &esengine::ecs::DragonBonesAnimation::skeletonPath)
+ .field("atlasPath", &esengine::ecs::DragonBonesAnimation::atlasPath)
+ .field("armature", &esengine::ecs::DragonBonesAnimation::armature)
+ .field("animation", &esengine::ecs::DragonBonesAnimation::animation)
+ .field("timeScale", &esengine::ecs::DragonBonesAnimation::timeScale)
+ .field("loop", &esengine::ecs::DragonBonesAnimation::loop)
+ .field("playing", &esengine::ecs::DragonBonesAnimation::playing)
+ .field("fadeInTime", &esengine::ecs::DragonBonesAnimation::fadeInTime)
+ .field("flipX", &esengine::ecs::DragonBonesAnimation::flipX)
+ .field("flipY", &esengine::ecs::DragonBonesAnimation::flipY)
+ .field("color", &esengine::ecs::DragonBonesAnimation::color)
+ .field("layer", &esengine::ecs::DragonBonesAnimation::layer)
+ .field("skeletonScale", &esengine::ecs::DragonBonesAnimation::skeletonScale)
+ .field("material", &esengine::ecs::DragonBonesAnimation::material)
+ .field("enabled", &esengine::ecs::DragonBonesAnimation::enabled);
+
value_object<FlexContainerJS>("FlexContainer")
.field("direction", &FlexContainerJS::direction)
.field("wrap", &FlexContainerJS::wrap)
@@ -1476,6 +1494,27 @@ EMSCRIPTEN_BINDINGS(esengine_registry) {
r.remove<esengine::ecs::CircleCollider>(entity);
}))
+ // DragonBonesAnimation
+ .function("hasDragonBonesAnimation", optional_override([](Registry& r, u32 e) {
+ return r.has<esengine::ecs::DragonBonesAnimation>(static_cast<Entity>(e));
+ }))
+ .function("getDragonBonesAnimation", optional_override([](Registry& r, u32 e) -> esengine::ecs::DragonBonesAnimation& {
+ auto entity = static_cast<Entity>(e);
+ static esengine::ecs::DragonBonesAnimation s_dummy{};
+ if (!r.valid(entity) || !r.has<esengine::ecs::DragonBonesAnimation>(entity)) return s_dummy;
+ return r.get<esengine::ecs::DragonBonesAnimation>(entity);
+ }), allow_raw_pointers())
+ .function("addDragonBonesAnimation", optional_override([](Registry& r, u32 e, const esengine::ecs::DragonBonesAnimation& c) {
+ auto entity = static_cast<Entity>(e);
+ if (!r.valid(entity)) return;
+ r.emplaceOrReplace<esengine::ecs::DragonBonesAnimation>(entity, c);
+ }))
+ .function("removeDragonBonesAnimation", optional_override([](Registry& r, u32 e) {
+ auto entity = static_cast<Entity>(e);
+ if (!r.valid(entity) || !r.has<esengine::ecs::DragonBonesAnimation>(entity)) return;
+ r.remove<esengine::ecs::DragonBonesAnimation>(entity);
+ }))
+
// FlexContainer
.function("hasFlexContainer", optional_override([](Registry& r, u32 e) {
return r.has<esengine::ecs::FlexContainer>(static_cast<Entity>(e));
@@ -1931,6 +1970,7 @@ emscripten::val esengineGetBuiltinComponentNames() {
arr.set(i++, val(std::string("CapsuleCollider")));
arr.set(i++, val(std::string("Children")));
arr.set(i++, val(std::string("CircleCollider")));
+ arr.set(i++, val(std::string("DragonBonesAnimation")));
arr.set(i++, val(std::string("FlexContainer")));
arr.set(i++, val(std::string("Interactable")));
arr.set(i++, val(std::string("Light2D")));
@@ -2018,6 +2058,17 @@ static_assert(offsetof(esengine::ecs::CircleCollider, isSensor) == 24, "ABI offs
static_assert(offsetof(esengine::ecs::CircleCollider, enabled) == 25, "ABI offset drift: esengine::ecs::CircleCollider.enabled (EHT expected 25)");
static_assert(offsetof(esengine::ecs::CircleCollider, categoryBits) == 28, "ABI offset drift: esengine::ecs::CircleCollider.categoryBits (EHT expected 28)");
static_assert(offsetof(esengine::ecs::CircleCollider, maskBits) == 32, "ABI offset drift: esengine::ecs::CircleCollider.maskBits (EHT expected 32)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, timeScale) == 48, "ABI offset drift: esengine::ecs::DragonBonesAnimation.timeScale (EHT expected 48)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, loop) == 52, "ABI offset drift: esengine::ecs::DragonBonesAnimation.loop (EHT expected 52)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, playing) == 53, "ABI offset drift: esengine::ecs::DragonBonesAnimation.playing (EHT expected 53)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, fadeInTime) == 56, "ABI offset drift: esengine::ecs::DragonBonesAnimation.fadeInTime (EHT expected 56)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, flipX) == 60, "ABI offset drift: esengine::ecs::DragonBonesAnimation.flipX (EHT expected 60)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, flipY) == 61, "ABI offset drift: esengine::ecs::DragonBonesAnimation.flipY (EHT expected 61)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, color) == 64, "ABI offset drift: esengine::ecs::DragonBonesAnimation.color (EHT expected 64)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, layer) == 80, "ABI offset drift: esengine::ecs::DragonBonesAnimation.layer (EHT expected 80)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, skeletonScale) == 84, "ABI offset drift: esengine::ecs::DragonBonesAnimation.skeletonScale (EHT expected 84)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, material) == 88, "ABI offset drift: esengine::ecs::DragonBonesAnimation.material (EHT expected 88)");
+static_assert(offsetof(esengine::ecs::DragonBonesAnimation, enabled) == 92, "ABI offset drift: esengine::ecs::DragonBonesAnimation.enabled (EHT expected 92)");
static_assert(offsetof(esengine::ecs::FlexContainer, direction) == 0, "ABI offset drift: esengine::ecs::FlexContainer.direction (EHT expected 0)");
static_assert(offsetof(esengine::ecs::FlexContainer, wrap) == 1, "ABI offset drift: esengine::ecs::FlexContainer.wrap (EHT expected 1)");
static_assert(offsetof(esengine::ecs::FlexContainer, justifyContent) == 2, "ABI offset drift: esengine::ecs::FlexContainer.justifyContent (EHT expected 2)");
@@ -2237,7 +2288,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "7454a67d3890bcbc";
+static const char* kEsAbiLayoutHash = "9219dd764c94a81e";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/ecs/components/DragonBonesAnimation.hpp b/src/esengine/ecs/components/DragonBonesAnimation.hpp
new file mode 100644
index 000000000..531b594c5
--- /dev/null
+++ b/src/esengine/ecs/components/DragonBonesAnimation.hpp
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file DragonBonesAnimation.hpp
+ * @brief A DragonBones armature on an entity.
+ *
+ * @details Declared here rather than in TypeScript for the same reason
+ * SpineAnimation is: this table is the authority the editor's inspector,
+ * the Create menu and the serializer all read through EHT, so a component
+ * that skipped it would need each of them told about it separately.
+ *
+ * It reads almost exactly like SpineAnimation, and the one field that
+ * differs is the point. A Spine file IS a skeleton; a DragonBones file is
+ * a project holding several armatures, so `armature` names which one —
+ * there is nothing to derive it from, and an entity that does not say
+ * gets the first in the file.
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the Apache License, Version 2.0.
+ */
+#pragma once
+
+#include "../../core/Types.hpp"
+#include "../../core/Reflection.hpp"
+#include "../../math/Math.hpp"
+
+#include <string>
+
+namespace esengine::ecs {
+
+ES_COMPONENT()
+struct DragonBonesAnimation {
+ /** @brief Skeleton data (`*_ske.json` or `.dbbin`) */
+ ES_PROPERTY(asset = dragonbones_skeleton)
+ std::string skeletonPath;
+
+ /** @brief Texture atlas data (`*_tex.json`) */
+ ES_PROPERTY(asset = dragonbones_atlas)
+ std::string atlasPath;
+
+ /** @brief Which armature in the file; empty takes the first */
+ ES_PROPERTY()
+ std::string armature;
+
+ /** @brief Current animation name */
+ ES_PROPERTY()
+ std::string animation;
+
+ /** @brief Animation playback speed multiplier */
+ ES_PROPERTY(min=0)
+ f32 timeScale{1.0f};
+
+ /** @brief Whether to loop the animation */
+ ES_PROPERTY()
+ bool loop{true};
+
+ /** @brief Whether animation is currently playing */
+ ES_PROPERTY()
+ bool playing{true};
+
+ /** @brief Seconds to crossfade over when the animation changes */
+ ES_PROPERTY(min=0, step=0.05)
+ f32 fadeInTime{0.0f};
+
+ /** @brief Flip armature horizontally */
+ ES_PROPERTY()
+ bool flipX{false};
+
+ /** @brief Flip armature vertically */
+ ES_PROPERTY()
+ bool flipY{false};
+
+ /** @brief Color tint (RGBA, 0-1 range) */
+ ES_PROPERTY()
+ glm::vec4 color{1.0f, 1.0f, 1.0f, 1.0f};
+
+ /** @brief Sorting layer (higher = rendered on top) */
+ ES_PROPERTY(step=1, enum_source=sortingLayers)
+ i32 layer{0};
+
+ /** @brief Armature scale factor */
+ ES_PROPERTY(min=0)
+ f32 skeletonScale{1.0f};
+
+ /** @brief Custom material ID (0 = use default batch shader) */
+ ES_PROPERTY(asset = material)
+ u32 material{0};
+
+ ES_PROPERTY()
+ bool enabled{true};
+
+ /** @brief Set while the paths have changed and the armature is not built yet */
+ bool needsReload{true};
+
+ DragonBonesAnimation() = default;
+};
+
+} // namespace esengine::ecs
diff --git a/tools/eht/generators/metadata.py b/tools/eht/generators/metadata.py
index 887271f4d..82a33a4f0 100644
--- a/tools/eht/generators/metadata.py
+++ b/tools/eht/generators/metadata.py
@@ -17,6 +17,11 @@ def _is_number(s: str) -> bool:
return False
+def _is_skeletal_asset(asset_type: str) -> bool:
+ """Half of a skeleton/atlas pair, which travels as one descriptor instead."""
+ return asset_type.endswith('_skeleton') or asset_type.endswith('_atlas')
+
+
class MetadataGenerator:
"""Generates component.generated.ts with defaults and metadata."""
@@ -32,20 +37,28 @@ class MetadataGenerator:
fields = []
for prop in comp.properties:
asset_type = prop.annotations.get('asset')
- if asset_type and asset_type not in ('spine_skeleton', 'spine_atlas'):
+ if asset_type and not _is_skeletal_asset(asset_type):
fields.append({'field': prop.name, 'type': asset_type})
return fields
- def _get_spine_descriptor(self, comp: Component) -> Optional[Dict[str, str]]:
- skel_field = atlas_field = None
+ def _get_skeletal_descriptor(self, comp: Component) -> Optional[Dict[str, str]]:
+ """The skeleton/atlas pair a skeletal component carries, and whose runtime.
+
+ A pair rather than two independent asset fields because neither half means
+ anything alone: loading a skeleton without its atlas gets you an armature
+ with no images. `runtime` is the prefix, so a consumer can tell a Spine
+ pair from a DragonBones one without a second descriptor kind.
+ """
+ skel_field = atlas_field = runtime = None
for prop in comp.properties:
- asset_type = prop.annotations.get('asset')
- if asset_type == 'spine_skeleton':
+ asset_type = prop.annotations.get('asset') or ''
+ if asset_type.endswith('_skeleton'):
skel_field = prop.name
- elif asset_type == 'spine_atlas':
+ runtime = asset_type[:-len('_skeleton')]
+ elif asset_type.endswith('_atlas'):
atlas_field = prop.name
- if skel_field and atlas_field:
- return {'skeletonField': skel_field, 'atlasField': atlas_field}
+ if skel_field and atlas_field and runtime:
+ return {'skeletonField': skel_field, 'atlasField': atlas_field, 'runtime': runtime}
return None
def _get_entity_fields(self, comp: Component) -> List[str]:
@@ -287,9 +300,11 @@ class MetadataGenerator:
' type: AssetFieldType;',
'}',
'',
- 'export interface SpineFieldMeta {',
+ 'export interface SkeletalFieldMeta {',
' skeletonField: string;',
' atlasField: string;',
+ ' /** Which runtime the pair belongs to — `spine`, `dragonbones`. */',
+ ' runtime: string;',
'}',
'',
'export interface ComponentMetaEntry {',
@@ -302,7 +317,7 @@ class MetadataGenerator:
' */',
' editorDefaults?: Record<string, unknown>;',
' assetFields: AssetFieldMeta[];',
- ' spine?: SpineFieldMeta;',
+ ' skeletal?: SkeletalFieldMeta;',
' entityFields: string[];',
' colorFields: string[];',
' animatableFields: string[];',
@@ -332,7 +347,7 @@ class MetadataGenerator:
continue
asset_fields = self._get_asset_fields(comp)
- spine = self._get_spine_descriptor(comp)
+ skeletal = self._get_skeletal_descriptor(comp)
entity_fields = self._get_entity_fields(comp)
color_fields = self._get_color_fields(comp)
animatable = self._get_animatable_fields(comp)
@@ -362,10 +377,10 @@ class MetadataGenerator:
else:
lines.append(' assetFields: [],')
- if spine:
+ if skeletal:
lines.append(
- f" spine: {{ skeletonField: '{spine['skeletonField']}', "
- f"atlasField: '{spine['atlasField']}' }},"
+ f" skeletal: {{ skeletonField: '{skeletal['skeletonField']}', "
+ f"atlasField: '{skeletal['atlasField']}', runtime: '{skeletal['runtime']}' }},"
)
if entity_fields:
diff --git a/tools/eht/parser.py b/tools/eht/parser.py
index c77a76c73..2bd4052c3 100644
--- a/tools/eht/parser.py
+++ b/tools/eht/parser.py
@@ -62,7 +62,12 @@ class CppParser:
})
NUMERIC_ANNOTATIONS = frozenset({'min', 'max', 'step'})
VALID_ASSET_TYPES = frozenset({
- 'texture', 'material', 'font', 'audio', 'spine_skeleton', 'spine_atlas',
+ 'texture', 'material', 'font', 'audio',
+ # A skeletal runtime's two halves. Recognised as a PAIR (see
+ # metadata.py::_get_skeletal_descriptor), so adding a runtime is these two
+ # entries and nothing else.
+ 'spine_skeleton', 'spine_atlas',
+ 'dragonbones_skeleton', 'dragonbones_atlas',
})
def __init__(self):