Failed to load buffer (.bin) - Three.JS

Viewed 1534

All the solutions for this problem seem to be the same - Put the .gltf & the .bin files in the same folder and then try. I have done this but im still getting this error and ive no idea as to why.

const loader = new GLTFLoader()
let mesh;

loader.load( './zippedFolder', function ( gltf ) {
  mesh = gltf.scene

  })

And the two files reside in a zipped folder. Any ideas?

1 Answers

You can't just ask the GLTFLoader to open a .zip file. It says in the documentation:

A loader for glTF 2.0 resources.

... not for .zip files.

You have to deliver both the .gltf and the .bin in their natural state. What you could do, however, is get your server to deliver assets with GZIP compression, which your browser knows to decompress automatically. But that's something that's handled in your server settings, not by manually converting to a .zip file.

Update: All you have to do is point the loader to the .gltf file, which contains a reference to the .bin file within. You can open it in a text editor, and you'll see something like this, the buffers.uri property has the path to the accompanying binary so the loader knows where to look for it:

"buffers" : [
    {
        "byteLength" : 69340,
        "uri" : "alloy.bin"
    }
]
Related