@galacean/engine-spine 0.0.0-experimental-2.0-migrate.2 → 0.0.0-experimental-2.0-migrate.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -948,7 +948,7 @@
948
948
  for(var key1 in LoaderObject){
949
949
  engine.Loader.registerClass(key1, LoaderObject[key1]);
950
950
  }
951
- var version = "0.0.0-experimental-2.0-migrate.2";
951
+ var version = "0.0.0-experimental-2.0-migrate.4";
952
952
  console.log("Galacean spine version: " + version);
953
953
 
954
954
  exports.LoaderUtils = LoaderUtils;
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean=e.Galacean||{},e.Galacean.Spine={}),e.Galacean)}(this,function(e,t){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}function a(e,t,n,r){var a,i=arguments.length,o=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,n,o):a(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}"function"==typeof SuppressedError&&SuppressedError;var i,o=null;function s(){if(!o)throw Error('@galacean/engine-spine: no spine runtime registered. Import a spine core package, e.g. `import "@galacean/engine-spine-core-4.2"`.');return o}var l=/*#__PURE__*/function(){function e(){}return e.createSkeletonData=function(e,t,n){return s().createSkeletonData(e,t,n)},e.createTextureAtlas=function(e,t){return s().createTextureAtlas(e,t)},e.loadTexturesByPaths=function(e,n,r,a){var i=r.resourceManager,o=i._virtualPathResourceMap;return Promise.all(e.map(function(e,r){var a=n[r],s=t.AssetType.Texture,l=o[e];return l?s=l.type:"ktx"===a?s=t.AssetType.KTX:"ktx2"===a&&(s=t.AssetType.KTX2),i.load({url:e,type:s})})).catch(function(e){return a(e),[]})},e.loadTextureAtlas=function(n,r,a){var i,o=e.getBaseUrl(n),l=r.resourceManager;return l._request(n,{type:"text"}).then(function(e){i=e;var n=s();return Promise.all(n.parseAtlasPageNames(i).map(function(e){return l.load({url:o+e,type:t.AssetType.Texture})})).then(function(e){return n.createTextureAtlas(i,e)})}).catch(function(e){return a(Error("Spine Atlas: "+n+" load error: "+e)),null})},e.getBaseUrl=function(e){if(!/^(http|https|ftp):\/\/.*/i.test(e)){var t=e.lastIndexOf("/");return -1===t?"":e.substring(0,t+1)}var n=new URL(e),r=n.origin+n.pathname;return r.endsWith("/")?r:r.substring(0,r.lastIndexOf("/")+1)},e}();function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}var d=((i={})[i.Normal=0]="Normal",i[i.Additive=1]="Additive",i[i.Multiply=2]="Multiply",i[i.Screen=3]="Screen",i),h=t.BlendFactor.SourceAlpha,p=t.BlendFactor.One,f=t.BlendFactor.DestinationColor,_=t.BlendFactor.OneMinusSourceColor,v=t.BlendFactor.OneMinusSourceAlpha,m=/*#__PURE__*/function(e){function n(n){var r;return(r=e.call(this,n,t.Shader.find("2D/Spine"))||this)._blendMode=d.Normal,r._setBlendMode(d.Normal,!1),r}r(n,e);var a=n.prototype;return a._setTintBlack=function(e){e?this.shaderData.enableMacro("RENDERER_TINT_BLACK"):this.shaderData.disableMacro("RENDERER_TINT_BLACK")},a._setPremultipliedAlpha=function(e){this.shaderData.setFloat("renderer_PremultipliedAlpha",e?1:0)},a._setTexture=function(e){this.shaderData.setTexture("material_SpineTexture",e)},a._setBlendMode=function(e,t){var r=this.shaderData,a=n._sourceColorBlendFactorProp,i=n._destinationColorBlendFactorProp,o=n._sourceAlphaBlendFactorProp,s=n._destinationAlphaBlendFactorProp;switch(this._blendMode=e,e){case d.Additive:r.setInt(a,t?p:h),r.setInt(i,p),r.setInt(o,p),r.setInt(s,p);break;case d.Multiply:r.setInt(a,f),r.setInt(i,v),r.setInt(o,p),r.setInt(s,v);break;case d.Screen:r.setInt(a,p),r.setInt(i,_),r.setInt(o,p),r.setInt(s,_);break;default:r.setInt(a,t?p:h),r.setInt(i,v),r.setInt(o,p),r.setInt(s,v)}},a._getBlendMode=function(){return this._blendMode},n}(t.Material);m._sourceColorBlendFactorProp=t.ShaderProperty.getByName("sourceColorBlendFactor"),m._destinationColorBlendFactorProp=t.ShaderProperty.getByName("destinationColorBlendFactor"),m._sourceAlphaBlendFactorProp=t.ShaderProperty.getByName("sourceAlphaBlendFactor"),m._destinationAlphaBlendFactorProp=t.ShaderProperty.getByName("destinationAlphaBlendFactor");var g={withoutTint:9,withTint:12},y=/*#__PURE__*/function(e){function n(r){(a=e.call(this,r)||this).zSpacing=.001,a.premultipliedAlpha=!1,a._tintBlack=!1,a.defaultConfig=new x,a._subPrimitives=[],a._vertices=new Float32Array,a._indices=new Uint16Array,a._needResizeBuffer=!1,a._vertexCount=0,a._localBounds=new t.BoundingBox(new t.Vector3(1/0,1/0,1/0),new t.Vector3(-1/0,-1/0,-1/0));var a,i=new t.Primitive(a.engine);return a._primitive=i,a._primitive._addReferCount(1),i.addVertexElement(n._positionVertexElement),i.addVertexElement(n._lightColorVertexElement),i.addVertexElement(n._uvVertexElement),i.addVertexElement(n._darkColorVertexElement),a}r(n,e);var a=n.prototype;return a._onEnable=function(){this._applyDefaultConfig()},a.update=function(e){var t=this._state,n=this._skeleton;if(t&&n){var r=s();r.updateState(n,t,e),r.buildPrimitive(n,this),this._dirtyUpdateFlag|=1}},a._render=function(e){var t=this._primitive,n=this._subPrimitives,r=this._materials;if(n)for(var a=this.engine,i=this.priority,o=this._distanceForSort,s=a._renderElementPool,l=e.camera._renderPipeline,u=0,c=n.length;u<c;u++){var d=r[u];if(d){(d.destroyed||d.shader.destroyed)&&(d=a._basicResources.meshMagentaMaterial);var h=s.get();h.set(this,d,t,n[u]),h.priority=i,h.distanceForSort=o,l.pushRenderElement(e,h)}}},a._updateBounds=function(e){t.BoundingBox.transform(this._localBounds,this.entity.transform.worldMatrix,e)},a._setSkeleton=function(e){this._skeleton=e},a._setState=function(e){this._state=e},a._cloneTo=function(e){if(this._skeleton&&this._state){var t=s(),n=t.createSkeleton(this._skeleton.data),r=t.createAnimationState(this._state.data);e._setSkeleton(n),e._setState(r)}},a._onDestroy=function(){this._clearMaterialCache(),this._subPrimitives.length=0;var t,n,r=this._primitive;r&&(r._addReferCount(-1),r.destroy(),this._primitive=null),null==(t=this._vertexBuffer)||t.destroy(),null==(n=this._indexBuffer)||n.destroy(),this._vertexBuffer=null,this._indexBuffer=null,this._resource=null,this._skeleton=null,this._state=null,e.prototype._onDestroy.call(this)},a._createAndBindBuffer=function(e){var n=this.engine,r=this._primitive,a=this._vertexBuffer,i=this._indexBuffer;this._vertexCount=e;var o=this.tintBlack?g.withTint:g.withoutTint;this._vertices=new Float32Array(e*o),this._indices=new Uint16Array(e);var s=new t.Buffer(n,t.BufferBindFlag.VertexBuffer,this._vertices,t.BufferUsage.Dynamic),l=new t.Buffer(n,t.BufferBindFlag.IndexBuffer,this._indices,t.BufferUsage.Dynamic);this._indexBuffer=l,this._vertexBuffer=s;var u=new t.VertexBufferBinding(s,o<<2);this._primitive.setVertexBufferBinding(0,u);var c=new t.IndexBufferBinding(l,t.IndexFormat.UInt16);r.setIndexBufferBinding(c),null==a||a.destroy(),null==i||i.destroy()},a._addSubPrimitive=function(e){this._subPrimitives.push(e)},a._clearSubPrimitives=function(){this._subPrimitives.length=0},a._getMaterial=function(e,t){var r=this.engine,a=this.premultipliedAlpha,i=this.tintBlack,o=e.instanceId+"_"+t+"_"+(a?1:0)+"_"+(i?1:0),s=n._materialCacheMap.get(o);return s||((s=new m(r)).isGCIgnored=!0,s._cacheKey=o,n._materialCacheMap.set(o,s)),s._setBlendMode(t,a),s._setTexture(e),s._setTintBlack(i),s._setPremultipliedAlpha(a),s},a._clearMaterialCache=function(){for(var e=n._materialCacheMap,t=this._materials,r=0,a=t.length;r<a;r+=1){var i=t[r];(null!=m&&"undefined"!=typeof Symbol&&m[Symbol.hasInstance]?!!m[Symbol.hasInstance](i):i instanceof m)&&e.delete(i._cacheKey)}},a._applyDefaultConfig=function(){var e=this.skeleton,t=this.state;if(e&&t){var n=this.defaultConfig,r=n.animationName,a=n.skinName,i=n.loop;"default"!==a&&(e.setSkinByName(a),e.setToSetupPose()),r&&t.setAnimation(0,r,i)}},c(n,[{key:"tintBlack",get:function(){return this._tintBlack},set:function(e){this._tintBlack!==e&&(this._tintBlack=e,this._needResizeBuffer=!0)}},{key:"state",get:function(){return this._state}},{key:"skeleton",get:function(){return this._skeleton}},{key:"resource",get:function(){return this._resource},set:function(e){if(!e){this._state=null,this._skeleton=null,this._resource=null;return}this._resource=e;var t=e.skeletonData,n=e.stateData,r=s(),a=r.createSkeleton(t),i=r.createAnimationState(n);this._setSkeleton(a),this._setState(i),this._applyDefaultConfig()}}]),n}(t.Renderer);y._positionVertexElement=new t.VertexElement("POSITION",0,t.VertexElementFormat.Vector3,0),y._lightColorVertexElement=new t.VertexElement("LIGHT_COLOR",12,t.VertexElementFormat.Vector4,0),y._uvVertexElement=new t.VertexElement("TEXCOORD_0",28,t.VertexElementFormat.Vector2,0),y._darkColorVertexElement=new t.VertexElement("DARK_COLOR",36,t.VertexElementFormat.Vector3,0),y._materialCacheMap=new Map,a([t.ignoreClone],y.prototype,"_primitive",void 0),a([t.ignoreClone],y.prototype,"_subPrimitives",void 0),a([t.ignoreClone],y.prototype,"_indexBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertexBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertices",void 0),a([t.ignoreClone],y.prototype,"_indices",void 0),a([t.ignoreClone],y.prototype,"_needResizeBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertexCount",void 0),a([t.ignoreClone],y.prototype,"_resource",void 0),a([t.ignoreClone],y.prototype,"_localBounds",void 0),a([t.ignoreClone],y.prototype,"_skeleton",void 0),a([t.ignoreClone],y.prototype,"_state",void 0);var x=/*#__PURE__*/function(e){function t(t,n,r){var a;return void 0===t&&(t=!0),void 0===n&&(n=null),void 0===r&&(r="default"),(a=e.call(this)||this).loop=t,a.animationName=n,a.skinName=r,a}return r(t,e),t}(t.DataObject),B=/*#__PURE__*/function(e){function n(t,n,r){var a;return(a=e.call(this,t)||this)._texturesInSpineAtlas=[],a.url=r,a._skeletonData=n,a._stateData=s().createAnimationStateData(n),a._associationTextureInSkeletonData(n),a._createTemplate(),a}r(n,e);var a=n.prototype;return a.instantiate=function(){return this._template.clone()},a._onDestroy=function(){e.prototype._onDestroy.call(this),this._disassociationSuperResource(),this._skeletonData=null,this._stateData=null},a._createTemplate=function(){var e=this._extractFileName(this.url),n=new t.Entity(this.engine,e),r=n.addComponent(y),a=s(),i=a.createSkeleton(this._skeletonData),o=a.createAnimationState(this._stateData);r._setSkeleton(i),r._setState(o),n._markAsTemplate(this),this._template=n},a._associationTextureInSkeletonData=function(e){for(var t=e.skins,n=e.slots,r=this._texturesInSpineAtlas,a=0,i=t.length;a<i;a++)for(var o=0,s=n.length;o<s;o++){var l,u=n[o],c=t[a].getAttachment(u.index,u.name),d=null==c?void 0:null==(l=c.region)?void 0:l.texture.getImage();d&&!r.includes(d)&&(r.push(d),d._associationSuperResource(this))}},a._disassociationSuperResource=function(){for(var e=this._texturesInSpineAtlas,t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},a._extractFileName=function(e){if(!e)return"Spine Entity";var t=e.match(/\/([^\/]+?)(\.[^\/]*)?$/);return t?t[1]:"Spine Entity"},c(n,[{key:"skeletonData",get:function(){return this._skeletonData}},{key:"stateData",get:function(){return this._stateData}}]),n}(t.ReferResource),P=/*#__PURE__*/function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var a=n.prototype;return a.load=function(e,r){var a=this;return new t.AssetPromise(function(t,i){var o={fileName:"",skeletonRawData:"",spineAssetPath:{atlasPath:null,skeletonPath:null,extraPaths:[]}},s=o.spineAssetPath;if(e.urls)for(var l=e.urls,u=0,c=l.length;u<c;u+=1){var d=l[u];n._groupAssetsByExtension(d,s)}else n._assignAssetPathsFromUrl(e.url,s,r);var h=s.skeletonPath,p=s.atlasPath;if(!h||!p){i(Error("Failed to load spine assets. Please check the file path and ensure the file extension is included."));return}r._request(h,{type:"arraybuffer"}).then(function(e){o.skeletonRawData=e;var t=n._decoder.decode(e);return t.startsWith("{")&&(o.skeletonRawData=t),a._loadAndCreateSpineResource(o,r)}).then(t).catch(i)})},a._loadAndCreateSpineResource=function(e,t){var n=t.engine,r=e.skeletonRawData,a=e.spineAssetPath,i=a.skeletonPath,o=a.atlasPath,s=a.extraPaths;return(0===s.length?t.load({url:o,type:"SpineAtlas"}):t.load({urls:[o].concat(s),type:"SpineAtlas"})).then(function(e){return new B(n,l.createSkeletonData(r,e,.01),i)})},n._groupAssetsByExtension=function(e,t){var r=n._getUrlExtension(e);r&&(["skel","json","bin"].includes(r)?t.skeletonPath=e:"atlas"===r?t.atlasPath=e:t.extraPaths.push(e))},n._assignAssetPathsFromUrl=function(e,t,r){if(n._getUrlExtension(e)){t.skeletonPath=e;var a=null==r?void 0:null==(o=r._virtualPathResourceMap)?void 0:null==(i=o[e])?void 0:i.dependentAssetMap;if(a)t.atlasPath=a.atlas;else{var i,o,s,l=/\.(json|bin|skel)$/;if(l.test(e)&&(s=e.replace(l,"")),s){var u=s+".atlas";t.atlasPath=u}}}},n._getUrlExtension=function(e){var t=e.match(/\.(\w+)(\?|$)/);return t?t[1]:null},n}(t.Loader);P._decoder=new TextDecoder("utf-8"),P=a([t.resourceLoader("Spine",["json","bin","skel"])],P);var S=/*#__PURE__*/function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.prototype.load=function(e,r){return new t.AssetPromise(function(t,a){var i=r.engine,o={atlasPath:"",imagePaths:[],imageExtensions:[]};if(e.urls)for(var s=e.urls,u=0,c=s.length;u<c;u+=1){var d=s[u];n._groupAssetsByExtension(d,o,r)}else n._assignAssetPathsFromUrl(e.url,o,r);var h=o.atlasPath;if(!h){a(Error("Failed to load spine atlas. Please check the file path and ensure the file extension is included."));return}if(0===o.imagePaths.length)l.loadTextureAtlas(h,i,a).then(function(e){t(e)}).catch(function(e){a(e)});else{var p=o.atlasPath,f=o.imagePaths,_=o.imageExtensions;f.length>0?Promise.all([r._request(p,{type:"text"}),l.loadTexturesByPaths(f,_,i,a)]).then(function(e){var n=e[0],r=e[1];t(l.createTextureAtlas(n,r))}).catch(function(e){a(e)}):l.loadTextureAtlas(p,i,a).then(function(e){t(e)}).catch(function(e){a(e)})}})},n._groupAssetsByExtension=function(e,t,n){var r=P._getUrlExtension(e);r&&("atlas"===r&&(t.atlasPath=e),["png","jpg","webp","jpeg","ktx","ktx2"].includes(r)&&t.imagePaths.push(e))},n._assignAssetPathsFromUrl=function(e,t,n){if("atlas"===P._getUrlExtension(e)){t.atlasPath=e;var r,a,i=null==n?void 0:null==(a=n._virtualPathResourceMap)?void 0:null==(r=a[e])?void 0:r.dependentAssetMap;if(i)for(var o in i){var s=i[o];t.imagePaths.push(s)}}},n}(t.Loader);S=a([t.resourceLoader("SpineAtlas",["atlas"],!1)],S);var k=/*#__PURE__*/Object.freeze({__proto__:null,SpineResource:B,LoaderUtils:l}),A=/*#__PURE__*/Object.freeze({__proto__:null,SpineAnimationRenderer:y,SpineMaterial:m});for(var C in A)t.Loader.registerClass(C,A[C]);for(var E in k)t.Loader.registerClass(E,k[E]);var b="0.0.0-experimental-2.0-migrate.2";console.log("Galacean spine version: "+b),e.LoaderUtils=l,e.SpineAnimationRenderer=y,e.SpineBlendMode=d,e.SpineMaterial=m,e.SpineResource=B,e.SpineVertexStride=g,e.getSpineRuntime=s,e.registerSpineRuntime=function(e){o=e},e.version=b,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean=e.Galacean||{},e.Galacean.Spine={}),e.Galacean)}(this,function(e,t){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&n(e,t)}function a(e,t,n,r){var a,i=arguments.length,o=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,n,o):a(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}"function"==typeof SuppressedError&&SuppressedError;var i,o=null;function s(){if(!o)throw Error('@galacean/engine-spine: no spine runtime registered. Import a spine core package, e.g. `import "@galacean/engine-spine-core-4.2"`.');return o}var l=/*#__PURE__*/function(){function e(){}return e.createSkeletonData=function(e,t,n){return s().createSkeletonData(e,t,n)},e.createTextureAtlas=function(e,t){return s().createTextureAtlas(e,t)},e.loadTexturesByPaths=function(e,n,r,a){var i=r.resourceManager,o=i._virtualPathResourceMap;return Promise.all(e.map(function(e,r){var a=n[r],s=t.AssetType.Texture,l=o[e];return l?s=l.type:"ktx"===a?s=t.AssetType.KTX:"ktx2"===a&&(s=t.AssetType.KTX2),i.load({url:e,type:s})})).catch(function(e){return a(e),[]})},e.loadTextureAtlas=function(n,r,a){var i,o=e.getBaseUrl(n),l=r.resourceManager;return l._request(n,{type:"text"}).then(function(e){i=e;var n=s();return Promise.all(n.parseAtlasPageNames(i).map(function(e){return l.load({url:o+e,type:t.AssetType.Texture})})).then(function(e){return n.createTextureAtlas(i,e)})}).catch(function(e){return a(Error("Spine Atlas: "+n+" load error: "+e)),null})},e.getBaseUrl=function(e){if(!/^(http|https|ftp):\/\/.*/i.test(e)){var t=e.lastIndexOf("/");return -1===t?"":e.substring(0,t+1)}var n=new URL(e),r=n.origin+n.pathname;return r.endsWith("/")?r:r.substring(0,r.lastIndexOf("/")+1)},e}();function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}var d=((i={})[i.Normal=0]="Normal",i[i.Additive=1]="Additive",i[i.Multiply=2]="Multiply",i[i.Screen=3]="Screen",i),h=t.BlendFactor.SourceAlpha,p=t.BlendFactor.One,f=t.BlendFactor.DestinationColor,_=t.BlendFactor.OneMinusSourceColor,v=t.BlendFactor.OneMinusSourceAlpha,m=/*#__PURE__*/function(e){function n(n){var r;return(r=e.call(this,n,t.Shader.find("2D/Spine"))||this)._blendMode=d.Normal,r._setBlendMode(d.Normal,!1),r}r(n,e);var a=n.prototype;return a._setTintBlack=function(e){e?this.shaderData.enableMacro("RENDERER_TINT_BLACK"):this.shaderData.disableMacro("RENDERER_TINT_BLACK")},a._setPremultipliedAlpha=function(e){this.shaderData.setFloat("renderer_PremultipliedAlpha",e?1:0)},a._setTexture=function(e){this.shaderData.setTexture("material_SpineTexture",e)},a._setBlendMode=function(e,t){var r=this.shaderData,a=n._sourceColorBlendFactorProp,i=n._destinationColorBlendFactorProp,o=n._sourceAlphaBlendFactorProp,s=n._destinationAlphaBlendFactorProp;switch(this._blendMode=e,e){case d.Additive:r.setInt(a,t?p:h),r.setInt(i,p),r.setInt(o,p),r.setInt(s,p);break;case d.Multiply:r.setInt(a,f),r.setInt(i,v),r.setInt(o,p),r.setInt(s,v);break;case d.Screen:r.setInt(a,p),r.setInt(i,_),r.setInt(o,p),r.setInt(s,_);break;default:r.setInt(a,t?p:h),r.setInt(i,v),r.setInt(o,p),r.setInt(s,v)}},a._getBlendMode=function(){return this._blendMode},n}(t.Material);m._sourceColorBlendFactorProp=t.ShaderProperty.getByName("sourceColorBlendFactor"),m._destinationColorBlendFactorProp=t.ShaderProperty.getByName("destinationColorBlendFactor"),m._sourceAlphaBlendFactorProp=t.ShaderProperty.getByName("sourceAlphaBlendFactor"),m._destinationAlphaBlendFactorProp=t.ShaderProperty.getByName("destinationAlphaBlendFactor");var g={withoutTint:9,withTint:12},y=/*#__PURE__*/function(e){function n(r){(a=e.call(this,r)||this).zSpacing=.001,a.premultipliedAlpha=!1,a._tintBlack=!1,a.defaultConfig=new x,a._subPrimitives=[],a._vertices=new Float32Array,a._indices=new Uint16Array,a._needResizeBuffer=!1,a._vertexCount=0,a._localBounds=new t.BoundingBox(new t.Vector3(1/0,1/0,1/0),new t.Vector3(-1/0,-1/0,-1/0));var a,i=new t.Primitive(a.engine);return a._primitive=i,a._primitive._addReferCount(1),i.addVertexElement(n._positionVertexElement),i.addVertexElement(n._lightColorVertexElement),i.addVertexElement(n._uvVertexElement),i.addVertexElement(n._darkColorVertexElement),a}r(n,e);var a=n.prototype;return a._onEnable=function(){this._applyDefaultConfig()},a.update=function(e){var t=this._state,n=this._skeleton;if(t&&n){var r=s();r.updateState(n,t,e),r.buildPrimitive(n,this),this._dirtyUpdateFlag|=1}},a._render=function(e){var t=this._primitive,n=this._subPrimitives,r=this._materials;if(n)for(var a=this.engine,i=this.priority,o=this._distanceForSort,s=a._renderElementPool,l=e.camera._renderPipeline,u=0,c=n.length;u<c;u++){var d=r[u];if(d){(d.destroyed||d.shader.destroyed)&&(d=a._basicResources.meshMagentaMaterial);var h=s.get();h.set(this,d,t,n[u]),h.priority=i,h.distanceForSort=o,l.pushRenderElement(e,h)}}},a._updateBounds=function(e){t.BoundingBox.transform(this._localBounds,this.entity.transform.worldMatrix,e)},a._setSkeleton=function(e){this._skeleton=e},a._setState=function(e){this._state=e},a._cloneTo=function(e){if(this._skeleton&&this._state){var t=s(),n=t.createSkeleton(this._skeleton.data),r=t.createAnimationState(this._state.data);e._setSkeleton(n),e._setState(r)}},a._onDestroy=function(){this._clearMaterialCache(),this._subPrimitives.length=0;var t,n,r=this._primitive;r&&(r._addReferCount(-1),r.destroy(),this._primitive=null),null==(t=this._vertexBuffer)||t.destroy(),null==(n=this._indexBuffer)||n.destroy(),this._vertexBuffer=null,this._indexBuffer=null,this._resource=null,this._skeleton=null,this._state=null,e.prototype._onDestroy.call(this)},a._createAndBindBuffer=function(e){var n=this.engine,r=this._primitive,a=this._vertexBuffer,i=this._indexBuffer;this._vertexCount=e;var o=this.tintBlack?g.withTint:g.withoutTint;this._vertices=new Float32Array(e*o),this._indices=new Uint16Array(e);var s=new t.Buffer(n,t.BufferBindFlag.VertexBuffer,this._vertices,t.BufferUsage.Dynamic),l=new t.Buffer(n,t.BufferBindFlag.IndexBuffer,this._indices,t.BufferUsage.Dynamic);this._indexBuffer=l,this._vertexBuffer=s;var u=new t.VertexBufferBinding(s,o<<2);this._primitive.setVertexBufferBinding(0,u);var c=new t.IndexBufferBinding(l,t.IndexFormat.UInt16);r.setIndexBufferBinding(c),null==a||a.destroy(),null==i||i.destroy()},a._addSubPrimitive=function(e){this._subPrimitives.push(e)},a._clearSubPrimitives=function(){this._subPrimitives.length=0},a._getMaterial=function(e,t){var r=this.engine,a=this.premultipliedAlpha,i=this.tintBlack,o=e.instanceId+"_"+t+"_"+(a?1:0)+"_"+(i?1:0),s=n._materialCacheMap.get(o);return s||((s=new m(r)).isGCIgnored=!0,s._cacheKey=o,n._materialCacheMap.set(o,s)),s._setBlendMode(t,a),s._setTexture(e),s._setTintBlack(i),s._setPremultipliedAlpha(a),s},a._clearMaterialCache=function(){for(var e=n._materialCacheMap,t=this._materials,r=0,a=t.length;r<a;r+=1){var i=t[r];(null!=m&&"undefined"!=typeof Symbol&&m[Symbol.hasInstance]?!!m[Symbol.hasInstance](i):i instanceof m)&&e.delete(i._cacheKey)}},a._applyDefaultConfig=function(){var e=this.skeleton,t=this.state;if(e&&t){var n=this.defaultConfig,r=n.animationName,a=n.skinName,i=n.loop;"default"!==a&&(e.setSkinByName(a),e.setToSetupPose()),r&&t.setAnimation(0,r,i)}},c(n,[{key:"tintBlack",get:function(){return this._tintBlack},set:function(e){this._tintBlack!==e&&(this._tintBlack=e,this._needResizeBuffer=!0)}},{key:"state",get:function(){return this._state}},{key:"skeleton",get:function(){return this._skeleton}},{key:"resource",get:function(){return this._resource},set:function(e){if(!e){this._state=null,this._skeleton=null,this._resource=null;return}this._resource=e;var t=e.skeletonData,n=e.stateData,r=s(),a=r.createSkeleton(t),i=r.createAnimationState(n);this._setSkeleton(a),this._setState(i),this._applyDefaultConfig()}}]),n}(t.Renderer);y._positionVertexElement=new t.VertexElement("POSITION",0,t.VertexElementFormat.Vector3,0),y._lightColorVertexElement=new t.VertexElement("LIGHT_COLOR",12,t.VertexElementFormat.Vector4,0),y._uvVertexElement=new t.VertexElement("TEXCOORD_0",28,t.VertexElementFormat.Vector2,0),y._darkColorVertexElement=new t.VertexElement("DARK_COLOR",36,t.VertexElementFormat.Vector3,0),y._materialCacheMap=new Map,a([t.ignoreClone],y.prototype,"_primitive",void 0),a([t.ignoreClone],y.prototype,"_subPrimitives",void 0),a([t.ignoreClone],y.prototype,"_indexBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertexBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertices",void 0),a([t.ignoreClone],y.prototype,"_indices",void 0),a([t.ignoreClone],y.prototype,"_needResizeBuffer",void 0),a([t.ignoreClone],y.prototype,"_vertexCount",void 0),a([t.ignoreClone],y.prototype,"_resource",void 0),a([t.ignoreClone],y.prototype,"_localBounds",void 0),a([t.ignoreClone],y.prototype,"_skeleton",void 0),a([t.ignoreClone],y.prototype,"_state",void 0);var x=/*#__PURE__*/function(e){function t(t,n,r){var a;return void 0===t&&(t=!0),void 0===n&&(n=null),void 0===r&&(r="default"),(a=e.call(this)||this).loop=t,a.animationName=n,a.skinName=r,a}return r(t,e),t}(t.DataObject),B=/*#__PURE__*/function(e){function n(t,n,r){var a;return(a=e.call(this,t)||this)._texturesInSpineAtlas=[],a.url=r,a._skeletonData=n,a._stateData=s().createAnimationStateData(n),a._associationTextureInSkeletonData(n),a._createTemplate(),a}r(n,e);var a=n.prototype;return a.instantiate=function(){return this._template.clone()},a._onDestroy=function(){e.prototype._onDestroy.call(this),this._disassociationSuperResource(),this._skeletonData=null,this._stateData=null},a._createTemplate=function(){var e=this._extractFileName(this.url),n=new t.Entity(this.engine,e),r=n.addComponent(y),a=s(),i=a.createSkeleton(this._skeletonData),o=a.createAnimationState(this._stateData);r._setSkeleton(i),r._setState(o),n._markAsTemplate(this),this._template=n},a._associationTextureInSkeletonData=function(e){for(var t=e.skins,n=e.slots,r=this._texturesInSpineAtlas,a=0,i=t.length;a<i;a++)for(var o=0,s=n.length;o<s;o++){var l,u=n[o],c=t[a].getAttachment(u.index,u.name),d=null==c?void 0:null==(l=c.region)?void 0:l.texture.getImage();d&&!r.includes(d)&&(r.push(d),d._associationSuperResource(this))}},a._disassociationSuperResource=function(){for(var e=this._texturesInSpineAtlas,t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},a._extractFileName=function(e){if(!e)return"Spine Entity";var t=e.match(/\/([^\/]+?)(\.[^\/]*)?$/);return t?t[1]:"Spine Entity"},c(n,[{key:"skeletonData",get:function(){return this._skeletonData}},{key:"stateData",get:function(){return this._stateData}}]),n}(t.ReferResource),P=/*#__PURE__*/function(e){function n(){return e.apply(this,arguments)||this}r(n,e);var a=n.prototype;return a.load=function(e,r){var a=this;return new t.AssetPromise(function(t,i){var o={fileName:"",skeletonRawData:"",spineAssetPath:{atlasPath:null,skeletonPath:null,extraPaths:[]}},s=o.spineAssetPath;if(e.urls)for(var l=e.urls,u=0,c=l.length;u<c;u+=1){var d=l[u];n._groupAssetsByExtension(d,s)}else n._assignAssetPathsFromUrl(e.url,s,r);var h=s.skeletonPath,p=s.atlasPath;if(!h||!p){i(Error("Failed to load spine assets. Please check the file path and ensure the file extension is included."));return}r._request(h,{type:"arraybuffer"}).then(function(e){o.skeletonRawData=e;var t=n._decoder.decode(e);return t.startsWith("{")&&(o.skeletonRawData=t),a._loadAndCreateSpineResource(o,r)}).then(t).catch(i)})},a._loadAndCreateSpineResource=function(e,t){var n=t.engine,r=e.skeletonRawData,a=e.spineAssetPath,i=a.skeletonPath,o=a.atlasPath,s=a.extraPaths;return(0===s.length?t.load({url:o,type:"SpineAtlas"}):t.load({urls:[o].concat(s),type:"SpineAtlas"})).then(function(e){return new B(n,l.createSkeletonData(r,e,.01),i)})},n._groupAssetsByExtension=function(e,t){var r=n._getUrlExtension(e);r&&(["skel","json","bin"].includes(r)?t.skeletonPath=e:"atlas"===r?t.atlasPath=e:t.extraPaths.push(e))},n._assignAssetPathsFromUrl=function(e,t,r){if(n._getUrlExtension(e)){t.skeletonPath=e;var a=null==r?void 0:null==(o=r._virtualPathResourceMap)?void 0:null==(i=o[e])?void 0:i.dependentAssetMap;if(a)t.atlasPath=a.atlas;else{var i,o,s,l=/\.(json|bin|skel)$/;if(l.test(e)&&(s=e.replace(l,"")),s){var u=s+".atlas";t.atlasPath=u}}}},n._getUrlExtension=function(e){var t=e.match(/\.(\w+)(\?|$)/);return t?t[1]:null},n}(t.Loader);P._decoder=new TextDecoder("utf-8"),P=a([t.resourceLoader("Spine",["json","bin","skel"])],P);var S=/*#__PURE__*/function(e){function n(){return e.apply(this,arguments)||this}return r(n,e),n.prototype.load=function(e,r){return new t.AssetPromise(function(t,a){var i=r.engine,o={atlasPath:"",imagePaths:[],imageExtensions:[]};if(e.urls)for(var s=e.urls,u=0,c=s.length;u<c;u+=1){var d=s[u];n._groupAssetsByExtension(d,o,r)}else n._assignAssetPathsFromUrl(e.url,o,r);var h=o.atlasPath;if(!h){a(Error("Failed to load spine atlas. Please check the file path and ensure the file extension is included."));return}if(0===o.imagePaths.length)l.loadTextureAtlas(h,i,a).then(function(e){t(e)}).catch(function(e){a(e)});else{var p=o.atlasPath,f=o.imagePaths,_=o.imageExtensions;f.length>0?Promise.all([r._request(p,{type:"text"}),l.loadTexturesByPaths(f,_,i,a)]).then(function(e){var n=e[0],r=e[1];t(l.createTextureAtlas(n,r))}).catch(function(e){a(e)}):l.loadTextureAtlas(p,i,a).then(function(e){t(e)}).catch(function(e){a(e)})}})},n._groupAssetsByExtension=function(e,t,n){var r=P._getUrlExtension(e);r&&("atlas"===r&&(t.atlasPath=e),["png","jpg","webp","jpeg","ktx","ktx2"].includes(r)&&t.imagePaths.push(e))},n._assignAssetPathsFromUrl=function(e,t,n){if("atlas"===P._getUrlExtension(e)){t.atlasPath=e;var r,a,i=null==n?void 0:null==(a=n._virtualPathResourceMap)?void 0:null==(r=a[e])?void 0:r.dependentAssetMap;if(i)for(var o in i){var s=i[o];t.imagePaths.push(s)}}},n}(t.Loader);S=a([t.resourceLoader("SpineAtlas",["atlas"],!1)],S);var k=/*#__PURE__*/Object.freeze({__proto__:null,SpineResource:B,LoaderUtils:l}),A=/*#__PURE__*/Object.freeze({__proto__:null,SpineAnimationRenderer:y,SpineMaterial:m});for(var C in A)t.Loader.registerClass(C,A[C]);for(var E in k)t.Loader.registerClass(E,k[E]);var b="0.0.0-experimental-2.0-migrate.4";console.log("Galacean spine version: "+b),e.LoaderUtils=l,e.SpineAnimationRenderer=y,e.SpineBlendMode=d,e.SpineMaterial=m,e.SpineResource=B,e.SpineVertexStride=g,e.getSpineRuntime=s,e.registerSpineRuntime=function(e){o=e},e.version=b,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=browser.min.js.map
package/dist/main.js CHANGED
@@ -948,7 +948,7 @@ for(var key in RendererObject){
948
948
  for(var key1 in LoaderObject){
949
949
  engine.Loader.registerClass(key1, LoaderObject[key1]);
950
950
  }
951
- var version = "0.0.0-experimental-2.0-migrate.2";
951
+ var version = "0.0.0-experimental-2.0-migrate.4";
952
952
  console.log("Galacean spine version: " + version);
953
953
 
954
954
  exports.LoaderUtils = LoaderUtils;
package/dist/module.js CHANGED
@@ -944,7 +944,7 @@ for(var key in RendererObject){
944
944
  for(var key1 in LoaderObject){
945
945
  Loader.registerClass(key1, LoaderObject[key1]);
946
946
  }
947
- var version = "0.0.0-experimental-2.0-migrate.2";
947
+ var version = "0.0.0-experimental-2.0-migrate.4";
948
948
  console.log("Galacean spine version: " + version);
949
949
 
950
950
  export { LoaderUtils, SpineAnimationRenderer, SpineBlendMode, SpineMaterial, SpineResource, SpineVertexStride, getSpineRuntime, registerSpineRuntime, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-spine",
3
- "version": "0.0.0-experimental-2.0-migrate.2",
3
+ "version": "0.0.0-experimental-2.0-migrate.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -26,10 +26,10 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@esotericsoftware/spine-core": "~4.2.66",
29
- "@galacean/engine": "0.0.0-experimental-2.0-migrate.2"
29
+ "@galacean/engine": "0.0.0-experimental-2.0-migrate.4"
30
30
  },
31
31
  "peerDependencies": {
32
- "@galacean/engine": "0.0.0-experimental-2.0-migrate.2"
32
+ "@galacean/engine": "0.0.0-experimental-2.0-migrate.4"
33
33
  },
34
34
  "scripts": {
35
35
  "b:types": "tsc"