使用Three.js r75合併具有不同顏色的網格
我想顯示根據從綠色到紅色的整數值更改顏色的多維數據集。我堅持使用了多種方法。我無法使cubeMat.material.color.setRGB工作,並創建一個新的Three.Color似乎也不工作。請注意,我將所有幾何圖形合併爲一個繪圖調用。我希望這不是問題。
[UPDATE] 我確認rgb值是用getStyle正確設置的,但是它們不能正確呈現。所有立方體堆疊應該是不同的顏色。
function colorData(percentage){
var rgbString = "",
r = parseInt(percentage * 25.5),
g = parseInt(((percentage * 25.5) - 255) * -1),
b = 0;
rgbString = "rgb("+r+","+g+",0)";
return rgbString;
}
...
var position = latLongToSphere(objectCoord[1], objectCoord[0], 300),
rgb = colorData(objectMag),
cubeColor = new THREE.Color(rgb),
cubeMat = new THREE.MeshBasicMaterial({color: cubeColor}),
cubeHeight = objectMag * 175,
cubeGeom = new THREE.BoxGeometry(3,3,cubeHeight,1,1,1),
cube = new THREE.Mesh(cubeGeom, cubeMat);
// set position of cube on globe, point to center, merge together for one draw call
cube.geometry.colorsNeedUpdate = true;
cube.position.set(position.x, position.y, position.z);
cube.lookAt(lookCenter);
cube.updateMatrix();
console.log(cube.material.color.getStyle());
geom.merge(cube.geometry, cube.matrix);
這是非常好的謝謝你!好奇這是什麼與緩衝幾何看起來......剛瞭解它,我想我應該使用它。我只在相應的場景中移動相機。 –
這是否與將框幾何體設置爲緩衝區幾何體一樣簡單,還是因爲在合併之前必須對其進行構造的方式有更多要求。 –
我不認爲'BufferGeometry'合併得到了適當的支持。 – WestLangley