The GLB boundary
Read one binary file. Expose its JSON and byte ranges.
GLB packages a JSON chunk and one or more binary chunks into a single file. The loader preserves chunk offsets and lengths so higher-level code can decide how to interpret them.
Input
`.glb` binary data
Envelope
Header, version, and chunk lengths
JSON
Parsed glTF or application JSON
Binary
One or more ArrayBuffer chunks
The GLBLoader parses a GLB binary "envelope" extracting the embedded JSON and binary chunks.
- Use
GLTFLoaderwhen the binary envelope contains a glTF scene and linked resources should be resolved for you. - Use
GLBLoaderwhen an application needs to inspect, preserve, or reinterpret the JSON and binary chunks directly.
| Input | Output | APIs |
|---|---|---|
.glb binary data | Header metadata, parsed JSON, and one or more binary chunks | load, parse, parseSync |
The loader reads GLB v1 and v2 files, plus the draft GLB v3 chunk layout. GLB v1 is returned in
the standard GLB shape with version: 1; it is not silently presented as a v2 file.
Usage
Detailed guide
Container and data-shape details
The reference below covers supported GLB versions, options, parsed output fields, chunk offsets, and the distinction from GLTFLoader.
import {load} from '@loaders.gl/core';
import {GLBLoader} from '@loaders.gl/scene/gltf';
const gltf = await load(url, GLBLoader);
Options
| Option | Type | Default | Description |
|---|---|---|---|
glb.strict (DEPRECATED) | Boolean | false | Whether to reject deprecated XVIZ chunk type numbers; false keeps compatibility. |
Remarks:
- Parses GLB v2 encoded data.
- Parses draft GLB v3 encoded data, including 64-bit file/chunk lengths and multiple binary chunks.
- Parses GLB v1 encoded data (enabling support for the glTF v1
KHR_binary_gltfextension). - Extracts multiple binary chunks if present, even though the glTF specification normally uses one.
Data Format
Returns
{
"header": {
"byteLength": number,
"byteOffset": number
},
"type": string,
"version": number,
// JSON Chunk
"json": any,
// BIN Chunk
"hasBinChunk": boolean,
"binChunks": [
{
"arrayBuffer": ArrayBuffer,
"byteOffset": Number,
"byteLength": Number
}
]
}
| Field | Type | Default | Description |
|---|---|---|---|
type | String | glTF | String containing the first four bytes of the file |
version | Number | 2 | The GLB version number |
json | Object | {} | Parsed JSON from the JSON chunk |
binChunks | ArrayBuffer | null | The binary chunk |
binChunks[\*].arrayBuffer | ArrayBuffer | null | The binary chunk |
binChunks[\*].byteOffset | Number | null | offset of BIN (e.g. embedded in larger binary block) |
binChunks[\*].byteLength | ArrayBuffer | null | length of BIN (e.g. embedded in larger binary block) |
header.byteLength | Number | - | length of GLB (e.g. embedded in larger binary block) |
header.byteOffset | Number | 0 | offset of GLB (e.g. embedded in larger binary block) |