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
Gives expected Result:
const sphere = MeshBuilder.CreateSphere("sphere"); const vertexData = VertexData.ExtractFromMesh(sphere); vertexData.applyToMesh(new Mesh("clone"));
Gives broken Result:
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^