# Flipped faces when manually cloning gltf vertexdata

**URL:** <https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153>\
**Category:** Bugs\
**Tags:** gltf, mesh, vertex\
**Created:** [November 30, 2022, 11:36pm UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153 "2022-11-30T23:36:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdup](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jdup/32/28429_2.png) [@jdup](https://forum.babylonjs.com/u/jdup)\
**Post date:** [November 30, 2022, 11:36pm UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153/1 "2022-11-30T23:36:45Z")

</div>

Hello there!  
Got a weird issue that I can’t make sense of. I need to clone a fairly large mesh across scenes which isn’t supported by the standard mesh cloning operations. I only need the mesh geo in the second scene, so to work around this, I’m trying to clone a mesh by manually extracting and then applying the VertexData.

This works fine except on GLTF models. When manually inspecting the vertex data after the clone, everything(indices, positions, normals, etc) seems to be identical, as expected, but for whatever reason, the rendered object has flipped faces and an offset origin.

Playground Repro: [https://playground.babylonjs.com/#S66FLG](https://playground.babylonjs.com/#S66FLG)

Gives expected Result:

```auto
const sphere = MeshBuilder.CreateSphere("sphere");
const vertexData = VertexData.ExtractFromMesh(sphere);
vertexData.applyToMesh(new Mesh("clone"));

```

Gives broken Result:

```auto
const gltfModel = SceneLoader.ImportMesh(...)
const vertexData = VertexData.ExtractFromMesh(gltfModel);
vertexData.applyToMesh(new Mesh("clone"));

```

* * *

- Blue: Original GLTF Import
- Red: Extract \> Apply of Blue^
  - This is the primary problem example. Inverted faces. Offset Position.

- Purple: Extract \> Apply \> mesh.flipFaces()
- Yellow: MeshBuilder.CreateSphere()
- Green: Extract \> Apply of Yellow^

 ![Screen Shot 2022-11-30 at 5.26.05 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/4/448a3708338fe0d2de72441e5f70eb1414756d9a.png)

Showing Normals:

 ![Screen Shot 2022-11-30 at 5.31.25 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/1/e10df7a9a9ea27d780d66481a080f58135adea26.png)

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [December 1, 2022, 9:39am UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153/2 "2022-12-01T09:39:45Z")

</div>

Hi @jdup and welcome to the forum !

Do you clone the material as well? Might be related to different back face culling property.

> **[Introduction To Materials | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/materials/using/materials_introduction#back-face-culling)**
>
> Jump into the exciting world of learning to use Babylon.js materials.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 1, 2022, 10:14am UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153/3 "2022-12-01T10:14:28Z")

</div>

Welcome aboard!

What you are missing is the `Mesh.overrideMaterialSideOrientation` property that the glTF loader is setting at load time. You should copy this value from `gltfOriginal` to `gltfClone`:

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

---

<div class="post-metadata">

**Author:** ![jdup](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jdup/32/28429_2.png) [@jdup](https://forum.babylonjs.com/u/jdup)\
**Post date:** [December 1, 2022, 4:12pm UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153/4 "2022-12-01T16:12:23Z")

</div>

ugh! I overlooked looked that - thanks!

Any idea on the position change? I’m not seeing that with my assets, however the inconsistency makes me nervous about some future model having this issue.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 1, 2022, 4:30pm UTC](https://forum.babylonjs.com/t/flipped-faces-when-manually-cloning-gltf-vertexdata/36153/5 "2022-12-01T16:30:15Z")

</div>

Currently, only the glTF loader is using this property AFAIK. But it’s safe to copy it even if it is `undefined`, so you can in all cases simply copy the property from the source object to the destination.
