Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在THREE.js中的顶点着色器之后获取变换的顶点位置_Three.js_Webgl - Fatal编程技术网

在THREE.js中的顶点着色器之后获取变换的顶点位置

在THREE.js中的顶点着色器之后获取变换的顶点位置,three.js,webgl,Three.js,Webgl,我正在更改顶点着色器中某些顶点的位置,但找不到将这些新更新的顶点位置恢复到js中的方法(我当前使用的是THREE.js:网格顶点的顶点位置始终保持不变)。 我找到了这个链接,但是webgl中不存在glGetTexImage(我也对这种浮点纹理方法表示怀疑)。 谢谢你的帮助 如果从缓冲区读取数据是唯一的问题,您可以这样做: //render the pass into the buffer renderer.render( rttScene, rttCamera, rttTexture, true

我正在更改顶点着色器中某些顶点的位置,但找不到将这些新更新的顶点位置恢复到js中的方法(我当前使用的是THREE.js:网格顶点的顶点位置始终保持不变)。 我找到了这个链接,但是webgl中不存在glGetTexImage(我也对这种浮点纹理方法表示怀疑)。
谢谢你的帮助

如果从缓冲区读取数据是唯一的问题,您可以这样做:

//render the pass into the buffer
renderer.render( rttScene, rttCamera, rttTexture, true );

// ...


//allocate an array to take the data from the buffer
var width = rttTexture.width;
var height = rttTexture.height;
var pixels = new Uint8Array(4 * width * height); 


//get gl context bind buffers, read pixels
var gl = renderer.context; 
var framebuffer = rttTexture.__webglFramebuffer;
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);        
gl.viewport(0, 0, width, height);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);


但是设置所有这些都很复杂,读取纹理可能很慢,为什么不在cpu上执行此操作?

请包含您尝试过的代码。谢谢您的回复。即使我没有测试从缓冲区读取数据,我也明白我的方法是错误的(从我所有的搜索结果来看,我仍然不确定我是否会错过一些关于gpu/cpu关系的信息)。无论如何,我接受了你的回答。@user3018088你的方法有什么问题,你是如何解决的?