Skip to content

Instantly share code, notes, and snippets.

@dsdshcym
Last active December 1, 2015 05:47
Show Gist options
  • Save dsdshcym/7703f49783b1a7ea222d to your computer and use it in GitHub Desktop.
Save dsdshcym/7703f49783b1a7ea222d to your computer and use it in GitHub Desktop.
var spacing = 15;
var size = 10;
var center = new THREE.Vector3( 1, 1, 1 );
center.multiplyScalar( Math.floor( size / 2 ) );
return {
init: function( particle, i ) {
var x = particle.index;
var y = 0;
var z = 0;
particle.position.set( x, y, z );
particle.position.sub( center );
particle.position.multiplyScalar( spacing );
particle.originalPosition = new THREE.Vector3().copy( particle.position );
},
update: function( particle, currentTime ) {
var offset = particle.index - 500;
particle.position.copy( particle.originalPosition );
if (particle.index % 2 == 1) {
particle.position.x = offset / 250.0 * 25
particle.position.y = Math.sqrt(1-Math.pow(Math.abs(offset / 250.0) -1, 2)) * 25 + 25 + Math.sin(currentTime) * 5
} else {
particle.position.x = offset / 250.0 * 25
particle.position.y = (Math.acos(1-Math.abs(offset / 250.0))-Math.PI) * 25 + 25 + Math.sin(currentTime) * 5
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment