WebGLMultipleRenderTargets.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { WebGLRenderTarget } from './WebGLRenderTarget.js';
  2. class WebGLMultipleRenderTargets extends WebGLRenderTarget {
  3. constructor( width = 1, height = 1, count = 1, options = {} ) {
  4. super( width, height, options );
  5. this.isWebGLMultipleRenderTargets = true;
  6. const texture = this.texture;
  7. this.texture = [];
  8. for ( let i = 0; i < count; i ++ ) {
  9. this.texture[ i ] = texture.clone();
  10. this.texture[ i ].isRenderTargetTexture = true;
  11. }
  12. }
  13. setSize( width, height, depth = 1 ) {
  14. if ( this.width !== width || this.height !== height || this.depth !== depth ) {
  15. this.width = width;
  16. this.height = height;
  17. this.depth = depth;
  18. for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
  19. this.texture[ i ].image.width = width;
  20. this.texture[ i ].image.height = height;
  21. this.texture[ i ].image.depth = depth;
  22. }
  23. this.dispose();
  24. }
  25. this.viewport.set( 0, 0, width, height );
  26. this.scissor.set( 0, 0, width, height );
  27. return this;
  28. }
  29. copy( source ) {
  30. this.dispose();
  31. this.width = source.width;
  32. this.height = source.height;
  33. this.depth = source.depth;
  34. this.scissor.copy( source.scissor );
  35. this.scissorTest = source.scissorTest;
  36. this.viewport.copy( source.viewport );
  37. this.depthBuffer = source.depthBuffer;
  38. this.stencilBuffer = source.stencilBuffer;
  39. if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
  40. this.texture.length = 0;
  41. for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
  42. this.texture[ i ] = source.texture[ i ].clone();
  43. this.texture[ i ].isRenderTargetTexture = true;
  44. }
  45. return this;
  46. }
  47. }
  48. export { WebGLMultipleRenderTargets };
粤ICP备19079148号