RenderPass.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.clear = true;
  12. this.needsSwap = false;
  13. };
  14. THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
  15. constructor: THREE.RenderPass,
  16. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  17. this.scene.overrideMaterial = this.overrideMaterial;
  18. if ( this.clearColor ) {
  19. var oldClearColorHex = renderer.getClearColor();
  20. var oldClearAlpha = renderer.getClearAlpha();
  21. renderer.setClearColor( this.clearColor, this.clearAlpha );
  22. }
  23. renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear );
  24. if ( this.clearColor ) {
  25. renderer.setClearColor( oldClearColorHex, oldClearAlpha );
  26. }
  27. this.scene.overrideMaterial = null;
  28. }
  29. } );