Pass.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {
  2. OrthographicCamera,
  3. PlaneBufferGeometry,
  4. Mesh
  5. } from "../../../build/three.module.js";
  6. function Pass() {
  7. // if set to true, the pass is processed by the composer
  8. this.enabled = true;
  9. // if set to true, the pass indicates to swap read and write buffer after rendering
  10. this.needsSwap = true;
  11. // if set to true, the pass clears its buffer before rendering
  12. this.clear = false;
  13. // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
  14. this.renderToScreen = false;
  15. }
  16. Object.assign( Pass.prototype, {
  17. setSize: function ( /* width, height */ ) {},
  18. render: function ( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
  19. console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
  20. }
  21. } );
  22. // Helper for passes that need to fill the viewport with a single quad.
  23. Pass.FullScreenQuad = ( function () {
  24. var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  25. var geometry = new PlaneBufferGeometry( 2, 2 );
  26. var FullScreenQuad = function ( material ) {
  27. this._mesh = new Mesh( geometry, material );
  28. };
  29. Object.defineProperty( FullScreenQuad.prototype, 'material', {
  30. get: function () {
  31. return this._mesh.material;
  32. },
  33. set: function ( value ) {
  34. this._mesh.material = value;
  35. }
  36. } );
  37. Object.assign( FullScreenQuad.prototype, {
  38. render: function ( renderer ) {
  39. renderer.render( this._mesh, camera );
  40. }
  41. } );
  42. return FullScreenQuad;
  43. } )();
  44. export { Pass };