Skip to content

Instantly share code, notes, and snippets.

@zz85
Created February 28, 2012 17:21
Show Gist options
  • Save zz85/1933802 to your computer and use it in GitHub Desktop.
Save zz85/1933802 to your computer and use it in GitHub Desktop.
Annotated Code Segment for Snow Scene
// Produces 50 snow particles every second
particleProducer = new SPARKS.SteadyCounter( 50 );
// Create the sparks.js Emitter
sparksEmitter = new SPARKS.Emitter( particleProducer );
// This defines that snow should emit from an plane like area
// instead of a point, giving the feel of snow falling from the sky
var zone = new SPARKS.ParallelogramZone(
new THREE.Vector3(-1400,800,-1000),
new THREE.Vector3(2800,0,0),
new THREE.Vector3(0,0,2000));
sparksEmitter.addInitializer(new SPARKS.Position( zone ));
sparksEmitter.addInitializer(new SPARKS.Lifetime( 5, 8 ));
// Let the snow fall to the ground
sparksEmitter.addInitializer( new SPARKS.Velocity( new SPARKS.PointZone( new THREE.Vector3( 0, -100, 0 ) ) ) );
sparksEmitter.addAction( new SPARKS.Age() );
sparksEmitter.addAction( new SPARKS.Move() );
// Make the snow move faster
sparksEmitter.addAction( new SPARKS.Accelerate( 40, -100, 50 ) );
// Make the snow move in random directions
// This is sufficient to give a natural random like motion of snow
sparksEmitter.addAction( new SPARKS.RandomDrift( 800 , 100, 800 ) );
// When mark the snow as dead after it hits the ground
sparksEmitter.addAction( new SPARKS.DeathZone( new SPARKS.CubeZone(
new THREE.Vector3(-5000, FLOOR, -5000),
10000, -5000, 10000
) ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment