0

我的锥体显示在 jsfiddle 链接中。现在整个锥体都是蓝色的单一颜色。但我想将圆锥方形底座的颜色更改为红色。为此,我需要更改构成方形底座的两个面的颜色。怎么做?

我的锥体的 JsFiddle 链接:http: //jsfiddle.net/sagh0900/suvKg/1/

function getGeometry(meshMaterial)
{
var cone;
var geo = new THREE.Geometry();
geo.vertices.push(new THREE.Vector3(0, 0, 0));
geo.vertices.push(new THREE.Vector3(-0.5, 0.5, 1));
geo.vertices.push(new THREE.Vector3(0.5, 0.5, 1));
geo.vertices.push(new THREE.Vector3(-0.5, -0.5, 1));
geo.vertices.push(new THREE.Vector3(0.5, -0.5, 1)); 
geo.faces.push( new THREE.Face3(0,1,2));
geo.faces.push( new THREE.Face3(2,1,4));
geo.faces.push( new THREE.Face3(1,3,4));
geo.faces.push( new THREE.Face3(4,3,0));
geo.faces.push( new THREE.Face3(3,1,0));
geo.faces.push( new THREE.Face3(0,2,4));
geo.computeFaceNormals();
cone = new THREE.Mesh(geo, meshMaterial);
cone.doubleSided = true;
cone.overdraw = true;
return cube;
}

提前致谢。

4

1 回答 1

0

您可以为顶点指定颜色,然后在材质中使用顶点颜色。这个过程的一个例子,看例子中的源码:

http://stemkoski.github.com/Three.js/Vertex-Colors.html

于 2013-03-18T00:55:11.570 回答