ClearPass.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. console.warn( "THREE.ClearPass: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. THREE.ClearPass = function ( clearColor, clearAlpha ) {
  6. THREE.Pass.call( this );
  7. this.needsSwap = false;
  8. this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
  9. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
  10. };
  11. THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  12. constructor: THREE.ClearPass,
  13. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  14. var oldClearColor, oldClearAlpha;
  15. if ( this.clearColor ) {
  16. oldClearColor = renderer.getClearColor().getHex();
  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( oldClearColor, oldClearAlpha );
  24. }
  25. }
  26. } );