Stalight Starbright

In this topic @Wingnut asked

But… WHAT IF… ANY mesh shape can be an emitter

Here is a step to step approach to trying to answer that question.

  1. Create a complex mesh shape Babylon.js Playground

  2. Add a function that calculates interior points of the mesh and then fill it with spheres for example, https://www.babylonjs-playground.com/#2K3T61#1

  3. Make the spheres with SPS, add color and wobble them about a bit https://www.babylonjs-playground.com/#2K3T61#2

  4. Return to the original question and emit particles based on the mesh shape https://www.babylonjs-playground.com/#2K3T61#4. BEWARE there is something wrong in my code. To rerun you MUST refresh the BROWSER. Clicking on RUN seems to add particles and so points[particle.id] tries to find an entry in the array larger than the number in the array. Perhaps someone can find my error!

EDIT
4 PG corrected https://www.babylonjs-playground.com/#2K3T61#7.

12 Likes

Woot! This is really cool! I love it

Wondering if this should be mentioned in the doc actually

It is my intention to add the createInnerPoints function to the utilities sub-section of the snippets section probably just with the first PG. Any insight into the not being able to use the RUN would be welcomed.

This is probably because you cannot reuse particle.id as the value will keep incrementing (It is not the particle index in the array unfortunately but a unique number: Babylon.js/babylon.particle.ts at master · BabylonJS/Babylon.js · GitHub)

Note to self - stop making assumptions :woozy_face:

1 Like

that is so nice

Hey @Dad72… here I needed the “agree” button, so I could agree with Naz. So, thats:

Like (old forum)
Thanks (old)
Laugh (old)
Confused (old)
Sad (old) (rarely used)
Agree (new button)

That’s a lot of data to store. :slight_smile:

But yeah, johnK… fabulous demos, THANK YOU! That’s VERY kind of you to remember, and follow-up-on one of my future-hopes. Well done! (hug) You have opened some very large and pretty doors.