Skip to content

Commit 0c3045e

Browse files
committed
fix(web): preserve texture references in GLTF viewer material cloning
Fixes texture loss issue where cloning textures in cloneSceneWithMaterials was breaking glTF texture data. Now preserves original texture references to maintain texture integrity during material cloning.
1 parent 8278bda commit 0c3045e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

  • apps/web/src/components/workflow/gltf-viewer

apps/web/src/components/workflow/gltf-viewer/utils.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ export function cloneSceneWithMaterials(source: Group): Group {
6767

6868
const cloneMaterial = (mat: Material): Material => {
6969
const clonedMat = mat.clone();
70-
// Clone key textures if present
7170
const anyMat = clonedMat as any;
72-
if (anyMat.map) anyMat.map = anyMat.map.clone();
73-
if (anyMat.normalMap) anyMat.normalMap = anyMat.normalMap.clone();
74-
if (anyMat.roughnessMap) anyMat.roughnessMap = anyMat.roughnessMap.clone();
75-
if (anyMat.metalnessMap) anyMat.metalnessMap = anyMat.metalnessMap.clone();
76-
if (anyMat.emissiveMap) anyMat.emissiveMap = anyMat.emissiveMap.clone();
71+
const originalMat = mat as any;
72+
73+
if (originalMat.map) anyMat.map = originalMat.map;
74+
if (originalMat.normalMap) anyMat.normalMap = originalMat.normalMap;
75+
if (originalMat.roughnessMap)
76+
anyMat.roughnessMap = originalMat.roughnessMap;
77+
if (originalMat.metalnessMap)
78+
anyMat.metalnessMap = originalMat.metalnessMap;
79+
if (originalMat.emissiveMap) anyMat.emissiveMap = originalMat.emissiveMap;
80+
7781
anyMat.needsUpdate = true;
7882
return clonedMat;
7983
};

0 commit comments

Comments
 (0)