# Buffergeometry, setDrawRange and performance

**URL:** <https://discourse.threejs.org/t/buffergeometry-setdrawrange-and-performance/5662>\
**Category:** Questions\
**Created:** [January 8, 2019, 10:20pm UTC](https://discourse.threejs.org/t/buffergeometry-setdrawrange-and-performance/5662 "2019-01-08T22:20:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheHappyKoala](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thehappykoala/32/6074_2.png) [@TheHappyKoala](https://discourse.threejs.org/u/TheHappyKoala)\
**Post date:** [January 8, 2019, 10:20pm UTC](https://discourse.threejs.org/t/buffergeometry-setdrawrange-and-performance/5662/1 "2019-01-08T22:20:15Z")

</div>

I want to be able to dynamically add particles to a scene, but I know that once you populate a buffergeometry with a given amount of vertices, that’s what you have to work with.

So, my idea is to create a buffergeometry for 40000 vertices, which means the array will have a length of 120000. Most of the time I’ll only want to render, say, 4000 particles, though, and my thinking is that I can have the cake and eat it, too, by using the setdrawrange method and set the range equal to 0 - 3999 particles in this hypothetical case.

Sounds too good, to be true, though… So how does having a buffer geometry for 4000 vertices with an array with a length of 12000 compare to the scenario I dreamt up above in terms of performance? Is it a big hit?

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [January 8, 2019, 10:44pm UTC](https://discourse.threejs.org/t/buffergeometry-setdrawrange-and-performance/5662/2 "2019-01-08T22:44:53Z")

</div>

I think that’s the right approach. You’ll be allocating the full amount of memory, but cost of rendering will be “only what you need”. See the _Shared BufferGeometry_ section here: [https://blog.mozvr.com/a-painter-performance-optimizations/](https://blog.mozvr.com/a-painter-performance-optimizations/).

---

<div class="post-metadata">

**Author:** ![TheHappyKoala](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thehappykoala/32/6074_2.png) [@TheHappyKoala](https://discourse.threejs.org/u/TheHappyKoala)\
**Post date:** [January 8, 2019, 10:54pm UTC](https://discourse.threejs.org/t/buffergeometry-setdrawrange-and-performance/5662/3 "2019-01-08T22:54:25Z")

</div>

Awesome! Thanks.
