Skip to content

Commit f6c73bb

Browse files
fix gltf bug where scene can't be saved due to circular shadow generator JSON structure inside metadata
1 parent 050faa2 commit f6c73bb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • packages/dev/babylonjs/lib/api/bitbybit/babylon

packages/dev/babylonjs/lib/api/bitbybit/babylon/io.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ export class BabylonIO {
129129
}
130130
};
131131
}
132+
// we need to handle metadata otherwise gltf files may fail due to circular JSON structures
133+
const metadata = this.context.scene.metadata;
134+
delete this.context.scene.metadata;
132135
SERIALIZERS.GLTF2Export.GLBAsync(this.context.scene, inputs.fileName, options).then((glb) => {
133136
glb.downloadFiles();
137+
this.context.scene.metadata = metadata;
134138
});
135139
}
136140

@@ -167,11 +171,11 @@ export class BabylonIO {
167171
childrenMeshes = allChildren.filter(s => !(s instanceof BABYLON.LinesMesh || s instanceof BABYLON.GreasedLineMesh));
168172
}
169173
meshes.push(mesh);
170-
if(childrenMeshes.length > 0) {
174+
if (childrenMeshes.length > 0) {
171175
meshes.push(...childrenMeshes);
172176
}
173177
});
174-
178+
175179
SERIALIZERS.STLExport.CreateSTL(meshes as BABYLON.Mesh[], true, inputs.fileName, true, true, true);
176180
return Promise.resolve({});
177181
}

0 commit comments

Comments
 (0)