An import that fails with "unsupported file" teaches you nothing. Reading the GLB first tells you what is actually inside: how many meshes, whether they carry names, how many primitives each one has and how many triangles the whole asset costs. All of that can be learned locally in a few milliseconds, before an engine is involved.

What a GLB file is made of

A GLB is a single binary container (glTF 2.0 specification, §4.4). The first twelve bytes are a header: a four-byte magic value spelling glTF, a four-byte version, and a four-byte total length. Everything after that is one or more chunks, each with its own length, type and payload.

  • JSON chunk – the glTF document itself: asset metadata, scenes, nodes, meshes, primitives, accessors, materials.
  • BIN chunk – the raw buffer holding vertex positions, indices, normals and texture data referenced by the accessors.

Chunks are aligned to four-byte boundaries, so a naive byte offset recount will drift on oddly sized JSON. The padding is why a hand-written parser that assumes "JSON ends where the next chunk starts" produces garbage on some files and works on others.

Why inspect before import

Four problems show up in the file and nowhere else.

Missing or duplicated names. A part-controllable export is only useful if each mesh carries its part name. A converter that drops names leaves you with mesh_0 through mesh_5 and no mapping back to the schema. Duplicate names are worse: two meshes both called lid will resolve unpredictably in every engine that looks up by name.

Multiple primitives per part. glTF meshes contain primitives, usually one per material. A "single part" with four materials is four draw calls in the engine, not one. The triangle budget can look fine while the draw-call count quietly doubles.

Unexpected triangle counts. A lid at 80,000 triangles and a base at 2,000 tells you something went wrong in export ordering or LOD assignment. You want to know that before it reaches a reviewer.

Truncation. A file whose header length disagrees with its actual byte length is a broken download or a failed write. Importers are inconsistent about reporting this; the header check is one comparison.

Counting triangles correctly

Triangle counts come from the accessor referenced by a primitive. For indexed geometry that is the index accessor; for non-indexed geometry it is the POSITION attribute. The primitive's mode decides the arithmetic, and the mode numbers below come from the glTF 2.0 specification:

  • mode 4 (TRIANGLES): accessor count divided by three.
  • mode 5 (TRIANGLE_STRIP) and mode 6 (TRIANGLE_FAN): accessor count minus two.
  • Point and line modes contribute no triangles and should be reported as such rather than counted as zero silently.

This is the same number an engine will report after triangulation for the overwhelming majority of exports. It is not a substitute for an engine's render statistics — instancing, culling and LOD selection all change what is actually drawn — but it is the right number for a budget check.

Local GLB inspector

Reads the file in this browser and lists mesh names, primitives and triangle counts. The file is never uploaded; geometry is not rendered.

What the inspector cannot tell you

Metadata is not quality. The inspector will not tell you whether normals are smooth, whether UVs overlap, whether the mesh is watertight, or whether the pivot is sensible. Those require geometry processing, and some of them — pivot placement, for instance — live in node transforms rather than in mesh data at all.

It also will not tell you whether the parts look right together. Two meshes can both be valid and still intersect by three centimetres, which is a visual review, not a file review.

Use it for the cheap deterministic questions and keep the expensive judgement for a viewer.

Wiring a check into a build

The same parse can run outside the browser. A short Node script that reads a file, validates the magic and prints mesh names and triangle counts is enough to fail a build when an export drops a name:

import { readFileSync } from 'node:fs';
const buf = readFileSync(process.argv[2]);
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
if (view.getUint32(0, true) !== 0x46546C67) throw new Error('not a GLB');
const jsonLength = view.getUint32(12, true);
const json = JSON.parse(buf.subarray(20, 20 + jsonLength).toString('utf8'));
const names = (json.meshes ?? []).map((m, i) => m.name ?? `mesh_${i}`);
if (new Set(names).size !== names.length) throw new Error('duplicate mesh names');
console.log(names.join('\n'));

Thirty lines of script catch the failures that otherwise surface as a silently missing lid three weeks later. That is a good trade.

A review sequence that scales

  1. Check the header: magic, version 2, declared length equals file length.
  2. List mesh names and compare them to the schema, in order and in spelling.
  3. Count primitives per mesh; anything above one is an extra draw call you should be able to explain.
  4. Sum triangles and compare with the budget for that asset class.
  5. Open one part in a viewer and check the seam against its neighbour.
  6. Import one representative part into the target engine and confirm name, scale and pivot before importing the rest.

Doing this in that order means the first expensive step — the engine import — happens with expectations already set. When something is wrong you know whether it was in the file or in the import, which halves the debugging.

Scenes, nodes and where pivots really live

A glTF file has meshes and it has nodes. Meshes hold geometry; nodes hold transforms and point at meshes. The name in the engine usually comes from the node, not from the mesh, and the pivot is the node's transform origin. Two files can contain identical mesh data and behave completely differently because one node sits at the object's centre and the other sits at a corner.

This is why a name check alone is not enough. An export can produce a mesh named lid whose node is called node_7, and an engine that imports node names will present node_7 in the hierarchy. When you inspect, compare the node names you plan to script against, not just the mesh list. If your importer renames nodes, decide once which one wins and make the schema match it.

The scene list matters for a smaller reason: a GLB can contain multiple scenes, and an importer may load only the default one. If half your parts live in a scene that is not the default, they will be absent from the import with no error. The inspector reports the scene count for exactly this reason — a part export should have one scene.

A worked reading

Imagine the inspector reports five meshes and the schema listed six. The triangle total looks plausible, names look clean, and the file opens without complaint. Where is the sixth part?

Three explanations cover almost every case. The exporter merged two parts that shared a material, which is common when a converter optimises by material rather than by node. The part was inside a non-default scene. Or the part was produced as an empty mesh node with no primitives, which glTF permits and many exporters silently drop.

Each has a different fix: re-export without the material merge, fix the scene, or regenerate the missing part. None of them is discoverable from an engine error message that says "imported 5 objects". The count comparison is the diagnostic, and it takes one glance once the file is read locally.

Deterministic checks beat visual hope

The reason to formalise these checks is that they are cheap, repeatable and independent of taste. A reviewer looking at a viewer will notice a missing lid; a reviewer looking at forty assets will not. A script that compares mesh names against the schema will, every time, and it will say which one is absent.

Keep the schema and the file in the same repository and run the comparison in whatever pipeline already exists. The check needs no GPU, no network and no credentials — which means it can run on every commit, including the ones that only touch documentation.