Skip to content

Instantly share code, notes, and snippets.

@chanpu
Created December 14, 2014 12:14
Show Gist options
  • Save chanpu/f9b40bfc6484f238639e to your computer and use it in GitHub Desktop.
Save chanpu/f9b40bfc6484f238639e to your computer and use it in GitHub Desktop.
// パーティクルの数
particleCount = 5000;
particles = new THREE.Geometry();
// テクスチャの設定
texture = THREE.ImageUtils.loadTexture("images/particles.png")
// マテリアルの設定
material = new THREE.PointCloudMaterial({
color: 0xFFFFFF,
size: 5,
map: texture,
transparent: true
});
// パーティクルの位置の設定
for (var i = 0; i < particleCount; i++) {
var px = Math.random() * 1000 - 500,
py = Math.random() * 1000 - 500,
pz = Math.random() * 1000 - 500;
particle = new THREE.Vector3( px, py, pz);
// パーティクルのべロシティの設定
particle.velocity = new THREE.Vector3( 0, -Math.random(), 0 );
particles.vertices.push( particle );
}
pointCloud = new THREE.PointCloud( particles, material );
// パーティクルの深さを毎フレームソート
pointCloud.sortParticles = true;
scene.add( pointCloud );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment