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