ClearPass.js 887 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. THREE.ClearPass = function ( clearColor, clearAlpha ) {
  2. THREE.Pass.call( this );
  3. this.needsSwap = false;
  4. this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
  5. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
  6. };
  7. THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  8. constructor: THREE.ClearPass,
  9. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  10. var oldClearColor, oldClearAlpha;
  11. if ( this.clearColor ) {
  12. oldClearColor = renderer.getClearColor().getHex();
  13. oldClearAlpha = renderer.getClearAlpha();
  14. renderer.setClearColor( this.clearColor, this.clearAlpha );
  15. }
  16. renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
  17. renderer.clear();
  18. if ( this.clearColor ) {
  19. renderer.setClearColor( oldClearColor, oldClearAlpha );
  20. }
  21. }
  22. } );