javascript - Flame is not showing in THREE.js World -
i making flame using three.js , spark.js, when render world can't see flame , world empty. saw console error there no error regarding this. tried lot can't find out actual error. here code.
threexsparks = new threex.sparks({ maxparticles : 400, counter : new sparks.steadycounter(300) }); //threexsparks.position.x = 1000; // setup emitter //var emitter = threexsparks.emitter(); var counter = new sparks.steadycounter(500); var emitter = new sparks.emitter(counter); var initcolorsize = function() { this.initialize = function(emitter, particle) { particle.target.color().sethsv(0.3, 0.9, 0.4); particle.target.size(150); }; }; emitter.addinitializer(new initcolorsize()); emitter.addinitializer(new sparks.position(new sparks.pointzone(new three.vector3(1000, 0, 0)))); emitter.addinitializer(new sparks.lifetime(0, 0.8)); emitter.addinitializer(new sparks.velocity(new sparks.pointzone(new three.vector3(0, 250, 00)))); 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));
thanks
tere strange problems particles , webgl render. if you're using canvasrender. webgl not. in code forgot creating threejs objects particles. sparks.js allows interface particles. need create particles itself. can @ jsfiddle example. there use modified version of sparks.js library. changes able override vectorpool behaviour.
main part there is:
var particlecount = 1800, particles = new three.geometry(), //store particle vertices pmaterial = new three.particlebasicmaterial({ size: 10, map: txture, //in jsfiddle create texture canvas transparent: true }); var particlesystem = new three.particlesystem(particles, pmaterial); //threejs particle system //initialize our particles (and set dirty). sparkjs initialize later for(var p = 0; p < particlecount; p++) { v = new three.vector3(nummax,nummax,nummax); v.isdirty=true; particles.vertices.push(v); } sparks.vectorpool.__pools = particles.vertices; //initialize vectors pool
and there new vector pool sparksjs
sparks.vectorpool = { __pools: [], get: function() { var ret = _.find(this.__pools, function(v){return v.isdirty}); ret.isdirty=false; return ret; }, release: function(v) { v.isdirty=true; v.set(nummax,nummax,nummax); } };
of course must care count of partices used in sparks.js , precreated hands.
my sparkjs fork here: https://github.com/elephanter/sparks.js there fix problem lastest tweenjs , add other little changes described before.
Comments
Post a Comment