WebGLRenderTarget.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @author szimek / https://github.com/szimek/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.WebGLRenderTarget = function ( width, height, options ) {
  6. this.uuid = THREE.Math.generateUUID();
  7. this.width = width;
  8. this.height = height;
  9. options = options || {};
  10. this.wrapS = options.wrapS !== undefined ? options.wrapS : THREE.ClampToEdgeWrapping;
  11. this.wrapT = options.wrapT !== undefined ? options.wrapT : THREE.ClampToEdgeWrapping;
  12. this.magFilter = options.magFilter !== undefined ? options.magFilter : THREE.LinearFilter;
  13. this.minFilter = options.minFilter !== undefined ? options.minFilter : THREE.LinearMipMapLinearFilter;
  14. this.anisotropy = options.anisotropy !== undefined ? options.anisotropy : 1;
  15. this.offset = new THREE.Vector2( 0, 0 );
  16. this.repeat = new THREE.Vector2( 1, 1 );
  17. this.format = options.format !== undefined ? options.format : THREE.RGBAFormat;
  18. this.type = options.type !== undefined ? options.type : THREE.UnsignedByteType;
  19. this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
  20. this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
  21. this.generateMipmaps = true;
  22. this.shareDepthFrom = options.shareDepthFrom !== undefined ? options.shareDepthFrom : null;
  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. },
  33. clone: function () {
  34. var tmp = new THREE.WebGLRenderTarget( this.width, this.height );
  35. tmp.wrapS = this.wrapS;
  36. tmp.wrapT = this.wrapT;
  37. tmp.magFilter = this.magFilter;
  38. tmp.minFilter = this.minFilter;
  39. tmp.anisotropy = this.anisotropy;
  40. tmp.offset.copy( this.offset );
  41. tmp.repeat.copy( this.repeat );
  42. tmp.format = this.format;
  43. tmp.type = this.type;
  44. tmp.depthBuffer = this.depthBuffer;
  45. tmp.stencilBuffer = this.stencilBuffer;
  46. tmp.generateMipmaps = this.generateMipmaps;
  47. tmp.shareDepthFrom = this.shareDepthFrom;
  48. return tmp;
  49. },
  50. dispose: function () {
  51. this.dispatchEvent( { type: 'dispose' } );
  52. }
  53. };
  54. THREE.EventDispatcher.prototype.apply( THREE.WebGLRenderTarget.prototype );