# Merge points of pcd files

**URL:** <https://discourse.threejs.org/t/merge-points-of-pcd-files/39135>\
**Category:** Questions\
**Tags:** points, pcd-format\
**Created:** [June 10, 2022, 9:43pm UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135 "2022-06-10T21:43:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashutosh\_Sharma](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ashutosh_sharma/32/26983_2.png) [@Ashutosh\_Sharma](https://discourse.threejs.org/u/Ashutosh_Sharma)\
**Post date:** [June 10, 2022, 9:43pm UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/1 "2022-06-10T21:43:32Z")

</div>

Hello everyone, this is my first query here. I am new to Three.JS and I wanted to know is it possible to merge points of one pcd file to another pcd file. If possible, then can it be done without loosing the RGB properties of each file.

---

<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:** [June 11, 2022, 8:11am UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/2 "2022-06-11T08:11:15Z")

</div>

`three.js` does not provide a PCD exporter so you have to write the logic by yourself. The actual merge of geometries in `three.js` can be done with [BufferGeometryUtils.mergeBufferGeometries()](https://threejs.org/docs/index.html#examples/en/utils/BufferGeometryUtils.mergeBufferGeometries).

It is of course possible to retain vertex colors. Just keep in mind that partial color definitions are not supported. Meaning if you merge two point clouds but only one of them has vertex colors, you have to define default values for the other one (e.g. white).

---

<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:** [June 11, 2022, 9:14am UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/3 "2022-06-11T09:14:14Z")

</div>

/cc

> <https://stackoverflow.com/questions/72580051/appending-points-to-pcd-in-threejs>

---

<div class="post-metadata">

**Author:** ![Ashutosh\_Sharma](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ashutosh_sharma/32/26983_2.png) [@Ashutosh\_Sharma](https://discourse.threejs.org/u/Ashutosh_Sharma)\
**Post date:** [June 13, 2022, 8:43am UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/4 "2022-06-13T08:43:24Z")

</div>

Thanks for the reply, can you please also explain the merging with an example for PCDLoader?

---

<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:** [June 13, 2022, 8:45am UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/5 "2022-06-13T08:45:02Z")

</div>

Well, you do the merge essentially like in [webgl\_geometry\_minecraft](https://threejs.org/examples/webgl_geometry_minecraft).

Instead of plane geometries like in the example, you use the geometries from your point clouds. The usage of `BufferGeometryUtils.mergeBufferGeometries()` is the same.

---

<div class="post-metadata">

**Author:** ![Ashutosh\_Sharma](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ashutosh_sharma/32/26983_2.png) [@Ashutosh\_Sharma](https://discourse.threejs.org/u/Ashutosh_Sharma)\
**Post date:** [June 13, 2022, 8:46am UTC](https://discourse.threejs.org/t/merge-points-of-pcd-files/39135/6 "2022-06-13T08:46:31Z")

</div>

Thanks alot
