ClearPass.js 984 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { Pass } from "../postprocessing/Pass.js";
  5. var ClearPass = function ( clearColor, clearAlpha ) {
  6. Pass.call( this );
  7. this.needsSwap = false;
  8. this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
  9. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
  10. };
  11. ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
  12. constructor: ClearPass,
  13. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  14. var oldClearColor, oldClearAlpha;
  15. if ( this.clearColor ) {
  16. oldClearColor = renderer.getClearColor().getHex();
  17. oldClearAlpha = renderer.getClearAlpha();
  18. renderer.setClearColor( this.clearColor, this.clearAlpha );
  19. }
  20. renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
  21. renderer.clear();
  22. if ( this.clearColor ) {
  23. renderer.setClearColor( oldClearColor, oldClearAlpha );
  24. }
  25. }
  26. } );
  27. export { ClearPass };