WebGLRenderTarget.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. options = options || {};
  16. if ( options.minFilter === undefined ) options.minFilter = THREE.LinearFilter;
  17. this.texture = new THREE.Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy );
  18. this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
  19. this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
  20. };
  21. THREE.WebGLRenderTarget.prototype = {
  22. constructor: THREE.WebGLRenderTarget,
  23. setSize: function ( width, height ) {
  24. if ( this.width !== width || this.height !== height ) {
  25. this.width = width;
  26. this.height = height;
  27. this.dispose();
  28. }
  29. },
  30. clone: function () {
  31. return new this.constructor().copy( this );
  32. },
  33. copy: function ( source ) {
  34. this.width = source.width;
  35. this.height = source.height;
  36. this.texture = source.texture.clone();
  37. this.depthBuffer = source.depthBuffer;
  38. this.stencilBuffer = source.stencilBuffer;
  39. this.shareDepthFrom = source.shareDepthFrom;
  40. return this;
  41. },
  42. dispose: function () {
  43. this.dispatchEvent( { type: 'dispose' } );
  44. }
  45. };
  46. THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype );