@eva/plugin-renderer-sprite 2.0.1-beta.2 → 2.0.1-beta.20
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,3 +1,4 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
globalThis.EVA = globalThis.EVA || {};
|
|
2
3
|
globalThis.EVA.plugin = globalThis.EVA.plugin || {};
|
|
3
4
|
globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
|
|
@@ -110,6 +111,7 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
110
111
|
const texture = data.image instanceof pixi_js.Texture ? data.image : pixi_js.Texture.from(data.image);
|
|
111
112
|
const frames = textureObj.frames || {};
|
|
112
113
|
const animations = textureObj.animations || {};
|
|
114
|
+
const newAnimations = {};
|
|
113
115
|
const newFrames = {};
|
|
114
116
|
for (const key in frames) {
|
|
115
117
|
const newKey = name + resourceKeySplit + key;
|
|
@@ -123,10 +125,12 @@ var _EVA_IIFE_sprite = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
123
125
|
spriteList.push(newSpriteName);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
newAnimations[key] = spriteList;
|
|
127
129
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
const spriteSheet = new pixi_js.Spritesheet(texture, _extends(_extends({}, textureObj), {
|
|
131
|
+
frames: newFrames,
|
|
132
|
+
animations: newAnimations
|
|
133
|
+
}));
|
|
130
134
|
spriteSheet.parse().then(() => {
|
|
131
135
|
r(spriteSheet.textures);
|
|
132
136
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,s){"use strict";function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function n(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function c(e){try{a(s.throw(e))}catch(e){n(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(o,c)}a((s=s.apply(e,t||[])).next())}))}function o(e){return function(t,r){var s=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);s.key=r,s.type=e}}class c extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}c.componentName="Sprite",i([o("string")],c.prototype,"resource",void 0),i([o("string")],c.prototype,"spriteName",void 0);class a{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const p="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},c=i.animations||{},a={};for(const t in o){
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_sprite=function(e,t,r,s){"use strict";function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function n(e,t,r,s){return new(r||(r=Promise))((function(i,n){function o(e){try{a(s.next(e))}catch(e){n(e)}}function c(e){try{a(s.throw(e))}catch(e){n(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(o,c)}a((s=s.apply(e,t||[])).next())}))}function o(e){return function(t,r){var s=function(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}(t,r);s.key=r,s.type=e}}class c extends t.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}c.componentName="Sprite",i([o("string")],c.prototype,"resource",void 0),i([o("string")],c.prototype,"spriteName",void 0);class a{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const p="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},c=i.animations||{},a={},u={};for(const t in o){u[e+p+t]=o[t]}for(const t in c){const r=[];if(c[t]&&c[t].length>=0)for(const s of c[t]){const t=e+p+s;r.push(t)}a[t]=r}const d=new s.Spritesheet(n,_extends(_extends({},i),{frames:u,animations:a}));d.parse().then((()=>{r(d.textures)}))})))),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let u=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(e){return n(this,void 0,void 0,(function*(){if("Sprite"===e.componentName){const r=e.gameObject.id,s=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const i=new a(null);this.sprites[e.gameObject.id]=i,this.containerManager.getContainer(e.gameObject.id).addChildAt(i.sprite,0);const n=this.increaseAsyncId(r),{instance:o}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(r,n))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);i.image=o[s.resource+p+s.spriteName]}else if(e.type===t.OBSERVER_TYPE.CHANGE){const i=this.increaseAsyncId(r),{instance:n}=yield t.resource.getResource(s.resource);if(!this.validateAsyncId(r,i))return;if(!n)return void console.error(`GameObject:${e.gameObject.name}'s Sprite resource load error`);this.sprites[e.gameObject.id].image=n[s.resource+p+s.spriteName]}else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const t=this.sprites[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(t.sprite),t.sprite.destroy({children:!0}),delete this.sprites[e.gameObject.id]}}}))}};u.systemName="Sprite",u=i([t.decorators.componentObserver({Sprite:["spriteName"]})],u);var d=u;return e.Sprite=c,e.SpriteSystem=d,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.sprite=globalThis.EVA.plugin.renderer.sprite||_EVA_IIFE_sprite;
|
|
@@ -100,6 +100,7 @@ eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, ({ name, data }) =
|
|
|
100
100
|
const texture = data.image instanceof pixi_js.Texture ? data.image : pixi_js.Texture.from(data.image);
|
|
101
101
|
const frames = textureObj.frames || {};
|
|
102
102
|
const animations = textureObj.animations || {};
|
|
103
|
+
const newAnimations = {};
|
|
103
104
|
const newFrames = {};
|
|
104
105
|
for (const key in frames) {
|
|
105
106
|
const newKey = name + resourceKeySplit + key;
|
|
@@ -113,10 +114,9 @@ eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE, ({ name, data }) =
|
|
|
113
114
|
spriteList.push(newSpriteName);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
+
newAnimations[key] = spriteList;
|
|
117
118
|
}
|
|
118
|
-
textureObj
|
|
119
|
-
const spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
119
|
+
const spriteSheet = new pixi_js.Spritesheet(texture, Object.assign(Object.assign({}, textureObj), { frames: newFrames, animations: newAnimations }));
|
|
120
120
|
spriteSheet.parse().then(() => {
|
|
121
121
|
r(spriteSheet.textures);
|
|
122
122
|
});
|
|
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var
|
|
16
|
+
function i(e,t,r,s){var i,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n<3?i(o):n>3?i(t,r,o):i(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}class n extends e.Component{constructor(){super(...arguments),this.resource="",this.spriteName=""}init(e){e&&e.resource&&(this.resource=e.resource,this.spriteName=e.spriteName)}}n.componentName="Sprite",i([t.type("string")],n.prototype,"resource",void 0),i([t.type("string")],n.prototype,"spriteName",void 0);class o{constructor(e){this._image=null,this._image=e,e?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?this.sprite=s.Sprite.from(e):e instanceof s.Texture&&(this.sprite=new s.Sprite(e)):this.sprite=new s.Sprite}set image(e){this._image!==e&&("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(this.sprite.texture&&this.sprite.texture.destroy(!1),this.sprite.texture=s.Texture.from(e)):e instanceof s.Texture&&(this.sprite.texture=e),this._image=e)}get image(){return this._image}}const a="_s|r|c_";e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE,(({name:e,data:t})=>new Promise((r=>{const i=t.json.data,n=t.image instanceof s.Texture?t.image:s.Texture.from(t.image),o=i.frames||{},c=i.animations||{},p={},m={};for(const t in o){m[e+a+t]=o[t]}for(const t in c){const r=[];if(c[t]&&c[t].length>=0)for(const s of c[t]){const t=e+a+s;r.push(t)}p[t]=r}const d=new s.Spritesheet(n,Object.assign(Object.assign({},i),{frames:m,animations:p}));d.parse().then((()=>{r(d.textures)}))})))),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE,(({instance:e})=>{if(e)for(const t in e)e[t].destroy(!0)}));let c=class extends r.Renderer{constructor(){super(...arguments),this.name="Sprite",this.sprites={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:r}=e.transform.size;this.sprites[e.id]&&(this.sprites[e.id].sprite.width=t,this.sprites[e.id].sprite.height=r)}componentChanged(t){return r=this,s=void 0,n=function*(){if("Sprite"===t.componentName){const r=t.gameObject.id,s=t.component;if(t.type===e.OBSERVER_TYPE.ADD){const i=new o(null);this.sprites[t.gameObject.id]=i,this.containerManager.getContainer(t.gameObject.id).addChildAt(i.sprite,0);const n=this.increaseAsyncId(r),{instance:c}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,n))return;if(!c)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);i.image=c[s.resource+a+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.CHANGE){const i=this.increaseAsyncId(r),{instance:n}=yield e.resource.getResource(s.resource);if(!this.validateAsyncId(r,i))return;if(!n)return void console.error(`GameObject:${t.gameObject.name}'s Sprite resource load error`);this.sprites[t.gameObject.id].image=n[s.resource+a+s.spriteName]}else if(t.type===e.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(r);const e=this.sprites[t.gameObject.id];this.containerManager.getContainer(t.gameObject.id).removeChild(e.sprite),e.sprite.destroy({children:!0}),delete this.sprites[t.gameObject.id]}}},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{c(n.next(e))}catch(e){t(e)}}function a(e){try{c(n.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new i((function(e){e(t.value)})).then(o,a)}c((n=n.apply(r,s||[])).next())}));var r,s,i,n}};c.systemName="Sprite",c=i([e.decorators.componentObserver({Sprite:["spriteName"]})],c);var p=c;exports.Sprite=n,exports.SpriteSystem=p;
|
|
@@ -96,6 +96,7 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE, ({ name, data }) => {
|
|
|
96
96
|
const texture = data.image instanceof Texture ? data.image : Texture.from(data.image);
|
|
97
97
|
const frames = textureObj.frames || {};
|
|
98
98
|
const animations = textureObj.animations || {};
|
|
99
|
+
const newAnimations = {};
|
|
99
100
|
const newFrames = {};
|
|
100
101
|
for (const key in frames) {
|
|
101
102
|
const newKey = name + resourceKeySplit + key;
|
|
@@ -109,10 +110,9 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE, ({ name, data }) => {
|
|
|
109
110
|
spriteList.push(newSpriteName);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
newAnimations[key] = spriteList;
|
|
113
114
|
}
|
|
114
|
-
textureObj
|
|
115
|
-
const spriteSheet = new Spritesheet(texture, textureObj);
|
|
115
|
+
const spriteSheet = new Spritesheet(texture, Object.assign(Object.assign({}, textureObj), { frames: newFrames, animations: newAnimations }));
|
|
116
116
|
spriteSheet.parse().then(() => {
|
|
117
117
|
r(spriteSheet.textures);
|
|
118
118
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.20",
|
|
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": "2.0.1-beta.
|
|
23
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.1-beta.20",
|
|
23
|
+
"@eva/eva.js": "2.0.1-beta.20",
|
|
24
24
|
"pixi.js": "^8.8.1"
|
|
25
25
|
}
|
|
26
26
|
}
|