[英]THREE.js Particles / PointCloud
我正在尝试使一些绕行物体离开轨道。 为此,我创建了一个粒子系统,它由三个几何,三个PointCloud和三个PointCloudMaterial组成:
particleMaterial = new THREE.PointCloudMaterial({
color: 0xFFFFFF, size: 1, sizeAttenuation: false
});
particles = new THREE.Geometry;
particles.verticesNeedUpdate = true;
particles.dynamic = true;
particleSystem = new THREE.PointCloud( particles, particleMaterial );
scene.add( particleSystem );
为了生成用于几何形状的顶点以形成轨迹,我在动画循环中创建了它们,并从提供该时间点的轨迹的对象中复制了位置:
function animate() {
if ( nodesArray.length > 0 ) {
for ( var i = 0; i < nodesArray.length; i++ ) {
nodesArray[i].position.x = Math.sin( nodesArray[i].counterX ) * 50;
nodesArray[i].position.z = Math.cos( nodesArray[i].counterZ ) * 50;
nodesArray[i].position.y = Math.cos( nodesArray[i].counterY ) * 50;
nodesArray[i].counterX += .01;
nodesArray[i].counterZ += .01;
nodesArray[i].counterY += .01;
var particle = new THREE.Vector3();
particle.copy( nodesArray[i].position );
particles.vertices.push( particle );
particles.verticesNeedUpdate = true;
}
}
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
这是一个jsfiddle: http : //jsfiddle.net/jayfield1979/184kbyLr/
将每个对象的第一个顶点添加到正确的位置。 但是后续顶点未注册。
我是否正确执行此操作(如果有的话)? 或者,还有更好的方法?
https://github.com/mrdoob/three.js/wiki/Updates
请阅读“几何图形”。 您不能向几何图形添加新顶点,这就是为什么只有第一个顶点可见的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.