RenderPass.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. */
  4. THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {
  5. THREE.Pass.call( this );
  6. this.scene = scene;
  7. this.camera = camera;
  8. this.overrideMaterial = overrideMaterial;
  9. this.clearColor = clearColor;
  10. this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 1;
  11. this.oldClearColor = new THREE.Color();
  12. this.oldClearAlpha = 1;
  13. this.clear = true;
  14. this.needsSwap = false;
  15. };
  16. THREE.RenderPass.prototype = Object.create( THREE.Pass.prototype );
  17. Object.assign( THREE.RenderPass.prototype, {
  18. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  19. this.scene.overrideMaterial = this.overrideMaterial;
  20. if ( this.clearColor ) {
  21. this.oldClearColor.copy( renderer.getClearColor() );
  22. this.oldClearAlpha = renderer.getClearAlpha();
  23. renderer.setClearColor( this.clearColor, this.clearAlpha );
  24. }
  25. renderer.render( this.scene, this.camera, readBuffer, this.clear );
  26. if ( this.clearColor ) {
  27. renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
  28. }
  29. this.scene.overrideMaterial = null;
  30. }
  31. } );