@eva/plugin-renderer-sprite 1.2.8-fix.1 → 1.2.8
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.
|
@@ -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
|
|
1
|
+
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,n){"use strict";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(e){return function(t,r){var n=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);n.key=r,n.type=e}}var l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(t,e),t.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},t.componentName="Sprite",s([p("string")],t.prototype,"resource",void 0),s([p("string")],t.prototype,"spriteName",void 0),t}(t.Component),f=l,d=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),h=d,m="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),c=s.frames||{},p=s.animations||{},l={};for(var f in c){l[t+m+f]=c[f]}for(var f in p){var d=[];if(p[f]&&p[f].length>=0)try{for(var h=(i=void 0,u(p[f])),y=h.next();!y.done;y=h.next()){var g=y.value,v=t+m+g;d.push(v)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}p[f]=d}s.frames=l;var b=new n.Spritesheet(a,s);b.parse((function(){var t=b.textures;e(t)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var y=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Sprite",t.sprites={},t}return o(n,e),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(e){return a(this,void 0,void 0,(function(){var r,n,i,o,s;return c(this,(function(a){switch(a.label){case 0:return"Sprite"!==e.componentName?[3,5]:(r=e.gameObject.id,n=e.component,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(s=new h(null),this.sprites[e.gameObject.id]=s,this.containerManager.getContainer(e.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+m+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,t.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[e.gameObject.id].image=o[n.resource+m+n.spriteName],[3,5]):(console.error("GameObject:"+e.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[e.gameObject.id],this.containerManager.getContainer(e.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]),a.label=5;case 5:return[2]}}))}))},n.systemName="Sprite",n=s([t.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer),g=y;return e.Sprite=f,e.SpriteSystem=g,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);window.EVA.plugin.renderer.sprite=window.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
|
|
2
|
+
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
3
|
+
import { type } from '@eva/inspector-decorator';
|
|
4
|
+
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
|
+
import { Sprite as Sprite$4 } from '@eva/renderer-adapter/dist/miniprogram';
|
|
6
|
+
import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
|
|
7
|
+
|
|
8
|
+
var Sprite$2 = function (_super) {
|
|
9
|
+
__extends(Sprite, _super);
|
|
10
|
+
|
|
11
|
+
function Sprite() {
|
|
12
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
13
|
+
|
|
14
|
+
_this.resource = '';
|
|
15
|
+
_this.spriteName = '';
|
|
16
|
+
return _this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Sprite.prototype.init = function (obj) {
|
|
20
|
+
if (obj && obj.resource) {
|
|
21
|
+
this.resource = obj.resource;
|
|
22
|
+
this.spriteName = obj.spriteName;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Sprite.componentName = 'Sprite';
|
|
27
|
+
|
|
28
|
+
__decorate([type('string')], Sprite.prototype, "resource", void 0);
|
|
29
|
+
|
|
30
|
+
__decorate([type('string')], Sprite.prototype, "spriteName", void 0);
|
|
31
|
+
|
|
32
|
+
return Sprite;
|
|
33
|
+
}(Component);
|
|
34
|
+
|
|
35
|
+
var Sprite$3 = Sprite$2;
|
|
36
|
+
var resourceKeySplit = '_s|r|c_';
|
|
37
|
+
resource.registerInstance(RESOURCE_TYPE.SPRITE, function (_a) {
|
|
38
|
+
var name = _a.name,
|
|
39
|
+
data = _a.data;
|
|
40
|
+
return new Promise(function (r) {
|
|
41
|
+
var e_1, _a;
|
|
42
|
+
|
|
43
|
+
var textureObj = data.json;
|
|
44
|
+
var texture = BaseTexture.from(data.image);
|
|
45
|
+
var frames = textureObj.frames || {};
|
|
46
|
+
var animations = textureObj.animations || {};
|
|
47
|
+
var newFrames = {};
|
|
48
|
+
|
|
49
|
+
for (var key in frames) {
|
|
50
|
+
var newKey = name + resourceKeySplit + key;
|
|
51
|
+
newFrames[newKey] = frames[key];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (var key in animations) {
|
|
55
|
+
var spriteList = [];
|
|
56
|
+
|
|
57
|
+
if (animations[key] && animations[key].length >= 0) {
|
|
58
|
+
try {
|
|
59
|
+
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
60
|
+
var spriteName = _c.value;
|
|
61
|
+
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
62
|
+
spriteList.push(newSpriteName);
|
|
63
|
+
}
|
|
64
|
+
} catch (e_1_1) {
|
|
65
|
+
e_1 = {
|
|
66
|
+
error: e_1_1
|
|
67
|
+
};
|
|
68
|
+
} finally {
|
|
69
|
+
try {
|
|
70
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
71
|
+
} finally {
|
|
72
|
+
if (e_1) throw e_1.error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
animations[key] = spriteList;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
textureObj.frames = newFrames;
|
|
81
|
+
var spriteSheet = new Spritesheet(texture, textureObj);
|
|
82
|
+
spriteSheet.parse(function () {
|
|
83
|
+
var textures = spriteSheet.textures;
|
|
84
|
+
r(textures);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
resource.registerDestroy(RESOURCE_TYPE.SPRITE, function (_a) {
|
|
89
|
+
var instance = _a.instance;
|
|
90
|
+
if (!instance) return;
|
|
91
|
+
|
|
92
|
+
for (var key in instance) {
|
|
93
|
+
instance[key].destroy(true);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
var Sprite = function (_super) {
|
|
98
|
+
__extends(Sprite, _super);
|
|
99
|
+
|
|
100
|
+
function Sprite() {
|
|
101
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
102
|
+
|
|
103
|
+
_this.name = 'Sprite';
|
|
104
|
+
_this.sprites = {};
|
|
105
|
+
return _this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Sprite.prototype.init = function () {
|
|
109
|
+
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
110
|
+
this.renderSystem.rendererManager.register(this);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Sprite.prototype.rendererUpdate = function (gameObject) {
|
|
114
|
+
var _a = gameObject.transform.size,
|
|
115
|
+
width = _a.width,
|
|
116
|
+
height = _a.height;
|
|
117
|
+
|
|
118
|
+
if (this.sprites[gameObject.id]) {
|
|
119
|
+
this.sprites[gameObject.id].sprite.width = width;
|
|
120
|
+
this.sprites[gameObject.id].sprite.height = height;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
Sprite.prototype.componentChanged = function (changed) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var gameObjectId, component, sprite, asyncId, instance, asyncId, instance, sprite;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
if (!(changed.componentName === 'Sprite')) return [3, 5];
|
|
131
|
+
gameObjectId = changed.gameObject.id;
|
|
132
|
+
component = changed.component;
|
|
133
|
+
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
134
|
+
sprite = new Sprite$4(null);
|
|
135
|
+
this.sprites[changed.gameObject.id] = sprite;
|
|
136
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.sprite, 0);
|
|
137
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
138
|
+
return [4, resource.getResource(component.resource)];
|
|
139
|
+
|
|
140
|
+
case 1:
|
|
141
|
+
instance = _a.sent().instance;
|
|
142
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
143
|
+
|
|
144
|
+
if (!instance) {
|
|
145
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
146
|
+
return [2];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
sprite.image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
150
|
+
return [3, 5];
|
|
151
|
+
|
|
152
|
+
case 2:
|
|
153
|
+
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 4];
|
|
154
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
155
|
+
return [4, resource.getResource(component.resource)];
|
|
156
|
+
|
|
157
|
+
case 3:
|
|
158
|
+
instance = _a.sent().instance;
|
|
159
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
160
|
+
|
|
161
|
+
if (!instance) {
|
|
162
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Sprite resource load error");
|
|
163
|
+
return [2];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.sprites[changed.gameObject.id].image = instance[component.resource + resourceKeySplit + component.spriteName];
|
|
167
|
+
return [3, 5];
|
|
168
|
+
|
|
169
|
+
case 4:
|
|
170
|
+
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
171
|
+
this.increaseAsyncId(gameObjectId);
|
|
172
|
+
sprite = this.sprites[changed.gameObject.id];
|
|
173
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.sprite);
|
|
174
|
+
sprite.sprite.destroy({
|
|
175
|
+
children: true
|
|
176
|
+
});
|
|
177
|
+
delete this.sprites[changed.gameObject.id];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
_a.label = 5;
|
|
181
|
+
|
|
182
|
+
case 5:
|
|
183
|
+
return [2];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
Sprite.systemName = 'Sprite';
|
|
190
|
+
Sprite = __decorate([decorators.componentObserver({
|
|
191
|
+
Sprite: ['spriteName']
|
|
192
|
+
})], Sprite);
|
|
193
|
+
return Sprite;
|
|
194
|
+
}(Renderer);
|
|
195
|
+
|
|
196
|
+
var Sprite$1 = Sprite;
|
|
197
|
+
export { Sprite$3 as Sprite, Sprite$1 as SpriteSystem };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function a(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function c(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var u=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t}return o(r,e),r.prototype.init=function(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)},r.componentName="Sprite",s([t.type("string")],r.prototype,"resource",void 0),s([t.type("string")],r.prototype,"spriteName",void 0),r}(e.Component),p=u,l=function(){function e(e){this._image=null,this._image=e,e?e instanceof HTMLImageElement?this.sprite=n.Sprite.from(e):e instanceof n.Texture&&(this.sprite=new n.Sprite(e)):this.sprite=new n.Sprite}return Object.defineProperty(e.prototype,"image",{get:function(){return this._image},set:function(e){this._image!==e&&(e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=n.Texture.from(e)):e instanceof n.Texture&&(this.sprite.texture=e),this._image=e)},enumerable:!1,configurable:!0}),e}(),f=l;e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var i,o,s=r.json,a=n.BaseTexture.from(r.image),u=s.frames||{},p=s.animations||{},l={};for(var f in u){l[t+"_s|r|c_"+f]=u[f]}for(var f in p){var h=[];if(p[f]&&p[f].length>=0)try{for(var m=(i=void 0,c(p[f])),d=m.next();!d.done;d=m.next()){var y=d.value,g=t+"_s|r|c_"+y;h.push(g)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}p[f]=h}s.frames=l;var v=new n.Spritesheet(a,s);v.parse((function(){var t=v.textures;e(t)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(function(e){var t=e.instance;if(t)for(var r in t)t[r].destroy(!0)}));var h=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Sprite",e.sprites={},e}return o(n,t),n.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},n.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=r,this.sprites[e.id].sprite.height=n)},n.prototype.componentChanged=function(t){return r=this,n=void 0,o=function(){var r,n,i,o,s;return a(this,(function(a){switch(a.label){case 0:return"Sprite"!==t.componentName?[3,5]:(r=t.gameObject.id,n=t.component,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(s=new f(null),this.sprites[t.gameObject.id]=s,this.containerManager.getContainer(t.gameObject.id).addChildAt(s.sprite,0),i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(s.image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,4]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]);case 3:return o=a.sent().instance,this.validateAsyncId(r,i)?o?(this.sprites[t.gameObject.id].image=o[n.resource+"_s|r|c_"+n.spriteName],[3,5]):(console.error("GameObject:"+t.gameObject.name+"'s Sprite resource load error"),[2]):[2];case 4:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),s=this.sprites[t.gameObject.id],this.containerManager.getContainer(t.gameObject.id).removeChild(s.sprite),s.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]),a.label=5;case 5:return[2]}}))},new((i=void 0)||(i=Promise))((function(e,t){function s(e){try{c(o.next(e))}catch(e){t(e)}}function a(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(s,a)}c((o=o.apply(r,n||[])).next())}));var r,n,i,o},n.systemName="Sprite",n=s([e.decorators.componentObserver({Sprite:["spriteName"]})],n)}(r.Renderer);exports.Sprite=p,exports.SpriteSystem=h;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
|
|
2
2
|
import { type } from '@eva/inspector-decorator';
|
|
3
3
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer';
|
|
4
|
-
import {
|
|
4
|
+
import { Sprite as Sprite$5, Texture, BaseTexture, Spritesheet } from 'pixi.js';
|
|
5
5
|
|
|
6
6
|
/*! *****************************************************************************
|
|
7
7
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite",
|
|
3
|
-
"version": "1.2.8
|
|
3
|
+
"version": "1.2.8",
|
|
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.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "1.2.8
|
|
23
|
-
"@eva/eva.js": "1.2.8
|
|
22
|
+
"@eva/plugin-renderer": "1.2.8",
|
|
23
|
+
"@eva/eva.js": "1.2.8",
|
|
24
24
|
"pixi.js": "^4.8.7"
|
|
25
25
|
}
|
|
26
26
|
}
|