@eva/spine-base 1.2.2-alpha.0
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/README.md +6 -0
- package/dist/EVA.plugin.spineBase.js +705 -0
- package/dist/EVA.plugin.spineBase.min.js +1 -0
- package/dist/global.d.ts +6 -0
- package/dist/miniprogram.js +499 -0
- package/dist/spine-base.cjs.js +493 -0
- package/dist/spine-base.cjs.prod.js +1 -0
- package/dist/spine-base.d.ts +55 -0
- package/dist/spine-base.esm.js +488 -0
- package/index.js +7 -0
- package/package.json +26 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { Component, OBSERVER_TYPE, decorators, resource } from '@eva/eva.js';
|
|
2
|
+
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
3
|
+
import { type } from '@eva/inspector-decorator';
|
|
4
|
+
import { Texture } from 'pixi.js';
|
|
5
|
+
|
|
6
|
+
/*! *****************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
9
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
10
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
13
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
14
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
15
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
16
|
+
|
|
17
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
18
|
+
and limitations under the License.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
/* global Reflect, Promise */
|
|
21
|
+
|
|
22
|
+
var extendStatics = function(d, b) {
|
|
23
|
+
extendStatics = Object.setPrototypeOf ||
|
|
24
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
25
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
26
|
+
return extendStatics(d, b);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function __extends(d, b) {
|
|
30
|
+
extendStatics(d, b);
|
|
31
|
+
function __() { this.constructor = d; }
|
|
32
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __decorate(decorators, target, key, desc) {
|
|
36
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
37
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
38
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
39
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function __generator(thisArg, body) {
|
|
52
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
53
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
54
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while (_) try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
60
|
+
switch (op[0]) {
|
|
61
|
+
case 0: case 1: t = op; break;
|
|
62
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
63
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
64
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
65
|
+
default:
|
|
66
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
67
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
68
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
69
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
70
|
+
if (t[2]) _.ops.pop();
|
|
71
|
+
_.trys.pop(); continue;
|
|
72
|
+
}
|
|
73
|
+
op = body.call(thisArg, _);
|
|
74
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
75
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var Spine = (function (_super) {
|
|
80
|
+
__extends(Spine, _super);
|
|
81
|
+
function Spine() {
|
|
82
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
83
|
+
_this.resource = '';
|
|
84
|
+
_this.animationName = '';
|
|
85
|
+
_this.autoPlay = true;
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
Spine.prototype.init = function (obj) {
|
|
89
|
+
if (!obj)
|
|
90
|
+
return;
|
|
91
|
+
Object.assign(this, obj);
|
|
92
|
+
if (this.autoPlay) {
|
|
93
|
+
this.play(this.animationName);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
Spine.prototype.onDestroy = function () {
|
|
97
|
+
this.destroied = true;
|
|
98
|
+
};
|
|
99
|
+
Spine.prototype.play = function (name, loop, track) {
|
|
100
|
+
try {
|
|
101
|
+
if (name)
|
|
102
|
+
this.animationName = name;
|
|
103
|
+
if (!this.armature) {
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (track === undefined) {
|
|
107
|
+
track = 0;
|
|
108
|
+
}
|
|
109
|
+
this.armature.state.setAnimation(track, this.animationName, loop);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
console.log(e);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
Spine.prototype.stop = function (track) {
|
|
117
|
+
if (!this.armature) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (track === undefined) {
|
|
121
|
+
track = 0;
|
|
122
|
+
}
|
|
123
|
+
this.armature.state.setEmptyAnimation(track, 0);
|
|
124
|
+
};
|
|
125
|
+
Spine.prototype.addAnimation = function (name, delay, loop, track) {
|
|
126
|
+
try {
|
|
127
|
+
if (!this.armature) {
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (track === undefined) {
|
|
131
|
+
track = 0;
|
|
132
|
+
}
|
|
133
|
+
this.armature.state.addAnimation(track, name, loop, delay);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
console.log(e);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
Spine.prototype.setMix = function (from, to, duration) {
|
|
141
|
+
if (!this.armature) ;
|
|
142
|
+
else {
|
|
143
|
+
this.armature.stateData.setMix(from, to, duration);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
Spine.prototype.getAnim = function (track) {
|
|
147
|
+
if (track === void 0) { track = 0; }
|
|
148
|
+
try {
|
|
149
|
+
if (!this.armature) {
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return this.armature.state.tracks[track].animation.name;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
console.log(e);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
Spine.prototype.setDefaultMix = function (duration) {
|
|
160
|
+
if (!this.armature) ;
|
|
161
|
+
else {
|
|
162
|
+
this.armature.stateData.defaultMix = duration;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
Spine.prototype.setAttachment = function (slotName, attachmentName) {
|
|
166
|
+
if (!this.armature) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.armature.skeleton.setAttachment(slotName, attachmentName);
|
|
170
|
+
};
|
|
171
|
+
Spine.prototype.getBone = function (boneName) {
|
|
172
|
+
if (!this.armature) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
return this.armature.skeleton.findBone(boneName);
|
|
176
|
+
};
|
|
177
|
+
Spine.componentName = 'Spine';
|
|
178
|
+
__decorate([
|
|
179
|
+
type('string')
|
|
180
|
+
], Spine.prototype, "resource", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
type('string')
|
|
183
|
+
], Spine.prototype, "animationName", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
type('boolean')
|
|
186
|
+
], Spine.prototype, "autoPlay", void 0);
|
|
187
|
+
return Spine;
|
|
188
|
+
}(Component));
|
|
189
|
+
var Spine$1 = Spine;
|
|
190
|
+
|
|
191
|
+
var texCache = {};
|
|
192
|
+
function cacheImage(data) {
|
|
193
|
+
var oldImg = data.image;
|
|
194
|
+
return {
|
|
195
|
+
tex: Texture.from(oldImg),
|
|
196
|
+
count: 0,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function retainTexture(name, data) {
|
|
200
|
+
var cache = texCache[name];
|
|
201
|
+
if (!cache) {
|
|
202
|
+
cache = cacheImage(data);
|
|
203
|
+
texCache[name] = cache;
|
|
204
|
+
}
|
|
205
|
+
cache.count++;
|
|
206
|
+
return cache.tex;
|
|
207
|
+
}
|
|
208
|
+
function getTexture(imageSrc, data) {
|
|
209
|
+
var cache = texCache[imageSrc];
|
|
210
|
+
if (!cache) {
|
|
211
|
+
cache = cacheImage(data);
|
|
212
|
+
texCache[imageSrc] = cache;
|
|
213
|
+
}
|
|
214
|
+
return cache.tex;
|
|
215
|
+
}
|
|
216
|
+
function releaseTexture(imageSrc) {
|
|
217
|
+
if (!imageSrc)
|
|
218
|
+
return;
|
|
219
|
+
setTimeout(function () {
|
|
220
|
+
var cache = texCache[imageSrc];
|
|
221
|
+
if (cache) {
|
|
222
|
+
cache.count--;
|
|
223
|
+
if (cache.count <= 0) {
|
|
224
|
+
if (cache.tex) {
|
|
225
|
+
cache.tex.destroy(true);
|
|
226
|
+
cache.tex = null;
|
|
227
|
+
}
|
|
228
|
+
delete texCache[imageSrc];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, 100);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var dataMap = {};
|
|
235
|
+
function createSpineData(name, data, scale, pixiSpine) {
|
|
236
|
+
var spineData = null;
|
|
237
|
+
var img = getTexture(data.image.src, data);
|
|
238
|
+
new pixiSpine.core.TextureAtlas(data.atlas, function (line, callback) {
|
|
239
|
+
callback(img.baseTexture);
|
|
240
|
+
}, function (spineAtlas) {
|
|
241
|
+
if (spineAtlas) {
|
|
242
|
+
var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
|
|
243
|
+
var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
|
|
244
|
+
if (scale) {
|
|
245
|
+
spineJsonParser.scale = scale;
|
|
246
|
+
}
|
|
247
|
+
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
var obj = { spineData: spineData, ref: 0, imageSrc: data.image.src };
|
|
251
|
+
dataMap[name] = obj;
|
|
252
|
+
return obj;
|
|
253
|
+
}
|
|
254
|
+
function getSpineData(res, pixiSpine) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
var data;
|
|
257
|
+
return __generator(this, function (_a) {
|
|
258
|
+
data = dataMap[res.name];
|
|
259
|
+
if (!data) {
|
|
260
|
+
if (res.complete) {
|
|
261
|
+
data = createSpineData(res.name, res.data, res.scale, pixiSpine);
|
|
262
|
+
}
|
|
263
|
+
else if (!data) {
|
|
264
|
+
return [2];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
retainTexture(res.data.image.src, res.data);
|
|
268
|
+
data.ref++;
|
|
269
|
+
return [2, data.spineData];
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function releaseSpineData(resourceName, imageSrc) {
|
|
274
|
+
var data = dataMap[resourceName];
|
|
275
|
+
if (!data) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
data.ref--;
|
|
279
|
+
if (data.ref <= 0) {
|
|
280
|
+
releaseTexture(imageSrc);
|
|
281
|
+
delete dataMap[resourceName];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
var MaxRetryCount = 20;
|
|
286
|
+
var SpineSystem = (function (_super) {
|
|
287
|
+
__extends(SpineSystem, _super);
|
|
288
|
+
function SpineSystem() {
|
|
289
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
290
|
+
_this.armatures = {};
|
|
291
|
+
return _this;
|
|
292
|
+
}
|
|
293
|
+
SpineSystem.prototype.init = function (_a) {
|
|
294
|
+
var _this = this;
|
|
295
|
+
var pixiSpine = _a.pixiSpine;
|
|
296
|
+
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
297
|
+
this.renderSystem.rendererManager.register(this);
|
|
298
|
+
this.pixiSpine = pixiSpine;
|
|
299
|
+
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
300
|
+
var objs = _this.game.gameObjects;
|
|
301
|
+
var toAdd = [];
|
|
302
|
+
for (var k in _this.armatures) {
|
|
303
|
+
var id = +k;
|
|
304
|
+
for (var i = 0; i < objs.length; ++i) {
|
|
305
|
+
var obj = objs[i];
|
|
306
|
+
if (obj.id === id) {
|
|
307
|
+
var sp = obj.getComponent(Spine$1);
|
|
308
|
+
if (sp) {
|
|
309
|
+
_this.remove({
|
|
310
|
+
type: OBSERVER_TYPE.REMOVE,
|
|
311
|
+
gameObject: obj,
|
|
312
|
+
component: sp,
|
|
313
|
+
componentName: Spine$1.componentName,
|
|
314
|
+
});
|
|
315
|
+
toAdd.push({
|
|
316
|
+
type: OBSERVER_TYPE.ADD,
|
|
317
|
+
gameObject: obj,
|
|
318
|
+
component: sp,
|
|
319
|
+
componentName: Spine$1.componentName,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
setTimeout(function () {
|
|
327
|
+
toAdd.forEach(function (obj) {
|
|
328
|
+
_this.add(obj);
|
|
329
|
+
});
|
|
330
|
+
}, 1000);
|
|
331
|
+
}, false);
|
|
332
|
+
};
|
|
333
|
+
SpineSystem.prototype.update = function (e) {
|
|
334
|
+
for (var key in this.armatures) {
|
|
335
|
+
this.armatures[key].update(e.deltaTime * 0.001);
|
|
336
|
+
this.armatures[key].updateTransform();
|
|
337
|
+
}
|
|
338
|
+
_super.prototype.update.call(this);
|
|
339
|
+
};
|
|
340
|
+
SpineSystem.prototype.componentChanged = function (changed) {
|
|
341
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
+
return __generator(this, function (_a) {
|
|
343
|
+
if (changed.componentName === 'Spine') {
|
|
344
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
345
|
+
this.add(changed);
|
|
346
|
+
}
|
|
347
|
+
else if (changed.type === OBSERVER_TYPE.CHANGE) {
|
|
348
|
+
switch (changed.prop.prop[0]) {
|
|
349
|
+
case 'resource':
|
|
350
|
+
this.change(changed);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
355
|
+
this.remove(changed);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return [2];
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
SpineSystem.prototype.add = function (changed, count) {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
364
|
+
var component, res, spineData, container, armature, tran;
|
|
365
|
+
var _this = this;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
component = changed.component;
|
|
370
|
+
clearTimeout(component.addHandler);
|
|
371
|
+
return [4, resource.getResource(component.resource)];
|
|
372
|
+
case 1:
|
|
373
|
+
res = _a.sent();
|
|
374
|
+
return [4, getSpineData(res, this.pixiSpine)];
|
|
375
|
+
case 2:
|
|
376
|
+
spineData = _a.sent();
|
|
377
|
+
if (!spineData) {
|
|
378
|
+
component.addHandler = setTimeout(function () {
|
|
379
|
+
if (!component.destroied) {
|
|
380
|
+
if (count === undefined) {
|
|
381
|
+
count = MaxRetryCount;
|
|
382
|
+
}
|
|
383
|
+
count--;
|
|
384
|
+
if (count > 0) {
|
|
385
|
+
_this.add(changed, count);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
console.log('retry exceed max times', component.resource);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}, 1000);
|
|
392
|
+
return [2];
|
|
393
|
+
}
|
|
394
|
+
this.remove(changed);
|
|
395
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
396
|
+
if (!container) {
|
|
397
|
+
return [2];
|
|
398
|
+
}
|
|
399
|
+
component.lastResource = component.resource;
|
|
400
|
+
armature = new this.pixiSpine.Spine(spineData);
|
|
401
|
+
this.armatures[changed.gameObject.id] = armature;
|
|
402
|
+
if (changed.gameObject && changed.gameObject.transform) {
|
|
403
|
+
tran = changed.gameObject.transform;
|
|
404
|
+
armature.x = tran.size.width * tran.origin.x;
|
|
405
|
+
armature.y = tran.size.height * tran.origin.y;
|
|
406
|
+
}
|
|
407
|
+
container.addChildAt(armature, 0);
|
|
408
|
+
armature.update();
|
|
409
|
+
armature.updateTransform();
|
|
410
|
+
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
|
+
component.emit('loaded', { resource: component.resource });
|
|
420
|
+
armature.state.addListener({
|
|
421
|
+
start: function (track, event) {
|
|
422
|
+
component.emit('start', { track: track, name: track.animation.name });
|
|
423
|
+
},
|
|
424
|
+
complete: function (track, event) {
|
|
425
|
+
component.emit('complete', { track: track, name: track.animation.name });
|
|
426
|
+
},
|
|
427
|
+
interrupt: function (track, event) {
|
|
428
|
+
component.emit('interrupt', { track: track, name: track.animation.name });
|
|
429
|
+
},
|
|
430
|
+
end: function (track, event) {
|
|
431
|
+
component.emit('end', { track: track, name: track.animation.name });
|
|
432
|
+
},
|
|
433
|
+
event: function (track, event) {
|
|
434
|
+
component.emit('event', track, event);
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
return [2];
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
SpineSystem.prototype.change = function (changed) {
|
|
443
|
+
this.remove(changed);
|
|
444
|
+
this.add(changed);
|
|
445
|
+
};
|
|
446
|
+
SpineSystem.prototype.remove = function (changed) {
|
|
447
|
+
var _a, _b;
|
|
448
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
449
|
+
var component, armature, container, res;
|
|
450
|
+
return __generator(this, function (_c) {
|
|
451
|
+
switch (_c.label) {
|
|
452
|
+
case 0:
|
|
453
|
+
component = changed.component;
|
|
454
|
+
clearTimeout(component.addHandler);
|
|
455
|
+
armature = this.armatures[changed.gameObject.id];
|
|
456
|
+
container = this.renderSystem.containerManager.getContainer(changed.gameObject.id);
|
|
457
|
+
if (container && armature) {
|
|
458
|
+
container.removeChild(armature);
|
|
459
|
+
}
|
|
460
|
+
if (!component.armature) return [3, 2];
|
|
461
|
+
component.armature.destroy({ children: true });
|
|
462
|
+
return [4, resource.getResource(component.lastResource)];
|
|
463
|
+
case 1:
|
|
464
|
+
res = _c.sent();
|
|
465
|
+
releaseSpineData(res.name, (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.src);
|
|
466
|
+
_c.label = 2;
|
|
467
|
+
case 2:
|
|
468
|
+
component.armature = null;
|
|
469
|
+
delete this.armatures[changed.gameObject.id];
|
|
470
|
+
if (changed.type === OBSERVER_TYPE.CHANGE) ;
|
|
471
|
+
return [2];
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
SpineSystem.systemName = 'SpineSystem';
|
|
477
|
+
SpineSystem = __decorate([
|
|
478
|
+
decorators.componentObserver({
|
|
479
|
+
Spine: ['resource'],
|
|
480
|
+
})
|
|
481
|
+
], SpineSystem);
|
|
482
|
+
return SpineSystem;
|
|
483
|
+
}(Renderer));
|
|
484
|
+
var SpineSystem$1 = SpineSystem;
|
|
485
|
+
|
|
486
|
+
resource.registerResourceType('SPINE');
|
|
487
|
+
|
|
488
|
+
export { Spine$1 as Spine, SpineSystem$1 as SpineSystem };
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eva/spine-base",
|
|
3
|
+
"version": "1.2.2-alpha.0",
|
|
4
|
+
"description": "@eva/spine-base",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/spine-base.esm.js",
|
|
7
|
+
"bundle": "EVA.plugin.spineBase",
|
|
8
|
+
"unpkg": "dist/EVA.plugin.spineBase.min.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.js",
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"types": "dist/spine-base.d.ts",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"eva.js"
|
|
16
|
+
],
|
|
17
|
+
"author": "fanmingfei <az8641683@163.com>",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://eva.js.org",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@eva/eva.js": "1.2.2-alpha.0",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.2-alpha.0",
|
|
23
|
+
"@eva/inspector-decorator": "^0.0.5",
|
|
24
|
+
"pixi.js": "^4.8.9"
|
|
25
|
+
}
|
|
26
|
+
}
|