RenderPass.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. THREE.RenderPass.prototype = {
  18. constructor: THREE.RenderPass,
  19. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  20. this.scene.overrideMaterial = this.overrideMaterial;
  21. if ( this.clearColor ) {
  22. this.oldClearColor.copy( renderer.getClearColor() );
  23. this.oldClearAlpha = renderer.getClearAlpha();
  24. renderer.setClearColor( this.clearColor, this.clearAlpha );
  25. }
  26. renderer.render( this.scene, this.camera, readBuffer, this.clear );
  27. if ( this.clearColor ) {
  28. renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
  29. }
  30. this.scene.overrideMaterial = null;
  31. }
  32. };