Jump to content

Particles Emitter Position Delay


Phuein
 Share

Recommended Posts

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? :P 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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...