# Convert glb to babylon, the model have some meshes with wrong position

**URL:** <https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130>\
**Category:** Questions\
**Created:** [May 7, 2022, 6:23am UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130 "2022-05-07T06:23:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaopangoo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiaopangoo/32/23507_2.png) [@xiaopangoo](https://forum.babylonjs.com/u/xiaopangoo)\
**Post date:** [May 7, 2022, 6:23am UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/1 "2022-05-07T06:23:35Z")

</div>

I want to use babylon file and only have glb file. So I use a webpage to convert glb to babylon file.Finally I get a babylon file,but the model in babylon file seems have som meshes with wrong position.

 ![glb](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/a/0a2f2aca059b2f47c42fd529cd976d5c19228fb8.png)  
 ![load glb or babylon](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/3/a3a221b63d90a52dba911628b95dae00b46d3003.png)  
 ![glbtobabylon](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/d/0d972fe684207259c1dab6fcd7fde4989e10e467.png)  
 ![babylon](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/6/b6fb1d19d635f4a56153f5b2533647cffea2b96f.png)  
This is origin glb file.

> **[final1\_old.glb](https://drive.google.com/file/d/1A4f9cvbkho3IevLNTWhWwwVLjAoh1AqN/view?usp=sharing)**
>
> Google Drive file.

This is webpage used to convert glb to babylon.

> **[Test\_babylonjs\_gltftobabylon.rar](https://drive.google.com/file/d/1rYehtF1DV1mLuH2_CKG8P_ndaDllryrB/view?usp=sharing)**
>
> Google Drive file.

This is babylon file exported by webpage.

> **[final1\_old.babylon](https://drive.google.com/file/d/1MzbhZf2XWQbdIPGR1TvsRr0sNpDznZv8/view?usp=sharing)**
>
> Google Drive file.

---

<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:** [May 9, 2022, 1:28pm UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/2 "2022-05-09T13:28:03Z")

</div>

cc @bghgary

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 1:30pm UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/3 "2022-05-09T13:30:41Z")

</div>

Hello! Have you tried to use the Sandbox ([sandbox.babylonjs.com](http://sandbox.babylonjs.com)) to convert from GLB to babylon? Is the result the same? 🙂

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/1/8199db960be247f39fb0464d9c79897337f2fbb3.png)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [May 9, 2022, 11:44pm UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/4 "2022-05-09T23:44:55Z")

</div>

I tried loading the `final1_old.glb` into the sandbox and export to `.babylon` and then reload in sandbox. That seems to be working.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [May 10, 2022, 12:40am UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/5 "2022-05-10T00:40:37Z")

</div>

@xiaopangoo You seem to be mucking with the ids/names in the scene before exporting. Does it work if you don’t muck with the names?

```auto
					//material.id处理
					for(var i=0; i<scene.meshes.length;i++){
						var newId = createUuid();
						console.log(i + '--' + scene.meshes[i].name);
						console.log(scene.meshes[i].material);
						if(scene.meshes[i].material){
							console.log(i + '--' + scene.meshes[i].material.id+ '--' + newId);
							scene.meshes[i].material.id = newId;
							scene.meshes[i].material.name = newId;
						}
					}
					
					//geometry.uniqueId,geometry.id处理
					for(var i=0; i<scene.meshes.length;i++){
						var newId = createUuid();
						console.log(i + '--' + scene.meshes[i].name);
						console.log(scene.meshes[i].geometry);
						if(scene.meshes[i].geometry){
							console.log(i + '--' + scene.meshes[i].geometry.id+ '--' + scene.meshes[i].geometry.uniqueId + '--' + newId);
							scene.meshes[i].geometry.id = newId;
							scene.meshes[i].geometry.uniqueId = newId;
						}
					}
					
					//skeletonId处理
					for(var i=0; i<scene.skeletons.length;i++){
						var newId = createUuid();
						console.log(i + '--' + scene.skeletons[i].id + '--' + newId);
						scene.skeletons[i].id = newId;
						scene.skeletons[i].name = newId;
					}
					
					//id,uniqueId处理
					for(var i=0;i<scene.getNodes().length;i++){
						var tmpNode = scene.getNodes()[i];
						console.log(i+'--' + tmpNode.name + '--' + tmpNode.id + '--'+ tmpNode.uniqueId );
						//根节点名字处理
						if(i === 0){
							tmpNode.name = fileName.split('.')[0];
						}
						tmpNode.id = createUuid();
						tmpNode.uniqueId = tmpNode.id;
						console.log(i+'--' + tmpNode.name + '--' + tmpNode.id + '--'+ tmpNode.uniqueId );
						console.log(tmpNode.parent);
					}

```

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [June 8, 2022, 4:40pm UTC](https://forum.babylonjs.com/t/convert-glb-to-babylon-the-model-have-some-meshes-with-wrong-position/30130/6 "2022-06-08T16:40:00Z")

</div>

Hello @xiaopangoo just checking in, are you still having issues?
