Convert scene to JSON file and download

Hi!
I have a simple scene - one THREE.Object3D and a few OBJ models.
I want to convert data of the scene to JSON file and give to user possibilities to download this file.

Below is the code. This code works to a small objects but not in this case. It means - it works, file is download but i can’t opened it. :smiley: I think - it’s too large and this is a problem.

function saveLikeJSON(){
var dataJSON = {scene: scene.children} 
var dataJson = JSON.stringify(dataJSON); // // I try  JSON.stringify(scene) but it is wrong solution too
downloadTextFile(dataJson,"p")

}

function downloadTextFile(text, name) {
const a = document.createElement('a');
const type = name.split(".").pop();
a.href = URL.createObjectURL( new Blob([text], { type:`text/${type === "txt" ? "plain" : type}` }) );
a.download = name;
a.click();
}

How download only nessesary information about the scene and convert they to json file?

What you do you mean with “necessary information”? When calling Scene.toJSON() the entire scene graph is serialized which is important if you want to deserialize it at a later point. It’s not possible to restrict the serialization to a subset of information.

“Necessary information” is for my all information to need to the deserialize later.
Ok, i understand that i must use scene.toJSON() - and above code works for it - today file is opening (for a long time but i can open it, i think mistake was my impatience - too early i gave up waiting for opening).

This file is large - circa 240MB. If is any solution to convert a a file to a smaller size (or maybe I do not have to care and leave it as it is? ) to be able to use it later?