@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
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { TextureFilterMode, TextureWrapMode, AssetType, BlendFactor, BlendOperation, SubPrimitive, Shader, CullMode, RenderQueueType, Material, VertexElement, VertexElementFormat, BoundingBox, Buffer, BufferBindFlag, BufferUsage, VertexBufferBinding, IndexBufferBinding, IndexFormat, Renderer, assignmentClone, deepClone, ignoreClone, Vector3, Primitive, Entity, ReferResource, resourceLoader, AssetPromise, Loader } from '@galacean/engine';
1
+ import { TextureFilterMode, TextureWrapMode, AssetType, SubPrimitive, BlendFactor, BlendOperation, Shader, CullMode, RenderQueueType, Material, VertexElement, VertexElementFormat, BoundingBox, Buffer, BufferBindFlag, BufferUsage, VertexBufferBinding, IndexBufferBinding, IndexFormat, Renderer, assignmentClone, deepClone, ignoreClone, Vector3, Primitive, Entity, ReferResource, resourceLoader, AssetPromise, Loader } from '@galacean/engine';
2
2
 
3
3
  function _set_prototype_of(o, p) {
4
4
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -39,6 +39,97 @@ function __decorate(decorators, target, key, desc) {
39
39
  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;
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
+ function __generator(thisArg, body) {
43
+ var _ = {
44
+ label: 0,
45
+ sent: function sent() {
46
+ if (t[0] & 1) throw t[1];
47
+ return t[1];
48
+ },
49
+ trys: [],
50
+ ops: []
51
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
52
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
53
+ return this;
54
+ }), g;
55
+ function verb(n) {
56
+ return function(v) {
57
+ return step([
58
+ n,
59
+ v
60
+ ]);
61
+ };
62
+ }
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
66
+ 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;
67
+ if (y = 0, t) op = [
68
+ op[0] & 2,
69
+ t.value
70
+ ];
71
+ switch(op[0]){
72
+ case 0:
73
+ case 1:
74
+ t = op;
75
+ break;
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+ case 5:
83
+ _.label++;
84
+ y = op[1];
85
+ op = [
86
+ 0
87
+ ];
88
+ continue;
89
+ case 7:
90
+ op = _.ops.pop();
91
+ _.trys.pop();
92
+ continue;
93
+ default:
94
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
95
+ _ = 0;
96
+ continue;
97
+ }
98
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
99
+ _.label = op[1];
100
+ break;
101
+ }
102
+ if (op[0] === 6 && _.label < t[1]) {
103
+ _.label = t[1];
104
+ t = op;
105
+ break;
106
+ }
107
+ if (t && _.label < t[2]) {
108
+ _.label = t[2];
109
+ _.ops.push(op);
110
+ break;
111
+ }
112
+ if (t[2]) _.ops.pop();
113
+ _.trys.pop();
114
+ continue;
115
+ }
116
+ op = body.call(thisArg, _);
117
+ } catch (e) {
118
+ op = [
119
+ 6,
120
+ e
121
+ ];
122
+ y = 0;
123
+ } finally{
124
+ f = t = 0;
125
+ }
126
+ if (op[0] & 5) throw op[1];
127
+ return {
128
+ value: op[0] ? op[1] : void 0,
129
+ done: true
130
+ };
131
+ }
132
+ }
42
133
  typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
43
134
  var e = new Error(message);
44
135
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -198,8 +289,9 @@ var Color = /*#__PURE__*/ function() {
198
289
  color.g = ((value & 0x0000ff00) >>> 8) / 255;
199
290
  color.b = (value & 0x000000ff) / 255;
200
291
  };
201
- Color.fromString = function fromString(hex) {
202
- return new Color().setFromString(hex);
292
+ Color.fromString = function fromString(hex, color) {
293
+ if (color === void 0) color = new Color();
294
+ return color.setFromString(hex);
203
295
  };
204
296
  return Color;
205
297
  }();
@@ -2823,18 +2915,16 @@ function _create_class(Constructor, protoProps, staticProps) {
2823
2915
  var finished = this.updateMixingFrom(from, delta);
2824
2916
  from.animationLast = from.nextAnimationLast;
2825
2917
  from.trackLast = from.nextTrackLast;
2826
- if (to.nextTrackLast != -1) {
2827
- var discard = to.mixTime == 0 && from.mixTime == 0; // Discard the from entry when neither have advanced yet.
2828
- if (to.mixTime >= to.mixDuration || discard) {
2829
- // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded.
2830
- if (from.totalAlpha == 0 || to.mixDuration == 0 || discard) {
2831
- to.mixingFrom = from.mixingFrom;
2832
- if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2833
- to.interruptAlpha = from.interruptAlpha;
2834
- this.queue.end(from);
2835
- }
2836
- return finished;
2918
+ // The from entry was applied at least once and the mix is complete.
2919
+ if (to.nextTrackLast != -1 && to.mixTime >= to.mixDuration) {
2920
+ // Mixing is complete for all entries before the from entry or the mix is instantaneous.
2921
+ if (from.totalAlpha == 0 || to.mixDuration == 0) {
2922
+ to.mixingFrom = from.mixingFrom;
2923
+ if (from.mixingFrom != null) from.mixingFrom.mixingTo = to;
2924
+ to.interruptAlpha = from.interruptAlpha;
2925
+ this.queue.end(from);
2837
2926
  }
2927
+ return finished;
2838
2928
  }
2839
2929
  from.trackTime += delta * from.timeScale;
2840
2930
  to.mixTime += delta;
@@ -3199,10 +3289,11 @@ function _create_class(Constructor, protoProps, staticProps) {
3199
3289
  if (!last) {
3200
3290
  this.setCurrent(trackIndex, entry, true);
3201
3291
  this.queue.drain();
3292
+ if (delay < 0) delay = 0;
3202
3293
  } else {
3203
3294
  last.next = entry;
3204
3295
  entry.previous = last;
3205
- if (delay <= 0) delay += last.getTrackComplete() - entry.mixDuration;
3296
+ if (delay <= 0) delay = Math.max(delay + last.getTrackComplete() - entry.mixDuration, 0);
3206
3297
  }
3207
3298
  entry.delay = delay;
3208
3299
  return entry;
@@ -3241,7 +3332,7 @@ function _create_class(Constructor, protoProps, staticProps) {
3241
3332
  if (mixDuration === void 0) mixDuration = 0;
3242
3333
  if (delay === void 0) delay = 0;
3243
3334
  var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation(), false, delay);
3244
- if (delay <= 0) entry.delay += entry.mixDuration - mixDuration;
3335
+ if (delay <= 0) entry.delay = Math.max(entry.delay + entry.mixDuration - mixDuration, 0);
3245
3336
  entry.mixDuration = mixDuration;
3246
3337
  entry.trackEnd = mixDuration;
3247
3338
  return entry;
@@ -3495,7 +3586,10 @@ AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
3495
3586
  var _proto = TrackEntry.prototype;
3496
3587
  _proto.setMixDurationWithDelay = function setMixDurationWithDelay(mixDuration, delay) {
3497
3588
  this._mixDuration = mixDuration;
3498
- if (this.previous != null && delay <= 0) delay += this.previous.getTrackComplete() - mixDuration;
3589
+ if (delay <= 0) {
3590
+ if (this.previous != null) delay = Math.max(delay + this.previous.getTrackComplete() - mixDuration, 0);
3591
+ else delay = 0;
3592
+ }
3499
3593
  this.delay = delay;
3500
3594
  };
3501
3595
  _proto.reset = function reset() {
@@ -3718,17 +3812,17 @@ var CURRENT = 2;
3718
3812
 
3719
3813
  /******************************************************************************
3720
3814
  * Spine Runtimes License Agreement
3721
- * Last updated July 28, 2023. Replaces all prior versions.
3815
+ * Last updated April 5, 2025. Replaces all prior versions.
3722
3816
  *
3723
- * Copyright (c) 2013-2023, Esoteric Software LLC
3817
+ * Copyright (c) 2013-2025, Esoteric Software LLC
3724
3818
  *
3725
3819
  * Integration of the Spine Runtimes into software or otherwise creating
3726
3820
  * derivative works of the Spine Runtimes is permitted under the terms and
3727
3821
  * conditions of Section 2 of the Spine Editor License Agreement:
3728
3822
  * http://esotericsoftware.com/spine-editor-license
3729
3823
  *
3730
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
3731
- * otherwise create derivative works of the Spine Runtimes (collectively,
3824
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
3825
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
3732
3826
  * "Products"), provided that each user of the Products must obtain their own
3733
3827
  * Spine Editor license and redistribution of the Products in any form must
3734
3828
  * include this license and copyright notice.
@@ -3741,8 +3835,8 @@ var CURRENT = 2;
3741
3835
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
3742
3836
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
3743
3837
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3744
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
3745
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3838
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3839
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3746
3840
  *****************************************************************************/ /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. */ var AnimationStateData = /*#__PURE__*/ function() {
3747
3841
  function AnimationStateData(skeletonData) {
3748
3842
  this.animationToMixTime = {};
@@ -4194,7 +4288,7 @@ var TextureAtlasRegion = /*#__PURE__*/ function(TextureRegion) {
4194
4288
  this.copyTo(copy);
4195
4289
  copy.regionUVs = new Array(this.regionUVs.length);
4196
4290
  Utils.arrayCopy(this.regionUVs, 0, copy.regionUVs, 0, this.regionUVs.length);
4197
- copy.uvs = new Array(this.uvs.length);
4291
+ copy.uvs = _instanceof1(this.uvs, Float32Array) ? Utils.newFloatArray(this.uvs.length) : new Array(this.uvs.length);
4198
4292
  Utils.arrayCopy(this.uvs, 0, copy.uvs, 0, this.uvs.length);
4199
4293
  copy.triangles = new Array(this.triangles.length);
4200
4294
  Utils.arrayCopy(this.triangles, 0, copy.triangles, 0, this.triangles.length);
@@ -4858,17 +4952,17 @@ RegionAttachment.V4 = 31;
4858
4952
 
4859
4953
  /******************************************************************************
4860
4954
  * Spine Runtimes License Agreement
4861
- * Last updated July 28, 2023. Replaces all prior versions.
4955
+ * Last updated April 5, 2025. Replaces all prior versions.
4862
4956
  *
4863
- * Copyright (c) 2013-2023, Esoteric Software LLC
4957
+ * Copyright (c) 2013-2025, Esoteric Software LLC
4864
4958
  *
4865
4959
  * Integration of the Spine Runtimes into software or otherwise creating
4866
4960
  * derivative works of the Spine Runtimes is permitted under the terms and
4867
4961
  * conditions of Section 2 of the Spine Editor License Agreement:
4868
4962
  * http://esotericsoftware.com/spine-editor-license
4869
4963
  *
4870
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
4871
- * otherwise create derivative works of the Spine Runtimes (collectively,
4964
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
4965
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
4872
4966
  * "Products"), provided that each user of the Products must obtain their own
4873
4967
  * Spine Editor license and redistribution of the Products in any form must
4874
4968
  * include this license and copyright notice.
@@ -4881,8 +4975,8 @@ RegionAttachment.V4 = 31;
4881
4975
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
4882
4976
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
4883
4977
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4884
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
4885
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4978
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
4979
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4886
4980
  *****************************************************************************/ /** The base class for all constraint datas. */ var ConstraintData = function ConstraintData(name, order, skinRequired) {
4887
4981
  this.name = name;
4888
4982
  this.order = order;
@@ -4890,12 +4984,41 @@ RegionAttachment.V4 = 31;
4890
4984
  }
4891
4985
  ;
4892
4986
 
4987
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4988
+ try {
4989
+ var info = gen[key](arg);
4990
+ var value = info.value;
4991
+ } catch (error) {
4992
+ reject(error);
4993
+ return;
4994
+ }
4995
+ if (info.done) resolve(value);
4996
+ else Promise.resolve(value).then(_next, _throw);
4997
+ }
4998
+ function _async_to_generator(fn) {
4999
+ return function() {
5000
+ var self = this, args = arguments;
5001
+ return new Promise(function(resolve, reject) {
5002
+ var gen = fn.apply(self, args);
5003
+ function _next(value) {
5004
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
5005
+ }
5006
+ function _throw(err) {
5007
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
5008
+ }
5009
+ _next(undefined);
5010
+ });
5011
+ };
5012
+ }
5013
+
4893
5014
  var AssetManagerBase = /*#__PURE__*/ function() {
4894
5015
  function AssetManagerBase(textureLoader, pathPrefix, downloader) {
4895
5016
  if (pathPrefix === void 0) pathPrefix = "";
4896
5017
  if (downloader === void 0) downloader = new Downloader();
4897
5018
  this.pathPrefix = "";
4898
5019
  this.assets = {};
5020
+ this.assetsRefCount = {};
5021
+ this.assetsLoaded = {};
4899
5022
  this.errors = {};
4900
5023
  this.toLoad = 0;
4901
5024
  this.loaded = 0;
@@ -4912,6 +5035,7 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4912
5035
  this.toLoad--;
4913
5036
  this.loaded++;
4914
5037
  this.assets[path] = asset;
5038
+ this.assetsRefCount[path] = (this.assetsRefCount[path] || 0) + 1;
4915
5039
  if (callback) callback(path, asset);
4916
5040
  };
4917
5041
  _proto.error = function error(callback, path, message) {
@@ -4943,10 +5067,16 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4943
5067
  if (success === void 0) success = function() {};
4944
5068
  if (error === void 0) error = function() {};
4945
5069
  path = this.start(path);
4946
- this.downloader.downloadBinary(path, function(data) {
4947
- _this.success(success, path, data);
4948
- }, function(status, responseText) {
4949
- _this.error(error, path, "Couldn't load binary " + path + ": status " + status + ", " + responseText);
5070
+ if (this.reuseAssets(path, success, error)) return;
5071
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5072
+ _this.downloader.downloadBinary(path, function(data) {
5073
+ _this.success(success, path, data);
5074
+ resolve(data);
5075
+ }, function(status, responseText) {
5076
+ var errorMsg = "Couldn't load binary " + path + ": status " + status + ", " + responseText;
5077
+ _this.error(error, path, errorMsg);
5078
+ reject(errorMsg);
5079
+ });
4950
5080
  });
4951
5081
  };
4952
5082
  _proto.loadText = function loadText(path, success, error) {
@@ -4965,46 +5095,79 @@ var AssetManagerBase = /*#__PURE__*/ function() {
4965
5095
  if (success === void 0) success = function() {};
4966
5096
  if (error === void 0) error = function() {};
4967
5097
  path = this.start(path);
4968
- this.downloader.downloadJson(path, function(data) {
4969
- _this.success(success, path, data);
4970
- }, function(status, responseText) {
4971
- _this.error(error, path, "Couldn't load JSON " + path + ": status " + status + ", " + responseText);
5098
+ if (this.reuseAssets(path, success, error)) return;
5099
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5100
+ _this.downloader.downloadJson(path, function(data) {
5101
+ _this.success(success, path, data);
5102
+ resolve(data);
5103
+ }, function(status, responseText) {
5104
+ var errorMsg = "Couldn't load JSON " + path + ": status " + status + ", " + responseText;
5105
+ _this.error(error, path, errorMsg);
5106
+ reject(errorMsg);
5107
+ });
4972
5108
  });
4973
5109
  };
4974
- _proto.loadTexture = function loadTexture(path, success, error) {
5110
+ _proto.reuseAssets = function reuseAssets(path, success, error) {
4975
5111
  var _this = this;
4976
5112
  if (success === void 0) success = function() {};
4977
5113
  if (error === void 0) error = function() {};
4978
- path = this.start(path);
4979
- var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
4980
- var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
4981
- if (isWebWorker) {
4982
- fetch(path, {
4983
- mode: "cors"
4984
- }).then(function(response) {
4985
- if (response.ok) return response.blob();
4986
- _this.error(error, path, "Couldn't load image: " + path);
4987
- return null;
4988
- }).then(function(blob) {
4989
- return blob ? createImageBitmap(blob, {
4990
- premultiplyAlpha: "none",
4991
- colorSpaceConversion: "none"
4992
- }) : null;
4993
- }).then(function(bitmap) {
4994
- if (bitmap) _this.success(success, path, _this.textureLoader(bitmap));
5114
+ var loadedStatus = this.assetsLoaded[path];
5115
+ var alreadyExistsOrLoading = loadedStatus !== undefined;
5116
+ if (alreadyExistsOrLoading) {
5117
+ loadedStatus.then(function(data) {
5118
+ return _this.success(success, path, data);
5119
+ }).catch(function(errorMsg) {
5120
+ return _this.error(error, path, errorMsg);
4995
5121
  });
4996
- } else {
4997
- var image = new Image();
4998
- image.crossOrigin = "anonymous";
4999
- image.onload = function() {
5000
- _this.success(success, path, _this.textureLoader(image));
5001
- };
5002
- image.onerror = function() {
5003
- _this.error(error, path, "Couldn't load image: " + path);
5004
- };
5005
- if (this.downloader.rawDataUris[path]) path = this.downloader.rawDataUris[path];
5006
- image.src = path;
5007
5122
  }
5123
+ return alreadyExistsOrLoading;
5124
+ };
5125
+ _proto.loadTexture = function loadTexture(path, success, error) {
5126
+ var _this = this;
5127
+ if (success === void 0) success = function() {};
5128
+ if (error === void 0) error = function() {};
5129
+ path = this.start(path);
5130
+ if (this.reuseAssets(path, success, error)) return;
5131
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5132
+ var isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document);
5133
+ var isWebWorker = !isBrowser; // && typeof importScripts !== 'undefined';
5134
+ if (isWebWorker) {
5135
+ fetch(path, {
5136
+ mode: "cors"
5137
+ }).then(function(response) {
5138
+ if (response.ok) return response.blob();
5139
+ var errorMsg = "Couldn't load image: " + path;
5140
+ _this.error(error, path, "Couldn't load image: " + path);
5141
+ reject(errorMsg);
5142
+ }).then(function(blob) {
5143
+ return blob ? createImageBitmap(blob, {
5144
+ premultiplyAlpha: "none",
5145
+ colorSpaceConversion: "none"
5146
+ }) : null;
5147
+ }).then(function(bitmap) {
5148
+ if (bitmap) {
5149
+ var texture = _this.textureLoader(bitmap);
5150
+ _this.success(success, path, texture);
5151
+ resolve(texture);
5152
+ }
5153
+ });
5154
+ } else {
5155
+ var image = new Image();
5156
+ image.crossOrigin = "anonymous";
5157
+ image.onload = function() {
5158
+ var texture = _this.textureLoader(image);
5159
+ _this.success(success, path, texture);
5160
+ resolve(texture);
5161
+ };
5162
+ image.onerror = function() {
5163
+ var errorMsg = "Couldn't load image: " + path;
5164
+ _this.error(error, path, errorMsg);
5165
+ reject(errorMsg);
5166
+ };
5167
+ if (_this.downloader.rawDataUris[path]) path = _this.downloader.rawDataUris[path];
5168
+ image.src = path;
5169
+ }
5170
+ });
5008
5171
  };
5009
5172
  _proto.loadTextureAtlas = function loadTextureAtlas(path, success, error, fileAlias) {
5010
5173
  var _this = this;
@@ -5013,30 +5176,159 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5013
5176
  var index = path.lastIndexOf("/");
5014
5177
  var parent = index >= 0 ? path.substring(0, index + 1) : "";
5015
5178
  path = this.start(path);
5016
- this.downloader.downloadText(path, function(atlasText) {
5017
- try {
5018
- var _loop = function() {
5019
- var page = _step.value;
5020
- _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5021
- if (!abort) {
5022
- page.setTexture(texture);
5023
- if (--toLoad == 0) _this.success(success, path, atlas);
5024
- }
5025
- }, function(imagePath, message) {
5026
- if (!abort) _this.error(error, path, "Couldn't load texture atlas " + path + " page image: " + imagePath);
5027
- abort = true;
5028
- });
5029
- };
5030
- var atlas = new TextureAtlas(atlasText);
5031
- var toLoad = atlas.pages.length, abort = false;
5032
- for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5033
- } catch (e) {
5034
- _this.error(error, path, "Couldn't parse texture atlas " + path + ": " + e.message);
5035
- }
5036
- }, function(status, responseText) {
5037
- _this.error(error, path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText);
5179
+ if (this.reuseAssets(path, success, error)) return;
5180
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5181
+ _this.downloader.downloadText(path, function(atlasText) {
5182
+ try {
5183
+ var _loop = function() {
5184
+ var page = _step.value;
5185
+ _this.loadTexture(!fileAlias ? parent + page.name : fileAlias[page.name], function(imagePath, texture) {
5186
+ if (!abort) {
5187
+ page.setTexture(texture);
5188
+ if (--toLoad == 0) {
5189
+ _this.success(success, path, atlas);
5190
+ resolve(atlas);
5191
+ }
5192
+ }
5193
+ }, function(imagePath, message) {
5194
+ if (!abort) {
5195
+ var errorMsg = "Couldn't load texture atlas " + path + " page image: " + imagePath;
5196
+ _this.error(error, path, errorMsg);
5197
+ reject(errorMsg);
5198
+ }
5199
+ abort = true;
5200
+ });
5201
+ };
5202
+ var atlas = new TextureAtlas(atlasText);
5203
+ var toLoad = atlas.pages.length, abort = false;
5204
+ for(var _iterator = _create_for_of_iterator_helper_loose(atlas.pages), _step; !(_step = _iterator()).done;)_loop();
5205
+ } catch (e) {
5206
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5207
+ _this.error(error, path, errorMsg);
5208
+ reject(errorMsg);
5209
+ }
5210
+ }, function(status, responseText) {
5211
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5212
+ _this.error(error, path, errorMsg);
5213
+ reject(errorMsg);
5214
+ });
5038
5215
  });
5039
5216
  };
5217
+ _proto.loadTextureAtlasButNoTextures = function loadTextureAtlasButNoTextures(path, success, error, fileAlias) {
5218
+ var _this = this;
5219
+ if (success === void 0) success = function() {};
5220
+ if (error === void 0) error = function() {};
5221
+ path = this.start(path);
5222
+ if (this.reuseAssets(path, success, error)) return;
5223
+ this.assetsLoaded[path] = new Promise(function(resolve, reject) {
5224
+ _this.downloader.downloadText(path, function(atlasText) {
5225
+ try {
5226
+ var atlas = new TextureAtlas(atlasText);
5227
+ _this.success(success, path, atlas);
5228
+ resolve(atlas);
5229
+ } catch (e) {
5230
+ var errorMsg = "Couldn't parse texture atlas " + path + ": " + e.message;
5231
+ _this.error(error, path, errorMsg);
5232
+ reject(errorMsg);
5233
+ }
5234
+ }, function(status, responseText) {
5235
+ var errorMsg = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText;
5236
+ _this.error(error, path, errorMsg);
5237
+ reject(errorMsg);
5238
+ });
5239
+ });
5240
+ };
5241
+ // Promisified versions of load function
5242
+ _proto.loadBinaryAsync = function loadBinaryAsync(path) {
5243
+ return _async_to_generator(function() {
5244
+ var _this;
5245
+ return __generator(this, function(_state) {
5246
+ _this = this;
5247
+ return [
5248
+ 2,
5249
+ new Promise(function(resolve, reject) {
5250
+ _this.loadBinary(path, function(_, binary) {
5251
+ return resolve(binary);
5252
+ }, function(_, message) {
5253
+ return reject(message);
5254
+ });
5255
+ })
5256
+ ];
5257
+ });
5258
+ }).call(this);
5259
+ };
5260
+ _proto.loadJsonAsync = function loadJsonAsync(path) {
5261
+ return _async_to_generator(function() {
5262
+ var _this;
5263
+ return __generator(this, function(_state) {
5264
+ _this = this;
5265
+ return [
5266
+ 2,
5267
+ new Promise(function(resolve, reject) {
5268
+ _this.loadJson(path, function(_, object) {
5269
+ return resolve(object);
5270
+ }, function(_, message) {
5271
+ return reject(message);
5272
+ });
5273
+ })
5274
+ ];
5275
+ });
5276
+ }).call(this);
5277
+ };
5278
+ _proto.loadTextureAsync = function loadTextureAsync(path) {
5279
+ return _async_to_generator(function() {
5280
+ var _this;
5281
+ return __generator(this, function(_state) {
5282
+ _this = this;
5283
+ return [
5284
+ 2,
5285
+ new Promise(function(resolve, reject) {
5286
+ _this.loadTexture(path, function(_, texture) {
5287
+ return resolve(texture);
5288
+ }, function(_, message) {
5289
+ return reject(message);
5290
+ });
5291
+ })
5292
+ ];
5293
+ });
5294
+ }).call(this);
5295
+ };
5296
+ _proto.loadTextureAtlasAsync = function loadTextureAtlasAsync(path) {
5297
+ return _async_to_generator(function() {
5298
+ var _this;
5299
+ return __generator(this, function(_state) {
5300
+ _this = this;
5301
+ return [
5302
+ 2,
5303
+ new Promise(function(resolve, reject) {
5304
+ _this.loadTextureAtlas(path, function(_, atlas) {
5305
+ return resolve(atlas);
5306
+ }, function(_, message) {
5307
+ return reject(message);
5308
+ });
5309
+ })
5310
+ ];
5311
+ });
5312
+ }).call(this);
5313
+ };
5314
+ _proto.loadTextureAtlasButNoTexturesAsync = function loadTextureAtlasButNoTexturesAsync(path) {
5315
+ return _async_to_generator(function() {
5316
+ var _this;
5317
+ return __generator(this, function(_state) {
5318
+ _this = this;
5319
+ return [
5320
+ 2,
5321
+ new Promise(function(resolve, reject) {
5322
+ _this.loadTextureAtlasButNoTextures(path, function(_, atlas) {
5323
+ return resolve(atlas);
5324
+ }, function(_, message) {
5325
+ return reject(message);
5326
+ });
5327
+ })
5328
+ ];
5329
+ });
5330
+ }).call(this);
5331
+ };
5040
5332
  _proto.get = function get(path) {
5041
5333
  return this.assets[this.pathPrefix + path];
5042
5334
  };
@@ -5052,14 +5344,18 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5052
5344
  var asset = this.assets[path];
5053
5345
  if (asset.dispose) asset.dispose();
5054
5346
  delete this.assets[path];
5347
+ delete this.assetsRefCount[path];
5348
+ delete this.assetsLoaded[path];
5055
5349
  return asset;
5056
5350
  };
5057
5351
  _proto.removeAll = function removeAll() {
5058
- for(var key in this.assets){
5059
- var asset = this.assets[key];
5352
+ for(var path in this.assets){
5353
+ var asset = this.assets[path];
5060
5354
  if (asset.dispose) asset.dispose();
5061
5355
  }
5062
5356
  this.assets = {};
5357
+ this.assetsLoaded = {};
5358
+ this.assetsRefCount = {};
5063
5359
  };
5064
5360
  _proto.isLoadingComplete = function isLoadingComplete() {
5065
5361
  return this.toLoad == 0;
@@ -5073,6 +5369,12 @@ var AssetManagerBase = /*#__PURE__*/ function() {
5073
5369
  _proto.dispose = function dispose() {
5074
5370
  this.removeAll();
5075
5371
  };
5372
+ // dispose asset only if it's not used by others
5373
+ _proto.disposeAsset = function disposeAsset(path) {
5374
+ if (--this.assetsRefCount[path] === 0) {
5375
+ this.remove(path);
5376
+ }
5377
+ };
5076
5378
  _proto.hasErrors = function hasErrors() {
5077
5379
  return Object.keys(this.errors).length > 0;
5078
5380
  };
@@ -5120,10 +5422,11 @@ var Downloader = /*#__PURE__*/ function() {
5120
5422
  _proto.downloadText = function downloadText(url, success, error) {
5121
5423
  var _this = this;
5122
5424
  if (this.start(url, success, error)) return;
5123
- if (this.rawDataUris[url]) {
5425
+ var rawDataUri = this.rawDataUris[url];
5426
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5427
+ if (rawDataUri && !rawDataUri.includes(".")) {
5124
5428
  try {
5125
- var dataUri = this.rawDataUris[url];
5126
- this.finish(url, 200, this.dataUriToString(dataUri));
5429
+ this.finish(url, 200, this.dataUriToString(rawDataUri));
5127
5430
  } catch (e) {
5128
5431
  this.finish(url, 400, JSON.stringify(e));
5129
5432
  }
@@ -5131,7 +5434,7 @@ var Downloader = /*#__PURE__*/ function() {
5131
5434
  }
5132
5435
  var request = new XMLHttpRequest();
5133
5436
  request.overrideMimeType("text/html");
5134
- request.open("GET", url, true);
5437
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5135
5438
  var done = function() {
5136
5439
  _this.finish(url, request.status, request.responseText);
5137
5440
  };
@@ -5147,17 +5450,18 @@ var Downloader = /*#__PURE__*/ function() {
5147
5450
  _proto.downloadBinary = function downloadBinary(url, success, error) {
5148
5451
  var _this = this;
5149
5452
  if (this.start(url, success, error)) return;
5150
- if (this.rawDataUris[url]) {
5453
+ var rawDataUri = this.rawDataUris[url];
5454
+ // we assume if a "." is included in a raw data uri, it is used to rewrite an asset URL
5455
+ if (rawDataUri && !rawDataUri.includes(".")) {
5151
5456
  try {
5152
- var dataUri = this.rawDataUris[url];
5153
- this.finish(url, 200, this.dataUriToUint8Array(dataUri));
5457
+ this.finish(url, 200, this.dataUriToUint8Array(rawDataUri));
5154
5458
  } catch (e) {
5155
5459
  this.finish(url, 400, JSON.stringify(e));
5156
5460
  }
5157
5461
  return;
5158
5462
  }
5159
5463
  var request = new XMLHttpRequest();
5160
- request.open("GET", url, true);
5464
+ request.open("GET", rawDataUri ? rawDataUri : url, true);
5161
5465
  request.responseType = "arraybuffer";
5162
5466
  var onerror = function() {
5163
5467
  _this.finish(url, request.status, request.response);
@@ -5195,17 +5499,17 @@ var Downloader = /*#__PURE__*/ function() {
5195
5499
 
5196
5500
  /******************************************************************************
5197
5501
  * Spine Runtimes License Agreement
5198
- * Last updated July 28, 2023. Replaces all prior versions.
5502
+ * Last updated April 5, 2025. Replaces all prior versions.
5199
5503
  *
5200
- * Copyright (c) 2013-2023, Esoteric Software LLC
5504
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5201
5505
  *
5202
5506
  * Integration of the Spine Runtimes into software or otherwise creating
5203
5507
  * derivative works of the Spine Runtimes is permitted under the terms and
5204
5508
  * conditions of Section 2 of the Spine Editor License Agreement:
5205
5509
  * http://esotericsoftware.com/spine-editor-license
5206
5510
  *
5207
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5208
- * otherwise create derivative works of the Spine Runtimes (collectively,
5511
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5512
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5209
5513
  * "Products"), provided that each user of the Products must obtain their own
5210
5514
  * Spine Editor license and redistribution of the Products in any form must
5211
5515
  * include this license and copyright notice.
@@ -5218,8 +5522,8 @@ var Downloader = /*#__PURE__*/ function() {
5218
5522
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5219
5523
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5220
5524
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5221
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5222
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5525
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5526
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5223
5527
  *****************************************************************************/ /** Stores the current pose values for an {@link Event}.
5224
5528
  *
5225
5529
  * See Timeline {@link Timeline#apply()},
@@ -5239,17 +5543,17 @@ var Downloader = /*#__PURE__*/ function() {
5239
5543
 
5240
5544
  /******************************************************************************
5241
5545
  * Spine Runtimes License Agreement
5242
- * Last updated July 28, 2023. Replaces all prior versions.
5546
+ * Last updated April 5, 2025. Replaces all prior versions.
5243
5547
  *
5244
- * Copyright (c) 2013-2023, Esoteric Software LLC
5548
+ * Copyright (c) 2013-2025, Esoteric Software LLC
5245
5549
  *
5246
5550
  * Integration of the Spine Runtimes into software or otherwise creating
5247
5551
  * derivative works of the Spine Runtimes is permitted under the terms and
5248
5552
  * conditions of Section 2 of the Spine Editor License Agreement:
5249
5553
  * http://esotericsoftware.com/spine-editor-license
5250
5554
  *
5251
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
5252
- * otherwise create derivative works of the Spine Runtimes (collectively,
5555
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
5556
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
5253
5557
  * "Products"), provided that each user of the Products must obtain their own
5254
5558
  * Spine Editor license and redistribution of the Products in any form must
5255
5559
  * include this license and copyright notice.
@@ -5262,8 +5566,8 @@ var Downloader = /*#__PURE__*/ function() {
5262
5566
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
5263
5567
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
5264
5568
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5265
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
5266
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5569
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5570
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5267
5571
  *****************************************************************************/ /** Stores the setup pose values for an {@link Event}.
5268
5572
  *
5269
5573
  * See [Events](http://esotericsoftware.com/spine-events) in the Spine User Guide. */ var EventData = function EventData(name) {
@@ -6123,7 +6427,7 @@ PathConstraint.epsilon = 0.00001;
6123
6427
  }
6124
6428
  if (a >= t) {
6125
6429
  d = Math.pow(this.damping, 60 * t);
6126
- var m = this.massInverse * t, e = this.strength, w = this.wind * f, g = (Skeleton.yDown ? -this.gravity : this.gravity) * f;
6430
+ var m = this.massInverse * t, e = this.strength, w = this.wind * f * skeleton.scaleX, g = this.gravity * f * skeleton.scaleY;
6127
6431
  do {
6128
6432
  if (x) {
6129
6433
  this.xVelocity += (w - this.xOffset * e) * m;
@@ -6965,10 +7269,10 @@ PathConstraint.epsilon = 0.00001;
6965
7269
  })) != null ? _this_physicsConstraints_find : null;
6966
7270
  };
6967
7271
  /** 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 }`.
6968
- * 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() {
7272
+ * 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) {
6969
7273
  var offset = new Vector2();
6970
7274
  var size = new Vector2();
6971
- this.getBounds(offset, size);
7275
+ this.getBounds(offset, size, undefined, clipper);
6972
7276
  return {
6973
7277
  x: offset.x,
6974
7278
  y: offset.y,
@@ -7097,17 +7401,17 @@ Skeleton.yDown = false;
7097
7401
 
7098
7402
  /******************************************************************************
7099
7403
  * Spine Runtimes License Agreement
7100
- * Last updated July 28, 2023. Replaces all prior versions.
7404
+ * Last updated April 5, 2025. Replaces all prior versions.
7101
7405
  *
7102
- * Copyright (c) 2013-2023, Esoteric Software LLC
7406
+ * Copyright (c) 2013-2025, Esoteric Software LLC
7103
7407
  *
7104
7408
  * Integration of the Spine Runtimes into software or otherwise creating
7105
7409
  * derivative works of the Spine Runtimes is permitted under the terms and
7106
7410
  * conditions of Section 2 of the Spine Editor License Agreement:
7107
7411
  * http://esotericsoftware.com/spine-editor-license
7108
7412
  *
7109
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
7110
- * otherwise create derivative works of the Spine Runtimes (collectively,
7413
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
7414
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
7111
7415
  * "Products"), provided that each user of the Products must obtain their own
7112
7416
  * Spine Editor license and redistribution of the Products in any form must
7113
7417
  * include this license and copyright notice.
@@ -7120,18 +7424,16 @@ Skeleton.yDown = false;
7120
7424
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
7121
7425
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
7122
7426
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7123
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
7124
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7427
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
7428
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7125
7429
  *****************************************************************************/ /** Stores the setup pose and all of the stateless data for a skeleton.
7126
7430
  *
7127
7431
  * See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes
7128
7432
  * Guide. */ var SkeletonData = /*#__PURE__*/ function() {
7129
7433
  function SkeletonData() {
7130
7434
  /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ this.name = null;
7131
- /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array() // Ordered parents first.
7132
- ;
7133
- /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array() // Setup pose draw order.
7134
- ;
7435
+ /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */ this.bones = new Array(); // Ordered parents first.
7436
+ /** The skeleton's slots in the setup pose draw order. */ this.slots = new Array(); // Setup pose draw order.
7135
7437
  this.skins = new Array();
7136
7438
  /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.
7137
7439
  *
@@ -7274,8 +7576,7 @@ Skeleton.yDown = false;
7274
7576
  this.attachments = new Array();
7275
7577
  this.bones = Array();
7276
7578
  this.constraints = new Array();
7277
- /** 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
7278
- ;
7579
+ /** 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
7279
7580
  if (!name) throw new Error("name cannot be null.");
7280
7581
  this.name = name;
7281
7582
  }
@@ -10433,17 +10734,17 @@ function getValue(map, property, defaultValue) {
10433
10734
 
10434
10735
  /******************************************************************************
10435
10736
  * Spine Runtimes License Agreement
10436
- * Last updated July 28, 2023. Replaces all prior versions.
10737
+ * Last updated April 5, 2025. Replaces all prior versions.
10437
10738
  *
10438
- * Copyright (c) 2013-2023, Esoteric Software LLC
10739
+ * Copyright (c) 2013-2025, Esoteric Software LLC
10439
10740
  *
10440
10741
  * Integration of the Spine Runtimes into software or otherwise creating
10441
10742
  * derivative works of the Spine Runtimes is permitted under the terms and
10442
10743
  * conditions of Section 2 of the Spine Editor License Agreement:
10443
10744
  * http://esotericsoftware.com/spine-editor-license
10444
10745
  *
10445
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
10446
- * otherwise create derivative works of the Spine Runtimes (collectively,
10746
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
10747
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
10447
10748
  * "Products"), provided that each user of the Products must obtain their own
10448
10749
  * Spine Editor license and redistribution of the Products in any form must
10449
10750
  * include this license and copyright notice.
@@ -10456,8 +10757,8 @@ function getValue(map, property, defaultValue) {
10456
10757
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
10457
10758
  * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
10458
10759
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
10459
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
10460
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10760
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
10761
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10461
10762
  *****************************************************************************/ (function() {
10462
10763
  if (typeof Math.fround === "undefined") {
10463
10764
  Math.fround = function(array) {
@@ -10606,55 +10907,6 @@ function getValue(map, property, defaultValue) {
10606
10907
  return LoaderUtils;
10607
10908
  }();
10608
10909
 
10609
- var SourceAlpha = BlendFactor.SourceAlpha, One = BlendFactor.One, DestinationColor = BlendFactor.DestinationColor, Zero = BlendFactor.Zero, OneMinusSourceColor = BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = BlendFactor.OneMinusSourceAlpha;
10610
- var Add = BlendOperation.Add;
10611
- function setBlendMode(material, blendMode, premultipliedAlpha) {
10612
- var target = material.renderState.blendState.targetBlendState;
10613
- switch(blendMode){
10614
- case BlendMode.Additive:
10615
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10616
- target.destinationColorBlendFactor = One;
10617
- target.sourceAlphaBlendFactor = One;
10618
- target.destinationAlphaBlendFactor = One;
10619
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10620
- break;
10621
- case BlendMode.Multiply:
10622
- target.sourceColorBlendFactor = DestinationColor;
10623
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10624
- target.sourceAlphaBlendFactor = One;
10625
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10626
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10627
- break;
10628
- case BlendMode.Screen:
10629
- target.sourceColorBlendFactor = One;
10630
- target.destinationColorBlendFactor = OneMinusSourceColor;
10631
- target.sourceAlphaBlendFactor = One;
10632
- target.destinationAlphaBlendFactor = OneMinusSourceColor;
10633
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10634
- break;
10635
- default:
10636
- target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10637
- target.destinationColorBlendFactor = OneMinusSourceAlpha;
10638
- target.sourceAlphaBlendFactor = One;
10639
- target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
10640
- target.colorBlendOperation = target.alphaBlendOperation = Add;
10641
- break;
10642
- }
10643
- }
10644
- function getBlendMode(material) {
10645
- var target = material.renderState.blendState.targetBlendState;
10646
- if (target.sourceColorBlendFactor === SourceAlpha && target.destinationColorBlendFactor === One && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === One && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10647
- return BlendMode.Additive;
10648
- }
10649
- if (target.sourceColorBlendFactor === DestinationColor && target.destinationColorBlendFactor === Zero && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === Zero && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10650
- return BlendMode.Multiply;
10651
- }
10652
- if (target.sourceColorBlendFactor === One && target.destinationColorBlendFactor === OneMinusSourceColor && target.sourceAlphaBlendFactor === One && target.destinationAlphaBlendFactor === OneMinusSourceColor && target.colorBlendOperation === Add && target.alphaBlendOperation === Add) {
10653
- return BlendMode.Screen;
10654
- }
10655
- return BlendMode.Normal;
10656
- }
10657
-
10658
10910
  var ClearablePool = /*#__PURE__*/ function() {
10659
10911
  function ClearablePool(type) {
10660
10912
  this._usedElementCount = 0;
@@ -10715,11 +10967,11 @@ var SubRenderItem = function SubRenderItem() {
10715
10967
  }
10716
10968
  var _proto = SpineGenerator.prototype;
10717
10969
  _proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
10718
- 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;
10970
+ 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;
10719
10971
  _localBounds.min.set(Infinity, Infinity, Infinity);
10720
10972
  _localBounds.max.set(-Infinity, -Infinity, -Infinity);
10721
10973
  var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
10722
- var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, VERTEX_SIZE = SpineGenerator.VERTEX_SIZE;
10974
+ var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, vertexStrideWithTint = SpineGenerator.vertexStrideWithTint, vertexStrideWithoutTint = SpineGenerator.vertexStrideWithoutTint;
10723
10975
  _subRenderItems.length = 0;
10724
10976
  subRenderItemPool.clear();
10725
10977
  var triangles;
@@ -10749,13 +11001,28 @@ var SubRenderItem = function SubRenderItem() {
10749
11001
  var isClipping = _clipper.isClipping();
10750
11002
  var numFloats = 0;
10751
11003
  var attachmentColor = null;
10752
- var vertexSize = isClipping ? 2 : VERTEX_SIZE;
11004
+ // This vertexSize will be passed to spine-core's computeWorldVertices function.
11005
+ //
11006
+ // Expected format by computeWorldVertices:
11007
+ // - Without tintBlack: [x, y, u, v, r, g, b, a] = 8 components
11008
+ // - With tintBlack: [x, y, u, v, r, g, b, a, dr, dg, db, da] = 12 components
11009
+ //
11010
+ // Our actual vertex buffer format:
11011
+ // - vertexStrideWithoutTint: [x, y, z, u, v, r, g, b, a] = 9 components
11012
+ // - vertexStrideWithTint: [x, y, z, u, v, r, g, b, a, dr, dg, db] = 12 components
11013
+ // (Note: we optimized 'da' as uniform instead of buffer attribute)
11014
+ //
11015
+ // Calculation:
11016
+ // - Without tintBlack: 9 - 1 (remove z) = 8 ✓
11017
+ // - With tintBlack: 12 - 1 (remove z) + 1 (add back da) = 12 ✓
11018
+ var vertexSize = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint - 1;
11019
+ var clippedVertexSize = isClipping ? 2 : vertexSize;
10753
11020
  switch(attachment.constructor){
10754
11021
  case RegionAttachment:
10755
11022
  var regionAttachment = attachment;
10756
11023
  attachmentColor = regionAttachment.color;
10757
- numFloats = vertexSize * 4;
10758
- regionAttachment.computeWorldVertices(slot, tempVerts, 0, vertexSize);
11024
+ numFloats = clippedVertexSize << 2;
11025
+ regionAttachment.computeWorldVertices(slot, tempVerts, 0, clippedVertexSize);
10759
11026
  triangles = SpineGenerator.QUAD_TRIANGLES;
10760
11027
  uvs = regionAttachment.uvs;
10761
11028
  texture = regionAttachment.region.texture;
@@ -10763,11 +11030,11 @@ var SubRenderItem = function SubRenderItem() {
10763
11030
  case MeshAttachment:
10764
11031
  var meshAttachment = attachment;
10765
11032
  attachmentColor = meshAttachment.color;
10766
- numFloats = (meshAttachment.worldVerticesLength >> 1) * vertexSize;
11033
+ numFloats = (meshAttachment.worldVerticesLength >> 1) * clippedVertexSize;
10767
11034
  if (numFloats > _vertices.length) {
10768
11035
  SpineGenerator.tempVerts = new Array(numFloats);
10769
11036
  }
10770
- meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, vertexSize);
11037
+ meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, clippedVertexSize);
10771
11038
  triangles = meshAttachment.triangles;
10772
11039
  uvs = meshAttachment.uvs;
10773
11040
  texture = meshAttachment.region.texture;
@@ -10799,8 +11066,21 @@ var SubRenderItem = function SubRenderItem() {
10799
11066
  finalColor.g *= finalAlpha;
10800
11067
  finalColor.b *= finalAlpha;
10801
11068
  }
11069
+ var darkColor = SpineGenerator.tempDark;
11070
+ var slotDarkColor = slot.darkColor;
11071
+ if (!slotDarkColor) {
11072
+ darkColor.set(0, 0, 0, 1);
11073
+ } else {
11074
+ if (premultipliedAlpha) {
11075
+ darkColor.r = slotDarkColor.r * finalAlpha;
11076
+ darkColor.g = slotDarkColor.g * finalAlpha;
11077
+ darkColor.b = slotDarkColor.b * finalAlpha;
11078
+ } else {
11079
+ darkColor.setFromColor(slotDarkColor);
11080
+ }
11081
+ }
10802
11082
  if (isClipping) {
10803
- _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, SpineGenerator.tempDark, false);
11083
+ _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, darkColor, tintBlack);
10804
11084
  finalVertices = _clipper.clippedVertices;
10805
11085
  finalVerticesLength = finalVertices.length;
10806
11086
  finalIndices = _clipper.clippedTriangles;
@@ -10814,6 +11094,12 @@ var SubRenderItem = function SubRenderItem() {
10814
11094
  tempVerts[v + 3] = a;
10815
11095
  tempVerts[v + 4] = uvs[u];
10816
11096
  tempVerts[v + 5] = uvs[u + 1];
11097
+ if (tintBlack) {
11098
+ tempVerts[v + 6] = darkColor.r;
11099
+ tempVerts[v + 7] = darkColor.g;
11100
+ tempVerts[v + 8] = darkColor.b;
11101
+ tempVerts[v + 9] = darkColor.a;
11102
+ }
10817
11103
  }
10818
11104
  finalVertices = tempVerts;
10819
11105
  finalVerticesLength = numFloats;
@@ -10824,7 +11110,8 @@ var SubRenderItem = function SubRenderItem() {
10824
11110
  _clipper.clipEndWithSlot(slot);
10825
11111
  continue;
10826
11112
  }
10827
- var indexStart = verticesLength / SpineGenerator.VERTEX_STRIDE;
11113
+ var stride = tintBlack ? vertexStrideWithTint : vertexStrideWithoutTint;
11114
+ var indexStart = verticesLength / stride;
10828
11115
  var i = verticesLength;
10829
11116
  var j = 0;
10830
11117
  for(; j < finalVerticesLength;){
@@ -10833,12 +11120,18 @@ var SubRenderItem = function SubRenderItem() {
10833
11120
  _vertices[i++] = x;
10834
11121
  _vertices[i++] = y;
10835
11122
  _vertices[i++] = z;
10836
- _vertices[i++] = finalVertices[j++];
10837
- _vertices[i++] = finalVertices[j++];
10838
- _vertices[i++] = finalVertices[j++];
10839
- _vertices[i++] = finalVertices[j++];
10840
- _vertices[i++] = finalVertices[j++];
10841
- _vertices[i++] = finalVertices[j++];
11123
+ _vertices[i++] = finalVertices[j++]; // u
11124
+ _vertices[i++] = finalVertices[j++]; // v
11125
+ _vertices[i++] = finalVertices[j++]; // r
11126
+ _vertices[i++] = finalVertices[j++]; // g
11127
+ _vertices[i++] = finalVertices[j++]; // b
11128
+ _vertices[i++] = finalVertices[j++]; // a
11129
+ if (tintBlack) {
11130
+ _vertices[i++] = finalVertices[j++]; // darkR
11131
+ _vertices[i++] = finalVertices[j++]; // darkG
11132
+ _vertices[i++] = finalVertices[j++]; // darkB
11133
+ j++; // darkA
11134
+ }
10842
11135
  this._expandBounds(x, y, z, _localBounds);
10843
11136
  }
10844
11137
  verticesLength = i;
@@ -10895,22 +11188,17 @@ var SubRenderItem = function SubRenderItem() {
10895
11188
  subPrimitivePool.return(item);
10896
11189
  }
10897
11190
  renderer._clearSubPrimitives();
10898
- var materialCache = SpineAnimationRenderer._materialCache;
10899
11191
  for(var i2 = 0, l = curLen; i2 < l; ++i2){
10900
11192
  var item1 = _subRenderItems[i2];
10901
11193
  var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
10902
11194
  renderer._addSubPrimitive(item1.subPrimitive);
10903
11195
  var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
10904
- var key = subTexture.instanceId + "_" + blendMode + "_" + premultipliedAlpha;
10905
- var material = materialCache.get(key);
10906
- if (!material) {
10907
- material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
10908
- materialCache.set(key, material);
10909
- }
11196
+ var material = renderer._getMaterial(subTexture, blendMode);
10910
11197
  renderer.setMaterial(i2, material);
10911
11198
  }
10912
- if (indicesLength > _vertexCount) {
11199
+ if (indicesLength > _vertexCount || renderer._needResizeBuffer) {
10913
11200
  renderer._createAndBindBuffer(indicesLength);
11201
+ renderer._needResizeBuffer = false;
10914
11202
  this.buildPrimitive(skeleton, renderer);
10915
11203
  return;
10916
11204
  }
@@ -10925,12 +11213,6 @@ var SubRenderItem = function SubRenderItem() {
10925
11213
  _proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
10926
11214
  this._separateSlotTextureMap.set(slotName, texture);
10927
11215
  };
10928
- _proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
10929
- var material = SpineAnimationRenderer._getDefaultMaterial(engine);
10930
- material.shaderData.setTexture("material_SpineTexture", texture);
10931
- setBlendMode(material, blendMode, premultipliedAlpha);
10932
- return material;
10933
- };
10934
11216
  _proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
10935
11217
  var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
10936
11218
  var origin = subPrimitives[primitiveIndex];
@@ -10955,8 +11237,8 @@ var SubRenderItem = function SubRenderItem() {
10955
11237
  };
10956
11238
  return SpineGenerator;
10957
11239
  }();
10958
- SpineGenerator.VERTEX_SIZE = 8;
10959
- SpineGenerator.VERTEX_STRIDE = 9;
11240
+ SpineGenerator.vertexStrideWithoutTint = 9;
11241
+ SpineGenerator.vertexStrideWithTint = 12;
10960
11242
  SpineGenerator.tempDark = new Color();
10961
11243
  SpineGenerator.tempColor = new Color();
10962
11244
  SpineGenerator.tempVerts = new Array(8);
@@ -10971,25 +11253,92 @@ SpineGenerator.QUAD_TRIANGLES = [
10971
11253
  SpineGenerator.subPrimitivePool = new ReturnablePool(SubPrimitive);
10972
11254
  SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
10973
11255
 
11256
+ var SourceAlpha = BlendFactor.SourceAlpha, One = BlendFactor.One, DestinationColor = BlendFactor.DestinationColor, OneMinusSourceColor = BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = BlendFactor.OneMinusSourceAlpha;
11257
+ var Add = BlendOperation.Add;
10974
11258
  var SpineMaterial = /*#__PURE__*/ function(Material) {
10975
11259
  _inherits(SpineMaterial, Material);
10976
11260
  function SpineMaterial(engine) {
10977
11261
  var _this;
10978
11262
  var shader = Shader.find("galacean-spine-shader") || Shader.create("galacean-spine-shader", SpineMaterial._spineVS, SpineMaterial._spineFS);
10979
- _this = Material.call(this, engine, shader) || this;
11263
+ _this = Material.call(this, engine, shader) || this, _this._blendMode = BlendMode.Normal;
10980
11264
  var renderState = _this.renderState;
10981
11265
  var target = renderState.blendState.targetBlendState;
10982
11266
  target.enabled = true;
10983
- setBlendMode(_this, BlendMode.Normal, false);
11267
+ _this._setBlendMode(BlendMode.Normal, false);
10984
11268
  renderState.depthState.writeEnabled = false;
10985
11269
  renderState.rasterState.cullMode = CullMode.Off;
10986
11270
  renderState.renderQueueType = RenderQueueType.Transparent;
10987
11271
  return _this;
10988
11272
  }
11273
+ var _proto = SpineMaterial.prototype;
11274
+ /**
11275
+ * @internal
11276
+ */ _proto._setTintBlack = function _setTintBlack(enabled) {
11277
+ if (enabled) {
11278
+ this.shaderData.enableMacro("RENDERER_TINT_BLACK");
11279
+ } else {
11280
+ this.shaderData.disableMacro("RENDERER_TINT_BLACK");
11281
+ }
11282
+ };
11283
+ /**
11284
+ * @internal
11285
+ */ _proto._setPremultipliedAlpha = function _setPremultipliedAlpha(enabled) {
11286
+ if (enabled) {
11287
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 1);
11288
+ } else {
11289
+ this.shaderData.setFloat("renderer_PremultipliedAlpha", 0);
11290
+ }
11291
+ };
11292
+ /**
11293
+ * @internal
11294
+ */ _proto._setTexture = function _setTexture(value) {
11295
+ this.shaderData.setTexture("material_SpineTexture", value);
11296
+ };
11297
+ /**
11298
+ * @internal
11299
+ */ _proto._setBlendMode = function _setBlendMode(blendMode, premultipliedAlpha) {
11300
+ var target = this.renderState.blendState.targetBlendState;
11301
+ this._blendMode = blendMode;
11302
+ switch(blendMode){
11303
+ case BlendMode.Additive:
11304
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11305
+ target.destinationColorBlendFactor = One;
11306
+ target.sourceAlphaBlendFactor = One;
11307
+ target.destinationAlphaBlendFactor = One;
11308
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11309
+ break;
11310
+ case BlendMode.Multiply:
11311
+ target.sourceColorBlendFactor = DestinationColor;
11312
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11313
+ target.sourceAlphaBlendFactor = One;
11314
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11315
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11316
+ break;
11317
+ case BlendMode.Screen:
11318
+ target.sourceColorBlendFactor = One;
11319
+ target.destinationColorBlendFactor = OneMinusSourceColor;
11320
+ target.sourceAlphaBlendFactor = One;
11321
+ target.destinationAlphaBlendFactor = OneMinusSourceColor;
11322
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11323
+ break;
11324
+ default:
11325
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
11326
+ target.destinationColorBlendFactor = OneMinusSourceAlpha;
11327
+ target.sourceAlphaBlendFactor = One;
11328
+ target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
11329
+ target.colorBlendOperation = target.alphaBlendOperation = Add;
11330
+ break;
11331
+ }
11332
+ };
11333
+ /**
11334
+ * @internal
11335
+ */ _proto._getBlendMode = function _getBlendMode() {
11336
+ return this._blendMode;
11337
+ };
10989
11338
  return SpineMaterial;
10990
11339
  }(Material);
10991
- 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 ";
10992
- 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 ";
11340
+ 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 ";
11341
+ 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 ";
10993
11342
 
10994
11343
  /**
10995
11344
  * Spine animation renderer, capable of rendering spine animations and providing functions for animation and skeleton manipulation.
@@ -11004,15 +11353,16 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11004
11353
  * When enabled, vertex color values are multiplied by the alpha channel.
11005
11354
  * @remarks
11006
11355
  If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
11007
- */ _this.premultipliedAlpha = false, /**
11356
+ */ _this.premultipliedAlpha = false, _this._tintBlack = false, /**
11008
11357
  * Default state for spine animation.
11009
11358
  * Contains the default animation name to be played, whether this animation should loop, the default skin name.
11010
11359
  */ _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 BoundingBox(new Vector3(Infinity, Infinity, Infinity), new Vector3(-Infinity, -Infinity, -Infinity));
11011
11360
  var primitive = new Primitive(_this._engine);
11012
11361
  _this._primitive = primitive;
11013
11362
  primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
11014
- primitive.addVertexElement(SpineAnimationRenderer._colorVertexElement);
11363
+ primitive.addVertexElement(SpineAnimationRenderer._lightColorVertexElement);
11015
11364
  primitive.addVertexElement(SpineAnimationRenderer._uvVertexElement);
11365
+ primitive.addVertexElement(SpineAnimationRenderer._darkColorVertexElement);
11016
11366
  return _this;
11017
11367
  }
11018
11368
  var _proto = SpineAnimationRenderer.prototype;
@@ -11106,9 +11456,10 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11106
11456
  */ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
11107
11457
  var _this = this, _engine = _this._engine, _primitive = _this._primitive;
11108
11458
  this._vertexCount = vertexCount;
11109
- this._vertices = new Float32Array(vertexCount * SpineGenerator.VERTEX_STRIDE);
11459
+ var stride = this.tintBlack ? SpineGenerator.vertexStrideWithTint : SpineGenerator.vertexStrideWithoutTint;
11460
+ this._vertices = new Float32Array(vertexCount * stride);
11110
11461
  this._indices = new Uint16Array(vertexCount);
11111
- var vertexStride = SpineGenerator.VERTEX_STRIDE * 4;
11462
+ var vertexStride = stride << 2;
11112
11463
  var vertexBuffer = new Buffer(_engine, BufferBindFlag.VertexBuffer, this._vertices, BufferUsage.Dynamic);
11113
11464
  var indexBuffer = new Buffer(_engine, BufferBindFlag.IndexBuffer, this._indices, BufferUsage.Dynamic);
11114
11465
  this._indexBuffer = indexBuffer;
@@ -11128,14 +11479,34 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11128
11479
  */ _proto._clearSubPrimitives = function _clearSubPrimitives() {
11129
11480
  this._subPrimitives.length = 0;
11130
11481
  };
11482
+ /**
11483
+ * @internal
11484
+ */ _proto._getMaterial = function _getMaterial(texture, blendMode) {
11485
+ var engine = this._engine;
11486
+ var premultipliedAlpha = this.premultipliedAlpha;
11487
+ var tintBlack = this.tintBlack;
11488
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11489
+ var cached = SpineAnimationRenderer._materialCacheMap[key];
11490
+ if (!cached) {
11491
+ cached = new SpineMaterial(engine);
11492
+ cached.isGCIgnored = true;
11493
+ SpineAnimationRenderer._materialCacheMap.set(key, cached);
11494
+ }
11495
+ cached._setBlendMode(blendMode, premultipliedAlpha);
11496
+ cached._setTexture(texture);
11497
+ cached._setTintBlack(tintBlack);
11498
+ cached._setPremultipliedAlpha(premultipliedAlpha);
11499
+ return cached;
11500
+ };
11131
11501
  _proto._clearMaterialCache = function _clearMaterialCache() {
11132
- var materialCache = SpineAnimationRenderer._materialCache;
11133
- var _this = this, materials = _this._materials;
11502
+ var materialCache = SpineAnimationRenderer._materialCacheMap;
11503
+ var premultipliedAlpha = this.premultipliedAlpha;
11504
+ var materials = this._materials;
11134
11505
  for(var i = 0, len = materials.length; i < len; i += 1){
11135
11506
  var material = materials[i];
11136
11507
  var texture = material.shaderData.getTexture("material_SpineTexture");
11137
- var blendMode = getBlendMode(material);
11138
- var key = texture.instanceId + "_" + blendMode;
11508
+ var blendMode = material._getBlendMode();
11509
+ var key = texture.instanceId + "_" + blendMode + "_" + (premultipliedAlpha ? 1 : 0);
11139
11510
  materialCache.delete(key);
11140
11511
  }
11141
11512
  };
@@ -11152,22 +11523,23 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11152
11523
  }
11153
11524
  }
11154
11525
  };
11155
- /** @internal */ SpineAnimationRenderer._getDefaultMaterial = function _getDefaultMaterial(engine) {
11156
- var defaultMaterial = this._defaultMaterial;
11157
- if (defaultMaterial) {
11158
- if (defaultMaterial.engine === engine) {
11159
- return defaultMaterial.clone();
11160
- } else {
11161
- defaultMaterial.destroy(true);
11162
- defaultMaterial = null;
11163
- }
11164
- }
11165
- defaultMaterial = new SpineMaterial(engine);
11166
- defaultMaterial.isGCIgnored = true;
11167
- this._defaultMaterial = defaultMaterial;
11168
- return defaultMaterial.clone();
11169
- };
11170
11526
  _create_class(SpineAnimationRenderer, [
11527
+ {
11528
+ key: "tintBlack",
11529
+ get: /**
11530
+ * Whether to enable tint black feature for dark color tinting.
11531
+ *
11532
+ * @remarks Should be enabled when using "Tint Black" feature in Spine editor.
11533
+ */ function get() {
11534
+ return this._tintBlack;
11535
+ },
11536
+ set: function set(value) {
11537
+ if (this._tintBlack !== value) {
11538
+ this._tintBlack = value;
11539
+ this._needResizeBuffer = true;
11540
+ }
11541
+ }
11542
+ },
11171
11543
  {
11172
11544
  key: "state",
11173
11545
  get: /**
@@ -11221,15 +11593,19 @@ SpineMaterial._spineFS = "\n #include <common>\n uniform sampler2D materia
11221
11593
  }(Renderer);
11222
11594
  SpineAnimationRenderer._spineGenerator = new SpineGenerator();
11223
11595
  SpineAnimationRenderer._positionVertexElement = new VertexElement("POSITION", 0, VertexElementFormat.Vector3, 0);
11224
- SpineAnimationRenderer._colorVertexElement = new VertexElement("COLOR_0", 12, VertexElementFormat.Vector4, 0);
11596
+ SpineAnimationRenderer._lightColorVertexElement = new VertexElement("LIGHT_COLOR", 12, VertexElementFormat.Vector4, 0);
11225
11597
  SpineAnimationRenderer._uvVertexElement = new VertexElement("TEXCOORD_0", 28, VertexElementFormat.Vector2, 0);
11226
- /** @internal */ SpineAnimationRenderer._materialCache = new Map();
11598
+ SpineAnimationRenderer._darkColorVertexElement = new VertexElement("DARK_COLOR", 36, VertexElementFormat.Vector3, 0);
11599
+ /** @internal */ SpineAnimationRenderer._materialCacheMap = new Map();
11227
11600
  __decorate([
11228
11601
  assignmentClone
11229
11602
  ], SpineAnimationRenderer.prototype, "zSpacing", void 0);
11230
11603
  __decorate([
11231
11604
  assignmentClone
11232
11605
  ], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
11606
+ __decorate([
11607
+ assignmentClone
11608
+ ], SpineAnimationRenderer.prototype, "_tintBlack", void 0);
11233
11609
  __decorate([
11234
11610
  deepClone
11235
11611
  ], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
@@ -11630,7 +12006,7 @@ for(var key in RendererObject){
11630
12006
  for(var key1 in LoaderObject){
11631
12007
  Loader.registerClass(key1, LoaderObject[key1]);
11632
12008
  }
11633
- var version = "4.2.2";
12009
+ var version = "4.2.3";
11634
12010
  console.log("Galacean spine version: " + version);
11635
12011
 
11636
12012
  export { AlphaTimeline, Animation, AnimationState, AnimationStateAdapter, AnimationStateData, AssetManagerBase, AtlasAttachmentLoader, Attachment, AttachmentTimeline, BinaryInput, BlendMode, Bone, BoneData, BoundingBoxAttachment, CURRENT, ClippingAttachment, Color, ConstraintData, CurveTimeline, CurveTimeline1, CurveTimeline2, DebugUtils, DeformTimeline, Downloader, DrawOrderTimeline, Event, EventData, EventQueue, EventTimeline, EventType, FIRST, FakeTexture, HOLD_FIRST, HOLD_MIX, HOLD_SUBSEQUENT, IkConstraint, IkConstraintData, IkConstraintTimeline, Inherit, InheritTimeline, IntSet, Interpolation, LoaderUtils, MathUtils, MeshAttachment, MixBlend, MixDirection, PathAttachment, PathConstraint, PathConstraintData, PathConstraintMixTimeline, PathConstraintPositionTimeline, PathConstraintSpacingTimeline, Physics, PhysicsConstraintDampingTimeline, PhysicsConstraintGravityTimeline, PhysicsConstraintInertiaTimeline, PhysicsConstraintMassTimeline, PhysicsConstraintMixTimeline, PhysicsConstraintResetTimeline, PhysicsConstraintStrengthTimeline, PhysicsConstraintTimeline, PhysicsConstraintWindTimeline, PointAttachment, Pool, PositionMode, Pow, PowOut, RGB2Timeline, RGBA2Timeline, RGBATimeline, RGBTimeline, RegionAttachment, RotateMode, RotateTimeline, SETUP, SUBSEQUENT, ScaleTimeline, ScaleXTimeline, ScaleYTimeline, SequenceTimeline, ShearTimeline, ShearXTimeline, ShearYTimeline, Skeleton, SkeletonBinary, SkeletonBounds, SkeletonClipping, SkeletonData, SkeletonJson, Skin, SkinEntry, Slot, SlotData, SpacingMode, SpineAnimationRenderer, SpineMaterial, SpineResource, StringSet, Texture, TextureAtlas, TextureAtlasPage, TextureAtlasRegion, TextureFilter, TextureRegion, TextureWrap, TimeKeeper, Timeline, TrackEntry, TransformConstraint, TransformConstraintData, TransformConstraintTimeline, TranslateTimeline, TranslateXTimeline, TranslateYTimeline, Triangulator, Utils, Vector2, VertexAttachment, WindowedMean, version };