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