2
0

Pass.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {
  2. OrthographicCamera,
  3. PlaneGeometry,
  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. // Important: It's actually a hack to put FullScreenQuad into the Pass namespace. This is only
  24. // done to make examples/js code work. Normally, FullScreenQuad should be exported
  25. // from this module like Pass.
  26. Pass.FullScreenQuad = ( function () {
  27. var camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  28. var geometry = new PlaneGeometry( 2, 2 );
  29. var FullScreenQuad = function ( material ) {
  30. this._mesh = new Mesh( geometry, material );
  31. };
  32. Object.defineProperty( FullScreenQuad.prototype, 'material', {
  33. get: function () {
  34. return this._mesh.material;
  35. },
  36. set: function ( value ) {
  37. this._mesh.material = value;
  38. }
  39. } );
  40. Object.assign( FullScreenQuad.prototype, {
  41. dispose: function () {
  42. this._mesh.geometry.dispose();
  43. },
  44. render: function ( renderer ) {
  45. renderer.render( this._mesh, camera );
  46. }
  47. } );
  48. return FullScreenQuad;
  49. } )();
  50. export { Pass };