WebGLMultipleRenderTargets.js 1.5 KB

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