@eva/plugin-renderer-sprite 1.2.7-editor.8 → 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.renderer.sprite.js +41 -442
- package/dist/EVA.plugin.renderer.sprite.min.js +1 -1
- package/dist/miniprogram.js +162 -0
- package/dist/plugin-renderer-sprite.cjs.js +2 -50
- package/dist/plugin-renderer-sprite.cjs.prod.js +1 -1
- package/dist/plugin-renderer-sprite.esm.js +4 -52
- package/package.json +4 -4
|
@@ -1,73 +1,43 @@
|
|
|
1
1
|
window.EVA = window.EVA || {};
|
|
2
2
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
3
3
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
4
|
-
|
|
5
4
|
var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
6
5
|
'use strict';
|
|
7
6
|
|
|
8
|
-
var _extendStatics
|
|
9
|
-
_extendStatics
|
|
7
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
8
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
10
9
|
__proto__: []
|
|
11
10
|
} instanceof Array && function (d, b) {
|
|
12
11
|
d.__proto__ = b;
|
|
13
12
|
} || function (d, b) {
|
|
14
13
|
for (var p in b) {
|
|
15
|
-
if (
|
|
14
|
+
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
return _extendStatics$(d, b);
|
|
17
|
+
return _extendStatics(d, b);
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
24
|
-
|
|
25
|
-
_extendStatics$(d, b);
|
|
26
|
-
|
|
19
|
+
function __extends(d, b) {
|
|
20
|
+
_extendStatics(d, b);
|
|
27
21
|
function __() {
|
|
28
22
|
this.constructor = d;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
var _assign = function __assign() {
|
|
35
|
-
_assign = Object.assign || function __assign(t) {
|
|
36
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
37
|
-
s = arguments[i];
|
|
38
|
-
|
|
39
|
-
for (var p in s) {
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return _assign.apply(this, arguments);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
26
|
function __decorate(decorators, target, key, desc) {
|
|
51
27
|
var c = arguments.length,
|
|
52
|
-
|
|
53
|
-
|
|
28
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
29
|
+
d;
|
|
54
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--) {
|
|
55
31
|
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
56
32
|
}
|
|
57
33
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
58
34
|
}
|
|
59
|
-
|
|
60
|
-
function __metadata(metadataKey, metadataValue) {
|
|
61
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
35
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
65
36
|
function adopt(value) {
|
|
66
37
|
return value instanceof P ? value : new P(function (resolve) {
|
|
67
38
|
resolve(value);
|
|
68
39
|
});
|
|
69
40
|
}
|
|
70
|
-
|
|
71
41
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
72
42
|
function fulfilled(value) {
|
|
73
43
|
try {
|
|
@@ -76,7 +46,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
76
46
|
reject(e);
|
|
77
47
|
}
|
|
78
48
|
}
|
|
79
|
-
|
|
80
49
|
function rejected(value) {
|
|
81
50
|
try {
|
|
82
51
|
step(generator["throw"](value));
|
|
@@ -84,29 +53,26 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
84
53
|
reject(e);
|
|
85
54
|
}
|
|
86
55
|
}
|
|
87
|
-
|
|
88
56
|
function step(result) {
|
|
89
57
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
90
58
|
}
|
|
91
|
-
|
|
92
59
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
93
60
|
});
|
|
94
61
|
}
|
|
95
|
-
|
|
96
62
|
function __generator(thisArg, body) {
|
|
97
63
|
var _ = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
64
|
+
label: 0,
|
|
65
|
+
sent: function sent() {
|
|
66
|
+
if (t[0] & 1) throw t[1];
|
|
67
|
+
return t[1];
|
|
68
|
+
},
|
|
69
|
+
trys: [],
|
|
70
|
+
ops: []
|
|
102
71
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
y,
|
|
108
|
-
t,
|
|
109
|
-
g;
|
|
72
|
+
f,
|
|
73
|
+
y,
|
|
74
|
+
t,
|
|
75
|
+
g;
|
|
110
76
|
return g = {
|
|
111
77
|
next: verb(0),
|
|
112
78
|
"throw": verb(1),
|
|
@@ -114,79 +80,60 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
114
80
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
115
81
|
return this;
|
|
116
82
|
}), g;
|
|
117
|
-
|
|
118
83
|
function verb(n) {
|
|
119
84
|
return function (v) {
|
|
120
85
|
return step([n, v]);
|
|
121
86
|
};
|
|
122
87
|
}
|
|
123
|
-
|
|
124
88
|
function step(op) {
|
|
125
89
|
if (f) throw new TypeError("Generator is already executing.");
|
|
126
|
-
|
|
127
90
|
while (_) {
|
|
128
91
|
try {
|
|
129
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;
|
|
130
93
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
131
|
-
|
|
132
94
|
switch (op[0]) {
|
|
133
95
|
case 0:
|
|
134
96
|
case 1:
|
|
135
97
|
t = op;
|
|
136
98
|
break;
|
|
137
|
-
|
|
138
99
|
case 4:
|
|
139
100
|
_.label++;
|
|
140
101
|
return {
|
|
141
102
|
value: op[1],
|
|
142
103
|
done: false
|
|
143
104
|
};
|
|
144
|
-
|
|
145
105
|
case 5:
|
|
146
106
|
_.label++;
|
|
147
107
|
y = op[1];
|
|
148
108
|
op = [0];
|
|
149
109
|
continue;
|
|
150
|
-
|
|
151
110
|
case 7:
|
|
152
111
|
op = _.ops.pop();
|
|
153
|
-
|
|
154
112
|
_.trys.pop();
|
|
155
|
-
|
|
156
113
|
continue;
|
|
157
|
-
|
|
158
114
|
default:
|
|
159
115
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
160
116
|
_ = 0;
|
|
161
117
|
continue;
|
|
162
118
|
}
|
|
163
|
-
|
|
164
119
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
165
120
|
_.label = op[1];
|
|
166
121
|
break;
|
|
167
122
|
}
|
|
168
|
-
|
|
169
123
|
if (op[0] === 6 && _.label < t[1]) {
|
|
170
124
|
_.label = t[1];
|
|
171
125
|
t = op;
|
|
172
126
|
break;
|
|
173
127
|
}
|
|
174
|
-
|
|
175
128
|
if (t && _.label < t[2]) {
|
|
176
129
|
_.label = t[2];
|
|
177
|
-
|
|
178
130
|
_.ops.push(op);
|
|
179
|
-
|
|
180
131
|
break;
|
|
181
132
|
}
|
|
182
|
-
|
|
183
133
|
if (t[2]) _.ops.pop();
|
|
184
|
-
|
|
185
134
|
_.trys.pop();
|
|
186
|
-
|
|
187
135
|
continue;
|
|
188
136
|
}
|
|
189
|
-
|
|
190
137
|
op = body.call(thisArg, _);
|
|
191
138
|
} catch (e) {
|
|
192
139
|
op = [6, e];
|
|
@@ -195,7 +142,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
195
142
|
f = t = 0;
|
|
196
143
|
}
|
|
197
144
|
}
|
|
198
|
-
|
|
199
145
|
if (op[0] & 5) throw op[1];
|
|
200
146
|
return {
|
|
201
147
|
value: op[0] ? op[1] : void 0,
|
|
@@ -203,11 +149,10 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
203
149
|
};
|
|
204
150
|
}
|
|
205
151
|
}
|
|
206
|
-
|
|
207
152
|
function __values(o) {
|
|
208
153
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
209
|
-
|
|
210
|
-
|
|
154
|
+
m = s && o[s],
|
|
155
|
+
i = 0;
|
|
211
156
|
if (m) return m.call(o);
|
|
212
157
|
if (o && typeof o.length === "number") return {
|
|
213
158
|
next: function next() {
|
|
@@ -220,275 +165,47 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
220
165
|
};
|
|
221
166
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
222
167
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
function SymbolKeysNotSupportedError() {
|
|
228
|
-
var _newTarget = this.constructor;
|
|
229
|
-
|
|
230
|
-
var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
|
|
231
|
-
|
|
232
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
233
|
-
return _this;
|
|
168
|
+
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
169
|
+
if (!target.constructor.IDEProps) {
|
|
170
|
+
target.constructor.IDEProps = {};
|
|
234
171
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}(Error);
|
|
238
|
-
|
|
239
|
-
(function (_super) {
|
|
240
|
-
__extends$1(StaticGetPropertiesIsNotAFunctionError, _super);
|
|
241
|
-
|
|
242
|
-
function StaticGetPropertiesIsNotAFunctionError() {
|
|
243
|
-
var _newTarget = this.constructor;
|
|
244
|
-
|
|
245
|
-
var _this = _super.call(this, 'getProperties is not a function!') || this;
|
|
246
|
-
|
|
247
|
-
Object.setPrototypeOf(_this, _newTarget.prototype);
|
|
248
|
-
return _this;
|
|
172
|
+
if (!target.constructor.IDEProps[propertyKey]) {
|
|
173
|
+
target.constructor.IDEProps[propertyKey] = {};
|
|
249
174
|
}
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
})(Error);
|
|
253
|
-
|
|
254
|
-
var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
|
|
255
|
-
|
|
256
|
-
function transformBasicType(type) {
|
|
257
|
-
if (type === String) {
|
|
258
|
-
return 'string';
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (type === Number) {
|
|
262
|
-
return 'number';
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (type === Boolean) {
|
|
266
|
-
return 'boolean';
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return 'unknown';
|
|
175
|
+
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
176
|
+
return propertyObj;
|
|
270
177
|
}
|
|
271
|
-
|
|
272
|
-
function defineTypes(target, key, options, returnTypeFunction) {
|
|
273
|
-
var type = Reflect.getMetadata('design:type', target, key);
|
|
274
|
-
var isArray = type === Array;
|
|
275
|
-
var str = transformBasicType(type);
|
|
276
|
-
|
|
277
|
-
if (str !== 'unknown') {
|
|
278
|
-
type = str;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (returnTypeFunction) {
|
|
282
|
-
var returnType = returnTypeFunction();
|
|
283
|
-
|
|
284
|
-
if (Array.isArray(returnType)) {
|
|
285
|
-
isArray = true;
|
|
286
|
-
type = returnType[0];
|
|
287
|
-
} else {
|
|
288
|
-
type = returnType;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
|
|
293
|
-
properties[key] = _assign({
|
|
294
|
-
type: type,
|
|
295
|
-
isArray: isArray
|
|
296
|
-
}, options);
|
|
297
|
-
Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
|
|
301
|
-
if (typeof returnTypeFuncOrOptions === 'function') {
|
|
302
|
-
return {
|
|
303
|
-
returnTypeFunc: returnTypeFuncOrOptions,
|
|
304
|
-
options: maybeOptions || {}
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return {
|
|
309
|
-
options: returnTypeFuncOrOptions || {}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function Field(returnTypeFunction, maybeOptions) {
|
|
178
|
+
function type(type) {
|
|
314
179
|
return function (target, propertyKey) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
|
|
320
|
-
options = _a.options,
|
|
321
|
-
returnTypeFunc = _a.returnTypeFunc;
|
|
322
|
-
|
|
323
|
-
defineTypes(target, propertyKey, options, returnTypeFunc);
|
|
180
|
+
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
181
|
+
prop.key = propertyKey;
|
|
182
|
+
prop.type = type;
|
|
324
183
|
};
|
|
325
184
|
}
|
|
326
|
-
|
|
327
|
-
var ExecuteMode;
|
|
328
|
-
|
|
329
|
-
(function (ExecuteMode) {
|
|
330
|
-
ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
|
|
331
|
-
ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
|
|
332
|
-
ExecuteMode[ExecuteMode["All"] = 6] = "All";
|
|
333
|
-
})(ExecuteMode || (ExecuteMode = {}));
|
|
334
|
-
|
|
335
|
-
var sleep = function sleep(time) {
|
|
336
|
-
return new Promise(function (resolve) {
|
|
337
|
-
return setTimeout(resolve, time);
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
|
|
341
185
|
var Sprite$3 = function (_super) {
|
|
342
|
-
__extends
|
|
343
|
-
|
|
186
|
+
__extends(Sprite, _super);
|
|
344
187
|
function Sprite() {
|
|
345
188
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
346
|
-
|
|
347
189
|
_this.resource = '';
|
|
348
190
|
_this.spriteName = '';
|
|
349
191
|
return _this;
|
|
350
192
|
}
|
|
351
|
-
|
|
352
193
|
Sprite.prototype.init = function (obj) {
|
|
353
194
|
if (obj && obj.resource) {
|
|
354
195
|
this.resource = obj.resource;
|
|
355
196
|
this.spriteName = obj.spriteName;
|
|
356
197
|
}
|
|
357
198
|
};
|
|
358
|
-
|
|
359
199
|
Sprite.componentName = 'Sprite';
|
|
360
|
-
|
|
361
|
-
__decorate([
|
|
362
|
-
type: 'resource'
|
|
363
|
-
}), __metadata("design:type", String)], Sprite.prototype, "resource", void 0);
|
|
364
|
-
|
|
365
|
-
__decorate([Field({
|
|
366
|
-
type: 'selector',
|
|
367
|
-
options: function options(instance) {
|
|
368
|
-
var _a, _b, _c;
|
|
369
|
-
|
|
370
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
371
|
-
var frames;
|
|
372
|
-
return __generator(this, function (_d) {
|
|
373
|
-
switch (_d.label) {
|
|
374
|
-
case 0:
|
|
375
|
-
return [4, sleep(0)];
|
|
376
|
-
|
|
377
|
-
case 1:
|
|
378
|
-
_d.sent();
|
|
379
|
-
|
|
380
|
-
if (!instance.resource || !eva_js.resource.promiseMap[instance.resource]) {
|
|
381
|
-
return [2, {}];
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return [4, eva_js.resource.promiseMap[instance.resource]];
|
|
385
|
-
|
|
386
|
-
case 2:
|
|
387
|
-
_d.sent();
|
|
388
|
-
|
|
389
|
-
frames = (_c = (_b = (_a = eva_js.resource.resourcesMap[instance.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.json) === null || _c === void 0 ? void 0 : _c.frames;
|
|
390
|
-
return [2, frames ? Object.values(frames).map(function (item) {
|
|
391
|
-
return item.name;
|
|
392
|
-
}).reduce(function (prev, key) {
|
|
393
|
-
var _a;
|
|
394
|
-
|
|
395
|
-
return _assign(_assign({}, prev), (_a = {}, _a[key] = key, _a));
|
|
396
|
-
}, {}) : {}];
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}), __metadata("design:type", String)], Sprite.prototype, "spriteName", void 0);
|
|
402
|
-
|
|
200
|
+
__decorate([type('string')], Sprite.prototype, "resource", void 0);
|
|
201
|
+
__decorate([type('string')], Sprite.prototype, "spriteName", void 0);
|
|
403
202
|
return Sprite;
|
|
404
203
|
}(eva_js.Component);
|
|
405
|
-
|
|
406
204
|
var Sprite$4 = Sprite$3;
|
|
407
|
-
|
|
408
|
-
var _extendStatics = function extendStatics(d, b) {
|
|
409
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
410
|
-
__proto__: []
|
|
411
|
-
} instanceof Array && function (d, b) {
|
|
412
|
-
d.__proto__ = b;
|
|
413
|
-
} || function (d, b) {
|
|
414
|
-
for (var p in b) {
|
|
415
|
-
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
return _extendStatics(d, b);
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
function __extends(d, b) {
|
|
423
|
-
_extendStatics(d, b);
|
|
424
|
-
|
|
425
|
-
function __() {
|
|
426
|
-
this.constructor = d;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
(function (_super) {
|
|
433
|
-
__extends(Application, _super);
|
|
434
|
-
|
|
435
|
-
function Application(params) {
|
|
436
|
-
var _this = this;
|
|
437
|
-
|
|
438
|
-
params.autoStart = false;
|
|
439
|
-
_this = _super.call(this, params) || this;
|
|
440
|
-
return _this;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return Application;
|
|
444
|
-
})(pixi_js.Application);
|
|
445
|
-
|
|
446
|
-
(function (_super) {
|
|
447
|
-
__extends(Container, _super);
|
|
448
|
-
|
|
449
|
-
function Container() {
|
|
450
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
return Container;
|
|
454
|
-
})(pixi_js.Container);
|
|
455
|
-
|
|
456
|
-
(function (_super) {
|
|
457
|
-
__extends(Graphics, _super);
|
|
458
|
-
|
|
459
|
-
function Graphics() {
|
|
460
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return Graphics;
|
|
464
|
-
})(pixi_js.Graphics);
|
|
465
|
-
|
|
466
|
-
(function (_super) {
|
|
467
|
-
__extends(NinePatch, _super);
|
|
468
|
-
|
|
469
|
-
function NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight) {
|
|
470
|
-
var _this = this;
|
|
471
|
-
|
|
472
|
-
var texture;
|
|
473
|
-
|
|
474
|
-
if (img === 'string') {
|
|
475
|
-
texture = pixi_js.Texture.fromFrame(img);
|
|
476
|
-
} else {
|
|
477
|
-
texture = pixi_js.Texture.from(img);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
_this = _super.call(this, texture, leftWidth, topHeight, rightWidth, bottomHeight) || this;
|
|
481
|
-
return _this;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return NinePatch;
|
|
485
|
-
})(pixi_js.mesh.NineSlicePlane);
|
|
486
|
-
|
|
487
205
|
var Sprite$2 = function () {
|
|
488
206
|
function Sprite(image) {
|
|
489
207
|
this._image = null;
|
|
490
208
|
this._image = image;
|
|
491
|
-
|
|
492
209
|
if (image) {
|
|
493
210
|
if (image instanceof HTMLImageElement) {
|
|
494
211
|
this.sprite = pixi_js.Sprite.from(image);
|
|
@@ -499,7 +216,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
499
216
|
this.sprite = new pixi_js.Sprite();
|
|
500
217
|
}
|
|
501
218
|
}
|
|
502
|
-
|
|
503
219
|
Object.defineProperty(Sprite.prototype, "image", {
|
|
504
220
|
get: function get() {
|
|
505
221
|
return this._image;
|
|
@@ -508,14 +224,12 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
508
224
|
if (this._image === val) {
|
|
509
225
|
return;
|
|
510
226
|
}
|
|
511
|
-
|
|
512
227
|
if (val instanceof HTMLImageElement) {
|
|
513
228
|
this.sprite.texture && this.sprite.texture.destroy(false);
|
|
514
229
|
this.sprite.texture = pixi_js.Texture.from(val);
|
|
515
230
|
} else if (val instanceof pixi_js.Texture) {
|
|
516
231
|
this.sprite.texture = val;
|
|
517
232
|
}
|
|
518
|
-
|
|
519
233
|
this._image = val;
|
|
520
234
|
},
|
|
521
235
|
enumerable: false,
|
|
@@ -523,116 +237,24 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
523
237
|
});
|
|
524
238
|
return Sprite;
|
|
525
239
|
}();
|
|
526
|
-
|
|
527
|
-
var Sprite$1$1 = Sprite$2;
|
|
528
|
-
|
|
529
|
-
(function () {
|
|
530
|
-
function SpriteAnimation(_a) {
|
|
531
|
-
var frames = _a.frames;
|
|
532
|
-
this.animatedSprite = new pixi_js.extras.AnimatedSprite(frames);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
SpriteAnimation.prototype.play = function () {
|
|
536
|
-
this.animatedSprite.play();
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
SpriteAnimation.prototype.stop = function () {
|
|
540
|
-
this.animatedSprite.stop();
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
544
|
-
this.animatedSprite.gotoAndPlay(frameNumber);
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
548
|
-
this.animatedSprite.gotoAndStop(frameNumber);
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
Object.defineProperty(SpriteAnimation.prototype, "speed", {
|
|
552
|
-
get: function get() {
|
|
553
|
-
return this.animatedSprite.animationSpeed;
|
|
554
|
-
},
|
|
555
|
-
set: function set(val) {
|
|
556
|
-
this.animatedSprite.animationSpeed = val;
|
|
557
|
-
},
|
|
558
|
-
enumerable: false,
|
|
559
|
-
configurable: true
|
|
560
|
-
});
|
|
561
|
-
return SpriteAnimation;
|
|
562
|
-
})();
|
|
563
|
-
|
|
564
|
-
(function (_super) {
|
|
565
|
-
__extends(Text, _super);
|
|
566
|
-
|
|
567
|
-
function Text(text, style) {
|
|
568
|
-
return _super.call(this, text, style) || this;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return Text;
|
|
572
|
-
})(pixi_js.Text);
|
|
573
|
-
|
|
574
|
-
var PIXITilingSprite = pixi_js.extras.TilingSprite;
|
|
575
|
-
|
|
576
|
-
(function () {
|
|
577
|
-
function TilingSprite(image) {
|
|
578
|
-
this._image = null;
|
|
579
|
-
this._image = image;
|
|
580
|
-
|
|
581
|
-
if (image) {
|
|
582
|
-
if (image instanceof HTMLImageElement) {
|
|
583
|
-
this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.from(image));
|
|
584
|
-
} else if (image instanceof pixi_js.Texture) {
|
|
585
|
-
this.tilingSprite = new PIXITilingSprite(image);
|
|
586
|
-
}
|
|
587
|
-
} else {
|
|
588
|
-
this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.EMPTY);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
Object.defineProperty(TilingSprite.prototype, "image", {
|
|
593
|
-
get: function get() {
|
|
594
|
-
return this._image;
|
|
595
|
-
},
|
|
596
|
-
set: function set(val) {
|
|
597
|
-
if (this._image === val) {
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (val instanceof HTMLImageElement) {
|
|
602
|
-
this.tilingSprite.texture = pixi_js.Texture.from(val);
|
|
603
|
-
} else if (val instanceof pixi_js.Texture) {
|
|
604
|
-
this.tilingSprite.texture = val;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
this._image = val;
|
|
608
|
-
},
|
|
609
|
-
enumerable: false,
|
|
610
|
-
configurable: true
|
|
611
|
-
});
|
|
612
|
-
return TilingSprite;
|
|
613
|
-
})();
|
|
614
|
-
|
|
240
|
+
var SpriteEngine = Sprite$2;
|
|
615
241
|
var resourceKeySplit = '_s|r|c_';
|
|
616
242
|
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, function (_a) {
|
|
617
243
|
var name = _a.name,
|
|
618
|
-
|
|
244
|
+
data = _a.data;
|
|
619
245
|
return new Promise(function (r) {
|
|
620
246
|
var e_1, _a;
|
|
621
|
-
|
|
622
247
|
var textureObj = data.json;
|
|
623
248
|
var texture = pixi_js.BaseTexture.from(data.image);
|
|
624
249
|
var frames = textureObj.frames || {};
|
|
625
250
|
var animations = textureObj.animations || {};
|
|
626
251
|
var newFrames = {};
|
|
627
|
-
|
|
628
252
|
for (var key in frames) {
|
|
629
253
|
var newKey = name + resourceKeySplit + key;
|
|
630
254
|
newFrames[newKey] = frames[key];
|
|
631
255
|
}
|
|
632
|
-
|
|
633
256
|
for (var key in animations) {
|
|
634
257
|
var spriteList = [];
|
|
635
|
-
|
|
636
258
|
if (animations[key] && animations[key].length >= 0) {
|
|
637
259
|
try {
|
|
638
260
|
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -652,10 +274,8 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
652
274
|
}
|
|
653
275
|
}
|
|
654
276
|
}
|
|
655
|
-
|
|
656
277
|
animations[key] = spriteList;
|
|
657
278
|
}
|
|
658
|
-
|
|
659
279
|
textureObj.frames = newFrames;
|
|
660
280
|
var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
661
281
|
spriteSheet.parse(function () {
|
|
@@ -667,39 +287,31 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
667
287
|
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE, function (_a) {
|
|
668
288
|
var instance = _a.instance;
|
|
669
289
|
if (!instance) return;
|
|
670
|
-
|
|
671
290
|
for (var key in instance) {
|
|
672
291
|
instance[key].destroy(true);
|
|
673
292
|
}
|
|
674
293
|
});
|
|
675
|
-
|
|
676
294
|
var Sprite = function (_super) {
|
|
677
|
-
__extends
|
|
678
|
-
|
|
295
|
+
__extends(Sprite, _super);
|
|
679
296
|
function Sprite() {
|
|
680
297
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
681
|
-
|
|
682
298
|
_this.name = 'Sprite';
|
|
683
299
|
_this.sprites = {};
|
|
684
300
|
return _this;
|
|
685
301
|
}
|
|
686
|
-
|
|
687
302
|
Sprite.prototype.init = function () {
|
|
688
303
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
689
304
|
this.renderSystem.rendererManager.register(this);
|
|
690
305
|
};
|
|
691
|
-
|
|
692
306
|
Sprite.prototype.rendererUpdate = function (gameObject) {
|
|
693
307
|
var _a = gameObject.transform.size,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
308
|
+
width = _a.width,
|
|
309
|
+
height = _a.height;
|
|
697
310
|
if (this.sprites[gameObject.id]) {
|
|
698
311
|
this.sprites[gameObject.id].sprite.width = width;
|
|
699
312
|
this.sprites[gameObject.id].sprite.height = height;
|
|
700
313
|
}
|
|
701
314
|
};
|
|
702
|
-
|
|
703
315
|
Sprite.prototype.componentChanged = function (changed) {
|
|
704
316
|
return __awaiter(this, void 0, void 0, function () {
|
|
705
317
|
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
@@ -710,41 +322,33 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
710
322
|
gameObjectId = changed.gameObject.id;
|
|
711
323
|
component = changed.component;
|
|
712
324
|
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
713
|
-
sprite = new
|
|
325
|
+
sprite = new SpriteEngine(null);
|
|
714
326
|
this.sprites[changed.gameObject.id] = sprite;
|
|
715
327
|
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
716
328
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
717
329
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
718
|
-
|
|
719
330
|
case 1:
|
|
720
331
|
instance = _a.sent().instance;
|
|
721
332
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
722
|
-
|
|
723
333
|
if (!instance) {
|
|
724
334
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
725
335
|
return [2];
|
|
726
336
|
}
|
|
727
|
-
|
|
728
337
|
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
729
338
|
return [3, 5];
|
|
730
|
-
|
|
731
339
|
case 2:
|
|
732
340
|
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
733
341
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
734
342
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
735
|
-
|
|
736
343
|
case 3:
|
|
737
344
|
instance = _a.sent().instance;
|
|
738
345
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
739
|
-
|
|
740
346
|
if (!instance) {
|
|
741
347
|
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
742
348
|
return [2];
|
|
743
349
|
}
|
|
744
|
-
|
|
745
350
|
this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
746
351
|
return [3, 5];
|
|
747
|
-
|
|
748
352
|
case 4:
|
|
749
353
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
750
354
|
this.increaseAsyncId(gameObjectId);
|
|
@@ -755,23 +359,19 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
755
359
|
});
|
|
756
360
|
delete this.sprites[changed.gameObject.id];
|
|
757
361
|
}
|
|
758
|
-
|
|
759
362
|
_a.label = 5;
|
|
760
|
-
|
|
761
363
|
case 5:
|
|
762
364
|
return [2];
|
|
763
365
|
}
|
|
764
366
|
});
|
|
765
367
|
});
|
|
766
368
|
};
|
|
767
|
-
|
|
768
369
|
Sprite.systemName = 'Sprite';
|
|
769
370
|
Sprite = __decorate([eva_js.decorators.componentObserver({
|
|
770
371
|
Sprite: ['spriteName']
|
|
771
372
|
})], Sprite);
|
|
772
373
|
return Sprite;
|
|
773
374
|
}(pluginRenderer.Renderer);
|
|
774
|
-
|
|
775
375
|
var Sprite$1 = Sprite;
|
|
776
376
|
exports.Sprite = Sprite$4;
|
|
777
377
|
exports.SpriteSystem = Sprite$1;
|
|
@@ -780,5 +380,4 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
780
380
|
});
|
|
781
381
|
return exports;
|
|
782
382
|
}({}, EVA, EVA.plugin.renderer, PIXI);
|
|
783
|
-
|
|
784
383
|
window.EVA.plugin.renderer.sprite = window.EVA.plugin.renderer.sprite || _EVA_IIFE_sprite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};function s(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var l=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return o(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}o(t,e)}(Error);var h,d="IDE_PROPERTY_METADATA";function y(e,t,r,n){var i=Reflect.getMetadata("design:type",e,t),o=i===Array,s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(i);if("unknown"!==s&&(i=s),n){var c=n();Array.isArray(c)?(o=!0,i=c[0]):i=c}var u=Reflect.getMetadata(d,e.constructor)||{};u[t]=a({type:i,isArray:o},r),Reflect.defineMetadata(d,u,e.constructor)}function m(e,t){return function(r,n){if("symbol"==typeof n)throw new l;var i=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);y(r,n,i.options,i.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(h||(h={}));var g=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([m({type:"resource"}),c("design:type",String)],r.prototype,"resource",void 0),s([m({type:"selector",options:function(e){var r,n,i;return u(this,void 0,void 0,(function(){var o;return p(this,(function(s){switch(s.label){case 0:return[4,(c=0,new Promise((function(e){return setTimeout(e,c)})))];case 1:return s.sent(),e.resource&&t.resource.promiseMap[e.resource]?[4,t.resource.promiseMap[e.resource]]:[2,{}];case 2:return s.sent(),[2,(o=null===(i=null===(n=null===(r=t.resource.resourcesMap[e.resource])||void 0===r?void 0:r.data)||void 0===n?void 0:n.json)||void 0===i?void 0:i.frames)?Object.values(o).map((function(e){return e.name})).reduce((function(e,t){var r;return a(a({},e),((r={})[t]=t,r))}),{}):{}]}var c}))}))}}),c("design:type",String)],r.prototype,"spriteName",void 0),r}(t.Component),v=g,b=function(e,t){return b=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])},b(e,t)};function w(e,t){function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}!function(e){function t(t){return t.autoStart=!1,e.call(this,t)||this}w(t,e)}(n.Application),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}w(t,e)}(n.Container),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}w(t,e)}(n.Graphics),function(e){function t(t,r,i,o,a){var s;return s="string"===t?n.Texture.fromFrame(t):n.Texture.from(t),e.call(this,s,r,i,o,a)||this}w(t,e)}(n.mesh.NineSlicePlane);var S=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),E=S;!function(){function e(e){var t=e.frames;this.animatedSprite=new n.extras.AnimatedSprite(t)}e.prototype.play=function(){this.animatedSprite.play()},e.prototype.stop=function(){this.animatedSprite.stop()},e.prototype.gotoAndPlay=function(e){this.animatedSprite.gotoAndPlay(e)},e.prototype.gotoAndStop=function(e){this.animatedSprite.gotoAndStop(e)},Object.defineProperty(e.prototype,"speed",{get:function(){return this.animatedSprite.animationSpeed},set:function(e){this.animatedSprite.animationSpeed=e},enumerable:!1,configurable:!0})}(),function(e){function t(t,r){return e.call(this,t,r)||this}w(t,e)}(n.Text);var O=n.extras.TilingSprite;!function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.tilingSprite=new O(n.Texture.from(e)):e instanceof n.Texture&&(this.tilingSprite=new O(e)):this.tilingSprite=new O(n.Texture.EMPTY)}Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?this.tilingSprite.texture=n.Texture.from(e):e instanceof n.Texture&&(this.tilingSprite.texture=e),this._image=e)},enumerable:!1,configurable:!0})}();var _="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,a=r.json,s=n.BaseTexture.from(r.image),c=a.frames||{},u=a.animations||{},p={};for(var l in c){p[t+_+l]=c[l]}for(var l in u){var h=[];if(u[l]&&u[l].length>=0)try{for(var d=(i=void 0,f(u[l])),y=d.next();!y.done;y=d.next()){var m=y.value,g=t+_+m;h.push(g)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}u[l]=h}a.frames=p;var v=new n.Spritesheet(s,a);v.parse((function(){var t=v.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var A=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return u(this,void 0,void 0,(function(){var r,n,i,o,a;return p(this,(function(s){switch(s.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new E(null),this.sprites[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(a.image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),a=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),s.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),T=A;return e.Sprite=v,e.SpriteSystem=T,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
|
|
1
|
+
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=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])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(e){return function(t,r){var n=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);n.key=r,n.type=e}}var l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},t.componentName="Sprite",s([p("string")],t.prototype,"resource",void 0),s([p("string")],t.prototype,"spriteName",void 0),t}(t.Component),f=l,d=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),h=d,m="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},p=s.animations||{},l={};for(var f in c){l[t+m+f]=c[f]}for(var f in p){var d=[];if(p[f]&&p[f].length>=0)try{for(var h=(i=void 0,u(p[f])),y=h.next();!y.done;y=h.next()){var g=y.value,v=t+m+g;d.push(v)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}p[f]=d}s.frames=l;var b=new n.Spritesheet(a,s);b.parse((function(){var t=b.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var y=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return a(this,void 0,void 0,(function(){var r,n,i,o,s;return c(this,(function(a){switch(a.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(s=new h(null),this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+m+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+m+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),a.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),g=y;return e.Sprite=f,e.SpriteSystem=g,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
3
|
+
import { type } from '@eva/inspector-decorator';
|
|
4
|
+
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
|
+
import { Sprite as Sprite$4 } from '@eva/renderer-adapter/dist/miniprogram';
|
|
6
|
+
import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
|
|
7
|
+
var Sprite$2 = function (_super) {
|
|
8
|
+
__extends(Sprite, _super);
|
|
9
|
+
function Sprite() {
|
|
10
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
11
|
+
_this.resource = '';
|
|
12
|
+
_this.spriteName = '';
|
|
13
|
+
return _this;
|
|
14
|
+
}
|
|
15
|
+
Sprite.prototype.init = function (obj) {
|
|
16
|
+
if (obj && obj.resource) {
|
|
17
|
+
this.resource = obj.resource;
|
|
18
|
+
this.spriteName = obj.spriteName;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
Sprite.componentName = 'Sprite';
|
|
22
|
+
__decorate([type('string')], Sprite.prototype, "resource", void 0);
|
|
23
|
+
__decorate([type('string')], Sprite.prototype, "spriteName", void 0);
|
|
24
|
+
return Sprite;
|
|
25
|
+
}(Component);
|
|
26
|
+
var Sprite$3 = Sprite$2;
|
|
27
|
+
var resourceKeySplit = '_s|r|c_';
|
|
28
|
+
resource.registerInstance(RESOURCE_TYPE.SPRITE, function (_a) {
|
|
29
|
+
var name = _a.name,
|
|
30
|
+
data = _a.data;
|
|
31
|
+
return new Promise(function (r) {
|
|
32
|
+
var e_1, _a;
|
|
33
|
+
var textureObj = data.json;
|
|
34
|
+
var texture = BaseTexture.from(data.image);
|
|
35
|
+
var frames = textureObj.frames || {};
|
|
36
|
+
var animations = textureObj.animations || {};
|
|
37
|
+
var newFrames = {};
|
|
38
|
+
for (var key in frames) {
|
|
39
|
+
var newKey = name + resourceKeySplit + key;
|
|
40
|
+
newFrames[newKey] = frames[key];
|
|
41
|
+
}
|
|
42
|
+
for (var key in animations) {
|
|
43
|
+
var spriteList = [];
|
|
44
|
+
if (animations[key] && animations[key].length >= 0) {
|
|
45
|
+
try {
|
|
46
|
+
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
47
|
+
var spriteName = _c.value;
|
|
48
|
+
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
49
|
+
spriteList.push(newSpriteName);
|
|
50
|
+
}
|
|
51
|
+
} catch (e_1_1) {
|
|
52
|
+
e_1 = {
|
|
53
|
+
error: e_1_1
|
|
54
|
+
};
|
|
55
|
+
} finally {
|
|
56
|
+
try {
|
|
57
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
58
|
+
} finally {
|
|
59
|
+
if (e_1) throw e_1.error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
animations[key] = spriteList;
|
|
64
|
+
}
|
|
65
|
+
textureObj.frames = newFrames;
|
|
66
|
+
var spriteSheet = new Spritesheet(texture, textureObj);
|
|
67
|
+
spriteSheet.parse(function () {
|
|
68
|
+
var textures = spriteSheet.textures;
|
|
69
|
+
r(textures);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
resource.registerDestroy(RESOURCE_TYPE.SPRITE, function (_a) {
|
|
74
|
+
var instance = _a.instance;
|
|
75
|
+
if (!instance) return;
|
|
76
|
+
for (var key in instance) {
|
|
77
|
+
instance[key].destroy(true);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
var Sprite = function (_super) {
|
|
81
|
+
__extends(Sprite, _super);
|
|
82
|
+
function Sprite() {
|
|
83
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
84
|
+
_this.name = 'Sprite';
|
|
85
|
+
_this.sprites = {};
|
|
86
|
+
return _this;
|
|
87
|
+
}
|
|
88
|
+
Sprite.prototype.init = function () {
|
|
89
|
+
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
90
|
+
this.renderSystem.rendererManager.register(this);
|
|
91
|
+
};
|
|
92
|
+
Sprite.prototype.rendererUpdate = function (gameObject) {
|
|
93
|
+
var _a = gameObject.transform.size,
|
|
94
|
+
width = _a.width,
|
|
95
|
+
height = _a.height;
|
|
96
|
+
if (this.sprites[gameObject.id]) {
|
|
97
|
+
this.sprites[gameObject.id].sprite.width = width;
|
|
98
|
+
this.sprites[gameObject.id].sprite.height = height;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
Sprite.prototype.componentChanged = function (changed) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
108
|
+
gameObjectId = changed.gameObject.id;
|
|
109
|
+
component = changed.component;
|
|
110
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
111
|
+
sprite = new Sprite$4(null);
|
|
112
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
113
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
114
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
115
|
+
return [4, resource.getResource(component.resource)];
|
|
116
|
+
case 1:
|
|
117
|
+
instance = _a.sent().instance;
|
|
118
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
119
|
+
if (!instance) {
|
|
120
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
121
|
+
return [2];
|
|
122
|
+
}
|
|
123
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
124
|
+
return [3, 5];
|
|
125
|
+
case 2:
|
|
126
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
127
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
128
|
+
return [4, resource.getResource(component.resource)];
|
|
129
|
+
case 3:
|
|
130
|
+
instance = _a.sent().instance;
|
|
131
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
132
|
+
if (!instance) {
|
|
133
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
134
|
+
return [2];
|
|
135
|
+
}
|
|
136
|
+
this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
137
|
+
return [3, 5];
|
|
138
|
+
case 4:
|
|
139
|
+
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
140
|
+
this.increaseAsyncId(gameObjectId);
|
|
141
|
+
sprite = this.sprites[changed.gameObject.id];
|
|
142
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
143
|
+
sprite.sprite.destroy({
|
|
144
|
+
children: true
|
|
145
|
+
});
|
|
146
|
+
delete this.sprites[changed.gameObject.id];
|
|
147
|
+
}
|
|
148
|
+
_a.label = 5;
|
|
149
|
+
case 5:
|
|
150
|
+
return [2];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
Sprite.systemName = 'Sprite';
|
|
156
|
+
Sprite = __decorate([decorators.componentObserver({
|
|
157
|
+
Sprite: ['spriteName']
|
|
158
|
+
})], Sprite);
|
|
159
|
+
return Sprite;
|
|
160
|
+
}(Renderer);
|
|
161
|
+
var Sprite$1 = Sprite;
|
|
162
|
+
export { Sprite$3 as Sprite, Sprite$1 as SpriteSystem };
|
|
@@ -36,17 +36,6 @@ function __extends(d, b) {
|
|
|
36
36
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
var __assign = function() {
|
|
40
|
-
__assign = Object.assign || function __assign(t) {
|
|
41
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
42
|
-
s = arguments[i];
|
|
43
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
|
-
return __assign.apply(this, arguments);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
39
|
function __decorate(decorators, target, key, desc) {
|
|
51
40
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
52
41
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -54,10 +43,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
54
43
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
function __metadata(metadataKey, metadataValue) {
|
|
58
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
46
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
62
47
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
63
48
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -106,7 +91,6 @@ function __values(o) {
|
|
|
106
91
|
};
|
|
107
92
|
}
|
|
108
93
|
|
|
109
|
-
var sleep = function (time) { return new Promise(function (resolve) { return setTimeout(resolve, time); }); };
|
|
110
94
|
var Sprite$3 = (function (_super) {
|
|
111
95
|
__extends(Sprite, _super);
|
|
112
96
|
function Sprite() {
|
|
@@ -123,42 +107,10 @@ var Sprite$3 = (function (_super) {
|
|
|
123
107
|
};
|
|
124
108
|
Sprite.componentName = 'Sprite';
|
|
125
109
|
__decorate([
|
|
126
|
-
inspectorDecorator.
|
|
127
|
-
__metadata("design:type", String)
|
|
110
|
+
inspectorDecorator.type('string')
|
|
128
111
|
], Sprite.prototype, "resource", void 0);
|
|
129
112
|
__decorate([
|
|
130
|
-
inspectorDecorator.
|
|
131
|
-
type: 'selector',
|
|
132
|
-
options: function (instance) {
|
|
133
|
-
var _a, _b, _c;
|
|
134
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
var frames;
|
|
136
|
-
return __generator(this, function (_d) {
|
|
137
|
-
switch (_d.label) {
|
|
138
|
-
case 0: return [4, sleep(0)];
|
|
139
|
-
case 1:
|
|
140
|
-
_d.sent();
|
|
141
|
-
if (!instance.resource || !eva_js.resource.promiseMap[instance.resource]) {
|
|
142
|
-
return [2, {}];
|
|
143
|
-
}
|
|
144
|
-
return [4, eva_js.resource.promiseMap[instance.resource]];
|
|
145
|
-
case 2:
|
|
146
|
-
_d.sent();
|
|
147
|
-
frames = (_c = (_b = (_a = eva_js.resource.resourcesMap[instance.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.json) === null || _c === void 0 ? void 0 : _c.frames;
|
|
148
|
-
return [2, frames
|
|
149
|
-
? Object.values(frames)
|
|
150
|
-
.map(function (item) { return item.name; })
|
|
151
|
-
.reduce(function (prev, key) {
|
|
152
|
-
var _a;
|
|
153
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[key] = key, _a)));
|
|
154
|
-
}, {})
|
|
155
|
-
: {}];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
}),
|
|
161
|
-
__metadata("design:type", String)
|
|
113
|
+
inspectorDecorator.type('string')
|
|
162
114
|
], Sprite.prototype, "spriteName", void 0);
|
|
163
115
|
return Sprite;
|
|
164
116
|
}(eva_js.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return i=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])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return i=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])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function c(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}}}}var u=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([t.type("string")],r.prototype,"resource",void 0),s([t.type("string")],r.prototype,"spriteName",void 0),r}(e.Component),p=u,l=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),f=l;e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),u=s.frames||{},p=s.animations||{},l={};for(var f in u){l[t+"_s|r|c_"+f]=u[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var m=(i=void 0,c(p[f])),d=m.next();!d.done;d=m.next()){var y=d.value,g=t+"_s|r|c_"+y;h.push(g)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var v=new n.Spritesheet(a,s);v.parse((function(){var t=v.textures;e(t)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var h=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Sprite",e.sprites={},e}return o(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(t){return r=this,n=void 0,o=function(){var r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:return"Sprite"!==t.componentName?[3,5]:(r=t.gameObject.id,n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new f(null),this.sprites[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[t.gameObject.id].image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]),a.label=5;case 5:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(s,a)}c((o=o.apply(r,n||[])).next())}));var r,n,i,o},n.systemName="Sprite",n=s([e.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);exports.Sprite=p,exports.SpriteSystem=h;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
|
-
import {
|
|
2
|
+
import { type } from '@eva/inspector-decorator';
|
|
3
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
4
|
-
import {
|
|
4
|
+
import { Sprite as Sprite$5, Texture, BaseTexture, Spritesheet } from 'pixi.js';
|
|
5
5
|
|
|
6
6
|
/*! *****************************************************************************
|
|
7
7
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -32,17 +32,6 @@ function __extends(d, b) {
|
|
|
32
32
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var __assign = function() {
|
|
36
|
-
__assign = Object.assign || function __assign(t) {
|
|
37
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
38
|
-
s = arguments[i];
|
|
39
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
|
-
return __assign.apply(this, arguments);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
35
|
function __decorate(decorators, target, key, desc) {
|
|
47
36
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
48
37
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -50,10 +39,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
50
39
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
51
40
|
}
|
|
52
41
|
|
|
53
|
-
function __metadata(metadataKey, metadataValue) {
|
|
54
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
42
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
58
43
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
59
44
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -102,7 +87,6 @@ function __values(o) {
|
|
|
102
87
|
};
|
|
103
88
|
}
|
|
104
89
|
|
|
105
|
-
var sleep = function (time) { return new Promise(function (resolve) { return setTimeout(resolve, time); }); };
|
|
106
90
|
var Sprite$3 = (function (_super) {
|
|
107
91
|
__extends(Sprite, _super);
|
|
108
92
|
function Sprite() {
|
|
@@ -119,42 +103,10 @@ var Sprite$3 = (function (_super) {
|
|
|
119
103
|
};
|
|
120
104
|
Sprite.componentName = 'Sprite';
|
|
121
105
|
__decorate([
|
|
122
|
-
|
|
123
|
-
__metadata("design:type", String)
|
|
106
|
+
type('string')
|
|
124
107
|
], Sprite.prototype, "resource", void 0);
|
|
125
108
|
__decorate([
|
|
126
|
-
|
|
127
|
-
type: 'selector',
|
|
128
|
-
options: function (instance) {
|
|
129
|
-
var _a, _b, _c;
|
|
130
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
-
var frames;
|
|
132
|
-
return __generator(this, function (_d) {
|
|
133
|
-
switch (_d.label) {
|
|
134
|
-
case 0: return [4, sleep(0)];
|
|
135
|
-
case 1:
|
|
136
|
-
_d.sent();
|
|
137
|
-
if (!instance.resource || !resource.promiseMap[instance.resource]) {
|
|
138
|
-
return [2, {}];
|
|
139
|
-
}
|
|
140
|
-
return [4, resource.promiseMap[instance.resource]];
|
|
141
|
-
case 2:
|
|
142
|
-
_d.sent();
|
|
143
|
-
frames = (_c = (_b = (_a = resource.resourcesMap[instance.resource]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.json) === null || _c === void 0 ? void 0 : _c.frames;
|
|
144
|
-
return [2, frames
|
|
145
|
-
? Object.values(frames)
|
|
146
|
-
.map(function (item) { return item.name; })
|
|
147
|
-
.reduce(function (prev, key) {
|
|
148
|
-
var _a;
|
|
149
|
-
return (__assign(__assign({}, prev), (_a = {}, _a[key] = key, _a)));
|
|
150
|
-
}, {})
|
|
151
|
-
: {}];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
}),
|
|
157
|
-
__metadata("design:type", String)
|
|
109
|
+
type('string')
|
|
158
110
|
], Sprite.prototype, "spriteName", void 0);
|
|
159
111
|
return Sprite;
|
|
160
112
|
}(Component));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite",
|
|
3
|
-
"version": "1.2.7-
|
|
3
|
+
"version": "1.2.7-fix.4",
|
|
4
4
|
"description": "@eva/plugin-renderer-sprite",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/inspector-decorator": "0.
|
|
22
|
-
"@eva/plugin-renderer": "1.2.7-
|
|
23
|
-
"@eva/eva.js": "1.2.7-
|
|
21
|
+
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7-fix.4",
|
|
23
|
+
"@eva/eva.js": "1.2.7-fix.4",
|
|
24
24
|
"pixi.js": "^4.8.7"
|
|
25
25
|
}
|
|
26
26
|
}
|