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(editor): a selected Spine or DragonBones entity shows its bones over the artwork, read from the runtime's posed skeleton
yhh884c099b6696
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 31814afe4..cb2fa727f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,7 +16,7 @@ published separately; it ships inside the editor.### Changed-- **Gizmos are redrawn.** The transform handles are larger and clearer: arrows have filled heads, rings dim on their far side, the scale handles are solid cubes, and the part under the cursor turns yellow while the others fall back as you drag. A chip beside the cursor reads the offset, angle or factor being applied (`X +120.0`, `Y 42.5°`, `X ×1.35`), a rotate drag fills the swept angle, a move leaves a ghost where it started and, with snapping on, ticks at each increment. The entity under the cursor is outlined faintly before you click it, and a selected entity's outline is a little heavier. A selected mesh shows corner brackets with the length of three edges and its triangle and vertex count in the readout, the Show menu can draw its wireframe and normals, and a skinned mesh or one of its bones shows the skeleton as bones with the chosen joint in yellow. A decal projector shows its box and the line it projects along, a light probe volume the grid of probes a bake would lay, a LOD group the level it is showing and the share of the screen it takes, and the Gizmo menu has a handle-size slider. A selected UI node shows its margin and padding as bands, the pinned insets of an absolutely placed node as dashed lines with their values, and a flex container's direction and the gaps between its children. The six faces of a light probe volume, reflection probe or decal projector are handles: drag one and that half of the box follows the cursor. A selected mesh is outlined along its own silhouette rather than a box, up to 80,000 triangles. The Show menu can draw wireframe on every mesh at once, and choosing a bone paints the surface it moves from blue to red, the rest left grey; convex colliders now draw with the other 3D colliders. A Hunter's attack range is drawn as a red ball, a Perceiver's sight as the cone it actually tests (a ball when its field of view is all round), and a ThirdPersonCamera's boom as a line from the point it looks at to where it ends up, with the probe swept along it as a ball at the end. A UI element drawn as 9-slice shows its picture under its Slice Border field with four guides to drag, as the texture inspector does; while the texture carries a border of its own, which the renderer prefers, it says so instead. The Show menu also picks how the viewport shades meshes: as authored, as neutral clay (shape, without anyone's colours) or as flat albedo (base colour, no light); the engine takes it as per-view state, so a camera preview in the same frame keeps the authored look. A fourth shading, wireframe, draws every triangle edge on a dark surface with the hidden ones hidden; the engine's pipelines now carry a primitive topology, WebGL2 and WebGPU alike, and each mesh the editor loads keeps a line list of its distinct edges.+- **Gizmos are redrawn.** The transform handles are larger and clearer: arrows have filled heads, rings dim on their far side, the scale handles are solid cubes, and the part under the cursor turns yellow while the others fall back as you drag. A chip beside the cursor reads the offset, angle or factor being applied (`X +120.0`, `Y 42.5°`, `X ×1.35`), a rotate drag fills the swept angle, a move leaves a ghost where it started and, with snapping on, ticks at each increment. The entity under the cursor is outlined faintly before you click it, and a selected entity's outline is a little heavier. A selected mesh shows corner brackets with the length of three edges and its triangle and vertex count in the readout, the Show menu can draw its wireframe and normals, and a skinned mesh or one of its bones shows the skeleton as bones with the chosen joint in yellow. A decal projector shows its box and the line it projects along, a light probe volume the grid of probes a bake would lay, a LOD group the level it is showing and the share of the screen it takes, and the Gizmo menu has a handle-size slider. A selected UI node shows its margin and padding as bands, the pinned insets of an absolutely placed node as dashed lines with their values, and a flex container's direction and the gaps between its children. The six faces of a light probe volume, reflection probe or decal projector are handles: drag one and that half of the box follows the cursor. A selected mesh is outlined along its own silhouette rather than a box, up to 80,000 triangles. The Show menu can draw wireframe on every mesh at once, and choosing a bone paints the surface it moves from blue to red, the rest left grey; convex colliders now draw with the other 3D colliders. A Hunter's attack range is drawn as a red ball, a Perceiver's sight as the cone it actually tests (a ball when its field of view is all round), and a ThirdPersonCamera's boom as a line from the point it looks at to where it ends up, with the probe swept along it as a ball at the end. A UI element drawn as 9-slice shows its picture under its Slice Border field with four guides to drag, as the texture inspector does; while the texture carries a border of its own, which the renderer prefers, it says so instead. A selected Spine or DragonBones entity shows its bones over the artwork as the 3D rigs do, laid where the runtime posed them this frame, with the entity's scale and flips applied; the Spine and DragonBones modules gained a call that lists the bone tree, so a module built before it still draws the skeleton and only the bones are absent. The Show menu also picks how the viewport shades meshes: as authored, as neutral clay (shape, without anyone's colours) or as flat albedo (base colour, no light); the engine takes it as per-view state, so a camera preview in the same frame keeps the authored look. A fourth shading, wireframe, draws every triangle edge on a dark surface with the hidden ones hidden; the engine's pipelines now carry a primitive topology, WebGL2 and WebGPU alike, and each mesh the editor loads keeps a line list of its distinct edges.- **A material's preview is a real shape.** Selecting a material shows it on a sphere, cube or plane (lit materials open on the sphere, sprite shaders on the plane), over a dark, checker or light background, with a sample image for shaders that sample a texture; the choice is remembered per kind. The header carries the ball as its icon and the name with a faint extension, the shader is a plain section with a link to make it unique, and the Content Browser's material thumbnails use the same preview. The engine's offscreen preview target now has a depth buffer, so a mesh drawn there is no longer drawn inside out.- **The 2D animation editors are redrawn.** In the sprite animation editor the view's tools float over its corner, playback and the timeline are one panel, frame events are flags on an event track (click one to rename, move or remove it), the frame source folds into a strip that opens on an empty clip, and frame rate, loop and Save no longer appear a second time in the inspector. The animator controller shows states as cards with their clip and speed, wires between a pair of states run side by side with a pill for the condition (dashed when it waits for the exit time), and its inspector puts the selected state or transition first, with the controller's layers, typed parameters and a folded constraints section below.- **The tile editor matches its design.** The layer and tileset menus sit on the raised surface, a picked tile has a 2px frame and shows its id on hover, the brush column shows the tile id, the replace dialog's button says Replace, and the tileset inspector shows one-way and trigger as switches, the layer opacity is a slim slider, and a collision layer's friction and bounce fields are flat with their own heading.diff --git a/desktop b/desktopindex 85fa5f93f..9590c78b7 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 85fa5f93f9d8f59d74b8613695471cc9a2eb47b3+Subproject commit 9590c78b7c05ba4170fff7f84d77c82922c8b01fdiff --git a/sdk/etc/dragonbones.api.md b/sdk/etc/dragonbones.api.mdindex eeaf799b3..c348ec42e 100644--- a/sdk/etc/dragonbones.api.md+++ b/sdk/etc/dragonbones.api.md@@ -37,6 +37,7 @@ skeletonScale: number | undefined```@internal discardUnboundSkeleton: (assetKey: string) => voidaddEntity: (entity: Entity, skeletonHandle: number, options: DragonBonesEntityOptions) => boolean+boneTree: (entity: Entity) => SkeletalBoneTree | nullboundEntities: () => Iterable<Entity>controller: DragonBonesModuleControllerdispose: () => void@@ -69,6 +70,7 @@ forEachMeshBatch: (instanceId: number, cb: MeshBatchVisitor) => voidgetAnimations: (instanceId: number) => string[]getArmatures: (handle: number) => string[]getAtlasImageName: (handle: number) => string+getBoneTree: (instanceId: number) => SkeletalBone[] | nullgetBounds: (instanceId: number) => SkeletalBoundsgetLastError: () => stringloadSkeleton: (skeletonData: Uint8Array | string, atlasJson: string) => number@@ -119,6 +121,8 @@ fadeInAnimation: (instanceId: number, name: string, fadeSeconds: number, playTimgetAnimations: (instanceId: number) => stringgetArmatures: (handle: number) => stringgetAtlasImageName: (handle: number) => string+getBonePoses: ((instanceId: number, outPtr: number, capacity: number) => number) | undefined+getBones: ((instanceId: number) => string) | undefinedgetBounds: (instanceId: number, xPtr: number, yPtr: number, wPtr: number, hPtr: number) => voidgetLastError: () => stringgetMeshBatchCount: (instanceId: number) => numberdiff --git a/sdk/etc/spine.api.md b/sdk/etc/spine.api.mdindex ecf182a94..08f58a202 100644--- a/sdk/etc/spine.api.md+++ b/sdk/etc/spine.api.md@@ -1,7 +1,7 @@# API surface — esengine/spine<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 0 public · 1 beta · 48 experimental · 0 deprecated+Symbols: 0 public · 1 beta · 50 experimental · 0 deprecated## ConstraintList — interface @experimental```@@ -36,6 +36,24 @@ spineCulling: ((skeleton: string, atlas: string) => { x: number; y: number; widttextureImportSettings: ((ref: string) => ParsedTextureImportSettings | undefined) | undefined```+## SkeletalBone — interface @experimental+```+degrees: number+length: number+name: string+parent: number+x: number+y: number+```++## SkeletalBoneTree — interface @experimental+```+bones: SkeletalBone[]+flipX: boolean+flipY: boolean+scale: number+```+## Spine — const @beta```ResourceDef<SpineManager>@@ -175,6 +193,7 @@ entities: number## SpineManager — class @experimental```+boneTree: (entity: Entity) => SkeletalBoneTree | nullboundEntities: () => Iterable<Entity>clipBudget: (entity: Entity) => SpineClipBudget | nullcollectAllEvents: (isActive?: (entity: Entity) => boolean) => { entity: Entity; raw: RawSpineEvent; }[]@@ -232,6 +251,7 @@ getAtlasPageCount: (handle: number) => numbergetAtlasPageTextureName: (handle: number, pageIndex: number) => stringgetBonePosition: (instanceId: number, boneName: string) => Vec2 | nullgetBoneRotation: (instanceId: number, boneName: string) => number+getBoneTree: (instanceId: number) => SkeletalBone[] | nullgetBounds: (instanceId: number) => { x: number; y: number; width: number; height: number; }getLastError: () => stringgetPathConstraintMix: (instanceId: number, name: string) => PathMixData | null@@ -319,6 +339,7 @@ requiresContinuousWorldPose: boolean## SpineRuntime — class @experimental```+boneTree: (entity: Entity) => SkeletalBoneTree | nullclipBudget: (entity: Entity) => SpineClipBudget | nullcollectAllEvents: (isActive?: (entity: Entity) => boolean) => { entity: Entity; raw: RawSpineEvent; }[]dispose: () => voiddiff --git a/sdk/src/dragonbones/DragonBonesController.ts b/sdk/src/dragonbones/DragonBonesController.tsindex 88e7ecd42..ee5a2a49a 100644--- a/sdk/src/dragonbones/DragonBonesController.ts+++ b/sdk/src/dragonbones/DragonBonesController.ts@@ -16,7 +16,7 @@* skeleton.*/import { forEachMeshBatch, type MeshBatchVisitor } from '../skeletal/meshBatches';-import type { SkeletalBounds, SkeletalController } from '../skeletal/types';+import type { SkeletalBone, SkeletalBounds, SkeletalController } from '../skeletal/types';import type { DragonBonesWasmModule, DragonBonesWrappedAPI } from './DragonBonesModuleLoader';import { withMalloc } from '../wasm/wasmScratch';import { encodeUtf8 } from '../util/utf8';@@ -135,6 +135,31 @@ export class DragonBonesModuleController implements SkeletalController {return parseNames(this.api_.getAnimations(instanceId));}+ /**+ * The armature's bones as posed now, in the y-up space the geometry is in: name, parent+ * (-1 for a root), start, the way each points in degrees, and length. Null from a module+ * built before the call existed. @experimental+ */+ getBoneTree(instanceId: number): SkeletalBone[] | null {+ const api = this.api_;+ if (!api.getBones || !api.getBonePoses) return null;+ const names = parseNames(api.getBones(instanceId));+ if (names.length === 0) return [];+ return withMalloc(this.raw_, names.length * 5 * 4, (ptr) => {+ const n = api.getBonePoses!(instanceId, ptr, names.length);+ const heap = this.raw_.HEAPF32;+ const out: SkeletalBone[] = [];+ for (let i = 0; i < n; i++) {+ const at = (ptr >> 2) + i * 5;+ out.push({+ name: names[i]!, parent: heap[at]! | 0,+ x: heap[at + 1]!, y: heap[at + 2]!, degrees: heap[at + 3]!, length: heap[at + 4]!,+ });+ }+ return out;+ });+ }+// — Geometry ————————————————————————————————————————————————————————————getBounds(instanceId: number): SkeletalBounds {diff --git a/sdk/src/dragonbones/DragonBonesManager.ts b/sdk/src/dragonbones/DragonBonesManager.tsindex d7a5647b7..48773568e 100644--- a/sdk/src/dragonbones/DragonBonesManager.ts+++ b/sdk/src/dragonbones/DragonBonesManager.ts@@ -17,7 +17,7 @@*/import type { Entity } from '../types';import { submitEntityMeshes, type SkeletalMaterialOf, type SkeletalSubmitCore } from '../skeletal/submitMeshes';-import type { SkeletalBounds } from '../skeletal/types';+import type { SkeletalBoneTree, SkeletalBounds } from '../skeletal/types';import { DragonBonesModuleController } from './DragonBonesController';import { log } from '../util/logger';import { releaseAtlasOwner, releaseAllAtlasOwners } from './atlasOwnership';@@ -228,6 +228,14 @@ export class DragonBonesManager {return info ? this.controller_.getAnimations(info.instanceId) : [];}+ /** The posed bones of this entity's armature and how it places them; null if not loaded. @experimental */+ boneTree(entity: Entity): SkeletalBoneTree | null {+ const info = this.entities_.get(entity);+ if (!info) return null;+ const bones = this.controller_.getBoneTree(info.instanceId);+ return bones ? { bones, scale: info.skeletonScale, flipX: info.flipX, flipY: info.flipY } : null;+ }+getBounds(entity: Entity): SkeletalBounds | null {const info = this.entities_.get(entity);return info ? this.controller_.getBounds(info.instanceId) : null;diff --git a/sdk/src/dragonbones/DragonBonesModuleLoader.ts b/sdk/src/dragonbones/DragonBonesModuleLoader.tsindex adee68053..d759652f4 100644--- a/sdk/src/dragonbones/DragonBonesModuleLoader.ts+++ b/sdk/src/dragonbones/DragonBonesModuleLoader.ts@@ -42,6 +42,10 @@ export interface DragonBonesWrappedAPI {verticesPtr: number, indicesPtr: number, textureIdPtr: number, blendModePtr: number,): void;getBounds(instanceId: number, xPtr: number, yPtr: number, wPtr: number, hPtr: number): void;+ /** Bone names in armature order; absent on a module built before the call existed. */+ getBones?(instanceId: number): string;+ /** Five floats a bone — parent index (-1 for a root), x, y, degrees, length — into `outPtr`; returns the count. */+ getBonePoses?(instanceId: number, outPtr: number, capacity: number): number;runtimeVersion(): number;}@@ -77,6 +81,8 @@ export function wrapDragonBonesModule(raw: DragonBonesWasmModule): DragonBonesWrgetMeshBatchIndexCount: w('getMeshBatchIndexCount', N, [N, N]),getMeshBatchData: w('getMeshBatchData', null, [N, N, N, N, N, N]),getBounds: w('getBounds', null, [N, N, N, N, N]),+ getBones: (raw as unknown as Record<string, unknown>)._db_getBones ? w('getBones', S, [N]) : undefined,+ getBonePoses: (raw as unknown as Record<string, unknown>)._db_getBonePoses ? w('getBonePoses', N, [N, N, N]) : undefined,runtimeVersion: w('runtimeVersion', N, []),};}diff --git a/sdk/src/skeletal/index.ts b/sdk/src/skeletal/index.tsindex 07d24a996..169a99968 100644--- a/sdk/src/skeletal/index.ts+++ b/sdk/src/skeletal/index.ts@@ -2,6 +2,6 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamexport { forEachMeshBatch } from './meshBatches';export type { MeshBatchSource, MeshBatchVisitor, SkeletalHeap } from './meshBatches';-export type { SkeletalBounds, SkeletalController } from './types';+export type { SkeletalBone, SkeletalBoneTree, SkeletalBounds, SkeletalController } from './types';export { SkeletalEnableMirror } from './enableSync';export type { SkeletalEnableTarget, SkeletalEnableWorld } from './enableSync';diff --git a/sdk/src/skeletal/types.ts b/sdk/src/skeletal/types.tsindex 286349c8d..0cec68a5d 100644--- a/sdk/src/skeletal/types.ts+++ b/sdk/src/skeletal/types.ts@@ -18,6 +18,31 @@*/import type { MeshBatchVisitor } from './meshBatches';+/** One bone of a posed skeleton, in the skeleton's own space. */+export interface SkeletalBone {+ name: string;+ /** Index of the parent in the same list; -1 for a root. */+ parent: number;+ /** Where the bone starts. */+ x: number;+ y: number;+ /** The way it points. */+ degrees: number;+ length: number;+}++/**+ * A skeleton's bones as drawn this frame, and how its entity places them: the+ * scale and flips the draw applies, which a point in skeleton space has to as+ * well to land where the artwork is.+ */+export interface SkeletalBoneTree {+ bones: SkeletalBone[];+ scale: number;+ flipX: boolean;+ flipY: boolean;+}+export interface SkeletalBounds {x: number;y: number;diff --git a/sdk/src/spine/SpineController.ts b/sdk/src/spine/SpineController.tsindex 5d5423add..4190fe6d6 100644--- a/sdk/src/spine/SpineController.ts+++ b/sdk/src/spine/SpineController.ts@@ -10,6 +10,7 @@ import type { SpineWasmModule, SpineWrappedAPI } from './SpineModuleLoader';import { SpineModuleBridge } from './SpineBridge';import { log } from '../util/logger';import { withMalloc, withScratch } from '../wasm/wasmScratch';+import type { SkeletalBone } from '../skeletal/types';import { forEachMeshBatch, type MeshBatchVisitor } from '../skeletal/meshBatches';import type { SpineClipBudget, SkeletalProbe } from './spineMetrics';import type { SpineAABB } from './spineBounds';@@ -204,6 +205,37 @@ export class SpineModuleController {return this.api_.getBoneRotation(instanceId, boneName);}+ /**+ * The skeleton as a tree in the pose the instance is in: each bone's name, parent+ * (-1 for a root), where it starts, the way it points in degrees and how long it is,+ * in skeleton space. Null from a module built before the call existed. @experimental+ */+ getBoneTree(instanceId: number): SkeletalBone[] | null {+ const api = this.api_;+ if (!api.getBones || !api.getBonePoses) return null;+ let names: string[];+ try {+ names = JSON.parse(api.getBones(instanceId));+ } catch (e) {+ log.warn('spine', 'Failed to parse bones JSON', e);+ return null;+ }+ if (names.length === 0) return [];+ return withMalloc(this.raw_, names.length * 5 * 4, (ptr) => {+ const n = api.getBonePoses!(instanceId, ptr, names.length);+ const heap = this.raw_.HEAPF32;+ const out: SkeletalBone[] = [];+ for (let i = 0; i < n; i++) {+ const at = (ptr >> 2) + i * 5;+ out.push({+ name: names[i]!, parent: heap[at]! | 0,+ x: heap[at + 1]!, y: heap[at + 2]!, degrees: heap[at + 3]!, length: heap[at + 4]!,+ });+ }+ return out;+ });+ }+/*** What this instance's clipping costs the engine in the pose it is in, as* work rather than time: a coefficient measured on one machine and compilerdiff --git a/sdk/src/spine/SpineManager.ts b/sdk/src/spine/SpineManager.tsindex c848d65ee..73d5f134d 100644--- a/sdk/src/spine/SpineManager.ts+++ b/sdk/src/spine/SpineManager.ts@@ -9,6 +9,7 @@ import type { SpineModuleFactory } from './SpineModuleLoader';import { SpineRuntime } from './SpineRuntime';import type { SpineEraBinding } from './prepareSpine';import type { SpineClipBudget } from './spineMetrics';+import type { SkeletalBoneTree } from '../skeletal/types';import { spineSceneDiagnostics } from './spineSceneDiagnostics';import type { SpineSceneDiagnostics, SpinePreviewInstance } from './spineSceneDiagnostics';import type { SpineCullingEnvelope } from './spineBounds';@@ -238,6 +239,11 @@ export class SpineManager {return this.runtimeOf_(entity)?.getSkins(entity) ?? [];}+ /** The posed bones of this entity's skeleton and how it places them; null if not loaded. @experimental */+ boneTree(entity: Entity): SkeletalBoneTree | null {+ return this.runtimeOf_(entity)?.boneTree(entity) ?? null;+ }+setDefaultMix(entity: Entity, duration: number): void {const backend = this.runtimeOf_(entity);if (backend) backend.setDefaultMix(entity, duration);diff --git a/sdk/src/spine/SpineModuleLoader.ts b/sdk/src/spine/SpineModuleLoader.tsindex 1e7f85cfb..26eb6fffe 100644--- a/sdk/src/spine/SpineModuleLoader.ts+++ b/sdk/src/spine/SpineModuleLoader.ts@@ -31,6 +31,8 @@ export interface SpineWasmModule {_spine_getSkins(instanceId: number): number;_spine_getBonePosition(instanceId: number, bone: number, outXPtr: number, outYPtr: number): number;_spine_getBoneRotation(instanceId: number, bone: number): number;+ _spine_getBones?(instanceId: number): number;+ _spine_getBonePoses?(instanceId: number, outPtr: number, capacity: number): number;_spine_getBounds(instanceId: number, outXPtr: number, outYPtr: number, outWPtr: number, outHPtr: number): void;_spine_getSkeletonBounds(skeletonHandle: number, outXPtr: number, outYPtr: number, outWPtr: number, outHPtr: number): number;@@ -117,6 +119,10 @@ export interface SpineWrappedAPI {getSkins(instanceId: number): string;getBonePosition(instanceId: number, bone: string, outXPtr: number, outYPtr: number): boolean;getBoneRotation(instanceId: number, bone: string): number;+ /** Bone names in skeleton order, a parent before its children; absent on a module built before the call existed. */+ getBones?(instanceId: number): string;+ /** Five floats a bone — parent index (-1 for a root), x, y, degrees, length — into `outPtr`; returns the count written. */+ getBonePoses?(instanceId: number, outPtr: number, capacity: number): number;getBounds(instanceId: number, outXPtr: number, outYPtr: number, outWPtr: number, outHPtr: number): void;/** The skeleton's authored extent — answerable without an instance or a pose. */getSkeletonBounds(skeletonHandle: number, outXPtr: number, outYPtr: number, outWPtr: number, outHPtr: number): number;@@ -195,6 +201,12 @@ export function wrapSpineModule(raw: SpineWasmModule): SpineWrappedAPI {getSkins: cw('spine_getSkins', 'string', ['number']) as SpineWrappedAPI['getSkins'],getBonePosition: cw('spine_getBonePosition', 'number', ['number', 'string', 'number', 'number']) as SpineWrappedAPI['getBonePosition'],getBoneRotation: cw('spine_getBoneRotation', 'number', ['number', 'string']) as SpineWrappedAPI['getBoneRotation'],+ getBones: typeof (raw as unknown as Record<string, unknown>)._spine_getBones === 'function'+ ? cw('spine_getBones', 'string', ['number']) as SpineWrappedAPI['getBones']+ : undefined,+ getBonePoses: typeof (raw as unknown as Record<string, unknown>)._spine_getBonePoses === 'function'+ ? cw('spine_getBonePoses', 'number', ['number', 'number', 'number']) as SpineWrappedAPI['getBonePoses']+ : undefined,getBounds: cw('spine_getBounds', null, ['number', 'number', 'number', 'number', 'number']) as SpineWrappedAPI['getBounds'],getSkeletonBounds: cw('spine_getSkeletonBounds', 'number', ['number', 'number', 'number', 'number', 'number']) as SpineWrappedAPI['getSkeletonBounds'],getMeshBatchColorPremultiplied: typeof (raw as unknown as Record<string, unknown>)._spine_getMeshBatchColorPremultiplied === 'function'diff --git a/sdk/src/spine/SpineRuntime.ts b/sdk/src/spine/SpineRuntime.tsindex e65d03931..8b18d9a71 100644--- a/sdk/src/spine/SpineRuntime.ts+++ b/sdk/src/spine/SpineRuntime.ts@@ -27,6 +27,7 @@ import type { SpineVersion } from '../sideModules/registry';import { log } from '../util/logger';import { submitEntityMeshes, type SkeletalMaterialOf } from '../skeletal/submitMeshes';import type { SpineClipBudget } from './spineMetrics';+import type { SkeletalBoneTree } from '../skeletal/types';import { mayDeferWorldPose, scanObservedBounds } from './spineBounds';import type { SpineBoundsSource } from './spineBounds';import type { SpineCullingEnvelope } from './spineBounds';@@ -242,6 +243,18 @@ export class SpineRuntime {return this.controller_.getSkins(info.instanceId);}+ /**+ * The skeleton's bones as drawn this frame, with how the entity places them: the+ * skeleton's own scale and flips, which the draw applies and a point in skeleton+ * space has to as well. Null when nothing is loaded or the module predates the call.+ */+ boneTree(entity: Entity): SkeletalBoneTree | null {+ const info = this.entities_.get(entity);+ if (!info) return null;+ const bones = this.controller_.getBoneTree(info.instanceId);+ return bones ? { bones, scale: info.skeletonScale, flipX: info.flipX, flipY: info.flipY } : null;+ }+// NOTE: mix durations live on the skeleton's AnimationStateData (C++ takes a// skeletonHandle), so these apply to EVERY entity sharing this asset, not just// `entity`. Crossfade timing is an asset-level property here — pass an entitydiff --git a/sdk/src/spine/index.ts b/sdk/src/spine/index.tsindex 3642752f5..08303e6f1 100644--- a/sdk/src/spine/index.ts+++ b/sdk/src/spine/index.ts@@ -6,6 +6,7 @@ export { SpineManager } from './SpineManager';export type { SpineVersion } from './SpineManager';export { SpineRuntime } from './SpineRuntime';export { SpineModuleController } from './SpineController';+export type { SkeletalBone, SkeletalBoneTree } from '../skeletal/types';export type { ConstraintList, TransformMixData, PathMixData } from './SpineController';export type { SpineModuleFactory } from './SpineModuleLoader';export { wrapSpineModule } from './SpineModuleLoader';diff --git a/sdk/tests/dragonbones-controller.integration.test.ts b/sdk/tests/dragonbones-controller.integration.test.tsindex 0838196dc..13b83a92a 100644--- a/sdk/tests/dragonbones-controller.integration.test.ts+++ b/sdk/tests/dragonbones-controller.integration.test.ts@@ -42,6 +42,32 @@ describe.skipIf(!HAS_ASSETS)('DragonBonesModuleController', () => {controller.unloadSkeleton(fromText);});+ it('lays the armature out as a tree of bones, in the same y-up space as its geometry', () => {+ const handle = load();+ controller.setAtlasTexture(handle, 42);+ const instance = controller.createInstance(handle, 'Dragon');+ controller.play(instance, 'stand');+ controller.update(instance, 1 / 60);+ const bones = controller.getBoneTree(instance);+ expect(bones).not.toBeNull();+ const authored = (JSON.parse(readFileSync(SKE, 'utf8')).armature[0].bone as Array<{ name: string; parent?: string; length?: number }>);+ expect(bones!.map((b) => b.name).sort()).toEqual(authored.map((b) => b.name).sort());+ // A parent always comes before its children, so a caller can walk the list once.+ bones!.forEach((b, i) => {+ expect(b.parent).toBeLessThan(i);+ expect(bones![b.parent === -1 ? i : b.parent]!.name).toBe(b.parent === -1 ? b.name : authored.find((a) => a.name === b.name)!.parent);+ });+ // The bones sit on the artwork: the middle of the bone set is inside the geometry's own bounds.+ const box = controller.getBounds(instance);+ const mean = bones!.reduce((a, b) => ({ x: a.x + b.x / bones!.length, y: a.y + b.y / bones!.length }), { x: 0, y: 0 });+ expect(mean.x).toBeGreaterThan(box.x);+ expect(mean.x).toBeLessThan(box.x + box.width);+ expect(mean.y).toBeGreaterThan(box.y);+ expect(mean.y).toBeLessThan(box.y + box.height);+ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });+it('reports a failure instead of a handle', () => {const handle = controller.loadSkeleton(new Uint8Array([1, 2, 3]), 'not json');expect(handle).toBeLessThan(0);diff --git a/sdk/tests/spine-bones-wasm.test.ts b/sdk/tests/spine-bones-wasm.test.tsnew file mode 100644index 000000000..eab4dfdc4--- /dev/null+++ b/sdk/tests/spine-bones-wasm.test.ts@@ -0,0 +1,55 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+import { describe, it, expect } from 'vitest';+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { WASM_DIR, hasSideModule } from './helpers/loadWasm';+import { SpineModuleController } from '../src/spine/SpineController';+import { wrapSpineModule, type SpineWasmModule } from '../src/spine/SpineModuleLoader';++for (const version of ['2.1', '3.8', '4.1', '4.2', '4.3']) {+ const moduleName = 'spine' + version.replace('.', '');+ describe.skipIf(!hasSideModule(moduleName))('Spine ' + version + ' bone tree', () => {+ it('names every bone with its parent first, and agrees with the per-bone queries', async () => {+ const factory = (await import(resolve(WASM_DIR, moduleName + '.js'))).default;+ const raw: SpineWasmModule = await factory({ wasmBinary: readFileSync(resolve(WASM_DIR, moduleName + '.wasm')) });+ const controller = new SpineModuleController(raw, wrapSpineModule(raw));+ const root = resolve(__dirname, '../../third_party/spine-runtimes-' + version);+ const dir = version === '2.1' ? resolve(root, 'spine-c/data') : resolve(root, 'examples/spineboy/export');+ const file = version === '2.1' ? 'spineboy.json' : 'spineboy-pro.json';+ const bytes = readFileSync(resolve(dir, file));+ const handle = controller.loadSkeleton(new Uint8Array(bytes), readFileSync(resolve(dir, 'spineboy.atlas'), 'utf8'), false);+ expect(handle).toBeGreaterThan(0);+ const id = controller.createInstance(handle);+ try {+ expect(controller.play(id, 'walk', true)).toBe(true);+ controller.update(id, 0.3);+ const bones = controller.getBoneTree(id);+ expect(bones).not.toBeNull();+ const authored = JSON.parse(bytes.toString('utf8')).bones as Array<{ name: string; parent?: string; length?: number }>;+ // The tree is the file's own bone list, in its order, with the parent each names.+ expect(bones!.map((b) => b.name)).toEqual(authored.map((b) => b.name));+ bones!.forEach((b, i) => {+ const parent = authored[i]!.parent;+ expect(b.parent).toBe(parent ? authored.findIndex((a) => a.name === parent) : -1);+ expect(b.parent).toBeLessThan(i);+ expect(b.length).toBeCloseTo(authored[i]!.length ?? 0, 3);+ });+ // Posed, not the setup pose: it matches what the single-bone queries say this frame.+ for (const b of bones!.slice(0, 12)) {+ const at = controller.getBonePosition(id, b.name)!;+ expect(b.x).toBeCloseTo(at.x, 4);+ expect(b.y).toBeCloseTo(at.y, 4);+ expect(b.degrees).toBeCloseTo(controller.getBoneRotation(id, b.name), 3);+ }+ const before = bones!.map((b) => b.x + b.y);+ controller.update(id, 0.2);+ const after = controller.getBoneTree(id)!.map((b) => b.x + b.y);+ expect(after).not.toEqual(before);+ } finally {+ controller.destroyInstance(id);+ controller.unloadSkeleton(handle);+ }+ }, 30_000);+ });+}diff --git a/src/esengine/bindings/modules/dragonbones/DragonBonesBindings.hpp b/src/esengine/bindings/modules/dragonbones/DragonBonesBindings.hppindex 12997c0a1..5239a7d7d 100644--- a/src/esengine/bindings/modules/dragonbones/DragonBonesBindings.hpp+++ b/src/esengine/bindings/modules/dragonbones/DragonBonesBindings.hpp@@ -50,6 +50,10 @@ void db_setTimeScale(int instanceId, float scale);void db_setColor(int instanceId, float r, float g, float b, float a);void db_update(int instanceId, float dt);const char* db_getAnimations(int instanceId);+/** The bone names in armature order, a parent before its children. */+const char* db_getBones(int instanceId);+/** @heapreturn outPtr: five floats a bone — parent index (-1 for a root), x, y, degrees, length; returns the count */+int db_getBonePoses(int instanceId, uintptr_t outPtr, int capacity);// — Geometry readback ——————————————————————————————————————————————————————int db_getMeshBatchCount(int instanceId);diff --git a/src/esengine/bindings/modules/dragonbones/DragonBonesModuleEntry.cpp b/src/esengine/bindings/modules/dragonbones/DragonBonesModuleEntry.cppindex aa8c34125..c40b61a17 100644--- a/src/esengine/bindings/modules/dragonbones/DragonBonesModuleEntry.cpp+++ b/src/esengine/bindings/modules/dragonbones/DragonBonesModuleEntry.cpp@@ -37,6 +37,7 @@#define EMSCRIPTEN_KEEPALIVE#endif+#include <algorithm>#include <cstring>#include <string>#include <vector>@@ -299,6 +300,49 @@ const char* db_getAnimations(int instanceId) {[&names](int i) { return names[static_cast<std::size_t>(i)].c_str(); });}+/** The bone names, in the armature's own order — a parent before each of its children. */+EMSCRIPTEN_KEEPALIVE+const char* db_getBones(int instanceId) {+ auto* armature = g_ctx.armatureOf(instanceId);+ if (!armature) return g_ctx.strings.publish("[]");+ const auto& bones = armature->getBones();+ return g_ctx.strings.publishArray(static_cast<int>(bones.size()),+ [&bones](int i) { return bones[static_cast<std::size_t>(i)]->getName().c_str(); });+}++/**+ * Every bone's parent index and pose in one call: 5 floats a bone — parent (-1 for a root),+ * x, y, degrees, length — into `outPtr`, at most `capacity` bones; returns how many it wrote.+ * Posed in the y-UP space the geometry leaves the runtime in (see EsArmatureProxy), so the+ * skeleton drawn over the artwork lands on it.+ */+EMSCRIPTEN_KEEPALIVE+int db_getBonePoses(int instanceId, uintptr_t outPtr, int capacity) {+ auto* armature = g_ctx.armatureOf(instanceId);+ if (!armature) return 0;+ const auto& bones = armature->getBones();+ float* out = reinterpret_cast<float*>(outPtr);+ const int n = std::min(static_cast<int>(bones.size()), capacity);+ for (int i = 0; i < n; ++i) {+ dragonBones::Bone* bone = bones[static_cast<std::size_t>(i)];+ bone->updateGlobalTransform();+ int parent = -1;+ if (const dragonBones::Bone* p = bone->getParent()) {+ for (int j = 0; j < i; ++j) {+ if (bones[static_cast<std::size_t>(j)] == p) { parent = j; break; }+ }+ }+ constexpr float kRadToDeg = 57.29577951308232f;+ float* at = out + i * 5;+ at[0] = static_cast<float>(parent);+ at[1] = bone->global.x;+ at[2] = -bone->global.y;+ at[3] = -bone->global.rotation * kRadToDeg;+ at[4] = bone->getBoneData()->length;+ }+ return n;+}+// =============================================================================// Geometry readback// =============================================================================diff --git a/src/esengine/bindings/modules/spine/SpineBindings.hpp b/src/esengine/bindings/modules/spine/SpineBindings.hppindex 3b0618497..b4259c4f9 100644--- a/src/esengine/bindings/modules/spine/SpineBindings.hpp+++ b/src/esengine/bindings/modules/spine/SpineBindings.hpp@@ -47,6 +47,10 @@ const char* spine_getAnimations(int instanceId);const char* spine_getSkins(int instanceId);int spine_getBonePosition(int instanceId, const char* bone, uintptr_t outXPtr, uintptr_t outYPtr);float spine_getBoneRotation(int instanceId, const char* bone);+/** The bone names in skeleton order, a parent before its children. */+const char* spine_getBones(int instanceId);+/** @heapreturn outPtr: five floats a bone — parent index (-1 for a root), x, y, degrees, length; returns the count */+int spine_getBonePoses(int instanceId, uintptr_t outPtr, int capacity);void spine_getBounds(int instanceId, uintptr_t outXPtr, uintptr_t outYPtr, uintptr_t outWPtr, uintptr_t outHPtr);int spine_getMeshBatchCount(int instanceId);int spine_getMeshBatchColorPremultiplied(int instanceId, int batchIndex);diff --git a/src/esengine/bindings/modules/spine/SpineModuleEntry.cpp b/src/esengine/bindings/modules/spine/SpineModuleEntry.cppindex 76e1cb1da..be1738331 100644--- a/src/esengine/bindings/modules/spine/SpineModuleEntry.cpp+++ b/src/esengine/bindings/modules/spine/SpineModuleEntry.cpp@@ -35,6 +35,7 @@#include "./SpineBindings.hpp"#include "./SpineRuntime.hpp"+#include <algorithm>#include <cstdio>#include <cstring>#include <iterator>@@ -321,6 +322,41 @@ int spine_getBonePosition(int instanceId, const char* bone,: 0;}+/** The bone names, in the skeleton's own order — a parent before each of its children. */+EMSCRIPTEN_KEEPALIVE+const char* spine_getBones(int instanceId) {+ auto* instance = g_ctx.instanceOf(instanceId);+ if (!instance) return publish("[]");+ return g_ctx.strings.publishArray(es::spine::boneCount(instance),+ [instance](int i) { return es::spine::boneName(instance, i); });+}++/**+ * Every bone's parent index and pose in one call: 5 floats a bone — parent (-1 for a root),+ * x, y, degrees, length — into `outPtr`, at most `capacity` bones. Returns how many it wrote.+ * One crossing for the whole tree, because an overlay asks every frame.+ */+EMSCRIPTEN_KEEPALIVE+int spine_getBonePoses(int instanceId, uintptr_t outPtr, int capacity) {+ auto* instance = g_ctx.instanceOf(instanceId);+ if (!instance) return 0;+ float* out = reinterpret_cast<float*>(outPtr);+ const int n = std::min(es::spine::boneCount(instance), capacity);+ int written = 0;+ for (int i = 0; i < n; ++i) {+ float x = 0, y = 0, degrees = 0, length = 0;+ if (!es::spine::bonePose(instance, i, &x, &y, °rees, &length)) continue;+ float* at = out + written * 5;+ at[0] = static_cast<float>(es::spine::boneParent(instance, i));+ at[1] = x;+ at[2] = y;+ at[3] = degrees;+ at[4] = length;+ ++written;+ }+ return written;+}+EMSCRIPTEN_KEEPALIVEfloat spine_getBoneRotation(int instanceId, const char* bone) {float degrees = 0.0f;diff --git a/src/esengine/bindings/modules/spine/SpineRuntime.hpp b/src/esengine/bindings/modules/spine/SpineRuntime.hppindex 0c975ef26..accf04143 100644--- a/src/esengine/bindings/modules/spine/SpineRuntime.hpp+++ b/src/esengine/bindings/modules/spine/SpineRuntime.hpp@@ -236,6 +236,21 @@ const char* skinName(const Instance* instance, int index);bool bonePosition(const Instance* instance, const char* bone, float* x, float* y);bool boneRotation(const Instance* instance, const char* bone, float* degrees);++/**+ * The skeleton as a tree: how many bones, each one's name, and which one is its parent+ * (-1 for a root). Indices are the skeleton's own order, which puts a parent before every+ * child, so a caller may walk it once without recursion.+ */+int boneCount(const Instance* instance);+const char* boneName(const Instance* instance, int index);+int boneParent(const Instance* instance, int index);++/**+ * One bone as drawn this frame: where it starts (skeleton space), the direction it points+ * in degrees, and how long it is. The applied pose, so constraints are in it.+ */+bool bonePose(const Instance* instance, int index, float* x, float* y, float* degrees, float* length);void bounds(const Instance* instance, float* x, float* y, float* width, float* height);/**diff --git a/src/esengine/bindings/modules/spine/SpineRuntime21.cpp b/src/esengine/bindings/modules/spine/SpineRuntime21.cppindex 6a2eee9da..1029030e4 100644--- a/src/esengine/bindings/modules/spine/SpineRuntime21.cpp+++ b/src/esengine/bindings/modules/spine/SpineRuntime21.cpp@@ -457,6 +457,36 @@ bool boneRotation(const Instance* instance, const char* bone, float* degrees) {return true;}+int boneCount(const Instance* instance) {+ return instance ? instance->skeleton->bonesCount : 0;+}++const char* boneName(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return nullptr;+ return instance->skeleton->bones[index]->data->name;+}++int boneParent(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return -1;+ const spBone* parent = instance->skeleton->bones[index]->parent;+ if (!parent) return -1;+ // 2.1 bones carry no index of their own: the parent is found by where it sits.+ for (int i = 0; i < index; ++i) {+ if (instance->skeleton->bones[i] == parent) return i;+ }+ return -1;+}++bool bonePose(const Instance* instance, int index, float* x, float* y, float* degrees, float* length) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return false;+ spBone* b = instance->skeleton->bones[index];+ *x = b->worldX;+ *y = b->worldY;+ *degrees = b->worldRotation;+ *length = b->data->length;+ return true;+}+void bounds(const Instance* instance, float* x, float* y, float* width, float* height) {*x = *y = *width = *height = 0.0f;if (!instance) return;diff --git a/src/esengine/bindings/modules/spine/SpineRuntimeC.cpp b/src/esengine/bindings/modules/spine/SpineRuntimeC.cppindex 600a1faea..38b057ade 100644--- a/src/esengine/bindings/modules/spine/SpineRuntimeC.cpp+++ b/src/esengine/bindings/modules/spine/SpineRuntimeC.cpp@@ -476,6 +476,31 @@ bool boneRotation(const Instance* instance, const char* bone, float* degrees) {return true;}+int boneCount(const Instance* instance) {+ return instance ? instance->skeleton->bonesCount : 0;+}++const char* boneName(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return nullptr;+ return instance->skeleton->bones[index]->data->name;+}++int boneParent(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return -1;+ const spBone* parent = instance->skeleton->bones[index]->parent;+ return parent ? parent->data->index : -1;+}++bool bonePose(const Instance* instance, int index, float* x, float* y, float* degrees, float* length) {+ if (!instance || index < 0 || index >= instance->skeleton->bonesCount) return false;+ spBone* b = instance->skeleton->bones[index];+ *x = b->worldX;+ *y = b->worldY;+ *degrees = spBone_getWorldRotationX(b);+ *length = b->data->length;+ return true;+}+bool skeletonBounds(const Skeleton* skeleton, float* x, float* y, float* width, float* height) {if (!skeleton || !skeleton->data) return false;*x = skeleton->data->x;diff --git a/src/esengine/bindings/modules/spine/SpineRuntimeCpp.cpp b/src/esengine/bindings/modules/spine/SpineRuntimeCpp.cppindex e8c33c178..b8814765e 100644--- a/src/esengine/bindings/modules/spine/SpineRuntimeCpp.cpp+++ b/src/esengine/bindings/modules/spine/SpineRuntimeCpp.cpp@@ -392,6 +392,31 @@ bool boneRotation(const Instance* instance, const char* bone, float* degrees) {return true;}+int boneCount(const Instance* instance) {+ return instance ? static_cast<int>(instance->skeleton->getBones().size()) : 0;+}++const char* boneName(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= boneCount(instance)) return nullptr;+ return cstr(instance->skeleton->getBones()[index]->getData().getName());+}++int boneParent(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= boneCount(instance)) return -1;+ sp::Bone* parent = instance->skeleton->getBones()[index]->getParent();+ return parent ? parent->getData().getIndex() : -1;+}++bool bonePose(const Instance* instance, int index, float* x, float* y, float* degrees, float* length) {+ if (!instance || index < 0 || index >= boneCount(instance)) return false;+ sp::Bone* b = instance->skeleton->getBones()[index];+ *x = b->getAppliedPose().getWorldX();+ *y = b->getAppliedPose().getWorldY();+ *degrees = b->getAppliedPose().getWorldRotationX();+ *length = b->getData().getLength();+ return true;+}+void bounds(const Instance* instance, float* x, float* y, float* width, float* height) {*x = *y = *width = *height = 0.0f;if (!instance) return;diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex ff8c56a18..83b8a35d8 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -122,6 +122,8 @@ export const NOTED = {{ note: 'Gizmos are redrawn.' },'feat(editor): a UI element with a 9-slice visual drags its own border on the picture, unless its texture already carries one':{ note: 'Gizmos are redrawn.' },+ "feat(editor): a selected Spine or DragonBones entity shows its bones over the artwork, read from the runtime's posed skeleton":+ { note: 'Gizmos are redrawn.' },'feat(editor): an asset header names its kind and size, and a segmented switch is used only when its words fit':{ note: "An asset's header names its kind and size." },"feat(editor): asset inspectors take the board's finish — a card preview, ruled key-value rows, tinted actions, a kind icon in the header":