THREE.js: get data from THREE.WebGLRenderTarget

血红的双手。 提交于 2019-12-01 06:42:24

New function for this now:

WebGLRenderer.readRenderTargetPixels ( renderTarget, x, y, width, height, buffer )

Reads the pixel data from the renderTarget into the buffer you pass in. Buffer should be a Javascript Uint8Array instantiated with new Uint8Array( renderTargetWidth * renderTargetWidth * 4 ) to account for size and color information. This is a wrapper around gl.readPixels.

I haven't tried it myself, but it should be possible to get a byte array using WebGL's readPixels function passing the render target's (private) __webglTexture property.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!