-
-
Save nbriz/d994b193cd2090cb93bf to your computer and use it in GitHub Desktop.
create particles, for threejs_playGnd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------- 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