I used GLFTExpoter to download file as a glft format but i get some error in my console that is downloadJSON is not define
code of function
//gltf exporter
function SaveDesign(e) {
e.preventDefault();
var data = blueprint3d.model.exportSerialized();
var exporter = new THREE.GLTFExporter();
exporter.parse(data, function (result) {
var output = JSON.stringify(result, null, 2);
console.log(output);
downloadJSON(output, "scene.gltf");
});
}
According to my detectivistic instincts, it could only mean that Mozilla blog used a sample snippet from Three’s documentation and the owners of Three repository should now continue with a legal action against this obvious copyright infringement, become billionaires overnight due to a polite court settlement, and spend the rest of their lives sipping tequila in Bali.
(Also, read the article further, in the A-Painter exporter paragraph they virtually show a working example of downloading a model, with a full code. :’) )
JSON.stringify() is being called twice on the same data, that’s my mistake… instead of calling downloadJSON … try… saveString( output, 'scene.gltf' );
What is the output of blueprint3d.model.exportSerialized();? Is that a three.js scene? I can’t tell you what to expect without knowing what your code does.
In the example you share, here’s the code I see:
When I press “Save” It does save the file, and that file contains the same JSON that exportSerialized() returns. It’s not three.js or glTF data, so I can’t tell you if it’s correct. It’s not a glTF file.
The data coming out of exportSerialized(), at least in the link you shared, is custom JSON that nothing in three.js, including GLTFExporter, can understand. If you need help debugging custom code you will have to share enough of that for us to fully reproduce the error. The code you shared above does not attempt to create a glTF file, so I’m not sure how to help you.
It’s probably possible, but it’s a proprietary format — only the authors of that custom JSON know what it means, unless you manage to reverse engineer it. You probably won’t be able to find any pre-existing tool that can convert it to anything else.
You are asking us how to reverse engineer someone else’s custom data format. Only the author knows, and it would take anyone else a lot of effort to learn. Sorry, but I can’t help you with that. I would suggest that you ask the author on GitHub (it looks like you already have?), or hire someone to do this, or find a way to solve your problem without using this proprietary format.