Show All

// Chrome Experiments #1000 Editor! // Press the run button to the right to see your changes 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 % size; var y = Math.floor( particle.index / size ) % size; var z = Math.floor( particle.index / ( size * size ) ); 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.position.x + particle.position.y + particle.position.z; particle.position.copy( particle.originalPosition ); particle.position.y += Math.sin( currentTime + offset * 0.04 ) * 8; } }