GPU挑选三个JS

时间:2015-04-16 11:51:58

标签: javascript three.js

我正在使用三个j中的GPU拾取示例。有人可以解释我们如何从拾取纹理中检索对象。我不明白代码是如何工作的。

//create buffer for reading single pixel
            var pixelBuffer = new Uint8Array( 4 );

            //read the pixel under the mouse from the texture
            renderer.readRenderTargetPixels(pickingTexture, mouse.x, pickingTexture.height - mouse.y, 1, 1, pixelBuffer);

            //interpret the pixel as an ID

            var id = ( pixelBuffer[0] << 16 ) | ( pixelBuffer[1] << 8 ) | ( pixelBuffer[2] );
            var data = pickingData[ id ];

我知道我们从纹理中获取像素值,但不清楚我们如何使用ID引用对象

0 个答案:

没有答案
相关问题