【问题标题】:THREE.js Particles / PointCloudTHREE.js 粒子/点云
【发布时间】:2015-06-24 19:06:46
【问题描述】:

我正在尝试让一些轨道物体留下踪迹。为此,我创建了一个粒子系统,它由一个三个几何体、一个三个点云和一个三个点云材料组成:

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/

每个对象的第一个顶点被添加到正确的位置。但是后面的顶点没有注册。

我这样做是否正确,如果正确,是什么坏了?还是有更好的办法?

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

    https://github.com/mrdoob/three.js/wiki/Updates

    请阅读“几何”。您不能向几何图形添加新顶点,这就是为什么只有第一个顶点可见的原因。

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 2014-01-26
      • 2012-06-28
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多