Pass.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ( function () {
  2. class Pass {
  3. constructor() {
  4. // if set to true, the pass is processed by the composer
  5. this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
  6. this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
  7. this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
  8. this.renderToScreen = false;
  9. }
  10. setSize() {}
  11. render() {
  12. console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );
  13. }
  14. } // Helper for passes that need to fill the viewport with a single quad.
  15. const _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
  16. const _geometry = new THREE.BufferGeometry();
  17. _geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
  18. _geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
  19. class FullScreenQuad {
  20. constructor( material ) {
  21. this._mesh = new THREE.Mesh( _geometry, material );
  22. }
  23. dispose() {
  24. this._mesh.geometry.dispose();
  25. }
  26. render( renderer ) {
  27. renderer.render( this._mesh, _camera );
  28. }
  29. get material() {
  30. return this._mesh.material;
  31. }
  32. set material( value ) {
  33. this._mesh.material = value;
  34. }
  35. }
  36. THREE.FullScreenQuad = FullScreenQuad;
  37. THREE.Pass = Pass;
  38. } )();