# How to merge meshes from imported 3D Model (glb or gltf)?

**URL:** <https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [July 9, 2022, 2:50pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152 "2022-07-09T14:50:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamuelSub](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/samuelsub/32/27890_2.png) [@SamuelSub](https://discourse.threejs.org/u/SamuelSub)\
**Post date:** [July 9, 2022, 2:50pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/1 "2022-07-09T14:50:55Z")

</div>

Hi! I am new to ThreeJS and I would love some help on this one. I am importing a 3d model into my Threejs scene and I want to create many clones of that model, I tried the .clone() method but when the number of the clones starts to go up the performance drops quite a lot. (i logged some renderer info and the draw calls were about 1200+ and the triangles were more than a million for about 20 cloned models).

I saw from my research that they were recommending using InstancedMesh or merging the meshes into one but I am not entirely sure how to implement that with an imported 3D model.

Thank you for your time!

---

<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:** [July 9, 2022, 6:36pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/2 "2022-07-09T18:36:17Z")

</div>

This example includes code that creates an InstancedMesh from geometries imported from GLB files:

[https://threejs.org/examples/?q=scatter#webgl\_instancing\_scatter](https://threejs.org/examples/?q=scatter#webgl_instancing_scatter)

---

<div class="post-metadata">

**Author:** ![SamuelSub](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/samuelsub/32/27890_2.png) [@SamuelSub](https://discourse.threejs.org/u/SamuelSub)\
**Post date:** [July 10, 2022, 1:02pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/3 "2022-07-10T13:02:57Z")

</div>

Thank you for your reply! I tried to do the same as in the example but get the following error:

![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/5/5535ba4cf8be27ebea8d82b9c63936c83ae71748.png)

My Code:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/7/7/774bbacc4547e6f9c3d55eb2105b05bef328fb2c.png)

---

<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:** [July 10, 2022, 1:51pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/4 "2022-07-10T13:51:47Z")

</div>

This would imply `Scene` is not a THREE.Mesh. It may be a Group or an Object3D, containing one or more mesh. If the model contains many meshes you will need to construct an InstancedMesh for each one.

---

<div class="post-metadata">

**Author:** ![SamuelSub](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/samuelsub/32/27890_2.png) [@SamuelSub](https://discourse.threejs.org/u/SamuelSub)\
**Post date:** [July 10, 2022, 2:08pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/5 "2022-07-10T14:08:34Z")

</div>

It is indeed an Object3D. I traversed the object and put the geometry in an array, when I console.log() the array this is what it shows:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/d/4dafeb75becb932f695269be84c76340660bea80.png)

How exactly can I construct an InstancedMesh for each one? Sorry for asking so many questions but I am new to Threejs

---

<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:** [July 11, 2022, 12:58am UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/6 "2022-07-11T00:58:23Z")

</div>

It sounds like you have maybe 85 draw calls _per model_. If total draw calls are around 1200 then that’s roughly 15 instances of the model. I’m not sure I’d recommend using instancing in this case. The model itself should be simplified. The [gltfpack](https://github.com/zeux/meshoptimizer#gltfpack) tool is often a good place to start, or editing the model in Blender, or finding a simpler source model.

---

<div class="post-metadata">

**Author:** ![D13](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@D13](https://discourse.threejs.org/u/D13)\
**Post date:** [July 11, 2022, 2:36pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/7 "2022-07-11T14:36:29Z")

</div>

Make a CodePen of your model. We can take a look from there.

InstancedMesh is intended to create multiple clones (Instances) of the same geometry. So if you want to create 1000 copies of the same geometry, with the same material, and each one be an indexed child of a parent geometry, then InstancedMesh is what you want.

If you have 1000 different geometries that you want as children of a parent geometry, all using the same material, then you want a merged BufferGeometry (BatchedMerge).

After those 2 usecases it gets complicated.

---

<div class="post-metadata">

**Author:** ![SamuelSub](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/samuelsub/32/27890_2.png) [@SamuelSub](https://discourse.threejs.org/u/SamuelSub)\
**Post date:** [July 11, 2022, 3:25pm UTC](https://discourse.threejs.org/t/how-to-merge-meshes-from-imported-3d-model-glb-or-gltf/40152/8 "2022-07-11T15:25:27Z")

</div>

Thanks for the clarification!

I have the whole code in this repo: [https://github.com/SamuelSub/threejs-demo](https://github.com/SamuelSub/threejs-demo)
