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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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,BufferGeometry,array.length/itemSize!=努米特斯?_Three.js_Webgl - Fatal编程技术网

THREE.js,BufferGeometry,array.length/itemSize!=努米特斯?

THREE.js,BufferGeometry,array.length/itemSize!=努米特斯?,three.js,webgl,Three.js,Webgl,看看这个例子 位置缓冲区的设置方式如下: var particles = 500000; var geometry = new THREE.BufferGeometry(); geometry.attributes = { position: { itemSize: 3, array: new Float32A

看看这个例子

位置缓冲区的设置方式如下:

            var particles = 500000;

            var geometry = new THREE.BufferGeometry();
            geometry.attributes = {

                position: {
                    itemSize: 3,
                    array: new Float32Array( particles * 3 ),
                    numItems: particles * 3
                },
如果T=geometry.attributes.position,那么T.array.length/T.itemSize==T.numItems,是否应该总是这样?如果数组的长度为L个插槽,并且每个项目占用K个插槽,那么就有理由存在L/K个项目。然而,这个例子似乎说明数组中有L个项目?L个项目将占用L*K个插槽:s

我在位置上也遇到了这个问题,只渲染了我的前1/3个顶点,因为我将顶点数用作numItems,itemSize=3,使用长度为numItems*itemSize的Float32Array

我误解了什么


谢谢

你没有误解任何事情。命名法可以改进

这样想:

itemSize = (number of components) / vertex

numItems = (number of components)
         = (number of vertices) * itemSize
numItems
视为发送到GPU的数组中的项目数


three.js r.57不会。numItems总是===array.length,那么?(如此多余)这有点令人困惑。只需遵循示例中的模式即可。