英文:
Cloning a texture created with THREE.WebGLRenderTarget
问题
我正在使用three.js,并且需要创建一些由THREE.WebGLRenderTarget()生成的纹理的克隆。
我可以使用原始纹理,例如:
scene.background = renderTarget.texture;
但如果我尝试使用它的克隆:
const tex = renderTarget.texture.clone();
scene.background = tex;
我会收到以下错误:
THREE.WebGLState: TypeError: Failed to execute 'texSubImage2D' on 'WebGL2RenderingContext': Overload resolution failed.
如果我添加以下代码:
tex.isRenderTargetTexture = true;
现在我不会收到任何错误,但纹理全是黑色的。
我还尝试过克隆渲染目标(而不是其纹理),但也没有成功。请您帮助我吗?
提前感谢您。
英文:
I'm using three.js and I need to create a few clones of a texture made with THREE.WebGLRenderTarget().
I can use the original texture, e.g.:
scene.background = renderTarget.texture;
But if I try to use a clone of it:
const tex = renderTarget.texture.clone();
scene.background = tex;
I get the following error:
THREE.WebGLState: TypeError: Failed to execute 'texSubImage2D' on 'WebGL2RenderingContext': Overload resolution failed.
If I add the line:
tex.isRenderTargetTexture = true;
Now I don't get any error, but the texture is all black.
I have also tried to clone the render target (instead of its texture) but it didn't work either. Can you please help me?
Thank you in advance.
答案1
得分: 0
问题已解决:我创建了一个帧缓冲纹理,并使用THREE.WebGLRenderer类的renderer.copyFramebufferToTexture()方法将纹理复制了出来。
英文:
Problem solved: I created a framebuffer texture, and I copied the texture by using method renderer.copyFramebufferToTexture() of class THREE.WebGLRenderer.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论