I recently started using the ShaderParticleEngine library in Three.js to set up particle emitters.
After browsing through various code snippets online, I managed to get an emitter up and running. Initially, I thought it wasn't working as I could only see a single stationary particle on the screen.
Upon closer inspection, I realized that the particle was indeed moving, but at an extremely slow rate. It was only when I used tick(delta * 1000)
that the emitter started showing some action. However, the outcome was far from ideal, with gaps and isolated particles.
Despite not having any issues with low FPS, I decided to remove the delta argument in the tick function call: particleGroup.tick()
.
Although the result improved slightly, it was still disappointing. See for yourself:
Online Emitter Editor:
My Result:
I'm puzzled by this inconsistency. I've utilized the same code provided in the library examples and exported the settings from the emitter editor. However, any minor tweaks I make, like adjusting particle life or velocity, yield drastically different outcomes in my game. Could it be that the particle life calculation is affected by the absence of the delta argument?
Here's a snippet from my game loop:
var animate = function () {
requestAnimationFrame( animate );
render();
stats.update();
};
var render = function() {
time = ctx3d.clock.getElapsedTime();
delta = ctx3d.clock.getDelta();
particleGroup.tick(delta);
if(ctx3d.move)
{
ctx3d.ship.position.z += delta * 500 * 3000;
//ctx3d.camera.position.x = ctx3d.ship.position.x;
//ctx3d.camera.position.z = ctx3d.ship.position.z;
}
ctx3d.renderer.render(ctx3d.scene, ctx3d.camera);
}
Delta values per loop:
30.0000010000003385357559 9.999985195463523e-7 30.0000020000006770715117 0.0000010000003385357559 30.0000020000006770715117 0.0000010000003385357559 0.0000020000006770715117 30.0000010000003385357559 0.000002999999196617864 0.0000010000003385357559 9.999985195463523e-7 0.000002999999196617864 0.0000010000003385357559 0.000001999998858082108 0.0000010000003385357559 20.0000020000006770715117 9.999985195463523e-7 0.0000010000003385357559