@eva/plugin-renderer-mask 2.1.0-beta.2 → 2.1.0-beta.4

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.
@@ -49,6 +49,10 @@ var _EVA_IIFE_mask = function (exports, eva_js, pluginRenderer, rendererAdapter)
49
49
  step((generator = generator.apply(thisArg, _arguments || [])).next());
50
50
  });
51
51
  }
52
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
53
+ var e = new Error(message);
54
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
55
+ };
52
56
  function __rest(s, e) {
53
57
  var t = {};
54
58
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}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_mask=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s<3?n(o):s>3?n(t,i,o):n(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function o(e,t,i,r){return new(i||(i=Promise))(function(n,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function l(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,l)}a((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class l extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const a="IDE_PROPERTY_METADATA";function d(e,t,i,r){let n=Reflect.getMetadata("design:type",e,t),s=n===Array;const o=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(n);if("unknown"!==o&&(n=o),r){const e=r();Array.isArray(e)?(s=!0,n=e[0]):n=e}const l=Reflect.getMetadata(a,e.constructor)||{},d=_extends(_extends(_extends({},l[t]||{}),{type:n,isArray:s}),i);l[t]=d,Reflect.defineMetadata(a,l,e.constructor);!function(e,t,i){const r=e.constructor,n=r.IDEProps||{};n[t]=_extends(_extends({key:t},n[t]),i),r.IDEProps=n}(e,t,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(d,["isArray"]))}function c(e){return t={type:e},(e,r)=>{if("symbol"==typeof r)throw new l;const{options:n,returnTypeFunc:s}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,i);d(e,r,n,s)};var t,i}var p,h;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(p||(p={})),e.MASK_TYPE=void 0,(h=e.MASK_TYPE||(e.MASK_TYPE={})).Circle="Circle",h.Ellipse="Ellipse",h.Rect="Rect",h.RoundedRect="RoundedRect",h.Polygon="Polygon",h.Img="Img",h.Sprite="Sprite";class u extends t.Component{constructor(t){super(t),this.type=e.MASK_TYPE.Rect,this.style={},this.x=0,this.y=0,this.resource="",this.spriteName="",this.enabled=!0,this.init(t)}init(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y,g,v,m,f,E,S,b,_;if(!e)return;const{style:w}=e;_extends(this,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(e,["style"])),this.style=_extends(_extends(_extends({},this.style),w),{x:null!==(n=null!==(i=null!==(t=e.x)&&void 0!==t?t:null==w?void 0:w.x)&&void 0!==i?i:null===(r=this.style)||void 0===r?void 0:r.x)&&void 0!==n?n:this.x,y:null!==(a=null!==(o=null!==(s=e.y)&&void 0!==s?s:null==w?void 0:w.y)&&void 0!==o?o:null===(l=this.style)||void 0===l?void 0:l.y)&&void 0!==a?a:this.y,radius:null!==(c=null!==(d=e.radius)&&void 0!==d?d:null==w?void 0:w.radius)&&void 0!==c?c:null===(p=this.style)||void 0===p?void 0:p.radius,width:null!==(u=null!==(h=e.width)&&void 0!==h?h:null==w?void 0:w.width)&&void 0!==u?u:null===(y=this.style)||void 0===y?void 0:y.width,height:null!==(v=null!==(g=e.height)&&void 0!==g?g:null==w?void 0:w.height)&&void 0!==v?v:null===(m=this.style)||void 0===m?void 0:m.height,paths:null!==(E=null!==(f=e.paths)&&void 0!==f?f:null==w?void 0:w.paths)&&void 0!==E?E:null===(S=this.style)||void 0===S?void 0:S.paths}),this.x=null!==(b=this.style.x)&&void 0!==b?b:0,this.y=null!==(_=this.style.y)&&void 0!==_?_:0,this.radius=this.style.radius,this.width=this.style.width,this.height=this.style.height,this.paths=this.style.paths}destroy(){return this}}u.componentName="Mask",n([c("number"),s("design:type",Number)],u.prototype,"x",void 0),n([c("number"),s("design:type",Number)],u.prototype,"y",void 0),n([c("number"),s("design:type",Number)],u.prototype,"radius",void 0),n([c("number"),s("design:type",Number)],u.prototype,"width",void 0),n([c("number"),s("design:type",Number)],u.prototype,"height",void 0),n([c("string"),s("design:type",String)],u.prototype,"resource",void 0),n([c("string"),s("design:type",String)],u.prototype,"spriteName",void 0),n([c("boolean"),s("design:type",Boolean)],u.prototype,"enabled",void 0);const y={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},g={Circle:"circle",Ellipse:"ellipse",Rect:"rect",RoundedRect:"roundRect",Polygon:"poly"},v={circle:e.MASK_TYPE.Circle,ellipse:e.MASK_TYPE.Ellipse,rect:e.MASK_TYPE.Rect,roundedrect:e.MASK_TYPE.RoundedRect,roundedRect:e.MASK_TYPE.RoundedRect,polygon:e.MASK_TYPE.Polygon,img:e.MASK_TYPE.Img,image:e.MASK_TYPE.Img,sprite:e.MASK_TYPE.Sprite};function m(t){if(t)return Object.values(e.MASK_TYPE).includes(t)?t:v[String(t)]||v[String(t).toLowerCase()]}let f=class extends i.Renderer{constructor(){super(...arguments),this.name="MaskSystem",this.changedCache={},this.maskSpriteCache={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(){this.changedCache={}}componentChanged(e){if("Mask"===e.component.name)switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}}add(t){const i=t.component;if(!1===i.enabled)return;const r=m(i.type);if(!r)throw new Error("no have Mask type: "+i.type);if(!i.style)throw new Error("no have Mask style: "+i.type);let n;switch(r){case e.MASK_TYPE.Circle:case e.MASK_TYPE.Ellipse:case e.MASK_TYPE.Rect:case e.MASK_TYPE.RoundedRect:case e.MASK_TYPE.Polygon:n=this.createGraphics(i);break;case e.MASK_TYPE.Img:case e.MASK_TYPE.Sprite:n=this.createSprite(i)}if(!n)throw new Error("no have mask instance, check your mask params: "+i.type);const s=this.containerManager.getContainer(t.gameObject.id);s.mask=n,s.addChild(n)}remove(e){const t=this.containerManager.getContainer(e.gameObject.id);(null==t?void 0:t.mask)&&(t.removeChild(t.mask),t.mask.destroy({children:!0}),t.mask=null,delete this.maskSpriteCache[e.gameObject.id])}change(t){if(this.changedCache[t.gameObject.id])return;const i=t.component;if("enabled"===t.prop.prop[0])return this.changedCache[t.gameObject.id]=!0,void(!1===i.enabled?this.remove(t):this.add(t));if("type"===t.prop.prop[0]){this.changedCache[t.gameObject.id]=!0;const r=m(i.type),n=m(i._lastType);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1||n!==r?(this.remove(t),this.add(t),i._lastType=i.type):this.redrawGraphics(t)}else if(["style","x","y","radius","width","height","paths"].indexOf(t.prop.prop[0])>-1){this.syncComponentStyle(i);const r=m(i.type);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1?this.changeSpriteStyle(i):this.redrawGraphics(t)}else("resource"===t.prop.prop[0]||"spriteName"===t.prop.prop[0])&&(this.changedCache[t.gameObject.id]=!0,this.changeSprite(i))}createGraphics(e){const t=new r.Graphics;return this.draw(t,e),t}redrawGraphics(e){const t=this.containerManager.getContainer(e.gameObject.id).mask;t.clear(),this.draw(t,e.component)}draw(e,t){const i=m(t.type),r=this.syncComponentStyle(t),n=[];for(const e of y[i])n.push(r[e]);e[g[i]](...n),e.fill(0)}createSprite(e){const t=new r.Sprite(null);return this.maskSpriteCache[e.gameObject.id]=t,this.setSprite(e,t),t.sprite}changeSpriteStyle(e){const t=this.maskSpriteCache[e.gameObject.id];t.sprite.width=e.style.width,t.sprite.height=e.style.height,t.sprite.position.x=e.style.x,t.sprite.position.y=e.style.y}changeSprite(e){const t=this.maskSpriteCache[e.gameObject.id];this.setSprite(e,t)}setSprite(i,r){var n,s;return o(this,void 0,void 0,function*(){const o=m(i.type);let l;try{const e=this.increaseAsyncId(i.gameObject.id);if(l=yield t.resource.getResource(i.resource),!this.validateAsyncId(i.gameObject.id,e))return}catch(e){throw new Error("mask resource load error")}if(o===e.MASK_TYPE.Sprite){const e=i.resource+"_s|r|c_"+i.spriteName,t=null===(n=null==l?void 0:l.instance)||void 0===n?void 0:n[e];t&&(r.image=t)}else(null===(s=null==l?void 0:l.data)||void 0===s?void 0:s.image)&&(r.image=l.data.image);r.sprite.width=i.style.width,r.sprite.height=i.style.height,r.sprite.position.x=i.style.x,r.sprite.position.y=i.style.y})}syncComponentStyle(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y;return e.style=_extends(_extends({},e.style),{x:null!==(r=null!==(t=e.x)&&void 0!==t?t:null===(i=e.style)||void 0===i?void 0:i.x)&&void 0!==r?r:0,y:null!==(o=null!==(n=e.y)&&void 0!==n?n:null===(s=e.style)||void 0===s?void 0:s.y)&&void 0!==o?o:0,radius:null!==(l=e.radius)&&void 0!==l?l:null===(a=e.style)||void 0===a?void 0:a.radius,width:null!==(d=e.width)&&void 0!==d?d:null===(c=e.style)||void 0===c?void 0:c.width,height:null!==(p=e.height)&&void 0!==p?p:null===(h=e.style)||void 0===h?void 0:h.height,paths:null!==(u=e.paths)&&void 0!==u?u:null===(y=e.style)||void 0===y?void 0:y.paths}),e.style}};f.systemName="MaskSystem",f=n([t.decorators.componentObserver({Mask:["type",{prop:["style"],deep:!0},"x","y","radius","width","height","paths","resource","spriteName","enabled"]})],f);var E=f;return e.Mask=u,e.MaskSystem=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.mask=globalThis.EVA.plugin.renderer.mask||_EVA_IIFE_mask;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}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_mask=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s<3?n(o):s>3?n(t,i,o):n(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function o(e,t,i,r){return new(i||(i=Promise))(function(n,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function l(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,l)}a((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError,"function"==typeof SuppressedError&&SuppressedError;class l extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const a="IDE_PROPERTY_METADATA";function d(e,t,i,r){let n=Reflect.getMetadata("design:type",e,t),s=n===Array;const o=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(n);if("unknown"!==o&&(n=o),r){const e=r();Array.isArray(e)?(s=!0,n=e[0]):n=e}const l=Reflect.getMetadata(a,e.constructor)||{},d=_extends(_extends(_extends({},l[t]||{}),{type:n,isArray:s}),i);l[t]=d,Reflect.defineMetadata(a,l,e.constructor);!function(e,t,i){const r=e.constructor,n=r.IDEProps||{};n[t]=_extends(_extends({key:t},n[t]),i),r.IDEProps=n}(e,t,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(d,["isArray"]))}function c(e){return t={type:e},(e,r)=>{if("symbol"==typeof r)throw new l;const{options:n,returnTypeFunc:s}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,i);d(e,r,n,s)};var t,i}var p,h;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(p||(p={})),e.MASK_TYPE=void 0,(h=e.MASK_TYPE||(e.MASK_TYPE={})).Circle="Circle",h.Ellipse="Ellipse",h.Rect="Rect",h.RoundedRect="RoundedRect",h.Polygon="Polygon",h.Img="Img",h.Sprite="Sprite";class u extends t.Component{constructor(t){super(t),this.type=e.MASK_TYPE.Rect,this.style={},this.x=0,this.y=0,this.resource="",this.spriteName="",this.enabled=!0,this.init(t)}init(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y,g,v,m,f,E,S,b,_;if(!e)return;const{style:w}=e;_extends(this,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(e,["style"])),this.style=_extends(_extends(_extends({},this.style),w),{x:null!==(n=null!==(i=null!==(t=e.x)&&void 0!==t?t:null==w?void 0:w.x)&&void 0!==i?i:null===(r=this.style)||void 0===r?void 0:r.x)&&void 0!==n?n:this.x,y:null!==(a=null!==(o=null!==(s=e.y)&&void 0!==s?s:null==w?void 0:w.y)&&void 0!==o?o:null===(l=this.style)||void 0===l?void 0:l.y)&&void 0!==a?a:this.y,radius:null!==(c=null!==(d=e.radius)&&void 0!==d?d:null==w?void 0:w.radius)&&void 0!==c?c:null===(p=this.style)||void 0===p?void 0:p.radius,width:null!==(u=null!==(h=e.width)&&void 0!==h?h:null==w?void 0:w.width)&&void 0!==u?u:null===(y=this.style)||void 0===y?void 0:y.width,height:null!==(v=null!==(g=e.height)&&void 0!==g?g:null==w?void 0:w.height)&&void 0!==v?v:null===(m=this.style)||void 0===m?void 0:m.height,paths:null!==(E=null!==(f=e.paths)&&void 0!==f?f:null==w?void 0:w.paths)&&void 0!==E?E:null===(S=this.style)||void 0===S?void 0:S.paths}),this.x=null!==(b=this.style.x)&&void 0!==b?b:0,this.y=null!==(_=this.style.y)&&void 0!==_?_:0,this.radius=this.style.radius,this.width=this.style.width,this.height=this.style.height,this.paths=this.style.paths}destroy(){return this}}u.componentName="Mask",n([c("number"),s("design:type",Number)],u.prototype,"x",void 0),n([c("number"),s("design:type",Number)],u.prototype,"y",void 0),n([c("number"),s("design:type",Number)],u.prototype,"radius",void 0),n([c("number"),s("design:type",Number)],u.prototype,"width",void 0),n([c("number"),s("design:type",Number)],u.prototype,"height",void 0),n([c("string"),s("design:type",String)],u.prototype,"resource",void 0),n([c("string"),s("design:type",String)],u.prototype,"spriteName",void 0),n([c("boolean"),s("design:type",Boolean)],u.prototype,"enabled",void 0);const y={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},g={Circle:"circle",Ellipse:"ellipse",Rect:"rect",RoundedRect:"roundRect",Polygon:"poly"},v={circle:e.MASK_TYPE.Circle,ellipse:e.MASK_TYPE.Ellipse,rect:e.MASK_TYPE.Rect,roundedrect:e.MASK_TYPE.RoundedRect,roundedRect:e.MASK_TYPE.RoundedRect,polygon:e.MASK_TYPE.Polygon,img:e.MASK_TYPE.Img,image:e.MASK_TYPE.Img,sprite:e.MASK_TYPE.Sprite};function m(t){if(t)return Object.values(e.MASK_TYPE).includes(t)?t:v[String(t)]||v[String(t).toLowerCase()]}let f=class extends i.Renderer{constructor(){super(...arguments),this.name="MaskSystem",this.changedCache={},this.maskSpriteCache={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(){this.changedCache={}}componentChanged(e){if("Mask"===e.component.name)switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}}add(t){const i=t.component;if(!1===i.enabled)return;const r=m(i.type);if(!r)throw new Error("no have Mask type: "+i.type);if(!i.style)throw new Error("no have Mask style: "+i.type);let n;switch(r){case e.MASK_TYPE.Circle:case e.MASK_TYPE.Ellipse:case e.MASK_TYPE.Rect:case e.MASK_TYPE.RoundedRect:case e.MASK_TYPE.Polygon:n=this.createGraphics(i);break;case e.MASK_TYPE.Img:case e.MASK_TYPE.Sprite:n=this.createSprite(i)}if(!n)throw new Error("no have mask instance, check your mask params: "+i.type);const s=this.containerManager.getContainer(t.gameObject.id);s.mask=n,s.addChild(n)}remove(e){const t=this.containerManager.getContainer(e.gameObject.id);(null==t?void 0:t.mask)&&(t.removeChild(t.mask),t.mask.destroy({children:!0}),t.mask=null,delete this.maskSpriteCache[e.gameObject.id])}change(t){if(this.changedCache[t.gameObject.id])return;const i=t.component;if("enabled"===t.prop.prop[0])return this.changedCache[t.gameObject.id]=!0,void(!1===i.enabled?this.remove(t):this.add(t));if("type"===t.prop.prop[0]){this.changedCache[t.gameObject.id]=!0;const r=m(i.type),n=m(i._lastType);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1||n!==r?(this.remove(t),this.add(t),i._lastType=i.type):this.redrawGraphics(t)}else if(["style","x","y","radius","width","height","paths"].indexOf(t.prop.prop[0])>-1){this.syncComponentStyle(i);const r=m(i.type);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1?this.changeSpriteStyle(i):this.redrawGraphics(t)}else("resource"===t.prop.prop[0]||"spriteName"===t.prop.prop[0])&&(this.changedCache[t.gameObject.id]=!0,this.changeSprite(i))}createGraphics(e){const t=new r.Graphics;return this.draw(t,e),t}redrawGraphics(e){const t=this.containerManager.getContainer(e.gameObject.id).mask;t.clear(),this.draw(t,e.component)}draw(e,t){const i=m(t.type),r=this.syncComponentStyle(t),n=[];for(const e of y[i])n.push(r[e]);e[g[i]](...n),e.fill(0)}createSprite(e){const t=new r.Sprite(null);return this.maskSpriteCache[e.gameObject.id]=t,this.setSprite(e,t),t.sprite}changeSpriteStyle(e){const t=this.maskSpriteCache[e.gameObject.id];t.sprite.width=e.style.width,t.sprite.height=e.style.height,t.sprite.position.x=e.style.x,t.sprite.position.y=e.style.y}changeSprite(e){const t=this.maskSpriteCache[e.gameObject.id];this.setSprite(e,t)}setSprite(i,r){var n,s;return o(this,void 0,void 0,function*(){const o=m(i.type);let l;try{const e=this.increaseAsyncId(i.gameObject.id);if(l=yield t.resource.getResource(i.resource),!this.validateAsyncId(i.gameObject.id,e))return}catch(e){throw new Error("mask resource load error")}if(o===e.MASK_TYPE.Sprite){const e=i.resource+"_s|r|c_"+i.spriteName,t=null===(n=null==l?void 0:l.instance)||void 0===n?void 0:n[e];t&&(r.image=t)}else(null===(s=null==l?void 0:l.data)||void 0===s?void 0:s.image)&&(r.image=l.data.image);r.sprite.width=i.style.width,r.sprite.height=i.style.height,r.sprite.position.x=i.style.x,r.sprite.position.y=i.style.y})}syncComponentStyle(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y;return e.style=_extends(_extends({},e.style),{x:null!==(r=null!==(t=e.x)&&void 0!==t?t:null===(i=e.style)||void 0===i?void 0:i.x)&&void 0!==r?r:0,y:null!==(o=null!==(n=e.y)&&void 0!==n?n:null===(s=e.style)||void 0===s?void 0:s.y)&&void 0!==o?o:0,radius:null!==(l=e.radius)&&void 0!==l?l:null===(a=e.style)||void 0===a?void 0:a.radius,width:null!==(d=e.width)&&void 0!==d?d:null===(c=e.style)||void 0===c?void 0:c.width,height:null!==(p=e.height)&&void 0!==p?p:null===(h=e.style)||void 0===h?void 0:h.height,paths:null!==(u=e.paths)&&void 0!==u?u:null===(y=e.style)||void 0===y?void 0:y.paths}),e.style}};f.systemName="MaskSystem",f=n([t.decorators.componentObserver({Mask:["type",{prop:["style"],deep:!0},"x","y","radius","width","height","paths","resource","spriteName","enabled"]})],f);var E=f;return e.Mask=u,e.MaskSystem=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.mask=globalThis.EVA.plugin.renderer.mask||_EVA_IIFE_mask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-mask",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.0-beta.4",
4
4
  "description": "@eva/plugin-renderer-mask",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-mask.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^2.0.0-beta.0",
22
- "@eva/plugin-renderer": "2.1.0-beta.2",
23
- "@eva/renderer-adapter": "2.1.0-beta.2",
24
- "@eva/eva.js": "2.1.0-beta.2",
22
+ "@eva/plugin-renderer": "2.1.0-beta.4",
23
+ "@eva/renderer-adapter": "2.1.0-beta.4",
24
+ "@eva/eva.js": "2.1.0-beta.4",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }