【发布时间】:2015-10-26 19:32:06
【问题描述】:
我创建了一个三角形,并试图将其变为红色。然而它仍然是黑色的。问题似乎不是材料,因为它适用于我制作的其他几何图形。
这是我的三角形:
var triangle = new THREE.Geometry();
triangle.vertices.push(
new THREE.Vector3(-10,10,0),
new THREE.Vector3(-10,-10,0),
new THREE.Vector3(10,-10,0)
);
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.computeBoundingSphere();
this.redtriangle = new THREE.Mesh(triangle, this.redMat)
我尝试了一些在线上色的建议:
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.faces[0].vertexColors[0] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[1] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[2] = new THREE.Color(0xFF0000);
我的资料
this.redMat = new THREE.MeshLambertMaterial ({
color: 0xFF0000,
shading:THREE.FlatShading,
// I added this line for the suggestion above
// vertexColors:THREE.VertexColors,
side:THREE.DoubleSide
})
我也试过插入
triangle.colorsNeedUpdate = true;
或
geometry.colorsNeedsUpdate = true;
但是无论我把它放在哪里/有什么变化,它都不想工作。三角形保持黑色。
【问题讨论】: