Hi guys,
I tried following this official threejs example three.js examples to download a .glb file of a specific 3Dobject from my scene but I’m having some issues.
The actual mesh I would like to download is a BufferGeometry in my scene. Console.log of the result from the GLTFExporter is below.
The downloaded file keeps appearing as .gltf even if I put “binary” as an option. I don’t understand why ?
Could you please assist with this.
Thanks in advance,
scene.add(mesh);
console.log(mesh)
const exporter = new GLTFExporter();
const options = {
trs: true,
binary: true,
};
// Parse the input and generate the glTF output
exporter.parse(
mesh,
// called when the gltf has been generated
function (result) {
console.log(result)
if (result instanceof ArrayBuffer) {
saveArrayBuffer(result, "mesh.glb")
}
else {
const output = JSON.stringify(result, null, 2);
saveString(output, 'mesh.gltf');
}
},
// called when there is an error in the generation
function (error) {
console.log('An error happened');
},
options
);
console.log(mesh)
console.log(result)