ClearPass.js 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.ClearPass = function ( clearColor, clearAlpha ) {
  5. THREE.Pass.call( this );
  6. this.needsSwap = false;
  7. this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
  8. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
  9. };
  10. THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  11. constructor: THREE.ClearPass,
  12. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  13. var oldClearColor, oldClearAlpha;
  14. if ( this.clearColor ) {
  15. oldClearColor = renderer.getClearColor().getHex();
  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( oldClearColor, oldClearAlpha );
  23. }
  24. }
  25. } );