Programmatically generating bin files for GLTF models I have a need to generate a series of GLB files. I have a base template for a GLTF file which I have to derive off of. The models thus generated will only have varying textures on them. The base mesh doesn't change at all.

What Im stuck with

Im able to generate the GLB, GLTF files from blender when exporting 3D models. After feeding these two files to: https://sbtron.github.io/makeglb/ Im able to create a GLB file which loads and works fine, with all the textures included.

However I am unable to generate the bin file programmatically. Ive tried searching google for generate bin file from images, but the first few pages dont seem to have anything relating to this.

What Ive tried

Went through this question, but the selected answer there isnt dealing with images:

How to generate binary gltf array buffers?

How do I go about generating a BIN file from a series of images?
The .bin file that goes with a .gltf only includes mesh data (position, normal, uv, other vertex attributes as needed).  It does not normally include any images (unless you're using the base64 export "glTF Embedded", but don't use that for this, use "glTF Separate" instead).

If you look in the JSON text of the .gltf file, you'll see an images array, where image files are called out by uri (filename, if local, or relative URLs for the web).

Let's look at the Damaged Helmet sample model for an example.  The JPG images are called out in the .gltf file, separately from the .bin file.  The data from the .bin file is used by buffers, which in turn are used by bufferViews, accessors, and then mesh primitives.  It is exclusively vertex mesh data, no images.  This is a separate chain from how the JPGs are being used.  The JPGs are called out by images, which are referenced by textures which in turn are used by materials, which are referenced by mesh primitives.  For a more graphical version of this explanation, take a look at the Overview Chart for glTF.

So when exporting from Blender, choose glTF Separate from the combo box in the export options panel.  This will produce a .gltf file, a .bin file, and may copy several images (be sure to export to a different folder from your source files, so nothing gets overwritten).  To change the images, just update the uri fields in the images array inside of the .gltf file, and keep the same .bin file around (the one that came out of Blender).

That way, you can swap out images with other images, but keep the same mesh data.