@eva/plugin-renderer-img 2.0.0-beta.1 → 2.0.0-beta.2
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.
|
@@ -3,23 +3,6 @@ window.EVA.plugin = window.EVA.plugin || {};
|
|
|
3
3
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
4
4
|
var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
|
|
5
5
|
'use strict';
|
|
6
|
-
var extendStatics = function (d, b) {
|
|
7
|
-
extendStatics = Object.setPrototypeOf || {
|
|
8
|
-
__proto__: []
|
|
9
|
-
} instanceof Array && function (d, b) {
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
} || function (d, b) {
|
|
12
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
13
|
-
};
|
|
14
|
-
return extendStatics(d, b);
|
|
15
|
-
};
|
|
16
|
-
function __extends(d, b) {
|
|
17
|
-
extendStatics(d, b);
|
|
18
|
-
function __() {
|
|
19
|
-
this.constructor = d;
|
|
20
|
-
}
|
|
21
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
22
|
-
}
|
|
23
6
|
function __decorate(decorators, target, key, desc) {
|
|
24
7
|
var c = arguments.length,
|
|
25
8
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -54,94 +37,6 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
54
37
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
55
38
|
});
|
|
56
39
|
}
|
|
57
|
-
function __generator(thisArg, body) {
|
|
58
|
-
var _ = {
|
|
59
|
-
label: 0,
|
|
60
|
-
sent: function () {
|
|
61
|
-
if (t[0] & 1) throw t[1];
|
|
62
|
-
return t[1];
|
|
63
|
-
},
|
|
64
|
-
trys: [],
|
|
65
|
-
ops: []
|
|
66
|
-
},
|
|
67
|
-
f,
|
|
68
|
-
y,
|
|
69
|
-
t,
|
|
70
|
-
g;
|
|
71
|
-
return g = {
|
|
72
|
-
next: verb(0),
|
|
73
|
-
"throw": verb(1),
|
|
74
|
-
"return": verb(2)
|
|
75
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
76
|
-
return this;
|
|
77
|
-
}), g;
|
|
78
|
-
function verb(n) {
|
|
79
|
-
return function (v) {
|
|
80
|
-
return step([n, v]);
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function step(op) {
|
|
84
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
85
|
-
while (_) try {
|
|
86
|
-
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;
|
|
87
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
88
|
-
switch (op[0]) {
|
|
89
|
-
case 0:
|
|
90
|
-
case 1:
|
|
91
|
-
t = op;
|
|
92
|
-
break;
|
|
93
|
-
case 4:
|
|
94
|
-
_.label++;
|
|
95
|
-
return {
|
|
96
|
-
value: op[1],
|
|
97
|
-
done: false
|
|
98
|
-
};
|
|
99
|
-
case 5:
|
|
100
|
-
_.label++;
|
|
101
|
-
y = op[1];
|
|
102
|
-
op = [0];
|
|
103
|
-
continue;
|
|
104
|
-
case 7:
|
|
105
|
-
op = _.ops.pop();
|
|
106
|
-
_.trys.pop();
|
|
107
|
-
continue;
|
|
108
|
-
default:
|
|
109
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
110
|
-
_ = 0;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
114
|
-
_.label = op[1];
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
118
|
-
_.label = t[1];
|
|
119
|
-
t = op;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
if (t && _.label < t[2]) {
|
|
123
|
-
_.label = t[2];
|
|
124
|
-
_.ops.push(op);
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
if (t[2]) _.ops.pop();
|
|
128
|
-
_.trys.pop();
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
op = body.call(thisArg, _);
|
|
132
|
-
} catch (e) {
|
|
133
|
-
op = [6, e];
|
|
134
|
-
y = 0;
|
|
135
|
-
} finally {
|
|
136
|
-
f = t = 0;
|
|
137
|
-
}
|
|
138
|
-
if (op[0] & 5) throw op[1];
|
|
139
|
-
return {
|
|
140
|
-
value: op[0] ? op[1] : void 0,
|
|
141
|
-
done: true
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
40
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
146
41
|
if (!target.constructor.IDEProps) {
|
|
147
42
|
target.constructor.IDEProps = {};
|
|
@@ -159,138 +54,123 @@ var _EVA_IIFE_img = function (exports, eva_js, pluginRenderer, rendererAdapter,
|
|
|
159
54
|
prop.type = type;
|
|
160
55
|
};
|
|
161
56
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_this.resource = '';
|
|
167
|
-
return _this;
|
|
57
|
+
class Img$2 extends eva_js.Component {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
60
|
+
this.resource = '';
|
|
168
61
|
}
|
|
169
|
-
|
|
62
|
+
init(obj) {
|
|
170
63
|
if (obj && obj.resource) {
|
|
171
64
|
this.resource = obj.resource;
|
|
172
65
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
Img$2.componentName = 'Img';
|
|
69
|
+
__decorate([type('string')], Img$2.prototype, "resource", void 0);
|
|
70
|
+
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.IMAGE, ({
|
|
71
|
+
data = {}
|
|
72
|
+
}) => {
|
|
73
|
+
const {
|
|
74
|
+
image
|
|
75
|
+
} = data;
|
|
183
76
|
if (image) {
|
|
184
77
|
if (image instanceof pixi_js.Texture) {
|
|
185
78
|
return image;
|
|
186
79
|
}
|
|
187
|
-
|
|
80
|
+
const texture = pixi_js.Texture.from(image);
|
|
188
81
|
return texture;
|
|
189
82
|
}
|
|
190
83
|
return data;
|
|
191
84
|
});
|
|
192
|
-
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE,
|
|
193
|
-
|
|
85
|
+
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE, ({
|
|
86
|
+
instance
|
|
87
|
+
}) => {
|
|
194
88
|
if (instance) {
|
|
195
89
|
instance.destroy(true);
|
|
196
90
|
}
|
|
197
91
|
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
_this.imgs = {};
|
|
204
|
-
return _this;
|
|
92
|
+
let Img = class Img extends pluginRenderer.Renderer {
|
|
93
|
+
constructor() {
|
|
94
|
+
super(...arguments);
|
|
95
|
+
this.name = 'Img';
|
|
96
|
+
this.imgs = {};
|
|
205
97
|
}
|
|
206
|
-
|
|
98
|
+
init() {
|
|
207
99
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
208
100
|
this.renderSystem.rendererManager.register(this);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
width
|
|
213
|
-
height
|
|
101
|
+
}
|
|
102
|
+
rendererUpdate(gameObject) {
|
|
103
|
+
const {
|
|
104
|
+
width,
|
|
105
|
+
height
|
|
106
|
+
} = gameObject.transform.size;
|
|
214
107
|
if (this.imgs[gameObject.id]) {
|
|
215
108
|
this.imgs[gameObject.id].sprite.width = width;
|
|
216
109
|
this.imgs[gameObject.id].sprite.height = height;
|
|
217
110
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
111
|
+
}
|
|
112
|
+
componentChanged(changed) {
|
|
220
113
|
var _a, _b;
|
|
221
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.increaseAsyncId(changed.gameObject.id);
|
|
257
|
-
sprite = this.imgs[changed.gameObject.id];
|
|
258
|
-
if (!sprite) return [2];
|
|
259
|
-
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
260
|
-
sprite.sprite.destroy({
|
|
261
|
-
children: true
|
|
262
|
-
});
|
|
263
|
-
delete this.imgs[changed.gameObject.id];
|
|
264
|
-
}
|
|
265
|
-
_c.label = 5;
|
|
266
|
-
case 5:
|
|
267
|
-
return [2];
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (changed.componentName === 'Img') {
|
|
116
|
+
const component = changed.component;
|
|
117
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
118
|
+
const sprite = new rendererAdapter.Sprite(null);
|
|
119
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
120
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
121
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
122
|
+
const {
|
|
123
|
+
instance
|
|
124
|
+
} = yield eva_js.resource.getResource(component.resource);
|
|
125
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return;
|
|
126
|
+
if (!instance) {
|
|
127
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
128
|
+
}
|
|
129
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
130
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
131
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
132
|
+
const {
|
|
133
|
+
instance
|
|
134
|
+
} = yield eva_js.resource.getResource(component.resource);
|
|
135
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId)) return;
|
|
136
|
+
if (!instance) {
|
|
137
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
138
|
+
}
|
|
139
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
140
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
141
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
142
|
+
const sprite = this.imgs[changed.gameObject.id];
|
|
143
|
+
if (!sprite) return;
|
|
144
|
+
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
145
|
+
sprite.sprite.destroy({
|
|
146
|
+
children: true
|
|
147
|
+
});
|
|
148
|
+
delete this.imgs[changed.gameObject.id];
|
|
268
149
|
}
|
|
269
|
-
}
|
|
150
|
+
}
|
|
270
151
|
});
|
|
271
|
-
}
|
|
272
|
-
|
|
152
|
+
}
|
|
153
|
+
destroy() {
|
|
273
154
|
var _a, _b;
|
|
274
|
-
for (
|
|
275
|
-
|
|
155
|
+
for (const key in this.imgs) {
|
|
156
|
+
const sprite = this.imgs[key];
|
|
276
157
|
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
277
158
|
sprite.sprite.destroy({
|
|
278
159
|
children: true
|
|
279
160
|
});
|
|
280
161
|
delete this.imgs[key];
|
|
281
162
|
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
}(pluginRenderer.Renderer);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
Img.systemName = 'Img';
|
|
166
|
+
Img = __decorate([eva_js.decorators.componentObserver({
|
|
167
|
+
Img: [{
|
|
168
|
+
prop: ['resource'],
|
|
169
|
+
deep: false
|
|
170
|
+
}]
|
|
171
|
+
})], Img);
|
|
292
172
|
var Img$1 = Img;
|
|
293
|
-
exports.Img = Img$
|
|
173
|
+
exports.Img = Img$2;
|
|
294
174
|
exports.ImgSystem = Img$1;
|
|
295
175
|
Object.defineProperty(exports, '__esModule', {
|
|
296
176
|
value: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_img=function(e,t,r,n,i){"use strict";
|
|
1
|
+
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_img=function(e,t,r,n,i){"use strict";function s(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{d(n.next(e))}catch(e){s(e)}}function c(e){try{d(n.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,c)}d((n=n.apply(e,t||[])).next())}))}class c extends t.Component{constructor(){super(...arguments),this.resource=""}init(e){e&&e.resource&&(this.resource=e.resource)}}c.componentName="Img",s([function(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}}("string")],c.prototype,"resource",void 0),t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(({data:e={}})=>{const{image:t}=e;if(t){if(t instanceof i.Texture)return t;return i.Texture.from(t)}return e})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(({instance:e})=>{e&&e.destroy(!0)}));let d=class extends r.Renderer{constructor(){super(...arguments),this.name="Img",this.imgs={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=t,this.imgs[e.id].sprite.height=r)}componentChanged(e){var r,i;return o(this,void 0,void 0,(function*(){if("Img"===e.componentName){const s=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const r=new n.Sprite(null);this.imgs[e.gameObject.id]=r,this.containerManager.getContainer(e.gameObject.id).addChildAt(r.sprite,0);const i=this.increaseAsyncId(e.gameObject.id),{instance:o}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(e.gameObject.id,i))return;o||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.imgs[e.gameObject.id].image=o}else if(e.type===t.OBSERVER_TYPE.CHANGE){const r=this.increaseAsyncId(e.gameObject.id),{instance:n}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(e.gameObject.id,r))return;n||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.imgs[e.gameObject.id].image=n}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(e.gameObject.id);const t=this.imgs[e.gameObject.id];if(!t)return;null===(i=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===i||i.removeChild(t.sprite),t.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}}}))}destroy(){var e,t;for(const r in this.imgs){const n=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(n.sprite),n.sprite.destroy({children:!0}),delete this.imgs[r]}}};d.systemName="Img",d=s([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],d);var a=d;return e.Img=c,e.ImgSystem=a,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);window.EVA.plugin.renderer.img=window.EVA.plugin.renderer.img||_EVA_IIFE_img;
|
|
@@ -22,20 +22,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
22
22
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
23
23
|
and limitations under the License.
|
|
24
24
|
***************************************************************************** */
|
|
25
|
-
/* global Reflect, Promise */
|
|
26
|
-
|
|
27
|
-
var extendStatics = function(d, b) {
|
|
28
|
-
extendStatics = Object.setPrototypeOf ||
|
|
29
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
30
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
31
|
-
return extendStatics(d, b);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function __extends(d, b) {
|
|
35
|
-
extendStatics(d, b);
|
|
36
|
-
function __() { this.constructor = d; }
|
|
37
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
38
|
-
}
|
|
39
25
|
|
|
40
26
|
function __decorate(decorators, target, key, desc) {
|
|
41
27
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -51,164 +37,114 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
51
37
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
52
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
39
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function __generator(thisArg, body) {
|
|
57
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
58
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
-
function step(op) {
|
|
61
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while (_) try {
|
|
63
|
-
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;
|
|
64
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
-
switch (op[0]) {
|
|
66
|
-
case 0: case 1: t = op; break;
|
|
67
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
-
default:
|
|
71
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
-
if (t[2]) _.ops.pop();
|
|
76
|
-
_.trys.pop(); continue;
|
|
77
|
-
}
|
|
78
|
-
op = body.call(thisArg, _);
|
|
79
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
-
}
|
|
82
40
|
}
|
|
83
41
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_this.resource = '';
|
|
89
|
-
return _this;
|
|
42
|
+
class Img$2 extends eva_js.Component {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(...arguments);
|
|
45
|
+
this.resource = '';
|
|
90
46
|
}
|
|
91
|
-
|
|
47
|
+
init(obj) {
|
|
92
48
|
if (obj && obj.resource) {
|
|
93
49
|
this.resource = obj.resource;
|
|
94
50
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}(eva_js.Component));
|
|
102
|
-
var Img$3 = Img$2;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
Img$2.componentName = 'Img';
|
|
54
|
+
__decorate([
|
|
55
|
+
inspectorDecorator.type('string')
|
|
56
|
+
], Img$2.prototype, "resource", void 0);
|
|
103
57
|
|
|
104
|
-
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.IMAGE,
|
|
105
|
-
|
|
106
|
-
var image = data.image;
|
|
58
|
+
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.IMAGE, ({ data = {} }) => {
|
|
59
|
+
const { image } = data;
|
|
107
60
|
if (image) {
|
|
108
61
|
if (image instanceof pixi_js.Texture) {
|
|
109
62
|
return image;
|
|
110
63
|
}
|
|
111
|
-
|
|
64
|
+
const texture = pixi_js.Texture.from(image);
|
|
112
65
|
return texture;
|
|
113
66
|
}
|
|
114
67
|
return data;
|
|
115
68
|
});
|
|
116
|
-
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE,
|
|
117
|
-
var instance = _a.instance;
|
|
69
|
+
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.IMAGE, ({ instance }) => {
|
|
118
70
|
if (instance) {
|
|
119
71
|
instance.destroy(true);
|
|
120
72
|
}
|
|
121
73
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
_this.imgs = {};
|
|
128
|
-
return _this;
|
|
74
|
+
let Img = class Img extends pluginRenderer.Renderer {
|
|
75
|
+
constructor() {
|
|
76
|
+
super(...arguments);
|
|
77
|
+
this.name = 'Img';
|
|
78
|
+
this.imgs = {};
|
|
129
79
|
}
|
|
130
|
-
|
|
80
|
+
init() {
|
|
131
81
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
132
82
|
this.renderSystem.rendererManager.register(this);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
83
|
+
}
|
|
84
|
+
rendererUpdate(gameObject) {
|
|
85
|
+
const { width, height } = gameObject.transform.size;
|
|
136
86
|
if (this.imgs[gameObject.id]) {
|
|
137
87
|
this.imgs[gameObject.id].sprite.width = width;
|
|
138
88
|
this.imgs[gameObject.id].sprite.height = height;
|
|
139
89
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
90
|
+
}
|
|
91
|
+
componentChanged(changed) {
|
|
142
92
|
var _a, _b;
|
|
143
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return [3, 5];
|
|
178
|
-
case 4:
|
|
179
|
-
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
180
|
-
this.increaseAsyncId(changed.gameObject.id);
|
|
181
|
-
sprite = this.imgs[changed.gameObject.id];
|
|
182
|
-
if (!sprite)
|
|
183
|
-
return [2];
|
|
184
|
-
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
185
|
-
sprite.sprite.destroy({ children: true });
|
|
186
|
-
delete this.imgs[changed.gameObject.id];
|
|
187
|
-
}
|
|
188
|
-
_c.label = 5;
|
|
189
|
-
case 5: return [2];
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
if (changed.componentName === 'Img') {
|
|
95
|
+
const component = changed.component;
|
|
96
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
97
|
+
const sprite = new rendererAdapter.Sprite(null);
|
|
98
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
99
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
100
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
101
|
+
const { instance } = yield eva_js.resource.getResource(component.resource);
|
|
102
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
103
|
+
return;
|
|
104
|
+
if (!instance) {
|
|
105
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
106
|
+
}
|
|
107
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
108
|
+
}
|
|
109
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
110
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
111
|
+
const { instance } = yield eva_js.resource.getResource(component.resource);
|
|
112
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
113
|
+
return;
|
|
114
|
+
if (!instance) {
|
|
115
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
116
|
+
}
|
|
117
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
118
|
+
}
|
|
119
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
120
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
121
|
+
const sprite = this.imgs[changed.gameObject.id];
|
|
122
|
+
if (!sprite)
|
|
123
|
+
return;
|
|
124
|
+
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
125
|
+
sprite.sprite.destroy({ children: true });
|
|
126
|
+
delete this.imgs[changed.gameObject.id];
|
|
190
127
|
}
|
|
191
|
-
}
|
|
128
|
+
}
|
|
192
129
|
});
|
|
193
|
-
}
|
|
194
|
-
|
|
130
|
+
}
|
|
131
|
+
destroy() {
|
|
195
132
|
var _a, _b;
|
|
196
|
-
for (
|
|
197
|
-
|
|
133
|
+
for (const key in this.imgs) {
|
|
134
|
+
const sprite = this.imgs[key];
|
|
198
135
|
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
199
136
|
sprite.sprite.destroy({ children: true });
|
|
200
137
|
delete this.imgs[key];
|
|
201
138
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}(pluginRenderer.Renderer));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
Img.systemName = 'Img';
|
|
142
|
+
Img = __decorate([
|
|
143
|
+
eva_js.decorators.componentObserver({
|
|
144
|
+
Img: [{ prop: ['resource'], deep: false }],
|
|
145
|
+
})
|
|
146
|
+
], Img);
|
|
211
147
|
var Img$1 = Img;
|
|
212
148
|
|
|
213
|
-
exports.Img = Img$
|
|
149
|
+
exports.Img = Img$2;
|
|
214
150
|
exports.ImgSystem = Img$1;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/inspector-decorator"),t=require("@eva/eva.js"),r=require("@eva/plugin-renderer"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/inspector-decorator"),t=require("@eva/eva.js"),r=require("@eva/plugin-renderer"),i=require("@eva/renderer-adapter"),s=require("pixi.js");
|
|
2
|
+
/*! *****************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
6
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
9
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
10
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
11
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
12
|
+
|
|
13
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
|
+
and limitations under the License.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
function n(e,t,r,i){var s,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(o=(n<3?s(o):n>3?s(t,r,o):s(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}class o extends t.Component{constructor(){super(...arguments),this.resource=""}init(e){e&&e.resource&&(this.resource=e.resource)}}o.componentName="Img",n([e.type("string")],o.prototype,"resource",void 0),t.resource.registerInstance(t.RESOURCE_TYPE.IMAGE,(({data:e={}})=>{const{image:t}=e;if(t){if(t instanceof s.Texture)return t;return s.Texture.from(t)}return e})),t.resource.registerDestroy(t.RESOURCE_TYPE.IMAGE,(({instance:e})=>{e&&e.destroy(!0)}));let c=class extends r.Renderer{constructor(){super(...arguments),this.name="Img",this.imgs={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.imgs[e.id]&&(this.imgs[e.id].sprite.width=t,this.imgs[e.id].sprite.height=r)}componentChanged(e){var r,s,n,o,c,a;return n=this,o=void 0,a=function*(){if("Img"===e.componentName){const n=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const r=new i.Sprite(null);this.imgs[e.gameObject.id]=r,this.containerManager.getContainer(e.gameObject.id).addChildAt(r.sprite,0);const s=this.increaseAsyncId(e.gameObject.id),{instance:o}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(e.gameObject.id,s))return;o||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.imgs[e.gameObject.id].image=o}else if(e.type===t.OBSERVER_TYPE.CHANGE){const r=this.increaseAsyncId(e.gameObject.id),{instance:i}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(e.gameObject.id,r))return;i||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.imgs[e.gameObject.id].image=i}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(e.gameObject.id);const t=this.imgs[e.gameObject.id];if(!t)return;null===(s=null===(r=this.containerManager)||void 0===r?void 0:r.getContainer(e.gameObject.id))||void 0===s||s.removeChild(t.sprite),t.sprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}}},new((c=void 0)||(c=Promise))((function(e,t){function r(e){try{s(a.next(e))}catch(e){t(e)}}function i(e){try{s(a.throw(e))}catch(e){t(e)}}function s(t){t.done?e(t.value):new c((function(e){e(t.value)})).then(r,i)}s((a=a.apply(n,o||[])).next())}))}destroy(){var e,t;for(const r in this.imgs){const i=this.imgs[r];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(parseInt(r)))||void 0===t||t.removeChild(i.sprite),i.sprite.destroy({children:!0}),delete this.imgs[r]}}};c.systemName="Img",c=n([t.decorators.componentObserver({Img:[{prop:["resource"],deep:!1}]})],c);var a=c;exports.Img=o,exports.ImgSystem=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type } from '@eva/inspector-decorator';
|
|
2
2
|
import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Renderer, RendererSystem } from '@eva/plugin-renderer';
|
|
4
4
|
import { Sprite } from '@eva/renderer-adapter';
|
|
5
5
|
import { Texture } from 'pixi.js';
|
|
6
6
|
|
|
@@ -18,20 +18,6 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
18
18
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
19
19
|
and limitations under the License.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
|
|
23
|
-
var extendStatics = function(d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
21
|
|
|
36
22
|
function __decorate(decorators, target, key, desc) {
|
|
37
23
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -47,163 +33,113 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
47
33
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
48
34
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
49
35
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function __generator(thisArg, body) {
|
|
53
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
54
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
55
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
56
|
-
function step(op) {
|
|
57
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
58
|
-
while (_) try {
|
|
59
|
-
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;
|
|
60
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
61
|
-
switch (op[0]) {
|
|
62
|
-
case 0: case 1: t = op; break;
|
|
63
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
64
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
65
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
66
|
-
default:
|
|
67
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
68
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
69
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
70
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
71
|
-
if (t[2]) _.ops.pop();
|
|
72
|
-
_.trys.pop(); continue;
|
|
73
|
-
}
|
|
74
|
-
op = body.call(thisArg, _);
|
|
75
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
76
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
77
|
-
}
|
|
78
36
|
}
|
|
79
37
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
_this.resource = '';
|
|
85
|
-
return _this;
|
|
38
|
+
class Img$2 extends Component {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.resource = '';
|
|
86
42
|
}
|
|
87
|
-
|
|
43
|
+
init(obj) {
|
|
88
44
|
if (obj && obj.resource) {
|
|
89
45
|
this.resource = obj.resource;
|
|
90
46
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}(Component));
|
|
98
|
-
var Img$3 = Img$2;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
Img$2.componentName = 'Img';
|
|
50
|
+
__decorate([
|
|
51
|
+
type('string')
|
|
52
|
+
], Img$2.prototype, "resource", void 0);
|
|
99
53
|
|
|
100
|
-
resource.registerInstance(RESOURCE_TYPE.IMAGE,
|
|
101
|
-
|
|
102
|
-
var image = data.image;
|
|
54
|
+
resource.registerInstance(RESOURCE_TYPE.IMAGE, ({ data = {} }) => {
|
|
55
|
+
const { image } = data;
|
|
103
56
|
if (image) {
|
|
104
57
|
if (image instanceof Texture) {
|
|
105
58
|
return image;
|
|
106
59
|
}
|
|
107
|
-
|
|
60
|
+
const texture = Texture.from(image);
|
|
108
61
|
return texture;
|
|
109
62
|
}
|
|
110
63
|
return data;
|
|
111
64
|
});
|
|
112
|
-
resource.registerDestroy(RESOURCE_TYPE.IMAGE,
|
|
113
|
-
var instance = _a.instance;
|
|
65
|
+
resource.registerDestroy(RESOURCE_TYPE.IMAGE, ({ instance }) => {
|
|
114
66
|
if (instance) {
|
|
115
67
|
instance.destroy(true);
|
|
116
68
|
}
|
|
117
69
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
_this.imgs = {};
|
|
124
|
-
return _this;
|
|
70
|
+
let Img = class Img extends Renderer {
|
|
71
|
+
constructor() {
|
|
72
|
+
super(...arguments);
|
|
73
|
+
this.name = 'Img';
|
|
74
|
+
this.imgs = {};
|
|
125
75
|
}
|
|
126
|
-
|
|
76
|
+
init() {
|
|
127
77
|
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
128
78
|
this.renderSystem.rendererManager.register(this);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
79
|
+
}
|
|
80
|
+
rendererUpdate(gameObject) {
|
|
81
|
+
const { width, height } = gameObject.transform.size;
|
|
132
82
|
if (this.imgs[gameObject.id]) {
|
|
133
83
|
this.imgs[gameObject.id].sprite.width = width;
|
|
134
84
|
this.imgs[gameObject.id].sprite.height = height;
|
|
135
85
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
86
|
+
}
|
|
87
|
+
componentChanged(changed) {
|
|
138
88
|
var _a, _b;
|
|
139
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return [3, 5];
|
|
174
|
-
case 4:
|
|
175
|
-
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
176
|
-
this.increaseAsyncId(changed.gameObject.id);
|
|
177
|
-
sprite = this.imgs[changed.gameObject.id];
|
|
178
|
-
if (!sprite)
|
|
179
|
-
return [2];
|
|
180
|
-
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
181
|
-
sprite.sprite.destroy({ children: true });
|
|
182
|
-
delete this.imgs[changed.gameObject.id];
|
|
183
|
-
}
|
|
184
|
-
_c.label = 5;
|
|
185
|
-
case 5: return [2];
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (changed.componentName === 'Img') {
|
|
91
|
+
const component = changed.component;
|
|
92
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
93
|
+
const sprite = new Sprite(null);
|
|
94
|
+
this.imgs[changed.gameObject.id] = sprite;
|
|
95
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
96
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
97
|
+
const { instance } = yield resource.getResource(component.resource);
|
|
98
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
99
|
+
return;
|
|
100
|
+
if (!instance) {
|
|
101
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
102
|
+
}
|
|
103
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
104
|
+
}
|
|
105
|
+
else if (changed.type === OBSERVER_TYPE.CHANGE) {
|
|
106
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
107
|
+
const { instance } = yield resource.getResource(component.resource);
|
|
108
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
109
|
+
return;
|
|
110
|
+
if (!instance) {
|
|
111
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
112
|
+
}
|
|
113
|
+
this.imgs[changed.gameObject.id].image = instance;
|
|
114
|
+
}
|
|
115
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
116
|
+
this.increaseAsyncId(changed.gameObject.id);
|
|
117
|
+
const sprite = this.imgs[changed.gameObject.id];
|
|
118
|
+
if (!sprite)
|
|
119
|
+
return;
|
|
120
|
+
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(changed.gameObject.id)) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
121
|
+
sprite.sprite.destroy({ children: true });
|
|
122
|
+
delete this.imgs[changed.gameObject.id];
|
|
186
123
|
}
|
|
187
|
-
}
|
|
124
|
+
}
|
|
188
125
|
});
|
|
189
|
-
}
|
|
190
|
-
|
|
126
|
+
}
|
|
127
|
+
destroy() {
|
|
191
128
|
var _a, _b;
|
|
192
|
-
for (
|
|
193
|
-
|
|
129
|
+
for (const key in this.imgs) {
|
|
130
|
+
const sprite = this.imgs[key];
|
|
194
131
|
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(parseInt(key))) === null || _b === void 0 ? void 0 : _b.removeChild(sprite.sprite);
|
|
195
132
|
sprite.sprite.destroy({ children: true });
|
|
196
133
|
delete this.imgs[key];
|
|
197
134
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}(Renderer));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
Img.systemName = 'Img';
|
|
138
|
+
Img = __decorate([
|
|
139
|
+
decorators.componentObserver({
|
|
140
|
+
Img: [{ prop: ['resource'], deep: false }],
|
|
141
|
+
})
|
|
142
|
+
], Img);
|
|
207
143
|
var Img$1 = Img;
|
|
208
144
|
|
|
209
|
-
export { Img$
|
|
145
|
+
export { Img$2 as Img, Img$1 as ImgSystem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-img",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-img",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-img.esm.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "2.0.0-beta.
|
|
23
|
-
"@eva/renderer-adapter": "2.0.0-beta.
|
|
24
|
-
"@eva/eva.js": "2.0.0-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.0-beta.2",
|
|
23
|
+
"@eva/renderer-adapter": "2.0.0-beta.2",
|
|
24
|
+
"@eva/eva.js": "2.0.0-beta.2",
|
|
25
25
|
"pixi.js": "^8.6.3"
|
|
26
26
|
}
|
|
27
27
|
}
|