@eva/spine-base 1.2.7-editor.1 → 1.2.7-editor.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.
|
@@ -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 (
|
|
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 __() {
|
|
@@ -30,6 +32,22 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
30
32
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
var _assign = function __assign() {
|
|
36
|
+
_assign = Object.assign || function __assign(t) {
|
|
37
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
+
s = arguments[i];
|
|
39
|
+
|
|
40
|
+
for (var p in s) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return _assign.apply(this, arguments);
|
|
49
|
+
};
|
|
50
|
+
|
|
33
51
|
function __decorate(decorators, target, key, desc) {
|
|
34
52
|
var c = arguments.length,
|
|
35
53
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -40,6 +58,10 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
40
58
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
59
|
}
|
|
42
60
|
|
|
61
|
+
function __metadata(metadataKey, metadataValue) {
|
|
62
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
44
66
|
function adopt(value) {
|
|
45
67
|
return value instanceof P ? value : new P(function (resolve) {
|
|
@@ -200,24 +222,106 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
200
222
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
201
223
|
}
|
|
202
224
|
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
225
|
+
var SymbolKeysNotSupportedError = function (_super) {
|
|
226
|
+
__extends(SymbolKeysNotSupportedError, _super);
|
|
227
|
+
|
|
228
|
+
function SymbolKeysNotSupportedError() {
|
|
229
|
+
var _newTarget = this.constructor;
|
|
230
|
+
|
|
231
|
+
var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
|
|
232
|
+
|
|
233
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
234
|
+
return _this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return SymbolKeysNotSupportedError;
|
|
238
|
+
}(Error);
|
|
239
|
+
|
|
240
|
+
(function (_super) {
|
|
241
|
+
__extends(StaticGetPropertiesIsNotAFunctionError, _super);
|
|
242
|
+
|
|
243
|
+
function StaticGetPropertiesIsNotAFunctionError() {
|
|
244
|
+
var _newTarget = this.constructor;
|
|
245
|
+
|
|
246
|
+
var _this = _super.call(this, 'getProperties is not a function!') || this;
|
|
247
|
+
|
|
248
|
+
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
249
|
+
return _this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return StaticGetPropertiesIsNotAFunctionError;
|
|
253
|
+
})(Error);
|
|
254
|
+
|
|
255
|
+
var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
|
|
256
|
+
|
|
257
|
+
function transformBasicType(type) {
|
|
258
|
+
if (type === String) {
|
|
259
|
+
return 'string';
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (type === Number) {
|
|
263
|
+
return 'number';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (type === Boolean) {
|
|
267
|
+
return 'boolean';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return 'unknown';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function defineTypes(target, key, options, returnTypeFunction) {
|
|
274
|
+
var type = Reflect.getMetadata('design:type', target, key);
|
|
275
|
+
var isArray = type === Array;
|
|
276
|
+
var str = transformBasicType(type);
|
|
277
|
+
|
|
278
|
+
if (str !== 'unknown') {
|
|
279
|
+
type = str;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (returnTypeFunction) {
|
|
283
|
+
var returnType = returnTypeFunction();
|
|
284
|
+
|
|
285
|
+
if (Array.isArray(returnType)) {
|
|
286
|
+
isArray = true;
|
|
287
|
+
type = returnType[0];
|
|
288
|
+
} else {
|
|
289
|
+
type = returnType;
|
|
290
|
+
}
|
|
206
291
|
}
|
|
207
292
|
|
|
208
|
-
|
|
209
|
-
|
|
293
|
+
var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
|
|
294
|
+
properties[key] = _assign({
|
|
295
|
+
type: type,
|
|
296
|
+
isArray: isArray
|
|
297
|
+
}, options);
|
|
298
|
+
Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
|
|
302
|
+
if (typeof returnTypeFuncOrOptions === 'function') {
|
|
303
|
+
return {
|
|
304
|
+
returnTypeFunc: returnTypeFuncOrOptions,
|
|
305
|
+
options: maybeOptions || {}
|
|
306
|
+
};
|
|
210
307
|
}
|
|
211
308
|
|
|
212
|
-
|
|
213
|
-
|
|
309
|
+
return {
|
|
310
|
+
options: returnTypeFuncOrOptions || {}
|
|
311
|
+
};
|
|
214
312
|
}
|
|
215
313
|
|
|
216
|
-
function
|
|
314
|
+
function Field(returnTypeFunction, maybeOptions) {
|
|
217
315
|
return function (target, propertyKey) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
316
|
+
if (typeof propertyKey === 'symbol') {
|
|
317
|
+
throw new SymbolKeysNotSupportedError();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
321
|
+
options = _a.options,
|
|
322
|
+
returnTypeFunc = _a.returnTypeFunc;
|
|
323
|
+
|
|
324
|
+
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
221
325
|
};
|
|
222
326
|
}
|
|
223
327
|
|
|
@@ -386,11 +490,13 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
386
490
|
|
|
387
491
|
Spine.componentName = 'Spine';
|
|
388
492
|
|
|
389
|
-
__decorate([
|
|
493
|
+
__decorate([Field({
|
|
494
|
+
type: 'resource'
|
|
495
|
+
}), __metadata("design:type", String)], Spine.prototype, "resource", void 0);
|
|
390
496
|
|
|
391
|
-
__decorate([
|
|
497
|
+
__decorate([Field(), __metadata("design:type", String)], Spine.prototype, "animationName", void 0);
|
|
392
498
|
|
|
393
|
-
__decorate([
|
|
499
|
+
__decorate([Field(), __metadata("design:type", Boolean)], Spine.prototype, "autoPlay", void 0);
|
|
394
500
|
|
|
395
501
|
return Spine;
|
|
396
502
|
}(eva_js.Component);
|
|
@@ -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(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{};var _EVA_IIFE_spineBase=function(t,e,n,r){"use strict";var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};function s(t,e,n,r){var o,a=arguments.length,i=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(i=(a<3?o(i):a>3?o(e,n,i):o(e,n))||i);return a>3&&i&&Object.defineProperty(e,n,i),i}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))}function p(t,e){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=e.call(t,i)}catch(t){a=[6,t],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 l=function(t){function e(){var e=this.constructor,n=t.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(n,e.prototype),n}return a(e,t),e}(Error);!function(t){function e(){var e=this.constructor,n=t.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(n,e.prototype),n}a(e,t)}(Error);var f="IDE_PROPERTY_METADATA";function m(t,e,n,r){var o=Reflect.getMetadata("design:type",t,e),a=o===Array,s=function(t){return t===String?"string":t===Number?"number":t===Boolean?"boolean":"unknown"}(o);if("unknown"!==s&&(o=s),r){var u=r();Array.isArray(u)?(a=!0,o=u[0]):o=u}var c=Reflect.getMetadata(f,t.constructor)||{};c[e]=i({type:o,isArray:a},n),Reflect.defineMetadata(f,c,t.constructor)}function d(t,e){return function(n,r){if("symbol"==typeof r)throw new l;var o=function(t,e){return"function"==typeof t?{returnTypeFunc:t,options:e||{}}:{options:t||{}}}(t,e);m(n,r,o.options,o.returnTypeFunc)}}var y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.animationName="",e.autoPlay=!0,e.waitExecuteInfos=[],e}return a(e,t),Object.defineProperty(e.prototype,"armature",{get:function(){return this._armature},set:function(t){var e,n;if(this._armature=t,t){this.autoPlay&&this.play(this.animationName);try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"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(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.waitExecuteInfos=[]}},enumerable:!1,configurable:!0}),e.prototype.init=function(t){t&&_extends(this,t)},e.prototype.onDestroy=function(){this.destroied=!0},e.prototype.play=function(t,e,n){try{t&&(this.animationName=t),this.armature?(void 0===n&&(n=0),this.armature.state.setAnimation(n,this.animationName,e)):this.waitExecuteInfos.push({playType:!0,name:t,loop:null!=e?e:this.autoPlay,track:n})}catch(t){console.log(t)}},e.prototype.stop=function(t){this.armature?(void 0===t&&(t=0),this.armature.state.setEmptyAnimation(t,0)):this.waitExecuteInfos.push({playType:!1,track:t})},e.prototype.addAnimation=function(t,e,n,r){try{this.armature&&(void 0===r&&(r=0),this.armature.state.addAnimation(r,t,n,e))}catch(t){console.log(t)}},e.prototype.setMix=function(t,e,n){this.armature&&this.armature.stateData.setMix(t,e,n)},e.prototype.getAnim=function(t){void 0===t&&(t=0);try{if(this.armature)return this.armature.state.tracks[t].animation.name}catch(t){console.log(t)}},e.prototype.setDefaultMix=function(t){this.armature&&(this.armature.stateData.defaultMix=t)},e.prototype.setAttachment=function(t,e){this.armature&&this.armature.skeleton.setAttachment(t,e)},e.prototype.getBone=function(t){if(this.armature)return this.armature.skeleton.findBone(t)},e.componentName="Spine",s([d({type:"resource"}),u("design:type",String)],e.prototype,"resource",void 0),s([d(),u("design:type",String)],e.prototype,"animationName",void 0),s([d(),u("design:type",Boolean)],e.prototype,"autoPlay",void 0),e}(e.Component),h=y,v={};function g(t){var e=t.image;return{tex:r.Texture.from(e),count:0}}var b={};function E(t,e,n,r){var o=null,a=function(t,e){var n=v[t];return n||(n=g(e),v[t]=n),n.tex}(e.image.src,e);new r.core.TextureAtlas(e.atlas,(function(t,e){e(a.baseTexture)}),(function(t){if(t){var a=new r.core.AtlasAttachmentLoader(t),i=new r.core.SkeletonJson(a);n&&(i.scale=n),o=i.readSkeletonData(e.ske)}}));var i={spineData:o,ref:0,imageSrc:e.image.src};return b[t]=i,i}function w(t,e){return c(this,void 0,void 0,(function(){var n;return p(this,(function(r){if(!(n=b[t.name]))if(t.complete)n=E(t.name,t.data,t.scale,e);else if(!n)return[2];return function(t,e){var n=v[t];n||(n=g(e),v[t]=n),n.count++,n.tex}(t.data.image.src,t.data),n.ref++,[2,n.spineData]}))}))}function O(t,e){var n=b[t];n&&(n.ref--,n.ref<=0&&(!function(t){t&&setTimeout((function(){var e=v[t];e&&(e.count--,e.count<=0&&(e.tex&&(e.tex.destroy(!0),e.tex=null),delete v[t]))}),100)}(e),delete b[t]))}var x=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.armatures={},e}return a(r,t),r.prototype.init=function(t){var r=this,o=t.pixiSpine;this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=r.game.gameObjects,n=[];for(var o in r.armatures)for(var a=+o,i=0;i<t.length;++i){var s=t[i];if(s.id===a){var u=s.getComponent(h);u&&(r.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:h.componentName}),n.push({type:e.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:h.componentName}));break}}setTimeout((function(){n.forEach((function(t){r.add(t)}))}),1e3)}),!1)},r.prototype.update=function(e){for(var n in this.armatures)this.armatures[n].update(.001*e.deltaTime),this.armatures[n].updateTransform();t.prototype.update.call(this)},r.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return p(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,o;return c(this,void 0,void 0,(function(){var a,i,s,u,c,l,f,m,d=this;return p(this,(function(p){switch(p.label){case 0:return a=t.component,clearTimeout(a.addHandler),i=t.gameObject.id,s=this.increaseAsyncId(i),[4,e.resource.getResource(a.resource)];case 1:return u=p.sent(),this.validateAsyncId(i,s)?[4,w(u,this.pixiSpine)]:[2];case 2:return c=p.sent(),this.validateAsyncId(i,s)?c?(this.remove(t),(l=null===(o=null===(r=this.renderSystem)||void 0===r?void 0:r.containerManager)||void 0===o?void 0:o.getContainer(t.gameObject.id))?(a.lastResource=a.resource,f=new this.pixiSpine.Spine(c),this.armatures[t.gameObject.id]=f,t.gameObject&&t.gameObject.transform&&(m=t.gameObject.transform,f.x=m.size.width*m.origin.x,f.y=m.size.height*m.origin.y),l.addChildAt(f,0),f.update(),f.updateTransform(),a.armature=f,a.emit("loaded",{resource:a.resource}),f.state.addListener({start:function(t,e){a.emit("start",{track:t,name:t.animation.name})},complete:function(t,e){a.emit("complete",{track:t,name:t.animation.name})},interrupt:function(t,e){a.emit("interrupt",{track:t,name:t.animation.name})},end:function(t,e){a.emit("end",{track:t,name:t.animation.name})},event:function(t,e){a.emit("event",t,e)}}),[2]):[2]):(a.addHandler=setTimeout((function(){a.destroied||(void 0===n&&(n=20),--n>0?d.add(t,n):console.log("retry exceed max times",a.resource))}),1e3),[2]):[2]}}))}))},r.prototype.change=function(t){this.remove(t),this.add(t)},r.prototype.remove=function(t){var n,r,o,a;return c(this,void 0,void 0,(function(){var i,s,u,c;return p(this,(function(p){switch(p.label){case 0:return this.increaseAsyncId(t.gameObject.id),i=t.component,clearTimeout(i.addHandler),s=this.armatures[t.gameObject.id],(u=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(t.gameObject.id))&&s&&u.removeChild(s),i.armature?(i.armature.destroy({children:!0}),[4,e.resource.getResource(i.lastResource)]):[3,2];case 1:O((c=p.sent()).name,null===(a=null===(o=c.data)||void 0===o?void 0:o.image)||void 0===a?void 0:a.src),p.label=2;case 2:return i.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=s([e.decorators.componentObserver({Spine:["resource"]})],r)}(n.Renderer),S=x;return e.resource.registerResourceType("SPINE"),t.Spine=h,t.SpineSystem=S,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.spineBase=window.EVA.plugin.spineBase||_EVA_IIFE_spineBase;
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
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
2
|
|
|
3
3
|
import { Component, OBSERVER_TYPE, resource, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
4
|
-
import { __extends, __values, __decorate, __awaiter, __generator } from 'tslib';
|
|
4
|
+
import { __extends, __values, __decorate, __metadata, __awaiter, __generator } from 'tslib';
|
|
5
5
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
6
|
-
import {
|
|
6
|
+
import { Field } from '@eva/inspector-decorator';
|
|
7
7
|
import { Texture } from '@eva/miniprogram-pixi';
|
|
8
8
|
|
|
9
9
|
var Spine = function (_super) {
|
|
@@ -171,11 +171,13 @@ var Spine = function (_super) {
|
|
|
171
171
|
|
|
172
172
|
Spine.componentName = 'Spine';
|
|
173
173
|
|
|
174
|
-
__decorate([
|
|
174
|
+
__decorate([Field({
|
|
175
|
+
type: 'resource'
|
|
176
|
+
}), __metadata("design:type", String)], Spine.prototype, "resource", void 0);
|
|
175
177
|
|
|
176
|
-
__decorate([
|
|
178
|
+
__decorate([Field(), __metadata("design:type", String)], Spine.prototype, "animationName", void 0);
|
|
177
179
|
|
|
178
|
-
__decorate([
|
|
180
|
+
__decorate([Field(), __metadata("design:type", Boolean)], Spine.prototype, "autoPlay", void 0);
|
|
179
181
|
|
|
180
182
|
return Spine;
|
|
181
183
|
}(Component);
|
package/dist/spine-base.cjs.js
CHANGED
|
@@ -43,6 +43,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
43
43
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function __metadata(metadataKey, metadataValue) {
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
47
51
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
48
52
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -154,7 +158,7 @@ var Spine = (function (_super) {
|
|
|
154
158
|
playType: true,
|
|
155
159
|
name: name,
|
|
156
160
|
loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
|
|
157
|
-
track: track
|
|
161
|
+
track: track,
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
else {
|
|
@@ -172,7 +176,7 @@ var Spine = (function (_super) {
|
|
|
172
176
|
if (!this.armature) {
|
|
173
177
|
this.waitExecuteInfos.push({
|
|
174
178
|
playType: false,
|
|
175
|
-
track: track
|
|
179
|
+
track: track,
|
|
176
180
|
});
|
|
177
181
|
return;
|
|
178
182
|
}
|
|
@@ -235,13 +239,16 @@ var Spine = (function (_super) {
|
|
|
235
239
|
};
|
|
236
240
|
Spine.componentName = 'Spine';
|
|
237
241
|
__decorate([
|
|
238
|
-
inspectorDecorator.type
|
|
242
|
+
inspectorDecorator.Field({ type: 'resource' }),
|
|
243
|
+
__metadata("design:type", String)
|
|
239
244
|
], Spine.prototype, "resource", void 0);
|
|
240
245
|
__decorate([
|
|
241
|
-
inspectorDecorator.
|
|
246
|
+
inspectorDecorator.Field(),
|
|
247
|
+
__metadata("design:type", String)
|
|
242
248
|
], Spine.prototype, "animationName", void 0);
|
|
243
249
|
__decorate([
|
|
244
|
-
inspectorDecorator.
|
|
250
|
+
inspectorDecorator.Field(),
|
|
251
|
+
__metadata("design:type", Boolean)
|
|
245
252
|
], Spine.prototype, "autoPlay", void 0);
|
|
246
253
|
return Spine;
|
|
247
254
|
}(eva_js.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),n=require("@eva/inspector-decorator"),r=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 n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},a(e,t)};function o(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(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}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(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 c(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 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 o(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",i([n.Field({type:"resource"}),s("design:type",String)],t.prototype,"resource",void 0),i([n.Field(),s("design:type",String)],t.prototype,"animationName",void 0),i([n.Field(),s("design:type",Boolean)],t.prototype,"autoPlay",void 0),t}(e.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 a=null,o=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(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 f[e]=i,i}function h(e,t){return u(this,void 0,void 0,(function(){var n;return c(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(n){function r(){var e=null!==n&&n.apply(this,arguments)||this;return e.armatures={},e}return o(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 s=t[i];if(s.id===o){var u=s.getComponent(p);u&&(r.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:p.componentName}),n.push({type:e.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(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){var o,i,s,u,p,l,m,f,d=this;return c(this,(function(c){switch(c.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 u=c.sent(),this.validateAsyncId(i,s)?[4,h(u,this.pixiSpine)]:[2];case 2:return p=c.sent(),this.validateAsyncId(i,s)?p?(this.remove(t),(l=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,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===n&&(n=20),--n>0?d.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,o;return u(this,void 0,void 0,(function(){var i,s,u,p;return c(this,(function(c){switch(c.label){case 0:return this.increaseAsyncId(t.gameObject.id),i=t.component,clearTimeout(i.addHandler),s=this.armatures[t.gameObject.id],(u=null===(r=null===(n=this.renderSystem)||void 0===n?void 0:n.containerManager)||void 0===r?void 0:r.getContainer(t.gameObject.id))&&s&&u.removeChild(s),i.armature?(i.armature.destroy({children:!0}),[4,e.resource.getResource(i.lastResource)]):[3,2];case 1:y((p=c.sent()).name,null===(o=null===(a=p.data)||void 0===a?void 0:a.image)||void 0===o?void 0:o.src),c.label=2;case 2:return i.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE,[2]}}))}))},r.systemName="SpineSystem",r=i([e.decorators.componentObserver({Spine:["resource"]})],r)}(t.Renderer);e.resource.registerResourceType("SPINE"),exports.Spine=p,exports.SpineSystem=v;
|
package/dist/spine-base.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, OBSERVER_TYPE, decorators, resource } from '@eva/eva.js';
|
|
2
2
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
3
|
-
import {
|
|
3
|
+
import { Field } from '@eva/inspector-decorator';
|
|
4
4
|
import { Texture } from 'pixi.js';
|
|
5
5
|
|
|
6
6
|
/*! *****************************************************************************
|
|
@@ -39,6 +39,10 @@ function __decorate(decorators, target, key, desc) {
|
|
|
39
39
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function __metadata(metadataKey, metadataValue) {
|
|
43
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
47
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
48
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -150,7 +154,7 @@ var Spine = (function (_super) {
|
|
|
150
154
|
playType: true,
|
|
151
155
|
name: name,
|
|
152
156
|
loop: loop !== null && loop !== void 0 ? loop : this.autoPlay,
|
|
153
|
-
track: track
|
|
157
|
+
track: track,
|
|
154
158
|
});
|
|
155
159
|
}
|
|
156
160
|
else {
|
|
@@ -168,7 +172,7 @@ var Spine = (function (_super) {
|
|
|
168
172
|
if (!this.armature) {
|
|
169
173
|
this.waitExecuteInfos.push({
|
|
170
174
|
playType: false,
|
|
171
|
-
track: track
|
|
175
|
+
track: track,
|
|
172
176
|
});
|
|
173
177
|
return;
|
|
174
178
|
}
|
|
@@ -231,13 +235,16 @@ var Spine = (function (_super) {
|
|
|
231
235
|
};
|
|
232
236
|
Spine.componentName = 'Spine';
|
|
233
237
|
__decorate([
|
|
234
|
-
type
|
|
238
|
+
Field({ type: 'resource' }),
|
|
239
|
+
__metadata("design:type", String)
|
|
235
240
|
], Spine.prototype, "resource", void 0);
|
|
236
241
|
__decorate([
|
|
237
|
-
|
|
242
|
+
Field(),
|
|
243
|
+
__metadata("design:type", String)
|
|
238
244
|
], Spine.prototype, "animationName", void 0);
|
|
239
245
|
__decorate([
|
|
240
|
-
|
|
246
|
+
Field(),
|
|
247
|
+
__metadata("design:type", Boolean)
|
|
241
248
|
], Spine.prototype, "autoPlay", void 0);
|
|
242
249
|
return Spine;
|
|
243
250
|
}(Component));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/spine-base",
|
|
3
|
-
"version": "1.2.7-editor.
|
|
3
|
+
"version": "1.2.7-editor.4",
|
|
4
4
|
"description": "@eva/spine-base",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/spine-base.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "1.2.7-editor.
|
|
22
|
-
"@eva/plugin-renderer": "1.2.7-editor.
|
|
21
|
+
"@eva/eva.js": "1.2.7-editor.4",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7-editor.4",
|
|
23
23
|
"@eva/inspector-decorator": "0.1.0-alpha.1",
|
|
24
24
|
"pixi.js": "^4.8.9"
|
|
25
25
|
}
|