Create a gist now

Instantly share code, notes, and snippets.

@nbriz /createParticles.js Secret
Last active Dec 18, 2015

What would you like to do?
create particles, for threejs_playGnd
/* ------------------- INSTRUCTIONS -----
to create particles
add the block of code below to your setup()
-------------------------------------- */
geometry = new THREE.Geometry();
for ( i = 0; i < 5000; i ++ ) {
var vertex = new THREE.Vector3();
vertex.x = 1000 * Math.random() - 500;
vertex.y = 1000 * Math.random() - 500;
vertex.z = 1000 * Math.random() - 500;
geometry.vertices.push( vertex );
}
material = new THREE.ParticleBasicMaterial( { size: 5, sizeAttenuation: false, transparent: true } );
material.color.setHex( 0xff00ff );
particles = new THREE.ParticleSystem( geometry, material );
particles.sortParticles = true;
scene.add( particles );
/* --------------------------------------
try moving spinning your particles around
add the code below to your draw() function
-------------------------------------- */
particles.rotation.y = Date.now() * 0.00005;
/* --------------------------------------
try oscillating the hue of your particles
add the code below to your draw() function
-------------------------------------- */
var time = Date.now() * 0.0005;
h = ( 360 * ( 1.0 + time ) % 360 ) / 360;
material.color.setHSL( h, 0.5, 0.5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment