@galacean/engine-spine 4.2.0 → 4.2.1

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/module.js CHANGED
@@ -1,31 +1,4 @@
1
- import { TextureFilterMode, TextureWrapMode, AssetType, request, BlendFactor, BlendOperation, SubPrimitive, BoundingBox, Vector3, Shader, CullMode, RenderQueueType, Material, VertexElement, VertexElementFormat, Buffer, BufferBindFlag, BufferUsage, VertexBufferBinding, IndexBufferBinding, IndexFormat, Renderer, deepClone, ignoreClone, Primitive, ReferResource, resourceLoader, AssetPromise, Loader } from '@galacean/engine';
2
-
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4
- try {
5
- var info = gen[key](arg);
6
- var value = info.value;
7
- } catch (error) {
8
- reject(error);
9
- return;
10
- }
11
- if (info.done) resolve(value);
12
- else Promise.resolve(value).then(_next, _throw);
13
- }
14
- function _async_to_generator(fn) {
15
- return function() {
16
- var self = this, args = arguments;
17
- return new Promise(function(resolve, reject) {
18
- var gen = fn.apply(self, args);
19
- function _next(value) {
20
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
21
- }
22
- function _throw(err) {
23
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
24
- }
25
- _next(undefined);
26
- });
27
- };
28
- }
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';
29
2
 
30
3
  function _set_prototype_of(o, p) {
31
4
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -66,97 +39,6 @@ function __decorate(decorators, target, key, desc) {
66
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;
67
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
68
41
  }
69
- function __generator(thisArg, body) {
70
- var _ = {
71
- label: 0,
72
- sent: function sent() {
73
- if (t[0] & 1) throw t[1];
74
- return t[1];
75
- },
76
- trys: [],
77
- ops: []
78
- }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
79
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
80
- return this;
81
- }), g;
82
- function verb(n) {
83
- return function(v) {
84
- return step([
85
- n,
86
- v
87
- ]);
88
- };
89
- }
90
- function step(op) {
91
- if (f) throw new TypeError("Generator is already executing.");
92
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
93
- 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;
94
- if (y = 0, t) op = [
95
- op[0] & 2,
96
- t.value
97
- ];
98
- switch(op[0]){
99
- case 0:
100
- case 1:
101
- t = op;
102
- break;
103
- case 4:
104
- _.label++;
105
- return {
106
- value: op[1],
107
- done: false
108
- };
109
- case 5:
110
- _.label++;
111
- y = op[1];
112
- op = [
113
- 0
114
- ];
115
- continue;
116
- case 7:
117
- op = _.ops.pop();
118
- _.trys.pop();
119
- continue;
120
- default:
121
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
122
- _ = 0;
123
- continue;
124
- }
125
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
- _.label = op[1];
127
- break;
128
- }
129
- if (op[0] === 6 && _.label < t[1]) {
130
- _.label = t[1];
131
- t = op;
132
- break;
133
- }
134
- if (t && _.label < t[2]) {
135
- _.label = t[2];
136
- _.ops.push(op);
137
- break;
138
- }
139
- if (t[2]) _.ops.pop();
140
- _.trys.pop();
141
- continue;
142
- }
143
- op = body.call(thisArg, _);
144
- } catch (e) {
145
- op = [
146
- 6,
147
- e
148
- ];
149
- y = 0;
150
- } finally{
151
- f = t = 0;
152
- }
153
- if (op[0] & 5) throw op[1];
154
- return {
155
- value: op[0] ? op[1] : void 0,
156
- done: true
157
- };
158
- }
159
- }
160
42
  typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
161
43
  var e = new Error(message);
162
44
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -10586,198 +10468,33 @@ function getValue(map, property, defaultValue) {
10586
10468
  }
10587
10469
  })();
10588
10470
 
10589
- function createSkeletonData(textureAtlas, skeletonTextData, skeletonFileType) {
10590
- var atlasLoader = new AtlasAttachmentLoader(textureAtlas);
10591
- if (skeletonFileType === 'json') {
10592
- return new SkeletonJson(atlasLoader).readSkeletonData(skeletonTextData);
10593
- } else {
10594
- return new SkeletonBinary(atlasLoader).readSkeletonData(new Uint8Array(skeletonTextData));
10595
- }
10596
- }
10597
- function loadTexturesByPath(imagePaths, imageExtensions, engine) {
10598
- return _loadTexturesByPath.apply(this, arguments);
10599
- }
10600
- function _loadTexturesByPath() {
10601
- _loadTexturesByPath = _async_to_generator(function(imagePaths, imageExtensions, engine) {
10602
- var textures, texturePromises, error;
10603
- return __generator(this, function(_state) {
10604
- switch(_state.label){
10605
- case 0:
10606
- texturePromises = imagePaths.map(function(imagePath, index) {
10607
- var ext = imageExtensions[index];
10608
- var imageLoaderType = AssetType.Texture2D;
10609
- if (ext === 'ktx') {
10610
- imageLoaderType = AssetType.KTX;
10611
- } else if (ext === 'ktx2') {
10612
- imageLoaderType = AssetType.KTX2;
10613
- }
10614
- return loadTexture(imagePath, engine, imageLoaderType);
10615
- });
10616
- _state.label = 1;
10617
- case 1:
10618
- _state.trys.push([
10619
- 1,
10620
- 3,
10621
- ,
10622
- 4
10623
- ]);
10624
- return [
10625
- 4,
10626
- Promise.all(texturePromises)
10627
- ];
10628
- case 2:
10629
- textures = _state.sent();
10630
- return [
10631
- 3,
10632
- 4
10633
- ];
10634
- case 3:
10635
- error = _state.sent();
10636
- throw error;
10637
- case 4:
10638
- return [
10639
- 2,
10640
- textures
10641
- ];
10642
- }
10643
- });
10644
- });
10645
- return _loadTexturesByPath.apply(this, arguments);
10646
- }
10647
- function loadTextureAtlas(atlasPath, engine) {
10648
- return _loadTextureAtlas.apply(this, arguments);
10649
- }
10650
- function _loadTextureAtlas() {
10651
- _loadTextureAtlas = _async_to_generator(function(atlasPath, engine) {
10652
- var baseUrl, atlasText, textures, err, textureAtlas, loadTexturePromises, _iterator, _step, page, textureUrl, err1;
10653
- return __generator(this, function(_state) {
10654
- switch(_state.label){
10655
- case 0:
10656
- baseUrl = getBaseUrl(atlasPath);
10657
- _state.label = 1;
10658
- case 1:
10659
- _state.trys.push([
10660
- 1,
10661
- 3,
10662
- ,
10663
- 4
10664
- ]);
10665
- return [
10666
- 4,
10667
- request(atlasPath, {
10668
- type: "text"
10669
- })
10670
- ];
10671
- case 2:
10672
- atlasText = _state.sent();
10673
- return [
10674
- 3,
10675
- 4
10676
- ];
10677
- case 3:
10678
- err = _state.sent();
10679
- throw new Error("Spine Atlas: " + atlasPath + " load error: " + err);
10680
- case 4:
10681
- textureAtlas = new TextureAtlas(atlasText);
10682
- loadTexturePromises = [];
10683
- for(_iterator = _create_for_of_iterator_helper_loose(textureAtlas.pages); !(_step = _iterator()).done;){
10684
- page = _step.value;
10685
- textureUrl = baseUrl + page.name;
10686
- loadTexturePromises.push(loadTexture(textureUrl, engine));
10687
- }
10688
- _state.label = 5;
10689
- case 5:
10690
- _state.trys.push([
10691
- 5,
10692
- 7,
10693
- ,
10694
- 8
10695
- ]);
10696
- return [
10697
- 4,
10698
- Promise.all(loadTexturePromises)
10699
- ];
10700
- case 6:
10701
- textures = _state.sent();
10702
- return [
10703
- 3,
10704
- 8
10705
- ];
10706
- case 7:
10707
- err1 = _state.sent();
10708
- throw new Error("Spine Texture: load error: " + err1);
10709
- case 8:
10710
- textureAtlas = createTextureAtlas(atlasText, textures);
10711
- return [
10712
- 2,
10713
- textureAtlas
10714
- ];
10715
- }
10716
- });
10717
- });
10718
- return _loadTextureAtlas.apply(this, arguments);
10719
- }
10720
- function createTextureAtlas(atlasText, textures) {
10721
- var textureAtlas = new TextureAtlas(atlasText);
10722
- textureAtlas.pages.forEach(function(page, index) {
10723
- var engineTexture = textures.find(function(item) {
10724
- return item.name === page.name;
10725
- }) || textures[index];
10726
- var texture = createAdaptiveTexture(engineTexture);
10727
- page.setTexture(texture);
10728
- });
10729
- return textureAtlas;
10730
- }
10731
- function loadTexture(url, engine, imageLoaderType) {
10732
- if (imageLoaderType === void 0) imageLoaderType = AssetType.Texture2D;
10733
- return engine.resourceManager.load({
10734
- url: url,
10735
- type: imageLoaderType
10736
- });
10737
- }
10738
- function createAdaptiveTexture(texture) {
10739
- return new AdaptiveTexture(new Image(), texture);
10740
- }
10741
- function getBaseUrl(url) {
10742
- var isLocalPath = !/^(http|https|ftp):\/\/.*/i.test(url);
10743
- if (isLocalPath) {
10744
- var lastSlashIndex = url.lastIndexOf('/');
10745
- if (lastSlashIndex === -1) {
10746
- return '';
10747
- }
10748
- return url.substring(0, lastSlashIndex + 1);
10749
- } else {
10750
- var parsedUrl = new URL(url);
10751
- var basePath = parsedUrl.origin + parsedUrl.pathname;
10752
- return basePath.endsWith('/') ? basePath : basePath.substring(0, basePath.lastIndexOf('/') + 1);
10753
- }
10754
- }
10755
- var AdaptiveTexture = /*#__PURE__*/ function(Texture) {
10756
- _inherits(AdaptiveTexture, Texture);
10757
- function AdaptiveTexture(image, texture) {
10471
+ /**
10472
+ * @internal
10473
+ */ var SpineTexture = /*#__PURE__*/ function(Texture) {
10474
+ _inherits(SpineTexture, Texture);
10475
+ function SpineTexture(image) {
10758
10476
  var _this;
10759
10477
  _this = Texture.call(this, image) || this;
10760
- _this.texture = texture;
10761
- _this.texture.generateMipmaps();
10478
+ image.generateMipmaps();
10762
10479
  return _this;
10763
10480
  }
10764
- var _proto = AdaptiveTexture.prototype;
10481
+ var _proto = SpineTexture.prototype;
10765
10482
  // rewrite getImage function, return galacean texture2D, then attachment can get size of texture
10766
10483
  _proto.getImage = function getImage() {
10767
- return this.texture;
10484
+ return this._image;
10768
10485
  };
10769
10486
  _proto.setFilters = function setFilters(minFilter, magFilter) {
10770
10487
  if (minFilter === TextureFilter.Nearest) {
10771
- this.texture.filterMode = TextureFilterMode.Point;
10488
+ this._image.filterMode = TextureFilterMode.Point;
10772
10489
  } else if (magFilter === TextureFilter.MipMapLinearLinear) {
10773
- this.texture.filterMode = TextureFilterMode.Trilinear;
10490
+ this._image.filterMode = TextureFilterMode.Trilinear;
10774
10491
  } else {
10775
- this.texture.filterMode = TextureFilterMode.Bilinear;
10492
+ this._image.filterMode = TextureFilterMode.Bilinear;
10776
10493
  }
10777
10494
  };
10778
10495
  _proto.setWraps = function setWraps(uWrap, vWrap) {
10779
- this.texture.wrapModeU = this._convertWrapMode(uWrap);
10780
- this.texture.wrapModeV = this._convertWrapMode(vWrap);
10496
+ this._image.wrapModeU = this._convertWrapMode(uWrap);
10497
+ this._image.wrapModeV = this._convertWrapMode(vWrap);
10781
10498
  };
10782
10499
  _proto.dispose = function dispose() {};
10783
10500
  _proto._convertWrapMode = function _convertWrapMode(wrap) {
@@ -10792,63 +10509,110 @@ var AdaptiveTexture = /*#__PURE__*/ function(Texture) {
10792
10509
  throw new Error("Unsupported texture wrap mode.");
10793
10510
  }
10794
10511
  };
10795
- return AdaptiveTexture;
10512
+ return SpineTexture;
10796
10513
  }(Texture);
10797
10514
 
10798
- var ReturnablePool = /*#__PURE__*/ function() {
10799
- function ReturnablePool(type, initializeCount) {
10800
- if (initializeCount === void 0) initializeCount = 1;
10801
- this._type = type;
10802
- this._lastElementIndex = initializeCount - 1;
10803
- var elements = this._elements = new Array(initializeCount);
10804
- for(var i = 0; i < initializeCount; ++i){
10805
- elements[i] = new type();
10806
- }
10807
- }
10808
- var _proto = ReturnablePool.prototype;
10809
- _proto.get = function get() {
10810
- if (this._lastElementIndex < 0) {
10811
- return new this._type();
10812
- }
10813
- return this._elements[this._lastElementIndex--];
10515
+ /**
10516
+ * @internal
10517
+ */ var LoaderUtils = /*#__PURE__*/ function() {
10518
+ function LoaderUtils() {}
10519
+ LoaderUtils.createSkeletonData = function createSkeletonData(skeletonRawData, textureAtlas, skeletonDataScale) {
10520
+ var atlasLoader = new AtlasAttachmentLoader(textureAtlas);
10521
+ if (typeof skeletonRawData === "string") {
10522
+ var skeletonJson = new SkeletonJson(atlasLoader);
10523
+ skeletonJson.scale = skeletonDataScale;
10524
+ return skeletonJson.readSkeletonData(skeletonRawData);
10525
+ } else {
10526
+ var skeletonBinary = new SkeletonBinary(atlasLoader);
10527
+ skeletonBinary.scale = skeletonDataScale;
10528
+ return skeletonBinary.readSkeletonData(new Uint8Array(skeletonRawData));
10529
+ }
10530
+ };
10531
+ LoaderUtils.createTextureAtlas = function createTextureAtlas(atlasText, textures) {
10532
+ var textureAtlas = new TextureAtlas(atlasText);
10533
+ textureAtlas.pages.forEach(function(page, index) {
10534
+ var engineTexture = textures.find(function(item) {
10535
+ return item.name === page.name;
10536
+ }) || textures[index];
10537
+ var texture = new SpineTexture(engineTexture);
10538
+ page.setTexture(texture);
10539
+ });
10540
+ return textureAtlas;
10814
10541
  };
10815
- _proto.return = function _return(element) {
10816
- this._elements[++this._lastElementIndex] = element;
10542
+ LoaderUtils.loadTexturesByPaths = function loadTexturesByPaths(imagePaths, imageExtensions, engine, reject) {
10543
+ var resourceManager = engine.resourceManager;
10544
+ // @ts-ignore
10545
+ var virtualPathResourceMap = resourceManager._virtualPathResourceMap;
10546
+ var texturePromises = imagePaths.map(function(imagePath, index) {
10547
+ var ext = imageExtensions[index];
10548
+ var imageLoaderType = AssetType.Texture2D;
10549
+ var virtualElement = virtualPathResourceMap[imagePath];
10550
+ if (virtualElement) {
10551
+ imageLoaderType = virtualElement.type;
10552
+ } else if (ext === "ktx") {
10553
+ imageLoaderType = AssetType.KTX;
10554
+ } else if (ext === "ktx2") {
10555
+ imageLoaderType = AssetType.KTX2;
10556
+ }
10557
+ return resourceManager.load({
10558
+ url: imagePath,
10559
+ type: imageLoaderType
10560
+ });
10561
+ });
10562
+ return Promise.all(texturePromises).catch(function(error) {
10563
+ reject(error);
10564
+ return [];
10565
+ });
10817
10566
  };
10818
- return ReturnablePool;
10819
- }();
10820
-
10821
- var ClearablePool = /*#__PURE__*/ function() {
10822
- function ClearablePool(type) {
10823
- this._usedElementCount = 0;
10824
- this._type = type;
10825
- this._elements = [];
10826
- }
10827
- var _proto = ClearablePool.prototype;
10828
- _proto.get = function get() {
10829
- var _this = this, usedElementCount = _this._usedElementCount, elements = _this._elements;
10830
- this._usedElementCount++;
10831
- if (elements.length === usedElementCount) {
10832
- var element = new this._type();
10833
- elements.push(element);
10834
- return element;
10567
+ LoaderUtils.loadTextureAtlas = function loadTextureAtlas(atlasPath, engine, reject) {
10568
+ var baseUrl = LoaderUtils.getBaseUrl(atlasPath);
10569
+ var resourceManager = engine.resourceManager;
10570
+ var atlasText;
10571
+ return resourceManager// @ts-ignore
10572
+ ._request(atlasPath, {
10573
+ type: "text"
10574
+ }).then(function(text) {
10575
+ atlasText = text;
10576
+ var textureAtlas = new TextureAtlas(atlasText);
10577
+ var loadTexturePromises = textureAtlas.pages.map(function(page) {
10578
+ var textureUrl = baseUrl + page.name;
10579
+ return resourceManager.load({
10580
+ url: textureUrl,
10581
+ type: AssetType.Texture2D
10582
+ });
10583
+ });
10584
+ return Promise.all(loadTexturePromises).then(function(textures) {
10585
+ return LoaderUtils.createTextureAtlas(atlasText, textures);
10586
+ });
10587
+ }).catch(function(err) {
10588
+ reject(new Error("Spine Atlas: " + atlasPath + " load error: " + err));
10589
+ return null;
10590
+ });
10591
+ };
10592
+ LoaderUtils.getBaseUrl = function getBaseUrl(url) {
10593
+ var isLocalPath = !/^(http|https|ftp):\/\/.*/i.test(url);
10594
+ if (isLocalPath) {
10595
+ var lastSlashIndex = url.lastIndexOf("/");
10596
+ if (lastSlashIndex === -1) {
10597
+ return "";
10598
+ }
10599
+ return url.substring(0, lastSlashIndex + 1);
10835
10600
  } else {
10836
- return elements[usedElementCount];
10601
+ var parsedUrl = new URL(url);
10602
+ var basePath = parsedUrl.origin + parsedUrl.pathname;
10603
+ return basePath.endsWith("/") ? basePath : basePath.substring(0, basePath.lastIndexOf("/") + 1);
10837
10604
  }
10838
10605
  };
10839
- _proto.clear = function clear() {
10840
- this._usedElementCount = 0;
10841
- };
10842
- return ClearablePool;
10606
+ return LoaderUtils;
10843
10607
  }();
10844
10608
 
10845
10609
  var SourceAlpha = BlendFactor.SourceAlpha, One = BlendFactor.One, DestinationColor = BlendFactor.DestinationColor, Zero = BlendFactor.Zero, OneMinusSourceColor = BlendFactor.OneMinusSourceColor, OneMinusSourceAlpha = BlendFactor.OneMinusSourceAlpha;
10846
10610
  var Add = BlendOperation.Add;
10847
- function setBlendMode(material, blendMode) {
10611
+ function setBlendMode(material, blendMode, premultipliedAlpha) {
10848
10612
  var target = material.renderState.blendState.targetBlendState;
10849
10613
  switch(blendMode){
10850
10614
  case BlendMode.Additive:
10851
- target.sourceColorBlendFactor = SourceAlpha;
10615
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10852
10616
  target.destinationColorBlendFactor = One;
10853
10617
  target.sourceAlphaBlendFactor = One;
10854
10618
  target.destinationAlphaBlendFactor = One;
@@ -10869,7 +10633,7 @@ function setBlendMode(material, blendMode) {
10869
10633
  target.colorBlendOperation = target.alphaBlendOperation = Add;
10870
10634
  break;
10871
10635
  default:
10872
- target.sourceColorBlendFactor = SourceAlpha;
10636
+ target.sourceColorBlendFactor = premultipliedAlpha ? One : SourceAlpha;
10873
10637
  target.destinationColorBlendFactor = OneMinusSourceAlpha;
10874
10638
  target.sourceAlphaBlendFactor = One;
10875
10639
  target.destinationAlphaBlendFactor = OneMinusSourceAlpha;
@@ -10891,71 +10655,101 @@ function getBlendMode(material) {
10891
10655
  return BlendMode.Normal;
10892
10656
  }
10893
10657
 
10658
+ var ClearablePool = /*#__PURE__*/ function() {
10659
+ function ClearablePool(type) {
10660
+ this._usedElementCount = 0;
10661
+ this._type = type;
10662
+ this._elements = [];
10663
+ }
10664
+ var _proto = ClearablePool.prototype;
10665
+ _proto.get = function get() {
10666
+ var _this = this, usedElementCount = _this._usedElementCount, elements = _this._elements;
10667
+ this._usedElementCount++;
10668
+ if (elements.length === usedElementCount) {
10669
+ var element = new this._type();
10670
+ elements.push(element);
10671
+ return element;
10672
+ } else {
10673
+ return elements[usedElementCount];
10674
+ }
10675
+ };
10676
+ _proto.clear = function clear() {
10677
+ this._usedElementCount = 0;
10678
+ };
10679
+ return ClearablePool;
10680
+ }();
10681
+
10682
+ var ReturnablePool = /*#__PURE__*/ function() {
10683
+ function ReturnablePool(type, initializeCount) {
10684
+ if (initializeCount === void 0) initializeCount = 1;
10685
+ this._type = type;
10686
+ this._lastElementIndex = initializeCount - 1;
10687
+ var elements = this._elements = new Array(initializeCount);
10688
+ for(var i = 0; i < initializeCount; ++i){
10689
+ elements[i] = new type();
10690
+ }
10691
+ }
10692
+ var _proto = ReturnablePool.prototype;
10693
+ _proto.get = function get() {
10694
+ if (this._lastElementIndex < 0) {
10695
+ return new this._type();
10696
+ }
10697
+ return this._elements[this._lastElementIndex--];
10698
+ };
10699
+ _proto.return = function _return(element) {
10700
+ this._elements[++this._lastElementIndex] = element;
10701
+ };
10702
+ return ReturnablePool;
10703
+ }();
10704
+
10894
10705
  var SubRenderItem = function SubRenderItem() {
10895
10706
  };
10896
- var maxBoundsValue = Infinity;
10897
- var minBoundsValue = -Infinity;
10898
- var SpineGenerator = /*#__PURE__*/ function() {
10707
+ /**
10708
+ * @internal
10709
+ */ var SpineGenerator = /*#__PURE__*/ function() {
10899
10710
  function SpineGenerator() {
10900
- this._clipper = new SkeletonClipping();
10901
- this._subRenderItems = [];
10902
10711
  this._separateSlots = new Map();
10712
+ this._subRenderItems = [];
10713
+ this._clipper = new SkeletonClipping();
10903
10714
  this._separateSlotTextureMap = new Map();
10904
10715
  }
10905
10716
  var _proto = SpineGenerator.prototype;
10906
- _proto.getMaxVertexCount = function getMaxVertexCount(skeletonData) {
10907
- var uniqueAttachments = new Set();
10908
- var skins = skeletonData.skins;
10909
- var skinLen = skins.length;
10910
- for(var i = 0; i < skinLen; i++){
10911
- var skin = skins[i];
10912
- this._collectUniqueAttachments(skin, uniqueAttachments);
10913
- }
10914
- return this._calculateTotalVertexCount(uniqueAttachments);
10915
- };
10916
10717
  _proto.buildPrimitive = function buildPrimitive(skeleton, renderer) {
10917
- var _renderer_setting = renderer.setting, _renderer_setting_useClipping = _renderer_setting.useClipping, useClipping = _renderer_setting_useClipping === void 0 ? true : _renderer_setting_useClipping, _renderer_setting_zSpacing = _renderer_setting.zSpacing, zSpacing = _renderer_setting_zSpacing === void 0 ? 0.01 : _renderer_setting_zSpacing;
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;
10719
+ _localBounds.min.set(Infinity, Infinity, Infinity);
10720
+ _localBounds.max.set(-Infinity, -Infinity, -Infinity);
10918
10721
  var _this = this, _clipper = _this._clipper, _separateSlots = _this._separateSlots, _subRenderItems = _this._subRenderItems, _separateSlotTextureMap = _this._separateSlotTextureMap;
10919
- var bounds = SpineGenerator.bounds;
10920
- bounds.min.set(maxBoundsValue, maxBoundsValue, maxBoundsValue);
10921
- bounds.max.set(minBoundsValue, minBoundsValue, minBoundsValue);
10922
- var verticesLength = 0;
10923
- var indicesLength = 0;
10924
- var drawOrder = skeleton.drawOrder;
10925
- var maxSlotCount = drawOrder.length;
10926
- var engine = renderer.engine, _indices = renderer._indices, _vertices = renderer._vertices, _subPrimitives = renderer._subPrimitives;
10927
- var tempVerts = SpineGenerator.tempVerts, tempTexture = SpineGenerator.tempTexture, tempBlendMode = SpineGenerator.tempBlendMode, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool;
10722
+ var tempVerts = SpineGenerator.tempVerts, subRenderItemPool = SpineGenerator.subRenderItemPool, subPrimitivePool = SpineGenerator.subPrimitivePool, VERTEX_SIZE = SpineGenerator.VERTEX_SIZE;
10928
10723
  _subRenderItems.length = 0;
10929
10724
  subRenderItemPool.clear();
10930
- var vertices = renderer._vertices;
10931
10725
  var triangles;
10932
10726
  var uvs;
10933
- // 记录当前
10727
+ var verticesLength = 0;
10728
+ var indicesLength = 0;
10934
10729
  var start = 0;
10935
10730
  var count = 0;
10936
10731
  var blend = BlendMode.Normal;
10937
10732
  var texture = null;
10733
+ var tempBlendMode = null;
10734
+ var tempTexture = null;
10938
10735
  var primitiveIndex = 0;
10939
- SpineGenerator.tempBlendMode = null;
10940
- SpineGenerator.tempTexture = null;
10941
- for(var slotIndex = 0; slotIndex < maxSlotCount; ++slotIndex){
10736
+ var drawOrder = skeleton.drawOrder;
10737
+ for(var slotIndex = 0, n = drawOrder.length; slotIndex < n; ++slotIndex){
10942
10738
  var slot = drawOrder[slotIndex];
10943
10739
  if (!slot.bone.active) {
10944
10740
  _clipper.clipEndWithSlot(slot);
10945
10741
  continue;
10946
10742
  }
10947
10743
  var attachment = slot.getAttachment();
10948
- var attachmentColor = null;
10949
- var z = zSpacing * slotIndex;
10950
- var numFloats = 0;
10951
- var isClipping = _clipper.isClipping();
10952
- var vertexSize = isClipping ? 2 : SpineGenerator.VERTEX_SIZE;
10953
10744
  if (!attachment) {
10954
- if (useClipping) {
10955
- _clipper.clipEndWithSlot(slot);
10956
- }
10745
+ _clipper.clipEndWithSlot(slot);
10957
10746
  continue;
10958
10747
  }
10748
+ var z = zSpacing * slotIndex;
10749
+ var isClipping = _clipper.isClipping();
10750
+ var numFloats = 0;
10751
+ var attachmentColor = null;
10752
+ var vertexSize = isClipping ? 2 : VERTEX_SIZE;
10959
10753
  switch(attachment.constructor){
10960
10754
  case RegionAttachment:
10961
10755
  var regionAttachment = attachment;
@@ -10970,7 +10764,7 @@ var SpineGenerator = /*#__PURE__*/ function() {
10970
10764
  var meshAttachment = attachment;
10971
10765
  attachmentColor = meshAttachment.color;
10972
10766
  numFloats = (meshAttachment.worldVerticesLength >> 1) * vertexSize;
10973
- if (numFloats > vertices.length) {
10767
+ if (numFloats > _vertices.length) {
10974
10768
  SpineGenerator.tempVerts = new Array(numFloats);
10975
10769
  }
10976
10770
  meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, tempVerts, 0, vertexSize);
@@ -10979,15 +10773,11 @@ var SpineGenerator = /*#__PURE__*/ function() {
10979
10773
  texture = meshAttachment.region.texture;
10980
10774
  break;
10981
10775
  case ClippingAttachment:
10982
- if (useClipping) {
10983
- var clip = attachment;
10984
- _clipper.clipStart(slot, clip);
10985
- }
10776
+ var clip = attachment;
10777
+ _clipper.clipStart(slot, clip);
10986
10778
  continue;
10987
10779
  default:
10988
- if (useClipping) {
10989
- _clipper.clipEndWithSlot(slot);
10990
- }
10780
+ _clipper.clipEndWithSlot(slot);
10991
10781
  continue;
10992
10782
  }
10993
10783
  if (texture != null) {
@@ -10998,26 +10788,32 @@ var SpineGenerator = /*#__PURE__*/ function() {
10998
10788
  var _$skeleton = slot.bone.skeleton;
10999
10789
  var skeletonColor = _$skeleton.color;
11000
10790
  var slotColor = slot.color;
11001
- var alpha = skeletonColor.a * slotColor.a * attachmentColor.a;
11002
- var color = SpineGenerator.tempColor;
11003
- var dark = SpineGenerator.tempDark;
11004
- color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha);
10791
+ var finalColor = SpineGenerator.tempColor;
10792
+ var finalAlpha = skeletonColor.a * slotColor.a * attachmentColor.a;
10793
+ finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;
10794
+ finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;
10795
+ finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;
10796
+ finalColor.a = finalAlpha;
10797
+ if (premultipliedAlpha) {
10798
+ finalColor.r *= finalAlpha;
10799
+ finalColor.g *= finalAlpha;
10800
+ finalColor.b *= finalAlpha;
10801
+ }
11005
10802
  if (isClipping) {
11006
- _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, color, dark, false);
10803
+ _clipper.clipTriangles(tempVerts, triangles, triangles.length, uvs, finalColor, SpineGenerator.tempDark, false);
11007
10804
  finalVertices = _clipper.clippedVertices;
11008
10805
  finalVerticesLength = finalVertices.length;
11009
10806
  finalIndices = _clipper.clippedTriangles;
11010
10807
  finalIndicesLength = finalIndices.length;
11011
10808
  } else {
11012
- var verts = tempVerts;
11013
- var r = color.r, g = color.g, b = color.b, a = color.a;
11014
- for(var v = 2, u = 0, n = numFloats; v < n; v += vertexSize, u += 2){
11015
- verts[v] = r;
11016
- verts[v + 1] = g;
11017
- verts[v + 2] = b;
11018
- verts[v + 3] = a;
11019
- verts[v + 4] = uvs[u];
11020
- verts[v + 5] = uvs[u + 1];
10809
+ var r = finalColor.r, g = finalColor.g, b = finalColor.b, a = finalColor.a;
10810
+ for(var v = 2, u = 0, n1 = numFloats; v < n1; v += vertexSize, u += 2){
10811
+ tempVerts[v] = r;
10812
+ tempVerts[v + 1] = g;
10813
+ tempVerts[v + 2] = b;
10814
+ tempVerts[v + 3] = a;
10815
+ tempVerts[v + 4] = uvs[u];
10816
+ tempVerts[v + 5] = uvs[u + 1];
11021
10817
  }
11022
10818
  finalVertices = tempVerts;
11023
10819
  finalVerticesLength = numFloats;
@@ -11029,48 +10825,37 @@ var SpineGenerator = /*#__PURE__*/ function() {
11029
10825
  continue;
11030
10826
  }
11031
10827
  var indexStart = verticesLength / SpineGenerator.VERTEX_STRIDE;
11032
- var vertices1 = _vertices;
11033
10828
  var i = verticesLength;
11034
10829
  var j = 0;
11035
10830
  for(; j < finalVerticesLength;){
11036
10831
  var x = finalVertices[j++];
11037
10832
  var y = finalVertices[j++];
11038
- vertices1[i++] = x;
11039
- vertices1[i++] = y;
11040
- vertices1[i++] = z;
11041
- vertices1[i++] = finalVertices[j++];
11042
- vertices1[i++] = finalVertices[j++];
11043
- vertices1[i++] = finalVertices[j++];
11044
- vertices1[i++] = finalVertices[j++];
11045
- vertices1[i++] = finalVertices[j++];
11046
- vertices1[i++] = finalVertices[j++];
11047
- this._expandByPoint(x, y, z);
10833
+ _vertices[i++] = x;
10834
+ _vertices[i++] = y;
10835
+ _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++];
10842
+ this._expandBounds(x, y, z, _localBounds);
11048
10843
  }
11049
10844
  verticesLength = i;
11050
- var indicesArray = _indices;
11051
10845
  for(i = indicesLength, j = 0; j < finalIndicesLength; i++, j++){
11052
- indicesArray[i] = finalIndices[j] + indexStart;
10846
+ _indices[i] = finalIndices[j] + indexStart;
11053
10847
  }
11054
10848
  indicesLength += finalIndicesLength;
11055
10849
  var slotData = slot.data;
11056
10850
  var slotName = slotData.name;
11057
- blend = slotData.blendMode;
11058
- var blendModeChanged = tempBlendMode !== null && tempBlendMode !== slotData.blendMode;
11059
10851
  var textureChanged = tempTexture !== null && tempTexture !== texture;
11060
10852
  var slotNeedSeparate = _separateSlots.get(slotName);
10853
+ blend = slotData.blendMode;
10854
+ var blendModeChanged = tempBlendMode !== null && tempBlendMode !== blend;
11061
10855
  if (slotNeedSeparate || blendModeChanged || textureChanged) {
11062
10856
  // Finish accumulated count first
11063
10857
  if (count > 0) {
11064
- var origin = _subPrimitives[primitiveIndex];
11065
- origin && primitiveIndex++;
11066
- var subPrimitive = origin || subPrimitivePool.get();
11067
- subPrimitive.start = start;
11068
- subPrimitive.count = count;
11069
- var renderItem = subRenderItemPool.get();
11070
- renderItem.subPrimitive = subPrimitive;
11071
- renderItem.texture = tempTexture;
11072
- renderItem.blendMode = tempBlendMode;
11073
- _subRenderItems.push(renderItem);
10858
+ primitiveIndex = this._createRenderItem(_subPrimitives, primitiveIndex, start, count, tempTexture, tempBlendMode);
11074
10859
  start += count;
11075
10860
  count = 0;
11076
10861
  }
@@ -11078,22 +10863,12 @@ var SpineGenerator = /*#__PURE__*/ function() {
11078
10863
  // If separatedTexture exist, set texture params
11079
10864
  var separateTexture = _separateSlotTextureMap.get(slotName);
11080
10865
  if (separateTexture) {
11081
- var oldTexture = texture.texture;
10866
+ var oldTexture = texture.getImage();
11082
10867
  separateTexture.filterMode = oldTexture.filterMode;
11083
10868
  separateTexture.wrapModeU = oldTexture.wrapModeU;
11084
10869
  separateTexture.wrapModeV = oldTexture.wrapModeV;
11085
10870
  }
11086
- var origin1 = _subPrimitives[primitiveIndex];
11087
- origin1 && primitiveIndex++;
11088
- var subPrimitive1 = origin1 || subPrimitivePool.get();
11089
- subPrimitive1.start = start;
11090
- subPrimitive1.count = finalIndicesLength;
11091
- var renderItem1 = subRenderItemPool.get();
11092
- renderItem1.blendMode = blend;
11093
- renderItem1.subPrimitive = subPrimitive1;
11094
- renderItem1.texture = texture;
11095
- renderItem1.slotName = slotName;
11096
- _subRenderItems.push(renderItem1);
10871
+ primitiveIndex = this._createRenderItem(_subPrimitives, primitiveIndex, start, finalIndicesLength, texture, blend, slotName);
11097
10872
  start += finalIndicesLength;
11098
10873
  count = 0;
11099
10874
  } else {
@@ -11109,44 +10884,36 @@ var SpineGenerator = /*#__PURE__*/ function() {
11109
10884
  } // slot traverse end
11110
10885
  // add reset sub primitive
11111
10886
  if (count > 0) {
11112
- var origin2 = _subPrimitives[primitiveIndex];
11113
- origin2 && primitiveIndex++;
11114
- var subPrimitive2 = origin2 || subPrimitivePool.get();
11115
- subPrimitive2.start = start;
11116
- subPrimitive2.count = count;
11117
- var renderItem2 = subRenderItemPool.get();
11118
- renderItem2.blendMode = blend;
11119
- renderItem2.subPrimitive = subPrimitive2;
11120
- renderItem2.texture = texture;
11121
- _subRenderItems.push(renderItem2);
10887
+ primitiveIndex = this._createRenderItem(_subPrimitives, primitiveIndex, start, count, texture, blend);
11122
10888
  count = 0;
11123
10889
  }
11124
10890
  _clipper.clipEnd();
11125
10891
  var lastLen = _subPrimitives.length;
11126
10892
  var curLen = _subRenderItems.length;
11127
- if (curLen < lastLen) {
11128
- for(var i1 = curLen; i1 < lastLen; i1++){
11129
- var item = _subPrimitives[i1];
11130
- subPrimitivePool.return(item);
11131
- }
10893
+ for(var i1 = curLen; i1 < lastLen; i1++){
10894
+ var item = _subPrimitives[i1];
10895
+ subPrimitivePool.return(item);
11132
10896
  }
11133
10897
  renderer._clearSubPrimitives();
10898
+ var materialCache = SpineAnimationRenderer._materialCache;
11134
10899
  for(var i2 = 0, l = curLen; i2 < l; ++i2){
11135
10900
  var item1 = _subRenderItems[i2];
11136
10901
  var slotName1 = item1.slotName, blendMode = item1.blendMode, texture1 = item1.texture;
11137
10902
  renderer._addSubPrimitive(item1.subPrimitive);
11138
- var subTexture = texture1.texture;
11139
- if (_separateSlotTextureMap.has(slotName1)) {
11140
- subTexture = _separateSlotTextureMap.get(slotName1);
11141
- }
11142
- var key = subTexture.instanceId + "_" + blendMode;
11143
- var material = SpineAnimationRenderer._materialCache.get(key);
10903
+ var subTexture = _separateSlotTextureMap.get(slotName1) || texture1.getImage();
10904
+ var key = subTexture.instanceId + "_" + blendMode + "_" + premultipliedAlpha;
10905
+ var material = materialCache.get(key);
11144
10906
  if (!material) {
11145
- material = this._createMaterialForTexture(subTexture, engine, blendMode);
11146
- SpineAnimationRenderer._materialCache.set(key, material);
10907
+ material = this._createMaterialForTexture(subTexture, engine, blendMode, premultipliedAlpha);
10908
+ materialCache.set(key, material);
11147
10909
  }
11148
10910
  renderer.setMaterial(i2, material);
11149
10911
  }
10912
+ if (indicesLength > _vertexCount) {
10913
+ renderer._createAndBindBuffer(indicesLength);
10914
+ this.buildPrimitive(skeleton, renderer);
10915
+ return;
10916
+ }
11150
10917
  renderer._vertexBuffer.setData(_vertices);
11151
10918
  renderer._indexBuffer.setData(_indices);
11152
10919
  };
@@ -11156,49 +10923,41 @@ var SpineGenerator = /*#__PURE__*/ function() {
11156
10923
  _proto.addSeparateSlotTexture = function addSeparateSlotTexture(slotName, texture) {
11157
10924
  this._separateSlotTextureMap.set(slotName, texture);
11158
10925
  };
11159
- _proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode) {
10926
+ _proto._createMaterialForTexture = function _createMaterialForTexture(texture, engine, blendMode, premultipliedAlpha) {
11160
10927
  var material = SpineAnimationRenderer._getDefaultMaterial(engine);
11161
10928
  material.shaderData.setTexture("material_SpineTexture", texture);
11162
- setBlendMode(material, blendMode);
10929
+ setBlendMode(material, blendMode, premultipliedAlpha);
11163
10930
  return material;
11164
10931
  };
11165
- _proto._expandByPoint = function _expandByPoint(x, y, z) {
11166
- var _SpineGenerator_bounds = SpineGenerator.bounds, min = _SpineGenerator_bounds.min, max = _SpineGenerator_bounds.max;
11167
- var newMinX = Math.min(min.x, x);
11168
- var newMinY = Math.min(min.y, y);
11169
- var newMinZ = Math.min(min.z, z);
11170
- var newMaxX = Math.max(max.x, x);
11171
- var newMaxY = Math.max(max.y, y);
11172
- var newMaxZ = Math.max(max.z, z);
11173
- min.set(newMinX, newMinY, newMinZ);
11174
- max.set(newMaxX, newMaxY, newMaxZ);
11175
- };
11176
- _proto._collectUniqueAttachments = function _collectUniqueAttachments(skin, uniqueAttachments) {
11177
- var attachments = skin.attachments;
11178
- for(var i = 0, n = attachments.length; i < n; i++){
11179
- var slotAttachment = attachments[i];
11180
- for(var key in slotAttachment){
11181
- var attachment = slotAttachment[key];
11182
- if (attachment && !uniqueAttachments.has(attachment)) {
11183
- uniqueAttachments.add(attachment);
11184
- }
11185
- }
11186
- }
11187
- };
11188
- _proto._calculateTotalVertexCount = function _calculateTotalVertexCount(uniqueAttachments) {
11189
- var totalVertexCount = 0;
11190
- var QUAD_TRIANGLE_LENGTH = SpineGenerator.QUAD_TRIANGLES.length;
11191
- uniqueAttachments.forEach(function(attachment) {
11192
- if (_instanceof1(attachment, RegionAttachment)) {
11193
- totalVertexCount += QUAD_TRIANGLE_LENGTH;
11194
- } else if (_instanceof1(attachment, MeshAttachment)) {
11195
- totalVertexCount += attachment.triangles.length;
11196
- }
11197
- });
11198
- return totalVertexCount;
10932
+ _proto._createRenderItem = function _createRenderItem(subPrimitives, primitiveIndex, start, count, texture, blend, slotName) {
10933
+ var subPrimitivePool = SpineGenerator.subPrimitivePool, subRenderItemPool = SpineGenerator.subRenderItemPool;
10934
+ var origin = subPrimitives[primitiveIndex];
10935
+ if (origin) {
10936
+ primitiveIndex++;
10937
+ }
10938
+ var subPrimitive = origin || subPrimitivePool.get();
10939
+ subPrimitive.start = start;
10940
+ subPrimitive.count = count;
10941
+ var renderItem = subRenderItemPool.get();
10942
+ renderItem.blendMode = blend;
10943
+ renderItem.subPrimitive = subPrimitive;
10944
+ renderItem.texture = texture;
10945
+ renderItem.slotName = slotName;
10946
+ this._subRenderItems.push(renderItem);
10947
+ return primitiveIndex;
10948
+ };
10949
+ _proto._expandBounds = function _expandBounds(x, y, z, localBounds) {
10950
+ var min = localBounds.min, max = localBounds.max;
10951
+ min.set(Math.min(min.x, x), Math.min(min.y, y), Math.min(min.z, z));
10952
+ max.set(Math.max(max.x, x), Math.max(max.y, y), Math.max(max.z, z));
11199
10953
  };
11200
10954
  return SpineGenerator;
11201
10955
  }();
10956
+ SpineGenerator.VERTEX_SIZE = 8;
10957
+ SpineGenerator.VERTEX_STRIDE = 9;
10958
+ SpineGenerator.tempDark = new Color();
10959
+ SpineGenerator.tempColor = new Color();
10960
+ SpineGenerator.tempVerts = new Array(8);
11202
10961
  SpineGenerator.QUAD_TRIANGLES = [
11203
10962
  0,
11204
10963
  1,
@@ -11207,18 +10966,8 @@ SpineGenerator.QUAD_TRIANGLES = [
11207
10966
  3,
11208
10967
  0
11209
10968
  ];
11210
- SpineGenerator.VERTEX_SIZE = 8 // 2 2 4 position without z, uv, color
11211
- ;
11212
- SpineGenerator.VERTEX_STRIDE = 9 // 3 2 4 position with z, uv, color
11213
- ;
11214
- SpineGenerator.tempDark = new Color();
11215
- SpineGenerator.tempColor = new Color();
11216
- SpineGenerator.tempVerts = new Array(8);
11217
- SpineGenerator.tempBlendMode = null;
11218
- SpineGenerator.tempTexture = null;
11219
10969
  SpineGenerator.subPrimitivePool = new ReturnablePool(SubPrimitive);
11220
10970
  SpineGenerator.subRenderItemPool = new ClearablePool(SubRenderItem);
11221
- SpineGenerator.bounds = new BoundingBox(new Vector3(maxBoundsValue, maxBoundsValue, maxBoundsValue), new Vector3(minBoundsValue, minBoundsValue, minBoundsValue));
11222
10971
 
11223
10972
  var SpineMaterial = /*#__PURE__*/ function(Material) {
11224
10973
  _inherits(SpineMaterial, Material);
@@ -11229,7 +10978,7 @@ var SpineMaterial = /*#__PURE__*/ function(Material) {
11229
10978
  var renderState = _this.renderState;
11230
10979
  var target = renderState.blendState.targetBlendState;
11231
10980
  target.enabled = true;
11232
- setBlendMode(_this, BlendMode.Normal);
10981
+ setBlendMode(_this, BlendMode.Normal, false);
11233
10982
  renderState.depthState.writeEnabled = false;
11234
10983
  renderState.rasterState.cullMode = CullMode.Off;
11235
10984
  renderState.renderQueueType = RenderQueueType.Transparent;
@@ -11246,11 +10995,17 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11246
10995
  _inherits(SpineAnimationRenderer, Renderer);
11247
10996
  function SpineAnimationRenderer(entity) {
11248
10997
  var _this;
11249
- _this = Renderer.call(this, entity) || this, /** Render setting for spine rendering. */ _this.setting = new SpineRenderSetting(), /**
10998
+ _this = Renderer.call(this, entity) || this, /**
10999
+ * The spacing between z layers in world units.
11000
+ */ _this.zSpacing = 0.001, /**
11001
+ * Whether to use premultiplied alpha mode for rendering.
11002
+ * When enabled, vertex color values are multiplied by the alpha channel.
11003
+ * @remarks
11004
+ If this option is enabled, the Spine editor must export textures with "Premultiply Alpha" checked.
11005
+ */ _this.premultipliedAlpha = false, /**
11250
11006
  * Default state for spine animation.
11251
- * Contains the default animation name to be played, whether this animation should loop,
11252
- * the default skin name, and the default scale of the skeleton.
11253
- */ _this.defaultState = new DefaultState(), /** @internal */ _this._subPrimitives = [], /** @internal */ _this._needResizeBuffer = false, /** @internal */ _this._vertexCount = 0;
11007
+ * Contains the default animation name to be played, whether this animation should loop, the default skin name.
11008
+ */ _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));
11254
11009
  var primitive = new Primitive(_this._engine);
11255
11010
  _this._primitive = primitive;
11256
11011
  primitive.addVertexElement(SpineAnimationRenderer._positionVertexElement);
@@ -11260,49 +11015,28 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11260
11015
  }
11261
11016
  var _proto = SpineAnimationRenderer.prototype;
11262
11017
  /**
11263
- * Separate slot by slot name. This will add a new sub primitive, and new materials.
11264
- */ _proto.addSeparateSlot = function addSeparateSlot(slotName) {
11265
- if (!this._skeleton) {
11266
- console.error("Skeleton not found!");
11267
- }
11268
- var slot = this._skeleton.findSlot(slotName);
11269
- if (slot) {
11270
- SpineAnimationRenderer._spineGenerator.addSeparateSlot(slotName);
11271
- } else {
11272
- console.warn("Slot: " + slotName + " not find.");
11273
- }
11274
- };
11275
- /**
11276
11018
  * @internal
11277
11019
  */ // @ts-ignore
11278
11020
  _proto._onEnable = function _onEnable() {
11279
- this._initializeDefaultState();
11021
+ this._applyDefaultConfig();
11280
11022
  };
11281
11023
  /**
11282
11024
  * @internal
11283
11025
  */ _proto.update = function update(delta) {
11284
- var _this = this, _state = _this._state, _skeleton = _this._skeleton;
11285
- if (_state && _skeleton) {
11286
- _state.update(delta);
11287
- _state.apply(_skeleton);
11288
- _skeleton.update(delta);
11289
- _skeleton.updateWorldTransform(Physics.update);
11290
- SpineAnimationRenderer._spineGenerator.buildPrimitive(this._skeleton, this);
11291
- if (this._isContainDirtyFlag(4)) {
11292
- this._onWorldVolumeChanged();
11293
- this._setDirtyFlagFalse(4);
11294
- }
11295
- if (this._isContainDirtyFlag(2)) {
11296
- this._calculateGeneratorBounds(this.bounds);
11297
- }
11298
- }
11026
+ var _this = this, state = _this._state, skeleton = _this._skeleton;
11027
+ if (!state || !skeleton) return;
11028
+ state.update(delta);
11029
+ state.apply(skeleton);
11030
+ skeleton.update(delta);
11031
+ skeleton.updateWorldTransform(Physics.update);
11032
+ SpineAnimationRenderer._spineGenerator.buildPrimitive(this._skeleton, this);
11033
+ this._dirtyUpdateFlag |= 1;
11299
11034
  };
11300
11035
  /**
11301
11036
  * @internal
11302
11037
  */ // @ts-ignore
11303
11038
  _proto._render = function _render(context) {
11304
- var _this = this, _primitive = _this._primitive, _subPrimitives = _this._subPrimitives;
11305
- var _this1 = this, materials = _this1._materials, engine = _this1._engine;
11039
+ var _this = this, _primitive = _this._primitive, _subPrimitives = _this._subPrimitives, materials = _this._materials, engine = _this._engine;
11306
11040
  // @ts-ignore
11307
11041
  var renderElement = engine._renderElementPool.get();
11308
11042
  // @ts-ignore
@@ -11330,46 +11064,49 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11330
11064
  * @internal
11331
11065
  */ // @ts-ignore
11332
11066
  _proto._updateBounds = function _updateBounds(worldBounds) {
11333
- this._calculateGeneratorBounds(worldBounds);
11067
+ BoundingBox.transform(this._localBounds, this.entity.transform.worldMatrix, worldBounds);
11068
+ };
11069
+ /**
11070
+ * @internal
11071
+ */ _proto._setSkeleton = function _setSkeleton(skeleton) {
11072
+ this._skeleton = skeleton;
11334
11073
  };
11335
11074
  /**
11336
11075
  * @internal
11337
- */ _proto._calculateGeneratorBounds = function _calculateGeneratorBounds(worldBounds) {
11338
- var bounds = SpineGenerator.bounds;
11339
- BoundingBox.transform(bounds, this.entity.transform.worldMatrix, worldBounds);
11076
+ */ _proto._setState = function _setState(state) {
11077
+ this._state = state;
11340
11078
  };
11341
11079
  /**
11342
11080
  * @internal
11343
11081
  */ // @ts-ignore
11344
11082
  _proto._cloneTo = function _cloneTo(target) {
11345
- target.resource = this._resource;
11083
+ var skeletonData = this._skeleton.data;
11084
+ var animationStateData = new AnimationStateData(skeletonData);
11085
+ var skeleton = new Skeleton(skeletonData);
11086
+ var state = new AnimationState(animationStateData);
11087
+ target._setSkeleton(skeleton);
11088
+ target._setState(state);
11346
11089
  };
11347
11090
  /**
11348
11091
  * @internal
11349
11092
  */ _proto._onDestroy = function _onDestroy() {
11350
- var _this = this, _primitive = _this._primitive, _subPrimitives = _this._subPrimitives, _resource = _this._resource;
11351
- _subPrimitives.length = 0;
11352
- if (_primitive) {
11353
- _primitive.destroy();
11354
- }
11355
- if (_resource) {
11356
- this._addResourceReferCount(_resource, -1);
11357
- }
11358
11093
  this._clearMaterialCache();
11094
+ this._subPrimitives.length = 0;
11095
+ this._primitive && this._primitive.destroy();
11359
11096
  this._primitive = null;
11360
11097
  this._resource = null;
11361
11098
  this._skeleton = null;
11362
11099
  this._state = null;
11363
- this.setting = null;
11364
11100
  Renderer.prototype._onDestroy.call(this);
11365
11101
  };
11366
11102
  /**
11367
11103
  * @internal
11368
- */ _proto._createBuffer = function _createBuffer(vertexCount) {
11104
+ */ _proto._createAndBindBuffer = function _createAndBindBuffer(vertexCount) {
11369
11105
  var _this = this, _engine = _this._engine, _primitive = _this._primitive;
11106
+ this._vertexCount = vertexCount;
11370
11107
  this._vertices = new Float32Array(vertexCount * SpineGenerator.VERTEX_STRIDE);
11371
11108
  this._indices = new Uint16Array(vertexCount);
11372
- var vertexStride = SpineGenerator.VERTEX_STRIDE * 4; // position + color + uv * Float32 byteLen
11109
+ var vertexStride = SpineGenerator.VERTEX_STRIDE * 4;
11373
11110
  var vertexBuffer = new Buffer(_engine, BufferBindFlag.VertexBuffer, this._vertices, BufferUsage.Dynamic);
11374
11111
  var indexBuffer = new Buffer(_engine, BufferBindFlag.IndexBuffer, this._indices, BufferUsage.Dynamic);
11375
11112
  this._indexBuffer = indexBuffer;
@@ -11389,44 +11126,22 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11389
11126
  */ _proto._clearSubPrimitives = function _clearSubPrimitives() {
11390
11127
  this._subPrimitives.length = 0;
11391
11128
  };
11392
- /**
11393
- * @internal
11394
- */ _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
11395
- return (this._dirtyUpdateFlag & type) != 0;
11396
- };
11397
- /**
11398
- * @internal
11399
- */ _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
11400
- this._dirtyUpdateFlag &= ~type;
11401
- };
11402
- /**
11403
- * @internal
11404
- */ _proto._onWorldVolumeChanged = function _onWorldVolumeChanged() {
11405
- this._dirtyUpdateFlag |= 1;
11406
- };
11407
- _proto._onAnimationStart = function _onAnimationStart() {
11408
- this._dirtyUpdateFlag |= 2;
11409
- };
11410
- _proto._onAnimationComplete = function _onAnimationComplete(entry) {
11411
- if (!entry.loop) {
11412
- this._setDirtyFlagFalse(2);
11413
- }
11414
- };
11415
11129
  _proto._clearMaterialCache = function _clearMaterialCache() {
11416
- this._materials.forEach(function(item) {
11417
- var texture = item.shaderData.getTexture('material_SpineTexture');
11418
- var blendMode = getBlendMode(item);
11130
+ var materialCache = SpineAnimationRenderer._materialCache;
11131
+ var _this = this, materials = _this._materials;
11132
+ for(var i = 0, len = materials.length; i < len; i += 1){
11133
+ var material = materials[i];
11134
+ var texture = material.shaderData.getTexture("material_SpineTexture");
11135
+ var blendMode = getBlendMode(material);
11419
11136
  var key = texture.instanceId + "_" + blendMode;
11420
- SpineAnimationRenderer._materialCache.delete(key);
11421
- });
11137
+ materialCache.delete(key);
11138
+ }
11422
11139
  };
11423
- _proto._initializeDefaultState = function _initializeDefaultState() {
11140
+ _proto._applyDefaultConfig = function _applyDefaultConfig() {
11424
11141
  var _this = this, skeleton = _this.skeleton, state = _this.state;
11425
11142
  if (skeleton && state) {
11426
- var _this_defaultState = this.defaultState, animationName = _this_defaultState.animationName, skinName = _this_defaultState.skinName, loop = _this_defaultState.loop, scale = _this_defaultState.scale;
11427
- skeleton.scaleX = scale;
11428
- skeleton.scaleY = scale;
11429
- if (skinName !== 'default') {
11143
+ var _this_defaultConfig = this.defaultConfig, animationName = _this_defaultConfig.animationName, skinName = _this_defaultConfig.skinName, loop = _this_defaultConfig.loop;
11144
+ if (skinName !== "default") {
11430
11145
  skeleton.setSkinByName(skinName);
11431
11146
  skeleton.setToSetupPose();
11432
11147
  }
@@ -11451,51 +11166,11 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11451
11166
  return defaultMaterial.clone();
11452
11167
  };
11453
11168
  _create_class(SpineAnimationRenderer, [
11454
- {
11455
- key: "resource",
11456
- get: /**
11457
- * Spine resource of current spine animation.This property allows you to switch between different animations at runtime.
11458
- */ function get() {
11459
- return this._resource;
11460
- },
11461
- set: function set(value) {
11462
- var _this = this;
11463
- if (!value) {
11464
- this._state = null;
11465
- this._skeleton = null;
11466
- this._resource = null;
11467
- return;
11468
- }
11469
- this._resource = value;
11470
- // @ts-ignore
11471
- this._addResourceReferCount(value, 1);
11472
- var skeletonData = value.skeletonData;
11473
- this._skeleton = new Skeleton(skeletonData);
11474
- var animationData = SpineAnimationRenderer._animationDataCache.get(skeletonData);
11475
- if (!animationData) {
11476
- animationData = new AnimationStateData(skeletonData);
11477
- SpineAnimationRenderer._animationDataCache.set(skeletonData, animationData);
11478
- }
11479
- this._state = new AnimationState(animationData);
11480
- var maxCount = SpineAnimationRenderer._spineGenerator.getMaxVertexCount(skeletonData);
11481
- this._createBuffer(maxCount);
11482
- this._initializeDefaultState();
11483
- this._dirtyUpdateFlag |= 4;
11484
- this._state.addListener({
11485
- start: function() {
11486
- _this._onAnimationStart();
11487
- },
11488
- complete: function(entry) {
11489
- _this._onAnimationComplete(entry);
11490
- }
11491
- });
11492
- }
11493
- },
11494
11169
  {
11495
11170
  key: "state",
11496
11171
  get: /**
11497
- * Provides access to `AnimationState` which controls animation playback on a skeleton.
11498
- * You can use its API to manage, blend, and transition between multiple simultaneous animations effectively.
11172
+ * The Spine.AnimationState object of this SpineAnimationRenderer.
11173
+ * Manage, blend, and transition between multiple simultaneous animations effectively.
11499
11174
  */ function get() {
11500
11175
  return this._state;
11501
11176
  }
@@ -11503,28 +11178,59 @@ SpineMaterial._spineFS = "\n uniform sampler2D material_SpineTexture;\n\n
11503
11178
  {
11504
11179
  key: "skeleton",
11505
11180
  get: /**
11506
- * Provides access to `Skeleton`, which defines the structure of a Spine model.
11507
- * Through its API, users can manipulate bone positions, rotations, scaling
11181
+ * The Spine.Skeleton object of this SpineAnimationRenderer.
11182
+ * Manipulate bone positions, rotations, scaling
11508
11183
  * and change spine attachment to customize character appearances dynamically during runtime.
11509
11184
  */ function get() {
11510
11185
  return this._skeleton;
11511
11186
  }
11187
+ },
11188
+ {
11189
+ key: "resource",
11190
+ get: /**
11191
+ * * @deprecated This property is deprecated and will be removed in future releases.
11192
+ * Spine resource of current spine animation.
11193
+ */ function get() {
11194
+ return this._resource;
11195
+ },
11196
+ set: /**
11197
+ * * @deprecated This property is deprecated and will be removed in future releases.
11198
+ * Sets the Spine resource for the current animation. This property allows switching to a different `SpineResource`.
11199
+ *
11200
+ * @param value - The new `SpineResource` to be used for the current animation
11201
+ */ function set(value) {
11202
+ if (!value) {
11203
+ this._state = null;
11204
+ this._skeleton = null;
11205
+ this._resource = null;
11206
+ return;
11207
+ }
11208
+ this._resource = value;
11209
+ var skeletonData = value.skeletonData, stateData = value.stateData;
11210
+ var skeleton = new Skeleton(skeletonData);
11211
+ var state = new AnimationState(stateData);
11212
+ this._setSkeleton(skeleton);
11213
+ this._setState(state);
11214
+ this._applyDefaultConfig();
11215
+ }
11512
11216
  }
11513
11217
  ]);
11514
11218
  return SpineAnimationRenderer;
11515
11219
  }(Renderer);
11516
11220
  SpineAnimationRenderer._spineGenerator = new SpineGenerator();
11517
- SpineAnimationRenderer._positionVertexElement = new VertexElement('POSITION', 0, VertexElementFormat.Vector3, 0);
11518
- SpineAnimationRenderer._colorVertexElement = new VertexElement('COLOR_0', 12, VertexElementFormat.Vector4, 0);
11519
- SpineAnimationRenderer._uvVertexElement = new VertexElement('TEXCOORD_0', 28, VertexElementFormat.Vector2, 0);
11221
+ SpineAnimationRenderer._positionVertexElement = new VertexElement("POSITION", 0, VertexElementFormat.Vector3, 0);
11222
+ SpineAnimationRenderer._colorVertexElement = new VertexElement("COLOR_0", 12, VertexElementFormat.Vector4, 0);
11223
+ SpineAnimationRenderer._uvVertexElement = new VertexElement("TEXCOORD_0", 28, VertexElementFormat.Vector2, 0);
11520
11224
  /** @internal */ SpineAnimationRenderer._materialCache = new Map();
11521
- /** @internal */ SpineAnimationRenderer._animationDataCache = new Map();
11522
11225
  __decorate([
11523
- deepClone
11524
- ], SpineAnimationRenderer.prototype, "setting", void 0);
11226
+ assignmentClone
11227
+ ], SpineAnimationRenderer.prototype, "zSpacing", void 0);
11228
+ __decorate([
11229
+ assignmentClone
11230
+ ], SpineAnimationRenderer.prototype, "premultipliedAlpha", void 0);
11525
11231
  __decorate([
11526
11232
  deepClone
11527
- ], SpineAnimationRenderer.prototype, "defaultState", void 0);
11233
+ ], SpineAnimationRenderer.prototype, "defaultConfig", void 0);
11528
11234
  __decorate([
11529
11235
  ignoreClone
11530
11236
  ], SpineAnimationRenderer.prototype, "_primitive", void 0);
@@ -11552,151 +11258,126 @@ __decorate([
11552
11258
  __decorate([
11553
11259
  ignoreClone
11554
11260
  ], SpineAnimationRenderer.prototype, "_resource", void 0);
11261
+ __decorate([
11262
+ ignoreClone
11263
+ ], SpineAnimationRenderer.prototype, "_localBounds", void 0);
11555
11264
  __decorate([
11556
11265
  ignoreClone
11557
11266
  ], SpineAnimationRenderer.prototype, "_skeleton", void 0);
11558
11267
  __decorate([
11559
11268
  ignoreClone
11560
11269
  ], SpineAnimationRenderer.prototype, "_state", void 0);
11561
- /**
11562
- * Render setting for spine rendering.
11563
- */ var SpineRenderSetting = function SpineRenderSetting(/**
11564
- * The spacing between z layers @defaultValue `0.01`
11565
- */ zSpacing, /**
11566
- * Whether to use clipping @defaultValue `true`
11567
- */ useClipping) {
11568
- if (zSpacing === void 0) zSpacing = 0.01;
11569
- if (useClipping === void 0) useClipping = true;
11570
- this.zSpacing = zSpacing;
11571
- this.useClipping = useClipping;
11572
- };
11573
11270
  /**
11574
11271
  * Default state for spine animation.
11575
11272
  * Contains the default animation name to be played, whether this animation should loop,
11576
11273
  * the default skin name, and the default scale of the skeleton.
11577
- */ var DefaultState = function DefaultState(/**
11578
- * The default scale of the animation @defaultValue `1`
11579
- */ scale, /**
11274
+ */ var SpineAnimationDefaultConfig = function SpineAnimationDefaultConfig(/**
11580
11275
  * Whether the default animation should loop @defaultValue `true. The default animation should loop`
11581
11276
  */ loop, /**
11582
11277
  * The name of the default animation @defaultValue `null. Do not play any animation by default`
11583
11278
  */ animationName, /**
11584
11279
  * The name of the default skin @defaultValue `default`
11585
11280
  */ skinName) {
11586
- if (scale === void 0) scale = 1;
11587
11281
  if (loop === void 0) loop = true;
11588
11282
  if (animationName === void 0) animationName = null;
11589
11283
  if (skinName === void 0) skinName = "default";
11590
- this.scale = scale;
11591
11284
  this.loop = loop;
11592
11285
  this.animationName = animationName;
11593
11286
  this.skinName = skinName;
11594
11287
  };
11595
11288
 
11596
- var SkeletonDataResource = /*#__PURE__*/ function(ReferResource) {
11597
- _inherits(SkeletonDataResource, ReferResource);
11598
- function SkeletonDataResource(engine, skeletonData) {
11289
+ /**
11290
+ * Represents a resource that manages Spine animation data, textures, and entity templates for the Galacean engine.
11291
+ *
11292
+ */ var SpineResource = /*#__PURE__*/ function(ReferResource) {
11293
+ _inherits(SpineResource, ReferResource);
11294
+ function SpineResource(engine, skeletonData, url) {
11599
11295
  var _this;
11600
- _this = ReferResource.call(this, engine) || this, _this.textures = [];
11296
+ _this = ReferResource.call(this, engine) || this, _this._texturesInSpineAtlas = [];
11297
+ _this.url = url;
11601
11298
  _this._skeletonData = skeletonData;
11299
+ _this._stateData = new AnimationStateData(skeletonData);
11602
11300
  _this._associationTextureInSkeletonData(skeletonData);
11301
+ _this._createTemplate();
11603
11302
  return _this;
11604
11303
  }
11605
- var _proto = SkeletonDataResource.prototype;
11304
+ var _proto = SpineResource.prototype;
11305
+ /**
11306
+ * Creates and returns a new instance of the spine entity template.
11307
+ * @returns A instance of the spine entity template
11308
+ */ _proto.instantiate = function instantiate() {
11309
+ return this._template.clone();
11310
+ };
11606
11311
  _proto._onDestroy = function _onDestroy() {
11607
11312
  ReferResource.prototype._onDestroy.call(this);
11608
- var _this = this, textures = _this.textures, _skeletonData = _this._skeletonData;
11609
- textures && this._disassociationSuperResource(textures);
11610
- this._clearAttachmentTextures(_skeletonData);
11611
- SpineAnimationRenderer._animationDataCache.delete(_skeletonData);
11313
+ this._disassociationSuperResource();
11612
11314
  this._skeletonData = null;
11613
- };
11614
- _proto._disassociationSuperResource = function _disassociationSuperResource(resources) {
11615
- for(var i = 0, n = resources.length; i < n; i++){
11616
- // @ts-ignore
11617
- resources[i]._disassociationSuperResource(this);
11618
- }
11315
+ this._stateData = null;
11316
+ };
11317
+ _proto._createTemplate = function _createTemplate() {
11318
+ var name = this._extractFileName(this.url);
11319
+ var spineEntity = new Entity(this.engine, name);
11320
+ var spineAnimationRenderer = spineEntity.addComponent(SpineAnimationRenderer);
11321
+ var skeleton = new Skeleton(this._skeletonData);
11322
+ var state = new AnimationState(this._stateData);
11323
+ spineAnimationRenderer._setSkeleton(skeleton);
11324
+ spineAnimationRenderer._setState(state);
11325
+ // @ts-ignore
11326
+ spineEntity._markAsTemplate(this);
11327
+ this._template = spineEntity;
11619
11328
  };
11620
11329
  _proto._associationTextureInSkeletonData = function _associationTextureInSkeletonData(skeletonData) {
11621
- var _this = this;
11622
- var skins = skeletonData.skins;
11623
- skins.forEach(function(skin) {
11624
- var attachments = skin.attachments;
11625
- attachments.forEach(function(attachmentMap) {
11330
+ var skins = skeletonData.skins, slots = skeletonData.slots;
11331
+ var textures = this._texturesInSpineAtlas;
11332
+ for(var i = 0, n = skins.length; i < n; i++){
11333
+ for(var j = 0, m = slots.length; j < m; j++){
11626
11334
  var _attachment_region;
11627
- var attachment = Object.values(attachmentMap)[0];
11628
- // @ts-ignore
11335
+ var slot = slots[j];
11336
+ var attachment = skins[i].getAttachment(slot.index, slot.name);
11629
11337
  var texture = attachment == null ? void 0 : (_attachment_region = attachment.region) == null ? void 0 : _attachment_region.texture.texture;
11630
- if (texture && !_this.textures.find(function(item) {
11631
- return item.instanceId === texture.instanceId;
11632
- })) {
11633
- _this.textures.push(texture);
11634
- texture._associationSuperResource(_this);
11338
+ if (texture) {
11339
+ if (!textures.includes(texture)) {
11340
+ textures.push(texture);
11341
+ // @ts-ignore
11342
+ texture._associationSuperResource(this);
11343
+ }
11635
11344
  }
11636
- });
11637
- });
11345
+ }
11346
+ }
11638
11347
  };
11639
- _proto._clearAttachmentTextures = function _clearAttachmentTextures(skeletonData) {
11640
- var skins = skeletonData.skins;
11641
- skins.forEach(function(skin) {
11642
- var attachments = skin.attachments;
11643
- attachments.forEach(function(attachmentMap) {
11644
- var _attachment_region;
11645
- var attachment = Object.values(attachmentMap)[0];
11646
- // @ts-ignore
11647
- if (attachment == null ? void 0 : (_attachment_region = attachment.region) == null ? void 0 : _attachment_region.texture) {
11648
- // @ts-ignore
11649
- attachment.region.texture.texture = null;
11650
- }
11651
- });
11652
- });
11348
+ _proto._disassociationSuperResource = function _disassociationSuperResource() {
11349
+ var textures = this._texturesInSpineAtlas;
11350
+ for(var i = 0, n = textures.length; i < n; i++){
11351
+ // @ts-ignore
11352
+ textures[i]._disassociationSuperResource(this);
11353
+ }
11354
+ };
11355
+ _proto._extractFileName = function _extractFileName(url) {
11356
+ if (!url) return "Spine Entity";
11357
+ var match = url.match(/\/([^\/]+?)(\.[^\/]*)?$/);
11358
+ return match ? match[1] : "Spine Entity";
11653
11359
  };
11654
- _create_class(SkeletonDataResource, [
11360
+ _create_class(SpineResource, [
11655
11361
  {
11656
11362
  key: "skeletonData",
11657
- get: function get() {
11363
+ get: /**
11364
+ * The skeleton data associated with this Spine resource.
11365
+ */ function get() {
11658
11366
  return this._skeletonData;
11659
11367
  }
11368
+ },
11369
+ {
11370
+ key: "stateData",
11371
+ get: /**
11372
+ * The animation state data associated with this Spine resource.
11373
+ */ function get() {
11374
+ return this._stateData;
11375
+ }
11660
11376
  }
11661
11377
  ]);
11662
- return SkeletonDataResource;
11378
+ return SpineResource;
11663
11379
  }(ReferResource);
11664
11380
 
11665
- var BufferReader = /*#__PURE__*/ function() {
11666
- function BufferReader(data, byteOffset, byteLength) {
11667
- if (byteOffset === void 0) byteOffset = 0;
11668
- this.data = data;
11669
- this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength != null ? byteLength : data.byteLength - byteOffset);
11670
- this._position = 0;
11671
- }
11672
- var _proto = BufferReader.prototype;
11673
- _proto.nextUint16 = function nextUint16() {
11674
- var value = this._dataView.getUint16(this._position, true);
11675
- this._position += 2;
11676
- return value;
11677
- };
11678
- _proto.nextStr = function nextStr() {
11679
- var strByteLength = this.nextUint16();
11680
- var uint8Array = new Uint8Array(this.data.buffer, this._position + this._dataView.byteOffset, strByteLength);
11681
- this._position += strByteLength;
11682
- return this.decodeText(uint8Array);
11683
- };
11684
- _proto.nextImageData = function nextImageData() {
11685
- return new Uint8Array(this.data.buffer, this.data.byteOffset + this._position);
11686
- };
11687
- _proto.decodeText = function decodeText(array) {
11688
- if (typeof TextDecoder !== "undefined") {
11689
- return new TextDecoder().decode(array);
11690
- }
11691
- var s = "";
11692
- for(var i = 0, il = array.length; i < il; i++){
11693
- s += String.fromCharCode(array[i]);
11694
- }
11695
- return decodeURIComponent(encodeURIComponent(s));
11696
- };
11697
- return BufferReader;
11698
- }();
11699
-
11700
11381
  var SpineLoader = /*#__PURE__*/ function(Loader) {
11701
11382
  _inherits(SpineLoader, Loader);
11702
11383
  function SpineLoader() {
@@ -11705,353 +11386,250 @@ var SpineLoader = /*#__PURE__*/ function(Loader) {
11705
11386
  var _proto = SpineLoader.prototype;
11706
11387
  _proto.load = function load(item, resourceManager) {
11707
11388
  var _this = this;
11708
- return new AssetPromise(/*#__PURE__*/ _async_to_generator(function(resolve) {
11709
- var resource, buffer, reader, header;
11710
- return __generator(this, function(_state) {
11711
- switch(_state.label){
11712
- case 0:
11713
- if (!item.urls) return [
11714
- 3,
11715
- 2
11716
- ];
11717
- return [
11718
- 4,
11719
- _this._handleOriginAsset(item, resourceManager)
11720
- ];
11721
- case 1:
11722
- resource = _state.sent();
11723
- return [
11724
- 3,
11725
- 7
11726
- ];
11727
- case 2:
11728
- return [
11729
- 4,
11730
- resourceManager._request(item.url, {
11731
- type: 'arraybuffer'
11732
- })
11733
- ];
11734
- case 3:
11735
- buffer = _state.sent();
11736
- reader = new BufferReader(new Uint8Array(buffer));
11737
- header = reader.nextStr();
11738
- if (!header.startsWith('spine')) return [
11739
- 3,
11740
- 5
11741
- ];
11742
- return [
11743
- 4,
11744
- _this._handleEditorAsset(buffer, reader, header, resourceManager)
11745
- ];
11746
- case 4:
11747
- resource = _state.sent();
11748
- return [
11749
- 3,
11750
- 7
11751
- ];
11752
- case 5:
11753
- return [
11754
- 4,
11755
- _this._handleOriginAsset(item, resourceManager, buffer)
11756
- ];
11757
- case 6:
11758
- resource = _state.sent();
11759
- _state.label = 7;
11760
- case 7:
11761
- resolve(resource);
11762
- return [
11763
- 2
11764
- ];
11765
- }
11766
- });
11767
- }));
11768
- };
11769
- _proto._handleEditorAsset = function _handleEditorAsset(buffer, reader, header, resourceManager) {
11770
- return _async_to_generator(function() {
11771
- var skeletonRawData, atlasRefId, type, engine, decoder, text, _JSON_parse, data, atlas, textureAtlas, skeletonData;
11772
- return __generator(this, function(_state) {
11773
- switch(_state.label){
11774
- case 0:
11775
- type = header.startsWith('spine:skel') ? 'skel' : 'json';
11776
- engine = resourceManager.engine;
11777
- if (type === 'skel') {
11778
- atlasRefId = reader.nextStr();
11779
- skeletonRawData = reader.nextImageData().buffer;
11780
- } else {
11781
- decoder = new TextDecoder('utf-8');
11782
- text = decoder.decode(new Uint8Array(buffer));
11783
- _JSON_parse = JSON.parse(text), data = _JSON_parse.data, atlas = _JSON_parse.atlas;
11784
- atlasRefId = atlas.refId;
11785
- skeletonRawData = data;
11786
- }
11787
- return [
11788
- 4,
11789
- resourceManager.getResourceByRef({
11790
- refId: atlasRefId
11791
- })
11792
- ];
11793
- case 1:
11794
- textureAtlas = _state.sent();
11795
- skeletonData = createSkeletonData(textureAtlas, skeletonRawData, type);
11796
- return [
11797
- 2,
11798
- new SkeletonDataResource(engine, skeletonData)
11799
- ];
11389
+ return new AssetPromise(function(resolve, reject) {
11390
+ var spineLoadContext = {
11391
+ fileName: "",
11392
+ skeletonRawData: "",
11393
+ spineAssetPath: {
11394
+ atlasPath: null,
11395
+ skeletonPath: null,
11396
+ extraPaths: []
11800
11397
  }
11801
- });
11802
- })();
11803
- };
11804
- _proto._handleOriginAsset = function _handleOriginAsset(item, resourceManager, buffer) {
11805
- var _this = this;
11806
- return _async_to_generator(function() {
11807
- var fileExtensions, spineAssetBundle, engine, fileExtension, skeletonPath, atlasPath, textureAtlas, _this__determineSkeletonDataType, data, type, skeletonData, i, url, extension, skeletonPath1, atlasPath1, imagePaths, skeletonExtension, imageExtensions, skeletonPromise, type1, loadQueue, textureAtlas1, skeletonTextData, atlasText, textures, ref, ref1, skeletonData1;
11808
- return __generator(this, function(_state) {
11809
- switch(_state.label){
11810
- case 0:
11811
- fileExtensions = (item.params || {}).fileExtensions;
11812
- spineAssetBundle = {
11813
- skeletonPath: '',
11814
- skeletonExtension: '',
11815
- atlasPath: '',
11816
- imagePaths: [],
11817
- imageExtensions: []
11818
- };
11819
- engine = resourceManager.engine;
11820
- if (!buffer) return [
11821
- 3,
11822
- 2
11823
- ];
11824
- fileExtension = SpineLoader.verifyFileExtensions(fileExtensions, false);
11825
- SpineLoader.deriveAndAssignSpineAsset(item.url, fileExtension, spineAssetBundle);
11826
- skeletonPath = spineAssetBundle.skeletonPath, atlasPath = spineAssetBundle.atlasPath;
11827
- if (!skeletonPath || !atlasPath) {
11828
- throw new Error('Failed to load spine assets. Please check the file path and ensure the file extension is included.');
11829
- }
11830
- return [
11831
- 4,
11832
- loadTextureAtlas(atlasPath, engine)
11833
- ];
11834
- case 1:
11835
- textureAtlas = _state.sent();
11836
- _this__determineSkeletonDataType = _this._determineSkeletonDataType(buffer), data = _this__determineSkeletonDataType.data, type = _this__determineSkeletonDataType.type;
11837
- skeletonData = createSkeletonData(textureAtlas, data, type);
11838
- return [
11839
- 2,
11840
- new SkeletonDataResource(engine, skeletonData)
11841
- ];
11842
- case 2:
11843
- fileExtensions = SpineLoader.verifyFileExtensions(fileExtensions, true);
11844
- for(i = 0; i < item.urls.length; i += 1){
11845
- url = item.urls[i];
11846
- extension = fileExtensions && fileExtensions[i] || null;
11847
- SpineLoader.parseAndAssignSpineAsset(url, extension, spineAssetBundle);
11848
- }
11849
- skeletonPath1 = spineAssetBundle.skeletonPath, atlasPath1 = spineAssetBundle.atlasPath, imagePaths = spineAssetBundle.imagePaths, skeletonExtension = spineAssetBundle.skeletonExtension, imageExtensions = spineAssetBundle.imageExtensions;
11850
- if (!skeletonPath1 || !atlasPath1) {
11851
- throw new Error('Failed to load spine assets. Please check the file path and ensure the file extension is included.');
11852
- }
11853
- // @ts-ignore
11854
- skeletonPromise = skeletonExtension === 'json' ? resourceManager._request(skeletonPath1, {
11855
- type: 'text'
11856
- }) : resourceManager._request(skeletonPath1, {
11857
- type: 'arraybuffer'
11858
- });
11859
- type1 = skeletonExtension === 'json' ? 'json' : 'skel';
11860
- loadQueue = [
11861
- skeletonPromise
11862
- ];
11863
- if (!(imagePaths.length > 0)) return [
11864
- 3,
11865
- 4
11866
- ];
11867
- loadQueue = loadQueue.concat([
11868
- // @ts-ignore
11869
- resourceManager._request(atlasPath1, {
11870
- type: 'text'
11871
- }),
11872
- loadTexturesByPath(imagePaths, imageExtensions, engine)
11873
- ]);
11874
- return [
11875
- 4,
11876
- Promise.all(loadQueue)
11877
- ];
11878
- case 3:
11879
- ref = _state.sent(), skeletonTextData = ref[0], atlasText = ref[1], textures = ref[2];
11880
- textureAtlas1 = createTextureAtlas(atlasText, textures);
11881
- return [
11882
- 3,
11883
- 6
11884
- ];
11885
- case 4:
11886
- loadQueue.push(loadTextureAtlas(atlasPath1, engine));
11887
- return [
11888
- 4,
11889
- Promise.all(loadQueue)
11890
- ];
11891
- case 5:
11892
- ref1 = _state.sent(), skeletonTextData = ref1[0], textureAtlas1 = ref1[1];
11893
- _state.label = 6;
11894
- case 6:
11895
- skeletonData1 = createSkeletonData(textureAtlas1, skeletonTextData, type1);
11896
- return [
11897
- 2,
11898
- new SkeletonDataResource(engine, skeletonData1)
11899
- ];
11900
- case 7:
11901
- return [
11902
- 2
11903
- ];
11398
+ };
11399
+ var spineAssetPath = spineLoadContext.spineAssetPath;
11400
+ if (!item.urls) {
11401
+ SpineLoader._assignAssetPathsFromUrl(item.url, spineAssetPath, resourceManager);
11402
+ } else {
11403
+ var urls = item.urls;
11404
+ for(var i = 0, len = urls.length; i < len; i += 1){
11405
+ var url = urls[i];
11406
+ SpineLoader._groupAssetsByExtension(url, spineAssetPath);
11904
11407
  }
11905
- });
11906
- })();
11408
+ }
11409
+ var skeletonPath = spineAssetPath.skeletonPath, atlasPath = spineAssetPath.atlasPath;
11410
+ if (!skeletonPath || !atlasPath) {
11411
+ reject(new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included."));
11412
+ return;
11413
+ }
11414
+ resourceManager// @ts-ignore
11415
+ ._request(skeletonPath, {
11416
+ type: "arraybuffer"
11417
+ }).then(function(skeletonRawData) {
11418
+ spineLoadContext.skeletonRawData = skeletonRawData;
11419
+ var skeletonString = SpineLoader._decoder.decode(skeletonRawData);
11420
+ if (skeletonString.startsWith("{")) {
11421
+ spineLoadContext.skeletonRawData = skeletonString;
11422
+ }
11423
+ return _this._loadAndCreateSpineResource(spineLoadContext, resourceManager);
11424
+ }).then(resolve).catch(reject);
11425
+ });
11907
11426
  };
11908
- _proto._determineSkeletonDataType = function _determineSkeletonDataType(buffer) {
11909
- var skeletonTextData;
11910
- var type;
11911
- try {
11912
- var decoder = new TextDecoder('utf-8');
11913
- var jsonString = decoder.decode(buffer);
11914
- JSON.parse(jsonString);
11915
- skeletonTextData = jsonString;
11916
- type = 'json';
11917
- } catch (error) {
11918
- skeletonTextData = buffer;
11919
- type = 'skel';
11920
- }
11921
- return {
11922
- data: skeletonTextData,
11923
- type: type
11924
- };
11427
+ _proto._loadAndCreateSpineResource = function _loadAndCreateSpineResource(spineLoadContext, resourceManager) {
11428
+ var engine = resourceManager.engine;
11429
+ var skeletonRawData = spineLoadContext.skeletonRawData, spineAssetPath = spineLoadContext.spineAssetPath;
11430
+ var skeletonPath = spineAssetPath.skeletonPath, atlasPath = spineAssetPath.atlasPath, extraPaths = spineAssetPath.extraPaths;
11431
+ var atlasLoadPromise = extraPaths.length === 0 ? resourceManager.load({
11432
+ url: atlasPath,
11433
+ type: "SpineAtlas"
11434
+ }) : resourceManager.load({
11435
+ urls: [
11436
+ atlasPath
11437
+ ].concat(extraPaths),
11438
+ type: "SpineAtlas"
11439
+ });
11440
+ return atlasLoadPromise.then(function(textureAtlas) {
11441
+ var skeletonData = LoaderUtils.createSkeletonData(skeletonRawData, textureAtlas, 0.01);
11442
+ return new SpineResource(engine, skeletonData, skeletonPath);
11443
+ });
11925
11444
  };
11926
- SpineLoader.parseAndAssignSpineAsset = function parseAndAssignSpineAsset(url, fileExtension, bundle) {
11927
- var imageExtensions = SpineLoader.imageExtensions, skeletonExtensions = SpineLoader.skeletonExtensions;
11928
- var ext = SpineLoader.getUrlExtension(url, fileExtension);
11445
+ SpineLoader._groupAssetsByExtension = function _groupAssetsByExtension(url, assetPath) {
11446
+ var ext = SpineLoader._getUrlExtension(url);
11929
11447
  if (!ext) return;
11930
- if (skeletonExtensions.includes(ext)) {
11931
- bundle.skeletonPath = url;
11932
- bundle.skeletonExtension = ext;
11933
- }
11934
- if (ext === 'atlas') {
11935
- bundle.atlasPath = url;
11936
- }
11937
- if (imageExtensions.includes(ext)) {
11938
- bundle.imagePaths.push(url);
11939
- bundle.imageExtensions.push(ext);
11448
+ if ([
11449
+ "skel",
11450
+ "json",
11451
+ "bin"
11452
+ ].includes(ext)) {
11453
+ assetPath.skeletonPath = url;
11454
+ } else if (ext === "atlas") {
11455
+ assetPath.atlasPath = url;
11456
+ } else {
11457
+ assetPath.extraPaths.push(url);
11940
11458
  }
11941
11459
  };
11942
- SpineLoader.deriveAndAssignSpineAsset = function deriveAndAssignSpineAsset(url, fileExtension, bundle) {
11943
- var ext = SpineLoader.getUrlExtension(url, fileExtension);
11460
+ SpineLoader._assignAssetPathsFromUrl = function _assignAssetPathsFromUrl(url, assetPath, resourceManager) {
11461
+ var _resourceManager__virtualPathResourceMap_url, _resourceManager__virtualPathResourceMap;
11462
+ var ext = SpineLoader._getUrlExtension(url);
11944
11463
  if (!ext) return;
11945
- bundle.skeletonPath = url;
11946
- bundle.skeletonExtension = ext;
11947
- var extensionPattern = /(\.(json|bin|skel))$/;
11948
- var baseUrl;
11949
- if (extensionPattern.test(url)) {
11950
- baseUrl = url.replace(extensionPattern, '');
11951
- }
11952
- if (baseUrl) {
11953
- var atlasUrl = baseUrl + '.atlas';
11954
- bundle.atlasPath = atlasUrl;
11955
- }
11956
- };
11957
- SpineLoader.verifyFileExtensions = function verifyFileExtensions(fileExtensions, expectArray) {
11958
- if (!fileExtensions) return null;
11959
- if (expectArray && !Array.isArray(fileExtensions)) {
11960
- console.error('Expect fileExtensions to be an array.');
11961
- return [];
11962
- } else if (!expectArray && typeof fileExtensions !== 'string') {
11963
- console.error('Expect fileExtensions to be a string.');
11964
- return null;
11464
+ assetPath.skeletonPath = url;
11465
+ // @ts-ignore
11466
+ var skeletonDependency = resourceManager == null ? void 0 : (_resourceManager__virtualPathResourceMap = resourceManager._virtualPathResourceMap) == null ? void 0 : (_resourceManager__virtualPathResourceMap_url = _resourceManager__virtualPathResourceMap[url]) == null ? void 0 : _resourceManager__virtualPathResourceMap_url.dependentAssetMap;
11467
+ if (skeletonDependency) {
11468
+ assetPath.atlasPath = skeletonDependency.atlas;
11469
+ } else {
11470
+ var extensionPattern = /\.(json|bin|skel)$/;
11471
+ var baseUrl;
11472
+ if (extensionPattern.test(url)) {
11473
+ baseUrl = url.replace(extensionPattern, "");
11474
+ }
11475
+ if (baseUrl) {
11476
+ var atlasUrl = baseUrl + ".atlas";
11477
+ assetPath.atlasPath = atlasUrl;
11478
+ }
11965
11479
  }
11966
- return fileExtensions;
11967
11480
  };
11968
- SpineLoader.getUrlExtension = function getUrlExtension(url, fileExtension) {
11969
- if (fileExtension) {
11970
- return fileExtension;
11971
- }
11972
- var regex = /\/([^\/?#]+)\.([a-zA-Z0-9]+)(\?|#|$)|\?[^#]*\.([a-zA-Z0-9]+)(\?|#|$)/;
11481
+ SpineLoader._getUrlExtension = function _getUrlExtension(url) {
11482
+ var regex = /\.(\w+)(\?|$)/;
11973
11483
  var match = url.match(regex);
11974
- if (match) {
11975
- return match[2] || match[4];
11976
- }
11977
- return null;
11484
+ return match ? match[1] : null;
11978
11485
  };
11979
11486
  return SpineLoader;
11980
11487
  }(Loader);
11981
- SpineLoader.imageExtensions = [
11982
- "png",
11983
- "jpg",
11984
- "webp",
11985
- "jpeg",
11986
- "ktx",
11987
- "ktx2"
11988
- ];
11989
- SpineLoader.skeletonExtensions = [
11990
- "skel",
11991
- "json",
11992
- "bin"
11993
- ];
11488
+ SpineLoader._decoder = new TextDecoder("utf-8");
11994
11489
  SpineLoader = __decorate([
11995
- resourceLoader("spine", [
11490
+ resourceLoader("Spine", [
11996
11491
  "json",
11997
11492
  "bin",
11998
11493
  "skel"
11999
11494
  ])
12000
11495
  ], SpineLoader);
11496
+ var DeprecatedSpineLoader = /*#__PURE__*/ function(SpineLoader) {
11497
+ _inherits(DeprecatedSpineLoader, SpineLoader);
11498
+ function DeprecatedSpineLoader() {
11499
+ return SpineLoader.apply(this, arguments) || this;
11500
+ }
11501
+ return DeprecatedSpineLoader;
11502
+ }(SpineLoader);
11503
+ DeprecatedSpineLoader = __decorate([
11504
+ resourceLoader("spine", [
11505
+ "json",
11506
+ "bin",
11507
+ "skel"
11508
+ ])
11509
+ ], DeprecatedSpineLoader);
12001
11510
 
12002
- var EditorSpineAtlasLoader = /*#__PURE__*/ function(Loader) {
12003
- _inherits(EditorSpineAtlasLoader, Loader);
12004
- function EditorSpineAtlasLoader() {
11511
+ var SpineAtlasLoader = /*#__PURE__*/ function(Loader) {
11512
+ _inherits(SpineAtlasLoader, Loader);
11513
+ function SpineAtlasLoader() {
12005
11514
  return Loader.apply(this, arguments) || this;
12006
11515
  }
12007
- var _proto = EditorSpineAtlasLoader.prototype;
11516
+ var _proto = SpineAtlasLoader.prototype;
12008
11517
  _proto.load = function load(item, resourceManager) {
12009
- return new AssetPromise(/*#__PURE__*/ _async_to_generator(function(resolve) {
12010
- var text, _JSON_parse, atlasText, textureRefs, promises, textures, textureAtlas;
12011
- return __generator(this, function(_state) {
12012
- switch(_state.label){
12013
- case 0:
12014
- return [
12015
- 4,
12016
- resourceManager._request(item.url, {
12017
- type: "text"
12018
- })
12019
- ];
12020
- case 1:
12021
- text = _state.sent();
12022
- _JSON_parse = JSON.parse(text), atlasText = _JSON_parse.data, textureRefs = _JSON_parse.textures;
11518
+ return new AssetPromise(function(resolve, reject) {
11519
+ var engine = resourceManager.engine;
11520
+ var spineAtlasAsset = {
11521
+ atlasPath: "",
11522
+ imagePaths: [],
11523
+ imageExtensions: []
11524
+ };
11525
+ if (!item.urls) {
11526
+ SpineAtlasLoader._assignAssetPathsFromUrl(item.url, spineAtlasAsset, resourceManager);
11527
+ } else {
11528
+ var urls = item.urls;
11529
+ for(var i = 0, len = urls.length; i < len; i += 1){
11530
+ var url = urls[i];
11531
+ SpineAtlasLoader._groupAssetsByExtension(url, spineAtlasAsset, resourceManager);
11532
+ }
11533
+ }
11534
+ var atlasPath = spineAtlasAsset.atlasPath;
11535
+ if (!atlasPath) {
11536
+ reject(new Error("Failed to load spine atlas. Please check the file path and ensure the file extension is included."));
11537
+ return;
11538
+ }
11539
+ var imagePaths = spineAtlasAsset.imagePaths;
11540
+ if (imagePaths.length === 0) {
11541
+ var atlasPath1 = item.url;
11542
+ LoaderUtils.loadTextureAtlas(atlasPath1, engine, reject).then(function(textureAtlas) {
11543
+ resolve(textureAtlas);
11544
+ }).catch(function(err) {
11545
+ reject(err);
11546
+ });
11547
+ } else {
11548
+ var atlasPath2 = spineAtlasAsset.atlasPath, imagePaths1 = spineAtlasAsset.imagePaths, imageExtensions = spineAtlasAsset.imageExtensions;
11549
+ if (imagePaths1.length > 0) {
11550
+ Promise.all([
12023
11551
  // @ts-ignore
12024
- promises = textureRefs.map(function(refItem) {
12025
- return resourceManager.getResourceByRef({
12026
- refId: refItem.refId
12027
- });
12028
- });
12029
- return [
12030
- 4,
12031
- Promise.all(promises)
12032
- ];
12033
- case 2:
12034
- textures = _state.sent();
12035
- textureAtlas = createTextureAtlas(atlasText, textures);
11552
+ resourceManager._request(atlasPath2, {
11553
+ type: "text"
11554
+ }),
11555
+ LoaderUtils.loadTexturesByPaths(imagePaths1, imageExtensions, engine, reject)
11556
+ ]).then(function(param) {
11557
+ var atlasText = param[0], textures = param[1];
11558
+ var textureAtlas = LoaderUtils.createTextureAtlas(atlasText, textures);
11559
+ resolve(textureAtlas);
11560
+ }).catch(function(err) {
11561
+ reject(err);
11562
+ });
11563
+ } else {
11564
+ LoaderUtils.loadTextureAtlas(atlasPath2, engine, reject).then(function(textureAtlas) {
12036
11565
  resolve(textureAtlas);
12037
- return [
12038
- 2
12039
- ];
11566
+ }).catch(function(err) {
11567
+ reject(err);
11568
+ });
12040
11569
  }
12041
- });
12042
- }));
11570
+ }
11571
+ });
11572
+ };
11573
+ SpineAtlasLoader._groupAssetsByExtension = function _groupAssetsByExtension(url, assetPath, resourceManager) {
11574
+ var ext = SpineLoader._getUrlExtension(url);
11575
+ if (!ext) return;
11576
+ if (ext === "atlas") {
11577
+ assetPath.atlasPath = url;
11578
+ }
11579
+ if ([
11580
+ "png",
11581
+ "jpg",
11582
+ "webp",
11583
+ "jpeg",
11584
+ "ktx",
11585
+ "ktx2"
11586
+ ].includes(ext)) {
11587
+ assetPath.imagePaths.push(url);
11588
+ }
11589
+ };
11590
+ SpineAtlasLoader._assignAssetPathsFromUrl = function _assignAssetPathsFromUrl(url, assetPath, resourceManager) {
11591
+ var ext = SpineLoader._getUrlExtension(url);
11592
+ if (ext === "atlas") {
11593
+ var _resourceManager__virtualPathResourceMap_url, _resourceManager__virtualPathResourceMap;
11594
+ assetPath.atlasPath = url;
11595
+ // @ts-ignore
11596
+ var atlasDependency = resourceManager == null ? void 0 : (_resourceManager__virtualPathResourceMap = resourceManager._virtualPathResourceMap) == null ? void 0 : (_resourceManager__virtualPathResourceMap_url = _resourceManager__virtualPathResourceMap[url]) == null ? void 0 : _resourceManager__virtualPathResourceMap_url.dependentAssetMap;
11597
+ if (atlasDependency) {
11598
+ for(var key in atlasDependency){
11599
+ var imageVirtualPath = atlasDependency[key];
11600
+ assetPath.imagePaths.push(imageVirtualPath);
11601
+ }
11602
+ }
11603
+ }
12043
11604
  };
12044
- return EditorSpineAtlasLoader;
11605
+ return SpineAtlasLoader;
12045
11606
  }(Loader);
12046
- EditorSpineAtlasLoader = __decorate([
12047
- resourceLoader("EditorSpineAtlas", [
11607
+ SpineAtlasLoader = __decorate([
11608
+ resourceLoader("SpineAtlas", [
12048
11609
  "atlas"
12049
11610
  ])
12050
- ], EditorSpineAtlasLoader);
11611
+ ], SpineAtlasLoader);
11612
+
11613
+ var LoaderObject = /*#__PURE__*/Object.freeze({
11614
+ __proto__: null,
11615
+ SpineResource: SpineResource,
11616
+ LoaderUtils: LoaderUtils
11617
+ });
12051
11618
 
12052
- var version = "4.2.0";
12053
- Loader.registerClass("SpineAnimationRenderer", SpineAnimationRenderer);
11619
+ var RendererObject = /*#__PURE__*/Object.freeze({
11620
+ __proto__: null,
11621
+ SpineAnimationRenderer: SpineAnimationRenderer,
11622
+ SpineMaterial: SpineMaterial
11623
+ });
11624
+
11625
+ for(var key in RendererObject){
11626
+ Loader.registerClass(key, RendererObject[key]);
11627
+ }
11628
+ for(var key1 in LoaderObject){
11629
+ Loader.registerClass(key1, LoaderObject[key1]);
11630
+ }
11631
+ var version = "4.2.1";
12054
11632
  console.log("Galacean spine version: " + version);
12055
11633
 
12056
- 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, 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, SkeletonDataResource, SkeletonJson, Skin, SkinEntry, Slot, SlotData, SpacingMode, SpineAnimationRenderer, StringSet, Texture, TextureAtlas, TextureAtlasPage, TextureAtlasRegion, TextureFilter, TextureRegion, TextureWrap, TimeKeeper, Timeline, TrackEntry, TransformConstraint, TransformConstraintData, TransformConstraintTimeline, TranslateTimeline, TranslateXTimeline, TranslateYTimeline, Triangulator, Utils, Vector2, VertexAttachment, WindowedMean, createTextureAtlas, version };
11634
+ 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 };
12057
11635
  //# sourceMappingURL=module.js.map