BufferAttribute尺寸为IndexedBufferGeometry
问题描述:
应该是什么其他的(自定义)的正确长度属性 如果 length of my position attribute is m
和 length of my index attribute is n
?BufferAttribute尺寸为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 ?
答
属性有itemSize
属性,决定了多少个号码都是为了一个矢量
位置属性有itemSize == 3
也不要紧,因为每个顶点需要定义你的几何形状是否被收录每个属性本身
你可以得到的顶点数positionAttribute.count
即positionAttribute.array.length/positionAttribute.itemSize
所以你的RGBA颜色属性需要itemSize = 4
因此它需要有长度4 * positionAttribute.count
var rbgaAttribute = new THREE.BufferAttribute(new Float32Array(4 * positionAttribute.count), 4);
我知道itemSize的阵列。我的问题是,如果一个缓冲区属性数组的长度为itemSize * positionArray.length/3或itemSize * indexArray.length。但是在我的测试之后,我发现了答案,正如你所说的,它应该是itemSize * positionArray.length/3 – Hasan