ClearPass.js 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {
  2. Color
  3. } from '../../../build/three.module.js';
  4. import { Pass } from './Pass.js';
  5. class ClearPass extends Pass {
  6. constructor( clearColor, clearAlpha ) {
  7. super();
  8. this.needsSwap = false;
  9. this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
  10. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
  11. this._oldClearColor = new Color();
  12. }
  13. render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  14. let oldClearAlpha;
  15. if ( this.clearColor ) {
  16. renderer.getClearColor( this._oldClearColor );
  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( this._oldClearColor, oldClearAlpha );
  24. }
  25. }
  26. }
  27. export { ClearPass };