@eva/plugin-renderer 2.1.0-beta.3 → 2.1.0-beta.5

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.
@@ -0,0 +1 @@
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{};var _EVA_IIFE_renderer=function(e,t,n,r){"use strict";function o(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function i(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})}function a(e,t){return e===t||e!=e&&t!=t}function s(e,t){for(var n=e.length;n--;)if(a(e[n][0],t))return n;return-1}var c=Array.prototype.splice;function l(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}l.prototype.clear=function(){this.__data__=[],this.size=0},l.prototype.delete=function(e){var t=this.__data__,n=s(t,e);return!(n<0)&&(n==t.length-1?t.pop():c.call(t,n,1),--this.size,!0)},l.prototype.get=function(e){var t=this.__data__,n=s(t,e);return n<0?void 0:t[n][1]},l.prototype.has=function(e){return s(this.__data__,e)>-1},l.prototype.set=function(e,t){var n=this.__data__,r=s(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var u="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,p=u||h||Function("return this")(),d=p.Symbol,f=Object.prototype,v=f.hasOwnProperty,y=f.toString,m=d?d.toStringTag:void 0;var g=Object.prototype.toString;var b=d?d.toStringTag:void 0;function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":b&&b in Object(e)?function(e){var t=v.call(e,m),n=e[m];try{e[m]=void 0;var r=!0}catch(e){}var o=y.call(e);return r&&(t?e[m]=n:delete e[m]),o}(e):function(e){return g.call(e)}(e)}function j(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function O(e){if(!j(e))return!1;var t=_(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var w,x=p["__core-js_shared__"],E=(w=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"";var A=Function.prototype.toString;function S(e){if(null!=e){try{return A.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var M=/^\[object .+?Constructor\]$/,C=Function.prototype,R=Object.prototype,T=C.toString,P=R.hasOwnProperty,z=RegExp("^"+T.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function I(e){return!(!j(e)||(t=e,E&&E in t))&&(O(e)?z:M).test(S(e));var t}function N(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return I(n)?n:void 0}var B=N(p,"Map"),k=N(Object,"create");var D=Object.prototype.hasOwnProperty;var L=Object.prototype.hasOwnProperty;function F(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function V(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function W(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}F.prototype.clear=function(){this.__data__=k?k(null):{},this.size=0},F.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},F.prototype.get=function(e){var t=this.__data__;if(k){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return D.call(t,e)?t[e]:void 0},F.prototype.has=function(e){var t=this.__data__;return k?void 0!==t[e]:L.call(t,e)},F.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=k&&void 0===t?"__lodash_hash_undefined__":t,this},W.prototype.clear=function(){this.size=0,this.__data__={hash:new F,map:new(B||l),string:new F}},W.prototype.delete=function(e){var t=V(this,e).delete(e);return this.size-=t?1:0,t},W.prototype.get=function(e){return V(this,e).get(e)},W.prototype.has=function(e){return V(this,e).has(e)},W.prototype.set=function(e,t){var n=V(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function G(e){var t=this.__data__=new l(e);this.size=t.size}G.prototype.clear=function(){this.__data__=new l,this.size=0},G.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},G.prototype.get=function(e){return this.__data__.get(e)},G.prototype.has=function(e){return this.__data__.has(e)},G.prototype.set=function(e,t){var n=this.__data__;if(n instanceof l){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new W(r)}return n.set(e,t),this.size=n.size,this};function U(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new W;++t<n;)this.add(e[t])}function $(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}U.prototype.add=U.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},U.prototype.has=function(e){return this.__data__.has(e)};function Y(e,t,n,r,o,i){var a=1&n,s=e.length,c=t.length;if(s!=c&&!(a&&c>s))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var h=-1,p=!0,d=2&n?new U:void 0;for(i.set(e,t),i.set(t,e);++h<s;){var f=e[h],v=t[h];if(r)var y=a?r(v,f,h,t,e,i):r(f,v,h,e,t,i);if(void 0!==y){if(y)continue;p=!1;break}if(d){if(!$(t,function(e,t){if(a=t,!d.has(a)&&(f===e||o(f,e,n,r,i)))return d.push(t);var a})){p=!1;break}}else if(f!==v&&!o(f,v,n,r,i)){p=!1;break}}return i.delete(e),i.delete(t),p}var K=p.Uint8Array;function X(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function q(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var H=d?d.prototype:void 0,J=H?H.valueOf:void 0;var Q=Array.isArray;var Z=Object.prototype.propertyIsEnumerable,ee=Object.getOwnPropertySymbols,te=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var a=e[n];t(a,n,e)&&(i[o++]=a)}return i}(ee(e),function(t){return Z.call(e,t)}))}:function(){return[]},ne=te;function re(e){return null!=e&&"object"==typeof e}function oe(e){return re(e)&&"[object Arguments]"==_(e)}var ie=Object.prototype,ae=ie.hasOwnProperty,se=ie.propertyIsEnumerable,ce=oe(function(){return arguments}())?oe:function(e){return re(e)&&ae.call(e,"callee")&&!se.call(e,"callee")},le=ce;var ue="object"==typeof e&&e&&!e.nodeType&&e,he=ue&&"object"==typeof module&&module&&!module.nodeType&&module,pe=he&&he.exports===ue?p.Buffer:void 0,de=(pe?pe.isBuffer:void 0)||function(){return!1},fe=/^(?:0|[1-9]\d*)$/;function ve(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&fe.test(e))&&e>-1&&e%1==0&&e<t}function ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var me={};me["[object Float32Array]"]=me["[object Float64Array]"]=me["[object Int8Array]"]=me["[object Int16Array]"]=me["[object Int32Array]"]=me["[object Uint8Array]"]=me["[object Uint8ClampedArray]"]=me["[object Uint16Array]"]=me["[object Uint32Array]"]=!0,me["[object Arguments]"]=me["[object Array]"]=me["[object ArrayBuffer]"]=me["[object Boolean]"]=me["[object DataView]"]=me["[object Date]"]=me["[object Error]"]=me["[object Function]"]=me["[object Map]"]=me["[object Number]"]=me["[object Object]"]=me["[object RegExp]"]=me["[object Set]"]=me["[object String]"]=me["[object WeakMap]"]=!1;var ge,be="object"==typeof e&&e&&!e.nodeType&&e,_e=be&&"object"==typeof module&&module&&!module.nodeType&&module,je=_e&&_e.exports===be&&u.process,Oe=function(){try{var e=_e&&_e.require&&_e.require("util").types;return e||je&&je.binding&&je.binding("util")}catch(e){}}(),we=Oe&&Oe.isTypedArray,xe=we?(ge=we,function(e){return ge(e)}):function(e){return re(e)&&ye(e.length)&&!!me[_(e)]},Ee=Object.prototype.hasOwnProperty;function Ae(e,t){var n=Q(e),r=!n&&le(e),o=!n&&!r&&de(e),i=!n&&!r&&!o&&xe(e),a=n||r||o||i,s=a?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],c=s.length;for(var l in e)!t&&!Ee.call(e,l)||a&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||ve(l,c))||s.push(l);return s}var Se=Object.prototype;var Me=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),Ce=Me,Re=Object.prototype.hasOwnProperty;function Te(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||Se))return Ce(e);var t,n,r=[];for(var o in Object(e))Re.call(e,o)&&"constructor"!=o&&r.push(o);return r}function Pe(e){return null!=(t=e)&&ye(t.length)&&!O(t)?Ae(e):Te(e);var t}function ze(e){return function(e,t,n){var r=t(e);return Q(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Pe,ne)}var Ie=Object.prototype.hasOwnProperty;var Ne=N(p,"DataView"),Be=N(p,"Promise"),ke=N(p,"Set"),De=N(p,"WeakMap"),Le="[object Map]",Fe="[object Promise]",Ve="[object Set]",We="[object WeakMap]",Ge="[object DataView]",Ue=S(Ne),$e=S(B),Ye=S(Be),Ke=S(ke),Xe=S(De),qe=_;(Ne&&qe(new Ne(new ArrayBuffer(1)))!=Ge||B&&qe(new B)!=Le||Be&&qe(Be.resolve())!=Fe||ke&&qe(new ke)!=Ve||De&&qe(new De)!=We)&&(qe=function(e){var t=_(e),n="[object Object]"==t?e.constructor:void 0,r=n?S(n):"";if(r)switch(r){case Ue:return Ge;case $e:return Le;case Ye:return Fe;case Ke:return Ve;case Xe:return We}return t});var He=qe,Je="[object Arguments]",Qe="[object Array]",Ze="[object Object]",et=Object.prototype.hasOwnProperty;function tt(e,t,n,r,o,i){var s=Q(e),c=Q(t),l=s?Qe:He(e),u=c?Qe:He(t),h=(l=l==Je?Ze:l)==Ze,p=(u=u==Je?Ze:u)==Ze,d=l==u;if(d&&de(e)){if(!de(t))return!1;s=!0,h=!1}if(d&&!h)return i||(i=new G),s||xe(e)?Y(e,t,n,r,o,i):function(e,t,n,r,o,i,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!i(new K(e),new K(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var c=X;case"[object Set]":var l=1&r;if(c||(c=q),e.size!=t.size&&!l)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var h=Y(c(e),c(t),r,o,i,s);return s.delete(e),h;case"[object Symbol]":if(J)return J.call(e)==J.call(t)}return!1}(e,t,l,n,r,o,i);if(!(1&n)){var f=h&&et.call(e,"__wrapped__"),v=p&&et.call(t,"__wrapped__");if(f||v){var y=f?e.value():e,m=v?t.value():t;return i||(i=new G),o(y,m,n,r,i)}}return!!d&&(i||(i=new G),function(e,t,n,r,o,i){var a=1&n,s=ze(e),c=s.length;if(c!=ze(t).length&&!a)return!1;for(var l=c;l--;){var u=s[l];if(!(a?u in t:Ie.call(t,u)))return!1}var h=i.get(e),p=i.get(t);if(h&&p)return h==t&&p==e;var d=!0;i.set(e,t),i.set(t,e);for(var f=a;++l<c;){var v=e[u=s[l]],y=t[u];if(r)var m=a?r(y,v,u,t,e,i):r(v,y,u,e,t,i);if(!(void 0===m?v===y||o(v,y,n,r,i):m)){d=!1;break}f||(f="constructor"==u)}if(d&&!f){var g=e.constructor,b=t.constructor;g==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(d=!1)}return i.delete(e),i.delete(t),d}(e,t,n,r,o,i))}function nt(e,t,n,r,o){return e===t||(null==e||null==t||!re(e)&&!re(t)?e!=e&&t!=t:tt(e,t,n,r,nt,o))}var rt=class{constructor({game:e,rendererSystem:t}){this.renderers=[],this.game=e,this.rendererSystem=t}register(...e){for(const t of e)t.game=this.game,t.rendererManager=this.rendererSystem.rendererManager,t.containerManager=this.rendererSystem.containerManager,this.renderers.push(t)}componentChanged(e){for(const n of e)for(const e of this.renderers){const r=e.observerInfo[n.componentName];if(r){if([t.OBSERVER_TYPE.ADD,t.OBSERVER_TYPE.REMOVE].indexOf(n.type)>-1){try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject.name}, ${n.componentName} is error.`,n,e)}continue}if(r.findIndex(e=>{return t=e,r=n.prop,nt(t,r);var t,r})>-1)try{e.componentChanged&&e.componentChanged(n)}catch(e){console.error(`gameObject: ${n.gameObject&&n.gameObject.name}, ${n.componentName} is componentChanged error.`,n,e)}}}}update(e){for(const t of e.components)for(const n of this.renderers){const r=[];if(n.observerInfo[t.name]&&-1===r.indexOf(e)){r.push(e);try{n.rendererUpdate&&n.rendererUpdate(e)}catch(n){console.info(`gameObject: ${e.name}, ${t.name} is update error`,n)}}}}};const ot=(e,t,n)=>{const r=Number.isFinite(e.x)?e.x:0,o=Number.isFinite(e.y)?e.y:0,i=Number.isFinite(e.width)?e.width:0,a=Number.isFinite(e.height)?e.height:0;return{x:r,y:o,width:i,height:a,right:r+i,bottom:o+a,coordinateSpace:t,source:n}};class it{constructor(){this.containerMap={}}addContainer({name:e,container:t,gameObject:n}){this.containerMap[e]=t,t.gName=n.name||e}getContainer(e){return this.containerMap[e]}getBounds(e,t={}){if(!e||e.destroyed)return null;const n=t.coordinateSpace||"world",r=!1!==t.fallbackToTransform,o=this.getContainer(e.id);if(null==o?void 0:o.getBounds)try{const e=o.getBounds();if(e&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&(0!==e.width||0!==e.height))return ot(e,n,"pixi")}catch(e){}return r?this.getTransformBounds(e,n):null}getTransformBounds(e,t){var n,r,o,i,a,s;const c=e.transform,l=this.getContainer(e.id);let u=null===(n=null==l?void 0:l.worldTransform)||void 0===n?void 0:n.tx,h=null===(r=null==l?void 0:l.worldTransform)||void 0===r?void 0:r.ty;if(!Number.isFinite(u)||!Number.isFinite(h)){const e=this.resolveFallbackWorldPosition(c);u=e.x,h=e.y}const p=Number.isFinite(null===(o=c.scale)||void 0===o?void 0:o.x)?c.scale.x:1,d=Number.isFinite(null===(i=c.scale)||void 0===i?void 0:i.y)?c.scale.y:1,f=Math.abs(((null===(a=c.size)||void 0===a?void 0:a.width)||0)*p),v=Math.abs(((null===(s=c.size)||void 0===s?void 0:s.height)||0)*d);return ot({x:u,y:h,width:f,height:v},t,"transform")}resolveFallbackWorldPosition(e){var t,n,r,o;if(!e)return{x:0,y:0};const i=e.parent,a=i?this.resolveFallbackWorldPosition(i):{x:0,y:0},s=(null==i?void 0:i.size)||{width:0,height:0};return{x:a.x+((null===(t=e.position)||void 0===t?void 0:t.x)||0)+s.width*((null===(n=e.anchor)||void 0===n?void 0:n.x)||0),y:a.y+((null===(r=e.position)||void 0===r?void 0:r.y)||0)+s.height*((null===(o=e.anchor)||void 0===o?void 0:o.y)||0)}}removeContainer(e){const t=this.containerMap[e];t&&t.destroy({children:!0}),delete this.containerMap[e]}updateTransform({name:e,transform:t}){const n=this.containerMap[e];if(!n||!t)return;const{anchor:r,origin:o,position:i,rotation:a,scale:s,size:c,skew:l}=t;n.rotation=a,n.scale=s,n.pivot.x=c.width*o.x,n.pivot.y=c.height*o.y,n.skew=l;let u=i.x,h=i.y;if(t.parent){const e=t.parent;u+=e.size.width*r.x,h+=e.size.height*r.y}n.position={x:u,y:h}}}var at=function(e){var t={exports:{}};return e(t,t.exports),t.exports}(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,i||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,i,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,i),!0;case 6:return u.fn.call(u.context,t,r,o,i,a),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var p,d=u.length;for(l=0;l<d;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(p=1,c=new Array(h-1);p<h;p++)c[p-1]=arguments[p];u[l].fn.apply(u[l].context,c)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var c=0,l=[],u=s.length;c<u;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&l.push(s[c]);l.length?this._events[i]=1===l.length?l[0]:l:a(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}),st=at;let ct=class extends st{constructor({system:e,containerManager:t}){super(),this.name="Transform",this.waitRemoveIds=[],this.waitChangeScenes=[],this.containerManager=t,this.init(e)}init(e){this.system=e,this.on("changeScene",({scene:e,mode:t,application:n})=>{this.waitChangeScenes.push({scene:e,mode:t,application:n})})}update(){for(const e of this.waitRemoveIds)this.containerManager.removeContainer(e);this.waitRemoveIds=[];for(const e of this.waitChangeScenes){const t=this.containerManager.getContainer(e.scene.id);t&&(e.application.stage.removeChildren(),e.application.stage.addChild(t))}this.waitChangeScenes=[]}componentChanged(e){e.type===t.OBSERVER_TYPE.ADD?this.addContainer(e):e.type===t.OBSERVER_TYPE.CHANGE?this.change(e):e.type===t.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(e.gameObject.id)}addContainer(e){const t=new n.Container;t.label=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t,gameObject:e.gameObject});const r=e.component;Object.defineProperty(r,"worldTransform",{get:()=>t.renderGroup||t.parentRenderGroup?t.worldTransform:void 0})}change(e){const t=e.component;if(t.parent){this.containerManager.getContainer(t.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));const n=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");n&&(n.sortDirty=!0)}else{const t=this.containerManager.getContainer(e.gameObject.id);t.parent&&t.parent.removeChild(t)}}destroy(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null}};ct=o([t.decorators.componentObserver({Transform:["_parent"]}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[Object])],ct);var lt,ut=ct;e.RENDERER_TYPE=void 0,(lt=e.RENDERER_TYPE||(e.RENDERER_TYPE={}))[lt.UNKNOWN=0]="UNKNOWN",lt[lt.WEBGL=1]="WEBGL",lt[lt.CANVAS=2]="CANVAS";let ht=class extends t.System{constructor(){super(...arguments),this.multiApps=[],this.destroyed=!1}init(e={}){var n,r,o,a,s,c,l,u;return i(this,void 0,void 0,function*(){this.destroyed=!1;const h=!this.game&&function(e){if(!e||"object"!=typeof e)return!1;const t=e;return Boolean(t.scene||t.gameObjects||"function"==typeof t.on)}(e)?e:void 0;h&&(this.game=h);const p=h?this.__systemDefaultParams||{}:e;this.params=p,this.application=yield this.createApplication(p),this.containerManager=new it,this.rendererManager=new rt({game:this.game,rendererSystem:this}),this.game&&(this.game.canvas=this.application.canvas),this.transform=new ut({system:this,containerManager:this.containerManager}),null===(r=null===(n=this.game)||void 0===n?void 0:n.on)||void 0===r||r.call(n,"sceneChanged",({scene:e,mode:n,params:r})=>i(this,void 0,void 0,function*(){let o;switch(n){case t.LOAD_SCENE_MODE.SINGLE:o=this.application;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:o=yield this.createMultiApplication({params:r})}e.canvas=o.canvas,this.transform.emit("changeScene",{scene:e,mode:n,application:o})})),null===(a=null===(o=this.game)||void 0===o?void 0:o.on)||void 0===a||a.call(o,"pauseScene",({scene:e})=>{this.onPauseScene(e)}),null===(c=null===(s=this.game)||void 0===s?void 0:s.on)||void 0===c||c.call(s,"startScene",({scene:e})=>{this.onStartScene(e)}),null===(u=null===(l=this.game)||void 0===l?void 0:l.on)||void 0===u||u.call(l,"sceneDestroyed",({scene:e})=>i(this,void 0,void 0,function*(){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){this.multiApps.splice(t,1)[0].destroy(),e.destroy()}}))})}registerObserver(e){const t=this.constructor.observerInfo;for(const n in e)t[n]||(t[n]=[]),t[n].push(...e[n])}createMultiApplication({params:e}){return i(this,void 0,void 0,function*(){const t=yield this.createApplication(e);return this.multiApps.push(t),t})}createApplication(e){return i(this,void 0,void 0,function*(){const t=new n.Application;var o;return e.debugMode&&(globalThis.__PIXI_APP__=t),yield t.init(_extends(_extends({sharedTicker:!0},e),{hello:!0})),void 0!==e.enableScroll&&(e.enableScroll?((o=t.renderer).events.autoPreventDefault=!1,o.canvas.style.touchAction="auto"):(e=>{e.events.autoPreventDefault=!0,e.canvas.style.touchAction="none"})(t.renderer)),r.Ticker.shared.stop(),r.Ticker.shared.autoStart=!1,t})}update(){if(this.destroyed||!this.game||!this.containerManager||!this.rendererManager)return;const e=this.componentObserver.clear();for(const t of e)this.transform.componentChanged(t);for(const e of this.game.gameObjects)this.containerManager.updateTransform({name:e.id,transform:e.transform}),this.rendererManager.update(e)}lateUpdate(e){!this.destroyed&&this.transform&&this.application&&(this.transform.update(),this.application.ticker.update(e.time))}onDestroy(){var e,t,n,r,o,i,a;if(!this.destroyed){this.destroyed=!0,null===(n=null===(t=null===(e=this.application)||void 0===e?void 0:e.ticker)||void 0===t?void 0:t.stop)||void 0===n||n.call(t),null===(r=this.application)||void 0===r||r.destroy(!1,{children:!0,context:!0});for(const e of this.multiApps)null===(i=null===(o=null==e?void 0:e.ticker)||void 0===o?void 0:o.stop)||void 0===i||i.call(o),e&&e.destroy(!1,{children:!0,context:!0});null===(a=this.transform)||void 0===a||a.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null}}resize(e,t,n){this.params.width=e,this.params.height=t,null!=n&&(this.params.resolution=this.clampResolution(n)),this.application.renderer.resize(e,t,this.params.resolution),null!=n&&this.syncDisplayObjectResolution(this.params.resolution)}resizeRenderer(e){var t,n,r,o,i,a;const s=null!==(n=null!==(t=e.width)&&void 0!==t?t:this.params.width)&&void 0!==n?n:this.application.renderer.width,c=null!==(o=null!==(r=e.height)&&void 0!==r?r:this.params.height)&&void 0!==o?o:this.application.renderer.height,l=null==e.resolution?null!==(a=null!==(i=this.params.resolution)&&void 0!==i?i:this.application.renderer.resolution)&&void 0!==a?a:1:this.clampResolution(e.resolution,e.maxResolution);this.params.width=s,this.params.height=c,this.params.resolution=l,this.application.renderer.resize(s,c,l);return{width:s,height:c,resolution:l,displayResolutionSyncCount:this.syncDisplayObjectResolution(l)}}setResolution(e,t={}){return this.resizeRenderer(_extends(_extends({},t),{resolution:e}))}clampResolution(e,t=3){const n=Number.isFinite(e)&&e>0?e:1;return Math.min(n,t)}syncDisplayObjectResolution(e){var t;const n=(null===(t=this.containerManager)||void 0===t?void 0:t.containerMap)?Object.values(this.containerManager.containerMap):[],r="undefined"!=typeof WeakSet?new WeakSet:void 0;let o=0;const i=t=>{if(t&&"object"==typeof t&&!(null==r?void 0:r.has(t))){if(null==r||r.add(t),"resolution"in t){const n=t.resolution;if(("number"==typeof n||null===n)&&Math.abs((null!=n?n:1)-e)>.001)try{t.resolution=e,"number"==typeof t.resolution&&Math.abs(t.resolution-e)<=.001&&(o+=1)}catch(e){}}if(Array.isArray(t.children))for(const e of t.children)i(e)}};for(const e of n)i(e);return o}getBounds(e,t){var n;return(null===(n=this.containerManager)||void 0===n?void 0:n.getBounds(e,t))||null}getApplicationByScene(e){const t=this.multiApps.findIndex(t=>t.canvas===e.canvas);if(t>-1){return this.multiApps[t]}console.warn("application not found")}onPauseScene(e){const t=this.getApplicationByScene(e);t&&t.stop()}onStartScene(e){const t=this.getApplicationByScene(e);t&&t.start()}resizeByScene(e,t,n,r){const o=this.getApplicationByScene(e);o&&o.renderer.resize(t,n,r)}};ht.systemName="Renderer",ht=o([t.decorators.componentObserver({Transform:["_parent"]})],ht);var pt=ht;let dt;function ft(e){e.addPreProcessResourceHandler(function(e){var t,n,r;let o=null===(n=null===(t=e.src)||void 0===t?void 0:t.image)||void 0===n?void 0:n.texture;if(!o)return;Array.isArray(o)||(o=[o]);const i=null!==(r=function(){if(dt)return dt;const e=document.createElement("canvas").getContext("webgl2");if(!e)return console.warn("WebGL not available for compressed textures. Silently failing."),{s3tc:!1,etc:!1,etc1:!1,pvrtc:!1,atc:!1,astc:!1};dt={s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc")||!!e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:!!e.getExtension("WEBGL_compressed_texture_atc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc")};try{console.log("Eva.js Supported Compressed Texture Format List: "+Object.keys(dt).filter(e=>dt[e]).join(", "))}catch(e){}return dt}())&&void 0!==r?r:{};let a=o.find(e=>i[e.type]);a&&_extends(e.src.image,a)})}class vt extends t.System{constructor(e){super(e),this.asyncIdMap={},this.observerInfo=this.constructor.observerInfo}componentChanged(e){}rendererUpdate(e){}update(e){const t=this.componentObserver.clear();for(const e of t)this.componentChanged(e)}increaseAsyncId(e){return this.asyncIdMap[e]=(this.asyncIdMap[e]||0)+1,this.asyncIdMap[e]}validateAsyncId(e,t){return this.asyncIdMap[e]===t}}return e.ContainerManager=it,e.Renderer=vt,e.RendererManager=rt,e.RendererSystem=pt,e.registerKtx2CompressedTexture=function(e){r.setKTXTranscoderPath(e),r.extensions.add(r.loadKTX2),r.extensions.add(r.resolveCompressedTextureUrl),r.extensions.add(r.detectCompressed),ft(t.resource)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.rendererAdapter,PIXI);globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||_EVA_IIFE_renderer;