【问题标题】:(THREE.js) Material isn't working on my custom THREE.Geometry shape(THREE.js) 材质不适用于我的自定义 THREE.Geometry 形状
【发布时间】: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;

但是无论我把它放在哪里/有什么变化,它都不想工作。三角形保持黑色。

【问题讨论】:

    标签: colors three.js geometry


    【解决方案1】:

    你的顶点定义是顺时针的,而它应该是逆时针的。因此,如果您将new THREE.Face3(0,1,2) 更改为new THREE.Face3(0,2,1),您应该会看到一些东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 2020-03-06
      • 2019-10-18
      • 1970-01-01
      相关资源
      最近更新 更多