@eva/plugin-renderer-sprite 1.2.7-editor.8 → 1.2.7-editor.9

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.
@@ -5,8 +5,8 @@ window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
5
5
  var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
6
6
  'use strict';
7
7
 
8
- var _extendStatics$ = function extendStatics$1(d, b) {
9
- _extendStatics$ = Object.setPrototypeOf || {
8
+ var _extendStatics = function extendStatics(d, b) {
9
+ _extendStatics = Object.setPrototypeOf || {
10
10
  __proto__: []
11
11
  } instanceof Array && function (d, b) {
12
12
  d.__proto__ = b;
@@ -16,13 +16,13 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
16
16
  }
17
17
  };
18
18
 
19
- return _extendStatics$(d, b);
19
+ return _extendStatics(d, b);
20
20
  };
21
21
 
22
- function __extends$1(d, b) {
22
+ function __extends(d, b) {
23
23
  if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
24
24
 
25
- _extendStatics$(d, b);
25
+ _extendStatics(d, b);
26
26
 
27
27
  function __() {
28
28
  this.constructor = d;
@@ -222,7 +222,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
222
222
  }
223
223
 
224
224
  var SymbolKeysNotSupportedError = function (_super) {
225
- __extends$1(SymbolKeysNotSupportedError, _super);
225
+ __extends(SymbolKeysNotSupportedError, _super);
226
226
 
227
227
  function SymbolKeysNotSupportedError() {
228
228
  var _newTarget = this.constructor;
@@ -237,7 +237,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
237
237
  }(Error);
238
238
 
239
239
  (function (_super) {
240
- __extends$1(StaticGetPropertiesIsNotAFunctionError, _super);
240
+ __extends(StaticGetPropertiesIsNotAFunctionError, _super);
241
241
 
242
242
  function StaticGetPropertiesIsNotAFunctionError() {
243
243
  var _newTarget = this.constructor;
@@ -339,7 +339,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
339
339
  };
340
340
 
341
341
  var Sprite$3 = function (_super) {
342
- __extends$1(Sprite, _super);
342
+ __extends(Sprite, _super);
343
343
 
344
344
  function Sprite() {
345
345
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -405,85 +405,6 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
405
405
 
406
406
  var Sprite$4 = Sprite$3;
407
407
 
408
- var _extendStatics = function extendStatics(d, b) {
409
- _extendStatics = Object.setPrototypeOf || {
410
- __proto__: []
411
- } instanceof Array && function (d, b) {
412
- d.__proto__ = b;
413
- } || function (d, b) {
414
- for (var p in b) {
415
- if (b.hasOwnProperty(p)) d[p] = b[p];
416
- }
417
- };
418
-
419
- return _extendStatics(d, b);
420
- };
421
-
422
- function __extends(d, b) {
423
- _extendStatics(d, b);
424
-
425
- function __() {
426
- this.constructor = d;
427
- }
428
-
429
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
430
- }
431
-
432
- (function (_super) {
433
- __extends(Application, _super);
434
-
435
- function Application(params) {
436
- var _this = this;
437
-
438
- params.autoStart = false;
439
- _this = _super.call(this, params) || this;
440
- return _this;
441
- }
442
-
443
- return Application;
444
- })(pixi_js.Application);
445
-
446
- (function (_super) {
447
- __extends(Container, _super);
448
-
449
- function Container() {
450
- return _super !== null && _super.apply(this, arguments) || this;
451
- }
452
-
453
- return Container;
454
- })(pixi_js.Container);
455
-
456
- (function (_super) {
457
- __extends(Graphics, _super);
458
-
459
- function Graphics() {
460
- return _super !== null && _super.apply(this, arguments) || this;
461
- }
462
-
463
- return Graphics;
464
- })(pixi_js.Graphics);
465
-
466
- (function (_super) {
467
- __extends(NinePatch, _super);
468
-
469
- function NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight) {
470
- var _this = this;
471
-
472
- var texture;
473
-
474
- if (img === 'string') {
475
- texture = pixi_js.Texture.fromFrame(img);
476
- } else {
477
- texture = pixi_js.Texture.from(img);
478
- }
479
-
480
- _this = _super.call(this, texture, leftWidth, topHeight, rightWidth, bottomHeight) || this;
481
- return _this;
482
- }
483
-
484
- return NinePatch;
485
- })(pixi_js.mesh.NineSlicePlane);
486
-
487
408
  var Sprite$2 = function () {
488
409
  function Sprite(image) {
489
410
  this._image = null;
@@ -524,94 +445,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
524
445
  return Sprite;
525
446
  }();
526
447
 
527
- var Sprite$1$1 = Sprite$2;
528
-
529
- (function () {
530
- function SpriteAnimation(_a) {
531
- var frames = _a.frames;
532
- this.animatedSprite = new pixi_js.extras.AnimatedSprite(frames);
533
- }
534
-
535
- SpriteAnimation.prototype.play = function () {
536
- this.animatedSprite.play();
537
- };
538
-
539
- SpriteAnimation.prototype.stop = function () {
540
- this.animatedSprite.stop();
541
- };
542
-
543
- SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
544
- this.animatedSprite.gotoAndPlay(frameNumber);
545
- };
546
-
547
- SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
548
- this.animatedSprite.gotoAndStop(frameNumber);
549
- };
550
-
551
- Object.defineProperty(SpriteAnimation.prototype, "speed", {
552
- get: function get() {
553
- return this.animatedSprite.animationSpeed;
554
- },
555
- set: function set(val) {
556
- this.animatedSprite.animationSpeed = val;
557
- },
558
- enumerable: false,
559
- configurable: true
560
- });
561
- return SpriteAnimation;
562
- })();
563
-
564
- (function (_super) {
565
- __extends(Text, _super);
566
-
567
- function Text(text, style) {
568
- return _super.call(this, text, style) || this;
569
- }
570
-
571
- return Text;
572
- })(pixi_js.Text);
573
-
574
- var PIXITilingSprite = pixi_js.extras.TilingSprite;
575
-
576
- (function () {
577
- function TilingSprite(image) {
578
- this._image = null;
579
- this._image = image;
580
-
581
- if (image) {
582
- if (image instanceof HTMLImageElement) {
583
- this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.from(image));
584
- } else if (image instanceof pixi_js.Texture) {
585
- this.tilingSprite = new PIXITilingSprite(image);
586
- }
587
- } else {
588
- this.tilingSprite = new PIXITilingSprite(pixi_js.Texture.EMPTY);
589
- }
590
- }
591
-
592
- Object.defineProperty(TilingSprite.prototype, "image", {
593
- get: function get() {
594
- return this._image;
595
- },
596
- set: function set(val) {
597
- if (this._image === val) {
598
- return;
599
- }
600
-
601
- if (val instanceof HTMLImageElement) {
602
- this.tilingSprite.texture = pixi_js.Texture.from(val);
603
- } else if (val instanceof pixi_js.Texture) {
604
- this.tilingSprite.texture = val;
605
- }
606
-
607
- this._image = val;
608
- },
609
- enumerable: false,
610
- configurable: true
611
- });
612
- return TilingSprite;
613
- })();
614
-
448
+ var SpriteEngine = Sprite$2;
615
449
  var resourceKeySplit = '_s|r|c_';
616
450
  eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, function (_a) {
617
451
  var name = _a.name,
@@ -674,7 +508,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
674
508
  });
675
509
 
676
510
  var Sprite = function (_super) {
677
- __extends$1(Sprite, _super);
511
+ __extends(Sprite, _super);
678
512
 
679
513
  function Sprite() {
680
514
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -710,7 +544,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
710
544
  gameObjectId = changed.gameObject.id;
711
545
  component = changed.component;
712
546
  if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
713
- sprite = new Sprite$1$1(null);
547
+ sprite = new SpriteEngine(null);
714
548
  this.sprites[changed.gameObject.id] = sprite;
715
549
  this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
716
550
  asyncId = this.increaseAsyncId(gameObjectId);
@@ -1 +1 @@
1
- window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},i(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};function s(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var l=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return o(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}o(t,e)}(Error);var h,d="IDE_PROPERTY_METADATA";function y(e,t,r,n){var i=Reflect.getMetadata("design:type",e,t),o=i===Array,s=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(i);if("unknown"!==s&&(i=s),n){var c=n();Array.isArray(c)?(o=!0,i=c[0]):i=c}var u=Reflect.getMetadata(d,e.constructor)||{};u[t]=a({type:i,isArray:o},r),Reflect.defineMetadata(d,u,e.constructor)}function m(e,t){return function(r,n){if("symbol"==typeof n)throw new l;var i=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);y(r,n,i.options,i.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(h||(h={}));var g=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([m({type:"resource"}),c("design:type",String)],r.prototype,"resource",void 0),s([m({type:"selector",options:function(e){var r,n,i;return u(this,void 0,void 0,(function(){var o;return p(this,(function(s){switch(s.label){case 0:return[4,(c=0,new Promise((function(e){return setTimeout(e,c)})))];case 1:return s.sent(),e.resource&&t.resource.promiseMap[e.resource]?[4,t.resource.promiseMap[e.resource]]:[2,{}];case 2:return s.sent(),[2,(o=null===(i=null===(n=null===(r=t.resource.resourcesMap[e.resource])||void 0===r?void 0:r.data)||void 0===n?void 0:n.json)||void 0===i?void 0:i.frames)?Object.values(o).map((function(e){return e.name})).reduce((function(e,t){var r;return a(a({},e),((r={})[t]=t,r))}),{}):{}]}var c}))}))}}),c("design:type",String)],r.prototype,"spriteName",void 0),r}(t.Component),v=g,b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},b(e,t)};function w(e,t){function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}!function(e){function t(t){return t.autoStart=!1,e.call(this,t)||this}w(t,e)}(n.Application),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}w(t,e)}(n.Container),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}w(t,e)}(n.Graphics),function(e){function t(t,r,i,o,a){var s;return s="string"===t?n.Texture.fromFrame(t):n.Texture.from(t),e.call(this,s,r,i,o,a)||this}w(t,e)}(n.mesh.NineSlicePlane);var S=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),E=S;!function(){function e(e){var t=e.frames;this.animatedSprite=new n.extras.AnimatedSprite(t)}e.prototype.play=function(){this.animatedSprite.play()},e.prototype.stop=function(){this.animatedSprite.stop()},e.prototype.gotoAndPlay=function(e){this.animatedSprite.gotoAndPlay(e)},e.prototype.gotoAndStop=function(e){this.animatedSprite.gotoAndStop(e)},Object.defineProperty(e.prototype,"speed",{get:function(){return this.animatedSprite.animationSpeed},set:function(e){this.animatedSprite.animationSpeed=e},enumerable:!1,configurable:!0})}(),function(e){function t(t,r){return e.call(this,t,r)||this}w(t,e)}(n.Text);var O=n.extras.TilingSprite;!function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.tilingSprite=new O(n.Texture.from(e)):e instanceof n.Texture&&(this.tilingSprite=new O(e)):this.tilingSprite=new O(n.Texture.EMPTY)}Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?this.tilingSprite.texture=n.Texture.from(e):e instanceof n.Texture&&(this.tilingSprite.texture=e),this._image=e)},enumerable:!1,configurable:!0})}();var _="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,a=r.json,s=n.BaseTexture.from(r.image),c=a.frames||{},u=a.animations||{},p={};for(var l in c){p[t+_+l]=c[l]}for(var l in u){var h=[];if(u[l]&&u[l].length>=0)try{for(var d=(i=void 0,f(u[l])),y=d.next();!y.done;y=d.next()){var m=y.value,g=t+_+m;h.push(g)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}u[l]=h}a.frames=p;var v=new n.Spritesheet(s,a);v.parse((function(){var t=v.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var A=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return u(this,void 0,void 0,(function(){var r,n,i,o,a;return p(this,(function(s){switch(s.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(a=new E(null),this.sprites[e.gameObject.id]=a,this.containerManager.getContainer(e.gameObject.id).addChildAt(a.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(a.image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=s.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+_+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),a=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(a.sprite),a.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),s.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),T=A;return e.Sprite=v,e.SpriteSystem=T,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
1
+ window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function a(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var f=function(e){function t(){var t=this.constructor,r=e.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(r,t.prototype),r}return i(t,e),t}(Error);!function(e){function t(){var t=this.constructor,r=e.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(r,t.prototype),r}i(t,e)}(Error);var d,y="IDE_PROPERTY_METADATA";function h(e,t,r,n){var o=Reflect.getMetadata("design:type",e,t),i=o===Array,a=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(o);if("unknown"!==a&&(o=a),n){var c=n();Array.isArray(c)?(i=!0,o=c[0]):o=c}var u=Reflect.getMetadata(y,e.constructor)||{};u[t]=s({type:o,isArray:i},r),Reflect.defineMetadata(y,u,e.constructor)}function m(e,t){return function(r,n){if("symbol"==typeof n)throw new f;var o=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);h(r,n,o.options,o.returnTypeFunc)}}!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(d||(d={}));var v=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return i(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",a([m({type:"resource"}),c("design:type",String)],r.prototype,"resource",void 0),a([m({type:"selector",options:function(e){var r,n,o;return u(this,void 0,void 0,(function(){var i;return p(this,(function(a){switch(a.label){case 0:return[4,(c=0,new Promise((function(e){return setTimeout(e,c)})))];case 1:return a.sent(),e.resource&&t.resource.promiseMap[e.resource]?[4,t.resource.promiseMap[e.resource]]:[2,{}];case 2:return a.sent(),[2,(i=null===(o=null===(n=null===(r=t.resource.resourcesMap[e.resource])||void 0===r?void 0:r.data)||void 0===n?void 0:n.json)||void 0===o?void 0:o.frames)?Object.values(i).map((function(e){return e.name})).reduce((function(e,t){var r;return s(s({},e),((r={})[t]=t,r))}),{}):{}]}var c}))}))}}),c("design:type",String)],r.prototype,"spriteName",void 0),r}(t.Component),g=v,b=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),w=b,E="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var o,i,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},u=s.animations||{},p={};for(var f in c){p[t+E+f]=c[f]}for(var f in u){var d=[];if(u[f]&&u[f].length>=0)try{for(var y=(o=void 0,l(u[f])),h=y.next();!h.done;h=y.next()){var m=h.value,v=t+E+m;d.push(v)}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=y.return)&&i.call(y)}finally{if(o)throw o.error}}u[f]=d}s.frames=p;var g=new n.Spritesheet(a,s);g.parse((function(){var t=g.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var O=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return i(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return u(this,void 0,void 0,(function(){var r,n,o,i,s;return p(this,(function(a){switch(a.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(s=new w(null),this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),o=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return i=a.sent().instance,this.validateAsyncId(r,o)?i?(s.image=i[n.resource+E+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(o=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return i=a.sent().instance,this.validateAsyncId(r,o)?i?(this.sprites[e.gameObject.id].image=i[n.resource+E+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),a.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=a([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),S=O;return e.Sprite=g,e.SpriteSystem=S,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-sprite",
3
- "version": "1.2.7-editor.8",
3
+ "version": "1.2.7-editor.9",
4
4
  "description": "@eva/plugin-renderer-sprite",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-sprite.esm.js",
@@ -19,8 +19,8 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "0.1.0-alpha.2",
22
- "@eva/plugin-renderer": "1.2.7-editor.8",
23
- "@eva/eva.js": "1.2.7-editor.8",
22
+ "@eva/plugin-renderer": "1.2.7-editor.9",
23
+ "@eva/eva.js": "1.2.7-editor.9",
24
24
  "pixi.js": "^4.8.7"
25
25
  }
26
26
  }