# BufferGeometry: toIndexed

**URL:** <https://discourse.threejs.org/t/buffergeometry-toindexed/1334>\
**Category:** Resources\
**Tags:** optimization, buffergeometry, performance\
**Created:** [December 3, 2017, 12:24pm UTC](https://discourse.threejs.org/t/buffergeometry-toindexed/1334 "2017-12-03T12:24:15Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [August 29, 2019, 4:32am UTC](https://discourse.threejs.org/t/buffergeometry-toindexed/1334/8 "2019-08-29T04:32:59Z")

</div>

> [@Fyrestar](#):
>
> You shouldn’t hope it optimizes it somehow for you, anything with clear cases you can tell the compiler in advance, such as initialization values avoids a lot steps.

Thank you for your insight. Would it also help the engine to do this?

```javascript
if (! ([1,2,3,4].includes(itemSize) ) {
    console.error("Invalid itemSize %d.", itemSize);
    return null;
}

```

Now the subsequent nested loop can in principle be unrolled on the valid itemSize cases statically.

> [@](#):
>
> There shouldn’t be even the case none is present, optimally the bounding sphere and box should be delivered with the asset, it isn’t really for free computing those.

OK. I agree that it is wise to deliver them with the asset. (I am not used to thinking in assets, as I like to generate geometry on the fly.) But what if your user is not done moving the vertices? Then the automatic `computeBoundingSphere` is just an annoying extra wait. To me it looks a bit like you are “forcing” _your_ way onto the user, since the `else` clauses are for specifically those cases where no bounding sphere is present yet, which may have been a user choice, (e.g. because that happens later in their workflow.) But it’s no big deal, of course. Easy to change if any of the conservative voices among the three.js maintainers asks.

I hope your PR gets merged, as this would be a nice addition to three.js. 🙌

---

_[View the full topic](https://discourse.threejs.org/t/buffergeometry-toindexed/1334)._
