diff --git a/packages/frontend/src/utility/room/engine.ts b/packages/frontend/src/utility/room/engine.ts index 291b47af5a..2c5719dd01 100644 --- a/packages/frontend/src/utility/room/engine.ts +++ b/packages/frontend/src/utility/room/engine.ts @@ -228,15 +228,24 @@ class ModelManager { const toMerge = [] as BABYLON.Mesh[]; for (const mesh of _toMerge) { const newMesh = mesh.clone(mesh.name + '_bakeMerged'); - mesh.makeGeometryUnique(); + newMesh.makeGeometryUnique(); applyMorphTargetsToMesh(newMesh); + if (newMesh.parent === this.root) { + newMesh.parent = null; + } else { + newMesh.setParent(this.root); + //newMesh.bakeCurrentTransformIntoVertices(); + newMesh.parent = null; + } //newMesh.bakeCurrentTransformIntoVertices(); toMerge.push(newMesh); } const merged = BABYLON.Mesh.MergeMeshes(toMerge, true, true, undefined, false, true); - merged.setParent(this.root); + //merged.bakeCurrentTransformIntoVertices(); + + merged.parent = this.root; this.bakedMeshes = [merged]; } catch (err) { diff --git a/packages/frontend/src/utility/room/utility.ts b/packages/frontend/src/utility/room/utility.ts index 5d42fee019..7c1a63eb9c 100644 --- a/packages/frontend/src/utility/room/utility.ts +++ b/packages/frontend/src/utility/room/utility.ts @@ -532,12 +532,12 @@ export function applyMorphTargetsToMesh(mesh: BABYLON.Mesh) { // Update the mesh with the morphed positions mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, finalPositions); - // Update normals if available - const normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind); - if (normals) { - // For simplicity, we'll just recompute the normals - mesh.createNormals(true); - } + //// Update normals if available + //const normals = mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind); + //if (normals) { + // // For simplicity, we'll just recompute the normals + // mesh.createNormals(true); + //} // Refresh the mesh mesh.refreshBoundingInfo();