THREE.js使用MeshPhongMaterial作为粒子材料和设置大小

时间:2013-08-25 21:57:46

标签: javascript three.js webgl

我正在尝试创建具有Phong材质属性(对光反应)的粒子,为了实现这一点,我使用了“createMultiMaterialObject”,除了忽略粒子大小之外,这在很大程度上起作用了因为粒子似乎是奇怪的三角形,见下文:

enter image description here

这是我正在使用的代码:

var ringGeometry = new THREE.TorusGeometry( rad, ringSize, 1, 200, Math.PI * 2);
materials = [
p2paterial = new THREE.MeshPhongMaterial({shading: THREE.SmoothShading, blending:     THREE.AdditiveBlending, transparent: true, color: ringColour, ambient: 0x000000, specular:     0xffffff, shininess: 1, vertexColors: false  } ),
pmaterial = new THREE.ParticleBasicMaterial( { size: 1, transparent: true,     vertexColors: true  } )
        ];
singleRing = new THREE.SceneUtils.createMultiMaterialObject(ringGeometry, materials);

任何人都可以指出我如何能够达到最后一点,让每个粒子大小为1 - 我非常接近得到我想要的东西,我怀疑它只是我需要在某处调整的选项。 / p>

2 个答案:

答案 0 :(得分:0)

请改为尝试:

var geometry = new THREE.TorusGeometry( rad, ringSize, 1, 200, Math.PI * 2);

var material = new THREE.MeshPhongMaterial({shading: THREE.SmoothShading, blending:     THREE.AdditiveBlending, transparent: true, color: ringColour, ambient: 0x000000, specular:     0xffffff, shininess: 1, vertexColors: false  } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );

var material = new THREE.ParticleBasicMaterial( { size: 1, transparent: true,     vertexColors: true  } );
var particles = new THREE.ParticleSystem( geometry, material );
scene.add( particles );

答案 1 :(得分:0)

我从未使用过three.js,但是我正在弄乱你的小提琴,我通过在TorusGeometry声明中调整RadialSegments的值来获得看起来更像粒子的东西....

var geometry = new THREE.TorusGeometry( 10, 10, .5, 200, Math.PI * 2);

http://jsfiddle.net/sJZeH/