ClearPass.js 972 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ( function () {
  2. var ClearPass = function ( clearColor, clearAlpha ) {
  3. THREE.Pass.call( this );
  4. this.needsSwap = false;
  5. this.clearColor = clearColor !== undefined ? clearColor : 0x000000;
  6. this.clearAlpha = clearAlpha !== undefined ? clearAlpha : 0;
  7. this._oldClearColor = new THREE.Color();
  8. };
  9. ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  10. constructor: ClearPass,
  11. render: function ( renderer, writeBuffer, readBuffer
  12. /*, deltaTime, maskActive */
  13. ) {
  14. var oldClearAlpha;
  15. if ( this.clearColor ) {
  16. renderer.getClearColor( this._oldClearColor );
  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( this._oldClearColor, oldClearAlpha );
  24. }
  25. }
  26. } );
  27. THREE.ClearPass = ClearPass;
  28. } )();