# Newbie question about editing of scene in javascript

**URL:** <https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302>\
**Category:** Questions\
**Tags:** documentation, gui\
**Created:** [March 10, 2022, 2:47pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302 "2022-03-10T14:47:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesG](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@DesG](https://forum.babylonjs.com/u/DesG)\
**Post date:** [March 10, 2022, 2:47pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/1 "2022-03-10T14:47:30Z")

</div>

Hello

I’m fairly new to Babylon,though I have used the basic viewer in the past. I have a reasonable understanding of gltf and have written a simple exporter for my configurator application. My gltf file describes a fairly simple model consisting of a number of top level nodes with each node referencing one of a large number of possible meshes each with a distinct transformation - not all of the possible meshes are referenced in the model at any one time. I’m looking for a way to swap node meshes from the model in javascript after it has been loaded into Babylon via LoadMeshAsync.

The model displays fine, but when I inspect it in javascript I notice that it seems to be optimised and only contains the meshes from the gltf which are referenced in the scene.

How would I go about loading all meshes and then programmatically swapping them in the current scene model? I’m guessing I need to use an asset container. Can anyone point me to any relevant documentation or (even better) some code examples?

On a related note. Is it possible to load a gltf model held locally as a javascript string into the Babylon viewer?

PS sorry if this question appears twice.

---

<div class="post-metadata">

**Author:** ![musk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/musk/32/17156_2.png) [@musk](https://forum.babylonjs.com/u/musk)\
**Post date:** [March 10, 2022, 4:14pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/2 "2022-03-10T16:14:56Z")

</div>

> [@DesG](#):
>
> only contains the meshes from the gltf which are referenced in the scene

Can you create a repro in the playground ?  
It looks like you used the first parameter of **ImportMeshAsync**

- 
##### meshNames: any

an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported

> [@DesG](#):
>
> programmatically swapping them in the current scene model

Like this ?

> **[Babylon.js Playground](https://playground.babylonjs.com/#XHTDPY)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

PS: You can return to the top of the list by replying to yourself. Don’t worry, I’ve hardly seen an unanswered topic.

---

<div class="post-metadata">

**Author:** ![DesG](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@DesG](https://forum.babylonjs.com/u/DesG)\
**Post date:** [March 10, 2022, 10:04pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/3 "2022-03-10T22:04:12Z")

</div>

Many thanks for your response

The setEnabled function might work, though I’m not quite sure at what level it operates. I also suspect I may be confusing a gltf Mesh object with a Babylon Mesh object.

I have a fixed number of gltf meshes - which define actual geometries through vertex attributes. I also have a number of top level nodes which can reference/instance any one of those meshes at a different position in the scene. All nodes could instance the same mesh or all could instance different meshes. IIUC the setEnabled function would effectively operate at the level of the gltf node rather than the gltf mesh which might not solve my problem.

I’ll look into Babylon Playground to see if I can create a simple example to explore this further.

Thanks again.

---

<div class="post-metadata">

**Author:** ![Regit](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Regit](https://forum.babylonjs.com/u/Regit)\
**Post date:** [March 11, 2022, 10:45am UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/4 "2022-03-11T10:45:48Z")

</div>

If I understand you correctly, you’d have to `node.getChildMeshes()` or `scene.getMeshByName("")` to access the correct meshes. Obbiously you need some way to id the meshes you want to `setEnabled()`, be it via hardcoding or a specific way your gltf is structured.

---

<div class="post-metadata">

**Author:** ![DesG](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@DesG](https://forum.babylonjs.com/u/DesG)\
**Post date:** [March 11, 2022, 4:21pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/5 "2022-03-11T16:21:40Z")

</div>

Thanks.

I used getChildMeshes on each node and it returns the expected number of sub nodes, however calling setEnabled(false) on each of these has no effect. Oh well, need to dig deeper.

Thanks again.

---

<div class="post-metadata">

**Author:** ![DesG](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@DesG](https://forum.babylonjs.com/u/DesG)\
**Post date:** [March 11, 2022, 11:56pm UTC](https://forum.babylonjs.com/t/newbie-question-about-editing-of-scene-in-javascript/28302/6 "2022-03-11T23:56:53Z")

</div>

Dug deeper and discovered a bug in my code.  
Things work exactly as you advise. Many thanks!
