2016-08-19 118 views
0

我在Three.js场景中创建了一个粒子系统。 这是我的代码。如何更改three.js中的某些顶点不透明度?

function createParticleSystem() { 
    var sphere = new THREE.SphereGeometry(20, 50, 50); 

    var particleMaterial = new THREE.PointsMaterial({ 
       color: 0xffffff, 
       size: 0.5, 
       map: THREE.ImageUtils.loadTexture("images/particle.png"), 
       blending: THREE.AdditiveBlending, 
       transparent: true, 
       opacity:1 
      }); 

    particleSystem = new THREE.Points(sphere, particleMaterial); 

    return particleSystem; 
} 

添加粒子系统场景

particleSystem = createParticleSystem(); 

scene.add(particleSystem); 

我不知道如何可以改变这种vertices.y> 0顶点的透明度?

for (var i; i<particleSystem.geometry.vertices.length; i++){ 
     if(particleSystem.geometry.vertices[i].y > 0){ 

     // 
     // I don't know how set the opacity of those vertices 
     // 

     } 
    } 
+0

)请参阅http://stackoverflow.com/questions/12337660/三个js调整不透明的个人粒子/ 12344288#12344288 – WestLangley

+0

@WestLangley非常感谢你!!!!!!!!它确实有用!!!!! 现在我想映射所有顶点的纹理。 你有没有关于改变顶点颜色或纹理的例子? 因为顶点着色器和片段着色器对我来说是新的,所以我想我需要一些示例来学习如何编写代码。 –

回答

-1

不幸的是,您无法更改对象的不透明度,但您所做的操作是设置材质的不透明度。我的建议是创建一个与您的particleMaterial相同的材质,在其中设置所需的不透明度,然后只需更改对象本身的材质(如果使用vertices.y> 0

相关问题