@eva/spine-base 1.2.2-alpha.3 → 1.2.2-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.plugin.spineBase.js +75 -14
- package/dist/EVA.plugin.spineBase.min.js +1 -1
- package/dist/miniprogram.js +59 -15
- package/dist/spine-base.cjs.js +58 -11
- package/dist/spine-base.cjs.prod.js +1 -1
- package/dist/spine-base.d.ts +4 -1
- package/dist/spine-base.esm.js +58 -11
- package/package.json +3 -3
|
@@ -183,6 +183,23 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
function __values(o) {
|
|
187
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
188
|
+
m = s && o[s],
|
|
189
|
+
i = 0;
|
|
190
|
+
if (m) return m.call(o);
|
|
191
|
+
if (o && typeof o.length === "number") return {
|
|
192
|
+
next: function next() {
|
|
193
|
+
if (o && i >= o.length) o = void 0;
|
|
194
|
+
return {
|
|
195
|
+
value: o && o[i++],
|
|
196
|
+
done: !o
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
201
|
+
}
|
|
202
|
+
|
|
186
203
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
187
204
|
if (!target.constructor.IDEProps) {
|
|
188
205
|
target.constructor.IDEProps = {};
|
|
@@ -213,17 +230,59 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
213
230
|
_this.resource = '';
|
|
214
231
|
_this.animationName = '';
|
|
215
232
|
_this.autoPlay = true;
|
|
233
|
+
_this.waitExecuteInfos = [];
|
|
216
234
|
return _this;
|
|
217
235
|
}
|
|
218
236
|
|
|
237
|
+
Object.defineProperty(Spine.prototype, "armature", {
|
|
238
|
+
get: function get() {
|
|
239
|
+
return this._armature;
|
|
240
|
+
},
|
|
241
|
+
set: function set(val) {
|
|
242
|
+
var e_1, _a;
|
|
243
|
+
|
|
244
|
+
this._armature = val;
|
|
245
|
+
if (!val) return;
|
|
246
|
+
|
|
247
|
+
if (this.autoPlay) {
|
|
248
|
+
this.play(this.animationName);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
253
|
+
var info = _c.value;
|
|
254
|
+
|
|
255
|
+
if (info.playType) {
|
|
256
|
+
var name_1 = info.name,
|
|
257
|
+
loop = info.loop,
|
|
258
|
+
track = info.track;
|
|
259
|
+
this.play(name_1, loop, track);
|
|
260
|
+
} else {
|
|
261
|
+
this.stop(info.track);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch (e_1_1) {
|
|
265
|
+
e_1 = {
|
|
266
|
+
error: e_1_1
|
|
267
|
+
};
|
|
268
|
+
} finally {
|
|
269
|
+
try {
|
|
270
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
271
|
+
} finally {
|
|
272
|
+
if (e_1) throw e_1.error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
this.waitExecuteInfos = [];
|
|
277
|
+
},
|
|
278
|
+
enumerable: false,
|
|
279
|
+
configurable: true
|
|
280
|
+
});
|
|
281
|
+
|
|
219
282
|
Spine.prototype.init = function (obj) {
|
|
220
283
|
if (!obj) return;
|
|
221
284
|
|
|
222
285
|
_extends(this, obj);
|
|
223
|
-
|
|
224
|
-
if (this.autoPlay) {
|
|
225
|
-
this.play(this.animationName);
|
|
226
|
-
}
|
|
227
286
|
};
|
|
228
287
|
|
|
229
288
|
Spine.prototype.onDestroy = function () {
|
|
@@ -234,7 +293,14 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
234
293
|
try {
|
|
235
294
|
if (name) this.animationName = name;
|
|
236
295
|
|
|
237
|
-
if (!this.armature) {
|
|
296
|
+
if (!this.armature) {
|
|
297
|
+
this.waitExecuteInfos.push({
|
|
298
|
+
playType: true,
|
|
299
|
+
name: name,
|
|
300
|
+
loop: loop,
|
|
301
|
+
track: track
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
238
304
|
if (track === undefined) {
|
|
239
305
|
track = 0;
|
|
240
306
|
}
|
|
@@ -248,6 +314,10 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
248
314
|
|
|
249
315
|
Spine.prototype.stop = function (track) {
|
|
250
316
|
if (!this.armature) {
|
|
317
|
+
this.waitExecuteInfos.push({
|
|
318
|
+
playType: false,
|
|
319
|
+
track: track
|
|
320
|
+
});
|
|
251
321
|
return;
|
|
252
322
|
}
|
|
253
323
|
|
|
@@ -595,15 +665,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
595
665
|
armature.update();
|
|
596
666
|
armature.updateTransform();
|
|
597
667
|
component.armature = armature;
|
|
598
|
-
|
|
599
|
-
if (component.autoPlay) {
|
|
600
|
-
try {
|
|
601
|
-
armature.state.setAnimation(0, component.animationName, true);
|
|
602
|
-
} catch (e) {
|
|
603
|
-
console.log(e);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
|
|
607
668
|
component.emit('loaded', {
|
|
608
669
|
resource: component.resource
|
|
609
670
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var
|
|
1
|
+
function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var _EVA_IIFE_spineBase=function(t,e,r,n){"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 r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function a(t,e){function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,r,n){var o,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(i=(a<3?o(i):a>3?o(e,r,i):o(e,r))||i);return a>3&&i&&Object.defineProperty(e,r,i),i}function s(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{u(n.next(t))}catch(t){a(t)}}function s(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,s)}u((n=n.apply(t,e||[])).next())}))}function u(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function c(t){return function(e,r){var n=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,r);n.key=r,n.type=t}}var p=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,r;if(this._armature=t,t){this.autoPlay&&this.play(this.animationName);try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.waitExecuteInfos),o=n.next();!o.done;o=n.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&&(r=n.return)&&r.call(n)}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,r){try{t&&(this.animationName=t),this.armature?(void 0===r&&(r=0),this.armature.state.setAnimation(r,this.animationName,e)):this.waitExecuteInfos.push({playType:!0,name:t,loop:e,track:r})}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,r,n){try{this.armature&&(void 0===n&&(n=0),this.armature.state.addAnimation(n,t,r,e))}catch(t){console.log(t)}},e.prototype.setMix=function(t,e,r){this.armature&&this.armature.stateData.setMix(t,e,r)},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",i([c("string")],e.prototype,"resource",void 0),i([c("string")],e.prototype,"animationName",void 0),i([c("boolean")],e.prototype,"autoPlay",void 0),e}(e.Component),m={};function l(t){var e=t.image;return{tex:n.Texture.from(e),count:0}}var f={};function d(t,e,r,n){var o=null,a=function(t,e){var r=m[t];return r||(r=l(e),m[t]=r),r.tex}(e.image.src,e);new n.core.TextureAtlas(e.atlas,(function(t,e){e(a.baseTexture)}),(function(t){if(t){var a=new n.core.AtlasAttachmentLoader(t),i=new n.core.SkeletonJson(a);r&&(i.scale=r),o=i.readSkeletonData(e.ske)}}));var i={spineData:o,ref:0,imageSrc:e.image.src};return f[t]=i,i}function h(t,e){return s(this,void 0,void 0,(function(){var r;return u(this,(function(n){if(!(r=f[t.name]))if(t.complete)r=d(t.name,t.data,t.scale,e);else if(!r)return[2];return function(t,e){var r=m[t];r||(r=l(e),m[t]=r),r.count++,r.tex}(t.data.image.src,t.data),r.ref++,[2,r.spineData]}))}))}function y(t,e){var r=f[t];r&&(r.ref--,r.ref<=0&&(!function(t){t&&setTimeout((function(){var e=m[t];e&&(e.count--,e.count<=0&&(e.tex&&(e.tex.destroy(!0),e.tex=null),delete m[t]))}),100)}(e),delete f[t]))}var v=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.armatures={},e}return a(n,t),n.prototype.init=function(t){var n=this,o=t.pixiSpine;this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=o,this.game.canvas.addEventListener("webglcontextrestored",(function(){var t=n.game.gameObjects,r=[];for(var o in n.armatures)for(var a=+o,i=0;i<t.length;++i){var s=t[i];if(s.id===a){var u=s.getComponent(p);u&&(n.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:s,component:u,componentName:p.componentName}),r.push({type:e.OBSERVER_TYPE.ADD,gameObject:s,component:u,componentName:p.componentName}));break}}setTimeout((function(){r.forEach((function(t){n.add(t)}))}),1e3)}),!1)},n.prototype.update=function(e){for(var r in this.armatures)this.armatures[r].update(.001*e.deltaTime),this.armatures[r].updateTransform();t.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){return s(this,void 0,void 0,(function(){var n,o,a,i,s,c=this;return u(this,(function(u){switch(u.label){case 0:return n=t.component,clearTimeout(n.addHandler),[4,e.resource.getResource(n.resource)];case 1:return[4,h(u.sent(),this.pixiSpine)];case 2:return(o=u.sent())?(this.remove(t),(a=this.renderSystem.containerManager.getContainer(t.gameObject.id))?(n.lastResource=n.resource,i=new this.pixiSpine.Spine(o),this.armatures[t.gameObject.id]=i,t.gameObject&&t.gameObject.transform&&(s=t.gameObject.transform,i.x=s.size.width*s.origin.x,i.y=s.size.height*s.origin.y),a.addChildAt(i,0),i.update(),i.updateTransform(),n.armature=i,n.emit("loaded",{resource:n.resource}),i.state.addListener({start:function(t,e){n.emit("start",{track:t,name:t.animation.name})},complete:function(t,e){n.emit("complete",{track:t,name:t.animation.name})},interrupt:function(t,e){n.emit("interrupt",{track:t,name:t.animation.name})},end:function(t,e){n.emit("end",{track:t,name:t.animation.name})},event:function(t,e){n.emit("event",t,e)}}),[2]):[2]):(n.addHandler=setTimeout((function(){n.destroied||(void 0===r&&(r=20),--r>0?c.add(t,r):console.log("retry exceed max times",n.resource))}),1e3),[2])}}))}))},n.prototype.change=function(t){this.remove(t),this.add(t)},n.prototype.remove=function(t){var r,n;return s(this,void 0,void 0,(function(){var o,a,i,s;return u(this,(function(u){switch(u.label){case 0:return o=t.component,clearTimeout(o.addHandler),a=this.armatures[t.gameObject.id],(i=this.renderSystem.containerManager.getContainer(t.gameObject.id))&&a&&i.removeChild(a),o.armature?(o.armature.destroy({children:!0}),[4,e.resource.getResource(o.lastResource)]):[3,2];case 1:y((s=u.sent()).name,null===(n=null===(r=s.data)||void 0===r?void 0:r.image)||void 0===n?void 0:n.src),u.label=2;case 2:return o.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)}(r.Renderer);return e.resource.registerResourceType("SPINE"),t.Spine=p,t.SpineSystem=v,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, __decorate, __awaiter, __generator } from 'tslib';
|
|
4
|
+
import { __extends, __values, __decorate, __awaiter, __generator } from 'tslib';
|
|
5
5
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
6
6
|
import { type } from '@eva/inspector-decorator';
|
|
7
7
|
import { Texture } from '@eva/miniprogram-pixi';
|
|
@@ -15,17 +15,59 @@ var Spine = function (_super) {
|
|
|
15
15
|
_this.resource = '';
|
|
16
16
|
_this.animationName = '';
|
|
17
17
|
_this.autoPlay = true;
|
|
18
|
+
_this.waitExecuteInfos = [];
|
|
18
19
|
return _this;
|
|
19
20
|
}
|
|
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
|
+
|
|
21
67
|
Spine.prototype.init = function (obj) {
|
|
22
68
|
if (!obj) return;
|
|
23
69
|
|
|
24
70
|
_extends(this, obj);
|
|
25
|
-
|
|
26
|
-
if (this.autoPlay) {
|
|
27
|
-
this.play(this.animationName);
|
|
28
|
-
}
|
|
29
71
|
};
|
|
30
72
|
|
|
31
73
|
Spine.prototype.onDestroy = function () {
|
|
@@ -36,7 +78,14 @@ var Spine = function (_super) {
|
|
|
36
78
|
try {
|
|
37
79
|
if (name) this.animationName = name;
|
|
38
80
|
|
|
39
|
-
if (!this.armature) {
|
|
81
|
+
if (!this.armature) {
|
|
82
|
+
this.waitExecuteInfos.push({
|
|
83
|
+
playType: true,
|
|
84
|
+
name: name,
|
|
85
|
+
loop: loop,
|
|
86
|
+
track: track
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
40
89
|
if (track === undefined) {
|
|
41
90
|
track = 0;
|
|
42
91
|
}
|
|
@@ -50,6 +99,10 @@ var Spine = function (_super) {
|
|
|
50
99
|
|
|
51
100
|
Spine.prototype.stop = function (track) {
|
|
52
101
|
if (!this.armature) {
|
|
102
|
+
this.waitExecuteInfos.push({
|
|
103
|
+
playType: false,
|
|
104
|
+
track: track
|
|
105
|
+
});
|
|
53
106
|
return;
|
|
54
107
|
}
|
|
55
108
|
|
|
@@ -397,15 +450,6 @@ var SpineSystem = function (_super) {
|
|
|
397
450
|
armature.update();
|
|
398
451
|
armature.updateTransform();
|
|
399
452
|
component.armature = armature;
|
|
400
|
-
|
|
401
|
-
if (component.autoPlay) {
|
|
402
|
-
try {
|
|
403
|
-
armature.state.setAnimation(0, component.animationName, true);
|
|
404
|
-
} catch (e) {
|
|
405
|
-
console.log(e);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
453
|
component.emit('loaded', {
|
|
410
454
|
resource: component.resource
|
|
411
455
|
});
|
package/dist/spine-base.cjs.js
CHANGED
|
@@ -78,6 +78,17 @@ function __generator(thisArg, body) {
|
|
|
78
78
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
79
79
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
80
80
|
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function __values(o) {
|
|
84
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
85
|
+
if (m) return m.call(o);
|
|
86
|
+
return {
|
|
87
|
+
next: function () {
|
|
88
|
+
if (o && i >= o.length) o = void 0;
|
|
89
|
+
return { value: o && o[i++], done: !o };
|
|
90
|
+
}
|
|
91
|
+
};
|
|
81
92
|
}
|
|
82
93
|
|
|
83
94
|
var Spine = (function (_super) {
|
|
@@ -87,15 +98,49 @@ var Spine = (function (_super) {
|
|
|
87
98
|
_this.resource = '';
|
|
88
99
|
_this.animationName = '';
|
|
89
100
|
_this.autoPlay = true;
|
|
101
|
+
_this.waitExecuteInfos = [];
|
|
90
102
|
return _this;
|
|
91
103
|
}
|
|
104
|
+
Object.defineProperty(Spine.prototype, "armature", {
|
|
105
|
+
get: function () {
|
|
106
|
+
return this._armature;
|
|
107
|
+
},
|
|
108
|
+
set: function (val) {
|
|
109
|
+
var e_1, _a;
|
|
110
|
+
this._armature = val;
|
|
111
|
+
if (!val)
|
|
112
|
+
return;
|
|
113
|
+
if (this.autoPlay) {
|
|
114
|
+
this.play(this.animationName);
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
118
|
+
var info = _c.value;
|
|
119
|
+
if (info.playType) {
|
|
120
|
+
var name_1 = info.name, loop = info.loop, track = info.track;
|
|
121
|
+
this.play(name_1, loop, track);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.stop(info.track);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
129
|
+
finally {
|
|
130
|
+
try {
|
|
131
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
132
|
+
}
|
|
133
|
+
finally { if (e_1) throw e_1.error; }
|
|
134
|
+
}
|
|
135
|
+
this.waitExecuteInfos = [];
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
92
140
|
Spine.prototype.init = function (obj) {
|
|
93
141
|
if (!obj)
|
|
94
142
|
return;
|
|
95
143
|
Object.assign(this, obj);
|
|
96
|
-
if (this.autoPlay) {
|
|
97
|
-
this.play(this.animationName);
|
|
98
|
-
}
|
|
99
144
|
};
|
|
100
145
|
Spine.prototype.onDestroy = function () {
|
|
101
146
|
this.destroied = true;
|
|
@@ -105,6 +150,12 @@ var Spine = (function (_super) {
|
|
|
105
150
|
if (name)
|
|
106
151
|
this.animationName = name;
|
|
107
152
|
if (!this.armature) {
|
|
153
|
+
this.waitExecuteInfos.push({
|
|
154
|
+
playType: true,
|
|
155
|
+
name: name,
|
|
156
|
+
loop: loop,
|
|
157
|
+
track: track
|
|
158
|
+
});
|
|
108
159
|
}
|
|
109
160
|
else {
|
|
110
161
|
if (track === undefined) {
|
|
@@ -119,6 +170,10 @@ var Spine = (function (_super) {
|
|
|
119
170
|
};
|
|
120
171
|
Spine.prototype.stop = function (track) {
|
|
121
172
|
if (!this.armature) {
|
|
173
|
+
this.waitExecuteInfos.push({
|
|
174
|
+
playType: false,
|
|
175
|
+
track: track
|
|
176
|
+
});
|
|
122
177
|
return;
|
|
123
178
|
}
|
|
124
179
|
if (track === undefined) {
|
|
@@ -412,14 +467,6 @@ var SpineSystem = (function (_super) {
|
|
|
412
467
|
armature.update();
|
|
413
468
|
armature.updateTransform();
|
|
414
469
|
component.armature = armature;
|
|
415
|
-
if (component.autoPlay) {
|
|
416
|
-
try {
|
|
417
|
-
armature.state.setAnimation(0, component.animationName, true);
|
|
418
|
-
}
|
|
419
|
-
catch (e) {
|
|
420
|
-
console.log(e);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
470
|
component.emit('loaded', { resource: component.resource });
|
|
424
471
|
armature.state.addListener({
|
|
425
472
|
start: function (track, event) {
|
|
@@ -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"),
|
|
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:t,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 m(e){var t=e.image;return{tex:n.Texture.from(t),count:0}}var l={};function f(e,t,r,n){var a=null,o=function(e,t){var r=p[e];return r||(r=m(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 l[e]=i,i}function d(e,t){return s(this,void 0,void 0,(function(){var r;return u(this,(function(n){if(!(r=l[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=m(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=l[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 l[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){return s(this,void 0,void 0,(function(){var n,a,o,i,s,c=this;return u(this,(function(u){switch(u.label){case 0:return n=t.component,clearTimeout(n.addHandler),[4,e.resource.getResource(n.resource)];case 1:return[4,d(u.sent(),this.pixiSpine)];case 2:return(a=u.sent())?(this.remove(t),(o=this.renderSystem.containerManager.getContainer(t.gameObject.id))?(n.lastResource=n.resource,i=new this.pixiSpine.Spine(a),this.armatures[t.gameObject.id]=i,t.gameObject&&t.gameObject.transform&&(s=t.gameObject.transform,i.x=s.size.width*s.origin.x,i.y=s.size.height*s.origin.y),o.addChildAt(i,0),i.update(),i.updateTransform(),n.armature=i,n.emit("loaded",{resource:n.resource}),i.state.addListener({start:function(e,t){n.emit("start",{track:e,name:e.animation.name})},complete:function(e,t){n.emit("complete",{track:e,name:e.animation.name})},interrupt:function(e,t){n.emit("interrupt",{track:e,name:e.animation.name})},end:function(e,t){n.emit("end",{track:e,name:e.animation.name})},event:function(e,t){n.emit("event",e,t)}}),[2]):[2]):(n.addHandler=setTimeout((function(){n.destroied||(void 0===r&&(r=20),--r>0?c.add(t,r):console.log("retry exceed max times",n.resource))}),1e3),[2])}}))}))},n.prototype.change=function(e){this.remove(e),this.add(e)},n.prototype.remove=function(t){var r,n;return s(this,void 0,void 0,(function(){var a,o,i,s;return u(this,(function(u){switch(u.label){case 0:return a=t.component,clearTimeout(a.addHandler),o=this.armatures[t.gameObject.id],(i=this.renderSystem.containerManager.getContainer(t.gameObject.id))&&o&&i.removeChild(o),a.armature?(a.armature.destroy({children:!0}),[4,e.resource.getResource(a.lastResource)]):[3,2];case 1:h((s=u.sent()).name,null===(n=null===(r=s.data)||void 0===r?void 0:r.image)||void 0===n?void 0:n.src),u.label=2;case 2:return a.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;
|
package/dist/spine-base.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ export declare class Spine extends Component<SpineParams> {
|
|
|
13
13
|
resource: string;
|
|
14
14
|
animationName: string;
|
|
15
15
|
autoPlay: boolean;
|
|
16
|
-
|
|
16
|
+
private _armature;
|
|
17
|
+
private waitExecuteInfos;
|
|
18
|
+
set armature(val: any);
|
|
19
|
+
get armature(): any;
|
|
17
20
|
destroied: boolean;
|
|
18
21
|
addHandler: any;
|
|
19
22
|
lastResource: string;
|
package/dist/spine-base.esm.js
CHANGED
|
@@ -74,6 +74,17 @@ function __generator(thisArg, body) {
|
|
|
74
74
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
75
75
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
76
76
|
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function __values(o) {
|
|
80
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
81
|
+
if (m) return m.call(o);
|
|
82
|
+
return {
|
|
83
|
+
next: function () {
|
|
84
|
+
if (o && i >= o.length) o = void 0;
|
|
85
|
+
return { value: o && o[i++], done: !o };
|
|
86
|
+
}
|
|
87
|
+
};
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
var Spine = (function (_super) {
|
|
@@ -83,15 +94,49 @@ var Spine = (function (_super) {
|
|
|
83
94
|
_this.resource = '';
|
|
84
95
|
_this.animationName = '';
|
|
85
96
|
_this.autoPlay = true;
|
|
97
|
+
_this.waitExecuteInfos = [];
|
|
86
98
|
return _this;
|
|
87
99
|
}
|
|
100
|
+
Object.defineProperty(Spine.prototype, "armature", {
|
|
101
|
+
get: function () {
|
|
102
|
+
return this._armature;
|
|
103
|
+
},
|
|
104
|
+
set: function (val) {
|
|
105
|
+
var e_1, _a;
|
|
106
|
+
this._armature = val;
|
|
107
|
+
if (!val)
|
|
108
|
+
return;
|
|
109
|
+
if (this.autoPlay) {
|
|
110
|
+
this.play(this.animationName);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
114
|
+
var info = _c.value;
|
|
115
|
+
if (info.playType) {
|
|
116
|
+
var name_1 = info.name, loop = info.loop, track = info.track;
|
|
117
|
+
this.play(name_1, loop, track);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.stop(info.track);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
125
|
+
finally {
|
|
126
|
+
try {
|
|
127
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
128
|
+
}
|
|
129
|
+
finally { if (e_1) throw e_1.error; }
|
|
130
|
+
}
|
|
131
|
+
this.waitExecuteInfos = [];
|
|
132
|
+
},
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
});
|
|
88
136
|
Spine.prototype.init = function (obj) {
|
|
89
137
|
if (!obj)
|
|
90
138
|
return;
|
|
91
139
|
Object.assign(this, obj);
|
|
92
|
-
if (this.autoPlay) {
|
|
93
|
-
this.play(this.animationName);
|
|
94
|
-
}
|
|
95
140
|
};
|
|
96
141
|
Spine.prototype.onDestroy = function () {
|
|
97
142
|
this.destroied = true;
|
|
@@ -101,6 +146,12 @@ var Spine = (function (_super) {
|
|
|
101
146
|
if (name)
|
|
102
147
|
this.animationName = name;
|
|
103
148
|
if (!this.armature) {
|
|
149
|
+
this.waitExecuteInfos.push({
|
|
150
|
+
playType: true,
|
|
151
|
+
name: name,
|
|
152
|
+
loop: loop,
|
|
153
|
+
track: track
|
|
154
|
+
});
|
|
104
155
|
}
|
|
105
156
|
else {
|
|
106
157
|
if (track === undefined) {
|
|
@@ -115,6 +166,10 @@ var Spine = (function (_super) {
|
|
|
115
166
|
};
|
|
116
167
|
Spine.prototype.stop = function (track) {
|
|
117
168
|
if (!this.armature) {
|
|
169
|
+
this.waitExecuteInfos.push({
|
|
170
|
+
playType: false,
|
|
171
|
+
track: track
|
|
172
|
+
});
|
|
118
173
|
return;
|
|
119
174
|
}
|
|
120
175
|
if (track === undefined) {
|
|
@@ -408,14 +463,6 @@ var SpineSystem = (function (_super) {
|
|
|
408
463
|
armature.update();
|
|
409
464
|
armature.updateTransform();
|
|
410
465
|
component.armature = armature;
|
|
411
|
-
if (component.autoPlay) {
|
|
412
|
-
try {
|
|
413
|
-
armature.state.setAnimation(0, component.animationName, true);
|
|
414
|
-
}
|
|
415
|
-
catch (e) {
|
|
416
|
-
console.log(e);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
466
|
component.emit('loaded', { resource: component.resource });
|
|
420
467
|
armature.state.addListener({
|
|
421
468
|
start: function (track, event) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/spine-base",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.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.2-alpha.
|
|
22
|
-
"@eva/plugin-renderer": "1.2.2-alpha.
|
|
21
|
+
"@eva/eva.js": "1.2.2-alpha.4",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.2-alpha.4",
|
|
23
23
|
"@eva/inspector-decorator": "^0.0.5",
|
|
24
24
|
"pixi.js": "^4.8.9"
|
|
25
25
|
}
|