0

I have the following simple function which is supposed to produce a simple flame effect, I build the actual display part of the code from here:

http://jeromeetienne.github.io/sparkseditor/

Whenever I run the function it seems to exhaust the pool (max particles) and then die, with no visible trace of it on the screen. I'm using r53, whereas many if not all of the sparks.js examples use r47, not sure if this is relevant.

You can find the actual file producing the error over here:

http://jeromeetienne.github.io/threex/docs/threex.sparks.html

And the code for my flame below:

  var position = data.status.position;
  var group = new Object3D();

  scene.add(group);

  var sparks = new THREEx.Sparks({
     maxParticles : 10,
     counter : new SPARKS.SteadyCounter(300)
  });

  var emitter   = sparks.emitter();

  var color = function() {
     this.initialize = function(emitter, particle) {
        particle.target.color().setHSV(0.4, 0.8, 0.4);
        particle.target.size(100);
     };
  };

  emitter.addInitializer(new color());
  emitter.addInitializer(new SPARKS.Position(new SPARKS.PointZone(new THREE.Vector3(

     position.x, position.y, position.z

  ))));
  emitter.addInitializer(new SPARKS.Lifetime(0, 0.8));
  emitter.addInitializer(new SPARKS.Velocity(new SPARKS.PointZone(new THREE.Vector3(

     position.x, position.y-100, position.z

  ))));
  emitter.addAction(new SPARKS.Age());
  emitter.addAction(new SPARKS.Move());
  emitter.addAction(new SPARKS.RandomDrift(1000,0,1000));
  emitter.addAction(new SPARKS.Accelerate(0,-200,0));

  emitter.addCallback('created', function(particle) {
     group.add(particle);
  });
  emitter.addCallback('dead', function(particle) {
     particle.target.visible = false;
     group.remove(particle);
  });

  emitter.start();

Thanks in advance, any help is much appreciated :)

jahilldev
  • 3,520
  • 4
  • 35
  • 52
  • 1
    Spark.js is outdated and not compatible with latest versions of Three.js. I highly recommend using latest Three.js version, you won't get much support for older versions. This probably means you need to use only Three.js particle system without spark.js. You should use `ShaderMaterial`. – Najam-us-Saqib May 28 '13 at 02:39
  • I got same problem as you have. I searched for the problem than come to know that `SPARK-js` is no more supported and for `particle system` we should use either the latest version or go for the `shaders` – Najam-us-Saqib May 28 '13 at 02:43

1 Answers1

0

I have recently written a Particle Engine that is capable of the special effects, including flame effects, which currently works with Three.js v.56:

http://stemkoski.github.io/Three.js/Particle-Engine.html

There is an accompanying blog post at http://stemkoski.blogspot.com/2013/06/creating-particle-effects-engine-in.html that contains related details. Perhaps this code can be adapted to suit your needs?

Hope this helps!

Stemkoski
  • 8,936
  • 3
  • 47
  • 61