RenderPass.js 1.0 KB

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