When I export a Blender model to .gltf file, it will output a.gltf
and a.bin
file.
What do I do with the .bin file in loader.load() ?
GLTFLoader only requires the path (or URL) of the .gltf
, and then the .gltf
file itself will tell the loader where to find the .bin
file. So wherever you put the .gltf
file in your server or project, put the .bin
file in the same place. If you have textures in Blender, they’ll also be saved alongside the other two files, and similarly should be kept together. In this example…
var loader = new THREE.GLTFLoader();
loader.load('model.gltf', function (gltf) {...});
… the loader can automatically find .bin
files and textures associated with model.gltf
, as long as they’re all kept in the same place relative to the glTF file.
If you’d rather not deal with multiple different file, export to GLB (.glb
) instead and they’ll all be packed into one binary file, which also works with GLTFLoader:
var loader = new THREE.GLTFLoader();
loader.load('model.glb', function (gltf) {...});
why we need bin file what it do ?
The .bin
file contains binary data referenced by the .gltf
file, like vertex properties or animations.
If you want to deal with only a single file you can package all of the files into a .glb
with https://glb-packer.glitch.me/ or glTF-Pipeline.