WebGPUTextureRenderer.js 715 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { WebGLRenderTarget } from 'three';
  2. class WebGPUTextureRenderer {
  3. constructor( renderer, options = {} ) {
  4. this.renderer = renderer;
  5. // @TODO: Consider to introduce WebGPURenderTarget or rename WebGLRenderTarget to just RenderTarget
  6. this.renderTarget = new WebGLRenderTarget( options );
  7. }
  8. getTexture() {
  9. return this.renderTarget.texture;
  10. }
  11. setSize( width, height ) {
  12. this.renderTarget.setSize( width, height );
  13. }
  14. render( scene, camera ) {
  15. const renderer = this.renderer;
  16. const renderTarget = this.renderTarget;
  17. renderer.setRenderTarget( renderTarget );
  18. renderer.render( scene, camera );
  19. renderer.setRenderTarget( null );
  20. }
  21. }
  22. export default WebGPUTextureRenderer;