DotScreenPass.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ( function () {
  2. class DotScreenPass extends THREE.Pass {
  3. constructor( center, angle, scale ) {
  4. super();
  5. if ( THREE.DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on THREE.DotScreenShader' );
  6. var shader = THREE.DotScreenShader;
  7. this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
  8. if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
  9. if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;
  10. if ( scale !== undefined ) this.uniforms[ 'scale' ].value = scale;
  11. this.material = new THREE.ShaderMaterial( {
  12. uniforms: this.uniforms,
  13. vertexShader: shader.vertexShader,
  14. fragmentShader: shader.fragmentShader
  15. } );
  16. this.fsQuad = new THREE.FullScreenQuad( this.material );
  17. }
  18. render( renderer, writeBuffer, readBuffer
  19. /*, deltaTime, maskActive */
  20. ) {
  21. this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
  22. this.uniforms[ 'tSize' ].value.set( readBuffer.width, readBuffer.height );
  23. if ( this.renderToScreen ) {
  24. renderer.setRenderTarget( null );
  25. this.fsQuad.render( renderer );
  26. } else {
  27. renderer.setRenderTarget( writeBuffer );
  28. if ( this.clear ) renderer.clear();
  29. this.fsQuad.render( renderer );
  30. }
  31. }
  32. }
  33. THREE.DotScreenPass = DotScreenPass;
  34. } )();