4.1: Particle System Simulation - The Nature of Code

preview_player
Показать описание


References:

Videos:

Timestamps:
0:00 Welcome to chapter 4!
0:24 What is a particle system?
1:24 What do we have to code?
2:01 Let's make a particle class!
2:46 Adding a lifetime property.
3:41 Many particles!
5:16 Emitting particles.
5:51 Removing finished particles from the array.
7:59 Let's make a few tweaks to this system?
8:55 What's next?

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#forbeginners #javascript #p5js
Рекомендации по теме
Комментарии
Автор

I wonder how many people are here to learn about the basics of JS versus how many have been coding with Dan for years and just find his voice and infectious enthusiasm comforting.

ShaneDavisDFTBA
Автор

As a side-note: particle emitters are commonly implemented with what's called an 'Object Pool' as a means to improve memory and even some runtime efficiency; especially when there are A LOT of particles in the simulation! An object pool is basically a specially maintained array of Particle objects which are created, but not [yet] used; and when unused: they're set to some disabled, hidden state. The particle emitter can get particle instances from this pool whenever particles are needed and [re]set them to the needed effect. And more importantly: the emitter can return particles which have completed their visual effect back to the pool for recycling - versus simply removing them from the array. This is just the basic description, but something for folks to explore more if they're curious about how to manage scenarios like having lots of particle emitters emitting lots of particles! Great video as always, Dan!

steveneiselen
Автор

This seems like a video that I never realised I wanted the most

sanathkumar
Автор

Been watching your vids for a couple years now, they're amazingly educational and you're a really great guy, no better man for the job!

VenomSwitch
Автор

I love the way you explain things in the purest form. Nice one!

shreyasshrawage
Автор

Everytime I come to your channel, I learn a lot of new things. Thanks

itspyguru
Автор

Love the way you teach, May god bless you!

natiqueibrar
Автор

Loooove the quick history lesson at the beginning! Great vid!

DEATHBYFIRE
Автор

I watched the original series back in 2014 or 2015 I think, and man this is a trip through memories lane. Made me wish to re-read the book and go over the videos again.

Dgiulian
Автор

For optimization of clearing the finished particles,
You could actually remove the particle after the particle.update() using an indexed loop there

BarYamin
Автор

Really helpful thank you, helped me to understand particles better and how to implement them.

kieranmcdermott
Автор

Thanks for recommending the paper.. I spent the day reading through it.

jujijiju
Автор

Amazing video! You should try adding more things to the particle system, such as wind and movement noise.

Will-Eves
Автор

Ooo more firework particle systems potential

NinjaTyr
Автор

Instead of splice & for-loop you could use:
particles = particles.filter(p => !p.finished())

Gazzar
Автор

Hey! I'm wondering can we use a shift() function instead of the splice() function, because the particles created after each other, so the first element would be removed 'cause it has faded away first. Can it be possible? or this function is much slower than the splice()?

molesz
Автор

There are a few things for the particle-system video that should be considered:
Particle-systems in general are used to simulated many simply objects - the purpose is to have a single handler that dictates the behaviour of the particles and do that as efficiently as possible to be able to display many particles.

For that it is better to not use the particles as classes with functions but just simple data-structures inside the particle-system class.
So updating and drawing the particles would all be functions of the particle-system, not the particles. This can make the handling of lifetime simpler as well - in the list the particles are ordered by their lifetime so while iterating and updating the particle you can also check for the remaining lifetime (only if they are inserted in order of their lifetime). If that reached zero you can remove ALL remaining particles at once as they are all older than the current particle. Like that the properties of how to display the particles also does not need to be changed for each particle.

ABaumstumpf
Автор

Please consider pausing a moment before changing files when making a code change, for example at 2:34

bobmvideos
Автор

Hey Daniel, i suggest you do something different or more advanced . You have done the same thing before right? Tnx, ur best subscriber here. ( U were my starting point in codeing)

mr.mirror
Автор

Wouldn't it make sense for each particle object to check its own lifetime each time it updates, instead of having to run through the entire array each time? But I'm guessing the issue is that the particle class can't easily access the array defined in the main program...

xnick_uy