2016-07-27 71 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