纹理在自定义网格上显示为黑色,但透明度是正确的

Texture appears black on custom mesh but transparency is right

我创建了一个网格,其中包含来自另一个几何体的顶点和 uv,如下所示:

var geom = mesh.geometry;

var projectGeometry = new THREE.Geometry(); 

var faces = [];

for(var i = 0; i < geom.faces.length; i++){

    var verts = [geom.faces[i].a, geom.faces[i].b, geom.faces[i].c];
    var uvs = [geom.faceVertexUvs[0][i][0], geom.faceVertexUvs[0][i][1], geom.faceVertexUvs[0][i][2]];

    var pts = [];
    var uvpts = {};
    var uv = [];

    var vec = geom.vertices[verts[v]].clone();

    for(var n = 0; n < 3; n++){
        uv.push(new THREE.Vector2( (vec[n].x + 1) / 2, (vec[n].y + 1) / 2));
        uvpts = { x: 2*geom.faceVertexUvs[0][i][n].x - 1, y: 2*geom.faceVertexUvs[0][i][n].y - 1, z: 0};
        projectGeometry.vertices.push( uvpts );
    }
    projectGeometry.faceVertexUvs[0].push(uv);

    var newFace = geom.faces[i].clone();

    newFace.a = decalGeometry.vertices.length - 3;
    newFace.b = decalGeometry.vertices.length - 2;
    newFace.c = decalGeometry.vertices.length - 1;

    var newUvFace = new THREE.Face3( newFace.a, newFace.b, newFace.c );

    newUvFace.normal = {x: 0, y: 0, z: 1};        
    newUvFace.color = {r: 1, g: 1, b: 1};         
    newUvFace.vertexNormals.push({x: 0, y: 0, z: 1});         
    newUvFace.vertexNormals.push({x: 0, y: 0, z: 1});         
    newUvFace.vertexNormals.push({x: 0, y: 0, z: 1});         

    projectGeometry.faces.push(newUvFace);
}

我将网格添加到场景中是这样的:

    var mesh = new THREE.Mesh(projectGeometry, material.clone());
    scene.add(mesh);

使用这样定义的材质:

texture = THREE.ImageUtils.loadTexture("tex.png");

material: new THREE.MeshPhongMaterial({
  side: THREE.DoubleSide,
  color: 0xffffff,
  map: texture,
  polygonOffset: true,
  polygonOffsetFactor: -4,
  transparent: true,
  depthWrite: false,
  shininess: 150,
  specular: 0xffffff
});

纹理有一些透明度,所以我可以看到纹理的 "shape" 是正确的,但没有应用颜色。全是黑色的。

这是一个轻微的问题。由于我的纹理 material 具有透明度,因此我使用了 PhongMaterial。我配置了一个 DirectionalLight 来照亮场景。由于某种原因,纹理颜色呈现为黑色。我将灯光更改为 AmbientLight,一切都变得很好。