@melonjs/spine-plugin 2.2.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0 - _2026-06-14_
4
+
5
+ ### Added
6
+
7
+ - `Spine.findConstraint(name)` — convenience wrapper around the unified 4.3 constraints list; matches the `findBone()`/`findSlot()` shape and resolves any constraint type (IK, transform, path, physics, Slider) by name. Return type is typed as a union of the five concrete constraint classes (`SpineConstraint` typedef) for `instanceof` narrowing without a cast
8
+ - `Spine.getConstraintNames()` — list all constraint names defined on the skeleton (mirrors `getAnimationNames()`/`getSkinNames()`)
9
+ - spine-core constraint classes re-exported from `@melonjs/spine-plugin` so `instanceof` narrowing of `findConstraint()` results doesn't require a second runtime import (the plugin already owns the spine-core re-export, so identity matches): the new 4.3 Slider classes (`Slider`, `SliderData`, `SliderTimeline`, `SliderMixTimeline`) plus the four pre-existing constraint classes (`IkConstraint`, `TransformConstraint`, `PathConstraint`, `PhysicsConstraint`)
10
+
11
+ ### Fixed
12
+
13
+ - `setSkeleton()` actually loads binary `.skel` skeletons — was hardcoded to `SkeletonJson` for every input, so passing a `.skel` file (loaded as a `Uint8Array` by the asset manager) threw inside the JSON parser. Now dispatches to `SkeletonBinary` for `.skel` filenames and `SkeletonJson` otherwise. The README and JSDoc have claimed binary support since the original 1.x release; this is the first version where it works. The `spineboy` example in the live preview now loads from `spineboy-pro.skel` to give the binary path continuous coverage
14
+
15
+ ### Chore
16
+
17
+ - dev deps: `tsx` ^4.21.0 → ^4.22.4, `typescript` ^6.0.2 → ^6.0.3 (no consumer impact — devDependencies aren't installed by npm consumers of the plugin)
18
+
19
+ ## 3.0.0 - _2026-06-14_
20
+
21
+ ### **BREAKING CHANGES**
22
+
23
+ - **Spine 4.3 editor required** — bundled Spine runtimes bumped from `^4.2.114` to `^4.3.7`. The 4.2 and 4.3 skeleton data formats are incompatible both ways: existing `.json`/`.skel` exports must be re-exported from a Spine 4.3 editor, and 4.3 exports will not load on plugin 2.x
24
+ - the plugin now sets `Skeleton.yDown = true` (the official 4.3 Y-down switch, same approach as Spine's own pixi/phaser/canvaskit integrations). Code that reached into `spineObject.skeleton` and compensated for the old manual Y-flip (root bone `scaleY = -1`, inverted physics gravity) must drop those workarounds — the runtime now handles Y-down natively
25
+ - Spine 4.3 moved bone/slot state into poses: code accessing `bone.x/.scaleX/.worldX` etc. through `spineObject.skeleton` must use `bone.pose.*` (unconstrained, for writing) or `bone.appliedPose.*` (constrained, for reading world transforms); `slot.color`/`slot.getAttachment()` are now `slot.appliedPose.color`/`slot.appliedPose.attachment`
26
+ - other 4.3 core renames that surface through `spineObject.skeleton`: `setToSetupPose()` → `setupPose()`, `physicsConstraints` → `physics`, `MixBlend`/`MixDirection` removed (use `TrackEntry.additive`), `MeshAttachment.getParentMesh()` → `getSourceMesh()`. The plugin's own `Spine.setToSetupPose()` wrapper keeps its name
27
+
28
+ ### Added
29
+
30
+ - Spine 4.3 feature support inherited with the runtime bump: slider constraints, sequence timelines, non-linear animation mixing (`TrackEntry.mixInterpolation`), convex/inverse clipping, physics force direction vectors (`skeleton.windX/Y`, `gravityX/Y`)
31
+ - **WebGL context-loss recovery** — the plugin now survives a `webglcontextlost`/`webglcontextrestored` cycle (melonJS ≥ 19.7 recovery machinery): `SpineBatcher` builds its GPU resources in `init()` so the renderer's restore path can re-create them, and all spine GL resources (atlas textures, debug pipeline) are funneled through a single shared canvas-backed `ManagedWebGLRenderingContext` so spine's own restorables actually fire (a managed context built from a raw GL context has no element to listen on and silently never restores)
32
+
33
+ ### Changed
34
+
35
+ - minimum melonJS version is now **19.7.1** (was 18.3.0) — required for the WebGL context-loss restore + blend-cache invalidation fix the plugin's recovery path relies on
36
+ - skeleton positioning now goes through `skeleton.x/y` instead of writing to the root bone pose — root-bone-relative user code (e.g. custom bone offsets) is unaffected
37
+ - `flipX()`/`flipY()` JSDoc corrected: flipping is around the root bone, not the visual center (behavior unchanged, was always root-relative)
38
+ - mesh auto-detection for the canvas renderer now uses the public `Skin.getAttachments()` API instead of walking spine's internal `skin.attachments` array
39
+
40
+ ### Performance
41
+
42
+ - Canvas `SkeletonRenderer` mesh vertex buffer slimmed from 8 floats per vertex down to 2 (positions only) — first removed the 4 dead per-vertex color floats (canvas tinting is applied per slot via `setTint()`/`setGlobalAlpha()`), then dropped the UV interleave entirely (UVs now read straight from `sequence.getUVs(index)` in `drawMesh`). Halves the buffer twice over, eliminates a per-vertex copy pass, and removes the dedicated `computeMeshVertices` method. Verified pixel-identical across all 15 example skeletons (cold-start harness drift falls in the same noise floor with the change applied or not)
43
+
44
+ ### Fixed
45
+
46
+ - Canvas `SkeletonRenderer` no longer corrupts mesh vertex data while a `ClippingAttachment` is active — the stride-2 "clipped vertex size" was inherited from spine-webgl's `clipTriangles` repacking, which the canvas path never performs: positions were written at stride 2 then read at the full vertex stride, scrambling any mesh drawn inside an active clip (latent since the 4.2 plugin; canvas meshes are clipped per-triangle, so no example skeleton ever exposed it)
47
+ - Canvas `SkeletonRenderer` now uses `color.alpha` (the melonJS `Color` accessor) instead of `color.a`, which was always `undefined`. Canvas's `globalAlpha = undefined` is silently ignored, so slot-alpha animation never faded attachments — the canvas renderer behaved as if every slot were fully opaque. Visible on `powerup` (the trailing stars stayed at full opacity instead of fading) and any other skeleton with slot-alpha keyframes
48
+ - Canvas `SkeletonRenderer` correctly handles atlas regions packed at 90° rotation (`region.degrees === 90`) — the `translate(-w/2, -h/2)` after the dimension swap was using the *pre-swap* half-dimensions, so any attachment whose texture region was rotated in the atlas drew with its quad offset by `±(w−h)/2`. Visible as the tank turret floating detached from the chassis and the raptor rider's visor tilted off his head on canvas (WebGL was unaffected). Now matches the official `spine-canvas` SkeletonRenderer math by re-deriving the halves from post-swap `w`/`h`
49
+
50
+ ### Removed
51
+
52
+ - all manual Y-down plumbing made obsolete by `Skeleton.yDown`: the root-bone `scaleY` inversion in `setToSetupPose()`, the per-constraint physics gravity flip in `setSkeleton()`, and the `+90°` Canvas rotation offset in `rotate()`
53
+
3
54
  ## 2.2.1 - 2026-05-11
4
55
 
5
56
  ### Changed
package/README.md CHANGED
@@ -1,26 +1,27 @@
1
1
  # melonJS Spine Plugin
2
2
 
3
- A [Spine](http://en.esotericsoftware.com/spine-in-depth) 4.2 runtime integration for the [melonJS](http://www.melonjs.org) game engine, using the official [@esotericsoftware/spine-webgl](https://www.npmjs.com/package/@esotericsoftware/spine-webgl) and [@esotericsoftware/spine-canvas](https://www.npmjs.com/package/@esotericsoftware/spine-canvas) runtimes.
3
+ A [Spine](http://en.esotericsoftware.com/spine-in-depth) 4.x runtime integration for the [melonJS](http://www.melonjs.org) game engine, using the official [@esotericsoftware/spine-webgl](https://www.npmjs.com/package/@esotericsoftware/spine-webgl) and [@esotericsoftware/spine-canvas](https://www.npmjs.com/package/@esotericsoftware/spine-canvas) runtimes.
4
4
 
5
5
  ![melonjs-spine-gif](https://github.com/melonjs/spine-plugin/assets/4033090/dc259c8e-def6-419e-83a9-cda374715686)
6
6
 
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/melonjs/melonJS/blob/master/packages/spine-plugin/LICENSE)
8
8
  [![NPM Package](https://img.shields.io/npm/v/@melonjs/spine-plugin)](https://www.npmjs.com/package/@melonjs/spine-plugin)
9
- [![Spine Runtime](https://img.shields.io/badge/spine--runtime-4.2-orange)](http://esotericsoftware.com/spine-runtimes)
9
+ [![Spine Runtime](https://img.shields.io/badge/spine--runtime-4.3-orange)](http://esotericsoftware.com/spine-runtimes)
10
10
 
11
- [Live Example](https://melonjs.github.io/melonJS/examples/#/spine) — 17 official Spine characters including spineboy, raptor, owl, dragon, and more
11
+ [Live Example](https://melonjs.github.io/melonJS/examples/#/spine) — 15 official Spine characters including spineboy, raptor, owl, dragon, and more
12
12
 
13
13
  ## Features
14
14
  -------------------------------------------------------------------------------
15
15
  - **WebGL rendering** via custom `SpineBatcher` extending melonJS `Batcher` with two-color tinting and indexed drawing
16
16
  - **Canvas rendering** with full mesh, clipping, tinting, and blend mode support
17
- - **Spine 4.2 physics** support with automatic gravity correction for Y-down coordinate system
17
+ - **Spine physics** support native Y-down handling via the official `Skeleton.yDown` runtime switch, including physics force direction vectors (`windX/Y`, `gravityX/Y`)
18
18
  - **Two-color tinting** (dark/light color) using Spine's official shader
19
19
  - **Blend modes** (Normal, Additive, Multiply, Screen) with premultiplied alpha support
20
20
  - **Clipping attachments** via melonJS masking (canvas) and Spine's SkeletonClipping (WebGL)
21
21
  - **Skin support** including mix-and-match skin combining via `setCombinedSkin()`
22
22
  - **Animation state events** (start, end, complete, event, interrupt, dispose)
23
- - **Skeleton introspection** — `findBone()`, `findSlot()`, `getAnimationNames()`, `getSkinNames()`
23
+ - **Skeleton introspection** — `findBone()`, `findSlot()`, `findConstraint()`, `getAnimationNames()`, `getSkinNames()`
24
+ - **Spine 4.3 Slider constraints** — full runtime support; all constraint classes (`Slider`/`SliderData`/`SliderTimeline`/`SliderMixTimeline`, plus `IkConstraint`, `TransformConstraint`, `PathConstraint`, `PhysicsConstraint`) re-exported for one-import `instanceof` narrowing of `findConstraint()` results
24
25
  - **Animation queuing** — `setAnimation()`, `addAnimation()`, `setEmptyAnimation()`
25
26
  - **Debug rendering** for bones, regions, meshes, and clipping areas
26
27
  - **Auto-detection** of mesh attachments for optimized canvas rendering (fast path for region-only skeletons)
@@ -30,7 +31,7 @@ A [Spine](http://en.esotericsoftware.com/spine-in-depth) 4.2 runtime integration
30
31
  ## Installation
31
32
  -------------------------------------------------------------------------------
32
33
  This plugin is already bundled with the required Spine [4.x runtime](package.json#dependencies), so there is no need to install it separately.
33
- >Note: this plugin requires melonJS version 18.3.0 or higher.
34
+ >Note: this plugin requires melonJS version 19.7.1 or higher.
34
35
 
35
36
  To install the plugin using npm:
36
37
 
@@ -109,9 +110,38 @@ me.loader.preload(DataManifest, function() {
109
110
  |---|---|
110
111
  | `findBone(boneName)` | Find a bone by name |
111
112
  | `findSlot(slotName)` | Find a slot by name |
113
+ | `findConstraint(constraintName)` | Find a constraint by name (IK / Transform / Path / Physics / **Slider**) — added in 3.1.0 |
114
+ | `getConstraintNames()` | Get the list of constraint names available in the skeleton — added in 3.1.0 |
112
115
  | `setToSetupPose()` | Reset skeleton to setup pose |
113
116
  | `setSkeleton(atlasFile, jsonFile)` | Load a skeleton (if not set via constructor) |
114
117
 
118
+ ### Spine 4.3 Slider constraints
119
+
120
+ Spine 4.3 introduced [Slider constraints](https://esotericsoftware.com/blog/Spine-4.3-released#slider-constraints) — a pre-baked animation indexed by a numeric `time` value, optionally driven by a bone's rotation. The plugin re-exports the Spine runtime's Slider classes (and the four pre-existing constraint classes) alongside the default `Spine` export so consumers can do `instanceof Slider` (or `instanceof IkConstraint`, etc.) without a second import from `@esotericsoftware/spine-core`:
121
+
122
+ ```javascript
123
+ import Spine, {
124
+ // 4.3 Slider classes
125
+ Slider, SliderData, SliderTimeline, SliderMixTimeline,
126
+ // other constraint classes — for narrowing findConstraint() results
127
+ IkConstraint, TransformConstraint, PathConstraint, PhysicsConstraint,
128
+ } from "@melonjs/spine-plugin";
129
+
130
+ const diamond = new Spine(750, 600, { atlasFile: "diamond-pma.atlas", jsonFile: "diamond-pro.json" });
131
+ diamond.setAnimation(0, "idle-rotating", true);
132
+
133
+ // query the "rotation" Slider constraint
134
+ const slider = diamond.findConstraint("rotation");
135
+ if (slider instanceof Slider) {
136
+ // scrub a slider manually (disable bone auto-driving first)
137
+ slider.bone = null;
138
+ slider.pose.time = 1.0; // jump to t=1s in the slider's animation
139
+ slider.pose.mix = 1.0; // 0..1 — how much of the slider pose to apply
140
+ }
141
+ ```
142
+
143
+ See the [diamond example](https://melonjs.github.io/melonJS/examples/#/spine) for an interactive demo.
144
+
115
145
  ### Transform
116
146
  | Method | Description |
117
147
  |---|---|
@@ -125,11 +155,14 @@ me.loader.preload(DataManifest, function() {
125
155
 
126
156
  | @melonjs/spine-plugin | melonJS | spine-runtime |
127
157
  |---|---|---|
128
- | v2.2.0 | v18.3.0 (or higher) | v4.2.x |
129
- | v2.1.0 | v18.3.0 (or higher) | v4.2.x |
130
- | v2.0.1 | v18.2.1 (or higher) | v4.2.x |
131
- | v2.0.0 | v18.2.0 | v4.2.x |
132
- | v1.5.x | v15.12.x v18.0.x | v4.1, v4.2-beta |
158
+ | v3.x.x | v19.7.1 (or higher) | v4.3.x |
159
+ | v2.2.x | v18.3.0 (or higher) | v4.2.x |
160
+ | v2.1.x | v18.3.0 (or higher) | v4.2.x |
161
+ | v2.0.x | v18.2.1 (or higher) | v4.2.x |
162
+ | v2.0.0 | v18.2.0 (or higher) | v4.2.x |
163
+ | v1.5.x | v15.12.0 (or higher)| v4.1, v4.2-beta |
164
+
165
+ > **Note:** skeleton data is editor-version locked — plugin 3.x requires assets exported from a Spine **4.3** editor; 4.2 exports will not load (and vice-versa on plugin 2.x).
133
166
 
134
167
  ## Questions, need help ?
135
168
  -------------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../src/AssetManager.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACC;;;OAGG;IACH,sBAHW,cAAc,GAAC,aAAa,eAC5B,MAAM,EA0ChB;IAvCA;;;OAGG;IACH,sEAG4C;IAkC7C;;;OAGG;IACH,sBAFW,MAAM,QAIhB;IAED;;;;;;;;;OASG;IACH,iBARW,MAAM,QACN,MAAM,QAgBhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,+CAMhB;IAED;;;;;OAKG;IACH,iBAJW,MAAM,+CAMhB;IAED;;;;;OAKG;IACH,eAJW,MAAM,+CAMhB;IAED;;;;OAIG;IACH,wBAEC;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,GAAC,CAIb;IAED;;OAEG;IACH,gBAEC;CACD;4BA3I2B,+BAA+B;6BAD9B,gCAAgC"}
1
+ {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../src/AssetManager.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH;IACC;;;OAGG;IACH,sBAHW,cAAc,GAAC,aAAa,eAC5B,MAAM,EA+ChB;IA5CA;;;OAGG;IACH,sEAQ4C;IAkC7C;;;OAGG;IACH,sBAFW,MAAM,QAIhB;IAED;;;;;;;;;OASG;IACH,iBARW,MAAM,QACN,MAAM,QAgBhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,+CAMhB;IAED;;;;;OAKG;IACH,iBAJW,MAAM,+CAMhB;IAED;;;;;OAKG;IACH,eAJW,MAAM,+CAMhB;IAED;;;;OAIG;IACH,wBAEC;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,GAAC,CAIb;IAED;;OAEG;IACH,gBAEC;CACD;4BAjJ2B,+BAA+B;6BAD9B,gCAAgC"}
@@ -28,7 +28,6 @@ export default class SkeletonRenderer {
28
28
  */
29
29
  premultipliedAlpha: boolean;
30
30
  tintColor: MColor;
31
- tempColor: MColor;
32
31
  clipper: SkeletonClipping;
33
32
  clippingVertices: any[];
34
33
  clippingMask: Polygon;
@@ -44,38 +43,31 @@ export default class SkeletonRenderer {
44
43
  * @param {HTMLImageElement} image
45
44
  * @param {Bone} bone
46
45
  * @param {RegionAttachment} attachment
46
+ * @param {SlotPose} slotPose - the slot's applied pose (resolves sequence offsets)
47
47
  * @param {TextureRegion} region
48
48
  * @param {Polygon|null} mask - clipping mask if active
49
49
  * @param {boolean} debug - whether to draw debug outline
50
50
  * @ignore
51
51
  */
52
- drawRegion(renderer: CanvasRenderer, image: HTMLImageElement, bone: Bone, attachment: RegionAttachment, region: TextureRegion, mask: Polygon | null, debug: boolean): void;
52
+ drawRegion(renderer: CanvasRenderer, image: HTMLImageElement, bone: Bone, attachment: RegionAttachment, slotPose: SlotPose, region: TextureRegion, mask: Polygon | null, debug: boolean): void;
53
53
  /**
54
54
  * Draw a mesh attachment as a series of textured triangles.
55
55
  * @param {CanvasRenderer} renderer
56
56
  * @param {HTMLImageElement} image
57
- * @param {Float32Array} vertices - world vertices
57
+ * @param {Float32Array} vertices - world positions, stride 2 (x, y per vertex)
58
+ * @param {NumberArrayLike} uvs - atlas UVs from `sequence.getUVs(index)`, stride 2
58
59
  * @param {number[]} triangles - triangle indices
59
60
  * @ignore
60
61
  */
61
- drawMesh(renderer: CanvasRenderer, image: HTMLImageElement, vertices: Float32Array, triangles: number[]): void;
62
+ drawMesh(renderer: CanvasRenderer, image: HTMLImageElement, vertices: Float32Array, uvs: NumberArrayLike, triangles: number[]): void;
62
63
  /**
63
64
  * Draw a single textured triangle using affine transform.
64
65
  * @ignore
65
66
  */
66
67
  drawTriangle(renderer: any, img: any, x0: any, y0: any, u0: any, v0: any, x1: any, y1: any, u1: any, v1: any, x2: any, y2: any, u2: any, v2: any): void;
67
- /**
68
- * Compute world vertices for a mesh attachment with color and UV data.
69
- * @param {Slot} slot
70
- * @param {MeshAttachment} mesh
71
- * @param {number} vertexSize - floats per vertex
72
- * @ignore
73
- */
74
- computeMeshVertices(slot: Slot, mesh: MeshAttachment, vertexSize: number): void;
75
68
  }
76
69
  import { Color as MColor } from "melonjs";
77
70
  import { SkeletonClipping } from "@esotericsoftware/spine-core";
78
71
  import { Polygon } from "melonjs";
79
72
  import { RegionAttachment } from "@esotericsoftware/spine-core";
80
- import { MeshAttachment } from "@esotericsoftware/spine-core";
81
73
  //# sourceMappingURL=SkeletonRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SkeletonRenderer.d.ts","sourceRoot":"","sources":["../src/SkeletonRenderer.js"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH;IACC;;;;;;;OAOG;IACH,mBAHU,OAAO,CAGS;IAE1B;;;;OAIG;IACH,gBAHU,OAAO,CAGM;IAEvB;;;;OAIG;IACH,oBAHU,OAAO,CAGU;IAG3B,kBAAyB;IACzB,kBAAyB;IAGzB,0BAAiC;IACjC,wBAAsB;IACtB,sBAIG;IAEH;;;;OAIG;IACH,eAHW,cAAc,YACd,QAAQ,QAoGlB;IAED;;;;;;;;;;OAUG;IACH,qBATW,cAAc,SACd,gBAAgB,QAChB,IAAI,cACJ,gBAAgB,UAChB,aAAa,QACb,OAAO,GAAC,IAAI,SACZ,OAAO,QAqDjB;IAED;;;;;;;OAOG;IACH,mBANW,cAAc,SACd,gBAAgB,YAChB,YAAY,aACZ,MAAM,EAAE,QA8BlB;IAED;;;OAGG;IACH,wJA2CC;IAED;;;;;;OAMG;IACH,0BALW,IAAI,QACJ,cAAc,cACd,MAAM,QAwChB;CACD;gCA5WuD,SAAS;iCAD1D,8BAA8B;wBACmB,SAAS;iCAD1D,8BAA8B;+BAA9B,8BAA8B"}
1
+ {"version":3,"file":"SkeletonRenderer.d.ts","sourceRoot":"","sources":["../src/SkeletonRenderer.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH;IACC;;;;;;;OAOG;IACH,mBAHU,OAAO,CAGS;IAE1B;;;;OAIG;IACH,gBAHU,OAAO,CAGM;IAEvB;;;;OAIG;IACH,oBAHU,OAAO,CAGU;IAG3B,kBAAyB;IAGzB,0BAAiC;IACjC,wBAAsB;IACtB,sBAIG;IAEH;;;;OAIG;IACH,eAHW,cAAc,YACd,QAAQ,QA2HlB;IAED;;;;;;;;;;;OAWG;IACH,qBAVW,cAAc,SACd,gBAAgB,QAChB,IAAI,cACJ,gBAAgB,YAChB,QAAQ,UACR,aAAa,QACb,OAAO,GAAC,IAAI,SACZ,OAAO,QAiEjB;IAED;;;;;;;;OAQG;IACH,mBAPW,cAAc,SACd,gBAAgB,YAChB,YAAY,OACZ,eAAe,aACf,MAAM,EAAE,QA8BlB;IAED;;;OAGG;IACH,wJA2CC;CACD;gCAnWuD,SAAS;iCAD1D,8BAA8B;wBACmB,SAAS;iCAD1D,8BAA8B"}
package/build/Spine.d.ts CHANGED
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Union of the five concrete constraint classes Spine 4.3 exposes via
3
+ * `skeleton.constraints` — returned by {@link Spine.findConstraint}.
4
+ * Narrow with `instanceof` against the corresponding re-export
5
+ * (`Slider`, `IkConstraint`, etc. from this plugin or
6
+ * `@esotericsoftware/spine-core`).
7
+ * @typedef {import("@esotericsoftware/spine-core").Slider
8
+ * | import("@esotericsoftware/spine-core").IkConstraint
9
+ * | import("@esotericsoftware/spine-core").TransformConstraint
10
+ * | import("@esotericsoftware/spine-core").PathConstraint
11
+ * | import("@esotericsoftware/spine-core").PhysicsConstraint
12
+ * } SpineConstraint
13
+ */
1
14
  /**
2
15
  * @classdesc
3
16
  * A renderable object to render Spine animated skeleton.
@@ -79,7 +92,6 @@ export default class Spine extends Renderable {
79
92
  currentTrack: TrackEntry;
80
93
  /** @ignore */
81
94
  isWebGL: boolean;
82
- canvas: any;
83
95
  spineBatcher: any;
84
96
  shapesShader: spineWebGL.Shader | undefined;
85
97
  shapes: spineWebGL.ShapeRenderer | undefined;
@@ -115,13 +127,13 @@ export default class Spine extends Renderable {
115
127
  setSkeleton(atlasFile: string, jsonFile: string): void;
116
128
  premultipliedAlpha: any;
117
129
  /**
118
- * Flip the Spine skeleton on the horizontal axis (around its center).
130
+ * Flip the Spine skeleton on the horizontal axis (around its root bone).
119
131
  * @param {boolean} [flip=true] - `true` to flip this Spine object.
120
132
  * @returns {Spine} Reference to this object for method chaining
121
133
  */
122
134
  flipX(flip?: boolean): Spine;
123
135
  /**
124
- * Flip the Spine skeleton on the vertical axis (around its center).
136
+ * Flip the Spine skeleton on the vertical axis (around its root bone).
125
137
  * @param {boolean} [flip=true] - `true` to flip this Spine object.
126
138
  * @returns {Spine} Reference to this object for method chaining
127
139
  */
@@ -153,6 +165,12 @@ export default class Spine extends Renderable {
153
165
  * Called automatically when the renderable is removed from the world.
154
166
  */
155
167
  dispose(): void;
168
+ /**
169
+ * Called when the renderable is destroyed (removed from the world).
170
+ * Cleans up GPU resources automatically.
171
+ * @ignore
172
+ */
173
+ onDestroyEvent(): void;
156
174
  /**
157
175
  * Sets the current animation for a track by animation index, discarding any queued animations.
158
176
  * @param {number} trackIndex - the track index
@@ -257,6 +275,29 @@ export default class Spine extends Renderable {
257
275
  * @returns {Slot|null} the slot, or null if not found
258
276
  */
259
277
  findSlot(slotName: string): Slot | null;
278
+ /**
279
+ * Find a constraint (Slider, IK, transform, path, or physics) by name.
280
+ * Convenience wrapper around the 4.3 unified constraints list — like
281
+ * {@link findBone}/{@link findSlot} but for any constraint type.
282
+ *
283
+ * Returns the constraint instance whose `data.name` matches; use
284
+ * `instanceof Slider` (etc., re-exported by this plugin) to narrow
285
+ * the type if you need the constraint's specific pose API.
286
+ * @param {string} constraintName - the constraint name
287
+ * @returns {SpineConstraint|null} the constraint, or null if not found
288
+ * @example
289
+ * // drive a Slider constraint manually (4.3+)
290
+ * const rot = spine.findConstraint("rotation");
291
+ * rot.pose.time = 1.5; // animation seconds; loops if `loop: true`
292
+ * rot.pose.mix = 1.0; // 0..1+ — blend toward the constrained pose
293
+ */
294
+ findConstraint(constraintName: string): SpineConstraint | null;
295
+ /**
296
+ * Get the list of constraint names available in this skeleton
297
+ * (Slider, IK, transform, path, physics — 4.3 unified list).
298
+ * @returns {string[]} array of constraint names
299
+ */
300
+ getConstraintNames(): string[];
260
301
  /**
261
302
  * Register a listener for animation state events.
262
303
  * @param {object} listener - an object with event handler methods
@@ -304,6 +345,14 @@ export default class Spine extends Renderable {
304
345
  */
305
346
  setToSetupPose(): void;
306
347
  }
348
+ /**
349
+ * Union of the five concrete constraint classes Spine 4.3 exposes via
350
+ * `skeleton.constraints` — returned by {@link Spine.findConstraint}.
351
+ * Narrow with `instanceof` against the corresponding re-export
352
+ * (`Slider`, `IkConstraint`, etc. from this plugin or
353
+ * `@esotericsoftware/spine-core`).
354
+ */
355
+ export type SpineConstraint = import("@esotericsoftware/spine-core").Slider | import("@esotericsoftware/spine-core").IkConstraint | import("@esotericsoftware/spine-core").TransformConstraint | import("@esotericsoftware/spine-core").PathConstraint | import("@esotericsoftware/spine-core").PhysicsConstraint;
307
356
  import { Renderable } from "melonjs";
308
357
  import * as spineWebGL from "@esotericsoftware/spine-webgl";
309
358
  import * as spineCanvas from "@esotericsoftware/spine-canvas";
@@ -1 +1 @@
1
- {"version":3,"file":"Spine.d.ts","sourceRoot":"","sources":["../src/Spine.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH;IAkCC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,eApCW,MAAM,KACN,MAAM,YAEd;QAA0B,SAAS;QACT,QAAQ;QACR,OAAO;KACjC,EA2FF;IAnID,gDAAQ;IACR,cAAS;IACT,0BAAO;IACP,oBAAe;IACf,iEAAiB;IACjB,UAAK;IACL,gCAAW;IACX,8BAAS;IACT;;;MAGE;IAEF;;;;;;;;;;;;;;;;;OAiBG;IACH,cAhBU,UAAU,CAgBP;IAmDZ,cAAc;IACd,iBAAyC;IAIxC,YAA0C;IAK1C,kBAAkD;IASlD,4CAA+D;IAC/D,6CAAyD;IACzD,oEAEC;IAmBF,gBAAsC;IAGrC,6BAAiC;IACjC,8BAAmC;IAcrC,0BANU,OAAO,EAQhB;IAXD;;;;OAIG;IACH,sBAFU,OAAO,CAIhB;IAMD;;;;;;;;;;;;;;;;;OAiBG;IACH,uBAfW,MAAM,YACN,MAAM,QAmEhB;IA3CA,wBAEE;IA2CH;;;;OAIG;IACH,aAHW,OAAO,GACL,KAAK,CASjB;IAED;;;;OAIG;IACH,aAHW,OAAO,GACL,KAAK,CASjB;IAED;;;;;OAKG;IACH,cAJW,MAAM,MACN,QAAQ,GAAC,kBAAkB,GACzB,KAAK,CAWjB;IAED;;;;;OAKG;IACH,SAJW,MAAM,MACN,MAAM,GACJ,KAAK,CAWjB;IAmFD;;;;;;OAMG;IACH,eAFW,cAAc,GAAC,aAAa,QA4CtC;IAED;;;OAGG;IACH,gBAMC;IAWD;;;;;;OAMG;IACH,gCALW,MAAM,SACN,MAAM,SACN,OAAO,GACL,UAAU,CAYtB;IAED;;;;;;;;;OASG;IACH,yBARW,MAAM,QACN,MAAM,SACN,OAAO,GACL,UAAU,CAYtB;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,GACJ,OAAO,CAWnB;IAED;;;;;;;OAOG;IACH,gCANW,MAAM,SACN,MAAM,SACN,OAAO,UACP,MAAM,GACJ,UAAU,CAatB;IAED;;;;;;;OAOG;IACH,yBANW,MAAM,QACN,MAAM,SACN,OAAO,UACP,MAAM,GACJ,UAAU,CAItB;IAED;;;OAGG;IACH,2BAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,qCAJW,MAAM,mBACN,MAAM,WACN,MAAM,QAIhB;IAED;;;;;;;;;;;;;;;OAeG;IACH,wBAdW,MAAM,QAgBhB;IAED;;;;;;;OAOG;IACH,8BANW,MAAM,gBACH,MAAM,EAAA,QAkBnB;IAED;;;;;OAKG;IACH,8BAJW,MAAM,gBACN,MAAM,GACJ,UAAU,CAItB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,IAAI,GAAC,IAAI,CAIrB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,IAAI,GAAC,IAAI,CAIrB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,+BAhBG;QAA4B,KAAK;QACL,SAAS;QACT,GAAG;QACH,OAAO;QACP,QAAQ;QACR,KAAK;KACjC,QAYF;IAED;;;OAGG;IACH,kCAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,qBAFa,MAAM,EAAE,CAMpB;IAED;;;OAGG;IACH,gBAFa,MAAM,EAAE,CAMpB;IAED;;OAEG;IACH,uBAYC;CACD;2BAnrBwC,SAAS;4BADtB,+BAA+B;6BAF9B,gCAAgC;uBAGpB,SAAS;6BACrB,uBAAuB"}
1
+ {"version":3,"file":"Spine.d.ts","sourceRoot":"","sources":["../src/Spine.js"],"names":[],"mappings":"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"}
@@ -5,16 +5,21 @@
5
5
  */
6
6
  export default class SpineBatcher extends Batcher {
7
7
  /**
8
+ * Initialize (or re-initialize) the batcher.
9
+ * Settings are built here rather than in the constructor so the
10
+ * renderer's context-restore recovery can re-create all GPU
11
+ * resources with a bare `batcher.init(renderer)` call, matching
12
+ * the engine's built-in batchers.
8
13
  * @param {WebGLRenderer} renderer - the current WebGL renderer session
9
- * @param {WebGLRenderingContext|WebGL2RenderingContext} canvas - the GL context for Spine shader creation
14
+ * @ignore
10
15
  */
11
- constructor(renderer: WebGLRenderer, canvas: WebGLRenderingContext | WebGL2RenderingContext);
16
+ init(renderer: WebGLRenderer): void;
12
17
  /**
13
18
  * the current texture bound to the batcher
14
19
  * @type {object|null}
15
20
  * @ignore
16
21
  */
17
- lastTexture: object | null;
22
+ lastTexture: object | null | undefined;
18
23
  /**
19
24
  * Set the blend mode for subsequent draw calls.
20
25
  * Maps Spine BlendMode enum to melonJS blend mode strings.
@@ -1 +1 @@
1
- {"version":3,"file":"SpineBatcher.d.ts","sourceRoot":"","sources":["../src/SpineBatcher.js"],"names":[],"mappings":"AAcA;;;;GAIG;AACH;IACC;;;OAGG;IACH,sBAHW,aAAa,UACb,qBAAqB,GAAC,sBAAsB,EAuDtD;IANA;;;;OAIG;IACH,aAHU,MAAM,GAAC,IAAI,CAGE;IAGxB;;;;;OAKG;IACH,wBAHW,MAAM,sBACN,OAAO,QAOjB;IAED;;;;;;OAMG;IACH,cAJW,MAAM,YACN,SAAS,CAAC,MAAM,CAAC,WACjB,MAAM,EAAE,QAwBlB;CAaD;wBArIuB,SAAS"}
1
+ {"version":3,"file":"SpineBatcher.d.ts","sourceRoot":"","sources":["../src/SpineBatcher.js"],"names":[],"mappings":"AAeA;;;;GAIG;AACH;IACC;;;;;;;;OAQG;IACH,eAHW,aAAa,QA0DvB;IANA;;;;OAIG;IACH,uCAAuB;IAGxB;;;;;OAKG;IACH,wBAHW,MAAM,sBACN,OAAO,QAOjB;IAED;;;;;;OAMG;IACH,cAJW,MAAM,YACN,SAAS,CAAC,MAAM,CAAC,WACjB,MAAM,EAAE,QAwBlB;CAaD;wBA7IuB,SAAS"}
@@ -4,7 +4,13 @@
4
4
  * @augments plugin.BasePlugin
5
5
  */
6
6
  export class SpinePlugin extends plugin.BasePlugin {
7
- constructor();
7
+ /**
8
+ * @param {Application} [app] - the application instance this plugin
9
+ * belongs to (defaults to the active game instance). Pass it through
10
+ * `plugin.register(SpinePlugin, "SpinePlugin", app)` when running
11
+ * multiple applications.
12
+ */
13
+ constructor(app?: Application);
8
14
  assetManager: AssetManager;
9
15
  }
10
16
  import { plugin } from "melonjs";
@@ -1 +1 @@
1
- {"version":3,"file":"SpinePlugin.d.ts","sourceRoot":"","sources":["../src/SpinePlugin.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH;IACC,cAkBC;IALA,2BAAuD;CAMxD;uBApCgD,SAAS;yBAQjC,gBAAgB"}
1
+ {"version":3,"file":"SpinePlugin.d.ts","sourceRoot":"","sources":["../src/SpinePlugin.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH;IACC;;;;;OAKG;IACH,kBALW,WAAW,EAuBrB;IALA,2BAAuD;CAMxD;uBA1CgD,SAAS;yBAQjC,gBAAgB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Return the shared spine ManagedWebGLRenderingContext for the given canvas,
3
+ * creating it on first use.
4
+ *
5
+ * One shared instance per canvas matters for WebGL context-loss recovery:
6
+ * Spine's GLTexture/Shader/Mesh register themselves as restorables on their
7
+ * managed context, but a managed context only listens for
8
+ * `webglcontextrestored` when constructed from a canvas (a raw
9
+ * WebGLRenderingContext gives it no element to listen on). Funneling every
10
+ * spine GL resource through this single canvas-backed instance guarantees
11
+ * they are all restored after a context loss.
12
+ * @param {HTMLCanvasElement} canvas - the canvas the melonJS WebGL renderer draws to
13
+ * @returns {ManagedWebGLRenderingContext} the shared managed context
14
+ * @ignore
15
+ */
16
+ export function getManagedContext(canvas: HTMLCanvasElement): ManagedWebGLRenderingContext;
17
+ import { ManagedWebGLRenderingContext } from "@esotericsoftware/spine-webgl";
18
+ //# sourceMappingURL=glContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glContext.d.ts","sourceRoot":"","sources":["../src/glContext.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,0CAJW,iBAAiB,GACf,4BAA4B,CAUxC;6CA1B4C,+BAA+B"}
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { SpinePlugin } from "./SpinePlugin.js";
2
+ export { IkConstraint, PathConstraint, PhysicsConstraint, Slider, SliderData, SliderMixTimeline, SliderTimeline, TransformConstraint } from "@esotericsoftware/spine-core";
2
3
  export { default, default as Spine } from "./Spine.js";
3
4
  //# sourceMappingURL=index.d.ts.map