ShaderPass.js 1.0 KB

123456789101112131415161718192021222324252627
  1. THREE.ShaderPass = function(e, t) {
  2. this.textureID = void 0 !== t ? t : "tDiffuse",
  3. e instanceof THREE.ShaderMaterial ? (this.uniforms = e.uniforms,
  4. this.material = e) : e && (this.uniforms = THREE.UniformsUtils.clone(e.uniforms),
  5. this.material = new THREE.ShaderMaterial({
  6. defines: e.defines || {},
  7. uniforms: this.uniforms,
  8. vertexShader: e.vertexShader,
  9. fragmentShader: e.fragmentShader
  10. })),
  11. this.renderToScreen = !1,
  12. this.enabled = !0,
  13. this.needsSwap = !0,
  14. this.clear = !1,
  15. this.camera = new THREE.OrthographicCamera(-1,1,1,-1,0,1),
  16. this.scene = new THREE.Scene,
  17. this.quad = new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),null),
  18. this.scene.add(this.quad)
  19. }
  20. ,
  21. THREE.ShaderPass.prototype = {
  22. render: function(e, t, i, n) {
  23. this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = i),
  24. this.quad.material = this.material,
  25. this.renderToScreen ? e.render(this.scene, this.camera) : e.render(this.scene, this.camera, t, this.clear)
  26. }
  27. }