0

我有方形底座的自定义几何图形,它看起来像一个圆锥体。这是 jsfiddle 链接:http: //jsfiddle.net/suvKg/18/

我在这里获得了整个对象的透明度:

 var meshMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, opacity: 0.6, depthWrite: false, depthTest: false, vertexColors: THREE.VertexColors } ); 

但我不希望将透明度应用于圆锥体的底部,而只有侧面应该有它。怎么做?

4

1 回答 1

2

您需要THREE.MeshFaceMaterial()用于整个网格。例如,如果您geometry有 X 面和 2 种不同的材料:

var materials = [
  new THREE.MeshLambertMaterial( { color: 0xffffff, opacity: 0.6, depthWrite: false, depthTest: false, vertexColors: THREE.VertexColors } ),
  new THREE.MeshLambertMaterial( { color: 0xffffff, opacity: 1, depthWrite: false, depthTest: false, vertexColors: THREE.VertexColors } )
]; // the two materials 

var mesh = new THREE.Mesh(yourGeometry, new THREE.MeshFaceMaterial(materials)); //tell three.js that you will have several materials in your geometry

然后,您将需要materialIndex根据材料索引手动确定每个面

yourGeometry.faces[0].materialIndex = 0; 
yourGeometry.faces[1].materialIndex = 0;
yourGeometry.faces[2].materialIndex = 1; // <= the cone base 
...
yourGeometry.faces[lastFaceIndex].materialIndex = 0;

注意:默认参数materialIndex0,因此在您的情况下,您只需要确定其材料索引的一个面

于 2013-01-03T15:15:37.963 回答