WebGLRenderTarget.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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, options.encoding );
  21. this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
  22. this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
  23. this.depthTexture = null;
  24. };
  25. Object.assign( THREE.WebGLRenderTarget.prototype, THREE.EventDispatcher.prototype, {
  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.depthTexture = source.depthTexture;
  46. return this;
  47. },
  48. dispose: function () {
  49. this.dispatchEvent( { type: 'dispose' } );
  50. }
  51. } );
粤ICP备19079148号