@eva/spine-base 1.2.7-editor.1 → 1.2.7-editor.12

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.
@@ -13,7 +13,7 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
13
13
  d.__proto__ = b;
14
14
  } || function (d, b) {
15
15
  for (var p in b) {
16
- if (b.hasOwnProperty(p)) d[p] = b[p];
16
+ if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
17
17
  }
18
18
  };
19
19
 
@@ -21,6 +21,8 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
21
21
  };
22
22
 
23
23
  function __extends(d, b) {
24
+ if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+
24
26
  _extendStatics(d, b);
25
27
 
26
28
  function __() {
@@ -200,27 +202,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
200
202
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
201
203
  }
202
204
 
203
- function getIDEPropsPropertyObj(target, propertyKey) {
204
- if (!target.constructor.IDEProps) {
205
- target.constructor.IDEProps = {};
206
- }
207
-
208
- if (!target.constructor.IDEProps[propertyKey]) {
209
- target.constructor.IDEProps[propertyKey] = {};
210
- }
211
-
212
- var propertyObj = target.constructor.IDEProps[propertyKey];
213
- return propertyObj;
214
- }
215
-
216
- function type(type) {
217
- return function (target, propertyKey) {
218
- var prop = getIDEPropsPropertyObj(target, propertyKey);
219
- prop.key = propertyKey;
220
- prop.type = type;
221
- };
222
- }
223
-
224
205
  var Spine = function (_super) {
225
206
  __extends(Spine, _super);
226
207
 
@@ -385,13 +366,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
385
366
  };
386
367
 
387
368
  Spine.componentName = 'Spine';
388
-
389
- __decorate([type('string')], Spine.prototype, "resource", void 0);
390
-
391
- __decorate([type('string')], Spine.prototype, "animationName", void 0);
392
-
393
- __decorate([type('boolean')], Spine.prototype, "autoPlay", void 0);
394
-
395
369
  return Spine;
396
370
  }(eva_js.Component);
397
371
 
@@ -1 +1 @@
1
- function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_spineBase=function(e,t,n,r){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function s(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function u(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function c(e){return function(t,n){var r=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,n);r.key=n,r.type=e}}var p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return a(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.waitExecuteInfos),o=r.next();!o.done;o=r.next()){var a=o.value;if(a.playType){var i=a.name,s=a.loop,u=a.track;this.play(i,s,u)}else this.stop(a.track)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&_extends(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",i([c("string")],t.prototype,"resource",void 0),i([c("string")],t.prototype,"animationName",void 0),i([c("boolean")],t.prototype,"autoPlay",void 0),t}(t.Component),l={};function m(e){var t=e.image;return{tex:r.Texture.from(t),count:0}}var f={};function d(e,t,n,r){var o=null,a=function(e,t){var n=l[e];return n||(n=m(t),l[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(a.baseTexture)}),(function(e){if(e){var a=new r.core.AtlasAttachmentLoader(e),i=new r.core.SkeletonJson(a);n&&(i.scale=n),o=i.readSkeletonData(t.ske)}}));var i={spineData:o,ref:0,imageSrc:t.image.src};return f[e]=i,i}function h(e,t){return s(this,void 0,void 0,(function(){var n;return u(this,(function(r){if(!(n=f[e.name]))if(e.complete)n=d(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=l[e];n||(n=m(t),l[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function y(e,t){var n=f[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=l[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete l[e]))}),100)}(t),delete f[e]))}var v=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.armatures={},t}return a(r,e),r.prototype.init=function(e){var r=this,o=e.pixiSpine;this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var e=r.game.gameObjects,n=[];for(var o in r.armatures)for(var a=+o,i=0;i<e.length;++i){var s=e[i];if(s.id===a){var u=s.getComponent(p);u&&(r.remove({type:t.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:p.componentName}),n.push({type:t.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:p.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(t){for(var n in this.armatures)this.armatures[n].update(.001*t.deltaTime),this.armatures[n].updateTransform();e.prototype.update.call(this)},r.prototype.componentChanged=function(e){return s(this,void 0,void 0,(function(){return u(this,(function(n){if("Spine"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD)this.add(e);else if(e.type===t.OBSERVER_TYPE.CHANGE)switch(e.prop.prop[0]){case"resource":this.change(e)}else e.type===t.OBSERVER_TYPE.REMOVE&&this.remove(e);return[2]}))}))},r.prototype.add=function(e,n){var r,o;return s(this,void 0,void 0,(function(){var a,i,s,c,p,l,m,f,d=this;return u(this,(function(u){switch(u.label){case 0:return a=e.component,clearTimeout(a.addHandler),i=e.gameObject.id,s=this.increaseAsyncId(i),[4,t.resource.getResource(a.resource)];case 1:return c=u.sent(),this.validateAsyncId(i,s)?[4,h(c,this.pixiSpine)]:[2];case 2:return p=u.sent(),this.validateAsyncId(i,s)?p?(this.remove(e),(l=null===(o=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===o?void 0:o.getContainer(e.gameObject.id))?(a.lastResource=a.resource,m=new this.pixiSpine.Spine(p),this.armatures[e.gameObject.id]=m,e.gameObject&&e.gameObject.transform&&(f=e.gameObject.transform,m.x=f.size.width*f.origin.x,m.y=f.size.height*f.origin.y),l.addChildAt(m,0),m.update(),m.updateTransform(),a.armature=m,a.emit("loaded",{resource:a.resource}),m.state.addListener({start:function(e,t){a.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){a.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){a.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){a.emit("end",{track:e,name:e.animation.name})},event:function(e,t){a.emit("event",e,t)}}),[2]):[2]):(a.addHandler=setTimeout((function(){a.destroied||(void 0===n&&(n=20),--n>0?d.add(e,n):console.log("retry exceed max times",a.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(e){var n,r,o,a;return s(this,void 0,void 0,(function(){var i,s,c,p;return u(this,(function(u){switch(u.label){case 0:return this.increaseAsyncId(e.gameObject.id),i=e.component,clearTimeout(i.addHandler),s=this.armatures[e.gameObject.id],(c=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))&&s&&c.removeChild(s),i.armature?(i.armature.destroy({children:!0}),[4,t.resource.getResource(i.lastResource)]):[3,2];case 1:y((p=u.sent()).name,null===(a=null===(o=p.data)||void 0===o?void 0:o.image)||void 0===a?void 0:a.src),u.label=2;case 2:return i.armature=null,delete this.armatures[e.gameObject.id],e.type,t.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=i([t.decorators.componentObserver({Spine:["resource"]})],r)}(n.Renderer);return t.resource.registerResourceType("SPINE"),e.Spine=p,e.SpineSystem=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.spineBase=window.EVA.plugin.spineBase||_EVA_IIFE_spineBase;
1
+ function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_spineBase=function(e,t,n,r){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function s(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return a(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.waitExecuteInfos),o=r.next();!o.done;o=r.next()){var a=o.value;if(a.playType){var i=a.name,s=a.loop,u=a.track;this.play(i,s,u)}else this.stop(a.track)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&_extends(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",t}(t.Component),c=u,l={};function p(e){var t=e.image;return{tex:r.Texture.from(t),count:0}}var m={};function f(e,t,n,r){var o=null,a=function(e,t){var n=l[e];return n||(n=p(t),l[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(a.baseTexture)}),(function(e){if(e){var a=new r.core.AtlasAttachmentLoader(e),i=new r.core.SkeletonJson(a);n&&(i.scale=n),o=i.readSkeletonData(t.ske)}}));var i={spineData:o,ref:0,imageSrc:t.image.src};return m[e]=i,i}function d(e,t){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){if(!(n=m[e.name]))if(e.complete)n=f(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=l[e];n||(n=p(t),l[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function h(e,t){var n=m[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=l[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete l[e]))}),100)}(t),delete m[e]))}var y=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.armatures={},t}return a(r,e),r.prototype.init=function(e){var r=this,o=e.pixiSpine;this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var e=r.game.gameObjects,n=[];for(var o in r.armatures)for(var a=+o,i=0;i<e.length;++i){var s=e[i];if(s.id===a){var u=s.getComponent(c);u&&(r.remove({type:t.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:c.componentName}),n.push({type:t.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:c.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(t){for(var n in this.armatures)this.armatures[n].update(.001*t.deltaTime),this.armatures[n].updateTransform();e.prototype.update.call(this)},r.prototype.componentChanged=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(n){if("Spine"===e.componentName)if(e.type===t.OBSERVER_TYPE.ADD)this.add(e);else if(e.type===t.OBSERVER_TYPE.CHANGE){if("resource"===e.prop.prop[0])this.change(e)}else e.type===t.OBSERVER_TYPE.REMOVE&&this.remove(e);return[2]}))}))},r.prototype.add=function(e,n){var r,o;return i(this,void 0,void 0,(function(){var a,i,u,c,l,p,m,f,h=this;return s(this,(function(s){switch(s.label){case 0:return a=e.component,clearTimeout(a.addHandler),i=e.gameObject.id,u=this.increaseAsyncId(i),[4,t.resource.getResource(a.resource)];case 1:return c=s.sent(),this.validateAsyncId(i,u)?[4,d(c,this.pixiSpine)]:[2];case 2:return l=s.sent(),this.validateAsyncId(i,u)?l?(this.remove(e),(p=null===(o=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===o?void 0:o.getContainer(e.gameObject.id))?(a.lastResource=a.resource,m=new this.pixiSpine.Spine(l),this.armatures[e.gameObject.id]=m,e.gameObject&&e.gameObject.transform&&(f=e.gameObject.transform,m.x=f.size.width*f.origin.x,m.y=f.size.height*f.origin.y),p.addChildAt(m,0),m.update(),m.updateTransform(),a.armature=m,a.emit("loaded",{resource:a.resource}),m.state.addListener({start:function(e,t){a.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){a.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){a.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){a.emit("end",{track:e,name:e.animation.name})},event:function(e,t){a.emit("event",e,t)}}),[2]):[2]):(a.addHandler=setTimeout((function(){a.destroied||(void 0===n&&(n=20),--n>0?h.add(e,n):console.log("retry exceed max times",a.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(e){var n,r,o,a;return i(this,void 0,void 0,(function(){var i,u,c,l;return s(this,(function(s){switch(s.label){case 0:return this.increaseAsyncId(e.gameObject.id),i=e.component,clearTimeout(i.addHandler),u=this.armatures[e.gameObject.id],(c=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))&&u&&c.removeChild(u),i.armature?(i.armature.destroy({children:!0}),[4,t.resource.getResource(i.lastResource)]):[3,2];case 1:h((l=s.sent()).name,null===(a=null===(o=l.data)||void 0===o?void 0:o.image)||void 0===a?void 0:a.src),s.label=2;case 2:return i.armature=null,delete this.armatures[e.gameObject.id],e.type,t.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=function(e,t,n,r){var o,a=arguments.length,i=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}([t.decorators.componentObserver({Spine:["resource"]})],r),r}(n.Renderer),v=y;return t.resource.registerResourceType("SPINE"),e.Spine=c,e.SpineSystem=v,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.spineBase=window.EVA.plugin.spineBase||_EVA_IIFE_spineBase;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var eva_js = require('@eva/eva.js');
6
6
  var pluginRenderer = require('@eva/plugin-renderer');
7
- var inspectorDecorator = require('@eva/inspector-decorator');
8
7
  var pixi_js = require('pixi.js');
9
8
 
10
9
  /*! *****************************************************************************
@@ -154,7 +153,7 @@ var Spine = (function (_super) {
154
153
  playType: true,
155
154
  name: name,
156
155
  loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
157
- track: track
156
+ track: track,
158
157
  });
159
158
  }
160
159
  else {
@@ -172,7 +171,7 @@ var Spine = (function (_super) {
172
171
  if (!this.armature) {
173
172
  this.waitExecuteInfos.push({
174
173
  playType: false,
175
- track: track
174
+ track: track,
176
175
  });
177
176
  return;
178
177
  }
@@ -234,15 +233,6 @@ var Spine = (function (_super) {
234
233
  return this.armature.skeleton.findBone(boneName);
235
234
  };
236
235
  Spine.componentName = 'Spine';
237
- __decorate([
238
- inspectorDecorator.type('string')
239
- ], Spine.prototype, "resource", void 0);
240
- __decorate([
241
- inspectorDecorator.type('string')
242
- ], Spine.prototype, "animationName", void 0);
243
- __decorate([
244
- inspectorDecorator.type('boolean')
245
- ], Spine.prototype, "autoPlay", void 0);
246
236
  return Spine;
247
237
  }(eva_js.Component));
248
238
  var Spine$1 = Spine;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),r=require("@eva/inspector-decorator"),n=require("pixi.js"),a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function i(e,t,r,n){var a,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(o<3?a(i):o>3?a(t,r,i):a(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}function s(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){e.done?a(e.value):new r((function(t){t(e.value)})).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return o(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,r;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var n=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}(this.waitExecuteInfos),a=n.next();!a.done;a=n.next()){var o=a.value;if(o.playType){var i=o.name,s=o.loop,u=o.track;this.play(i,s,u)}else this.stop(o.track)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&Object.assign(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,r){try{e&&(this.animationName=e),this.armature?(void 0===r&&(r=0),this.armature.state.setAnimation(r,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:r})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,r,n){try{this.armature&&(void 0===n&&(n=0),this.armature.state.addAnimation(n,e,r,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,r){this.armature&&this.armature.stateData.setMix(e,t,r)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",i([r.type("string")],t.prototype,"resource",void 0),i([r.type("string")],t.prototype,"animationName",void 0),i([r.type("boolean")],t.prototype,"autoPlay",void 0),t}(e.Component),p={};function l(e){var t=e.image;return{tex:n.Texture.from(t),count:0}}var m={};function f(e,t,r,n){var a=null,o=function(e,t){var r=p[e];return r||(r=l(t),p[e]=r),r.tex}(t.image.src,t);new n.core.TextureAtlas(t.atlas,(function(e,t){t(o.baseTexture)}),(function(e){if(e){var o=new n.core.AtlasAttachmentLoader(e),i=new n.core.SkeletonJson(o);r&&(i.scale=r),a=i.readSkeletonData(t.ske)}}));var i={spineData:a,ref:0,imageSrc:t.image.src};return m[e]=i,i}function d(e,t){return s(this,void 0,void 0,(function(){var r;return u(this,(function(n){if(!(r=m[e.name]))if(e.complete)r=f(e.name,e.data,e.scale,t);else if(!r)return[2];return function(e,t){var r=p[e];r||(r=l(t),p[e]=r),r.count++,r.tex}(e.data.image.src,e.data),r.ref++,[2,r.spineData]}))}))}function h(e,t){var r=m[e];r&&(r.ref--,r.ref<=0&&(!function(e){e&&setTimeout((function(){var t=p[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete p[e]))}),100)}(t),delete m[e]))}var y=function(r){function n(){var e=null!==r&&r.apply(this,arguments)||this;return e.armatures={},e}return o(n,r),n.prototype.init=function(r){var n=this,a=r.pixiSpine;this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=a,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=n.game.gameObjects,r=[];for(var a in n.armatures)for(var o=+a,i=0;i<t.length;++i){var s=t[i];if(s.id===o){var u=s.getComponent(c);u&&(n.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:c.componentName}),r.push({type:e.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:c.componentName}));break}}setTimeout((function(){r.forEach((function(e){n.add(e)}))}),1e3)}),!1)},n.prototype.update=function(e){for(var t in this.armatures)this.armatures[t].update(.001*e.deltaTime),this.armatures[t].updateTransform();r.prototype.update.call(this)},n.prototype.componentChanged=function(t){return s(this,void 0,void 0,(function(){return u(this,(function(r){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE)switch(t.prop.prop[0]){case"resource":this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t);return[2]}))}))},n.prototype.add=function(t,r){var n,a;return s(this,void 0,void 0,(function(){var o,i,s,c,p,l,m,f,h=this;return u(this,(function(u){switch(u.label){case 0:return o=t.component,clearTimeout(o.addHandler),i=t.gameObject.id,s=this.increaseAsyncId(i),[4,e.resource.getResource(o.resource)];case 1:return c=u.sent(),this.validateAsyncId(i,s)?[4,d(c,this.pixiSpine)]:[2];case 2:return p=u.sent(),this.validateAsyncId(i,s)?p?(this.remove(t),(l=null===(a=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===a?void 0:a.getContainer(t.gameObject.id))?(o.lastResource=o.resource,m=new this.pixiSpine.Spine(p),this.armatures[t.gameObject.id]=m,t.gameObject&&t.gameObject.transform&&(f=t.gameObject.transform,m.x=f.size.width*f.origin.x,m.y=f.size.height*f.origin.y),l.addChildAt(m,0),m.update(),m.updateTransform(),o.armature=m,o.emit("loaded",{resource:o.resource}),m.state.addListener({start:function(e,t){o.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){o.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){o.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){o.emit("end",{track:e,name:e.animation.name})},event:function(e,t){o.emit("event",e,t)}}),[2]):[2]):(o.addHandler=setTimeout((function(){o.destroied||(void 0===r&&(r=20),--r>0?h.add(t,r):console.log("retry exceed max times",o.resource))}),1e3),[2]):[2]}}))}))},n.prototype.change=function(e){this.remove(e),this.add(e)},n.prototype.remove=function(t){var r,n,a,o;return s(this,void 0,void 0,(function(){var i,s,c,p;return u(this,(function(u){switch(u.label){case 0:return this.increaseAsyncId(t.gameObject.id),i=t.component,clearTimeout(i.addHandler),s=this.armatures[t.gameObject.id],(c=null===(n=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id))&&s&&c.removeChild(s),i.armature?(i.armature.destroy({children:!0}),[4,e.resource.getResource(i.lastResource)]):[3,2];case 1:h((p=u.sent()).name,null===(o=null===(a=p.data)||void 0===a?void 0:a.image)||void 0===o?void 0:o.src),u.label=2;case 2:return i.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},n.systemName="SpineSystem",n=i([e.decorators.componentObserver({Spine:["resource"]})],n)}(t.Renderer);e.resource.registerResourceType("SPINE"),exports.Spine=c,exports.SpineSystem=y;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),n=require("pixi.js"),r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function a(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?a(e.value):new n((function(t){t(e.value)})).then(i,s)}u((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.animationName="",t.autoPlay=!0,t.waitExecuteInfos=[],t}return a(t,e),Object.defineProperty(t.prototype,"armature",{get:function(){return this._armature},set:function(e){var t,n;if(this._armature=e,e){this.autoPlay&&this.play(this.animationName);try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(this.waitExecuteInfos),a=r.next();!a.done;a=r.next()){var o=a.value;if(o.playType){var i=o.name,s=o.loop,u=o.track;this.play(i,s,u)}else this.stop(o.track)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),t.prototype.init=function(e){e&&Object.assign(this,e)},t.prototype.onDestroy=function(){this.destroied=!0},t.prototype.play=function(e,t,n){try{e&&(this.animationName=e),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,t)):this.waitExecuteInfos.push({playType:!0,name:e,loop:null!=t?t:this.autoPlay,track:n})}catch(e){console.log(e)}},t.prototype.stop=function(e){this.armature?(void 0===e&&(e=0),this.armature.state.setEmptyAnimation(e,0)):this.waitExecuteInfos.push({playType:!1,track:e})},t.prototype.addAnimation=function(e,t,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,e,n,t))}catch(e){console.log(e)}},t.prototype.setMix=function(e,t,n){this.armature&&this.armature.stateData.setMix(e,t,n)},t.prototype.getAnim=function(e){void 0===e&&(e=0);try{if(this.armature)return this.armature.state.tracks[e].animation.name}catch(e){console.log(e)}},t.prototype.setDefaultMix=function(e){this.armature&&(this.armature.stateData.defaultMix=e)},t.prototype.setAttachment=function(e,t){this.armature&&this.armature.skeleton.setAttachment(e,t)},t.prototype.getBone=function(e){if(this.armature)return this.armature.skeleton.findBone(e)},t.componentName="Spine",t}(e.Component),u={};function c(e){var t=e.image;return{tex:n.Texture.from(t),count:0}}var l={};function m(e,t,n,r){var a=null,o=function(e,t){var n=u[e];return n||(n=c(t),u[e]=n),n.tex}(t.image.src,t);new r.core.TextureAtlas(t.atlas,(function(e,t){t(o.baseTexture)}),(function(e){if(e){var o=new r.core.AtlasAttachmentLoader(e),i=new r.core.SkeletonJson(o);n&&(i.scale=n),a=i.readSkeletonData(t.ske)}}));var i={spineData:a,ref:0,imageSrc:t.image.src};return l[e]=i,i}function p(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){if(!(n=l[e.name]))if(e.complete)n=m(e.name,e.data,e.scale,t);else if(!n)return[2];return function(e,t){var n=u[e];n||(n=c(t),u[e]=n),n.count++,n.tex}(e.data.image.src,e.data),n.ref++,[2,n.spineData]}))}))}function f(e,t){var n=l[e];n&&(n.ref--,n.ref<=0&&(!function(e){e&&setTimeout((function(){var t=u[e];t&&(t.count--,t.count<=0&&(t.tex&&(t.tex.destroy(!0),t.tex=null),delete u[e]))}),100)}(t),delete l[e]))}var d=function(n){function r(){var e=null!==n&&n.apply(this,arguments)||this;return e.armatures={},e}return a(r,n),r.prototype.init=function(n){var r=this,a=n.pixiSpine;this.renderSystem=this.game.getSystem(t.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=a,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=r.game.gameObjects,n=[];for(var a in r.armatures)for(var o=+a,i=0;i<t.length;++i){var u=t[i];if(u.id===o){var c=u.getComponent(s);c&&(r.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:u,component:c,componentName:s.componentName}),n.push({type:e.OBSERVER_TYPE.ADD,gameObject:u,component:c,componentName:s.componentName}));break}}setTimeout((function(){n.forEach((function(e){r.add(e)}))}),1e3)}),!1)},r.prototype.update=function(e){for(var t in this.armatures)this.armatures[t].update(.001*e.deltaTime),this.armatures[t].updateTransform();n.prototype.update.call(this)},r.prototype.componentChanged=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t);return[2]}))}))},r.prototype.add=function(t,n){var r,a;return o(this,void 0,void 0,(function(){var o,s,u,c,l,m,f,d,h=this;return i(this,(function(i){switch(i.label){case 0:return o=t.component,clearTimeout(o.addHandler),s=t.gameObject.id,u=this.increaseAsyncId(s),[4,e.resource.getResource(o.resource)];case 1:return c=i.sent(),this.validateAsyncId(s,u)?[4,p(c,this.pixiSpine)]:[2];case 2:return l=i.sent(),this.validateAsyncId(s,u)?l?(this.remove(t),(m=null===(a=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===a?void 0:a.getContainer(t.gameObject.id))?(o.lastResource=o.resource,f=new this.pixiSpine.Spine(l),this.armatures[t.gameObject.id]=f,t.gameObject&&t.gameObject.transform&&(d=t.gameObject.transform,f.x=d.size.width*d.origin.x,f.y=d.size.height*d.origin.y),m.addChildAt(f,0),f.update(),f.updateTransform(),o.armature=f,o.emit("loaded",{resource:o.resource}),f.state.addListener({start:function(e,t){o.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){o.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){o.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){o.emit("end",{track:e,name:e.animation.name})},event:function(e,t){o.emit("event",e,t)}}),[2]):[2]):(o.addHandler=setTimeout((function(){o.destroied||(void 0===n&&(n=20),--n>0?h.add(t,n):console.log("retry exceed max times",o.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(e){this.remove(e),this.add(e)},r.prototype.remove=function(t){var n,r,a,s;return o(this,void 0,void 0,(function(){var o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return this.increaseAsyncId(t.gameObject.id),o=t.component,clearTimeout(o.addHandler),u=this.armatures[t.gameObject.id],(c=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(t.gameObject.id))&&u&&c.removeChild(u),o.armature?(o.armature.destroy({children:!0}),[4,e.resource.getResource(o.lastResource)]):[3,2];case 1:f((l=i.sent()).name,null===(s=null===(a=l.data)||void 0===a?void 0:a.image)||void 0===s?void 0:s.src),i.label=2;case 2:return o.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=function(e,t,n,r){var a,o=arguments.length,i=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(o<3?a(i):o>3?a(t,n,i):a(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}([e.decorators.componentObserver({Spine:["resource"]})],r),r}(t.Renderer);e.resource.registerResourceType("SPINE"),exports.Spine=s,exports.SpineSystem=d;
@@ -1,6 +1,5 @@
1
1
  import { Component, OBSERVER_TYPE, decorators, resource } from '@eva/eva.js';
2
2
  import { RendererSystem, Renderer } from '@eva/plugin-renderer';
3
- import { type } from '@eva/inspector-decorator';
4
3
  import { Texture } from 'pixi.js';
5
4
 
6
5
  /*! *****************************************************************************
@@ -150,7 +149,7 @@ var Spine = (function (_super) {
150
149
  playType: true,
151
150
  name: name,
152
151
  loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
153
- track: track
152
+ track: track,
154
153
  });
155
154
  }
156
155
  else {
@@ -168,7 +167,7 @@ var Spine = (function (_super) {
168
167
  if (!this.armature) {
169
168
  this.waitExecuteInfos.push({
170
169
  playType: false,
171
- track: track
170
+ track: track,
172
171
  });
173
172
  return;
174
173
  }
@@ -230,15 +229,6 @@ var Spine = (function (_super) {
230
229
  return this.armature.skeleton.findBone(boneName);
231
230
  };
232
231
  Spine.componentName = 'Spine';
233
- __decorate([
234
- type('string')
235
- ], Spine.prototype, "resource", void 0);
236
- __decorate([
237
- type('string')
238
- ], Spine.prototype, "animationName", void 0);
239
- __decorate([
240
- type('boolean')
241
- ], Spine.prototype, "autoPlay", void 0);
242
232
  return Spine;
243
233
  }(Component));
244
234
  var Spine$1 = Spine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/spine-base",
3
- "version": "1.2.7-editor.1",
3
+ "version": "1.2.7-editor.12",
4
4
  "description": "@eva/spine-base",
5
5
  "main": "index.js",
6
6
  "module": "dist/spine-base.esm.js",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/eva.js": "1.2.7-editor.1",
22
- "@eva/plugin-renderer": "1.2.7-editor.1",
23
- "@eva/inspector-decorator": "0.1.0-alpha.1",
21
+ "@eva/eva.js": "1.2.7-editor.12",
22
+ "@eva/plugin-renderer": "1.2.7-editor.12",
23
+ "@eva/inspector-decorator": "0.1.0-alpha.3",
24
24
  "pixi.js": "^4.8.9"
25
25
  }
26
26
  }
@@ -1,550 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import { Component, OBSERVER_TYPE, resource, decorators } from '@eva/eva.js/dist/miniprogram';
4
- import { __extends, __values, __decorate, __awaiter, __generator } from 'tslib';
5
- import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
6
- import { type } from '@eva/inspector-decorator';
7
- import { Texture } from '@eva/miniprogram-pixi';
8
-
9
- var Spine = function (_super) {
10
- __extends(Spine, _super);
11
-
12
- function Spine() {
13
- var _this = _super !== null && _super.apply(this, arguments) || this;
14
-
15
- _this.resource = '';
16
- _this.animationName = '';
17
- _this.autoPlay = true;
18
- _this.waitExecuteInfos = [];
19
- return _this;
20
- }
21
-
22
- Object.defineProperty(Spine.prototype, "armature", {
23
- get: function get() {
24
- return this._armature;
25
- },
26
- set: function set(val) {
27
- var e_1, _a;
28
-
29
- this._armature = val;
30
- if (!val) return;
31
-
32
- if (this.autoPlay) {
33
- this.play(this.animationName);
34
- }
35
-
36
- try {
37
- for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
38
- var info = _c.value;
39
-
40
- if (info.playType) {
41
- var name_1 = info.name,
42
- loop = info.loop,
43
- track = info.track;
44
- this.play(name_1, loop, track);
45
- } else {
46
- this.stop(info.track);
47
- }
48
- }
49
- } catch (e_1_1) {
50
- e_1 = {
51
- error: e_1_1
52
- };
53
- } finally {
54
- try {
55
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
56
- } finally {
57
- if (e_1) throw e_1.error;
58
- }
59
- }
60
-
61
- this.waitExecuteInfos = [];
62
- },
63
- enumerable: false,
64
- configurable: true
65
- });
66
-
67
- Spine.prototype.init = function (obj) {
68
- if (!obj) return;
69
-
70
- _extends(this, obj);
71
- };
72
-
73
- Spine.prototype.onDestroy = function () {
74
- this.destroied = true;
75
- };
76
-
77
- Spine.prototype.play = function (name, loop, track) {
78
- try {
79
- if (name) this.animationName = name;
80
-
81
- if (!this.armature) {
82
- this.waitExecuteInfos.push({
83
- playType: true,
84
- name: name,
85
- loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
86
- track: track
87
- });
88
- } else {
89
- if (track === undefined) {
90
- track = 0;
91
- }
92
-
93
- this.armature.state.setAnimation(track, this.animationName, loop);
94
- }
95
- } catch (e) {
96
- console.log(e);
97
- }
98
- };
99
-
100
- Spine.prototype.stop = function (track) {
101
- if (!this.armature) {
102
- this.waitExecuteInfos.push({
103
- playType: false,
104
- track: track
105
- });
106
- return;
107
- }
108
-
109
- if (track === undefined) {
110
- track = 0;
111
- }
112
-
113
- this.armature.state.setEmptyAnimation(track, 0);
114
- };
115
-
116
- Spine.prototype.addAnimation = function (name, delay, loop, track) {
117
- try {
118
- if (!this.armature) {} else {
119
- if (track === undefined) {
120
- track = 0;
121
- }
122
-
123
- this.armature.state.addAnimation(track, name, loop, delay);
124
- }
125
- } catch (e) {
126
- console.log(e);
127
- }
128
- };
129
-
130
- Spine.prototype.setMix = function (from, to, duration) {
131
- if (!this.armature) ;else {
132
- this.armature.stateData.setMix(from, to, duration);
133
- }
134
- };
135
-
136
- Spine.prototype.getAnim = function (track) {
137
- if (track === void 0) {
138
- track = 0;
139
- }
140
-
141
- try {
142
- if (!this.armature) {} else {
143
- return this.armature.state.tracks[track].animation.name;
144
- }
145
- } catch (e) {
146
- console.log(e);
147
- }
148
- };
149
-
150
- Spine.prototype.setDefaultMix = function (duration) {
151
- if (!this.armature) ;else {
152
- this.armature.stateData.defaultMix = duration;
153
- }
154
- };
155
-
156
- Spine.prototype.setAttachment = function (slotName, attachmentName) {
157
- if (!this.armature) {
158
- return;
159
- }
160
-
161
- this.armature.skeleton.setAttachment(slotName, attachmentName);
162
- };
163
-
164
- Spine.prototype.getBone = function (boneName) {
165
- if (!this.armature) {
166
- return;
167
- }
168
-
169
- return this.armature.skeleton.findBone(boneName);
170
- };
171
-
172
- Spine.componentName = 'Spine';
173
-
174
- __decorate([type('string')], Spine.prototype, "resource", void 0);
175
-
176
- __decorate([type('string')], Spine.prototype, "animationName", void 0);
177
-
178
- __decorate([type('boolean')], Spine.prototype, "autoPlay", void 0);
179
-
180
- return Spine;
181
- }(Component);
182
-
183
- var Spine$1 = Spine;
184
- var texCache = {};
185
-
186
- function cacheImage(data) {
187
- var oldImg = data.image;
188
- return {
189
- tex: Texture.from(oldImg),
190
- count: 0
191
- };
192
- }
193
-
194
- function retainTexture(name, data) {
195
- var cache = texCache[name];
196
-
197
- if (!cache) {
198
- cache = cacheImage(data);
199
- texCache[name] = cache;
200
- }
201
-
202
- cache.count++;
203
- return cache.tex;
204
- }
205
-
206
- function getTexture(imageSrc, data) {
207
- var cache = texCache[imageSrc];
208
-
209
- if (!cache) {
210
- cache = cacheImage(data);
211
- texCache[imageSrc] = cache;
212
- }
213
-
214
- return cache.tex;
215
- }
216
-
217
- function releaseTexture(imageSrc) {
218
- if (!imageSrc) return;
219
- setTimeout(function () {
220
- var cache = texCache[imageSrc];
221
-
222
- if (cache) {
223
- cache.count--;
224
-
225
- if (cache.count <= 0) {
226
- if (cache.tex) {
227
- cache.tex.destroy(true);
228
- cache.tex = null;
229
- }
230
-
231
- delete texCache[imageSrc];
232
- }
233
- }
234
- }, 100);
235
- }
236
-
237
- var dataMap = {};
238
-
239
- function createSpineData(name, data, scale, pixiSpine) {
240
- var spineData = null;
241
- var img = getTexture(data.image.src, data);
242
- new pixiSpine.core.TextureAtlas(data.atlas, function (line, callback) {
243
- callback(img.baseTexture);
244
- }, function (spineAtlas) {
245
- if (spineAtlas) {
246
- var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
247
- var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
248
-
249
- if (scale) {
250
- spineJsonParser.scale = scale;
251
- }
252
-
253
- spineData = spineJsonParser.readSkeletonData(data.ske);
254
- }
255
- });
256
- var obj = {
257
- spineData: spineData,
258
- ref: 0,
259
- imageSrc: data.image.src
260
- };
261
- dataMap[name] = obj;
262
- return obj;
263
- }
264
-
265
- function getSpineData(res, pixiSpine) {
266
- return __awaiter(this, void 0, void 0, function () {
267
- var data;
268
- return __generator(this, function (_a) {
269
- data = dataMap[res.name];
270
-
271
- if (!data) {
272
- if (res.complete) {
273
- data = createSpineData(res.name, res.data, res.scale, pixiSpine);
274
- } else if (!data) {
275
- return [2];
276
- }
277
- }
278
-
279
- retainTexture(res.data.image.src, res.data);
280
- data.ref++;
281
- return [2, data.spineData];
282
- });
283
- });
284
- }
285
-
286
- function releaseSpineData(resourceName, imageSrc) {
287
- var data = dataMap[resourceName];
288
-
289
- if (!data) {
290
- return;
291
- }
292
-
293
- data.ref--;
294
-
295
- if (data.ref <= 0) {
296
- releaseTexture(imageSrc);
297
- delete dataMap[resourceName];
298
- }
299
- }
300
-
301
- var MaxRetryCount = 20;
302
-
303
- var SpineSystem = function (_super) {
304
- __extends(SpineSystem, _super);
305
-
306
- function SpineSystem() {
307
- var _this = _super !== null && _super.apply(this, arguments) || this;
308
-
309
- _this.armatures = {};
310
- return _this;
311
- }
312
-
313
- SpineSystem.prototype.init = function (_a) {
314
- var _this = this;
315
-
316
- var pixiSpine = _a.pixiSpine;
317
- this.renderSystem = this.game.getSystem(RendererSystem);
318
- this.renderSystem.rendererManager.register(this);
319
- this.pixiSpine = pixiSpine;
320
- this.game.canvas.addEventListener('webglcontextrestored', function () {
321
- var objs = _this.game.gameObjects;
322
- var toAdd = [];
323
-
324
- for (var k in _this.armatures) {
325
- var id = +k;
326
-
327
- for (var i = 0; i < objs.length; ++i) {
328
- var obj = objs[i];
329
-
330
- if (obj.id === id) {
331
- var sp = obj.getComponent(Spine$1);
332
-
333
- if (sp) {
334
- _this.remove({
335
- type: OBSERVER_TYPE.REMOVE,
336
- gameObject: obj,
337
- component: sp,
338
- componentName: Spine$1.componentName
339
- });
340
-
341
- toAdd.push({
342
- type: OBSERVER_TYPE.ADD,
343
- gameObject: obj,
344
- component: sp,
345
- componentName: Spine$1.componentName
346
- });
347
- }
348
-
349
- break;
350
- }
351
- }
352
- }
353
-
354
- setTimeout(function () {
355
- toAdd.forEach(function (obj) {
356
- _this.add(obj);
357
- });
358
- }, 1000);
359
- }, false);
360
- };
361
-
362
- SpineSystem.prototype.update = function (e) {
363
- for (var key in this.armatures) {
364
- this.armatures[key].update(e.deltaTime * 0.001);
365
- this.armatures[key].updateTransform();
366
- }
367
-
368
- _super.prototype.update.call(this);
369
- };
370
-
371
- SpineSystem.prototype.componentChanged = function (changed) {
372
- return __awaiter(this, void 0, void 0, function () {
373
- return __generator(this, function (_a) {
374
- if (changed.componentName === 'Spine') {
375
- if (changed.type === OBSERVER_TYPE.ADD) {
376
- this.add(changed);
377
- } else if (changed.type === OBSERVER_TYPE.CHANGE) {
378
- switch (changed.prop.prop[0]) {
379
- case 'resource':
380
- this.change(changed);
381
- break;
382
- }
383
- } else if (changed.type === OBSERVER_TYPE.REMOVE) {
384
- this.remove(changed);
385
- }
386
- }
387
-
388
- return [2];
389
- });
390
- });
391
- };
392
-
393
- SpineSystem.prototype.add = function (changed, count) {
394
- var _a, _b;
395
-
396
- return __awaiter(this, void 0, void 0, function () {
397
- var component, gameObjectId, asyncId, res, spineData, container, armature, tran;
398
-
399
- var _this = this;
400
-
401
- return __generator(this, function (_c) {
402
- switch (_c.label) {
403
- case 0:
404
- component = changed.component;
405
- clearTimeout(component.addHandler);
406
- gameObjectId = changed.gameObject.id;
407
- asyncId = this.increaseAsyncId(gameObjectId);
408
- return [4, resource.getResource(component.resource)];
409
-
410
- case 1:
411
- res = _c.sent();
412
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
413
- return [4, getSpineData(res, this.pixiSpine)];
414
-
415
- case 2:
416
- spineData = _c.sent();
417
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
418
-
419
- if (!spineData) {
420
- component.addHandler = setTimeout(function () {
421
- if (!component.destroied) {
422
- if (count === undefined) {
423
- count = MaxRetryCount;
424
- }
425
-
426
- count--;
427
-
428
- if (count > 0) {
429
- _this.add(changed, count);
430
- } else {
431
- console.log('retry exceed max times', component.resource);
432
- }
433
- }
434
- }, 1000);
435
- return [2];
436
- }
437
-
438
- this.remove(changed);
439
- container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
440
-
441
- if (!container) {
442
- return [2];
443
- }
444
-
445
- component.lastResource = component.resource;
446
- armature = new this.pixiSpine.Spine(spineData);
447
- this.armatures[changed.gameObject.id] = armature;
448
-
449
- if (changed.gameObject && changed.gameObject.transform) {
450
- tran = changed.gameObject.transform;
451
- armature.x = tran.size.width * tran.origin.x;
452
- armature.y = tran.size.height * tran.origin.y;
453
- }
454
-
455
- container.addChildAt(armature, 0);
456
- armature.update();
457
- armature.updateTransform();
458
- component.armature = armature;
459
- component.emit('loaded', {
460
- resource: component.resource
461
- });
462
- armature.state.addListener({
463
- start: function start(track, event) {
464
- component.emit('start', {
465
- track: track,
466
- name: track.animation.name
467
- });
468
- },
469
- complete: function complete(track, event) {
470
- component.emit('complete', {
471
- track: track,
472
- name: track.animation.name
473
- });
474
- },
475
- interrupt: function interrupt(track, event) {
476
- component.emit('interrupt', {
477
- track: track,
478
- name: track.animation.name
479
- });
480
- },
481
- end: function end(track, event) {
482
- component.emit('end', {
483
- track: track,
484
- name: track.animation.name
485
- });
486
- },
487
- event: function event(track, _event) {
488
- component.emit('event', track, _event);
489
- }
490
- });
491
- return [2];
492
- }
493
- });
494
- });
495
- };
496
-
497
- SpineSystem.prototype.change = function (changed) {
498
- this.remove(changed);
499
- this.add(changed);
500
- };
501
-
502
- SpineSystem.prototype.remove = function (changed) {
503
- var _a, _b, _c, _d;
504
-
505
- return __awaiter(this, void 0, void 0, function () {
506
- var component, armature, container, res;
507
- return __generator(this, function (_e) {
508
- switch (_e.label) {
509
- case 0:
510
- this.increaseAsyncId(changed.gameObject.id);
511
- component = changed.component;
512
- clearTimeout(component.addHandler);
513
- armature = this.armatures[changed.gameObject.id];
514
- container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
515
-
516
- if (container && armature) {
517
- container.removeChild(armature);
518
- }
519
-
520
- if (!component.armature) return [3, 2];
521
- component.armature.destroy({
522
- children: true
523
- });
524
- return [4, resource.getResource(component.lastResource)];
525
-
526
- case 1:
527
- res = _e.sent();
528
- releaseSpineData(res.name, (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src);
529
- _e.label = 2;
530
-
531
- case 2:
532
- component.armature = null;
533
- delete this.armatures[changed.gameObject.id];
534
- if (changed.type === OBSERVER_TYPE.CHANGE) ;
535
- return [2];
536
- }
537
- });
538
- });
539
- };
540
-
541
- SpineSystem.systemName = 'SpineSystem';
542
- SpineSystem = __decorate([decorators.componentObserver({
543
- Spine: ['resource']
544
- })], SpineSystem);
545
- return SpineSystem;
546
- }(Renderer);
547
-
548
- var SpineSystem$1 = SpineSystem;
549
- resource.registerResourceType('SPINE');
550
- export { Spine$1 as Spine, SpineSystem$1 as SpineSystem };