RenderPass.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.clear = true;
  11. this.needsSwap = false;
  12. this.oldClearColor = new THREE.Color();
  13. this.oldClearAlpha = 1;
  14. };
  15. THREE.RenderPass.prototype = {
  16. render: function ( renderer, writeBuffer, readBuffer, delta ) {
  17. this.scene.overrideMaterial = this.overrideMaterial;
  18. if ( this.clearColor ) {
  19. this.oldClearColor.copy( renderer.getClearColor() );
  20. this.oldClearAlpha = renderer.getClearAlpha();
  21. renderer.setClearColor( this.clearColor, this.clearAlpha );
  22. }
  23. renderer.render( this.scene, this.camera, readBuffer, this.clear );
  24. if ( this.clearColor ) {
  25. renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
  26. }
  27. this.scene.overrideMaterial = null;
  28. }
  29. };