WebGLRenderer: Allow for copying textures from the canvas, remove copyFramebufferToTexture
Related issue: #21734
Depends on #29769
Description
This PR adjusts copyTextureToTexture so it can take null as the first "srcTexture" argument so data can be copied from the "canvas" frame buffer, removing the need for a separate "copyFramebufferToTexture" function since this was the only remaining use case after #29662 was merged. Since this function was the only documented reason for FrameBufferTexture, that has been removed, as well.
The LensFlare addon is the last thing that needs to be changed before this PR is ready but I'll wait for feedback before making further changes.
📦 Bundle size
Full ESM build, minified and gzipped.
| Before | After | Diff | |
|---|---|---|---|
| WebGL | 692.66 171.56 |
693.05 171.77 |
+394 B +212 B |
| WebGPU | 822.12 221.9 |
822.25 221.97 |
+136 B +65 B |
| WebGPU Nodes | 821.63 221.78 |
821.76 221.84 |
+136 B +60 B |
🌳 Bundle size after tree-shaking
Minimal build including a renderer, camera, empty scene, and dependencies.
| Before | After | Diff | |
|---|---|---|---|
| WebGL | 465.01 112.35 |
467.12 112.93 |
+2.1 kB +579 B |
| WebGPU | 542.65 146.78 |
542.79 146.84 |
+136 B +55 B |
| WebGPU Nodes | 498.65 136.58 |
498.79 136.65 |
+136 B +70 B |
cc @Mugen87 what are your thoughts on this? I'm hoping it cuts down on some API redundancy with copyTextureToTexture. Happy to adjust it however and remove the last couple uses of copyFramebufferToTexture in examples.
FYI: I've noticed the PR but I'm currently focusing on bug fixing/support in WebGPURenderer so it will take a bit until I can revisit this topic.