zz85 / sparks.js

a lightweight 3d particle engine in javascript, compatible with THREE.js and TWEEN.js
435 stars 47 forks source link

SPARKS.RandomDrift/Accelerate should accept a Zone ? #7

Closed jeromeetienne closed 12 years ago

jeromeetienne commented 12 years ago

if i understand zone concept, i think randomdrift/accelerate may benefit in accepting a zone.

Currently they accept x,y,z raw. it seems a bit like a SPARKS.PointZone.

what do you think ?

zz85 commented 12 years ago

Zones are basically to describe a area / volume of space.

It can be used for particle emission, but can also be used for actions.

I could add a few more classes to illustrate this, and think of a way to chain Actions to Zones, but meanwhile you could try to modify RandomDrift to perhaps a RandomDriftInZone class.

zz85 commented 12 years ago

I've added a new class called ActionZone, which takes in an action and zone.

An example can be found in examples/tests_sandbox.html

            sparksEmitter.addAction(new SPARKS.ActionZone( 
                new SPARKS.Accelerate(0, 0, 1000),
                new SPARKS.CubeZone( new THREE.Vector3(20,20,0), 30, 30, 100 ) ) );

This means that any particles found in the cube zone would get an acceleration action applies on them.

zz85 commented 12 years ago

hmm, I think I misunderstood your point here.. if you have a use case for this, i could see where i could change the classes

jeromeetienne commented 12 years ago

too old. closing :)