@galacean/engine-spine 4.2.2 → 4.2.3

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 +617 -241
  3. package/dist/main.js.map +1 -1
  4. package/dist/miniprogram.js +617 -241
  5. package/dist/module.js +618 -242
  6. package/dist/module.js.map +1 -1
  7. package/package.json +3 -2
  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
@@ -44,6 +44,97 @@ function __decorate(decorators, target, key, desc) {
44
44
  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;
45
45
  return c > 3 && r && Object.defineProperty(target, key, r), r;
46
46
  }
47
+ function __generator(thisArg, body) {
48
+ var _ = {
49
+ label: 0,
50
+ sent: function sent() {
51
+ if (t[0] & 1) throw t[1];
52
+ return t[1];
53
+ },
54
+ trys: [],
55
+ ops: []
56
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
58
+ return this;
59
+ }), g;
60
+ function verb(n) {
61
+ return function(v) {
62
+ return step([
63
+ n,
64
+ v
65
+ ]);
66
+ };
67
+ }
68
+ function step(op) {
69
+ if (f) throw new TypeError("Generator is already executing.");
70
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
71
+ 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;
72
+ if (y = 0, t) op = [
73
+ op[0] & 2,
74
+ t.value
75
+ ];
76
+ switch(op[0]){
77
+ case 0:
78
+ case 1:
79
+ t = op;
80
+ break;
81
+ case 4:
82
+ _.label++;
83
+ return {
84
+ value: op[1],
85
+ done: false
86
+ };
87
+ case 5:
88
+ _.label++;
89
+ y = op[1];
90
+ op = [
91
+ 0
92
+ ];
93
+ continue;
94
+ case 7:
95
+ op = _.ops.pop();
96
+ _.trys.pop();
97
+ continue;
98
+ default:
99
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
100
+ _ = 0;
101
+ continue;
102
+ }
103
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
104
+ _.label = op[1];
105
+ break;
106
+ }
107
+ if (op[0] === 6 && _.label < t[1]) {
108
+ _.label = t[1];
109
+ t = op;
110
+ break;
111
+ }
112
+ if (t && _.label < t[2]) {
113
+ _.label = t[2];
114
+ _.ops.push(op);
115
+ break;
116
+ }
117
+ if (t[2]) _.ops.pop();
118
+ _.trys.pop();
119
+ continue;
120
+ }
121
+ op = body.call(thisArg, _);
122
+ } catch (e) {
123
+ op = [
124
+ 6,
125
+ e
126
+ ];
127
+ y = 0;
128
+ } finally{
129
+ f = t = 0;
130
+ }
131
+ if (op[0] & 5) throw op[1];
132
+ return {
133
+ value: op[0] ? op[1] : void 0,
134
+ done: true
135
+ };
136
+ }
137
+ }
47
138
  typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
48
139
  var e = new Error(message);
49
140
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -203,8 +294,9 @@ var Color = /*#__PURE__*/ function() {
203
294
  color.g = ((value & 0x0000ff00) >>> 8) / 255;
204
295
  color.b = (value & 0x000000ff) / 255;
205
296
  };
206
- Color.fromString = function fromString(hex) {
207
- return new Color().setFromString(hex);
297
+ Color.fromString = function fromString(hex, color) {
298
+ if (color === void 0) color = new Color();
299
+ return color.setFromString(hex);
208
300
  };
209
301
  return Color;
210
302
  }();
@@ -2828,18 +2920,16 @@ function _create_class(Constructor, protoProps, staticProps) {
2828
2920
  var finished = this.updateMixingFrom(from, delta);
2829
2921
  from.animationLast = from.nextAnimationLast;
2830
2922
  from.trackLast = from.nextTrackLast;
2831
- if (to.nextTrackLast != -1) {
2832
- var discard = to.mixTime == 0 && from.mixTime == 0; // Discard the from entry when neither have advanced yet.
2833
- if (to.mixTime >= to.mixDuration || discard) {
2834
- // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded.
2835
- if (from.totalAlpha == 0 || to.mixDuration == 0 || discard) {
2836
- to.mixingFrom = from.mixingFrom;
2837
- if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2838
- to.interruptAlpha = from.interruptAlpha;
2839
- this.queue.end(from);
2840
- }
2841
- return finished;
2923
+ // The from entry was applied at least once and the mix is complete.
2924
+ if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) {
2925
+ // Mixing is complete for all entries before the from entry or the mix is instantaneous.
2926
+ if (from.totalAlpha == 0 || to.mixDuration == 0) {
2927
+ to.mixingFrom = from.mixingFrom;
2928
+ if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2929
+ to.interruptAlpha = from.interruptAlpha;
2930
+ this.queue.end(from);
2842
2931
  }
2932
+ return finished;
2843
2933
  }
2844
2934
  from.trackTime += delta * from.timeScale;
2845
2935
  to.mixTime += delta;
@@ -3204,10 +3294,11 @@ function _create_class(Constructor, protoProps, staticProps) {
3204
3294
  if (!last) {
3205
3295
  this.setCurrent(trackIndex, entry, true);
3206
3296
  this.queue.drain();
3297
+ if (delay < 0) delay = 0;
3207
3298
  } else {
3208
3299
  last.next = entry;
3209
3300
  entry.previous = last;
3210
- if (delay <= 0) delay += last.getTrackComplete() - entry.mixDuration;
3301
+ if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
3211
3302
  }
3212
3303
  entry.delay = delay;
3213
3304
  return entry;
@@ -3246,7 +3337,7 @@ function _create_class(Constructor, protoProps, staticProps) {
3246
3337
  if (mixDuration === void 0) mixDuration = 0;
3247
3338
  if (delay === void 0) delay = 0;
3248
3339
  var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
3249
- if (delay <= 0) entry.delay += entry.mixDuration - mixDuration;
3340
+ if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
3250
3341
  entry.mixDuration = mixDuration;
3251
3342
  entry.trackEnd = mixDuration;
3252
3343
  return entry;
@@ -3500,7 +3591,10 @@ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
3500
3591
  var _proto = TrackEntry.prototype;
3501
3592
  _proto.setMixDurationWithDelay = function setMixDurationWithDelay(mixDuration, delay) {
3502
3593
  this._mixDuration = mixDuration;
3503
- if (this.previous != null && delay <= 0) delay += this.previous.getTrackComplete() - mixDuration;
3594
+ if (delay <= 0) {
3595
+ if (this.previous != null) delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
3596
+ else delay = 0;
3597
+ }
3504
3598
  this.delay = delay;
3505
3599
  };
3506
3600
  _proto.reset = function reset() {
@@ -3723,17 +3817,17 @@ var CURRENT = 2;
3723
3817
 
3724
3818
  /******************************************************************************
3725
3819
  * Spine Runtimes License Agreement
3726
- * Last updated July 28, 2023. Replaces all prior versions.
3820
+ * Last updated April 5, 2025. Replaces all prior versions.
3727
3821
  *
3728
- * Copyright (c) 2013-2023, Esoteric Software LLC
3822
+ * Copyright (c) 2013-2025, Esoteric Software LLC
3729
3823
  *
3730
3824
  * Integration of the Spine Runtimes into software or otherwise creating
3731
3825
  * derivative works of the Spine Runtimes is permitted under the terms and
3732
3826
  * conditions of Section 2 of the Spine Editor License Agreement:
3733
3827
  * http://esotericsoftware.com/spine-editor-license
3734
3828
  *
3735
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
3736
- * otherwise create derivative works of the Spine Runtimes (collectively,
3829
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
3830
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
3737
3831
  * "Products"), provided that each user of the Products must obtain their own
3738
3832
  * Spine Editor license and redistribution of the Products in any form must
3739
3833
  * include this license and copyright notice.
@@ -3746,8 +3840,8 @@ var CURRENT = 2;
3746
3840
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
3747
3841
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
3748
3842
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3749
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
3750
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3843
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3844
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3751
3845
  *****************************************************************************/ /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */ var AnimationStateData = /*#__PURE__*/ function() {
3752
3846
  function AnimationStateData(skeletonData) {
3753
3847
  this.animationToMixTime = {};
@@ -4199,7 +4293,7 @@ var TextureAtlasRegion = /*#__PURE__*/ function(TextureRegion) {
4199
4293
  this.copyTo(copy);
4200
4294
  copy.regionUVs = new Array(this.regionUVs.length);
4201
4295
  Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
4202
- copy.uvs = new Array(this.uvs.length);
4296
+ copy.uvs = _instanceof1(this.uvs, Float32Array) ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
4203
4297
  Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
4204
4298
  copy.triangles = new Array(this.triangles.length);
4205
4299
  Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
@@ -4863,17 +4957,17 @@ RegionAttachment.V4 = 31;
4863
4957
 
4864
4958
  /******************************************************************************
4865
4959
  * Spine Runtimes License Agreement
4866
- * Last updated July 28, 2023. Replaces all prior versions.
4960
+ * Last updated April 5, 2025. Replaces all prior versions.
4867
4961
  *
4868
- * Copyright (c) 2013-2023, Esoteric Software LLC
4962
+ * Copyright (c) 2013-2025, Esoteric Software LLC
4869
4963
  *
4870
4964
  * Integration of the Spine Runtimes into software or otherwise creating
4871
4965
  * derivative works of the Spine Runtimes is permitted under the terms and
4872
4966
  * conditions of Section 2 of the Spine Editor License Agreement:
4873
4967
  * http://esotericsoftware.com/spine-editor-license
4874
4968
  *
4875
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
4876
- * otherwise create derivative works of the Spine Runtimes (collectively,
4969
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
4970
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
4877
4971
  * "Products"), provided that each user of the Products must obtain their own
4878
4972
  * Spine Editor license and redistribution of the Products in any form must
4879
4973
  * include this license and copyright notice.
@@ -4886,8 +4980,8 @@ RegionAttachment.V4 = 31;
4886
4980
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
4887
4981
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
4888
4982
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4889
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
4890
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4983
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4984
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4891
4985
  *****************************************************************************/ /** The base class for all constraint datas. */ var ConstraintData = function ConstraintData(name, order, skinRequired) {
4892
4986
  this.name = name;
4893
4987
  this.order = order;
@@ -4895,12 +4989,41 @@ RegionAttachment.V4 = 31;
4895
4989
  }
4896
4990
  ;
4897
4991
 
4992
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4993
+ try {
4994
+ var info = gen[key](arg);
4995
+ var value = info.value;
4996
+ } catch (error) {
4997
+ reject(error);
4998
+ return;
4999
+ }
5000
+ if (info.done) resolve(value);
5001
+ else Promise.resolve(value).then(_next, _throw);
5002
+ }
5003
+ function _async_to_generator(fn) {
5004
+ return function() {
5005
+ var self = this, args = arguments;
5006
+ return new Promise(function(resolve, reject) {
5007
+ var gen = fn.apply(self, args);
5008
+ function _next(value) {
5009
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
5010
+ }
5011
+ function _throw(err) {
5012
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
5013
+ }
5014
+ _next(undefined);
5015
+ });
5016
+ };
5017
+ }
5018
+
4898
5019
  var AssetManagerBase = /*#__PURE__*/ function() {
4899
5020
  function AssetManagerBase(textureLoader, pathPrefix, downloader) {
4900
5021
  if (pathPrefix === void 0) pathPrefix = "";
4901
5022
  if (downloader === void 0) downloader = new Downloader();
4902
5023
  this.pathPrefix = "";
4903
5024
  this.assets = {};
5025
+ this.assetsRefCount = {};
5026
+ this.assetsLoaded = {};
4904
5027
  this.errors = {};
4905
5028
  this.toLoad = 0;
4906
5029
  this.loaded = 0;
@@ -4917,6 +5040,7 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4917
5040
  this.toLoad--;
4918
5041
  this.loaded++;
4919
5042
  this.assets[path] = asset;
5043
+ this.assetsRefCount[path] = (this.assetsRefCount[path] || 0) + 1;
4920
5044
  if (callback) callback(path, asset);
4921
5045
  };
4922
5046
  _proto.error = function error(callback, path, message) {
@@ -4948,10 +5072,16 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4948
5072
  if (success === void 0) success = function() {};
4949
5073
  if (error === void 0) error = function() {};
4950
5074
  path = this.start(path);
4951
- this.downloader.downloadBinary(path, function(data) {
4952
- _this.success(success, path, data);
4953
- }, function(status, responseText) {
4954
- _this.error(error, path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
5075
+ if (this.reuseAssets(path, success, error)) return;
5076
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5077
+ _this.downloader.downloadBinary(path, function(data) {
5078
+ _this.success(success, path, data);
5079
+ resolve(data);
5080
+ }, function(status, responseText) {
5081
+ var errorMsg = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
5082
+ _this.error(error, path, errorMsg);
5083
+ reject(errorMsg);
5084
+ });
4955
5085
  });
4956
5086
  };
4957
5087
  _proto.loadText = function loadText(path, success, error) {
@@ -4970,46 +5100,79 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4970
5100
  if (success === void 0) success = function() {};
4971
5101
  if (error === void 0) error = function() {};
4972
5102
  path = this.start(path);
4973
- this.downloader.downloadJson(path, function(data) {
4974
- _this.success(success, path, data);
4975
- }, function(status, responseText) {
4976
- _this.error(error, path, "Couldn't load JSON " + path + ": status " + status + ", " + responseText);
5103
+ if (this.reuseAssets(path, success, error)) return;
5104
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5105
+ _this.downloader.downloadJson(path, function(data) {
5106
+ _this.success(success, path, data);
5107
+ resolve(data);
5108
+ }, function(status, responseText) {
5109
+ var errorMsg = "Couldn't load JSON " + path + ": status " + status + ", " + responseText;
5110
+ _this.error(error, path, errorMsg);
5111
+ reject(errorMsg);
5112
+ });
4977
5113
  });
4978
5114
  };
4979
- _proto.loadTexture = function loadTexture(path, success, error) {
5115
+ _proto.reuseAssets = function reuseAssets(path, success, error) {
4980
5116
  var _this = this;
4981
5117
  if (success === void 0) success = function() {};
4982
5118
  if (error === void 0) error = function() {};
4983
- path = this.start(path);
4984
- var isBrowser = !!(typeof engineMiniprogramAdapter.window !== 'undefined' && typeof engineMiniprogramAdapter.navigator !== 'undefined' && engineMiniprogramAdapter.window.document);
4985
- var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
4986
- if (isWebWorker) {
4987
- fetch(path, {
4988
- mode: "cors"
4989
- }).then(function(response) {
4990
- if (response.ok) return response.blob();
4991
- _this.error(error, path, "Couldn't load image: " + path);
4992
- return null;
4993
- }).then(function(blob) {
4994
- return blob ? createImageBitmap(blob, {
4995
- premultiplyAlpha: "none",
4996
- colorSpaceConversion: "none"
4997
- }) : null;
4998
- }).then(function(bitmap) {
4999
- if (bitmap) _this.success(success, path, _this.textureLoader(bitmap));
5119
+ var loadedStatus = this.assetsLoaded[path];
5120
+ var alreadyExistsOrLoading = loadedStatus !== undefined;
5121
+ if (alreadyExistsOrLoading) {
5122
+ loadedStatus.then(function(data) {
5123
+ return _this.success(success, path, data);
5124
+ }).catch(function(errorMsg) {
5125
+ return _this.error(error, path, errorMsg);
5000
5126
  });
5001
- } else {
5002
- var image = new engineMiniprogramAdapter.Image();
5003
- image.crossOrigin = "anonymous";
5004
- image.onload = function() {
5005
- _this.success(success, path, _this.textureLoader(image));
5006
- };
5007
- image.onerror = function() {
5008
- _this.error(error, path, "Couldn't load image: " + path);
5009
- };
5010
- if (this.downloader.rawDataUris[path]) path = this.downloader.rawDataUris[path];
5011
- image.src = path;
5012
5127
  }
5128
+ return alreadyExistsOrLoading;
5129
+ };
5130
+ _proto.loadTexture = function loadTexture(path, success, error) {
5131
+ var _this = this;
5132
+ if (success === void 0) success = function() {};
5133
+ if (error === void 0) error = function() {};
5134
+ path = this.start(path);
5135
+ if (this.reuseAssets(path, success, error)) return;
5136
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5137
+ var isBrowser = !!(typeof engineMiniprogramAdapter.window !== 'undefined' && typeof engineMiniprogramAdapter.navigator !== 'undefined' && engineMiniprogramAdapter.window.document);
5138
+ var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
5139
+ if (isWebWorker) {
5140
+ fetch(path, {
5141
+ mode: "cors"
5142
+ }).then(function(response) {
5143
+ if (response.ok) return response.blob();
5144
+ var errorMsg = "Couldn't load image: " + path;
5145
+ _this.error(error, path, "Couldn't load image: " + path);
5146
+ reject(errorMsg);
5147
+ }).then(function(blob) {
5148
+ return blob ? createImageBitmap(blob, {
5149
+ premultiplyAlpha: "none",
5150
+ colorSpaceConversion: "none"
5151
+ }) : null;
5152
+ }).then(function(bitmap) {
5153
+ if (bitmap) {
5154
+ var texture = _this.textureLoader(bitmap);
5155
+ _this.success(success, path, texture);
5156
+ resolve(texture);
5157
+ }
5158
+ });
5159
+ } else {
5160
+ var image = new engineMiniprogramAdapter.Image();
5161
+ image.crossOrigin = "anonymous";
5162
+ image.onload = function() {
5163
+ var texture = _this.textureLoader(image);
5164
+ _this.success(success, path, texture);
5165
+ resolve(texture);
5166
+ };
5167
+ image.onerror = function() {
5168
+ var errorMsg = "Couldn't load image: " + path;
5169
+ _this.error(error, path, errorMsg);
5170
+ reject(errorMsg);
5171
+ };
5172
+ if (_this.downloader.rawDataUris[path]) path = _this.downloader.rawDataUris[path];
5173
+ image.src = path;
5174
+ }
5175
+ });
5013
5176
  };
5014
5177
  _proto.loadTextureAtlas = function loadTextureAtlas(path, success, error, fileAlias) {
5015
5178
  var _this = this;
@@ -5018,30 +5181,159 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5018
5181
  var index = path.lastIndexOf("/");
5019
5182
  var parent = index >= 0 ? path.substring(0, index + 1) : "";
5020
5183
  path = this.start(path);
5021
- this.downloader.downloadText(path, function(atlasText) {
5022
- try {
5023
- var _loop = function() {
5024
- var page = _step.value;
5025
- _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5026
- if (!abort) {
5027
- page.setTexture(texture);
5028
- if (--toLoad == 0) _this.success(success, path, atlas);
5029
- }
5030
- }, function(imagePath, message) {
5031
- if (!abort) _this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
5032
- abort = true;
5033
- });
5034
- };
5035
- var atlas = new TextureAtlas(atlasText);
5036
- var toLoad = atlas.pages.length, abort = false;
5037
- for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5038
- } catch (e) {
5039
- _this.error(error, path, "Couldn't parse texture atlas " + path + ": " + e.message);
5040
- }
5041
- }, function(status, responseText) {
5042
- _this.error(error, path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
5184
+ if (this.reuseAssets(path, success, error)) return;
5185
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5186
+ _this.downloader.downloadText(path, function(atlasText) {
5187
+ try {
5188
+ var _loop = function() {
5189
+ var page = _step.value;
5190
+ _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5191
+ if (!abort) {
5192
+ page.setTexture(texture);
5193
+ if (--toLoad == 0) {
5194
+ _this.success(success, path, atlas);
5195
+ resolve(atlas);
5196
+ }
5197
+ }
5198
+ }, function(imagePath, message) {
5199
+ if (!abort) {
5200
+ var errorMsg = "Couldn't load texture atlas " + path + " page image: " + imagePath;
5201
+ _this.error(error, path, errorMsg);
5202
+ reject(errorMsg);
5203
+ }
5204
+ abort = true;
5205
+ });
5206
+ };
5207
+ var atlas = new TextureAtlas(atlasText);
5208
+ var toLoad = atlas.pages.length, abort = false;
5209
+ for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5210
+ } catch (e) {
5211
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5212
+ _this.error(error, path, errorMsg);
5213
+ reject(errorMsg);
5214
+ }
5215
+ }, function(status, responseText) {
5216
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5217
+ _this.error(error, path, errorMsg);
5218
+ reject(errorMsg);
5219
+ });
5043
5220
  });
5044
5221
  };
5222
+ _proto.loadTextureAtlasButNoTextures = function loadTextureAtlasButNoTextures(path, success, error, fileAlias) {
5223
+ var _this = this;
5224
+ if (success === void 0) success = function() {};
5225
+ if (error === void 0) error = function() {};
5226
+ path = this.start(path);
5227
+ if (this.reuseAssets(path, success, error)) return;
5228
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5229
+ _this.downloader.downloadText(path, function(atlasText) {
5230
+ try {
5231
+ var atlas = new TextureAtlas(atlasText);
5232
+ _this.success(success, path, atlas);
5233
+ resolve(atlas);
5234
+ } catch (e) {
5235
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5236
+ _this.error(error, path, errorMsg);
5237
+ reject(errorMsg);
5238
+ }
5239
+ }, function(status, responseText) {
5240
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5241
+ _this.error(error, path, errorMsg);
5242
+ reject(errorMsg);
5243
+ });
5244
+ });
5245
+ };
5246
+ // Promisified versions of load function
5247
+ _proto.loadBinaryAsync = function loadBinaryAsync(path) {
5248
+ return _async_to_generator(function() {
5249
+ var _this;
5250
+ return __generator(this, function(_state) {
5251
+ _this = this;
5252
+ return [
5253
+ 2,
5254
+ new Promise(function(resolve, reject) {
5255
+ _this.loadBinary(path, function(_, binary) {
5256
+ return resolve(binary);
5257
+ }, function(_, message) {
5258
+ return reject(message);
5259
+ });
5260
+ })
5261
+ ];
5262
+ });
5263
+ }).call(this);
5264
+ };
5265
+ _proto.loadJsonAsync = function loadJsonAsync(path) {
5266
+ return _async_to_generator(function() {
5267
+ var _this;
5268
+ return __generator(this, function(_state) {
5269
+ _this = this;
5270
+ return [
5271
+ 2,
5272
+ new Promise(function(resolve, reject) {
5273
+ _this.loadJson(path, function(_, object) {
5274
+ return resolve(object);
5275
+ }, function(_, message) {
5276
+ return reject(message);
5277
+ });
5278
+ })
5279
+ ];
5280
+ });
5281
+ }).call(this);
5282
+ };
5283
+ _proto.loadTextureAsync = function loadTextureAsync(path) {
5284
+ return _async_to_generator(function() {
5285
+ var _this;
5286
+ return __generator(this, function(_state) {
5287
+ _this = this;
5288
+ return [
5289
+ 2,
5290
+ new Promise(function(resolve, reject) {
5291
+ _this.loadTexture(path, function(_, texture) {
5292
+ return resolve(texture);
5293
+ }, function(_, message) {
5294
+ return reject(message);
5295
+ });
5296
+ })
5297
+ ];
5298
+ });
5299
+ }).call(this);
5300
+ };
5301
+ _proto.loadTextureAtlasAsync = function loadTextureAtlasAsync(path) {
5302
+ return _async_to_generator(function() {
5303
+ var _this;
5304
+ return __generator(this, function(_state) {
5305
+ _this = this;
5306
+ return [
5307
+ 2,
5308
+ new Promise(function(resolve, reject) {
5309
+ _this.loadTextureAtlas(path, function(_, atlas) {
5310
+ return resolve(atlas);
5311
+ }, function(_, message) {
5312
+ return reject(message);
5313
+ });
5314
+ })
5315
+ ];
5316
+ });
5317
+ }).call(this);
5318
+ };
5319
+ _proto.loadTextureAtlasButNoTexturesAsync = function loadTextureAtlasButNoTexturesAsync(path) {
5320
+ return _async_to_generator(function() {
5321
+ var _this;
5322
+ return __generator(this, function(_state) {
5323
+ _this = this;
5324
+ return [
5325
+ 2,
5326
+ new Promise(function(resolve, reject) {
5327
+ _this.loadTextureAtlasButNoTextures(path, function(_, atlas) {
5328
+ return resolve(atlas);
5329
+ }, function(_, message) {
5330
+ return reject(message);
5331
+ });
5332
+ })
5333
+ ];
5334
+ });
5335
+ }).call(this);
5336
+ };
5045
5337
  _proto.get = function get(path) {
5046
5338
  return this.assets[this.pathPrefix + path];
5047
5339
  };
@@ -5057,14 +5349,18 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5057
5349
  var asset = this.assets[path];
5058
5350
  if (asset.dispose) asset.dispose();
5059
5351
  delete this.assets[path];
5352
+ delete this.assetsRefCount[path];
5353
+ delete this.assetsLoaded[path];
5060
5354
  return asset;
5061
5355
  };
5062
5356
  _proto.removeAll = function removeAll() {
5063
- for(var key in this.assets){
5064
- var asset = this.assets[key];
5357
+ for(var path in this.assets){
5358
+ var asset = this.assets[path];
5065
5359
  if (asset.dispose) asset.dispose();
5066
5360
  }
5067
5361
  this.assets = {};
5362
+ this.assetsLoaded = {};
5363
+ this.assetsRefCount = {};
5068
5364
  };
5069
5365
  _proto.isLoadingComplete = function isLoadingComplete() {
5070
5366
  return this.toLoad == 0;
@@ -5078,6 +5374,12 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5078
5374
  _proto.dispose = function dispose() {
5079
5375
  this.removeAll();
5080
5376
  };
5377
+ // dispose asset only if it's not used by others
5378
+ _proto.disposeAsset = function disposeAsset(path) {
5379
+ if (--this.assetsRefCount[path] === 0) {
5380
+ this.remove(path);
5381
+ }
5382
+ };
5081
5383
  _proto.hasErrors = function hasErrors() {
5082
5384
  return Object.keys(this.errors).length > 0;
5083
5385
  };
@@ -5125,10 +5427,11 @@ var Downloader = /*#__PURE__*/ function() {
5125
5427
  _proto.downloadText = function downloadText(url, success, error) {
5126
5428
  var _this = this;
5127
5429
  if (this.start(url, success, error)) return;
5128
- if (this.rawDataUris[url]) {
5430
+ var rawDataUri = this.rawDataUris[url];
5431
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5432
+ if (rawDataUri && !rawDataUri.includes(".")) {
5129
5433
  try {
5130
- var dataUri = this.rawDataUris[url];
5131
- this.finish(url, 200, this.dataUriToString(dataUri));
5434
+ this.finish(url, 200, this.dataUriToString(rawDataUri));
5132
5435
  } catch (e) {
5133
5436
  this.finish(url, 400, JSON.stringify(e));
5134
5437
  }
@@ -5136,7 +5439,7 @@ var Downloader = /*#__PURE__*/ function() {
5136
5439
  }
5137
5440
  var request = new engineMiniprogramAdapter.XMLHttpRequest();
5138
5441
  request.overrideMimeType("text/html");
5139
- request.open("GET", url, true);
5442
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5140
5443
  var done = function() {
5141
5444
  _this.finish(url, request.status, request.responseText);
5142
5445
  };
@@ -5152,17 +5455,18 @@ var Downloader = /*#__PURE__*/ function() {
5152
5455
  _proto.downloadBinary = function downloadBinary(url, success, error) {
5153
5456
  var _this = this;
5154
5457
  if (this.start(url, success, error)) return;
5155
- if (this.rawDataUris[url]) {
5458
+ var rawDataUri = this.rawDataUris[url];
5459
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5460
+ if (rawDataUri && !rawDataUri.includes(".")) {
5156
5461
  try {
5157
- var dataUri = this.rawDataUris[url];
5158
- this.finish(url, 200, this.dataUriToUint8Array(dataUri));
5462
+ this.finish(url, 200, this.dataUriToUint8Array(rawDataUri));
5159
5463
  } catch (e) {
5160
5464
  this.finish(url, 400, JSON.stringify(e));
5161
5465
  }
5162
5466
  return;
5163
5467
  }
5164
5468
  var request = new engineMiniprogramAdapter.XMLHttpRequest();
5165
- request.open("GET", url, true);
5469
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5166
5470
  request.responseType = "arraybuffer";
5167
5471
  var onerror = function() {
5168
5472
  _this.finish(url, request.status, request.response);
@@ -5200,17 +5504,17 @@ var Downloader = /*#__PURE__*/ function() {
5200
5504
 
5201
5505
  /******************************************************************************
5202
5506
  * Spine Runtimes License Agreement
5203
- * Last updated July 28, 2023. Replaces all prior versions.
5507
+ * Last updated April 5, 2025. Replaces all prior versions.
5204
5508
  *
5205
- * Copyright (c) 2013-2023, Esoteric Software LLC
5509
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5206
5510
  *
5207
5511
  * Integration of the Spine Runtimes into software or otherwise creating
5208
5512
  * derivative works of the Spine Runtimes is permitted under the terms and
5209
5513
  * conditions of Section 2 of the Spine Editor License Agreement:
5210
5514
  * http://esotericsoftware.com/spine-editor-license
5211
5515
  *
5212
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5213
- * otherwise create derivative works of the Spine Runtimes (collectively,
5516
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5517
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5214
5518
  * "Products"), provided that each user of the Products must obtain their own
5215
5519
  * Spine Editor license and redistribution of the Products in any form must
5216
5520
  * include this license and copyright notice.
@@ -5223,8 +5527,8 @@ var Downloader = /*#__PURE__*/ function() {
5223
5527
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5224
5528
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5225
5529
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5226
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5227
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5530
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5531
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5228
5532
  *****************************************************************************/ /** Stores the current pose values for an {@link Event}.
5229
5533
  *
5230
5534
  * See Timeline {@link Timeline#apply()},
@@ -5244,17 +5548,17 @@ var Downloader = /*#__PURE__*/ function() {
5244
5548
 
5245
5549
  /******************************************************************************
5246
5550
  * Spine Runtimes License Agreement
5247
- * Last updated July 28, 2023. Replaces all prior versions.
5551
+ * Last updated April 5, 2025. Replaces all prior versions.
5248
5552
  *
5249
- * Copyright (c) 2013-2023, Esoteric Software LLC
5553
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5250
5554
  *
5251
5555
  * Integration of the Spine Runtimes into software or otherwise creating
5252
5556
  * derivative works of the Spine Runtimes is permitted under the terms and
5253
5557
  * conditions of Section 2 of the Spine Editor License Agreement:
5254
5558
  * http://esotericsoftware.com/spine-editor-license
5255
5559
  *
5256
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5257
- * otherwise create derivative works of the Spine Runtimes (collectively,
5560
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5561
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5258
5562
  * "Products"), provided that each user of the Products must obtain their own
5259
5563
  * Spine Editor license and redistribution of the Products in any form must
5260
5564
  * include this license and copyright notice.
@@ -5267,8 +5571,8 @@ var Downloader = /*#__PURE__*/ function() {
5267
5571
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5268
5572
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5269
5573
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5270
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5271
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5574
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5575
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5272
5576
  *****************************************************************************/ /** Stores the setup pose values for an {@link Event}.
5273
5577
  *
5274
5578
  * See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */ var EventData = function EventData(name) {
@@ -6128,7 +6432,7 @@ PathConstraint.epsilon = 0.00001;
6128
6432
  }
6129
6433
  if (a >= t) {
6130
6434
  d = Math.pow(this.damping, 60 * t);
6131
- var m = this.massInverse * t, e = this.strength, w = this.wind * f, g = (Skeleton.yDown ? -this.gravity : this.gravity) * f;
6435
+ var m = this.massInverse * t, e = this.strength, w = this.wind * f * skeleton.scaleX, g = this.gravity * f * skeleton.scaleY;
6132
6436
  do {
6133
6437
  if (x) {
6134
6438
  this.xVelocity += (w - this.xOffset * e) * m;
@@ -6970,10 +7274,10 @@ PathConstraint.epsilon = 0.00001;
6970
7274
  })) != null ? _this_physicsConstraints_find : null;
6971
7275
  };
6972
7276
  /** 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 }`.
6973
- * 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() {
7277
+ * 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) {
6974
7278
  var offset = new Vector2();
6975
7279
  var size = new Vector2();
6976
- this.getBounds(offset, size);
7280
+ this.getBounds(offset, size, undefined, clipper);
6977
7281
  return {
6978
7282
  x: offset.x,
6979
7283
  y: offset.y,
@@ -7102,17 +7406,17 @@ Skeleton.yDown = false;
7102
7406
 
7103
7407
  /******************************************************************************
7104
7408
  * Spine Runtimes License Agreement
7105
- * Last updated July 28, 2023. Replaces all prior versions.
7409
+ * Last updated April 5, 2025. Replaces all prior versions.
7106
7410
  *
7107
- * Copyright (c) 2013-2023, Esoteric Software LLC
7411
+ * Copyright (c) 2013-2025, Esoteric Software LLC
7108
7412
  *
7109
7413
  * Integration of the Spine Runtimes into software or otherwise creating
7110
7414
  * derivative works of the Spine Runtimes is permitted under the terms and
7111
7415
  * conditions of Section 2 of the Spine Editor License Agreement:
7112
7416
  * http://esotericsoftware.com/spine-editor-license
7113
7417
  *
7114
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
7115
- * otherwise create derivative works of the Spine Runtimes (collectively,
7418
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
7419
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
7116
7420
  * "Products"), provided that each user of the Products must obtain their own
7117
7421
  * Spine Editor license and redistribution of the Products in any form must
7118
7422
  * include this license and copyright notice.
@@ -7125,18 +7429,16 @@ Skeleton.yDown = false;
7125
7429
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
7126
7430
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
7127
7431
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7128
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
7129
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7432
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
7433
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7130
7434
  *****************************************************************************/ /** Stores the setup pose and all of the stateless data for a skeleton.
7131
7435
  *
7132
7436
  * See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes
7133
7437
  * Guide. */ var SkeletonData = /*#__PURE__*/ function() {
7134
7438
  function SkeletonData() {
7135
7439
  /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ this.name = null;
7136
- /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array() // Ordered parents first.
7137
- ;
7138
- /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array() // Setup pose draw order.
7139
- ;
7440
+ /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array(); // Ordered parents first.
7441
+ /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array(); // Setup pose draw order.
7140
7442
  this.skins = new Array();
7141
7443
  /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
7142
7444
  *
@@ -7279,8 +7581,7 @@ Skeleton.yDown = false;
7279
7581
  this.attachments = new Array();
7280
7582
  this.bones = Array();
7281
7583
  this.constraints = new Array();
7282
- /** 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
- ;
7584
+ /** 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
7284
7585
  if (!name) throw new Error("name cannot be null.");
7285
7586
  this.name = name;
7286
7587
  }
@@ -10438,17 +10739,17 @@ function getValue(map, property, defaultValue) {
10438
10739
 
10439
10740
  /******************************************************************************
10440
10741
  * Spine Runtimes License Agreement
10441
- * Last updated July 28, 2023. Replaces all prior versions.
10742
+ * Last updated April 5, 2025. Replaces all prior versions.
10442
10743
  *
10443
- * Copyright (c) 2013-2023, Esoteric Software LLC
10744
+ * Copyright (c) 2013-2025, Esoteric Software LLC
10444
10745
  *
10445
10746
  * Integration of the Spine Runtimes into software or otherwise creating
10446
10747
  * derivative works of the Spine Runtimes is permitted under the terms and
10447
10748
  * conditions of Section 2 of the Spine Editor License Agreement:
10448
10749
  * http://esotericsoftware.com/spine-editor-license
10449
10750
  *
10450
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
10451
- * otherwise create derivative works of the Spine Runtimes (collectively,
10751
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
10752
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
10452
10753
  * "Products"), provided that each user of the Products must obtain their own
10453
10754
  * Spine Editor license and redistribution of the Products in any form must
10454
10755
  * include this license and copyright notice.
@@ -10461,8 +10762,8 @@ function getValue(map, property, defaultValue) {
10461
10762
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
10462
10763
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
10463
10764
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10464
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
10465
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10765
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
10766
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10466
10767
  *****************************************************************************/ (function() {
10467
10768
  if (typeof Math.fround === "undefined") {
10468
10769
  Math.fround = function(array) {
@@ -10611,55 +10912,6 @@ function getValue(map, property, defaultValue) {
10611
10912
  return LoaderUtils;
10612
10913
  }();
10613
10914
 
10614
- var SourceAlpha = miniprogram.BlendFactor.SourceAlpha, One = miniprogram.BlendFactor.One, DestinationColor = miniprogram.BlendFactor.DestinationColor, Zero = miniprogram.BlendFactor.Zero, OneMinusSourceColor = miniprogram.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = miniprogram.BlendFactor.OneMinusSourceAlpha;
10615
- var Add = miniprogram.BlendOperation.Add;
10616
- function setBlendMode(material, blendMode, premultipliedAlpha) {
10617
- var target = material.renderState.blendState.targetBlendState;
10618
- switch(blendMode){
10619
- case exports.BlendMode.Additive:
10620
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10621
- target.destinationColorBlendFactor = One;
10622
- target.sourceAlphaBlendFactor = One;
10623
- target.destinationAlphaBlendFactor = One;
10624
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10625
- break;
10626
- case exports.BlendMode.Multiply:
10627
- target.sourceColorBlendFactor = DestinationColor;
10628
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10629
- target.sourceAlphaBlendFactor = One;
10630
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10631
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10632
- break;
10633
- case exports.BlendMode.Screen:
10634
- target.sourceColorBlendFactor = One;
10635
- target.destinationColorBlendFactor = OneMinusSourceColor;
10636
- target.sourceAlphaBlendFactor = One;
10637
- target.destinationAlphaBlendFactor = OneMinusSourceColor;
10638
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10639
- break;
10640
- default:
10641
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10642
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10643
- target.sourceAlphaBlendFactor = One;
10644
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10645
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10646
- break;
10647
- }
10648
- }
10649
- function getBlendMode(material) {
10650
- var target = material.renderState.blendState.targetBlendState;
10651
- if (target.sourceColorBlendFactor === SourceAlpha && target.destinationColorBlendFactor === One && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === One && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10652
- return exports.BlendMode.Additive;
10653
- }
10654
- if (target.sourceColorBlendFactor === DestinationColor && target.destinationColorBlendFactor === Zero && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === Zero && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10655
- return exports.BlendMode.Multiply;
10656
- }
10657
- if (target.sourceColorBlendFactor === One && target.destinationColorBlendFactor === OneMinusSourceColor && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === OneMinusSourceColor && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10658
- return exports.BlendMode.Screen;
10659
- }
10660
- return exports.BlendMode.Normal;
10661
- }
10662
-
10663
10915
  var ClearablePool = /*#__PURE__*/ function() {
10664
10916
  function ClearablePool(type) {
10665
10917
  this._usedElementCount = 0;
@@ -10720,11 +10972,11 @@ var SubRenderItem = function SubRenderItem() {
10720
10972
  }
10721
10973
  var _proto = SpineGenerator.prototype;
10722
10974
  _proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
10723
- 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;
10975
+ 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;
10724
10976
  _localBounds.min.set(Infinity, Infinity, Infinity);
10725
10977
  _localBounds.max.set(-Infinity, -Infinity, -Infinity);
10726
10978
  var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
10727
- var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, VERTEX_SIZE = SpineGenerator.VERTEX_SIZE;
10979
+ var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, vertexStrideWithTint = SpineGenerator.vertexStrideWithTint, vertexStrideWithoutTint = SpineGenerator.vertexStrideWithoutTint;
10728
10980
  _subRenderItems.length = 0;
10729
10981
  subRenderItemPool.clear();
10730
10982
  var triangles;
@@ -10754,13 +11006,28 @@ var SubRenderItem = function SubRenderItem() {
10754
11006
  var isClipping = _clipper.isClipping();
10755
11007
  var numFloats = 0;
10756
11008
  var attachmentColor = null;
10757
- var vertexSize = isClipping ? 2 : VERTEX_SIZE;
11009
+ // This vertexSize will be passed to spine-core's computeWorldVertices function.
11010
+ //
11011
+ // Expected format by computeWorldVertices:
11012
+ // - Without tintBlack: [x, y, u, v, r, g, b, a] = 8 components
11013
+ // - With tintBlack: [x, y, u, v, r, g, b, a, dr, dg, db, da] = 12 components
11014
+ //
11015
+ // Our actual vertex buffer format:
11016
+ // - vertexStrideWithoutTint: [x, y, z, u, v, r, g, b, a] = 9 components
11017
+ // - vertexStrideWithTint: [x, y, z, u, v, r, g, b, a, dr, dg, db] = 12 components
11018
+ // (Note: we optimized 'da' as uniform instead of buffer attribute)
11019
+ //
11020
+ // Calculation:
11021
+ // - Without tintBlack: 9 - 1 (remove z) = 8 ✓
11022
+ // - With tintBlack: 12 - 1 (remove z) + 1 (add back da) = 12 ✓
11023
+ var vertexSize = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint - 1;
11024
+ var clippedVertexSize = isClipping ? 2 : vertexSize;
10758
11025
  switch(attachment.constructor){
10759
11026
  case RegionAttachment:
10760
11027
  var regionAttachment = attachment;
10761
11028
  attachmentColor = regionAttachment.color;
10762
- numFloats = vertexSize * 4;
10763
- regionAttachment.computeWorldVertices(slot, tempVerts, 0, vertexSize);
11029
+ numFloats = clippedVertexSize << 2;
11030
+ regionAttachment.computeWorldVertices(slot, tempVerts, 0, clippedVertexSize);
10764
11031
  triangles = SpineGenerator.QUAD_TRIANGLES;
10765
11032
  uvs = regionAttachment.uvs;
10766
11033
  texture = regionAttachment.region.texture;
@@ -10768,11 +11035,11 @@ var SubRenderItem = function SubRenderItem() {
10768
11035
  case MeshAttachment:
10769
11036
  var meshAttachment = attachment;
10770
11037
  attachmentColor = meshAttachment.color;
10771
- numFloats = (meshAttachment.worldVerticesLength >> 1) * vertexSize;
11038
+ numFloats = (meshAttachment.worldVerticesLength >> 1) * clippedVertexSize;
10772
11039
  if (numFloats > _vertices.length) {
10773
11040
  SpineGenerator.tempVerts = new Array(numFloats);
10774
11041
  }
10775
- meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, vertexSize);
11042
+ meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, clippedVertexSize);
10776
11043
  triangles = meshAttachment.triangles;
10777
11044
  uvs = meshAttachment.uvs;
10778
11045
  texture = meshAttachment.region.texture;
@@ -10804,8 +11071,21 @@ var SubRenderItem = function SubRenderItem() {
10804
11071
  finalColor.g *= finalAlpha;
10805
11072
  finalColor.b *= finalAlpha;
10806
11073
  }
11074
+ var darkColor = SpineGenerator.tempDark;
11075
+ var slotDarkColor = slot.darkColor;
11076
+ if (!slotDarkColor) {
11077
+ darkColor.set(0, 0, 0, 1);
11078
+ } else {
11079
+ if (premultipliedAlpha) {
11080
+ darkColor.r = slotDarkColor.r * finalAlpha;
11081
+ darkColor.g = slotDarkColor.g * finalAlpha;
11082
+ darkColor.b = slotDarkColor.b * finalAlpha;
11083
+ } else {
11084
+ darkColor.setFromColor(slotDarkColor);
11085
+ }
11086
+ }
10807
11087
  if (isClipping) {
10808
- _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, SpineGenerator.tempDark, false);
11088
+ _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, darkColor, tintBlack);
10809
11089
  finalVertices = _clipper.clippedVertices;
10810
11090
  finalVerticesLength = finalVertices.length;
10811
11091
  finalIndices = _clipper.clippedTriangles;
@@ -10819,6 +11099,12 @@ var SubRenderItem = function SubRenderItem() {
10819
11099
  tempVerts[v + 3] = a;
10820
11100
  tempVerts[v + 4] = uvs[u];
10821
11101
  tempVerts[v + 5] = uvs[u + 1];
11102
+ if (tintBlack) {
11103
+ tempVerts[v + 6] = darkColor.r;
11104
+ tempVerts[v + 7] = darkColor.g;
11105
+ tempVerts[v + 8] = darkColor.b;
11106
+ tempVerts[v + 9] = darkColor.a;
11107
+ }
10822
11108
  }
10823
11109
  finalVertices = tempVerts;
10824
11110
  finalVerticesLength = numFloats;
@@ -10829,7 +11115,8 @@ var SubRenderItem = function SubRenderItem() {
10829
11115
  _clipper.clipEndWithSlot(slot);
10830
11116
  continue;
10831
11117
  }
10832
- var indexStart = verticesLength / SpineGenerator.VERTEX_STRIDE;
11118
+ var stride = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint;
11119
+ var indexStart = verticesLength / stride;
10833
11120
  var i = verticesLength;
10834
11121
  var j = 0;
10835
11122
  for(; j < finalVerticesLength;){
@@ -10838,12 +11125,18 @@ var SubRenderItem = function SubRenderItem() {
10838
11125
  _vertices[i++] = x;
10839
11126
  _vertices[i++] = y;
10840
11127
  _vertices[i++] = z;
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++];
10846
- _vertices[i++] = finalVertices[j++];
11128
+ _vertices[i++] = finalVertices[j++]; // u
11129
+ _vertices[i++] = finalVertices[j++]; // v
11130
+ _vertices[i++] = finalVertices[j++]; // r
11131
+ _vertices[i++] = finalVertices[j++]; // g
11132
+ _vertices[i++] = finalVertices[j++]; // b
11133
+ _vertices[i++] = finalVertices[j++]; // a
11134
+ if (tintBlack) {
11135
+ _vertices[i++] = finalVertices[j++]; // darkR
11136
+ _vertices[i++] = finalVertices[j++]; // darkG
11137
+ _vertices[i++] = finalVertices[j++]; // darkB
11138
+ j++; // darkA
11139
+ }
10847
11140
  this._expandBounds(x, y, z, _localBounds);
10848
11141
  }
10849
11142
  verticesLength = i;
@@ -10900,22 +11193,17 @@ var SubRenderItem = function SubRenderItem() {
10900
11193
  subPrimitivePool.return(item);
10901
11194
  }
10902
11195
  renderer._clearSubPrimitives();
10903
- var materialCache = SpineAnimationRenderer._materialCache;
10904
11196
  for(var i2 = 0, l = curLen; i2 < l; ++i2){
10905
11197
  var item1 = _subRenderItems[i2];
10906
11198
  var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
10907
11199
  renderer._addSubPrimitive(item1.subPrimitive);
10908
11200
  var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
10909
- var key = subTexture.instanceId + "_" + blendMode + "_" + premultipliedAlpha;
10910
- var material = materialCache.get(key);
10911
- if (!material) {
10912
- material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
10913
- materialCache.set(key, material);
10914
- }
11201
+ var material = renderer._getMaterial(subTexture, blendMode);
10915
11202
  renderer.setMaterial(i2, material);
10916
11203
  }
10917
- if (indicesLength > _vertexCount) {
11204
+ if (indicesLength > _vertexCount || renderer._needResizeBuffer) {
10918
11205
  renderer._createAndBindBuffer(indicesLength);
11206
+ renderer._needResizeBuffer = false;
10919
11207
  this.buildPrimitive(skeleton, renderer);
10920
11208
  return;
10921
11209
  }
@@ -10930,12 +11218,6 @@ var SubRenderItem = function SubRenderItem() {
10930
11218
  _proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
10931
11219
  this._separateSlotTextureMap.set(slotName, texture);
10932
11220
  };
10933
- _proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
10934
- var material = SpineAnimationRenderer._getDefaultMaterial(engine);
10935
- material.shaderData.setTexture("material_SpineTexture", texture);
10936
- setBlendMode(material, blendMode, premultipliedAlpha);
10937
- return material;
10938
- };
10939
11221
  _proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
10940
11222
  var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
10941
11223
  var origin = subPrimitives[primitiveIndex];
@@ -10960,8 +11242,8 @@ var SubRenderItem = function SubRenderItem() {
10960
11242
  };
10961
11243
  return SpineGenerator;
10962
11244
  }();
10963
- SpineGenerator.VERTEX_SIZE = 8;
10964
- SpineGenerator.VERTEX_STRIDE = 9;
11245
+ SpineGenerator.vertexStrideWithoutTint = 9;
11246
+ SpineGenerator.vertexStrideWithTint = 12;
10965
11247
  SpineGenerator.tempDark = new Color();
10966
11248
  SpineGenerator.tempColor = new Color();
10967
11249
  SpineGenerator.tempVerts = new Array(8);
@@ -10976,25 +11258,92 @@ SpineGenerator.QUAD_TRIANGLES = [
10976
11258
  SpineGenerator.subPrimitivePool = new ReturnablePool(miniprogram.SubPrimitive);
10977
11259
  SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
10978
11260
 
11261
+ var SourceAlpha = miniprogram.BlendFactor.SourceAlpha, One = miniprogram.BlendFactor.One, DestinationColor = miniprogram.BlendFactor.DestinationColor, OneMinusSourceColor = miniprogram.BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = miniprogram.BlendFactor.OneMinusSourceAlpha;
11262
+ var Add = miniprogram.BlendOperation.Add;
10979
11263
  var SpineMaterial = /*#__PURE__*/ function(Material) {
10980
11264
  _inherits(SpineMaterial, Material);
10981
11265
  function SpineMaterial(engine) {
10982
11266
  var _this;
10983
11267
  var shader = miniprogram.Shader.find("galacean-spine-shader") || miniprogram.Shader.create("galacean-spine-shader", SpineMaterial._spineVS, SpineMaterial._spineFS);
10984
- _this = Material.call(this, engine, shader) || this;
11268
+ _this = Material.call(this, engine, shader) || this, _this._blendMode = exports.BlendMode.Normal;
10985
11269
  var renderState = _this.renderState;
10986
11270
  var target = renderState.blendState.targetBlendState;
10987
11271
  target.enabled = true;
10988
- setBlendMode(_this, exports.BlendMode.Normal, false);
11272
+ _this._setBlendMode(exports.BlendMode.Normal, false);
10989
11273
  renderState.depthState.writeEnabled = false;
10990
11274
  renderState.rasterState.cullMode = miniprogram.CullMode.Off;
10991
11275
  renderState.renderQueueType = miniprogram.RenderQueueType.Transparent;
10992
11276
  return _this;
10993
11277
  }
11278
+ var _proto = SpineMaterial.prototype;
11279
+ /**
11280
+ * @internal
11281
+ */ _proto._setTintBlack = function _setTintBlack(enabled) {
11282
+ if (enabled) {
11283
+ this.shaderData.enableMacro("RENDERER_TINT_BLACK");
11284
+ } else {
11285
+ this.shaderData.disableMacro("RENDERER_TINT_BLACK");
11286
+ }
11287
+ };
11288
+ /**
11289
+ * @internal
11290
+ */ _proto._setPremultipliedAlpha = function _setPremultipliedAlpha(enabled) {
11291
+ if (enabled) {
11292
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 1);
11293
+ } else {
11294
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 0);
11295
+ }
11296
+ };
11297
+ /**
11298
+ * @internal
11299
+ */ _proto._setTexture = function _setTexture(value) {
11300
+ this.shaderData.setTexture("material_SpineTexture", value);
11301
+ };
11302
+ /**
11303
+ * @internal
11304
+ */ _proto._setBlendMode = function _setBlendMode(blendMode, premultipliedAlpha) {
11305
+ var target = this.renderState.blendState.targetBlendState;
11306
+ this._blendMode = blendMode;
11307
+ switch(blendMode){
11308
+ case exports.BlendMode.Additive:
11309
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11310
+ target.destinationColorBlendFactor = One;
11311
+ target.sourceAlphaBlendFactor = One;
11312
+ target.destinationAlphaBlendFactor = One;
11313
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11314
+ break;
11315
+ case exports.BlendMode.Multiply:
11316
+ target.sourceColorBlendFactor = DestinationColor;
11317
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11318
+ target.sourceAlphaBlendFactor = One;
11319
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11320
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11321
+ break;
11322
+ case exports.BlendMode.Screen:
11323
+ target.sourceColorBlendFactor = One;
11324
+ target.destinationColorBlendFactor = OneMinusSourceColor;
11325
+ target.sourceAlphaBlendFactor = One;
11326
+ target.destinationAlphaBlendFactor = OneMinusSourceColor;
11327
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11328
+ break;
11329
+ default:
11330
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11331
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11332
+ target.sourceAlphaBlendFactor = One;
11333
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11334
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11335
+ break;
11336
+ }
11337
+ };
11338
+ /**
11339
+ * @internal
11340
+ */ _proto._getBlendMode = function _getBlendMode() {
11341
+ return this._blendMode;
11342
+ };
10994
11343
  return SpineMaterial;
10995
11344
  }(miniprogram.Material);
10996
- 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 ";
10997
- 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 ";
11345
+ 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 ";
11346
+ 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 ";
10998
11347
 
10999
11348
  /**
11000
11349
  * Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
@@ -11009,15 +11358,16 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11009
11358
  * When enabled, vertex color values are multiplied by the alpha channel.
11010
11359
  * @remarks
11011
11360
  If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
11012
- */ _this.premultipliedAlpha = false, /**
11361
+ */ _this.premultipliedAlpha = false, _this._tintBlack = false, /**
11013
11362
  * Default state for spine animation.
11014
11363
  * Contains the default animation name to be played, whether this animation should loop, the default skin name.
11015
11364
  */ _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 miniprogram.BoundingBox(new miniprogram.Vector3(Infinity, Infinity, Infinity), new miniprogram.Vector3(-Infinity, -Infinity, -Infinity));
11016
11365
  var primitive = new miniprogram.Primitive(_this._engine);
11017
11366
  _this._primitive = primitive;
11018
11367
  primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
11019
- primitive.addVertexElement(SpineAnimationRenderer._colorVertexElement);
11368
+ primitive.addVertexElement(SpineAnimationRenderer._lightColorVertexElement);
11020
11369
  primitive.addVertexElement(SpineAnimationRenderer._uvVertexElement);
11370
+ primitive.addVertexElement(SpineAnimationRenderer._darkColorVertexElement);
11021
11371
  return _this;
11022
11372
  }
11023
11373
  var _proto = SpineAnimationRenderer.prototype;
@@ -11111,9 +11461,10 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11111
11461
  */ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
11112
11462
  var _this = this, _engine = _this._engine, _primitive = _this._primitive;
11113
11463
  this._vertexCount = vertexCount;
11114
- this._vertices = new Float32Array(vertexCount * SpineGenerator.VERTEX_STRIDE);
11464
+ var stride = this.tintBlack ? SpineGenerator.vertexStrideWithTint : SpineGenerator.vertexStrideWithoutTint;
11465
+ this._vertices = new Float32Array(vertexCount * stride);
11115
11466
  this._indices = new Uint16Array(vertexCount);
11116
- var vertexStride = SpineGenerator.VERTEX_STRIDE * 4;
11467
+ var vertexStride = stride << 2;
11117
11468
  var vertexBuffer = new miniprogram.Buffer(_engine, miniprogram.BufferBindFlag.VertexBuffer, this._vertices, miniprogram.BufferUsage.Dynamic);
11118
11469
  var indexBuffer = new miniprogram.Buffer(_engine, miniprogram.BufferBindFlag.IndexBuffer, this._indices, miniprogram.BufferUsage.Dynamic);
11119
11470
  this._indexBuffer = indexBuffer;
@@ -11133,14 +11484,34 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11133
11484
  */ _proto._clearSubPrimitives = function _clearSubPrimitives() {
11134
11485
  this._subPrimitives.length = 0;
11135
11486
  };
11487
+ /**
11488
+ * @internal
11489
+ */ _proto._getMaterial = function _getMaterial(texture, blendMode) {
11490
+ var engine = this._engine;
11491
+ var premultipliedAlpha = this.premultipliedAlpha;
11492
+ var tintBlack = this.tintBlack;
11493
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11494
+ var cached = SpineAnimationRenderer._materialCacheMap[key];
11495
+ if (!cached) {
11496
+ cached = new SpineMaterial(engine);
11497
+ cached.isGCIgnored = true;
11498
+ SpineAnimationRenderer._materialCacheMap.set(key, cached);
11499
+ }
11500
+ cached._setBlendMode(blendMode, premultipliedAlpha);
11501
+ cached._setTexture(texture);
11502
+ cached._setTintBlack(tintBlack);
11503
+ cached._setPremultipliedAlpha(premultipliedAlpha);
11504
+ return cached;
11505
+ };
11136
11506
  _proto._clearMaterialCache = function _clearMaterialCache() {
11137
- var materialCache = SpineAnimationRenderer._materialCache;
11138
- var _this = this, materials = _this._materials;
11507
+ var materialCache = SpineAnimationRenderer._materialCacheMap;
11508
+ var premultipliedAlpha = this.premultipliedAlpha;
11509
+ var materials = this._materials;
11139
11510
  for(var i = 0, len = materials.length; i < len; i += 1){
11140
11511
  var material = materials[i];
11141
11512
  var texture = material.shaderData.getTexture("material_SpineTexture");
11142
- var blendMode = getBlendMode(material);
11143
- var key = texture.instanceId + "_" + blendMode;
11513
+ var blendMode = material._getBlendMode();
11514
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11144
11515
  materialCache.delete(key);
11145
11516
  }
11146
11517
  };
@@ -11157,22 +11528,23 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11157
11528
  }
11158
11529
  }
11159
11530
  };
11160
- /** @internal */ SpineAnimationRenderer._getDefaultMaterial = function _getDefaultMaterial(engine) {
11161
- var defaultMaterial = this._defaultMaterial;
11162
- if (defaultMaterial) {
11163
- if (defaultMaterial.engine === engine) {
11164
- return defaultMaterial.clone();
11165
- } else {
11166
- defaultMaterial.destroy(true);
11167
- defaultMaterial = null;
11168
- }
11169
- }
11170
- defaultMaterial = new SpineMaterial(engine);
11171
- defaultMaterial.isGCIgnored = true;
11172
- this._defaultMaterial = defaultMaterial;
11173
- return defaultMaterial.clone();
11174
- };
11175
11531
  _create_class(SpineAnimationRenderer, [
11532
+ {
11533
+ key: "tintBlack",
11534
+ get: /**
11535
+ * Whether to enable tint black feature for dark color tinting.
11536
+ *
11537
+ * @remarks Should be enabled when using "Tint Black" feature in Spine editor.
11538
+ */ function get() {
11539
+ return this._tintBlack;
11540
+ },
11541
+ set: function set(value) {
11542
+ if (this._tintBlack !== value) {
11543
+ this._tintBlack = value;
11544
+ this._needResizeBuffer = true;
11545
+ }
11546
+ }
11547
+ },
11176
11548
  {
11177
11549
  key: "state",
11178
11550
  get: /**
@@ -11226,15 +11598,19 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11226
11598
  }(miniprogram.Renderer);
11227
11599
  SpineAnimationRenderer._spineGenerator = new SpineGenerator();
11228
11600
  SpineAnimationRenderer._positionVertexElement = new miniprogram.VertexElement("POSITION", 0, miniprogram.VertexElementFormat.Vector3, 0);
11229
- SpineAnimationRenderer._colorVertexElement = new miniprogram.VertexElement("COLOR_0", 12, miniprogram.VertexElementFormat.Vector4, 0);
11601
+ SpineAnimationRenderer._lightColorVertexElement = new miniprogram.VertexElement("LIGHT_COLOR", 12, miniprogram.VertexElementFormat.Vector4, 0);
11230
11602
  SpineAnimationRenderer._uvVertexElement = new miniprogram.VertexElement("TEXCOORD_0", 28, miniprogram.VertexElementFormat.Vector2, 0);
11231
- /** @internal */ SpineAnimationRenderer._materialCache = new Map();
11603
+ SpineAnimationRenderer._darkColorVertexElement = new miniprogram.VertexElement("DARK_COLOR", 36, miniprogram.VertexElementFormat.Vector3, 0);
11604
+ /** @internal */ SpineAnimationRenderer._materialCacheMap = new Map();
11232
11605
  __decorate([
11233
11606
  miniprogram.assignmentClone
11234
11607
  ], SpineAnimationRenderer.prototype, "zSpacing", void 0);
11235
11608
  __decorate([
11236
11609
  miniprogram.assignmentClone
11237
11610
  ], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
11611
+ __decorate([
11612
+ miniprogram.assignmentClone
11613
+ ], SpineAnimationRenderer.prototype, "_tintBlack", void 0);
11238
11614
  __decorate([
11239
11615
  miniprogram.deepClone
11240
11616
  ], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
@@ -11635,7 +12011,7 @@ for(var key in RendererObject){
11635
12011
  for(var key1 in LoaderObject){
11636
12012
  miniprogram.Loader.registerClass(key1, LoaderObject[key1]);
11637
12013
  }
11638
- var version = "4.2.2";
12014
+ var version = "4.2.3";
11639
12015
  console.log("Galacean spine version: " + version);
11640
12016
 
11641
12017
  exports.AlphaTimeline = AlphaTimeline;