
THREE.EffectComposer = function(e, t) {
    if (this.renderer = e,
    void 0 === t) {
        var i = {
            minFilter: THREE.LinearFilter,
            magFilter: THREE.LinearFilter,
            format: THREE.RGBAFormat,
            stencilBuffer: !1
        }
            , r = e.getSize();
        t = new THREE.WebGLRenderTarget(r.width,r.height,i)
    }
    this.renderTarget1 = t,
    this.renderTarget2 = t.clone(),
    this.writeBuffer = this.renderTarget1,
    this.readBuffer = this.renderTarget2,
    this.passes = [],
    void 0 === THREE.CopyShader && console.error("THREE.EffectComposer relies on THREE.CopyShader"),
    this.copyPass = new THREE.ShaderPass(THREE.CopyShader)
}
,
THREE.EffectComposer.prototype = {
    swapBuffers: function() {
        var e = this.readBuffer;
        this.readBuffer = this.writeBuffer,
        this.writeBuffer = e
    },
    addPass: function(e) {
        this.passes.push(e)
    },
    insertPass: function(e, t) {
        this.passes.splice(t, 0, e)
    },
    render: function(e) {
        this.writeBuffer = this.renderTarget1,
        this.readBuffer = this.renderTarget2;
        var t, i, r = !1, o = this.passes.length;
        for (i = 0; i < o; i++)
            if (t = this.passes[i],
            t.enabled) {
                if (t.render(this.renderer, this.writeBuffer, this.readBuffer, e, r),
                t.needsSwap) {
                    if (r) {
                        var a = this.renderer.context;
                        a.stencilFunc(a.NOTEQUAL, 1, 4294967295),
                        this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, e),
                        a.stencilFunc(a.EQUAL, 1, 4294967295)
                    }
                    this.swapBuffers()
                }
                t instanceof THREE.MaskPass ? r = !0 : t instanceof THREE.ClearMaskPass && (r = !1)
            }
    },
    reset: function(e) {
        if (void 0 === e) {
            var t = this.renderer.getSize();
            e = this.renderTarget1.clone(),
            e.setSize(t.width, t.height)
        }
        this.renderTarget1.dispose(),
        this.renderTarget2.dispose(),
        this.renderTarget1 = e,
        this.renderTarget2 = e.clone(),
        this.writeBuffer = this.renderTarget1,
        this.readBuffer = this.renderTarget2
    },
    setSize: function(e, t) {
        this.renderTarget1.setSize(e, t),
        this.renderTarget2.setSize(e, t)
    }
}