Most efficient way to place many points in a BufferGeometry – all at once or staggered?

Hi everyone :slight_smile:

So, I realised thanks to the answers in my previous thread that I need to create a BufferGeometry with a lot of points and then just increase the draw range if I want to make points appear progressively. That’s all good.

Now I’m wondering, should I place all of them initially or should I position them progressively as I need more?

To give you some context, the geometry is a large star field that takes up the whole screen, and doesn’t scale with the window (so if you have a tiny window you’ll only see a tiny portion of it).
I’m wondering if I should create all of it on initialisation or use a window resize event to know when more of the stars become visible and position them at that moment.

I guess you should also phrase it this way: is a geometry with 10,000 vertices equivalent to one that’s only 100 vertices, performance-wise, if only 100 are visible in both cases?

This is probably a noobish question and I might have misunderstood some core concepts, sorry about that – bear with me as I understand more of how three.js works :blush:

It does not matter what kind of data are in your buffer. The same amount of memory is allocated either way. You can easily check this by creating a typed array with a particular size. The respective buffer is completely initialized with default values (e.g. zeros). The drawRange determines how much of this data are actually processed by the WebGL graphics pipeline.


Ah, right. I guess that means I’ll have to rewrite stuff… :sob:

Oh well – I’ll probably end up with a leaner solution. Thanks!