ClearPass.js 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. this._oldClearColor = new THREE.Color();
  7. };
  8. THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  9. constructor: THREE.ClearPass,
  10. render: function ( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
  11. var 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. } );