2
0

ClearPass.js 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {
  2. Color
  3. } from '../../../build/three.module.js';
  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. this._oldClearColor = new Color();
  11. };
  12. ClearPass.prototype = Object.assign( Object.create( Pass.prototype ), {
  13. constructor: ClearPass,
  14. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  15. var oldClearAlpha;
  16. if ( this.clearColor ) {
  17. renderer.getClearColor( this._oldClearColor );
  18. oldClearAlpha = renderer.getClearAlpha();
  19. renderer.setClearColor( this.clearColor, this.clearAlpha );
  20. }
  21. renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
  22. renderer.clear();
  23. if ( this.clearColor ) {
  24. renderer.setClearColor( this._oldClearColor, oldClearAlpha );
  25. }
  26. }
  27. } );
  28. export { ClearPass };