tôi muốn làm hái qua IdMapping trong Three.jsThreejs: gán màu sắc khác nhau cho mỗi đỉnh trong một hình học
Bởi vì vấn đề hiệu suất Tôi chỉ có một hình học rất lớn, tính toán như thế này:
for (var i = 0; i < numberOfVertices; i += 9) {
p1 = new THREE.Vector3(graphData.triangles.vertices[i+0], graphData.triangles.vertices[i+1], graphData.triangles.vertices[i+2]);
p2 = new THREE.Vector3(graphData.triangles.vertices[i+3], graphData.triangles.vertices[i+4], graphData.triangles.vertices[i+5]);
p3 = new THREE.Vector3(graphData.triangles.vertices[i+6], graphData.triangles.vertices[i+7], graphData.triangles.vertices[i+8]);
geometry.vertices.push(new THREE.Vertex(p1.clone()));
geometry.vertices.push(new THREE.Vertex(p2.clone()));
geometry.vertices.push(new THREE.Vertex(p3.clone()));
geometry.faces.push(new THREE.Face3(i/3, i/3+1, i/3+2));
// i want to do something like this:
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
}
geometry.computeFaceNormals();
var material = new THREE.MeshBasicMaterial({});
var triangles = new THREE.Mesh(geometry, material);
scene.add(triangles);
Làm cách nào để gán các màu khác nhau cho mỗi đỉnh trong hình của tôi?
Ít nhất là đối với tôi, tôi chỉ có thể đặt .vertexColors trên khuôn mặt hình học của tôi, như geometry.faces [0] .vertexColors [0] = .. –
Nó có thể đã thay đổi trong phiên bản mới nhất của ba. Bạn đang sử dụng bản sửa đổi nào? – sole
tôi sử dụng? Hiện tại? Phiên bản r49 –