@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.
@@ -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
- var TilingSprite$2 = function (_super) {
169
- __extends(TilingSprite, _super);
170
- function TilingSprite() {
171
- var _this = _super !== null && _super.apply(this, arguments) || this;
172
- _this.resource = '';
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
- _this.tilePosition = {
71
+ this.tilePosition = {
178
72
  x: 0,
179
73
  y: 0
180
74
  };
181
- return _this;
182
75
  }
183
- TilingSprite.prototype.init = function (obj) {
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
- TilingSprite.prototype.init = function () {
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
- TilingSprite.prototype.rendererUpdate = function (gameObject) {
210
- var _a = gameObject.transform.size,
211
- width = _a.width,
212
- height = _a.height;
213
- var img = this.imgs[gameObject.id];
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
- TilingSprite.prototype.componentChanged = function (changed) {
220
- return __awaiter(this, void 0, void 0, function () {
221
- var gameObjectId, component, sprite, asyncId, data, asyncId, data, sprite;
222
- return __generator(this, function (_a) {
223
- switch (_a.label) {
224
- case 0:
225
- gameObjectId = changed.gameObject.id;
226
- if (!(changed.componentName === 'TilingSprite')) return [3, 7];
227
- component = changed.component;
228
- if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
229
- sprite = new rendererAdapter.TilingSprite(null);
230
- this.imgs[changed.gameObject.id] = sprite;
231
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0);
232
- this.setProp(changed.gameObject.id, component);
233
- asyncId = this.increaseAsyncId(gameObjectId);
234
- return [4, eva_js.resource.getResource(component.resource)];
235
- case 1:
236
- data = _a.sent().data;
237
- if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
238
- if (!data) {
239
- console.error("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
240
- return [2];
241
- }
242
- sprite.image = data.image;
243
- return [3, 7];
244
- case 2:
245
- if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
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("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
254
- return [2];
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
- return [3, 5];
258
- case 4:
141
+ } else {
259
142
  this.setProp(changed.gameObject.id, component);
260
- _a.label = 5;
261
- case 5:
262
- return [3, 7];
263
- case 6:
264
- if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
265
- this.increaseAsyncId(gameObjectId);
266
- sprite = this.imgs[changed.gameObject.id];
267
- this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.tilingSprite);
268
- sprite.tilingSprite.destroy({
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
- TilingSprite.prototype.setProp = function (id, component) {
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
- TilingSprite = __decorate([eva_js.decorators.componentObserver({
285
- TilingSprite: [{
286
- prop: ['resource'],
287
- deep: false
288
- }, {
289
- prop: ['tileScale'],
290
- deep: true
291
- }, {
292
- prop: ['tilePosition'],
293
- deep: true
294
- }]
295
- })], TilingSprite);
296
- return TilingSprite;
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$3;
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,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 c(e,t,r,n){var i,o=arguments.length,c=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(c=(o<3?i(c):o>3?i(t,r,c):i(t,r))||c);return o>3&&c&&Object.defineProperty(t,r,c),c}function s(e,t,r,n){return new(r||(r=Promise))((function(i,o){function c(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(c,s)}a((n=n.apply(e,t||[])).next())}))}function a(e,t){var r,n,i,o,c={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(;c;)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 c.label++,{value:o[1],done:!1};case 5:c.label++,n=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){c.label=o[1];break}if(6===o[0]&&c.label<i[1]){c.label=i[1],i=o;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(o);break}i[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}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 l(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function p(e){return function(t,r){var n=l(t,r);n.key=r,n.type=e}}function u(e){return function(t,r){l(t,r).step=e}}var d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.tileScale={x:1,y:1},t.tilePosition={x:0,y:0},t}return o(t,e),t.prototype.init=function(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)},t.componentName="TilingSprite",c([p("string")],t.prototype,"resource",void 0),c([p("vector2"),u(.1)],t.prototype,"tileScale",void 0),c([p("vector2"),u(1)],t.prototype,"tilePosition",void 0),t}(t.Component),g=d,f=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="TilingSprite",t.imgs={},t}return o(i,e),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height,i=this.imgs[e.id];i&&(i.tilingSprite.width=r,i.tilingSprite.height=n)},i.prototype.componentChanged=function(e){return s(this,void 0,void 0,(function(){var r,i,o,c,s;return a(this,(function(a){switch(a.label){case 0:return r=e.gameObject.id,"TilingSprite"!==e.componentName?[3,7]:(i=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(s=new n.TilingSprite(null),this.imgs[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.tilingSprite,0),this.setProp(e.gameObject.id,i),o=this.increaseAsyncId(r),[4,t.resource.getResource(i.resource)]));case 1:return c=a.sent().data,this.validateAsyncId(r,o)?c?(s.image=c.image,[3,7]):(console.error("GameObject:"+e.gameObject.name+"'s TilingSprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,6]:"resource"!==e.prop.prop[0]?[3,4]:(o=this.increaseAsyncId(r),[4,t.resource.getResource(i.resource)]);case 3:return c=a.sent().data,this.validateAsyncId(r,o)?c?(this.imgs[e.gameObject.id].image=c.image,[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s TilingSprite resource load error"),[2]):[2];case 4:this.setProp(e.gameObject.id,i),a.label=5;case 5:return[3,7];case 6:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.imgs[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(s.tilingSprite),s.tilingSprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]),a.label=7;case 7:return[2]}}))}))},i.prototype.setProp=function(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale},i=c([t.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],i)}(r.Renderer),h=f;return e.TilingSprite=g,e.TilingSpriteSystem=h,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;
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
- var TilingSprite$2 = (function (_super) {
84
- __extends(TilingSprite, _super);
85
- function TilingSprite() {
86
- var _this = _super !== null && _super.apply(this, arguments) || this;
87
- _this.resource = '';
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
- _this.tilePosition = {
49
+ this.tilePosition = {
93
50
  x: 0,
94
51
  y: 0,
95
52
  };
96
- return _this;
97
53
  }
98
- TilingSprite.prototype.init = function (obj) {
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
- TilingSprite.componentName = 'TilingSprite';
106
- __decorate([
107
- inspectorDecorator.type('string')
108
- ], TilingSprite.prototype, "resource", void 0);
109
- __decorate([
110
- inspectorDecorator.type('vector2'),
111
- inspectorDecorator.step(0.1)
112
- ], TilingSprite.prototype, "tileScale", void 0);
113
- __decorate([
114
- inspectorDecorator.type('vector2'),
115
- inspectorDecorator.step(1)
116
- ], TilingSprite.prototype, "tilePosition", void 0);
117
- return TilingSprite;
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
- var TilingSprite = (function (_super) {
122
- __extends(TilingSprite, _super);
123
- function TilingSprite() {
124
- var _this = _super !== null && _super.apply(this, arguments) || this;
125
- _this.name = 'TilingSprite';
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
- TilingSprite.prototype.init = function () {
81
+ init() {
130
82
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
131
83
  this.renderSystem.rendererManager.register(this);
132
- };
133
- TilingSprite.prototype.rendererUpdate = function (gameObject) {
134
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
135
- var img = this.imgs[gameObject.id];
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
- TilingSprite.prototype.componentChanged = function (changed) {
142
- return __awaiter(this, void 0, void 0, function () {
143
- var gameObjectId, component, sprite, asyncId, data, asyncId, data, sprite;
144
- return __generator(this, function (_a) {
145
- switch (_a.label) {
146
- case 0:
147
- gameObjectId = changed.gameObject.id;
148
- if (!(changed.componentName === 'TilingSprite')) return [3, 7];
149
- component = changed.component;
150
- if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
151
- sprite = new rendererAdapter.TilingSprite(null);
152
- this.imgs[changed.gameObject.id] = sprite;
153
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0);
154
- this.setProp(changed.gameObject.id, component);
155
- asyncId = this.increaseAsyncId(gameObjectId);
156
- return [4, eva_js.resource.getResource(component.resource)];
157
- case 1:
158
- data = (_a.sent()).data;
159
- if (!this.validateAsyncId(gameObjectId, asyncId))
160
- return [2];
161
- if (!data) {
162
- console.error("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
163
- return [2];
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 [2];
118
+ return;
176
119
  if (!data) {
177
- console.error("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
178
- return [2];
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
- return [3, 5];
182
- case 4:
124
+ }
125
+ else {
183
126
  this.setProp(changed.gameObject.id, component);
184
- _a.label = 5;
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
- TilingSprite.prototype.setProp = function (id, component) {
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
- TilingSprite = __decorate([
207
- eva_js.decorators.componentObserver({
208
- TilingSprite: [
209
- { prop: ['resource'], deep: false },
210
- { prop: ['tileScale'], deep: true },
211
- { prop: ['tilePosition'], deep: true },
212
- ],
213
- })
214
- ], TilingSprite);
215
- return TilingSprite;
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$3;
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"),r=require("@eva/plugin-renderer"),i=require("@eva/renderer-adapter"),n=function(e,t){return n=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])},n(e,t)};function o(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(e,t,r,i){var n,o=arguments.length,c=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(c=(o<3?n(c):o>3?n(t,r,c):n(t,r))||c);return o>3&&c&&Object.defineProperty(t,r,c),c}function a(e,t){var r,i,n,o,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[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(;c;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,i=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(n=c.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){c.label=o[1];break}if(6===o[0]&&c.label<n[1]){c.label=n[1],n=o;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(o);break}n[2]&&c.ops.pop(),c.trys.pop();continue}o=t.call(e,c)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var s=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.tileScale={x:1,y:1},t.tilePosition={x:0,y:0},t}return o(r,e),r.prototype.init=function(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)},r.componentName="TilingSprite",c([t.type("string")],r.prototype,"resource",void 0),c([t.type("vector2"),t.step(.1)],r.prototype,"tileScale",void 0),c([t.type("vector2"),t.step(1)],r.prototype,"tilePosition",void 0),r}(e.Component),l=s,p=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="TilingSprite",e.imgs={},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,i=t.height,n=this.imgs[e.id];n&&(n.tilingSprite.width=r,n.tilingSprite.height=i)},n.prototype.componentChanged=function(t){return r=this,n=void 0,c=function(){var r,n,o,c,s;return a(this,(function(a){switch(a.label){case 0:return r=t.gameObject.id,"TilingSprite"!==t.componentName?[3,7]:(n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new i.TilingSprite(null),this.imgs[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.tilingSprite,0),this.setProp(t.gameObject.id,n),o=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return c=a.sent().data,this.validateAsyncId(r,o)?c?(s.image=c.image,[3,7]):(console.error("GameObject:"+t.gameObject.name+"'s TilingSprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,6]:"resource"!==t.prop.prop[0]?[3,4]:(o=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return c=a.sent().data,this.validateAsyncId(r,o)?c?(this.imgs[t.gameObject.id].image=c.image,[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s TilingSprite resource load error"),[2]):[2];case 4:this.setProp(t.gameObject.id,n),a.label=5;case 5:return[3,7];case 6:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.imgs[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.tilingSprite),s.tilingSprite.destroy({children:!0}),delete this.imgs[t.gameObject.id]),a.label=7;case 7:return[2]}}))},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{s(c.next(e))}catch(e){t(e)}}function a(e){try{s(c.throw(e))}catch(e){t(e)}}function s(t){t.done?e(t.value):new o((function(e){e(t.value)})).then(i,a)}s((c=c.apply(r,n||[])).next())}));var r,n,o,c},n.prototype.setProp=function(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale},n=c([e.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],n)}(r.Renderer);exports.TilingSprite=l,exports.TilingSpriteSystem=p;
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 { RendererSystem, Renderer } from '@eva/plugin-renderer';
4
- import { TilingSprite as TilingSprite$4 } from '@eva/renderer-adapter';
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
- var TilingSprite$2 = (function (_super) {
80
- __extends(TilingSprite, _super);
81
- function TilingSprite() {
82
- var _this = _super !== null && _super.apply(this, arguments) || this;
83
- _this.resource = '';
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
- _this.tilePosition = {
45
+ this.tilePosition = {
89
46
  x: 0,
90
47
  y: 0,
91
48
  };
92
- return _this;
93
49
  }
94
- TilingSprite.prototype.init = function (obj) {
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
- TilingSprite.componentName = 'TilingSprite';
102
- __decorate([
103
- type('string')
104
- ], TilingSprite.prototype, "resource", void 0);
105
- __decorate([
106
- type('vector2'),
107
- step(0.1)
108
- ], TilingSprite.prototype, "tileScale", void 0);
109
- __decorate([
110
- type('vector2'),
111
- step(1)
112
- ], TilingSprite.prototype, "tilePosition", void 0);
113
- return TilingSprite;
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
- var TilingSprite = (function (_super) {
118
- __extends(TilingSprite, _super);
119
- function TilingSprite() {
120
- var _this = _super !== null && _super.apply(this, arguments) || this;
121
- _this.name = 'TilingSprite';
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
- TilingSprite.prototype.init = function () {
77
+ init() {
126
78
  this.renderSystem = this.game.getSystem(RendererSystem);
127
79
  this.renderSystem.rendererManager.register(this);
128
- };
129
- TilingSprite.prototype.rendererUpdate = function (gameObject) {
130
- var _a = gameObject.transform.size, width = _a.width, height = _a.height;
131
- var img = this.imgs[gameObject.id];
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
- TilingSprite.prototype.componentChanged = function (changed) {
138
- return __awaiter(this, void 0, void 0, function () {
139
- var gameObjectId, component, sprite, asyncId, data, asyncId, data, sprite;
140
- return __generator(this, function (_a) {
141
- switch (_a.label) {
142
- case 0:
143
- gameObjectId = changed.gameObject.id;
144
- if (!(changed.componentName === 'TilingSprite')) return [3, 7];
145
- component = changed.component;
146
- if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
147
- sprite = new TilingSprite$4(null);
148
- this.imgs[changed.gameObject.id] = sprite;
149
- this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0);
150
- this.setProp(changed.gameObject.id, component);
151
- asyncId = this.increaseAsyncId(gameObjectId);
152
- return [4, resource.getResource(component.resource)];
153
- case 1:
154
- data = (_a.sent()).data;
155
- if (!this.validateAsyncId(gameObjectId, asyncId))
156
- return [2];
157
- if (!data) {
158
- console.error("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
159
- return [2];
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 [2];
114
+ return;
172
115
  if (!data) {
173
- console.error("GameObject:" + changed.gameObject.name + "'s TilingSprite resource load error");
174
- return [2];
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
- return [3, 5];
178
- case 4:
120
+ }
121
+ else {
179
122
  this.setProp(changed.gameObject.id, component);
180
- _a.label = 5;
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
- TilingSprite.prototype.setProp = function (id, component) {
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
- TilingSprite = __decorate([
203
- decorators.componentObserver({
204
- TilingSprite: [
205
- { prop: ['resource'], deep: false },
206
- { prop: ['tileScale'], deep: true },
207
- { prop: ['tilePosition'], deep: true },
208
- ],
209
- })
210
- ], TilingSprite);
211
- return TilingSprite;
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$3 as TilingSprite, TilingSprite$1 as TilingSpriteSystem };
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.1",
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.1",
23
- "@eva/renderer-adapter": "2.0.0-beta.1",
24
- "@eva/eva.js": "2.0.0-beta.1"
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
  }