# mergeVertices colors mapping problem

**URL:** <https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [July 7, 2019, 10:36am UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418 "2019-07-07T10:36:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [July 7, 2019, 10:36am UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418/1 "2019-07-07T10:36:07Z")

</div>

Hi.

I am using Geometry.mergeVertices method and I have realized that colors are not properly mapped after merging.

In my case I have a IndexedBufferGeometry which I convert into a geometry with:  
geometry = new THREE.Geometry().fromBufferGeometry( geometry );

After doing this colors i Geometry are ok.

But after applying mergeVertice they don’t.  
geometry.mergeVertices();

It seems that this method doesn’t take in mind colors.

Is there any fix for this?

Best regards

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [July 7, 2019, 11:08am UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418/2 "2019-07-07T11:08:21Z")

</div>

> [@Alejandro\_Insua](#):
>
> It seems that this method doesn’t take in mind colors.

Any chances to demonstrate this issue with a [live example](https://jsfiddle.net/f2Lommf5/)? Right now, it’s hard to understand the expected and actual visual result.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [July 8, 2019, 5:27am UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418/3 "2019-07-08T05:27:34Z")

</div>

Hi.

Today I will try to push a live example.

It’s quite easy to demonstrate with a merged BufferGeometry composed of multiple bufferGeometries with different colors.

Best regards

---

<div class="post-metadata">

**Author:** ![gkjohnson](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gkjohnson/32/2298_2.png) [@gkjohnson](https://discourse.threejs.org/u/gkjohnson)\
**Post date:** [July 8, 2019, 4:23pm UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418/4 "2019-07-08T16:23:17Z")

</div>

`mergeVertices` in the `BufferGeometryUtils` example should (if I remember right) account for multiple vertex attributes in a geometry and correctly retain vertex colors:

> <https://github.com/mrdoob/three.js/blob/f7efa14bcc8b470c071bec277be7bafbfbeb4735/examples/jsm/utils/BufferGeometryUtils.js#L488>

I think in general it’s considered best to not use `Geometry` if you can avoid it.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Insua](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/alejandro_insua/32/3958_2.png) [@Alejandro\_Insua](https://discourse.threejs.org/u/Alejandro_Insua)\
**Post date:** [July 22, 2019, 6:13am UTC](https://discourse.threejs.org/t/mergevertices-colors-mapping-problem/8418/5 "2019-07-22T06:13:45Z")

</div>

Hi

Very sorry for the delay.

I have been on vacations in a place with no internet connection. Really nice.

: )

I will try this option and will keep you informed,

Best regards
