import{aY as _,d as i,_ as d,s as m}from"./index-CDrXokXW.js";class p{get name(){return this._name}get cameras(){return this._cameras}get engine(){return this._engine}constructor(t,s){this._engine=t,this.uniqueId=_.UniqueId,this._name=s,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}getClassName(){return"PostProcessRenderPipeline"}get isSupported(){for(const t in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,t)&&!this._renderEffects[t].isSupported)return!1;return!0}addEffect(t){this._renderEffects[t._name]=t}_rebuild(){}_enableEffect(t,s){const e=this._renderEffects[t];e&&e._enable(i.MakeArray(s||this._cameras))}_disableEffect(t,s){const e=this._renderEffects[t];e&&e._disable(i.MakeArray(s||this._cameras))}_attachCameras(t,s){const e=i.MakeArray(t||this._cameras);if(!e)return;const a=[];let r;for(r=0;r<e.length;r++){const c=e[r];c&&(this._cameras.indexOf(c)===-1?this._cameras.push(c):s&&a.push(r))}for(r=0;r<a.length;r++)e.splice(a[r],1);for(const c in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,c)&&this._renderEffects[c]._attachCameras(e)}_detachCameras(t){const s=i.MakeArray(t||this._cameras);if(s){for(const e in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&this._renderEffects[e]._detachCameras(s);for(let e=0;e<s.length;e++)this._cameras.splice(this._cameras.indexOf(s[e]),1)}}_update(){for(const t in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,t)&&this._renderEffects[t]._update();for(let t=0;t<this._cameras.length;t++){if(!this._cameras[t])continue;const s=this._cameras[t].name;this._renderEffectsForIsolatedPass[s]&&this._renderEffectsForIsolatedPass[s]._update()}}_reset(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array}_enableMSAAOnFirstPostProcess(t){if(!this._engine._features.supportMSAA)return!1;const s=Object.keys(this._renderEffects);if(s.length>0){const e=this._renderEffects[s[0]].getPostProcesses();e&&(e[0].samples=t)}return!0}_adaptPostProcessesToViewPort(){const t=Object.keys(this._renderEffects);for(const s of t){const e=this._renderEffects[s].getPostProcesses();if(e)for(const a of e)a.adaptScaleToCurrentViewport=!0}}setPrePassRenderer(t){return!1}dispose(){}}d([m()],p.prototype,"_name",void 0);class P{constructor(t,s,e,a=!0){this._name=s,this._singleInstance=a,this._getPostProcesses=e,this._cameras={},this._indicesForCamera={},this._postProcesses={}}get isSupported(){for(const t in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,t)){const s=this._postProcesses[t];for(let e=0;e<s.length;e++)if(!s[e].isSupported)return!1}return!0}_update(){}_attachCameras(t){let s;const e=i.MakeArray(t||this._cameras);if(e)for(let a=0;a<e.length;a++){const r=e[a];if(!r)continue;const c=r.name;if(this._singleInstance?s=0:s=c,!this._postProcesses[s]){const o=this._getPostProcesses();o&&(this._postProcesses[s]=Array.isArray(o)?o:[o])}this._indicesForCamera[c]||(this._indicesForCamera[c]=[]);const n=this._postProcesses[s];for(const o of n){const f=r.attachPostProcess(o);this._indicesForCamera[c].push(f)}this._cameras[c]||(this._cameras[c]=r)}}_detachCameras(t){const s=i.MakeArray(t||this._cameras);if(s)for(let e=0;e<s.length;e++){const a=s[e],r=a.name,c=this._postProcesses[this._singleInstance?0:r];if(c)for(const n of c)a.detachPostProcess(n);this._cameras[r]&&(this._cameras[r]=null),delete this._indicesForCamera[r]}}_enable(t){const s=i.MakeArray(t||this._cameras);if(s)for(let e=0;e<s.length;e++){const a=s[e],r=a.name,c=this._singleInstance?0:r;for(let n=0;n<this._indicesForCamera[r].length;n++){const o=this._indicesForCamera[r][n],f=a._postProcesses[o];f==null&&s[e].attachPostProcess(this._postProcesses[c][n],o)}}}_disable(t){const s=i.MakeArray(t||this._cameras);if(s)for(let e=0;e<s.length;e++){const a=s[e],r=a.name,c=this._postProcesses[this._singleInstance?0:r];for(const n of c)a.detachPostProcess(n)}}getPostProcesses(t){return this._singleInstance?this._postProcesses[0]:t?this._postProcesses[t.name]:null}}export{p as P,P as a};
