@eva/spine-base 1.2.7-editor.9 → 1.2.7-fix.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 +33 -322
- package/dist/EVA.plugin.spineBase.min.js +1 -1
- package/dist/miniprogram.js +453 -0
- package/dist/spine-base.cjs.js +5 -50
- package/dist/spine-base.cjs.prod.js +1 -1
- package/dist/spine-base.esm.js +7 -52
- package/package.json +4 -4
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
3
2
|
window.EVA = window.EVA || {};
|
|
4
3
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
5
|
-
|
|
6
4
|
var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
7
5
|
'use strict';
|
|
8
6
|
|
|
@@ -13,62 +11,33 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
13
11
|
d.__proto__ = b;
|
|
14
12
|
} || function (d, b) {
|
|
15
13
|
for (var p in b) {
|
|
16
|
-
if (
|
|
14
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
return _extendStatics(d, b);
|
|
21
18
|
};
|
|
22
|
-
|
|
23
19
|
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
|
-
|
|
26
20
|
_extendStatics(d, b);
|
|
27
|
-
|
|
28
21
|
function __() {
|
|
29
22
|
this.constructor = d;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
25
|
}
|
|
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
|
-
|
|
51
26
|
function __decorate(decorators, target, key, desc) {
|
|
52
27
|
var c = arguments.length,
|
|
53
|
-
|
|
54
|
-
|
|
28
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
29
|
+
d;
|
|
55
30
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
|
|
56
31
|
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
57
32
|
}
|
|
58
33
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
59
34
|
}
|
|
60
|
-
|
|
61
|
-
function __metadata(metadataKey, metadataValue) {
|
|
62
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
35
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
66
36
|
function adopt(value) {
|
|
67
37
|
return value instanceof P ? value : new P(function (resolve) {
|
|
68
38
|
resolve(value);
|
|
69
39
|
});
|
|
70
40
|
}
|
|
71
|
-
|
|
72
41
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
73
42
|
function fulfilled(value) {
|
|
74
43
|
try {
|
|
@@ -77,7 +46,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
77
46
|
reject(e);
|
|
78
47
|
}
|
|
79
48
|
}
|
|
80
|
-
|
|
81
49
|
function rejected(value) {
|
|
82
50
|
try {
|
|
83
51
|
step(generator["throw"](value));
|
|
@@ -85,29 +53,26 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
85
53
|
reject(e);
|
|
86
54
|
}
|
|
87
55
|
}
|
|
88
|
-
|
|
89
56
|
function step(result) {
|
|
90
57
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
91
58
|
}
|
|
92
|
-
|
|
93
59
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
94
60
|
});
|
|
95
61
|
}
|
|
96
|
-
|
|
97
62
|
function __generator(thisArg, body) {
|
|
98
63
|
var _ = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function sent() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
103
71
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
y,
|
|
109
|
-
t,
|
|
110
|
-
g;
|
|
72
|
+
f,
|
|
73
|
+
y,
|
|
74
|
+
t,
|
|
75
|
+
g;
|
|
111
76
|
return g = {
|
|
112
77
|
next: verb(0),
|
|
113
78
|
"throw": verb(1),
|
|
@@ -115,79 +80,60 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
115
80
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
116
81
|
return this;
|
|
117
82
|
}), g;
|
|
118
|
-
|
|
119
83
|
function verb(n) {
|
|
120
84
|
return function (v) {
|
|
121
85
|
return step([n, v]);
|
|
122
86
|
};
|
|
123
87
|
}
|
|
124
|
-
|
|
125
88
|
function step(op) {
|
|
126
89
|
if (f) throw new TypeError("Generator is already executing.");
|
|
127
|
-
|
|
128
90
|
while (_) {
|
|
129
91
|
try {
|
|
130
92
|
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;
|
|
131
93
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
132
|
-
|
|
133
94
|
switch (op[0]) {
|
|
134
95
|
case 0:
|
|
135
96
|
case 1:
|
|
136
97
|
t = op;
|
|
137
98
|
break;
|
|
138
|
-
|
|
139
99
|
case 4:
|
|
140
100
|
_.label++;
|
|
141
101
|
return {
|
|
142
102
|
value: op[1],
|
|
143
103
|
done: false
|
|
144
104
|
};
|
|
145
|
-
|
|
146
105
|
case 5:
|
|
147
106
|
_.label++;
|
|
148
107
|
y = op[1];
|
|
149
108
|
op = [0];
|
|
150
109
|
continue;
|
|
151
|
-
|
|
152
110
|
case 7:
|
|
153
111
|
op = _.ops.pop();
|
|
154
|
-
|
|
155
112
|
_.trys.pop();
|
|
156
|
-
|
|
157
113
|
continue;
|
|
158
|
-
|
|
159
114
|
default:
|
|
160
115
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
161
116
|
_ = 0;
|
|
162
117
|
continue;
|
|
163
118
|
}
|
|
164
|
-
|
|
165
119
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
166
120
|
_.label = op[1];
|
|
167
121
|
break;
|
|
168
122
|
}
|
|
169
|
-
|
|
170
123
|
if (op[0] === 6 && _.label < t[1]) {
|
|
171
124
|
_.label = t[1];
|
|
172
125
|
t = op;
|
|
173
126
|
break;
|
|
174
127
|
}
|
|
175
|
-
|
|
176
128
|
if (t && _.label < t[2]) {
|
|
177
129
|
_.label = t[2];
|
|
178
|
-
|
|
179
130
|
_.ops.push(op);
|
|
180
|
-
|
|
181
131
|
break;
|
|
182
132
|
}
|
|
183
|
-
|
|
184
133
|
if (t[2]) _.ops.pop();
|
|
185
|
-
|
|
186
134
|
_.trys.pop();
|
|
187
|
-
|
|
188
135
|
continue;
|
|
189
136
|
}
|
|
190
|
-
|
|
191
137
|
op = body.call(thisArg, _);
|
|
192
138
|
} catch (e) {
|
|
193
139
|
op = [6, e];
|
|
@@ -196,7 +142,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
196
142
|
f = t = 0;
|
|
197
143
|
}
|
|
198
144
|
}
|
|
199
|
-
|
|
200
145
|
if (op[0] & 5) throw op[1];
|
|
201
146
|
return {
|
|
202
147
|
value: op[0] ? op[1] : void 0,
|
|
@@ -204,11 +149,10 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
204
149
|
};
|
|
205
150
|
}
|
|
206
151
|
}
|
|
207
|
-
|
|
208
152
|
function __values(o) {
|
|
209
153
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
210
|
-
|
|
211
|
-
|
|
154
|
+
m = s && o[s],
|
|
155
|
+
i = 0;
|
|
212
156
|
if (m) return m.call(o);
|
|
213
157
|
if (o && typeof o.length === "number") return {
|
|
214
158
|
next: function next() {
|
|
@@ -221,159 +165,51 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
221
165
|
};
|
|
222
166
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
223
167
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
}
|
|
168
|
+
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
169
|
+
if (!target.constructor.IDEProps) {
|
|
170
|
+
target.constructor.IDEProps = {};
|
|
291
171
|
}
|
|
292
|
-
|
|
293
|
-
|
|
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
|
-
};
|
|
172
|
+
if (!target.constructor.IDEProps[propertyKey]) {
|
|
173
|
+
target.constructor.IDEProps[propertyKey] = {};
|
|
307
174
|
}
|
|
308
|
-
|
|
309
|
-
return
|
|
310
|
-
options: returnTypeFuncOrOptions || {}
|
|
311
|
-
};
|
|
175
|
+
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
176
|
+
return propertyObj;
|
|
312
177
|
}
|
|
313
|
-
|
|
314
|
-
function Field(returnTypeFunction, maybeOptions) {
|
|
178
|
+
function type(type) {
|
|
315
179
|
return function (target, propertyKey) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
321
|
-
options = _a.options,
|
|
322
|
-
returnTypeFunc = _a.returnTypeFunc;
|
|
323
|
-
|
|
324
|
-
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
180
|
+
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
181
|
+
prop.key = propertyKey;
|
|
182
|
+
prop.type = type;
|
|
325
183
|
};
|
|
326
184
|
}
|
|
327
|
-
|
|
328
|
-
var ExecuteMode;
|
|
329
|
-
|
|
330
|
-
(function (ExecuteMode) {
|
|
331
|
-
ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
|
|
332
|
-
ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
|
|
333
|
-
ExecuteMode[ExecuteMode["All"] = 6] = "All";
|
|
334
|
-
})(ExecuteMode || (ExecuteMode = {}));
|
|
335
|
-
|
|
336
|
-
var sleep = function sleep(time) {
|
|
337
|
-
return new Promise(function (resolve) {
|
|
338
|
-
return setTimeout(resolve, time);
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
|
|
342
185
|
var Spine = function (_super) {
|
|
343
186
|
__extends(Spine, _super);
|
|
344
|
-
|
|
345
187
|
function Spine() {
|
|
346
188
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
347
|
-
|
|
348
189
|
_this.resource = '';
|
|
349
190
|
_this.animationName = '';
|
|
350
191
|
_this.autoPlay = true;
|
|
351
192
|
_this.waitExecuteInfos = [];
|
|
352
193
|
return _this;
|
|
353
194
|
}
|
|
354
|
-
|
|
355
195
|
Object.defineProperty(Spine.prototype, "armature", {
|
|
356
196
|
get: function get() {
|
|
357
197
|
return this._armature;
|
|
358
198
|
},
|
|
359
199
|
set: function set(val) {
|
|
360
200
|
var e_1, _a;
|
|
361
|
-
|
|
362
201
|
this._armature = val;
|
|
363
202
|
if (!val) return;
|
|
364
|
-
|
|
365
203
|
if (this.autoPlay) {
|
|
366
204
|
this.play(this.animationName);
|
|
367
205
|
}
|
|
368
|
-
|
|
369
206
|
try {
|
|
370
207
|
for (var _b = __values(this.waitExecuteInfos), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
371
208
|
var info = _c.value;
|
|
372
|
-
|
|
373
209
|
if (info.playType) {
|
|
374
210
|
var name_1 = info.name,
|
|
375
|
-
|
|
376
|
-
|
|
211
|
+
loop = info.loop,
|
|
212
|
+
track = info.track;
|
|
377
213
|
this.play(name_1, loop, track);
|
|
378
214
|
} else {
|
|
379
215
|
this.stop(info.track);
|
|
@@ -390,27 +226,21 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
390
226
|
if (e_1) throw e_1.error;
|
|
391
227
|
}
|
|
392
228
|
}
|
|
393
|
-
|
|
394
229
|
this.waitExecuteInfos = [];
|
|
395
230
|
},
|
|
396
231
|
enumerable: false,
|
|
397
232
|
configurable: true
|
|
398
233
|
});
|
|
399
|
-
|
|
400
234
|
Spine.prototype.init = function (obj) {
|
|
401
235
|
if (!obj) return;
|
|
402
|
-
|
|
403
236
|
_extends(this, obj);
|
|
404
237
|
};
|
|
405
|
-
|
|
406
238
|
Spine.prototype.onDestroy = function () {
|
|
407
239
|
this.destroied = true;
|
|
408
240
|
};
|
|
409
|
-
|
|
410
241
|
Spine.prototype.play = function (name, loop, track) {
|
|
411
242
|
try {
|
|
412
243
|
if (name) this.animationName = name;
|
|
413
|
-
|
|
414
244
|
if (!this.armature) {
|
|
415
245
|
this.waitExecuteInfos.push({
|
|
416
246
|
playType: true,
|
|
@@ -422,14 +252,12 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
422
252
|
if (track === undefined) {
|
|
423
253
|
track = 0;
|
|
424
254
|
}
|
|
425
|
-
|
|
426
255
|
this.armature.state.setAnimation(track, this.animationName, loop);
|
|
427
256
|
}
|
|
428
257
|
} catch (e) {
|
|
429
258
|
console.log(e);
|
|
430
259
|
}
|
|
431
260
|
};
|
|
432
|
-
|
|
433
261
|
Spine.prototype.stop = function (track) {
|
|
434
262
|
if (!this.armature) {
|
|
435
263
|
this.waitExecuteInfos.push({
|
|
@@ -438,39 +266,32 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
438
266
|
});
|
|
439
267
|
return;
|
|
440
268
|
}
|
|
441
|
-
|
|
442
269
|
if (track === undefined) {
|
|
443
270
|
track = 0;
|
|
444
271
|
}
|
|
445
|
-
|
|
446
272
|
this.armature.state.setEmptyAnimation(track, 0);
|
|
447
273
|
};
|
|
448
|
-
|
|
449
274
|
Spine.prototype.addAnimation = function (name, delay, loop, track) {
|
|
450
275
|
try {
|
|
451
276
|
if (!this.armature) {} else {
|
|
452
277
|
if (track === undefined) {
|
|
453
278
|
track = 0;
|
|
454
279
|
}
|
|
455
|
-
|
|
456
280
|
this.armature.state.addAnimation(track, name, loop, delay);
|
|
457
281
|
}
|
|
458
282
|
} catch (e) {
|
|
459
283
|
console.log(e);
|
|
460
284
|
}
|
|
461
285
|
};
|
|
462
|
-
|
|
463
286
|
Spine.prototype.setMix = function (from, to, duration) {
|
|
464
287
|
if (!this.armature) ;else {
|
|
465
288
|
this.armature.stateData.setMix(from, to, duration);
|
|
466
289
|
}
|
|
467
290
|
};
|
|
468
|
-
|
|
469
291
|
Spine.prototype.getAnim = function (track) {
|
|
470
292
|
if (track === void 0) {
|
|
471
293
|
track = 0;
|
|
472
294
|
}
|
|
473
|
-
|
|
474
295
|
try {
|
|
475
296
|
if (!this.armature) {} else {
|
|
476
297
|
return this.armature.state.tracks[track].animation.name;
|
|
@@ -479,79 +300,31 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
479
300
|
console.log(e);
|
|
480
301
|
}
|
|
481
302
|
};
|
|
482
|
-
|
|
483
303
|
Spine.prototype.setDefaultMix = function (duration) {
|
|
484
304
|
if (!this.armature) ;else {
|
|
485
305
|
this.armature.stateData.defaultMix = duration;
|
|
486
306
|
}
|
|
487
307
|
};
|
|
488
|
-
|
|
489
308
|
Spine.prototype.setAttachment = function (slotName, attachmentName) {
|
|
490
309
|
if (!this.armature) {
|
|
491
310
|
return;
|
|
492
311
|
}
|
|
493
|
-
|
|
494
312
|
this.armature.skeleton.setAttachment(slotName, attachmentName);
|
|
495
313
|
};
|
|
496
|
-
|
|
497
314
|
Spine.prototype.getBone = function (boneName) {
|
|
498
315
|
if (!this.armature) {
|
|
499
316
|
return;
|
|
500
317
|
}
|
|
501
|
-
|
|
502
318
|
return this.armature.skeleton.findBone(boneName);
|
|
503
319
|
};
|
|
504
|
-
|
|
505
320
|
Spine.componentName = 'Spine';
|
|
506
|
-
|
|
507
|
-
__decorate([
|
|
508
|
-
|
|
509
|
-
}), __metadata("design:type", String)], Spine.prototype, "resource", void 0);
|
|
510
|
-
|
|
511
|
-
__decorate([Field({
|
|
512
|
-
type: 'selector',
|
|
513
|
-
options: function options(that) {
|
|
514
|
-
var _a, _b, _c;
|
|
515
|
-
|
|
516
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
517
|
-
var animations;
|
|
518
|
-
return __generator(this, function (_d) {
|
|
519
|
-
switch (_d.label) {
|
|
520
|
-
case 0:
|
|
521
|
-
return [4, sleep(0)];
|
|
522
|
-
|
|
523
|
-
case 1:
|
|
524
|
-
_d.sent();
|
|
525
|
-
|
|
526
|
-
if (!that.resource || !eva_js.resource.promiseMap[that.resource]) {
|
|
527
|
-
return [2, {}];
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return [4, eva_js.resource.promiseMap[that.resource]];
|
|
531
|
-
|
|
532
|
-
case 2:
|
|
533
|
-
_d.sent();
|
|
534
|
-
|
|
535
|
-
animations = (_c = (_b = (_a = eva_js.resource.resourcesMap[that.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.ske) === null || _c === void 0 ? void 0 : _c.animations;
|
|
536
|
-
return [2, animations ? Object.keys(animations).reduce(function (prev, key) {
|
|
537
|
-
var _a;
|
|
538
|
-
|
|
539
|
-
return _assign(_assign({}, prev), (_a = {}, _a[key] = key, _a));
|
|
540
|
-
}, {}) : {}];
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
}), __metadata("design:type", String)], Spine.prototype, "animationName", void 0);
|
|
546
|
-
|
|
547
|
-
__decorate([Field(), __metadata("design:type", Boolean)], Spine.prototype, "autoPlay", void 0);
|
|
548
|
-
|
|
321
|
+
__decorate([type('string')], Spine.prototype, "resource", void 0);
|
|
322
|
+
__decorate([type('string')], Spine.prototype, "animationName", void 0);
|
|
323
|
+
__decorate([type('boolean')], Spine.prototype, "autoPlay", void 0);
|
|
549
324
|
return Spine;
|
|
550
325
|
}(eva_js.Component);
|
|
551
|
-
|
|
552
326
|
var Spine$1 = Spine;
|
|
553
327
|
var texCache = {};
|
|
554
|
-
|
|
555
328
|
function cacheImage(data) {
|
|
556
329
|
var oldImg = data.image;
|
|
557
330
|
return {
|
|
@@ -559,52 +332,40 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
559
332
|
count: 0
|
|
560
333
|
};
|
|
561
334
|
}
|
|
562
|
-
|
|
563
335
|
function retainTexture(name, data) {
|
|
564
336
|
var cache = texCache[name];
|
|
565
|
-
|
|
566
337
|
if (!cache) {
|
|
567
338
|
cache = cacheImage(data);
|
|
568
339
|
texCache[name] = cache;
|
|
569
340
|
}
|
|
570
|
-
|
|
571
341
|
cache.count++;
|
|
572
342
|
return cache.tex;
|
|
573
343
|
}
|
|
574
|
-
|
|
575
344
|
function getTexture(imageSrc, data) {
|
|
576
345
|
var cache = texCache[imageSrc];
|
|
577
|
-
|
|
578
346
|
if (!cache) {
|
|
579
347
|
cache = cacheImage(data);
|
|
580
348
|
texCache[imageSrc] = cache;
|
|
581
349
|
}
|
|
582
|
-
|
|
583
350
|
return cache.tex;
|
|
584
351
|
}
|
|
585
|
-
|
|
586
352
|
function releaseTexture(imageSrc) {
|
|
587
353
|
if (!imageSrc) return;
|
|
588
354
|
setTimeout(function () {
|
|
589
355
|
var cache = texCache[imageSrc];
|
|
590
|
-
|
|
591
356
|
if (cache) {
|
|
592
357
|
cache.count--;
|
|
593
|
-
|
|
594
358
|
if (cache.count <= 0) {
|
|
595
359
|
if (cache.tex) {
|
|
596
360
|
cache.tex.destroy(true);
|
|
597
361
|
cache.tex = null;
|
|
598
362
|
}
|
|
599
|
-
|
|
600
363
|
delete texCache[imageSrc];
|
|
601
364
|
}
|
|
602
365
|
}
|
|
603
366
|
}, 100);
|
|
604
367
|
}
|
|
605
|
-
|
|
606
368
|
var dataMap = {};
|
|
607
|
-
|
|
608
369
|
function createSpineData(name, data, scale, pixiSpine) {
|
|
609
370
|
var spineData = null;
|
|
610
371
|
var img = getTexture(data.image.src, data);
|
|
@@ -614,11 +375,9 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
614
375
|
if (spineAtlas) {
|
|
615
376
|
var attachmentLoader = new pixiSpine.core.AtlasAttachmentLoader(spineAtlas);
|
|
616
377
|
var spineJsonParser = new pixiSpine.core.SkeletonJson(attachmentLoader);
|
|
617
|
-
|
|
618
378
|
if (scale) {
|
|
619
379
|
spineJsonParser.scale = scale;
|
|
620
380
|
}
|
|
621
|
-
|
|
622
381
|
spineData = spineJsonParser.readSkeletonData(data.ske);
|
|
623
382
|
}
|
|
624
383
|
});
|
|
@@ -630,13 +389,11 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
630
389
|
dataMap[name] = obj;
|
|
631
390
|
return obj;
|
|
632
391
|
}
|
|
633
|
-
|
|
634
392
|
function getSpineData(res, pixiSpine) {
|
|
635
393
|
return __awaiter(this, void 0, void 0, function () {
|
|
636
394
|
var data;
|
|
637
395
|
return __generator(this, function (_a) {
|
|
638
396
|
data = dataMap[res.name];
|
|
639
|
-
|
|
640
397
|
if (!data) {
|
|
641
398
|
if (res.complete) {
|
|
642
399
|
data = createSpineData(res.name, res.data, res.scale, pixiSpine);
|
|
@@ -644,44 +401,33 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
644
401
|
return [2];
|
|
645
402
|
}
|
|
646
403
|
}
|
|
647
|
-
|
|
648
404
|
retainTexture(res.data.image.src, res.data);
|
|
649
405
|
data.ref++;
|
|
650
406
|
return [2, data.spineData];
|
|
651
407
|
});
|
|
652
408
|
});
|
|
653
409
|
}
|
|
654
|
-
|
|
655
410
|
function releaseSpineData(resourceName, imageSrc) {
|
|
656
411
|
var data = dataMap[resourceName];
|
|
657
|
-
|
|
658
412
|
if (!data) {
|
|
659
413
|
return;
|
|
660
414
|
}
|
|
661
|
-
|
|
662
415
|
data.ref--;
|
|
663
|
-
|
|
664
416
|
if (data.ref <= 0) {
|
|
665
417
|
releaseTexture(imageSrc);
|
|
666
418
|
delete dataMap[resourceName];
|
|
667
419
|
}
|
|
668
420
|
}
|
|
669
|
-
|
|
670
421
|
var MaxRetryCount = 20;
|
|
671
|
-
|
|
672
422
|
var SpineSystem = function (_super) {
|
|
673
423
|
__extends(SpineSystem, _super);
|
|
674
|
-
|
|
675
424
|
function SpineSystem() {
|
|
676
425
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
677
|
-
|
|
678
426
|
_this.armatures = {};
|
|
679
427
|
return _this;
|
|
680
428
|
}
|
|
681
|
-
|
|
682
429
|
SpineSystem.prototype.init = function (_a) {
|
|
683
430
|
var _this = this;
|
|
684
|
-
|
|
685
431
|
var pixiSpine = _a.pixiSpine;
|
|
686
432
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
687
433
|
this.renderSystem.rendererManager.register(this);
|
|
@@ -689,16 +435,12 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
689
435
|
this.game.canvas.addEventListener('webglcontextrestored', function () {
|
|
690
436
|
var objs = _this.game.gameObjects;
|
|
691
437
|
var toAdd = [];
|
|
692
|
-
|
|
693
438
|
for (var k in _this.armatures) {
|
|
694
439
|
var id = +k;
|
|
695
|
-
|
|
696
440
|
for (var i = 0; i < objs.length; ++i) {
|
|
697
441
|
var obj = objs[i];
|
|
698
|
-
|
|
699
442
|
if (obj.id === id) {
|
|
700
443
|
var sp = obj.getComponent(Spine$1);
|
|
701
|
-
|
|
702
444
|
if (sp) {
|
|
703
445
|
_this.remove({
|
|
704
446
|
type: eva_js.OBSERVER_TYPE.REMOVE,
|
|
@@ -706,7 +448,6 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
706
448
|
component: sp,
|
|
707
449
|
componentName: Spine$1.componentName
|
|
708
450
|
});
|
|
709
|
-
|
|
710
451
|
toAdd.push({
|
|
711
452
|
type: eva_js.OBSERVER_TYPE.ADD,
|
|
712
453
|
gameObject: obj,
|
|
@@ -714,12 +455,10 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
714
455
|
componentName: Spine$1.componentName
|
|
715
456
|
});
|
|
716
457
|
}
|
|
717
|
-
|
|
718
458
|
break;
|
|
719
459
|
}
|
|
720
460
|
}
|
|
721
461
|
}
|
|
722
|
-
|
|
723
462
|
setTimeout(function () {
|
|
724
463
|
toAdd.forEach(function (obj) {
|
|
725
464
|
_this.add(obj);
|
|
@@ -727,16 +466,13 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
727
466
|
}, 1000);
|
|
728
467
|
}, false);
|
|
729
468
|
};
|
|
730
|
-
|
|
731
469
|
SpineSystem.prototype.update = function (e) {
|
|
732
470
|
for (var key in this.armatures) {
|
|
733
471
|
this.armatures[key].update(e.deltaTime * 0.001);
|
|
734
472
|
this.armatures[key].updateTransform();
|
|
735
473
|
}
|
|
736
|
-
|
|
737
474
|
_super.prototype.update.call(this);
|
|
738
475
|
};
|
|
739
|
-
|
|
740
476
|
SpineSystem.prototype.componentChanged = function (changed) {
|
|
741
477
|
return __awaiter(this, void 0, void 0, function () {
|
|
742
478
|
return __generator(this, function (_a) {
|
|
@@ -753,20 +489,15 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
753
489
|
this.remove(changed);
|
|
754
490
|
}
|
|
755
491
|
}
|
|
756
|
-
|
|
757
492
|
return [2];
|
|
758
493
|
});
|
|
759
494
|
});
|
|
760
495
|
};
|
|
761
|
-
|
|
762
496
|
SpineSystem.prototype.add = function (changed, count) {
|
|
763
497
|
var _a, _b;
|
|
764
|
-
|
|
765
498
|
return __awaiter(this, void 0, void 0, function () {
|
|
766
499
|
var component, gameObjectId, asyncId, res, spineData, container, armature, tran;
|
|
767
|
-
|
|
768
500
|
var _this = this;
|
|
769
|
-
|
|
770
501
|
return __generator(this, function (_c) {
|
|
771
502
|
switch (_c.label) {
|
|
772
503
|
case 0:
|
|
@@ -775,25 +506,20 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
775
506
|
gameObjectId = changed.gameObject.id;
|
|
776
507
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
777
508
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
778
|
-
|
|
779
509
|
case 1:
|
|
780
510
|
res = _c.sent();
|
|
781
511
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
782
512
|
return [4, getSpineData(res, this.pixiSpine)];
|
|
783
|
-
|
|
784
513
|
case 2:
|
|
785
514
|
spineData = _c.sent();
|
|
786
515
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
787
|
-
|
|
788
516
|
if (!spineData) {
|
|
789
517
|
component.addHandler = setTimeout(function () {
|
|
790
518
|
if (!component.destroied) {
|
|
791
519
|
if (count === undefined) {
|
|
792
520
|
count = MaxRetryCount;
|
|
793
521
|
}
|
|
794
|
-
|
|
795
522
|
count--;
|
|
796
|
-
|
|
797
523
|
if (count > 0) {
|
|
798
524
|
_this.add(changed, count);
|
|
799
525
|
} else {
|
|
@@ -803,24 +529,19 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
803
529
|
}, 1000);
|
|
804
530
|
return [2];
|
|
805
531
|
}
|
|
806
|
-
|
|
807
532
|
this.remove(changed);
|
|
808
533
|
container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
|
|
809
|
-
|
|
810
534
|
if (!container) {
|
|
811
535
|
return [2];
|
|
812
536
|
}
|
|
813
|
-
|
|
814
537
|
component.lastResource = component.resource;
|
|
815
538
|
armature = new this.pixiSpine.Spine(spineData);
|
|
816
539
|
this.armatures[changed.gameObject.id] = armature;
|
|
817
|
-
|
|
818
540
|
if (changed.gameObject && changed.gameObject.transform) {
|
|
819
541
|
tran = changed.gameObject.transform;
|
|
820
542
|
armature.x = tran.size.width * tran.origin.x;
|
|
821
543
|
armature.y = tran.size.height * tran.origin.y;
|
|
822
544
|
}
|
|
823
|
-
|
|
824
545
|
container.addChildAt(armature, 0);
|
|
825
546
|
armature.update();
|
|
826
547
|
armature.updateTransform();
|
|
@@ -862,15 +583,12 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
862
583
|
});
|
|
863
584
|
});
|
|
864
585
|
};
|
|
865
|
-
|
|
866
586
|
SpineSystem.prototype.change = function (changed) {
|
|
867
587
|
this.remove(changed);
|
|
868
588
|
this.add(changed);
|
|
869
589
|
};
|
|
870
|
-
|
|
871
590
|
SpineSystem.prototype.remove = function (changed) {
|
|
872
591
|
var _a, _b, _c, _d;
|
|
873
|
-
|
|
874
592
|
return __awaiter(this, void 0, void 0, function () {
|
|
875
593
|
var component, armature, container, res;
|
|
876
594
|
return __generator(this, function (_e) {
|
|
@@ -881,22 +599,18 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
881
599
|
clearTimeout(component.addHandler);
|
|
882
600
|
armature = this.armatures[changed.gameObject.id];
|
|
883
601
|
container = (_b = (_a = this.renderSystem) === null || _a === void 0 ? void 0 : _a.containerManager) === null || _b === void 0 ? void 0 : _b.getContainer(changed.gameObject.id);
|
|
884
|
-
|
|
885
602
|
if (container && armature) {
|
|
886
603
|
container.removeChild(armature);
|
|
887
604
|
}
|
|
888
|
-
|
|
889
605
|
if (!component.armature) return [3, 2];
|
|
890
606
|
component.armature.destroy({
|
|
891
607
|
children: true
|
|
892
608
|
});
|
|
893
609
|
return [4, eva_js.resource.getResource(component.lastResource)];
|
|
894
|
-
|
|
895
610
|
case 1:
|
|
896
611
|
res = _e.sent();
|
|
897
612
|
releaseSpineData(res.name, (_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src);
|
|
898
613
|
_e.label = 2;
|
|
899
|
-
|
|
900
614
|
case 2:
|
|
901
615
|
component.armature = null;
|
|
902
616
|
delete this.armatures[changed.gameObject.id];
|
|
@@ -906,14 +620,12 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
906
620
|
});
|
|
907
621
|
});
|
|
908
622
|
};
|
|
909
|
-
|
|
910
623
|
SpineSystem.systemName = 'SpineSystem';
|
|
911
624
|
SpineSystem = __decorate([eva_js.decorators.componentObserver({
|
|
912
625
|
Spine: ['resource']
|
|
913
626
|
})], SpineSystem);
|
|
914
627
|
return SpineSystem;
|
|
915
628
|
}(pluginRenderer.Renderer);
|
|
916
|
-
|
|
917
629
|
var SpineSystem$1 = SpineSystem;
|
|
918
630
|
eva_js.resource.registerResourceType('SPINE');
|
|
919
631
|
exports.Spine = Spine$1;
|
|
@@ -923,5 +635,4 @@ var _EVA_IIFE_spineBase = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
923
635
|
});
|
|
924
636
|
return exports;
|
|
925
637
|
}({}, EVA, EVA.plugin.renderer, PIXI);
|
|
926
|
-
|
|
927
638
|
window.EVA.plugin.spineBase = window.EVA.plugin.spineBase || _EVA_IIFE_spineBase;
|