# Import GLB containing primitives and rename meshes

**URL:** <https://forum.babylonjs.com/t/import-glb-containing-primitives-and-rename-meshes/35373>\
**Category:** Questions\
**Tags:** glb\
**Created:** [November 3, 2022, 1:10pm UTC](https://forum.babylonjs.com/t/import-glb-containing-primitives-and-rename-meshes/35373 "2022-11-03T13:10:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [November 3, 2022, 1:10pm UTC](https://forum.babylonjs.com/t/import-glb-containing-primitives-and-rename-meshes/35373/1 "2022-11-03T13:10:45Z")

</div>

I have a couple of models of houses in Blender which I export to GLB e.g. `house_2.glb` and `house_3.glb`. Both are made up of multiple meshes like “door”, “window” etc.  
When I import them I want to be able to then clone specific parts of each house to construct new houses. To do this I need to be able to specifically reference each component. Previously I was using `scene.getNodeByName` however with multiple “door”, “window”, etc. meshes now being imported this does not work anymore.

I am using react-babylonjs and the `useAssetManager` hook. In the onSuccess callback I rename the meshes to prepend the file name e.g. the `result.loadedMeshes.forEach(m => m.name = ("house_3_" + m.name))` below:

```typescript
tasks = [
    {
        taskType: TaskType.Mesh,
        name: "load house_3",
        rootUrl: "/public/models/house/",
        sceneFilename: "house_3.glb",
        onSuccess: result =>
        {
            const root = result.loadedMeshes.find(m => m.name === " __root__")
            root?.setEnabled(false) // disable the root which will hide all meshes of the imported model
            if (root)
            {
                result.loadedMeshes.forEach(m => m.name = ("house_3_" + m.name))
                success()
            }
            else reject("Can not find house_3.glb")
        },
        onError: reject
    },
]

useAssetManager(tasks)

```

This seems to work well for meshes where only one material is used however when I have used multiple materials, e.g. for colouring the inside of a chimney black with soot and the outside grey stone, or the tread of some stairs being a different colour to the stair material, then when these meshes are imported they become: `chimney_primitive0` and `chimney_primitive1` etc.  
I can rename these primitives to `house_3_chimney_primitive0` but then the `scene.getNodeByName` stops working as in their “node form” they are still refered to as `chimney`, `stairs`, etc. instead of `house_3_chimney`

I would like to avoid having to append the model name to each of the meshes in Blender before I export them as these seems clunky and error prone. Is there a solution or a better approach to this?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 3, 2022, 5:10pm UTC](https://forum.babylonjs.com/t/import-glb-containing-primitives-and-rename-meshes/35373/2 "2022-11-03T17:10:17Z")

</div>

> [@ajp](#):
>
> result.loadedMeshes

Maybe use result.loadedTransformNodes as well ?

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [November 3, 2022, 5:42pm UTC](https://forum.babylonjs.com/t/import-glb-containing-primitives-and-rename-meshes/35373/3 "2022-11-03T17:42:10Z")

</div>

Perfect. Thanks. Yes I just had to upgrade my dependencies (now at version 5.31.0) and I can now see the `loadedTransformNodes` array. I now run:

```typescript
result.loadedMeshes.forEach(m => m.name = ("house_3_" + m.name))
result.loadedTransformNodes.forEach(m => m.name = ("house_3_" + m.name))
success()

```
