I have a particles emitter. I create a sphere and position it. Then I create the particle system. But the particles start in the original position, too. They continue in the new position, but the first ones are created and eventually fade from the starting position, too, which is unwanted. Now let's just talk code.
https://www.babylonjs-playground.com/#MX2Z99#9
I added this:
coreSphere.position = new BABYLON.Vector3(0, 5, -5)
If you can't see the particles in the new position, turn the camera around until you do. After a few seconds the old ones dissipate. If I do preventAutoStart = true and start() the particles with a delay, like 1 second, it works as expected without particles in the original position.
EDIT: I'm realizing it's because of
// Pre-warm
surfaceParticles.preWarmStepOffset = 10;
surfaceParticles.preWarmCycles = 100;
But still don't know what to do about it. The preWarm is necessary for the effect, after all. I'd expect it to warm-up in the right position.
EDIT 2: Going over the engine code, I'm seeing surfaceParticles.startDelay = 1 (millisecond) solves this order issue, but still seems like a bug worth noticing?
Well, it needs more delay the bigger the object, too. So random guess-solution.
https://github.com/BabylonJS/Babylon.js/blob/master/src/Particles/babylon.baseParticleSystem.ts
EDIT 3: Figured I'll try a scene-ready function, as a delay is unreliable when there's some lag. Using:
scene.onReadyObservable.add(() => {
surfaceParticles.start()
})
Seems to work. Is this reliable?