ClearPass.js 861 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ( function () {
  2. class ClearPass extends THREE.Pass {
  3. constructor( clearColor, clearAlpha ) {
  4. super();
  5. this.needsSwap = false;
  6. this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
  7. this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
  8. this._oldClearColor = new THREE.Color();
  9. }
  10. render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  11. let oldClearAlpha;
  12. if ( this.clearColor ) {
  13. renderer.getClearColor( this._oldClearColor );
  14. oldClearAlpha = renderer.getClearAlpha();
  15. renderer.setClearColor( this.clearColor, this.clearAlpha );
  16. }
  17. renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
  18. renderer.clear();
  19. if ( this.clearColor ) {
  20. renderer.setClearColor( this._oldClearColor, oldClearAlpha );
  21. }
  22. }
  23. }
  24. THREE.ClearPass = ClearPass;
  25. } )();