Pass.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. dispose() {}
  15. } // Helper for passes that need to fill the viewport with a single quad.
  16. const _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); // https://github.com/mrdoob/three.js/pull/21358
  17. const _geometry = new THREE.BufferGeometry();
  18. _geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
  19. _geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
  20. class FullScreenQuad {
  21. constructor( material ) {
  22. this._mesh = new THREE.Mesh( _geometry, material );
  23. }
  24. dispose() {
  25. this._mesh.geometry.dispose();
  26. }
  27. render( renderer ) {
  28. renderer.render( this._mesh, _camera );
  29. }
  30. get material() {
  31. return this._mesh.material;
  32. }
  33. set material( value ) {
  34. this._mesh.material = value;
  35. }
  36. }
  37. THREE.FullScreenQuad = FullScreenQuad;
  38. THREE.Pass = Pass;
  39. } )();