Downloading a glb file with GLTFExporter

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)

Anybody would be kind enough to give this a shot ?
Thank you

The code above looks fine to me, I don’t see any obvious difference from usage in this example, which does work correctly.

If you’re able to make a demo (JSFiddle, Codepen, Github repo, etc…) that reproduces the problem, I would recommend filing a bug!