@galacean/engine-spine 4.2.2 → 4.2.4

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.
Files changed (63) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/main.js +677 -251
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +677 -251
  5. package/dist/module.js +678 -253
  6. package/dist/module.js.map +1 -1
  7. package/package.json +5 -4
  8. package/types/renderer/SpineAnimationRenderer.d.ts +18 -7
  9. package/types/renderer/SpineGenerator.d.ts +3 -4
  10. package/types/renderer/SpineMaterial.d.ts +23 -1
  11. package/types/SpineAnimation.d.ts +0 -48
  12. package/types/SpineLoader.d.ts +0 -32
  13. package/types/SpineMaterial.d.ts +0 -6
  14. package/types/SpineRenderer.d.ts +0 -38
  15. package/types/core/MeshGenerator.d.ts +0 -43
  16. package/types/core/SpineMesh.d.ts +0 -11
  17. package/types/spine-core/Animation.d.ts +0 -378
  18. package/types/spine-core/AnimationState.d.ts +0 -365
  19. package/types/spine-core/AnimationStateData.d.ts +0 -23
  20. package/types/spine-core/AssetManager.d.ts +0 -36
  21. package/types/spine-core/AtlasAttachmentLoader.d.ts +0 -23
  22. package/types/spine-core/BlendMode.d.ts +0 -7
  23. package/types/spine-core/Bone.d.ts +0 -110
  24. package/types/spine-core/BoneData.d.ts +0 -44
  25. package/types/spine-core/ConstraintData.d.ts +0 -7
  26. package/types/spine-core/Event.d.ts +0 -16
  27. package/types/spine-core/EventData.d.ts +0 -13
  28. package/types/spine-core/IkConstraint.d.ts +0 -38
  29. package/types/spine-core/IkConstraintData.d.ts +0 -26
  30. package/types/spine-core/PathConstraint.d.ts +0 -46
  31. package/types/spine-core/PathConstraintData.d.ts +0 -52
  32. package/types/spine-core/SharedAssetManager.d.ts +0 -19
  33. package/types/spine-core/Skeleton.d.ts +0 -134
  34. package/types/spine-core/SkeletonBinary.d.ts +0 -49
  35. package/types/spine-core/SkeletonBounds.d.ts +0 -48
  36. package/types/spine-core/SkeletonClipping.d.ts +0 -22
  37. package/types/spine-core/SkeletonData.d.ts +0 -89
  38. package/types/spine-core/SkeletonJson.d.ts +0 -34
  39. package/types/spine-core/Skin.d.ts +0 -43
  40. package/types/spine-core/Slot.d.ts +0 -42
  41. package/types/spine-core/SlotData.d.ts +0 -23
  42. package/types/spine-core/Texture.d.ts +0 -46
  43. package/types/spine-core/TextureAtlas.d.ts +0 -30
  44. package/types/spine-core/TransformConstraint.d.ts +0 -36
  45. package/types/spine-core/TransformConstraintData.d.ts +0 -34
  46. package/types/spine-core/Triangulator.d.ts +0 -14
  47. package/types/spine-core/Updatable.d.ts +0 -9
  48. package/types/spine-core/Utils.d.ts +0 -124
  49. package/types/spine-core/VertexEffect.d.ts +0 -7
  50. package/types/spine-core/attachments/Attachment.d.ts +0 -43
  51. package/types/spine-core/attachments/AttachmentLoader.d.ts +0 -25
  52. package/types/spine-core/attachments/AttachmentType.d.ts +0 -9
  53. package/types/spine-core/attachments/BoundingBoxAttachment.d.ts +0 -12
  54. package/types/spine-core/attachments/ClippingAttachment.d.ts +0 -14
  55. package/types/spine-core/attachments/MeshAttachment.d.ts +0 -46
  56. package/types/spine-core/attachments/PathAttachment.d.ts +0 -19
  57. package/types/spine-core/attachments/PointAttachment.d.ts +0 -20
  58. package/types/spine-core/attachments/RegionAttachment.d.ts +0 -88
  59. package/types/spine-core/polyfills.d.ts +0 -3
  60. package/types/spine-core/vertexeffects/JitterEffect.d.ts +0 -11
  61. package/types/spine-core/vertexeffects/SwirlEffect.d.ts +0 -16
  62. package/types/types.d.ts +0 -4
  63. package/types/util/BlendMode.d.ts +0 -4
package/dist/main.js CHANGED
@@ -43,6 +43,97 @@ function __decorate(decorators, target, key, desc) {
43
43
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
44
44
  return c > 3 && r && Object.defineProperty(target, key, r), r;
45
45
  }
46
+ function __generator(thisArg, body) {
47
+ var _ = {
48
+ label: 0,
49
+ sent: function sent() {
50
+ if (t[0] & 1) throw t[1];
51
+ return t[1];
52
+ },
53
+ trys: [],
54
+ ops: []
55
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
56
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
57
+ return this;
58
+ }), g;
59
+ function verb(n) {
60
+ return function(v) {
61
+ return step([
62
+ n,
63
+ v
64
+ ]);
65
+ };
66
+ }
67
+ function step(op) {
68
+ if (f) throw new TypeError("Generator is already executing.");
69
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
70
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
71
+ if (y = 0, t) op = [
72
+ op[0] & 2,
73
+ t.value
74
+ ];
75
+ switch(op[0]){
76
+ case 0:
77
+ case 1:
78
+ t = op;
79
+ break;
80
+ case 4:
81
+ _.label++;
82
+ return {
83
+ value: op[1],
84
+ done: false
85
+ };
86
+ case 5:
87
+ _.label++;
88
+ y = op[1];
89
+ op = [
90
+ 0
91
+ ];
92
+ continue;
93
+ case 7:
94
+ op = _.ops.pop();
95
+ _.trys.pop();
96
+ continue;
97
+ default:
98
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
99
+ _ = 0;
100
+ continue;
101
+ }
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+ if (op[0] === 6 && _.label < t[1]) {
107
+ _.label = t[1];
108
+ t = op;
109
+ break;
110
+ }
111
+ if (t && _.label < t[2]) {
112
+ _.label = t[2];
113
+ _.ops.push(op);
114
+ break;
115
+ }
116
+ if (t[2]) _.ops.pop();
117
+ _.trys.pop();
118
+ continue;
119
+ }
120
+ op = body.call(thisArg, _);
121
+ } catch (e) {
122
+ op = [
123
+ 6,
124
+ e
125
+ ];
126
+ y = 0;
127
+ } finally{
128
+ f = t = 0;
129
+ }
130
+ if (op[0] & 5) throw op[1];
131
+ return {
132
+ value: op[0] ? op[1] : void 0,
133
+ done: true
134
+ };
135
+ }
136
+ }
46
137
  typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
47
138
  var e = new Error(message);
48
139
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -202,8 +293,9 @@ var Color = /*#__PURE__*/ function() {
202
293
  color.g = ((value & 0x0000ff00) >>> 8) / 255;
203
294
  color.b = (value & 0x000000ff) / 255;
204
295
  };
205
- Color.fromString = function fromString(hex) {
206
- return new Color().setFromString(hex);
296
+ Color.fromString = function fromString(hex, color) {
297
+ if (color === void 0) color = new Color();
298
+ return color.setFromString(hex);
207
299
  };
208
300
  return Color;
209
301
  }();
@@ -2827,18 +2919,16 @@ function _create_class(Constructor, protoProps, staticProps) {
2827
2919
  var finished = this.updateMixingFrom(from, delta);
2828
2920
  from.animationLast = from.nextAnimationLast;
2829
2921
  from.trackLast = from.nextTrackLast;
2830
- if (to.nextTrackLast != -1) {
2831
- var discard = to.mixTime == 0 && from.mixTime == 0; // Discard the from entry when neither have advanced yet.
2832
- if (to.mixTime >= to.mixDuration || discard) {
2833
- // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded.
2834
- if (from.totalAlpha == 0 || to.mixDuration == 0 || discard) {
2835
- to.mixingFrom = from.mixingFrom;
2836
- if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2837
- to.interruptAlpha = from.interruptAlpha;
2838
- this.queue.end(from);
2839
- }
2840
- return finished;
2922
+ // The from entry was applied at least once and the mix is complete.
2923
+ if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) {
2924
+ // Mixing is complete for all entries before the from entry or the mix is instantaneous.
2925
+ if (from.totalAlpha == 0 || to.mixDuration == 0) {
2926
+ to.mixingFrom = from.mixingFrom;
2927
+ if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2928
+ to.interruptAlpha = from.interruptAlpha;
2929
+ this.queue.end(from);
2841
2930
  }
2931
+ return finished;
2842
2932
  }
2843
2933
  from.trackTime += delta * from.timeScale;
2844
2934
  to.mixTime += delta;
@@ -3203,10 +3293,11 @@ function _create_class(Constructor, protoProps, staticProps) {
3203
3293
  if (!last) {
3204
3294
  this.setCurrent(trackIndex, entry, true);
3205
3295
  this.queue.drain();
3296
+ if (delay < 0) delay = 0;
3206
3297
  } else {
3207
3298
  last.next = entry;
3208
3299
  entry.previous = last;
3209
- if (delay <= 0) delay += last.getTrackComplete() - entry.mixDuration;
3300
+ if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
3210
3301
  }
3211
3302
  entry.delay = delay;
3212
3303
  return entry;
@@ -3245,7 +3336,7 @@ function _create_class(Constructor, protoProps, staticProps) {
3245
3336
  if (mixDuration === void 0) mixDuration = 0;
3246
3337
  if (delay === void 0) delay = 0;
3247
3338
  var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
3248
- if (delay <= 0) entry.delay += entry.mixDuration - mixDuration;
3339
+ if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
3249
3340
  entry.mixDuration = mixDuration;
3250
3341
  entry.trackEnd = mixDuration;
3251
3342
  return entry;
@@ -3499,7 +3590,10 @@ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
3499
3590
  var _proto = TrackEntry.prototype;
3500
3591
  _proto.setMixDurationWithDelay = function setMixDurationWithDelay(mixDuration, delay) {
3501
3592
  this._mixDuration = mixDuration;
3502
- if (this.previous != null && delay <= 0) delay += this.previous.getTrackComplete() - mixDuration;
3593
+ if (delay <= 0) {
3594
+ if (this.previous != null) delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
3595
+ else delay = 0;
3596
+ }
3503
3597
  this.delay = delay;
3504
3598
  };
3505
3599
  _proto.reset = function reset() {
@@ -3722,17 +3816,17 @@ var CURRENT = 2;
3722
3816
 
3723
3817
  /******************************************************************************
3724
3818
  * Spine Runtimes License Agreement
3725
- * Last updated July 28, 2023. Replaces all prior versions.
3819
+ * Last updated April 5, 2025. Replaces all prior versions.
3726
3820
  *
3727
- * Copyright (c) 2013-2023, Esoteric Software LLC
3821
+ * Copyright (c) 2013-2025, Esoteric Software LLC
3728
3822
  *
3729
3823
  * Integration of the Spine Runtimes into software or otherwise creating
3730
3824
  * derivative works of the Spine Runtimes is permitted under the terms and
3731
3825
  * conditions of Section 2 of the Spine Editor License Agreement:
3732
3826
  * http://esotericsoftware.com/spine-editor-license
3733
3827
  *
3734
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
3735
- * otherwise create derivative works of the Spine Runtimes (collectively,
3828
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
3829
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
3736
3830
  * "Products"), provided that each user of the Products must obtain their own
3737
3831
  * Spine Editor license and redistribution of the Products in any form must
3738
3832
  * include this license and copyright notice.
@@ -3745,8 +3839,8 @@ var CURRENT = 2;
3745
3839
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
3746
3840
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
3747
3841
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3748
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
3749
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3842
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3843
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3750
3844
  *****************************************************************************/ /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */ var AnimationStateData = /*#__PURE__*/ function() {
3751
3845
  function AnimationStateData(skeletonData) {
3752
3846
  this.animationToMixTime = {};
@@ -4198,7 +4292,7 @@ var TextureAtlasRegion = /*#__PURE__*/ function(TextureRegion) {
4198
4292
  this.copyTo(copy);
4199
4293
  copy.regionUVs = new Array(this.regionUVs.length);
4200
4294
  Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
4201
- copy.uvs = new Array(this.uvs.length);
4295
+ copy.uvs = _instanceof1(this.uvs, Float32Array) ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
4202
4296
  Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
4203
4297
  copy.triangles = new Array(this.triangles.length);
4204
4298
  Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
@@ -4862,17 +4956,17 @@ RegionAttachment.V4 = 31;
4862
4956
 
4863
4957
  /******************************************************************************
4864
4958
  * Spine Runtimes License Agreement
4865
- * Last updated July 28, 2023. Replaces all prior versions.
4959
+ * Last updated April 5, 2025. Replaces all prior versions.
4866
4960
  *
4867
- * Copyright (c) 2013-2023, Esoteric Software LLC
4961
+ * Copyright (c) 2013-2025, Esoteric Software LLC
4868
4962
  *
4869
4963
  * Integration of the Spine Runtimes into software or otherwise creating
4870
4964
  * derivative works of the Spine Runtimes is permitted under the terms and
4871
4965
  * conditions of Section 2 of the Spine Editor License Agreement:
4872
4966
  * http://esotericsoftware.com/spine-editor-license
4873
4967
  *
4874
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
4875
- * otherwise create derivative works of the Spine Runtimes (collectively,
4968
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
4969
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
4876
4970
  * "Products"), provided that each user of the Products must obtain their own
4877
4971
  * Spine Editor license and redistribution of the Products in any form must
4878
4972
  * include this license and copyright notice.
@@ -4885,8 +4979,8 @@ RegionAttachment.V4 = 31;
4885
4979
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
4886
4980
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
4887
4981
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4888
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
4889
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4982
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4983
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4890
4984
  *****************************************************************************/ /** The base class for all constraint datas. */ var ConstraintData = function ConstraintData(name, order, skinRequired) {
4891
4985
  this.name = name;
4892
4986
  this.order = order;
@@ -4894,18 +4988,46 @@ RegionAttachment.V4 = 31;
4894
4988
  }
4895
4989
  ;
4896
4990
 
4991
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4992
+ try {
4993
+ var info = gen[key](arg);
4994
+ var value = info.value;
4995
+ } catch (error) {
4996
+ reject(error);
4997
+ return;
4998
+ }
4999
+ if (info.done) resolve(value);
5000
+ else Promise.resolve(value).then(_next, _throw);
5001
+ }
5002
+ function _async_to_generator(fn) {
5003
+ return function() {
5004
+ var self = this, args = arguments;
5005
+ return new Promise(function(resolve, reject) {
5006
+ var gen = fn.apply(self, args);
5007
+ function _next(value) {
5008
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
5009
+ }
5010
+ function _throw(err) {
5011
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
5012
+ }
5013
+ _next(undefined);
5014
+ });
5015
+ };
5016
+ }
5017
+
4897
5018
  var AssetManagerBase = /*#__PURE__*/ function() {
4898
- function AssetManagerBase(textureLoader, pathPrefix, downloader) {
5019
+ function AssetManagerBase(textureLoader, pathPrefix, downloader, cache) {
4899
5020
  if (pathPrefix === void 0) pathPrefix = "";
4900
5021
  if (downloader === void 0) downloader = new Downloader();
5022
+ if (cache === void 0) cache = new AssetCache();
4901
5023
  this.pathPrefix = "";
4902
- this.assets = {};
4903
5024
  this.errors = {};
4904
5025
  this.toLoad = 0;
4905
5026
  this.loaded = 0;
4906
5027
  this.textureLoader = textureLoader;
4907
5028
  this.pathPrefix = pathPrefix;
4908
5029
  this.downloader = downloader;
5030
+ this.cache = cache;
4909
5031
  }
4910
5032
  var _proto = AssetManagerBase.prototype;
4911
5033
  _proto.start = function start(path) {
@@ -4915,7 +5037,8 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4915
5037
  _proto.success = function success(callback, path, asset) {
4916
5038
  this.toLoad--;
4917
5039
  this.loaded++;
4918
- this.assets[path] = asset;
5040
+ this.cache.assets[path] = asset;
5041
+ this.cache.assetsRefCount[path] = (this.cache.assetsRefCount[path] || 0) + 1;
4919
5042
  if (callback) callback(path, asset);
4920
5043
  };
4921
5044
  _proto.error = function error(callback, path, message) {
@@ -4947,10 +5070,16 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4947
5070
  if (success === void 0) success = function() {};
4948
5071
  if (error === void 0) error = function() {};
4949
5072
  path = this.start(path);
4950
- this.downloader.downloadBinary(path, function(data) {
4951
- _this.success(success, path, data);
4952
- }, function(status, responseText) {
4953
- _this.error(error, path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
5073
+ if (this.reuseAssets(path, success, error)) return;
5074
+ this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
5075
+ _this.downloader.downloadBinary(path, function(data) {
5076
+ _this.success(success, path, data);
5077
+ resolve(data);
5078
+ }, function(status, responseText) {
5079
+ var errorMsg = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
5080
+ _this.error(error, path, errorMsg);
5081
+ reject(errorMsg);
5082
+ });
4954
5083
  });
4955
5084
  };
4956
5085
  _proto.loadText = function loadText(path, success, error) {
@@ -4969,46 +5098,83 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4969
5098
  if (success === void 0) success = function() {};
4970
5099
  if (error === void 0) error = function() {};
4971
5100
  path = this.start(path);
4972
- this.downloader.downloadJson(path, function(data) {
4973
- _this.success(success, path, data);
4974
- }, function(status, responseText) {
4975
- _this.error(error, path, "Couldn't load JSON " + path + ": status " + status + ", " + responseText);
5101
+ if (this.reuseAssets(path, success, error)) return;
5102
+ this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
5103
+ _this.downloader.downloadJson(path, function(data) {
5104
+ _this.success(success, path, data);
5105
+ resolve(data);
5106
+ }, function(status, responseText) {
5107
+ var errorMsg = "Couldn't load JSON " + path + ": status " + status + ", " + responseText;
5108
+ _this.error(error, path, errorMsg);
5109
+ reject(errorMsg);
5110
+ });
4976
5111
  });
4977
5112
  };
4978
- _proto.loadTexture = function loadTexture(path, success, error) {
5113
+ _proto.reuseAssets = function reuseAssets(path, success, error) {
4979
5114
  var _this = this;
4980
5115
  if (success === void 0) success = function() {};
4981
5116
  if (error === void 0) error = function() {};
4982
- path = this.start(path);
4983
- var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
4984
- var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
4985
- if (isWebWorker) {
4986
- fetch(path, {
4987
- mode: "cors"
4988
- }).then(function(response) {
4989
- if (response.ok) return response.blob();
4990
- _this.error(error, path, "Couldn't load image: " + path);
4991
- return null;
4992
- }).then(function(blob) {
4993
- return blob ? createImageBitmap(blob, {
4994
- premultiplyAlpha: "none",
4995
- colorSpaceConversion: "none"
4996
- }) : null;
4997
- }).then(function(bitmap) {
4998
- if (bitmap) _this.success(success, path, _this.textureLoader(bitmap));
5117
+ var loadedStatus = this.cache.assetsLoaded[path];
5118
+ var alreadyExistsOrLoading = loadedStatus !== undefined;
5119
+ if (alreadyExistsOrLoading) {
5120
+ this.cache.assetsLoaded[path] = loadedStatus.then(function(data) {
5121
+ // necessary when user preloads an image into the cache.
5122
+ // texture loader is not avaiable in the cache, so we transform in GLTexture at first use
5123
+ data = _instanceof1(data, Image) || _instanceof1(data, ImageBitmap) ? _this.textureLoader(data) : data;
5124
+ _this.success(success, path, data);
5125
+ return data;
5126
+ }).catch(function(errorMsg) {
5127
+ return _this.error(error, path, errorMsg);
4999
5128
  });
5000
- } else {
5001
- var image = new Image();
5002
- image.crossOrigin = "anonymous";
5003
- image.onload = function() {
5004
- _this.success(success, path, _this.textureLoader(image));
5005
- };
5006
- image.onerror = function() {
5007
- _this.error(error, path, "Couldn't load image: " + path);
5008
- };
5009
- if (this.downloader.rawDataUris[path]) path = this.downloader.rawDataUris[path];
5010
- image.src = path;
5011
5129
  }
5130
+ return alreadyExistsOrLoading;
5131
+ };
5132
+ _proto.loadTexture = function loadTexture(path, success, error) {
5133
+ var _this = this;
5134
+ if (success === void 0) success = function() {};
5135
+ if (error === void 0) error = function() {};
5136
+ path = this.start(path);
5137
+ if (this.reuseAssets(path, success, error)) return;
5138
+ this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
5139
+ var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
5140
+ var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
5141
+ if (isWebWorker) {
5142
+ fetch(path, {
5143
+ mode: "cors"
5144
+ }).then(function(response) {
5145
+ if (response.ok) return response.blob();
5146
+ var errorMsg = "Couldn't load image: " + path;
5147
+ _this.error(error, path, "Couldn't load image: " + path);
5148
+ reject(errorMsg);
5149
+ }).then(function(blob) {
5150
+ return blob ? createImageBitmap(blob, {
5151
+ premultiplyAlpha: "none",
5152
+ colorSpaceConversion: "none"
5153
+ }) : null;
5154
+ }).then(function(bitmap) {
5155
+ if (bitmap) {
5156
+ var texture = _this.textureLoader(bitmap);
5157
+ _this.success(success, path, texture);
5158
+ resolve(texture);
5159
+ }
5160
+ });
5161
+ } else {
5162
+ var image = new Image();
5163
+ image.crossOrigin = "anonymous";
5164
+ image.onload = function() {
5165
+ var texture = _this.textureLoader(image);
5166
+ _this.success(success, path, texture);
5167
+ resolve(texture);
5168
+ };
5169
+ image.onerror = function() {
5170
+ var errorMsg = "Couldn't load image: " + path;
5171
+ _this.error(error, path, errorMsg);
5172
+ reject(errorMsg);
5173
+ };
5174
+ if (_this.downloader.rawDataUris[path]) path = _this.downloader.rawDataUris[path];
5175
+ image.src = path;
5176
+ }
5177
+ });
5012
5178
  };
5013
5179
  _proto.loadTextureAtlas = function loadTextureAtlas(path, success, error, fileAlias) {
5014
5180
  var _this = this;
@@ -5017,53 +5183,189 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5017
5183
  var index = path.lastIndexOf("/");
5018
5184
  var parent = index >= 0 ? path.substring(0, index + 1) : "";
5019
5185
  path = this.start(path);
5020
- this.downloader.downloadText(path, function(atlasText) {
5021
- try {
5022
- var _loop = function() {
5023
- var page = _step.value;
5024
- _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5025
- if (!abort) {
5026
- page.setTexture(texture);
5027
- if (--toLoad == 0) _this.success(success, path, atlas);
5028
- }
5029
- }, function(imagePath, message) {
5030
- if (!abort) _this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
5031
- abort = true;
5032
- });
5033
- };
5034
- var atlas = new TextureAtlas(atlasText);
5035
- var toLoad = atlas.pages.length, abort = false;
5036
- for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5037
- } catch (e) {
5038
- _this.error(error, path, "Couldn't parse texture atlas " + path + ": " + e.message);
5039
- }
5040
- }, function(status, responseText) {
5041
- _this.error(error, path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
5186
+ if (this.reuseAssets(path, success, error)) return;
5187
+ this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
5188
+ _this.downloader.downloadText(path, function(atlasText) {
5189
+ try {
5190
+ var _loop = function() {
5191
+ var page = _step.value;
5192
+ _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5193
+ if (!abort) {
5194
+ page.setTexture(texture);
5195
+ if (--toLoad == 0) {
5196
+ _this.success(success, path, atlas);
5197
+ resolve(atlas);
5198
+ }
5199
+ }
5200
+ }, function(imagePath, message) {
5201
+ if (!abort) {
5202
+ var errorMsg = "Couldn't load texture " + path + " page image: " + imagePath;
5203
+ _this.error(error, path, errorMsg);
5204
+ reject(errorMsg);
5205
+ }
5206
+ abort = true;
5207
+ });
5208
+ };
5209
+ var atlas = new TextureAtlas(atlasText);
5210
+ var toLoad = atlas.pages.length, abort = false;
5211
+ for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5212
+ } catch (e) {
5213
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5214
+ _this.error(error, path, errorMsg);
5215
+ reject(errorMsg);
5216
+ }
5217
+ }, function(status, responseText) {
5218
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5219
+ _this.error(error, path, errorMsg);
5220
+ reject(errorMsg);
5221
+ });
5042
5222
  });
5043
5223
  };
5224
+ _proto.loadTextureAtlasButNoTextures = function loadTextureAtlasButNoTextures(path, success, error, fileAlias) {
5225
+ var _this = this;
5226
+ if (success === void 0) success = function() {};
5227
+ if (error === void 0) error = function() {};
5228
+ path = this.start(path);
5229
+ if (this.reuseAssets(path, success, error)) return;
5230
+ this.cache.assetsLoaded[path] = new Promise(function(resolve, reject) {
5231
+ _this.downloader.downloadText(path, function(atlasText) {
5232
+ try {
5233
+ var atlas = new TextureAtlas(atlasText);
5234
+ _this.success(success, path, atlas);
5235
+ resolve(atlas);
5236
+ } catch (e) {
5237
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5238
+ _this.error(error, path, errorMsg);
5239
+ reject(errorMsg);
5240
+ }
5241
+ }, function(status, responseText) {
5242
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5243
+ _this.error(error, path, errorMsg);
5244
+ reject(errorMsg);
5245
+ });
5246
+ });
5247
+ };
5248
+ // Promisified versions of load function
5249
+ _proto.loadBinaryAsync = function loadBinaryAsync(path) {
5250
+ return _async_to_generator(function() {
5251
+ var _this;
5252
+ return __generator(this, function(_state) {
5253
+ _this = this;
5254
+ return [
5255
+ 2,
5256
+ new Promise(function(resolve, reject) {
5257
+ _this.loadBinary(path, function(_, binary) {
5258
+ return resolve(binary);
5259
+ }, function(_, message) {
5260
+ return reject(message);
5261
+ });
5262
+ })
5263
+ ];
5264
+ });
5265
+ }).call(this);
5266
+ };
5267
+ _proto.loadJsonAsync = function loadJsonAsync(path) {
5268
+ return _async_to_generator(function() {
5269
+ var _this;
5270
+ return __generator(this, function(_state) {
5271
+ _this = this;
5272
+ return [
5273
+ 2,
5274
+ new Promise(function(resolve, reject) {
5275
+ _this.loadJson(path, function(_, object) {
5276
+ return resolve(object);
5277
+ }, function(_, message) {
5278
+ return reject(message);
5279
+ });
5280
+ })
5281
+ ];
5282
+ });
5283
+ }).call(this);
5284
+ };
5285
+ _proto.loadTextureAsync = function loadTextureAsync(path) {
5286
+ return _async_to_generator(function() {
5287
+ var _this;
5288
+ return __generator(this, function(_state) {
5289
+ _this = this;
5290
+ return [
5291
+ 2,
5292
+ new Promise(function(resolve, reject) {
5293
+ _this.loadTexture(path, function(_, texture) {
5294
+ return resolve(texture);
5295
+ }, function(_, message) {
5296
+ return reject(message);
5297
+ });
5298
+ })
5299
+ ];
5300
+ });
5301
+ }).call(this);
5302
+ };
5303
+ _proto.loadTextureAtlasAsync = function loadTextureAtlasAsync(path) {
5304
+ return _async_to_generator(function() {
5305
+ var _this;
5306
+ return __generator(this, function(_state) {
5307
+ _this = this;
5308
+ return [
5309
+ 2,
5310
+ new Promise(function(resolve, reject) {
5311
+ _this.loadTextureAtlas(path, function(_, atlas) {
5312
+ return resolve(atlas);
5313
+ }, function(_, message) {
5314
+ return reject(message);
5315
+ });
5316
+ })
5317
+ ];
5318
+ });
5319
+ }).call(this);
5320
+ };
5321
+ _proto.loadTextureAtlasButNoTexturesAsync = function loadTextureAtlasButNoTexturesAsync(path) {
5322
+ return _async_to_generator(function() {
5323
+ var _this;
5324
+ return __generator(this, function(_state) {
5325
+ _this = this;
5326
+ return [
5327
+ 2,
5328
+ new Promise(function(resolve, reject) {
5329
+ _this.loadTextureAtlasButNoTextures(path, function(_, atlas) {
5330
+ return resolve(atlas);
5331
+ }, function(_, message) {
5332
+ return reject(message);
5333
+ });
5334
+ })
5335
+ ];
5336
+ });
5337
+ }).call(this);
5338
+ };
5339
+ _proto.setCache = function setCache(cache) {
5340
+ this.cache = cache;
5341
+ };
5044
5342
  _proto.get = function get(path) {
5045
- return this.assets[this.pathPrefix + path];
5343
+ return this.cache.assets[this.pathPrefix + path];
5046
5344
  };
5047
5345
  _proto.require = function require(path) {
5048
5346
  path = this.pathPrefix + path;
5049
- var asset = this.assets[path];
5347
+ var asset = this.cache.assets[path];
5050
5348
  if (asset) return asset;
5051
5349
  var error = this.errors[path];
5052
5350
  throw Error("Asset not found: " + path + (error ? "\n" + error : ""));
5053
5351
  };
5054
5352
  _proto.remove = function remove(path) {
5055
5353
  path = this.pathPrefix + path;
5056
- var asset = this.assets[path];
5354
+ var asset = this.cache.assets[path];
5057
5355
  if (asset.dispose) asset.dispose();
5058
- delete this.assets[path];
5356
+ delete this.cache.assets[path];
5357
+ delete this.cache.assetsRefCount[path];
5358
+ delete this.cache.assetsLoaded[path];
5059
5359
  return asset;
5060
5360
  };
5061
5361
  _proto.removeAll = function removeAll() {
5062
- for(var key in this.assets){
5063
- var asset = this.assets[key];
5362
+ for(var path in this.cache.assets){
5363
+ var asset = this.cache.assets[path];
5064
5364
  if (asset.dispose) asset.dispose();
5065
5365
  }
5066
- this.assets = {};
5366
+ this.cache.assets = {};
5367
+ this.cache.assetsLoaded = {};
5368
+ this.cache.assetsRefCount = {};
5067
5369
  };
5068
5370
  _proto.isLoadingComplete = function isLoadingComplete() {
5069
5371
  return this.toLoad == 0;
@@ -5077,6 +5379,12 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5077
5379
  _proto.dispose = function dispose() {
5078
5380
  this.removeAll();
5079
5381
  };
5382
+ // dispose asset only if it's not used by others
5383
+ _proto.disposeAsset = function disposeAsset(path) {
5384
+ if (--this.cache.assetsRefCount[path] === 0) {
5385
+ this.remove(path);
5386
+ }
5387
+ };
5080
5388
  _proto.hasErrors = function hasErrors() {
5081
5389
  return Object.keys(this.errors).length > 0;
5082
5390
  };
@@ -5085,6 +5393,44 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5085
5393
  };
5086
5394
  return AssetManagerBase;
5087
5395
  }();
5396
+ var AssetCache = /*#__PURE__*/ function() {
5397
+ function AssetCache() {
5398
+ this.assets = {};
5399
+ this.assetsRefCount = {};
5400
+ this.assetsLoaded = {};
5401
+ }
5402
+ var _proto = AssetCache.prototype;
5403
+ _proto.addAsset = function addAsset(path, asset) {
5404
+ return _async_to_generator(function() {
5405
+ var _;
5406
+ return __generator(this, function(_state) {
5407
+ switch(_state.label){
5408
+ case 0:
5409
+ this.assetsLoaded[path] = Promise.resolve(asset);
5410
+ _ = this.assets;
5411
+ return [
5412
+ 4,
5413
+ asset
5414
+ ];
5415
+ case 1:
5416
+ _[path] = _state.sent();
5417
+ return [
5418
+ 2
5419
+ ];
5420
+ }
5421
+ });
5422
+ }).call(this);
5423
+ };
5424
+ AssetCache.getCache = function getCache(id) {
5425
+ var cache = AssetCache.AVAILABLE_CACHES.get(id);
5426
+ if (cache) return cache;
5427
+ var newCache = new AssetCache();
5428
+ AssetCache.AVAILABLE_CACHES.set(id, newCache);
5429
+ return newCache;
5430
+ };
5431
+ return AssetCache;
5432
+ }();
5433
+ AssetCache.AVAILABLE_CACHES = new Map();
5088
5434
  var Downloader = /*#__PURE__*/ function() {
5089
5435
  function Downloader() {
5090
5436
  this.callbacks = {};
@@ -5124,10 +5470,11 @@ var Downloader = /*#__PURE__*/ function() {
5124
5470
  _proto.downloadText = function downloadText(url, success, error) {
5125
5471
  var _this = this;
5126
5472
  if (this.start(url, success, error)) return;
5127
- if (this.rawDataUris[url]) {
5473
+ var rawDataUri = this.rawDataUris[url];
5474
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5475
+ if (rawDataUri && !rawDataUri.includes(".")) {
5128
5476
  try {
5129
- var dataUri = this.rawDataUris[url];
5130
- this.finish(url, 200, this.dataUriToString(dataUri));
5477
+ this.finish(url, 200, this.dataUriToString(rawDataUri));
5131
5478
  } catch (e) {
5132
5479
  this.finish(url, 400, JSON.stringify(e));
5133
5480
  }
@@ -5135,7 +5482,7 @@ var Downloader = /*#__PURE__*/ function() {
5135
5482
  }
5136
5483
  var request = new XMLHttpRequest();
5137
5484
  request.overrideMimeType("text/html");
5138
- request.open("GET", url, true);
5485
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5139
5486
  var done = function() {
5140
5487
  _this.finish(url, request.status, request.responseText);
5141
5488
  };
@@ -5151,17 +5498,18 @@ var Downloader = /*#__PURE__*/ function() {
5151
5498
  _proto.downloadBinary = function downloadBinary(url, success, error) {
5152
5499
  var _this = this;
5153
5500
  if (this.start(url, success, error)) return;
5154
- if (this.rawDataUris[url]) {
5501
+ var rawDataUri = this.rawDataUris[url];
5502
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5503
+ if (rawDataUri && !rawDataUri.includes(".")) {
5155
5504
  try {
5156
- var dataUri = this.rawDataUris[url];
5157
- this.finish(url, 200, this.dataUriToUint8Array(dataUri));
5505
+ this.finish(url, 200, this.dataUriToUint8Array(rawDataUri));
5158
5506
  } catch (e) {
5159
5507
  this.finish(url, 400, JSON.stringify(e));
5160
5508
  }
5161
5509
  return;
5162
5510
  }
5163
5511
  var request = new XMLHttpRequest();
5164
- request.open("GET", url, true);
5512
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5165
5513
  request.responseType = "arraybuffer";
5166
5514
  var onerror = function() {
5167
5515
  _this.finish(url, request.status, request.response);
@@ -5199,17 +5547,17 @@ var Downloader = /*#__PURE__*/ function() {
5199
5547
 
5200
5548
  /******************************************************************************
5201
5549
  * Spine Runtimes License Agreement
5202
- * Last updated July 28, 2023. Replaces all prior versions.
5550
+ * Last updated April 5, 2025. Replaces all prior versions.
5203
5551
  *
5204
- * Copyright (c) 2013-2023, Esoteric Software LLC
5552
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5205
5553
  *
5206
5554
  * Integration of the Spine Runtimes into software or otherwise creating
5207
5555
  * derivative works of the Spine Runtimes is permitted under the terms and
5208
5556
  * conditions of Section 2 of the Spine Editor License Agreement:
5209
5557
  * http://esotericsoftware.com/spine-editor-license
5210
5558
  *
5211
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5212
- * otherwise create derivative works of the Spine Runtimes (collectively,
5559
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5560
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5213
5561
  * "Products"), provided that each user of the Products must obtain their own
5214
5562
  * Spine Editor license and redistribution of the Products in any form must
5215
5563
  * include this license and copyright notice.
@@ -5222,8 +5570,8 @@ var Downloader = /*#__PURE__*/ function() {
5222
5570
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5223
5571
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5224
5572
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5225
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5226
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5573
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5574
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5227
5575
  *****************************************************************************/ /** Stores the current pose values for an {@link Event}.
5228
5576
  *
5229
5577
  * See Timeline {@link Timeline#apply()},
@@ -5243,17 +5591,17 @@ var Downloader = /*#__PURE__*/ function() {
5243
5591
 
5244
5592
  /******************************************************************************
5245
5593
  * Spine Runtimes License Agreement
5246
- * Last updated July 28, 2023. Replaces all prior versions.
5594
+ * Last updated April 5, 2025. Replaces all prior versions.
5247
5595
  *
5248
- * Copyright (c) 2013-2023, Esoteric Software LLC
5596
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5249
5597
  *
5250
5598
  * Integration of the Spine Runtimes into software or otherwise creating
5251
5599
  * derivative works of the Spine Runtimes is permitted under the terms and
5252
5600
  * conditions of Section 2 of the Spine Editor License Agreement:
5253
5601
  * http://esotericsoftware.com/spine-editor-license
5254
5602
  *
5255
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5256
- * otherwise create derivative works of the Spine Runtimes (collectively,
5603
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5604
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5257
5605
  * "Products"), provided that each user of the Products must obtain their own
5258
5606
  * Spine Editor license and redistribution of the Products in any form must
5259
5607
  * include this license and copyright notice.
@@ -5266,8 +5614,8 @@ var Downloader = /*#__PURE__*/ function() {
5266
5614
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5267
5615
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5268
5616
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5269
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5270
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5617
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5618
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5271
5619
  *****************************************************************************/ /** Stores the setup pose values for an {@link Event}.
5272
5620
  *
5273
5621
  * See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */ var EventData = function EventData(name) {
@@ -6127,7 +6475,7 @@ PathConstraint.epsilon = 0.00001;
6127
6475
  }
6128
6476
  if (a >= t) {
6129
6477
  d = Math.pow(this.damping, 60 * t);
6130
- var m = this.massInverse * t, e = this.strength, w = this.wind * f, g = (Skeleton.yDown ? -this.gravity : this.gravity) * f;
6478
+ var m = this.massInverse * t, e = this.strength, w = this.wind * f * skeleton.scaleX, g = this.gravity * f * skeleton.scaleY;
6131
6479
  do {
6132
6480
  if (x) {
6133
6481
  this.xVelocity += (w - this.xOffset * e) * m;
@@ -6969,10 +7317,10 @@ PathConstraint.epsilon = 0.00001;
6969
7317
  })) != null ? _this_physicsConstraints_find : null;
6970
7318
  };
6971
7319
  /** Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose as `{ x: number, y: number, width: number, height: number }`.
6972
- * Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */ _proto.getBoundsRect = function getBoundsRect() {
7320
+ * Note that this method will create temporary objects which can add to garbage collection pressure. Use `getBounds()` if garbage collection is a concern. */ _proto.getBoundsRect = function getBoundsRect(clipper) {
6973
7321
  var offset = new Vector2();
6974
7322
  var size = new Vector2();
6975
- this.getBounds(offset, size);
7323
+ this.getBounds(offset, size, undefined, clipper);
6976
7324
  return {
6977
7325
  x: offset.x,
6978
7326
  y: offset.y,
@@ -7101,17 +7449,17 @@ Skeleton.yDown = false;
7101
7449
 
7102
7450
  /******************************************************************************
7103
7451
  * Spine Runtimes License Agreement
7104
- * Last updated July 28, 2023. Replaces all prior versions.
7452
+ * Last updated April 5, 2025. Replaces all prior versions.
7105
7453
  *
7106
- * Copyright (c) 2013-2023, Esoteric Software LLC
7454
+ * Copyright (c) 2013-2025, Esoteric Software LLC
7107
7455
  *
7108
7456
  * Integration of the Spine Runtimes into software or otherwise creating
7109
7457
  * derivative works of the Spine Runtimes is permitted under the terms and
7110
7458
  * conditions of Section 2 of the Spine Editor License Agreement:
7111
7459
  * http://esotericsoftware.com/spine-editor-license
7112
7460
  *
7113
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
7114
- * otherwise create derivative works of the Spine Runtimes (collectively,
7461
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
7462
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
7115
7463
  * "Products"), provided that each user of the Products must obtain their own
7116
7464
  * Spine Editor license and redistribution of the Products in any form must
7117
7465
  * include this license and copyright notice.
@@ -7124,18 +7472,16 @@ Skeleton.yDown = false;
7124
7472
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
7125
7473
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
7126
7474
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7127
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
7128
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7475
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
7476
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7129
7477
  *****************************************************************************/ /** Stores the setup pose and all of the stateless data for a skeleton.
7130
7478
  *
7131
7479
  * See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes
7132
7480
  * Guide. */ var SkeletonData = /*#__PURE__*/ function() {
7133
7481
  function SkeletonData() {
7134
7482
  /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ this.name = null;
7135
- /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array() // Ordered parents first.
7136
- ;
7137
- /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array() // Setup pose draw order.
7138
- ;
7483
+ /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array(); // Ordered parents first.
7484
+ /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array(); // Setup pose draw order.
7139
7485
  this.skins = new Array();
7140
7486
  /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
7141
7487
  *
@@ -7278,8 +7624,7 @@ Skeleton.yDown = false;
7278
7624
  this.attachments = new Array();
7279
7625
  this.bones = Array();
7280
7626
  this.constraints = new Array();
7281
- /** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */ this.color = new Color(0.99607843, 0.61960787, 0.30980393, 1) // fe9e4fff
7282
- ;
7627
+ /** The color of the skin as it was in Spine, or a default color if nonessential data was not exported. */ this.color = new Color(0.99607843, 0.61960787, 0.30980393, 1); // fe9e4fff
7283
7628
  if (!name) throw new Error("name cannot be null.");
7284
7629
  this.name = name;
7285
7630
  }
@@ -10437,17 +10782,17 @@ function getValue(map, property, defaultValue) {
10437
10782
 
10438
10783
  /******************************************************************************
10439
10784
  * Spine Runtimes License Agreement
10440
- * Last updated July 28, 2023. Replaces all prior versions.
10785
+ * Last updated April 5, 2025. Replaces all prior versions.
10441
10786
  *
10442
- * Copyright (c) 2013-2023, Esoteric Software LLC
10787
+ * Copyright (c) 2013-2025, Esoteric Software LLC
10443
10788
  *
10444
10789
  * Integration of the Spine Runtimes into software or otherwise creating
10445
10790
  * derivative works of the Spine Runtimes is permitted under the terms and
10446
10791
  * conditions of Section 2 of the Spine Editor License Agreement:
10447
10792
  * http://esotericsoftware.com/spine-editor-license
10448
10793
  *
10449
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
10450
- * otherwise create derivative works of the Spine Runtimes (collectively,
10794
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
10795
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
10451
10796
  * "Products"), provided that each user of the Products must obtain their own
10452
10797
  * Spine Editor license and redistribution of the Products in any form must
10453
10798
  * include this license and copyright notice.
@@ -10460,8 +10805,8 @@ function getValue(map, property, defaultValue) {
10460
10805
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
10461
10806
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
10462
10807
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10463
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
10464
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10808
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
10809
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10465
10810
  *****************************************************************************/ (function() {
10466
10811
  if (typeof Math.fround === "undefined") {
10467
10812
  Math.fround = function(array) {
@@ -10610,55 +10955,6 @@ function getValue(map, property, defaultValue) {
10610
10955
  return LoaderUtils;
10611
10956
  }();
10612
10957
 
10613
- var SourceAlpha = engine.BlendFactor.SourceAlpha, One = engine.BlendFactor.One, DestinationColor = engine.BlendFactor.DestinationColor, Zero = engine.BlendFactor.Zero, OneMinusSourceColor = engine.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = engine.BlendFactor.OneMinusSourceAlpha;
10614
- var Add = engine.BlendOperation.Add;
10615
- function setBlendMode(material, blendMode, premultipliedAlpha) {
10616
- var target = material.renderState.blendState.targetBlendState;
10617
- switch(blendMode){
10618
- case exports.BlendMode.Additive:
10619
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10620
- target.destinationColorBlendFactor = One;
10621
- target.sourceAlphaBlendFactor = One;
10622
- target.destinationAlphaBlendFactor = One;
10623
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10624
- break;
10625
- case exports.BlendMode.Multiply:
10626
- target.sourceColorBlendFactor = DestinationColor;
10627
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10628
- target.sourceAlphaBlendFactor = One;
10629
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10630
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10631
- break;
10632
- case exports.BlendMode.Screen:
10633
- target.sourceColorBlendFactor = One;
10634
- target.destinationColorBlendFactor = OneMinusSourceColor;
10635
- target.sourceAlphaBlendFactor = One;
10636
- target.destinationAlphaBlendFactor = OneMinusSourceColor;
10637
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10638
- break;
10639
- default:
10640
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10641
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10642
- target.sourceAlphaBlendFactor = One;
10643
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10644
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10645
- break;
10646
- }
10647
- }
10648
- function getBlendMode(material) {
10649
- var target = material.renderState.blendState.targetBlendState;
10650
- if (target.sourceColorBlendFactor === SourceAlpha && target.destinationColorBlendFactor === One && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === One && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10651
- return exports.BlendMode.Additive;
10652
- }
10653
- if (target.sourceColorBlendFactor === DestinationColor && target.destinationColorBlendFactor === Zero && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === Zero && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10654
- return exports.BlendMode.Multiply;
10655
- }
10656
- if (target.sourceColorBlendFactor === One && target.destinationColorBlendFactor === OneMinusSourceColor && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === OneMinusSourceColor && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10657
- return exports.BlendMode.Screen;
10658
- }
10659
- return exports.BlendMode.Normal;
10660
- }
10661
-
10662
10958
  var ClearablePool = /*#__PURE__*/ function() {
10663
10959
  function ClearablePool(type) {
10664
10960
  this._usedElementCount = 0;
@@ -10719,11 +11015,11 @@ var SubRenderItem = function SubRenderItem() {
10719
11015
  }
10720
11016
  var _proto = SpineGenerator.prototype;
10721
11017
  _proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
10722
- var _indices = renderer._indices, _vertices = renderer._vertices, _localBounds = renderer._localBounds, _vertexCount = renderer._vertexCount, _subPrimitives = renderer._subPrimitives, engine = renderer.engine, zSpacing = renderer.zSpacing, premultipliedAlpha = renderer.premultipliedAlpha;
11018
+ var _indices = renderer._indices, _vertices = renderer._vertices, _localBounds = renderer._localBounds, _vertexCount = renderer._vertexCount, _subPrimitives = renderer._subPrimitives, zSpacing = renderer.zSpacing, premultipliedAlpha = renderer.premultipliedAlpha, tintBlack = renderer.tintBlack;
10723
11019
  _localBounds.min.set(Infinity, Infinity, Infinity);
10724
11020
  _localBounds.max.set(-Infinity, -Infinity, -Infinity);
10725
11021
  var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
10726
- var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, VERTEX_SIZE = SpineGenerator.VERTEX_SIZE;
11022
+ var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, vertexStrideWithTint = SpineGenerator.vertexStrideWithTint, vertexStrideWithoutTint = SpineGenerator.vertexStrideWithoutTint;
10727
11023
  _subRenderItems.length = 0;
10728
11024
  subRenderItemPool.clear();
10729
11025
  var triangles;
@@ -10753,13 +11049,28 @@ var SubRenderItem = function SubRenderItem() {
10753
11049
  var isClipping = _clipper.isClipping();
10754
11050
  var numFloats = 0;
10755
11051
  var attachmentColor = null;
10756
- var vertexSize = isClipping ? 2 : VERTEX_SIZE;
11052
+ // This vertexSize will be passed to spine-core's computeWorldVertices function.
11053
+ //
11054
+ // Expected format by computeWorldVertices:
11055
+ // - Without tintBlack: [x, y, u, v, r, g, b, a] = 8 components
11056
+ // - With tintBlack: [x, y, u, v, r, g, b, a, dr, dg, db, da] = 12 components
11057
+ //
11058
+ // Our actual vertex buffer format:
11059
+ // - vertexStrideWithoutTint: [x, y, z, u, v, r, g, b, a] = 9 components
11060
+ // - vertexStrideWithTint: [x, y, z, u, v, r, g, b, a, dr, dg, db] = 12 components
11061
+ // (Note: we optimized 'da' as uniform instead of buffer attribute)
11062
+ //
11063
+ // Calculation:
11064
+ // - Without tintBlack: 9 - 1 (remove z) = 8 ✓
11065
+ // - With tintBlack: 12 - 1 (remove z) + 1 (add back da) = 12 ✓
11066
+ var vertexSize = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint - 1;
11067
+ var clippedVertexSize = isClipping ? 2 : vertexSize;
10757
11068
  switch(attachment.constructor){
10758
11069
  case RegionAttachment:
10759
11070
  var regionAttachment = attachment;
10760
11071
  attachmentColor = regionAttachment.color;
10761
- numFloats = vertexSize * 4;
10762
- regionAttachment.computeWorldVertices(slot, tempVerts, 0, vertexSize);
11072
+ numFloats = clippedVertexSize << 2;
11073
+ regionAttachment.computeWorldVertices(slot, tempVerts, 0, clippedVertexSize);
10763
11074
  triangles = SpineGenerator.QUAD_TRIANGLES;
10764
11075
  uvs = regionAttachment.uvs;
10765
11076
  texture = regionAttachment.region.texture;
@@ -10767,11 +11078,11 @@ var SubRenderItem = function SubRenderItem() {
10767
11078
  case MeshAttachment:
10768
11079
  var meshAttachment = attachment;
10769
11080
  attachmentColor = meshAttachment.color;
10770
- numFloats = (meshAttachment.worldVerticesLength >> 1) * vertexSize;
11081
+ numFloats = (meshAttachment.worldVerticesLength >> 1) * clippedVertexSize;
10771
11082
  if (numFloats > _vertices.length) {
10772
11083
  SpineGenerator.tempVerts = new Array(numFloats);
10773
11084
  }
10774
- meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, vertexSize);
11085
+ meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, clippedVertexSize);
10775
11086
  triangles = meshAttachment.triangles;
10776
11087
  uvs = meshAttachment.uvs;
10777
11088
  texture = meshAttachment.region.texture;
@@ -10803,8 +11114,21 @@ var SubRenderItem = function SubRenderItem() {
10803
11114
  finalColor.g *= finalAlpha;
10804
11115
  finalColor.b *= finalAlpha;
10805
11116
  }
11117
+ var darkColor = SpineGenerator.tempDark;
11118
+ var slotDarkColor = slot.darkColor;
11119
+ if (!slotDarkColor) {
11120
+ darkColor.set(0, 0, 0, 1);
11121
+ } else {
11122
+ if (premultipliedAlpha) {
11123
+ darkColor.r = slotDarkColor.r * finalAlpha;
11124
+ darkColor.g = slotDarkColor.g * finalAlpha;
11125
+ darkColor.b = slotDarkColor.b * finalAlpha;
11126
+ } else {
11127
+ darkColor.setFromColor(slotDarkColor);
11128
+ }
11129
+ }
10806
11130
  if (isClipping) {
10807
- _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, SpineGenerator.tempDark, false);
11131
+ _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, darkColor, tintBlack);
10808
11132
  finalVertices = _clipper.clippedVertices;
10809
11133
  finalVerticesLength = finalVertices.length;
10810
11134
  finalIndices = _clipper.clippedTriangles;
@@ -10818,6 +11142,12 @@ var SubRenderItem = function SubRenderItem() {
10818
11142
  tempVerts[v + 3] = a;
10819
11143
  tempVerts[v + 4] = uvs[u];
10820
11144
  tempVerts[v + 5] = uvs[u + 1];
11145
+ if (tintBlack) {
11146
+ tempVerts[v + 6] = darkColor.r;
11147
+ tempVerts[v + 7] = darkColor.g;
11148
+ tempVerts[v + 8] = darkColor.b;
11149
+ tempVerts[v + 9] = darkColor.a;
11150
+ }
10821
11151
  }
10822
11152
  finalVertices = tempVerts;
10823
11153
  finalVerticesLength = numFloats;
@@ -10828,7 +11158,8 @@ var SubRenderItem = function SubRenderItem() {
10828
11158
  _clipper.clipEndWithSlot(slot);
10829
11159
  continue;
10830
11160
  }
10831
- var indexStart = verticesLength / SpineGenerator.VERTEX_STRIDE;
11161
+ var stride = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint;
11162
+ var indexStart = verticesLength / stride;
10832
11163
  var i = verticesLength;
10833
11164
  var j = 0;
10834
11165
  for(; j < finalVerticesLength;){
@@ -10837,12 +11168,18 @@ var SubRenderItem = function SubRenderItem() {
10837
11168
  _vertices[i++] = x;
10838
11169
  _vertices[i++] = y;
10839
11170
  _vertices[i++] = z;
10840
- _vertices[i++] = finalVertices[j++];
10841
- _vertices[i++] = finalVertices[j++];
10842
- _vertices[i++] = finalVertices[j++];
10843
- _vertices[i++] = finalVertices[j++];
10844
- _vertices[i++] = finalVertices[j++];
10845
- _vertices[i++] = finalVertices[j++];
11171
+ _vertices[i++] = finalVertices[j++]; // u
11172
+ _vertices[i++] = finalVertices[j++]; // v
11173
+ _vertices[i++] = finalVertices[j++]; // r
11174
+ _vertices[i++] = finalVertices[j++]; // g
11175
+ _vertices[i++] = finalVertices[j++]; // b
11176
+ _vertices[i++] = finalVertices[j++]; // a
11177
+ if (tintBlack) {
11178
+ _vertices[i++] = finalVertices[j++]; // darkR
11179
+ _vertices[i++] = finalVertices[j++]; // darkG
11180
+ _vertices[i++] = finalVertices[j++]; // darkB
11181
+ j++; // darkA
11182
+ }
10846
11183
  this._expandBounds(x, y, z, _localBounds);
10847
11184
  }
10848
11185
  verticesLength = i;
@@ -10899,22 +11236,17 @@ var SubRenderItem = function SubRenderItem() {
10899
11236
  subPrimitivePool.return(item);
10900
11237
  }
10901
11238
  renderer._clearSubPrimitives();
10902
- var materialCache = SpineAnimationRenderer._materialCache;
10903
11239
  for(var i2 = 0, l = curLen; i2 < l; ++i2){
10904
11240
  var item1 = _subRenderItems[i2];
10905
11241
  var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
10906
11242
  renderer._addSubPrimitive(item1.subPrimitive);
10907
11243
  var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
10908
- var key = subTexture.instanceId + "_" + blendMode + "_" + premultipliedAlpha;
10909
- var material = materialCache.get(key);
10910
- if (!material) {
10911
- material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
10912
- materialCache.set(key, material);
10913
- }
11244
+ var material = renderer._getMaterial(subTexture, blendMode);
10914
11245
  renderer.setMaterial(i2, material);
10915
11246
  }
10916
- if (indicesLength > _vertexCount) {
11247
+ if (indicesLength > _vertexCount || renderer._needResizeBuffer) {
10917
11248
  renderer._createAndBindBuffer(indicesLength);
11249
+ renderer._needResizeBuffer = false;
10918
11250
  this.buildPrimitive(skeleton, renderer);
10919
11251
  return;
10920
11252
  }
@@ -10929,12 +11261,6 @@ var SubRenderItem = function SubRenderItem() {
10929
11261
  _proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
10930
11262
  this._separateSlotTextureMap.set(slotName, texture);
10931
11263
  };
10932
- _proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
10933
- var material = SpineAnimationRenderer._getDefaultMaterial(engine);
10934
- material.shaderData.setTexture("material_SpineTexture", texture);
10935
- setBlendMode(material, blendMode, premultipliedAlpha);
10936
- return material;
10937
- };
10938
11264
  _proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
10939
11265
  var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
10940
11266
  var origin = subPrimitives[primitiveIndex];
@@ -10959,8 +11285,8 @@ var SubRenderItem = function SubRenderItem() {
10959
11285
  };
10960
11286
  return SpineGenerator;
10961
11287
  }();
10962
- SpineGenerator.VERTEX_SIZE = 8;
10963
- SpineGenerator.VERTEX_STRIDE = 9;
11288
+ SpineGenerator.vertexStrideWithoutTint = 9;
11289
+ SpineGenerator.vertexStrideWithTint = 12;
10964
11290
  SpineGenerator.tempDark = new Color();
10965
11291
  SpineGenerator.tempColor = new Color();
10966
11292
  SpineGenerator.tempVerts = new Array(8);
@@ -10975,25 +11301,92 @@ SpineGenerator.QUAD_TRIANGLES = [
10975
11301
  SpineGenerator.subPrimitivePool = new ReturnablePool(engine.SubPrimitive);
10976
11302
  SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
10977
11303
 
11304
+ var SourceAlpha = engine.BlendFactor.SourceAlpha, One = engine.BlendFactor.One, DestinationColor = engine.BlendFactor.DestinationColor, OneMinusSourceColor = engine.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = engine.BlendFactor.OneMinusSourceAlpha;
11305
+ var Add = engine.BlendOperation.Add;
10978
11306
  var SpineMaterial = /*#__PURE__*/ function(Material) {
10979
11307
  _inherits(SpineMaterial, Material);
10980
11308
  function SpineMaterial(engine$1) {
10981
11309
  var _this;
10982
11310
  var shader = engine.Shader.find("galacean-spine-shader") || engine.Shader.create("galacean-spine-shader", SpineMaterial._spineVS, SpineMaterial._spineFS);
10983
- _this = Material.call(this, engine$1, shader) || this;
11311
+ _this = Material.call(this, engine$1, shader) || this, _this._blendMode = exports.BlendMode.Normal;
10984
11312
  var renderState = _this.renderState;
10985
11313
  var target = renderState.blendState.targetBlendState;
10986
11314
  target.enabled = true;
10987
- setBlendMode(_this, exports.BlendMode.Normal, false);
11315
+ _this._setBlendMode(exports.BlendMode.Normal, false);
10988
11316
  renderState.depthState.writeEnabled = false;
10989
11317
  renderState.rasterState.cullMode = engine.CullMode.Off;
10990
11318
  renderState.renderQueueType = engine.RenderQueueType.Transparent;
10991
11319
  return _this;
10992
11320
  }
11321
+ var _proto = SpineMaterial.prototype;
11322
+ /**
11323
+ * @internal
11324
+ */ _proto._setTintBlack = function _setTintBlack(enabled) {
11325
+ if (enabled) {
11326
+ this.shaderData.enableMacro("RENDERER_TINT_BLACK");
11327
+ } else {
11328
+ this.shaderData.disableMacro("RENDERER_TINT_BLACK");
11329
+ }
11330
+ };
11331
+ /**
11332
+ * @internal
11333
+ */ _proto._setPremultipliedAlpha = function _setPremultipliedAlpha(enabled) {
11334
+ if (enabled) {
11335
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 1);
11336
+ } else {
11337
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 0);
11338
+ }
11339
+ };
11340
+ /**
11341
+ * @internal
11342
+ */ _proto._setTexture = function _setTexture(value) {
11343
+ this.shaderData.setTexture("material_SpineTexture", value);
11344
+ };
11345
+ /**
11346
+ * @internal
11347
+ */ _proto._setBlendMode = function _setBlendMode(blendMode, premultipliedAlpha) {
11348
+ var target = this.renderState.blendState.targetBlendState;
11349
+ this._blendMode = blendMode;
11350
+ switch(blendMode){
11351
+ case exports.BlendMode.Additive:
11352
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11353
+ target.destinationColorBlendFactor = One;
11354
+ target.sourceAlphaBlendFactor = One;
11355
+ target.destinationAlphaBlendFactor = One;
11356
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11357
+ break;
11358
+ case exports.BlendMode.Multiply:
11359
+ target.sourceColorBlendFactor = DestinationColor;
11360
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11361
+ target.sourceAlphaBlendFactor = One;
11362
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11363
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11364
+ break;
11365
+ case exports.BlendMode.Screen:
11366
+ target.sourceColorBlendFactor = One;
11367
+ target.destinationColorBlendFactor = OneMinusSourceColor;
11368
+ target.sourceAlphaBlendFactor = One;
11369
+ target.destinationAlphaBlendFactor = OneMinusSourceColor;
11370
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11371
+ break;
11372
+ default:
11373
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11374
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11375
+ target.sourceAlphaBlendFactor = One;
11376
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11377
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11378
+ break;
11379
+ }
11380
+ };
11381
+ /**
11382
+ * @internal
11383
+ */ _proto._getBlendMode = function _getBlendMode() {
11384
+ return this._blendMode;
11385
+ };
10993
11386
  return SpineMaterial;
10994
11387
  }(engine.Material);
10995
- SpineMaterial._spineVS = "\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 COLOR_0;\n \n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n }\n ";
10996
- SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n vec4 baseColor = texture2DSRGB(material_SpineTexture, v_uv);\n gl_FragColor = baseColor * sRGBToLinear(v_color);\n }\n ";
11388
+ SpineMaterial._spineVS = "\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 LIGHT_COLOR;\n \n varying vec2 v_uv;\n varying vec4 v_lightColor;\n\n #ifdef RENDERER_TINT_BLACK\n attribute vec3 DARK_COLOR;\n varying vec3 v_darkColor;\n #endif\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_lightColor = LIGHT_COLOR;\n\n #ifdef RENDERER_TINT_BLACK\n v_darkColor = DARK_COLOR;\n #endif\n }\n ";
11389
+ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D material_SpineTexture;\n uniform float renderer_PremultipliedAlpha;\n\n varying vec2 v_uv;\n varying vec4 v_lightColor;\n\n #ifdef RENDERER_TINT_BLACK\n varying vec3 v_darkColor;\n #endif\n \n void main()\n {\n vec4 texColor = texture2D(material_SpineTexture, v_uv);\n vec4 lightColor = sRGBToLinear(v_lightColor);\n #ifdef RENDERER_TINT_BLACK\n vec4 darkColor = sRGBToLinear(vec4(v_darkColor, 1.0));\n vec3 dark_premult = (texColor.a - texColor.rgb) * darkColor.rgb;\n vec3 dark_nonpremult = (1.0 - texColor.rgb) * darkColor.rgb;\n vec3 dark = mix(dark_nonpremult, dark_premult, renderer_PremultipliedAlpha);\n vec3 light = texColor.rgb * lightColor.rgb;\n gl_FragColor.rgb = dark + light;\n gl_FragColor.a = texColor.a * lightColor.a;\n #else\n gl_FragColor = texColor * lightColor;\n #endif\n }\n ";
10997
11390
 
10998
11391
  /**
10999
11392
  * Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
@@ -11008,15 +11401,17 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11008
11401
  * When enabled, vertex color values are multiplied by the alpha channel.
11009
11402
  * @remarks
11010
11403
  If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
11011
- */ _this.premultipliedAlpha = false, /**
11404
+ */ _this.premultipliedAlpha = false, _this._tintBlack = false, /**
11012
11405
  * Default state for spine animation.
11013
11406
  * Contains the default animation name to be played, whether this animation should loop, the default skin name.
11014
11407
  */ _this.defaultConfig = new SpineAnimationDefaultConfig(), /** @internal */ _this._subPrimitives = [], /** @internal */ _this._vertices = new Float32Array(), /** @internal */ _this._indices = new Uint16Array(), /** @internal */ _this._needResizeBuffer = false, /** @internal */ _this._vertexCount = 0, /** @internal */ _this._localBounds = new engine.BoundingBox(new engine.Vector3(Infinity, Infinity, Infinity), new engine.Vector3(-Infinity, -Infinity, -Infinity));
11015
11408
  var primitive = new engine.Primitive(_this._engine);
11016
11409
  _this._primitive = primitive;
11410
+ _this._primitive._addReferCount(1);
11017
11411
  primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
11018
- primitive.addVertexElement(SpineAnimationRenderer._colorVertexElement);
11412
+ primitive.addVertexElement(SpineAnimationRenderer._lightColorVertexElement);
11019
11413
  primitive.addVertexElement(SpineAnimationRenderer._uvVertexElement);
11414
+ primitive.addVertexElement(SpineAnimationRenderer._darkColorVertexElement);
11020
11415
  return _this;
11021
11416
  }
11022
11417
  var _proto = SpineAnimationRenderer.prototype;
@@ -11098,8 +11493,12 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11098
11493
  */ _proto._onDestroy = function _onDestroy() {
11099
11494
  this._clearMaterialCache();
11100
11495
  this._subPrimitives.length = 0;
11101
- this._primitive && this._primitive.destroy();
11102
- this._primitive = null;
11496
+ var primitive = this._primitive;
11497
+ if (primitive) {
11498
+ primitive._addReferCount(-1);
11499
+ primitive._destroy();
11500
+ this._primitive = null;
11501
+ }
11103
11502
  this._resource = null;
11104
11503
  this._skeleton = null;
11105
11504
  this._state = null;
@@ -11110,9 +11509,10 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11110
11509
  */ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
11111
11510
  var _this = this, _engine = _this._engine, _primitive = _this._primitive;
11112
11511
  this._vertexCount = vertexCount;
11113
- this._vertices = new Float32Array(vertexCount * SpineGenerator.VERTEX_STRIDE);
11512
+ var stride = this.tintBlack ? SpineGenerator.vertexStrideWithTint : SpineGenerator.vertexStrideWithoutTint;
11513
+ this._vertices = new Float32Array(vertexCount * stride);
11114
11514
  this._indices = new Uint16Array(vertexCount);
11115
- var vertexStride = SpineGenerator.VERTEX_STRIDE * 4;
11515
+ var vertexStride = stride << 2;
11116
11516
  var vertexBuffer = new engine.Buffer(_engine, engine.BufferBindFlag.VertexBuffer, this._vertices, engine.BufferUsage.Dynamic);
11117
11517
  var indexBuffer = new engine.Buffer(_engine, engine.BufferBindFlag.IndexBuffer, this._indices, engine.BufferUsage.Dynamic);
11118
11518
  this._indexBuffer = indexBuffer;
@@ -11132,14 +11532,34 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11132
11532
  */ _proto._clearSubPrimitives = function _clearSubPrimitives() {
11133
11533
  this._subPrimitives.length = 0;
11134
11534
  };
11535
+ /**
11536
+ * @internal
11537
+ */ _proto._getMaterial = function _getMaterial(texture, blendMode) {
11538
+ var engine = this._engine;
11539
+ var premultipliedAlpha = this.premultipliedAlpha;
11540
+ var tintBlack = this.tintBlack;
11541
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11542
+ var cached = SpineAnimationRenderer._materialCacheMap[key];
11543
+ if (!cached) {
11544
+ cached = new SpineMaterial(engine);
11545
+ cached.isGCIgnored = true;
11546
+ SpineAnimationRenderer._materialCacheMap.set(key, cached);
11547
+ }
11548
+ cached._setBlendMode(blendMode, premultipliedAlpha);
11549
+ cached._setTexture(texture);
11550
+ cached._setTintBlack(tintBlack);
11551
+ cached._setPremultipliedAlpha(premultipliedAlpha);
11552
+ return cached;
11553
+ };
11135
11554
  _proto._clearMaterialCache = function _clearMaterialCache() {
11136
- var materialCache = SpineAnimationRenderer._materialCache;
11137
- var _this = this, materials = _this._materials;
11555
+ var materialCache = SpineAnimationRenderer._materialCacheMap;
11556
+ var premultipliedAlpha = this.premultipliedAlpha;
11557
+ var materials = this._materials;
11138
11558
  for(var i = 0, len = materials.length; i < len; i += 1){
11139
11559
  var material = materials[i];
11140
11560
  var texture = material.shaderData.getTexture("material_SpineTexture");
11141
- var blendMode = getBlendMode(material);
11142
- var key = texture.instanceId + "_" + blendMode;
11561
+ var blendMode = material._getBlendMode();
11562
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11143
11563
  materialCache.delete(key);
11144
11564
  }
11145
11565
  };
@@ -11156,22 +11576,23 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11156
11576
  }
11157
11577
  }
11158
11578
  };
11159
- /** @internal */ SpineAnimationRenderer._getDefaultMaterial = function _getDefaultMaterial(engine) {
11160
- var defaultMaterial = this._defaultMaterial;
11161
- if (defaultMaterial) {
11162
- if (defaultMaterial.engine === engine) {
11163
- return defaultMaterial.clone();
11164
- } else {
11165
- defaultMaterial.destroy(true);
11166
- defaultMaterial = null;
11167
- }
11168
- }
11169
- defaultMaterial = new SpineMaterial(engine);
11170
- defaultMaterial.isGCIgnored = true;
11171
- this._defaultMaterial = defaultMaterial;
11172
- return defaultMaterial.clone();
11173
- };
11174
11579
  _create_class(SpineAnimationRenderer, [
11580
+ {
11581
+ key: "tintBlack",
11582
+ get: /**
11583
+ * Whether to enable tint black feature for dark color tinting.
11584
+ *
11585
+ * @remarks Should be enabled when using "Tint Black" feature in Spine editor.
11586
+ */ function get() {
11587
+ return this._tintBlack;
11588
+ },
11589
+ set: function set(value) {
11590
+ if (this._tintBlack !== value) {
11591
+ this._tintBlack = value;
11592
+ this._needResizeBuffer = true;
11593
+ }
11594
+ }
11595
+ },
11175
11596
  {
11176
11597
  key: "state",
11177
11598
  get: /**
@@ -11225,15 +11646,19 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11225
11646
  }(engine.Renderer);
11226
11647
  SpineAnimationRenderer._spineGenerator = new SpineGenerator();
11227
11648
  SpineAnimationRenderer._positionVertexElement = new engine.VertexElement("POSITION", 0, engine.VertexElementFormat.Vector3, 0);
11228
- SpineAnimationRenderer._colorVertexElement = new engine.VertexElement("COLOR_0", 12, engine.VertexElementFormat.Vector4, 0);
11649
+ SpineAnimationRenderer._lightColorVertexElement = new engine.VertexElement("LIGHT_COLOR", 12, engine.VertexElementFormat.Vector4, 0);
11229
11650
  SpineAnimationRenderer._uvVertexElement = new engine.VertexElement("TEXCOORD_0", 28, engine.VertexElementFormat.Vector2, 0);
11230
- /** @internal */ SpineAnimationRenderer._materialCache = new Map();
11651
+ SpineAnimationRenderer._darkColorVertexElement = new engine.VertexElement("DARK_COLOR", 36, engine.VertexElementFormat.Vector3, 0);
11652
+ /** @internal */ SpineAnimationRenderer._materialCacheMap = new Map();
11231
11653
  __decorate([
11232
11654
  engine.assignmentClone
11233
11655
  ], SpineAnimationRenderer.prototype, "zSpacing", void 0);
11234
11656
  __decorate([
11235
11657
  engine.assignmentClone
11236
11658
  ], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
11659
+ __decorate([
11660
+ engine.assignmentClone
11661
+ ], SpineAnimationRenderer.prototype, "_tintBlack", void 0);
11237
11662
  __decorate([
11238
11663
  engine.deepClone
11239
11664
  ], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
@@ -11634,7 +12059,7 @@ for(var key in RendererObject){
11634
12059
  for(var key1 in LoaderObject){
11635
12060
  engine.Loader.registerClass(key1, LoaderObject[key1]);
11636
12061
  }
11637
- var version = "4.2.2";
12062
+ var version = "4.2.4";
11638
12063
  console.log("Galacean spine version: " + version);
11639
12064
 
11640
12065
  exports.AlphaTimeline = AlphaTimeline;
@@ -11642,6 +12067,7 @@ exports.Animation = Animation;
11642
12067
  exports.AnimationState = AnimationState;
11643
12068
  exports.AnimationStateAdapter = AnimationStateAdapter;
11644
12069
  exports.AnimationStateData = AnimationStateData;
12070
+ exports.AssetCache = AssetCache;
11645
12071
  exports.AssetManagerBase = AssetManagerBase;
11646
12072
  exports.AtlasAttachmentLoader = AtlasAttachmentLoader;
11647
12073
  exports.Attachment = Attachment;