threejs第四用粒子系统

自带的粒子系统需要GPUParticleSystem.js

options = {//一些初始值和随机参数
                position: new THREE.Vector3(),位置
                positionRandomness: .3,
                velocity: new THREE.Vector3(),速度
                velocityRandomness: .5,
                color: 0xffffff,颜色
                colorRandomness: 1.2,
                turbulence: .5,动荡
                lifetime: 2,生命周期
                size: 10,大小
                sizeRandomness: 1
            };

particleSystem = new THREE.GPUParticleSystem( {
                maxParticles: 250000
            } );

    scene.add( particleSystem );

在每次render()里面

                options.position.x = Math.random() * 5;
                options.position.y = Math.random( ) * 10;
                options.position.z = Math.random() * 5;

                for ( var x = 0; x <15000*Math.random(); x++ ) {

              particleSystem.spawnParticle( options );

                }

particleSystem.update( Math.random() * 5);//更新各种数据

调这些参数应该就能得到想要的效果。

猜你喜欢

转载自blog.csdn.net/qq_35158695/article/details/81205323
今日推荐