2016-07-27 68 views
0

应该是什么其他的(自定义)的正确长度属性 如果 length of my position attribute is mlength of my index attribute is nBufferAttribute尺寸为IndexedBufferGeometry

例如,如果我有一个矩形表面绘制;

4 points => 4*3 = length of positions is 12, 
2 triangles => 2*3 = length of index attribute is 6 

如果我需要颜色属性(rgba)应该是什么数组的长度?

4 * 4 = 16 or 6*4 = 24 ? 

回答

0

属性有itemSize属性,决定了多少个号码都是为了一个矢量

位置属性有itemSize == 3

也不要紧,因为每个顶点需要定义你的几何形状是否被收录每个属性本身

你可以得到的顶点数positionAttribute.countpositionAttribute.array.length/positionAttribute.itemSize

所以你的RGBA颜色属性需要itemSize = 4因此它需要有长度4 * positionAttribute.count

var rbgaAttribute = new THREE.BufferAttribute(new Float32Array(4 * positionAttribute.count), 4); 
+0

我知道itemSize的阵列。我的问题是,如果一个缓冲区属性数组的长度为itemSize * positionArray.length/3或itemSize * indexArray.length。但是在我的测试之后,我发现了答案,正如你所说的,它应该是itemSize * positionArray.length/3 – Hasan