RenderPass.js 1.2 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 : 0;
  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. var oldAutoClear = renderer.autoClear;
  18. renderer.autoClear = false;
  19. this.scene.overrideMaterial = this.overrideMaterial;
  20. var oldClearColor, oldClearAlpha;
  21. if ( this.clearColor ) {
  22. oldClearColor = renderer.getClearColor().getHex();
  23. oldClearAlpha = renderer.getClearAlpha();
  24. renderer.setClearColor( this.clearColor, this.clearAlpha );
  25. }
  26. renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear );
  27. if ( this.clearColor ) {
  28. renderer.setClearColor( oldClearColor, oldClearAlpha );
  29. }
  30. this.scene.overrideMaterial = null;
  31. renderer.autoClear = oldAutoClear;
  32. }
  33. } );