UNPKG

@forbespro/lead-agent

Version:
46 lines (45 loc) 2.12 kB
import { ShaderMaterial as s, UniformsUtils as a } from "three"; import { Pass as n, FullScreenQuad as u } from "./index52.js"; class o extends n { /** * Constructs a new shader pass. * * @param {Object|ShaderMaterial} [shader] - A shader object holding vertex and fragment shader as well as * defines and uniforms. It's also valid to pass a custom shader material. * @param {string} [textureID='tDiffuse'] - The name of the texture uniform that should sample * the read buffer. */ constructor(t, i = "tDiffuse") { super(), this.textureID = i, this.uniforms = null, this.material = null, t instanceof s ? (this.uniforms = t.uniforms, this.material = t) : t && (this.uniforms = a.clone(t.uniforms), this.material = new s({ name: t.name !== void 0 ? t.name : "unspecified", defines: Object.assign({}, t.defines), uniforms: this.uniforms, vertexShader: t.vertexShader, fragmentShader: t.fragmentShader })), this._fsQuad = new u(this.material); } /** * Performs the shader pass. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering * destination for the pass. * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the * previous pass from this buffer. * @param {number} deltaTime - The delta time in seconds. * @param {boolean} maskActive - Whether masking is active or not. */ render(t, i, e) { this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = e.texture), this._fsQuad.material = this.material, this.renderToScreen ? (t.setRenderTarget(null), this._fsQuad.render(t)) : (t.setRenderTarget(i), this.clear && t.clear(t.autoClearColor, t.autoClearDepth, t.autoClearStencil), this._fsQuad.render(t)); } /** * Frees the GPU-related resources allocated by this instance. Call this * method whenever the pass is no longer used in your app. */ dispose() { this.material.dispose(), this._fsQuad.dispose(); } } export { o as ShaderPass };