WebGLRenderTarget.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @author szimek / https://github.com/szimek/
  3. * @author alteredq / http://alteredqualia.com/
  4. * @author Marius Kintel / https://github.com/kintel
  5. */
  6. /*
  7. In options, we can specify:
  8. * Texture parameters for an auto-generated target texture
  9. * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
  10. */
  11. THREE.WebGLRenderTarget = function ( width, height, options ) {
  12. this.uuid = THREE.Math.generateUUID();
  13. this.width = width;
  14. this.height = height;
  15. this.scissor = new THREE.Vector4( 0, 0, width, height );
  16. this.scissorTest = false;
  17. this.viewport = new THREE.Vector4( 0, 0, width, height );
  18. options = options || {};
  19. if ( options.minFilter === undefined ) options.minFilter = THREE.LinearFilter;
  20. this.texture = new THREE.Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy );
  21. this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
  22. this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
  23. };
  24. THREE.WebGLRenderTarget.prototype = {
  25. constructor: THREE.WebGLRenderTarget,
  26. setSize: function ( width, height ) {
  27. if ( this.width !== width || this.height !== height ) {
  28. this.width = width;
  29. this.height = height;
  30. this.dispose();
  31. }
  32. this.viewport.set( 0, 0, width, height );
  33. this.scissor.set( 0, 0, width, height );
  34. },
  35. clone: function () {
  36. return new this.constructor().copy( this );
  37. },
  38. copy: function ( source ) {
  39. this.width = source.width;
  40. this.height = source.height;
  41. this.viewport.copy( source.viewport );
  42. this.texture = source.texture.clone();
  43. this.depthBuffer = source.depthBuffer;
  44. this.stencilBuffer = source.stencilBuffer;
  45. this.shareDepthFrom = source.shareDepthFrom;
  46. return this;
  47. },
  48. dispose: function () {
  49. this.dispatchEvent( { type: 'dispose' } );
  50. }
  51. };
  52. THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype );
粤ICP备19079148号