ClearPass.js 869 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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
  11. /*, deltaTime, maskActive */
  12. ) {
  13. let oldClearAlpha;
  14. if ( this.clearColor ) {
  15. renderer.getClearColor( this._oldClearColor );
  16. oldClearAlpha = renderer.getClearAlpha();
  17. renderer.setClearColor( this.clearColor, this.clearAlpha );
  18. }
  19. renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
  20. renderer.clear();
  21. if ( this.clearColor ) {
  22. renderer.setClearColor( this._oldClearColor, oldClearAlpha );
  23. }
  24. }
  25. }
  26. THREE.ClearPass = ClearPass;
  27. } )();